Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
enhanced web structure images
Michael Peter Christen9eaede50e796
diff --git a/htroot/Crawler_p.html b/htroot/Crawler_p.htmlindex ed9e7844a..b8d8d1b8a 100644--- a/htroot/Crawler_p.html+++ b/htroot/Crawler_p.html@@ -181,15 +181,15 @@#(linkstructure)#::<script type="text/javascript"><!--- imagestub = "WebStructurePicture_p.png?host=#[hosts]#&depth=3&width=1024&height=576&nodes=300&time=1000&colortext=888888&colorback=FFFFFF&colordot=11BB11&colorline=222222&colorlineend=333333";+ imagestub = "WebStructurePicture_p.png?host=#[hosts]#&depth=3&width=1024&height=512&nodes=300&time=1000&colortext=888888&colorback=FFFFFF&colordot=11BB11&colorline=222222&colorlineend=333333";idx = 0;- setTimeout("doanimation()", 2000);- function doanimation() {+ setTimeout("doanimation(500)", 500);+ function doanimation(nexttimeout) {var accessPicture = document.getElementById("WebPicture");if (accessPicture != null) {idx++;accessPicture.src = imagestub + "&idx=" + idx;- setTimeout("doanimation()", 1000);+ setTimeout("doanimation(" + (nexttimeout > 3000 ? 3000 : nexttimeout * 1.2) + ")", nexttimeout);}}-->diff --git a/htroot/WatchWebStructure_p.html b/htroot/WatchWebStructure_p.htmlindex 9dc529666..ad1573473 100644--- a/htroot/WatchWebStructure_p.html+++ b/htroot/WatchWebStructure_p.html@@ -18,21 +18,6 @@text-align:right;}</style>- <script type="text/javascript">- <!--- imagestub = "WebStructurePicture_p.png?host=#[besthost]#&depth=#[depth]#&width=#[width]#&height=#[height]#&nodes=#[nodes]#&time=#[time]#&colortext=#[colortext]#&colorback=#[colorback]#&colordot=#[colordot]#&colorline=#[colorline]#&colorlineend=#[colorlineend]#";- idx = 0;- setTimeout("doanimation()", 3000);- function doanimation() {- var accessPicture = document.getElementById("WebPicture");- if (accessPicture != null) {- idx++;- accessPicture.src = imagestub + "&idx=" + idx;- setTimeout("doanimation()", 3000);- }- }- -->- </script></head><body id="WebStructure" style="margin:0px;">#%env/templates/header.template%#@@ -65,9 +50,7 @@ Click the API icon to see the XML file.To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de/wiki/index.php/Dev:API">API wiki page</a>.</span></div>-<h2>Web Structure</h2>-#(hosts)#::<fieldset><legend>Host List</legend>#{list}#@@ -78,7 +61,6 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de#{/list}#</fieldset>#(/hosts)#-<div id="left"><form action="/WatchWebStructure_p.html" accept-charset="UTF-8" onsubmit="return checkform(this);"><fieldset>@@ -118,7 +100,7 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de</fieldset></form></div><br />-<div style="text-align:right;">+<div style="text-align:left;"><img id="WebPicture" src="WebStructurePicture_p.png?host=#[besthost]#&depth=#[depth]#&width=#[width]#&height=#[height]#&nodes=#[nodes]#&time=#[time]#&colortext=#[colortext]#&colorback=#[colorback]#&colordot=#[colordot]#&colorline=#[colorline]#&colorlineend=#[colorlineend]#" alt="WebStructurePicture"/></div>#%env/templates/footer.template%#diff --git a/htroot/WatchWebStructure_p.java b/htroot/WatchWebStructure_p.javaindex be8ce12ca..0a6c7c195 100644--- a/htroot/WatchWebStructure_p.java+++ b/htroot/WatchWebStructure_p.java@@ -27,8 +27,8 @@ public class WatchWebStructure_p {String color_line = "222222";String color_lineend = "333333";- int width = 1024;- int height = 576;+ int width = 1280;+ int height = 720;int depth = 3;int nodes = 300; // maximum number of host nodes that are paintedint time = -1;@@ -36,10 +36,10 @@ public class WatchWebStructure_p {String besthost;if (post != null) {- width = post.getInt("width", 1024);- height = post.getInt("height", 576);+ width = post.getInt("width", 1280);+ height = post.getInt("height", 720);depth = post.getInt("depth", 3);- nodes = post.getInt("nodes", width * height * 300 / 1024 / 576);+ nodes = post.getInt("nodes", width * height * 300 / width / height);time = post.getInt("time", -1);host = post.get("host", "auto");color_text = post.get("colortext", color_text);diff --git a/htroot/WebStructurePicture_p.java b/htroot/WebStructurePicture_p.javaindex f48212fe7..1d0aa457a 100644--- a/htroot/WebStructurePicture_p.java+++ b/htroot/WebStructurePicture_p.java@@ -133,7 +133,8 @@ public class WebStructurePicture_p {}// draw the graph- graphPicture = graph.draw(width, height, 40, 40, 16, 16, color_back, color_dot, color_line, color_lineend, color_text);+ graph.normalize();+ graphPicture = graph.draw(width, height, 40, 40, 16, 16, 12, 6, color_back, color_dot, color_line, color_lineend, color_text);}// print headlinegraphPicture.setColor(color_text);diff --git a/source/net/yacy/visualization/GraphPlotter.java b/source/net/yacy/visualization/GraphPlotter.javaindex 39ea0c22d..0c7afa693 100644--- a/source/net/yacy/visualization/GraphPlotter.java+++ b/source/net/yacy/visualization/GraphPlotter.java@@ -26,6 +26,7 @@package net.yacy.visualization;+import java.util.AbstractMap;import java.util.ArrayList;import java.util.Collection;import java.util.HashMap;@@ -47,7 +48,7 @@ public class GraphPlotter implements Cloneable {// a ymageGraph is a set of points and borders between the points// to reference the points, they must all have a nickname- private final Map<String, Point> nodes; // the interconnected objects+ private Map<String, Point> nodes; // the interconnected objectsprivate final Set<String> edges; // the links that connect pairs of verticesprivate double leftmost, rightmost, topmost, bottommost;@@ -167,7 +168,76 @@ public class GraphPlotter implements Cloneable {if ((from == null) || (to == null)) return null;return new Point[] {from, to};}++ private String getLeftmost() {+ if (this.nodes.size() == 0) return null;+ String ns = "";+ double ps = Double.MAX_VALUE;+ for (Map.Entry<String, Point> node: this.nodes.entrySet()) {+ if (node.getValue().x < ps) {ns = node.getKey(); ps = node.getValue().x;}+ }+ assert ns != null;+ return ns;+ }++ private String getBottommost() {+ if (this.nodes.size() == 0) return null;+ String ns = "";+ double ps = Double.MAX_VALUE;+ for (Map.Entry<String, Point> node: this.nodes.entrySet()) {+ if (node.getValue().y < ps) {ns = node.getKey(); ps = node.getValue().y;}+ }+ assert ns != null;+ return ns;+ }+ public int normalizeVertical() {+ Map<String, Point> nc = new HashMap<String, Point>();+ int d = 0;+ while (this.nodes.size() > 0) {+ String n = getBottommost();+ Point p = this.nodes.remove(n);+ p.y = d++;+ nc.put(n, p);+ }+ this.nodes = nc;+ this.bottommost = 0.0d;+ this.topmost = d - 1;+ return d;+ }++ public int normalizeHorizontal() {+ ArrayList<Map.Entry<String, Point>> l = new ArrayList<Map.Entry<String, Point>>();+ int d = 0;+ Point p;+ while (this.nodes.size() > 0) {+ String n = getLeftmost();+ p = this.nodes.remove(n);+ p.x = d++;+ l.add(new AbstractMap.SimpleEntry<String, Point>(n, p));+ }+ for (int i = 0; i < l.size() / 5; i++) {+ p = l.get(i).getValue(); p.x = p.x + 3 * l.get(i).getKey().length() / 2; this.rightmost = Math.max(p.x, this.rightmost);+ p = l.get(l.size() - i - 1).getValue(); p.x = p.x - 3 * l.get(i).getKey().length() / 2; this.leftmost = Math.min(p.x, this.leftmost);+ }+ this.leftmost = Double.MAX_VALUE;+ this.rightmost = Double.MIN_VALUE;+ Map<String, Point> nc = new HashMap<String, Point>();+ for (Map.Entry<String, Point> entry: l) {+ p = entry.getValue();+ nc.put(entry.getKey(), p);+ if (p.x - entry.getKey().length() < this.leftmost) this.leftmost = p.x - entry.getKey().length();+ if (p.x + entry.getKey().length() > this.rightmost) this.rightmost = p.x + entry.getKey().length();+ }+ this.nodes = nc;+ return d;+ }++ public void normalize() {+ normalizeVertical();+ normalizeHorizontal();+ }+public Point addNode(final String node, Point p) {this.nodes.put(node, p);if (p.x > this.rightmost) this.rightmost = p.x;@@ -226,18 +296,14 @@ public class GraphPlotter implements Cloneable {System.out.println("border(" + j.next() + ")");}}-+public RasterPlotter draw(- final int width,- final int height,- final int leftborder,- final int rightborder,- final int topborder,- final int bottomborder,- final String color_back,- final String color_dot,- final String color_line,- final String color_lineend,+ final int width, final int height,+ final int leftborder, final int rightborder,+ final int topborder, final int bottomborder,+ final int xraster, final int yraster,+ final String color_back, final String color_dot,+ final String color_line, final String color_lineend,final String color_text) {final RasterPlotter.DrawMode drawMode = (RasterPlotter.darkColor(color_back)) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB;@@ -256,12 +322,12 @@ public class GraphPlotter implements Cloneable {entry = i.next();name = entry.getKey();c = entry.getValue();- x = (xfactor == 0.0) ? width / 2 : (int) (leftborder + (c.x - this.leftmost) * xfactor);- y = (yfactor == 0.0) ? height / 2 : (int) (height - bottomborder - (c.y - this.bottommost) * yfactor);+ x = (xfactor == 0.0) ? raster(width / 2, xraster) : leftborder + raster((c.x - this.leftmost) * xfactor, xraster);+ y = (yfactor == 0.0) ? raster(height / 2, yraster) : height - bottomborder - raster((c.y - this.bottommost) * yfactor, yraster);image.setColor(color_dot);image.dot(x, y, 6, true, 100);image.setColor(color_text);- PrintTool.print(image, x, y + 10, 0, name.toUpperCase(), 0);+ PrintTool.print(image, x, y + 10, 0, name.toUpperCase(), 0 /*x < 2 * width / 5 ? 1 : x > 3 * width / 5 ? -1 : 0*/);}// draw lines@@ -273,23 +339,28 @@ public class GraphPlotter implements Cloneable {border = getEdge(j.next());if (border == null) continue;if (xfactor == 0.0) {- x0 = width / 2;- x1 = width / 2;+ x0 = raster(width / 2, xraster);+ x1 = raster(width / 2, xraster);} else {- x0 = (int) (leftborder + (border[0].x - this.leftmost) * xfactor);- x1 = (int) (leftborder + (border[1].x - this.leftmost) * xfactor);+ x0 = leftborder + raster((border[0].x - this.leftmost) * xfactor, xraster);+ x1 = leftborder + raster((border[1].x - this.leftmost) * xfactor, xraster);}if (yfactor == 0.0) {- y0 = height / 2;- y1 = height / 2;+ y0 = raster(height / 2, yraster);+ y1 = raster(height / 2, yraster);} else {- y0 = (int) (height - bottomborder - (border[0].y - this.bottommost) * yfactor);- y1 = (int) (height - bottomborder - (border[1].y - this.bottommost) * yfactor);+ y0 = height - bottomborder - raster((border[0].y - this.bottommost) * yfactor, yraster);+ y1 = height - bottomborder - raster((border[1].y - this.bottommost) * yfactor, yraster);}// draw the line, with the dot at the beginning of the lineimage.lineDot(x1, y1, x0, y0, 3, 4, color_line, color_lineend);}return image;}++ private int raster(final double pos, final int raster) {+ if (raster <= 1) return (int) pos;+ return ((int) (pos / raster)) * raster;+ }}