fixed to network graph testing

pull/1/head
Michael Peter Christen 13 years ago
parent f31ad84d98
commit 91a86f0b06

@ -119,7 +119,7 @@ public class WebStructurePicture_p {
// apply physics to it to get a better shape // apply physics to it to get a better shape
if (post != null && post.containsKey("pa")) { if (post != null && post.containsKey("pa")) {
// test with: http://localhost:8090/WebStructurePicture_p.png?pa=10&ral=0.7&raa=0.001&rar=0.0002&rel=0.25&rea=0.1&rer=0.0001 // test with: http://localhost:8090/WebStructurePicture_p.png?pa=1&ral=0.7&raa=0.5&rar=2&rel=0.5&rea=1&rer=2
GraphPlotter.Ribbon rAll = new GraphPlotter.Ribbon(post.getFloat("ral", 0.1f), post.getFloat("raa", 0.1f), post.getFloat("rar", 0.1f)); GraphPlotter.Ribbon rAll = new GraphPlotter.Ribbon(post.getFloat("ral", 0.1f), post.getFloat("raa", 0.1f), post.getFloat("rar", 0.1f));
GraphPlotter.Ribbon rEdge = new GraphPlotter.Ribbon(post.getFloat("rel", 0.05f), post.getFloat("rea", 0.1f), post.getFloat("rer", 0.1f)); GraphPlotter.Ribbon rEdge = new GraphPlotter.Ribbon(post.getFloat("rel", 0.05f), post.getFloat("rea", 0.1f), post.getFloat("rer", 0.1f));
for (int i = 0; i < post.getInt("pa", 1); i++) graph = graph.physics(rAll, rEdge); for (int i = 0; i < post.getInt("pa", 1); i++) graph = graph.physics(rAll, rEdge);

@ -60,6 +60,7 @@ public class GraphPlotter implements Cloneable {
this.bottommost = 1.0; this.bottommost = 1.0;
} }
@Override
public Object clone() { public Object clone() {
GraphPlotter g = new GraphPlotter(); GraphPlotter g = new GraphPlotter();
g.nodes.putAll(this.nodes); g.nodes.putAll(this.nodes);
@ -95,6 +96,7 @@ public class GraphPlotter implements Cloneable {
this.layer = layer; this.layer = layer;
} }
@Override
public Object clone() { public Object clone() {
return new Point(this.x, this.y, this.layer); return new Point(this.x, this.y, this.layer);
} }
@ -113,14 +115,15 @@ public class GraphPlotter implements Cloneable {
double f = attraction ? r.attraction * (d - r.length) * (d - r.length) : - r.repulsion * (r.length - d) * (r.length - d); // the force double f = attraction ? r.attraction * (d - r.length) * (d - r.length) : - r.repulsion * (r.length - d) * (r.length - d); // the force
double x1 = Math.cos(a) * f; double x1 = Math.cos(a) * f;
double y1 = Math.sin(a) * f; double y1 = Math.sin(a) * f;
assert !(attraction && a < Math.PI) || y1 > 0 : "attraction = " + attraction + ", a = " + a + ", y1 = " + y1; // verify calculation
assert !(!attraction && a < Math.PI) || y1 < 0 : "attraction = " + attraction + ", a = " + a + ", y1 = " + y1; assert !(attraction && a < Math.PI) || y1 >= 0 : "attraction = " + attraction + ", a = " + a + ", y1 = " + y1;
assert !(attraction && a > Math.PI) || y1 < 0 : "attraction = " + attraction + ", a = " + a + ", y1 = " + y1; assert !(!attraction && a < Math.PI) || y1 <= 0 : "attraction = " + attraction + ", a = " + a + ", y1 = " + y1;
assert !(!attraction && a > Math.PI) || y1 > 0 : "attraction = " + attraction + ", a = " + a + ", y1 = " + y1; assert !(attraction && a > Math.PI) || y1 <= 0 : "attraction = " + attraction + ", a = " + a + ", y1 = " + y1;
assert !(attraction && (a < p2 || a > p23)) || x1 > 0 : "attraction = " + attraction + ", a = " + a + ", x1 = " + x1; assert !(!attraction && a > Math.PI) || y1 >= 0 : "attraction = " + attraction + ", a = " + a + ", y1 = " + y1;
assert !(!attraction && (a < p2 || a > p23)) || x1 < 0 : "attraction = " + attraction + ", a = " + a + ", x1 = " + x1; assert !(attraction && (a < p2 || a > p23)) || x1 >= 0 : "attraction = " + attraction + ", a = " + a + ", x1 = " + x1;
assert !(attraction && !(a < p2 || a > p23)) || x1 < 0 : "attraction = " + attraction + ", a = " + a + ", x1 = " + x1; assert !(!attraction && (a < p2 || a > p23)) || x1 <= 0 : "attraction = " + attraction + ", a = " + a + ", x1 = " + x1;
assert !(!attraction && !(a < p2 || a > p23)) || x1 > 0 : "attraction = " + attraction + ", a = " + a + ", x1 = " + x1; assert !(attraction && !(a < p2 || a > p23)) || x1 <= 0 : "attraction = " + attraction + ", a = " + a + ", x1 = " + x1;
assert !(!attraction && !(a < p2 || a > p23)) || x1 >= 0 : "attraction = " + attraction + ", a = " + a + ", x1 = " + x1;
calcPoint.x += x1; calcPoint.x += x1;
calcPoint.y += y1; calcPoint.y += y1;
} }

Loading…
Cancel
Save