Commit 8d935acc authored by Antoine's avatar Antoine

Test on node flickering.

parent c4d30741
......@@ -317,21 +317,27 @@ public abstract class BarnesHutLayout extends SourceBase implements Layout,
}
public double randomXInsideBounds() {
org.miv.pherd.geom.Point3 lo = nodes.getNTree().getLowestPoint();
org.miv.pherd.geom.Point3 hi = nodes.getNTree().getHighestPoint();
return lo.x + ((hi.x - lo.x)*Math.random());
org.miv.pherd.geom.Point3 c = ((GraphCellData)nodes.getNTree().getRootCell().getData()).center;
return c.x + (random.nextDouble()*2-1);
//org.miv.pherd.geom.Point3 lo = nodes.getNTree().getLowestPoint();
//org.miv.pherd.geom.Point3 hi = nodes.getNTree().getHighestPoint();
//return lo.x + ((hi.x - lo.x)*random.nextDouble());
}
public double randomYInsideBounds() {
org.miv.pherd.geom.Point3 lo = nodes.getNTree().getLowestPoint();
org.miv.pherd.geom.Point3 hi = nodes.getNTree().getHighestPoint();
return lo.y + ((hi.y - lo.y)*Math.random());
org.miv.pherd.geom.Point3 c = ((GraphCellData)nodes.getNTree().getRootCell().getData()).center;
return c.y + (random.nextDouble()*2-1);
//org.miv.pherd.geom.Point3 lo = nodes.getNTree().getLowestPoint();
//org.miv.pherd.geom.Point3 hi = nodes.getNTree().getHighestPoint();
//return lo.y + ((hi.y - lo.y)*random.nextDouble());
}
public double randomZInsideBounds() {
org.miv.pherd.geom.Point3 lo = nodes.getNTree().getLowestPoint();
org.miv.pherd.geom.Point3 hi = nodes.getNTree().getHighestPoint();
return lo.z + ((hi.z - lo.z)*Math.random());
org.miv.pherd.geom.Point3 c = ((GraphCellData)nodes.getNTree().getRootCell().getData()).center;
return c.z + (random.nextDouble()*2-1);
//org.miv.pherd.geom.Point3 lo = nodes.getNTree().getLowestPoint();
//org.miv.pherd.geom.Point3 hi = nodes.getNTree().getHighestPoint();
//return lo.z + ((hi.z - lo.z)*random.nextDouble());
}
public Point3 getCenterPoint() {
......@@ -533,8 +539,10 @@ public abstract class BarnesHutLayout extends SourceBase implements Layout,
energies.clearEnergies();
}
protected void addNode(String sourceId, String id) {
nodes.addParticle(newNodeParticle(id));
protected NodeParticle addNode(String sourceId, String id) {
NodeParticle np = newNodeParticle(id);
nodes.addParticle(np);
return np;
}
public void moveNode(String id, double x, double y, double z) {
......@@ -695,8 +703,13 @@ public abstract class BarnesHutLayout extends SourceBase implements Layout,
public void nodeAdded(String graphId, long time, String nodeId) {
if (sinkTime.isNewEvent(graphId, time)) {
addNode(graphId, nodeId);
//System.err.printf("## before (%.2f, %.2f -- %.2f %.2f) %n", lo.x, lo.y, hi.x, hi.y);
NodeParticle np = addNode(graphId, nodeId);
sendNodeAdded(graphId, time, nodeId);
// org.miv.pherd.geom.Point3 p = np.getPosition();
//System.err.printf("-- node added at (%.2f, %.2f) inside (%.2f, %.2f -- %.2f %.2f) %n", p.x, p.y, lo.x, lo.y, hi.x, hi.y);
// particleMoved(nodeId, p.x, p.y, p.z);
}
}
......
......@@ -108,6 +108,7 @@ public abstract class NodeParticle extends Particle {
* The node identifier.
*/
public NodeParticle(BarnesHutLayout box, String id) {
// this(box, id, box.getCenterPoint().x, box.getCenterPoint().y, box.is3D() ? box.getCenterPoint().z : 0);
this(box, id, box.randomXInsideBounds(), box.randomYInsideBounds(), box.is3D ? box.randomZInsideBounds() : 0);
// this(box, id, (box.random.nextDouble() * 2) - 1, (box.random
// .nextDouble() * 2) - 1,
......
......@@ -56,10 +56,9 @@ public class SpringBoxNodeParticle extends NodeParticle {
* The node identifier.
*/
public SpringBoxNodeParticle(SpringBox box, String id) {
this(box, id, (box.getRandom().nextDouble() * 2 * box.k) - box.k, (box
.getRandom().nextDouble() * 2 * box.k) - box.k,
box.is3D() ? (box.getRandom().nextDouble() * 2 * box.k) - box.k
: 0);
//this(box, id, box.getCenterPoint().x, box.getCenterPoint().y, box.is3D() ? box.getCenterPoint().z : 0);
this(box, id, box.randomXInsideBounds(), box.randomYInsideBounds(), box.is3D() ? box.randomZInsideBounds() : 0);
//this(box, id, (box.getRandom().nextDouble() * 2 * box.k) - box.k, (box.getRandom().nextDouble() * 2 * box.k) - box.k, box.is3D() ? (box.getRandom().nextDouble() * 2 * box.k) - box.k : 0);
this.box = box;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment