[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qsos-commits] qsos/apps/xuleditor/chrome/content Document.js ...
From: |
Raphaël Semeteys |
Subject: |
[Qsos-commits] qsos/apps/xuleditor/chrome/content Document.js ... |
Date: |
Mon, 22 May 2006 00:25:46 +0000 |
CVSROOT: /sources/qsos
Module name: qsos
Branch:
Changes by: Raphaël Semeteys <address@hidden> 06/05/22 00:25:46
Modified files:
apps/xuleditor/chrome/content: Document.js editor.js editor.xul
Log message:
Chart navigation bar added
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qsos/qsos/apps/xuleditor/chrome/content/Document.js.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/qsos/qsos/apps/xuleditor/chrome/content/editor.js.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/qsos/qsos/apps/xuleditor/chrome/content/editor.xul.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: qsos/apps/xuleditor/chrome/content/Document.js
diff -u qsos/apps/xuleditor/chrome/content/Document.js:1.5
qsos/apps/xuleditor/chrome/content/Document.js:1.6
--- qsos/apps/xuleditor/chrome/content/Document.js:1.5 Thu May 18 22:04:09 2006
+++ qsos/apps/xuleditor/chrome/content/Document.js Mon May 22 00:25:46 2006
@@ -81,6 +81,7 @@
this.getcomplextree = getcomplextree;
this.getChartData = getChartData;
this.getSubChartData = getSubChartData;
+ this.getChartDataParent = getChartDataParent;
////////////////////////////////////////////////////////////////////
// QSOS XML file functions
@@ -561,6 +562,16 @@
// Chart functions
////////////////////////////////////////////////////////////////////
+ function getChartDataParent(name) {
+ var node = sheet.evaluate("//address@hidden'"+name+"']", sheet, null,
XPathResult.ANY_TYPE,null).iterateNext();
+ if (node) {
+ return node.parentNode.getAttribute("name");
+ }
+ else {
+ return null;
+ }
+ }
+
function getChartData() {
var chartData = new Array();
var sections = sheet.evaluate("//section", sheet, null,
XPathResult.ANY_TYPE,null);
Index: qsos/apps/xuleditor/chrome/content/editor.js
diff -u qsos/apps/xuleditor/chrome/content/editor.js:1.5
qsos/apps/xuleditor/chrome/content/editor.js:1.6
--- qsos/apps/xuleditor/chrome/content/editor.js:1.5 Thu May 18 22:18:01 2006
+++ qsos/apps/xuleditor/chrome/content/editor.js Mon May 22 00:25:46 2006
@@ -105,6 +105,8 @@
//Draw top-level SVG chart
drawChart();
+
+ window.sizeToContent();
}
}
@@ -224,6 +226,7 @@
var tree = document.getElementById("mytree");
var treechildren = document.getElementById("myTreechildren");
tree.removeChild(treechildren);
+ clearChart()
}
//Checks Document's state before closing it
@@ -451,17 +454,38 @@
const SCALE = 100;
const FONT_SIZE = SCALE/10;
-//Draw the SVG chart of a criterion
-//criterion: if not specified, the top-level chart of sections is displayed
-function drawChart(criterion) {
+//Clear the SVG chart
+function clearChart() {
var myChart = document.getElementById("chart");
- //Delete pre-existing chart
while (myChart.firstChild) {
myChart.removeChild(myChart.firstChild);
}
+}
+
+//Draw the SVG chart of a criterion
+//criterion: if not specified, the top-level chart of sections is displayed
+function drawChart(name) {
+ clearChart();
+ var myChart = document.getElementById("chart");
+ var width = myChart.parentNode.width.baseVal.value / 2;
+ var height = myChart.parentNode.height.baseVal.value / 2;
+ myChart.setAttribute("transform", "translate("+width+","+height+")");
//Collect charting data
- var myScores =
(criterion)?myDoc.getSubChartData(criterion):myDoc.getChartData();
+ var myScores = (name)?myDoc.getSubChartData(name):myDoc.getChartData();
+
+ //Chart's label
+ clearLabels();
+ var marker = null;
+
+ if (name) marker = addLabel(name, null);
+ var parentName = myDoc.getChartDataParent(name);
+
+ while (parentName != null) {
+ marker = addLabel(parentName, marker);
+ parentName = myDoc.getChartDataParent(parentName);
+ }
+ addFirstLabel(marker);
//draw chart's axis
drawAxis(myScores.length);
@@ -487,6 +511,47 @@
myChart.appendChild(myPath);
}
+function addFirstLabel(marker) {
+ var label = document.getElementById("chart-label");
+ var newLabel = document.createElement("label");
+ newLabel.setAttribute("value", myDoc.getappname() + " " +
myDoc.getrelease());
+ newLabel.setAttribute("onclick", "drawChart()");
+ newLabel.style.cursor = "pointer";
+
+ if (marker) {
+ label.insertBefore(newLabel, marker);
+ }
+ else {
+ label.appendChild(newLabel);
+ }
+
+ return newLabel;
+}
+
+function addLabel(name, marker) {
+ var label = document.getElementById("chart-label");
+ var newLabel = document.createElement("label");
+ newLabel.setAttribute("value", "> " + myDoc.getkeytitle(name));
+ newLabel.setAttribute("onclick", "drawChart(\"" + name + "\")");
+ newLabel.style.cursor = "pointer";
+
+ if (marker) {
+ label.insertBefore(newLabel, marker);
+ }
+ else {
+ label.appendChild(newLabel);
+ }
+
+ return newLabel;
+}
+
+function clearLabels() {
+ var label = document.getElementById("chart-label");
+ while (label.firstChild) {
+ label.removeChild(label.firstChild);
+ }
+}
+
//draw "n" equidistant axis
function drawAxis(n) {
drawCircle(0.5*SCALE);
@@ -553,12 +618,11 @@
}
else {
myText.setAttribute("fill", "red");
- myText.setAttribute("text-decoration", "line-through");
}
if (myScore.children) {
myText.setAttribute("onclick", "drawChart(\"" + myScore.name +
"\")");
- myText.setAttribute("text-decoration", "underline");
+ myText.style.cursor = "pointer";
}
myText.appendChild(document.createTextNode(myScore.title));
@@ -570,5 +634,5 @@
myX = (Math.abs(x)==x)?x:x-myTextLength;
myY = (Math.abs(y)==y)?y+FONT_SIZE:y;
myText.setAttribute("x", myX);
- myText.setAttribute("y", myY)
+ myText.setAttribute("y", myY);
}
\ No newline at end of file
Index: qsos/apps/xuleditor/chrome/content/editor.xul
diff -u qsos/apps/xuleditor/chrome/content/editor.xul:1.5
qsos/apps/xuleditor/chrome/content/editor.xul:1.6
--- qsos/apps/xuleditor/chrome/content/editor.xul:1.5 Thu May 18 22:19:00 2006
+++ qsos/apps/xuleditor/chrome/content/editor.xul Mon May 22 00:25:46 2006
@@ -92,9 +92,12 @@
</vbox>
</tabpanel>
<tabpanel>
- <svg xmlns="http://www.w3.org/2000/svg"
version="1.1">
- <g id="chart"
transform="translate(300,300)"/>
- </svg>
+ <vbox id="chart-box">
+ <hbox id="chart-label" />
+ <svg xmlns="http://www.w3.org/2000/svg"
version="1.1" width="100%" height="100%">
+ <g id="chart" />
+ </svg>
+ </vbox>
</tabpanel>
</tabpanels>
</tabbox>
- [Qsos-commits] qsos/apps/xuleditor/chrome/content Document.js ...,
Raphaël Semeteys <=