Author: jflesch
Date: 2007-08-26 15:34:33 +0000 (Sun, 26 Aug 2007)
New Revision: 14884
Modified:
trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java
trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/GraphBuilder.java
trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/Node.java
Log:
Make the use of the 'compute' button in the index web grapher clearer
Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-08-26
14:25:18 UTC (rev 14883)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-08-26
15:34:33 UTC (rev 14884)
@@ -642,6 +642,8 @@
thaw.plugin.indexWebGrapher=Une tentative de repr?sentation de la toile des
indexes
thaw.plugin.indexWebGrapher.shortName=Toile d'indexes
thaw.plugin.indexWebGrapher.compute=Calculer
+thaw.plugin.indexWebGrapher.faster=Plus vite
+thaw.plugin.indexWebGrapher.stop=Arr?t
thaw.plugin.indexWebGrapher.computing=En cours ...
thaw.plugin.indexWebGrapher.waiting=En attente
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-08-26 14:25:18 UTC
(rev 14883)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-08-26 15:34:33 UTC
(rev 14884)
@@ -660,6 +660,8 @@
thaw.plugin.indexWebGrapher=An attempt to draw a graph of the index web
thaw.plugin.indexWebGrapher.shortName=Index web
thaw.plugin.indexWebGrapher.compute=Compute
+thaw.plugin.indexWebGrapher.faster=Faster
+thaw.plugin.indexWebGrapher.stop=Stop
thaw.plugin.indexWebGrapher.computing=Computing
thaw.plugin.indexWebGrapher.waiting=Waiting
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-08-26 14:25:18 UTC
(rev 14883)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-08-26 15:34:33 UTC
(rev 14884)
@@ -642,6 +642,8 @@
thaw.plugin.indexWebGrapher=Une tentative de repr\u00e9sentation de la toile
des indexes
thaw.plugin.indexWebGrapher.shortName=Toile d'indexes
thaw.plugin.indexWebGrapher.compute=Calculer
+thaw.plugin.indexWebGrapher.faster=Plus vite
+thaw.plugin.indexWebGrapher.stop=Arr\u00eat
thaw.plugin.indexWebGrapher.computing=En cours ...
thaw.plugin.indexWebGrapher.waiting=En attente
Modified: trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java 2007-08-26
14:25:18 UTC (rev 14883)
+++ trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java 2007-08-26
15:34:33 UTC (rev 14884)
@@ -148,14 +148,19 @@
public void actionPerformed(ActionEvent e) {
if (e.getSource() == compute) {
if (lastBuilder == null || lastBuilder.isFinished()) {
+
compute.setText(I18n.getMessage("thaw.plugin.indexWebGrapher.faster"));
+
lastBuilder = new GraphBuilder(this,
graphPanel, db);
Thread th = new Thread(lastBuilder);
th.start();
} else {
- if (!lastBuilder.fasterFlag())
+ if (!lastBuilder.fasterFlag()) {
+
compute.setText(I18n.getMessage("thaw.plugin.indexWebGrapher.stop"));
lastBuilder.setFasterFlag(true);
- else
+ } else {
+
compute.setText(I18n.getMessage("thaw.plugin.indexWebGrapher.compute"));
lastBuilder.stop();
+ }
}
} else if (e.getSource() == zoomIn) {
graphPanel.zoomIn();
@@ -165,4 +170,9 @@
graphPanel.refresh();
}
}
+
+
+ public void endOfProcess() {
+
compute.setText(I18n.getMessage("thaw.plugin.indexWebGrapher.compute"));
+ }
}
Modified: trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/GraphBuilder.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/GraphBuilder.java
2007-08-26 14:25:18 UTC (rev 14883)
+++ trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/GraphBuilder.java
2007-08-26 15:34:33 UTC (rev 14884)
@@ -50,7 +50,7 @@
graphPanel.refresh();
try {
- Thread.sleep(faster /* == separate
thread */ ? 5000 : 50 );
+ Thread.sleep(50);
} catch(InterruptedException e) {
/* \_o< */
}
@@ -170,7 +170,7 @@
Node node = (Node)it.next();
if (!node.isPositionSet()) {
node.setPosition(x, 0.0);
- node.setInitialNeightboorPositions();
+ node.setInitialNeightbourPositions();
x += ((Node.FACTOR_INITIAL_DISTANCE *
node.getLinkCount())+1);
}
}
@@ -195,6 +195,8 @@
int lastStep = 4;
double totalKinetic = 0.0;
+ double sumKinetics = 0.0;
+ int nmbKinetics = 0;
for (int i = 0 ; i < Node.NMB_STEPS && !stop ; i++) {
int currentStep = (6 * i) / Node.NMB_STEPS;
@@ -216,9 +218,16 @@
}
}
- if (i%100 == 0) {
+ if (i != 0) {
+ sumKinetics += totalKinetic;
+ nmbKinetics++;
+ }
+
+ if (i != 0 && i%100 == 0) {
+ Logger.info(this,
"================================");
Logger.info(this, "- Step
"+Integer.toString(i)+"/"+Node.NMB_STEPS);
Logger.info(this, "- Kinetic :
"+Double.toString(totalKinetic));
+ Logger.info(this, "- Average kinetic :
"+Double.toString(sumKinetics/nmbKinetics));
}
totalKinetic = 0.0;
@@ -229,7 +238,7 @@
totalKinetic += node.computeVelocity(nodes);
}
- if (totalKinetic < Node.MIN_KINETIC) {
+ if (totalKinetic < (Node.MIN_KINETIC)) {
Logger.info(this, "Wow, seems optimized :)");
break;
}
@@ -268,6 +277,8 @@
}
finish = true;
+
+ plugin.endOfProcess();
} /* /run */
Modified: trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/Node.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/Node.java 2007-08-26
14:25:18 UTC (rev 14883)
+++ trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/Node.java 2007-08-26
15:34:33 UTC (rev 14884)
@@ -125,8 +125,8 @@
public final static double FACTOR_REPULSION = 1;
public final static double REPULSE_LIMIT = 10000;
public final static double FACTOR_DECELERATION = 1.1;
- public final static double FACTOR_INITIAL_DISTANCE = 5.0;
- public final static double MIN_KINETIC = 1.0; /* will stop
if < */
+ public final static double FACTOR_INITIAL_DISTANCE = 5;
+ public final static double MIN_KINETIC = 0.1; /* will stop
if < */
/**
* attracted by its peers/neightbours
@@ -148,11 +148,13 @@
double repX = 0.0;
double repY = 0.0;
- if (x != node.getX())
+ if (x != node.getX()) {
repX = (1/(x-node.getX())*FACTOR_REPULSION);
+ }
- if (y != node.getY())
+ if (y != node.getY()) {
repY = (1/(y-node.getY())*FACTOR_REPULSION);
+ }
if (repX > REPULSE_LIMIT) repX = REPULSE_LIMIT;
@@ -192,6 +194,7 @@
}
/* attraction */
+
for (Iterator it = linkTo.iterator();
it.hasNext();) {
Node node = (Node)it.next();
@@ -204,7 +207,9 @@
netForceY += attr[1];
}
+
/* attraction */
+
for (Iterator it = linkedFrom.iterator();
it.hasNext();) {
Node node = (Node)it.next();
@@ -217,6 +222,7 @@
netForceY += attr[1];
}
+
velocityX = velocityX/FACTOR_DECELERATION;
velocityY = velocityY/FACTOR_DECELERATION;
@@ -240,10 +246,7 @@
}
- /**
- * Recursivity : Dirty, but easier :P
- */
- public void setInitialNeightboorPositions() {
+ public int getNmbUnplacedNeightbours() {
int unplaced = 0;
for (Iterator it = linkTo.iterator();
@@ -254,7 +257,17 @@
unplaced++;
}
- if (unplaced == 0)
+ return unplaced;
+ }
+
+
+ /**
+ * Recursivity : Dirty, but easier :P
+ */
+ public void setInitialNeightbourPositions() {
+ int unplaced = 0;
+
+ if ( (unplaced = getNmbUnplacedNeightbours()) == 0)
return;
double step = (2*Math.PI) / unplaced;
@@ -266,13 +279,15 @@
Node node = (Node)it.next();
if (!node.isPositionSet()) {
- double diffX = Math.cos(current) *
((FACTOR_INITIAL_DISTANCE*unplaced)+1);
- double diffY = Math.sin(current) *
((FACTOR_INITIAL_DISTANCE*unplaced)+1);
+ int i = unplaced +
node.getNmbUnplacedNeightbours();
+ double diffX = Math.cos(current) *
(FACTOR_INITIAL_DISTANCE*(i+1));
+ double diffY = Math.sin(current) *
(FACTOR_INITIAL_DISTANCE*(i+1));
+
node.setPosition(x + diffX,
y + diffY);
- node.setInitialNeightboorPositions();
+ node.setInitialNeightbourPositions();
current += step;
}