restrict number of nodes in web structure picture

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3822 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 559d1c447f
commit 8f00c1e896

@ -32,19 +32,21 @@
</dd> </dd>
<dt>depth</dt> <dt>depth</dt>
<dd> <dd>
<a href="WatchWebStructure_p.html?host=#[host]#&depth=#[depthd]#&width=#[width]#&height=#[height]#"><img src="env/grafics/minus.gif" /></a> <a href="WatchWebStructure_p.html?host=#[host]#&depth=#[depthd]#&width=#[width]#&height=#[height]#&nodes=#[nodes]#"><img src="env/grafics/minus.gif" /></a>
<input type="text" name="depth" value="#[depth]#" size="1" maxlength="1" /> <input type="text" name="depth" value="#[depth]#" size="1" maxlength="1" />
<a href="WatchWebStructure_p.html?host=#[host]#&depth=#[depthi]#&width=#[width]#&height=#[height]#"><img src="env/grafics/plus.gif" /></a> <a href="WatchWebStructure_p.html?host=#[host]#&depth=#[depthi]#&width=#[width]#&height=#[height]#&nodes=#[nodes]#"><img src="env/grafics/plus.gif" /></a>
</dd> </dd>
<dt>size</dt> <dt>size</dt>
<dd><input type="text" name="width" value="#[width]#" size="4" maxlength="4" />&nbsp;x&nbsp;<input type="text" name="height" value="#[height]#" size="4" maxlength="4" /></dd> <dd><input type="text" name="width" value="#[width]#" size="4" maxlength="4" />&nbsp;x&nbsp;<input type="text" name="height" value="#[height]#" size="4" maxlength="4" /></dd>
<dt>nodes</dt>
<dd><input type="text" name="nodes" value="#[nodes]#" size="4" maxlength="4" /></dd>
<dt>&nbsp;</dt> <dt>&nbsp;</dt>
<dd><input type="submit" value="change" /></dd> <dd><input type="submit" value="change" /></dd>
</dl> </dl>
</form> </form>
</div> </div>
<img src="WebStructurePicture_p.png?host=#[host]#&depth=#[depth]#&width=#[width]#&height=#[height]#" /> <img src="WebStructurePicture_p.png?host=#[host]#&depth=#[depth]#&width=#[width]#&height=#[height]#&nodes=#[nodes]#" />
#%env/templates/footer.template%# #%env/templates/footer.template%#
</body> </body>

@ -16,12 +16,14 @@ public class WatchWebStructure_p {
int width = 768; int width = 768;
int height = 576; int height = 576;
int depth = 3; int depth = 3;
int nodes = 100; // maximum number of host nodes that are painted
String host = "auto"; String host = "auto";
if (post != null) { if (post != null) {
width = post.getInt("width", 768); width = post.getInt("width", 768);
height = post.getInt("height", 576); height = post.getInt("height", 576);
depth = post.getInt("depth", 3); depth = post.getInt("depth", 3);
nodes = post.getInt("nodes", width * height * 100 / 768 / 576);
host = post.get("host", "auto"); host = post.get("host", "auto");
} }
@ -47,6 +49,7 @@ public class WatchWebStructure_p {
prop.put("depthd", Math.max(0, depth - 1)); prop.put("depthd", Math.max(0, depth - 1));
prop.put("width", width); prop.put("width", width);
prop.put("height", height); prop.put("height", height);
prop.put("nodes", nodes);
return prop; return prop;
} }

