enhanced web structure picture

- hand-over of get properties from web front-end to graphics generation
- added depth-control buttons
- added marking of anchor-points to highlight relation order
- enhanced ymage graphics library

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3757 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 2f34f32ce3
commit 0ae6664ad8

@ -4,12 +4,29 @@
<title>YaCy '#[clientname]#': Web Structure</title>
#%env/templates/metas.template%#
</head>
<body id="WebStructure">
<body id="WebStructure" style="margin:0px;">
#%env/templates/header.template%#
#%env/templates/submenuCrawler.template%#
<h2>Web Structure</h2>
<img src="WebStructurePicture_p.png">
<table>
<tr>
<td valign="top">
<dl>
<dt>host</dt><dd>#[host]#</dd>
<dt>depth</dt><dd>#[depth]#<br/>
<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=#[depthi]#&width=#[width]#&height=#[height]#"><img src="env/grafics/plus.gif" /></a>
</dd>
</dl>
</td>
<td>
<img src="WebStructurePicture_p.png?host=#[host]#&depth=#[depth]#&width=#[width]#&height=#[height]#" />
</td>
<td>
</td>
</tr>
</table>
#%env/templates/footer.template%#
</body>
</html>

@ -1,14 +1,33 @@
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class WatchWebStructure_p {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
plasmaSwitchboard sb = (plasmaSwitchboard) env;
//plasmaSwitchboard sb = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects();
int width = 768;
int height = 576;
int depth = 3;
String host = "auto";
if (post != null) {
width = post.getInt("width", 768);
height = post.getInt("height", 576);
depth = post.getInt("depth", 3);
host = post.get("host", "auto");
}
prop.put("host", host);
prop.put("depth", depth);
prop.put("depthi", Math.min(8, depth + 1));
prop.put("depthd", Math.max(0, depth - 1));
prop.put("width", width);
prop.put("height", height);
return prop;
}
}

@ -60,15 +60,15 @@ public class WebStructurePicture_p {
}
//too small values lead to an error, too big to huge CPU/memory consumption, resulting in possible DOS.
if (width < 320 ) width = 320;
if (width < 32 ) width = 32;
if (width > 1920) width = 1920;
if (height < 240) height = 240;
if (height < 24) height = 24;
if (height > 1920) height = 1920;
if (depth > 8) depth = 8;
if (depth < 1) depth = 1;
if (depth < 0) depth = 0;
// find start point
if (host == null) {
if ((host == null) || (host.length() == 0) || (host.equals("auto"))) {
// find domain with most references
host = sb.webStructure.hostWithMaxReferences();
}
@ -84,7 +84,7 @@ public class WebStructurePicture_p {
if (host != null) place(graph, sb.webStructure, hash, host, 0.0, 0.0, 0, depth);
//graph.print();
return graph.draw(width, height, 20, 20, 20, 20);
return graph.draw(width, height, 40, 40, 5, 15);
}
@ -110,7 +110,7 @@ public class WebStructurePicture_p {
if (graph.getPoint(targethost) != null) continue;
// set a new point. It is placed on a circle around the host point
double angle = ((double) kelondroBase64Order.enhancedCoder.cardinal((targethash + "____").getBytes())) / maxlongd * 2 * Math.PI;
System.out.println("ANGLE = " + angle);
//System.out.println("ANGLE = " + angle);
double radius = 1.0 / ((double) (1 << nextlayer));
graph.addPoint(targethost, x + radius * Math.cos(angle), y + radius * Math.sin(angle), nextlayer);
}

@ -1,3 +1,29 @@
// ymageGraph.java
// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
// first published 22.05.2007 on http://yacy.net
//
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package de.anomic.ymage;
import java.util.HashMap;
@ -5,7 +31,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
/* this class does not really draw graphes, it is only a container for graph coordinates.
/* this class is a container for graph coordinates and it can draw such coordinates into a graph
* all coordinates are given in a artificial corrdinate system, in the range from
* -1 to +1. The lower left point of the graph has the coordinate -1, -1 and the upper
* right is 1,1
@ -99,16 +125,18 @@ public class ymageGraph {
}
private static final long color_back = ymageMatrix.SUBTRACTIVE_WHITE;
private static final long color_dot = 0x4444AA;
private static final long color_dot = 0x6633AA;
private static final long color_line = 0x333333;
private static final long color_lineend = 0x555555;
private static final long color_text = ymageMatrix.SUBTRACTIVE_BLACK;
public ymageMatrix draw(int width, int height, int leftborder, int rightborder, int topborder, int bottomborder) {
ymageMatrix image = new ymageMatrix(width, height, color_back);
double xfactor = (width - leftborder - rightborder) / (rightmost - leftmost);
double yfactor = (height - topborder - bottomborder) / (topmost - bottommost);
double xfactor = ((rightmost - leftmost) == 0.0) ? 0.0 : (width - leftborder - rightborder) / (rightmost - leftmost);
double yfactor = ((topmost - bottommost) == 0.0) ? 0.0 : (height - topborder - bottomborder) / (topmost - bottommost);
image.setMode(ymageMatrix.MODE_SUB);
// draw dots and names
Iterator i = points.entrySet().iterator();
Map.Entry entry;
String name;
@ -118,25 +146,40 @@ public class ymageGraph {
entry = (Map.Entry) i.next();
name = (String) entry.getKey();
c = (coordinate) entry.getValue();
x = (int) (leftborder + (c.x - leftmost) * xfactor);
y = (int) (height - bottomborder - (c.y - bottommost) * yfactor);
x = (xfactor == 0.0) ? width / 2 : (int) (leftborder + (c.x - leftmost) * xfactor);
y = (yfactor == 0.0) ? height / 2 : (int) (height - bottomborder - (c.y - bottommost) * yfactor);
image.setColor(color_dot);
image.dot(x, y, 5, true);
image.dot(x, y, 6, true);
image.setColor(color_text);
ymageToolPrint.print(image, x, y + 10, 0, name.toUpperCase(), 0);
}
// draw lines
i = borders.iterator();
coordinate[] border;
image.setColor(color_line);
int x0, x1, y0, y1;
while (i.hasNext()) {
border = getBorder((String) i.next());
if (border == null) continue;
image.line(
(int) (leftborder + (border[0].x - leftmost) * xfactor),
(int) (height - bottomborder - (border[0].y - bottommost) * yfactor),
(int) (leftborder + (border[1].x - leftmost) * xfactor),
(int) (height - bottomborder - (border[1].y - bottommost) * yfactor));
if (xfactor == 0.0) {
x0 = width / 2;
x1 = width / 2;
} else {
x0 = (int) (leftborder + (border[0].x - leftmost) * xfactor);
x1 = (int) (leftborder + (border[1].x - leftmost) * xfactor);
}
if (yfactor == 0.0) {
y0 = height / 2;
y1 = height / 2;
} else {
y0 = (int) (height - bottomborder - (border[0].y - bottommost) * yfactor);
y1 = (int) (height - bottomborder - (border[1].y - bottommost) * yfactor);
}
// draw the line, with the dot at the beginning of the line
image.lineDot(x1, y1, x0, y0, 3, 4, color_line, color_lineend);
}
return image;
}
}

@ -1,10 +1,15 @@
// ymageMatrix.java
// ---------------------------
// (C) by Michael Peter Christen; mc@anomic.de
// first published on http://www.anomic.de
// Frankfurt, Germany, 2005
// last major change: 16.09.2005
// (C) 2005 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
// first published 16.09.2005 on http://yacy.net
//
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
@ -18,25 +23,6 @@
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Using this software in any meaning (reading, learning, copying, compiling,
// running) means that you agree that the Author(s) is (are) not responsible
// for cost, loss of data or any harm that may be caused directly or indirectly
// by usage of this softare or this documentation. The usage of this software
// is on your own risk. The installation and usage (starting/running) of this
// software may allow other people or application to access your computer and
// any attached devices and is highly dependent on the configuration of the
// software which must be done by the user of the software; the author(s) is
// (are) also not responsible for proper configuration and usage of the
// software, even if provoked by documentation provided together with
// the software.
//
// Any changes to this file according to the GPL as documented in the file
// gpl.txt aside this file in the shipment you received can be done to the
// lines that follows this copyright notice here, but changes must not be
// done inside the copyright notive above. A re-distribution must contain
// the intact and unchanged copyright notice.
// Contributions and changes to the program code must be marked as such.
/*
This Class implements some convenience-methods to support drawing of statistical Data
@ -110,17 +96,18 @@ public class ymageMatrix /*implements Cloneable*/ {
//gr.clearRect(0, 0, width, height);
grid = image.getRaster();
// fill grid with background color
byte bgR = (byte) (0xFF - (backgroundColor >> 16));
byte bgG = (byte) (0xFF - ((backgroundColor >> 8) & 0xff));
byte bgB = (byte) (0xFF - (backgroundColor & 0xff));
int[] c = new int[]{bgR, bgG, bgB};
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
grid.setPixel(i, j, c);
//if (backgroundColor != SUBTRACTIVE_WHITE) {
// fill grid with background color
byte bgR = (byte) (0xFF - (backgroundColor >> 16));
byte bgG = (byte) (0xFF - ((backgroundColor >> 8) & 0xff));
byte bgB = (byte) (0xFF - (backgroundColor & 0xff));
int[] c = new int[]{bgR, bgG, bgB};
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
grid.setPixel(i, j, c);
}
}
}
//}
}
public BufferedImage getImage() {
@ -215,6 +202,32 @@ public class ymageMatrix /*implements Cloneable*/ {
}
}
public void lineDot(int x0, int y0, int x1, int y1, int radius, int distance, long lineColor, long dotColor) {
// draw a line with a dot at the end.
// the radius value is the radius of the dot
// the distance value is the distance of the dot border to the endpoint
// compute first the angle of the line between the points
double angle = (x1 - x0 > 0) ? Math.atan(((double) (y0 - y1)) / ((double) (x1 - x0))) : Math.PI - Math.atan(((double) (y0 - y1)) / ((double) (x0 - x1)));
// now find two more points in between
// first calculate the radius' of the points
double ra = Math.sqrt((double) ((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1))); // from a known point x1, y1
double rb = ra - radius - distance;
double rc = rb - radius;
//System.out.println("CONTROL angle = " + angle);
//System.out.println("CONTROL x1 = " + x1 + ", x1calc = " + ((x0 + ((int) ra * Math.cos(angle)))));
//System.out.println("CONTROL y1 = " + y1 + ", y1calc = " + ((y0 - ((int) ra * Math.sin(angle)))));
// the points are on a circle with radius rb and rc
int x2 = x0 + ((int) (rb * Math.cos(angle)));
int y2 = y0 - ((int) (rb * Math.sin(angle)));
int x3 = x0 + ((int) (rc * Math.cos(angle)));
int y3 = y0 - ((int) (rc * Math.sin(angle)));
setColor(lineColor);
line(x0, y0, x3, y3);
setColor(dotColor);
dot(x2, y2, radius, true);
}
public int[] getColor(int x, int y) {
int[] c = new int[3];
return grid.getPixel(x, y, c);

Loading…
Cancel
Save