@ -50,12 +50,14 @@ public class WebStructurePicture_p {
int width = 768; int width = 768;
int height = 576; int height = 576;
int depth = 3; int depth = 3;
int nodes = 100; // maximum number of host nodes that are painted
String host = null; String host = null;
if (post != null) { if (post != null) {
width = post.getInt("width", 768); width = post.getInt("width", 768);
height = post.getInt("height", 576); height = post.getInt("height", 576);
depth = post.getInt("depth", 3); depth = post.getInt("depth", 3);
nodes = post.getInt("nodes", width * height * 100 / 768 / 576);
host = post.get("host", null); host = post.get("host", null);
} }
@ -81,19 +83,24 @@ public class WebStructurePicture_p {
// recursively find domains, up to a specific depth // recursively find domains, up to a specific depth
ymageGraph graph = new ymageGraph(); ymageGraph graph = new ymageGraph();
if (host != null) place(graph, sb.webStructure, hash, host, 0.0, 0.0, 0, depth); if (host != null) place(graph, sb.webStructure, hash, host, nodes, 0.0, 0.0, 0, depth);
//graph.print(); //graph.print();
return graph.draw(width, height, 40, 40, 5, 15); return graph.draw(width, height, 40, 40, 5, 15);
} }
private static final void place(ymageGraph graph, plasmaWebStructure structure, String centerhash, String centerhost, double x, double y, int nextlayer, int maxlayer) { private static final int place(ymageGraph graph, plasmaWebStructure structure, String centerhash, String centerhost, int maxnodes, double x, double y, int nextlayer, int maxlayer) {
// returns the host string // returns the number of nodes that had been placed
assert centerhost != null; assert centerhost != null;
ymageGraph.coordinate center = graph.getPoint(centerhost); ymageGraph.coordinate center = graph.getPoint(centerhost);
if (center == null) center = graph.addPoint(centerhost, x, y, nextlayer); int mynodes = 0;
if (nextlayer == maxlayer) return; if (center == null) {
center = graph.addPoint(centerhost, x, y, nextlayer);
maxnodes--;
mynodes++;
}
if (nextlayer == maxlayer) return mynodes;
nextlayer++; nextlayer++;
double radius = 1.0 / ((double) (1 << nextlayer)); double radius = 1.0 / ((double) (1 << nextlayer));
Map next = structure.references(centerhash); Map next = structure.references(centerhash);
@ -105,7 +112,7 @@ public class WebStructurePicture_p {
int maxtargetrefs = 8, maxthisrefs = 8; int maxtargetrefs = 8, maxthisrefs = 8;
int targetrefs, thisrefs; int targetrefs, thisrefs;
double rr, re; double rr, re;
while (i.hasNext()) { while ((i.hasNext()) && (maxnodes > 0)) {
entry = (Map.Entry) i.next(); entry = (Map.Entry) i.next();
targethash = (String) entry.getKey(); targethash = (String) entry.getKey();
targethost = structure.resolveDomHash2DomString(targethash); targethost = structure.resolveDomHash2DomString(targethash);
@ -122,20 +129,25 @@ public class WebStructurePicture_p {
rr = radius * 0.25 * (1 - targetrefs / maxtargetrefs); rr = radius * 0.25 * (1 - targetrefs / maxtargetrefs);
re = radius * 0.5 * (thisrefs / maxthisrefs); re = radius * 0.5 * (thisrefs / maxthisrefs);
graph.addPoint(targethost, x + (radius - rr - re) * Math.cos(angle), y + (radius - rr - re) * Math.sin(angle), nextlayer); graph.addPoint(targethost, x + (radius - rr - re) * Math.cos(angle), y + (radius - rr - re) * Math.sin(angle), nextlayer);
maxnodes--;
mynodes++;
} }
// recursively set next hosts // recursively set next hosts
i = targets.iterator(); i = targets.iterator();
String[] target; String[] target;
int nextnodes;
while (i.hasNext()) { while (i.hasNext()) {
target = (String[]) i.next(); target = (String[]) i.next();
targethash = target[0]; targethash = target[0];
targethost = target[1]; targethost = target[1];
ymageGraph.coordinate c = graph.getPoint(targethost); ymageGraph.coordinate c = graph.getPoint(targethost);
assert c != null; assert c != null;
place(graph, structure, targethash, targethost, c.x, c.y, nextlayer, maxlayer); nextnodes = (maxnodes <= 0) ? 0 : place(graph, structure, targethash, targethost, maxnodes, c.x, c.y, nextlayer, maxlayer);
mynodes += nextnodes;
maxnodes -= nextnodes;
graph.setBorder(centerhost, targethost); graph.setBorder(centerhost, targethost);
} }
return; return mynodes;
} }
} }

Loading…
Cancel
Save