Skip to content

Commit

Permalink
more animations in graphics. See network and access picture.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7498 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Feb 19, 2011
1 parent 93b9c4f commit 29dc416
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 73 deletions.
2 changes: 1 addition & 1 deletion htroot/AccessGrid_p.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#%env/templates/header.template%#
#%env/templates/submenuAccessTracker.template%#
<h2>Server Access Grid</h2>

<p>This images shows incoming connections to your YaCy peer and outgoing connections from your peer to other peers and web servers</p>
<div class="left">
<p>
<a href="AccessPicture_p.png?width=1024&amp;height=576&amp;bgcolor=FFFFFF"><img id="AccessPicture" src="AccessPicture_p.png?width=1024&amp;height=576&amp;bgcolor=FFFFFF&amp;coronaangle=0" alt="The YaCy Network" width="1024" height="576" /></a>
Expand Down
63 changes: 44 additions & 19 deletions htroot/AccessPicture_p.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public static RasterPlotter respond(final RequestHeader header, final serverObje
int width = 1024;
int height = 576;
int cellsize = 18;
boolean corona = false;
int coronaangle = 0;

if (post != null) {
width = post.getInt("width", 1024);
Expand All @@ -63,7 +65,10 @@ public static RasterPlotter respond(final RequestHeader header, final serverObje
color_grid = post.get("colorgrid", color_grid);
color_dot = post.get("colordot", color_dot);
color_line = post.get("colorline", color_line);
corona = post.get("corona", "true").equals("true");
coronaangle = (corona) ? post.getInt("coronaangle", 0) : -1;
}
if (coronaangle < 0) corona = false;

// too small values lead to an error, too big to huge CPU/memory consumption, resulting in possible DOS.
if (width < 32 ) width = 32;
Expand All @@ -83,8 +88,14 @@ public static RasterPlotter respond(final RequestHeader header, final serverObje
int centerx = (picture.gridWidth() >> 1) - 1;
int centery = picture.gridHeight() >> 1;
picture.setColor(color_dot);
picture.gridDot(centerx, centery, 5, true);
//picture.gridDot(centerx, centery, 50, false);
picture.gridDot(centerx, centery, 5);
if (corona) {
for (int i = 0; i < 6; i++) {
picture.gridDot(centerx, centery, 50, i * 60 + coronaangle / 6, i * 60 + 30 + coronaangle / 6);
}
} else {
picture.gridDot(centerx, centery, 50, 0, 360);
}
//picture.gridDot(centerx, centery, 31, false);
picture.setColor(color_text);
picture.gridPrint(centerx, centery, 5, "THIS YACY PEER", "\"" + sb.peers.myName().toUpperCase() + "\"", 0);
Expand Down Expand Up @@ -118,13 +129,20 @@ public static RasterPlotter respond(final RequestHeader header, final serverObje
for (int i = 0; i < hosts.length; i++) {
if (hosts[i] != null) {
picture.setColor(color_dot);
picture.gridDot(gridLeft, i * 2 + 1, 7, false);
picture.gridDot(gridLeft, i * 2 + 1, 8, false);
picture.gridDot(gridLeft, i * 2 + 1, 7, 0, 360);
picture.gridDot(gridLeft, i * 2 + 1, 8, 0, 360);
picture.setColor(color_text);
picture.gridPrint(gridLeft, i * 2 + 1, 8, hosts[i].toUpperCase(), "COUNT = " + count[i] + ", TIME > " + ((time[i] >= 60000) ? ((time[i] / 60000) + " MINUTES") : ((time[i] / 1000) + " SECONDS")), -1);
picture.setColor(color_line);
picture.gridLine(gridLeft, i * 2 + 1, (centerx - gridLeft) / 2, i * 2 + 1);
picture.gridLine(centerx, centery, (centerx - gridLeft) / 2, i * 2 + 1);
if (corona) {
picture.gridLine((centerx - gridLeft) / 2, i * 2 + 1, gridLeft, i * 2 + 1,
color_line, 100, "111111", 100, 12, 11 - coronaangle / 30, 1, true);
picture.gridLine(centerx, centery, (centerx - gridLeft) / 2, i * 2 + 1,
color_line, 100, "111111", 100, 12, 11 - coronaangle / 30, 1, true);
} else {
picture.setColor(color_line);
picture.gridLine(gridLeft, i * 2 + 1, (centerx - gridLeft) / 2, i * 2 + 1);
picture.gridLine(centerx, centery, (centerx - gridLeft) / 2, i * 2 + 1);
}
}
}

Expand All @@ -146,13 +164,20 @@ public static RasterPlotter respond(final RequestHeader header, final serverObje
for (int i = 0; i < hosts.length; i++) {
if (hosts[i] != null) {
picture.setColor(color_dot);
picture.gridDot(gridRight, i * 2 + 1, 7, false);
picture.gridDot(gridRight, i * 2 + 1, 8, false);
picture.gridDot(gridRight, i * 2 + 1, 7, 0, 360);
picture.gridDot(gridRight, i * 2 + 1, 8, 0, 360);
picture.setColor(color_text);
picture.gridPrint(gridRight, i * 2 + 1, 8, hosts[i].toUpperCase(), count[i] + " BYTES, " + time[i] + " MS DUE", 1);
picture.setColor(color_line);
picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2, i * 2 + 1);
picture.gridLine(centerx, centery, centerx + (gridRight - centerx) / 2, i * 2 + 1);
if (corona) {
picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2, i * 2 + 1,
color_line, 100, "111111", 100, 12, coronaangle / 30, 1, true);
picture.gridLine(centerx, centery, centerx + (gridRight - centerx) / 2, i * 2 + 1,
color_line, 100, "111111", 100, 12, coronaangle / 30, 1, true);
} else {
picture.setColor(color_line);
picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2, i * 2 + 1);
picture.gridLine(centerx, centery, centerx + (gridRight - centerx) / 2, i * 2 + 1);
}
}
}

Expand All @@ -163,20 +188,20 @@ public static RasterPlotter respond(final RequestHeader header, final serverObje

// print legend
picture.setColor(color_grid);
picture.gridLine(gridLeft, 0, centerx - 2, 0);
picture.gridLine(gridLeft, 0, centerx - 3, 0);
picture.gridLine(gridLeft, 0, gridLeft, picture.gridHeight() - 1);
picture.gridLine(centerx - 2, 0, centerx - 2, picture.gridHeight() - 1);
picture.gridLine(centerx - 3, 0, centerx - 3, picture.gridHeight() - 1);
picture.setColor(color_dot);
picture.gridLine(gridLeft, picture.gridHeight() - 1, centerx - 2, picture.gridHeight() - 1);
picture.gridLine(gridLeft, picture.gridHeight() - 1, centerx - 3, picture.gridHeight() - 1);
picture.gridPrint(gridLeft, picture.gridHeight() - 1, 8, "", "INCOMING CONNECTIONS", -1);

picture.setColor(color_grid);
picture.gridLine(centerx + 3, 0, gridRight + 1, 0);
picture.gridLine(centerx + 3, 0, gridRight, 0);
picture.gridLine(centerx + 3, 0, centerx + 3, picture.gridHeight() - 1);
picture.gridLine(gridRight + 1, 0, gridRight + 1, picture.gridHeight() - 1);
picture.gridLine(gridRight, 0, gridRight, picture.gridHeight() - 1);
picture.setColor(color_dot);
picture.gridLine(centerx + 3, picture.gridHeight() - 1, gridRight + 1, picture.gridHeight() - 1);
picture.gridPrint(gridRight + 1, picture.gridHeight() - 1, 8, "", "OUTGOING CONNECTIONS", 1);
picture.gridLine(centerx + 3, picture.gridHeight() - 1, gridRight, picture.gridHeight() - 1);
picture.gridPrint(gridRight, picture.gridHeight() - 1, 8, "", "OUTGOING CONNECTIONS", 1);

return picture;

Expand Down
12 changes: 6 additions & 6 deletions htroot/imagetest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public static RasterPlotter respond(final RequestHeader header, final serverObje
for (int y = 0; y < 600; y = y + 50) PrintTool.print(img, 0, 6 + y, 0, Integer.toString(y), -1);
for (int x = 0; x < 800; x = x + 50) PrintTool.print(img, x, 6 , 0, Integer.toString(x), -1);
img.setColor(RasterPlotter.RED);
img.dot(550, 110, 90, true);
img.dot(550, 110, 90, true, 100);
img.setColor(RasterPlotter.GREEN);
img.dot(480, 200, 90, true);
img.dot(480, 200, 90, true, 100);
img.setColor(RasterPlotter.BLUE);
img.dot(620, 200, 90, true);
img.dot(620, 200, 90, true, 100);
img.setColor(RasterPlotter.RED);
img.arc(300, 270, 30, 70, 0, 360);
img.setColor("330000");
Expand All @@ -85,10 +85,10 @@ public static RasterPlotter respond(final RequestHeader header, final serverObje
PrintTool.print(img, 50, 120, 0, "BROADCAST MESSAGE #772: NODE %882 GREEN abcefghijklmnopqrstuvwxyz", -1);
for (long i = 0; i < 256; i++) {
img.setColor(i);
img.dot(10 + 14 * (int) (i / 16), 200 + 14 * (int) (i % 16), 6, true);
img.dot(10 + 14 * (int) (i / 16), 200 + 14 * (int) (i % 16), 6, true, 100);
}
img.setColor("008000");
img.dot(10 + 14 * 8, 200 + 14 * 8, 90, true);
img.dot(10 + 14 * 8, 200 + 14 * 8, 90, true, 100);
/*
for (long r = 0; r < 256; r = r + 16) {
for (long g = 0; g < 256; g = g + 16) {
Expand All @@ -108,7 +108,7 @@ public static RasterPlotter respond(final RequestHeader header, final serverObje
int angle;
for (byte c = (byte) 'A'; c <= 'Z'; c++) {
angle = (c - (byte) 'A') * 360 / ((byte) 'Z' - (byte) 'A');
img.arcLine(550, 400, 81, 100, angle);
img.arcLine(550, 400, 81, 100, angle, null, null, -1, -1, -1, false);
PrintTool.arcPrint(img, 550, 400, 100, angle, "ANGLE" + angle + ":" + (char) c);
}
return img;
Expand Down
35 changes: 22 additions & 13 deletions source/de/anomic/yacy/graphics/NetworkGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static RasterPlotter getSearchEventPicture(final yacySeedDB seedDB, final
if (primarySearches[j] == null) continue;
eventPicture.setColor((primarySearches[j].isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(primarySearches[j].target().hash.getBytes(), null)) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle);
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, null, null, -1, -1, -1, false);
}

// draw in the secondary search peers
Expand All @@ -146,8 +146,8 @@ public static RasterPlotter getSearchEventPicture(final yacySeedDB seedDB, final
if (secondarySearches[j] == null) continue;
eventPicture.setColor((secondarySearches[j].isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(secondarySearches[j].target().hash.getBytes(), null)) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1);
eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1);
eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1, null, null, -1, -1, -1, false);
eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1, null, null, -1, -1, -1, false);
}
}

Expand All @@ -159,7 +159,7 @@ public static RasterPlotter getSearchEventPicture(final yacySeedDB seedDB, final
long[] positions = seedDB.scheme.dhtPositions(i.next());
for (int j = 0; j < positions.length; j++) {
angle = (int) (360.0 * (((double) positions[j]) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle);
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, null, null, -1, -1, -1, false);
}
}

Expand All @@ -170,7 +170,12 @@ public static RasterPlotter getNetworkPicture(final yacySeedDB seedDB, final lon
return drawNetworkPicture(seedDB, width, height, passiveLimit, potentialLimit, maxCount, coronaangle, communicationTimeout, networkName, networkTitle, bgcolor);
}

private static RasterPlotter drawNetworkPicture(final yacySeedDB seedDB, final int width, final int height, final int passiveLimit, final int potentialLimit, final int maxCount, final int coronaangle, final long communicationTimeout, final String networkName, final String networkTitle, final String bgcolor) {
private static RasterPlotter drawNetworkPicture(
final yacySeedDB seedDB, final int width, final int height,
final int passiveLimit, final int potentialLimit,
final int maxCount, final int coronaangle,
final long communicationTimeout,
final String networkName, final String networkTitle, final String bgcolor) {

RasterPlotter networkPicture = new RasterPlotter(width, height, (bgcolor.equals("000000")) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB, bgcolor);
if (seedDB == null) return networkPicture; // no other peers known
Expand Down Expand Up @@ -253,14 +258,14 @@ private static RasterPlotter drawNetworkPicture(final yacySeedDB seedDB, final i
if (event == null || event.getPubDate() == null) continue;
if (event.getPubDate().after(horizon)) {
//System.out.println("*** NETWORK-DHTRECEIVE: " + event.getLink());
drawNetworkPictureConnection(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTIN);
drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTIN);
}
}
for (Hit event: yacyChannel.channels(yacyChannel.DHTSEND)) {
if (event == null || event.getPubDate() == null) continue;
if (event.getPubDate().after(horizon)) {
//System.out.println("*** NETWORK-DHTSEND: " + event.getLink());
drawNetworkPictureConnection(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTOUT);
drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTOUT);
}
}
}
Expand All @@ -275,17 +280,22 @@ private static RasterPlotter drawNetworkPicture(final yacySeedDB seedDB, final i
return networkPicture;
}

private static void drawNetworkPictureConnection(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final yacySeed mySeed, final yacySeed otherSeed, final String colorLine) {
private static void drawNetworkPictureDHT(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final yacySeed mySeed, final yacySeed otherSeed, final String colorLine) {
final int angleMy = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(mySeed.hash.getBytes(), null)) / ((double) Long.MAX_VALUE)));
final int angleOther = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(otherSeed.hash.getBytes(), null)) / ((double) Long.MAX_VALUE)));
// draw line
img.setColor(colorLine);
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleMy);
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleOther);
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleMy, null, null, -1, -1, -1, false);
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleOther, null, null, -1, -1, -1, false);
img.arcConnect(centerX, centerY, innerradius - 20, angleMy, angleOther);
}

private static void drawNetworkPicturePeer(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final int outerradius, final yacySeed seed, final String colorDot, final String colorLine, final String colorText, final int coronaangle) {
private static void drawNetworkPicturePeer(
final RasterPlotter img, final int centerX, final int centerY,
final int innerradius, final int outerradius,
final yacySeed seed,
final String colorDot, final String colorLine, final String colorText,
final int coronaangle) {
final String name = seed.getName().toUpperCase() /*+ ":" + seed.hash + ":" + (((double) ((int) (100 * (((double) yacySeed.dhtPosition(seed.hash)) / ((double) yacySeed.maxDHTDistance))))) / 100.0)*/;
if (name.length() < shortestName) shortestName = name.length();
if (name.length() > longestName) longestName = name.length();
Expand All @@ -299,8 +309,7 @@ private static void drawNetworkPicturePeer(final RasterPlotter img, final int ce
img.setColor(colorDot);
img.arcDot(centerX, centerY, innerradius, angle, dotsize);
// draw line to text
img.setColor(colorLine);
img.arcLine(centerX, centerY, innerradius + 18, innerradius + linelength, angle);
img.arcLine(centerX, centerY, innerradius + 18, innerradius + linelength, angle, colorLine, "111111", 12, coronaangle / 30, 1, true);
// draw text
img.setColor(colorText);
PrintTool.arcPrint(img, centerX, centerY, innerradius + linelength, angle, name);
Expand Down
2 changes: 1 addition & 1 deletion source/net/yacy/visualization/ChartPlotter.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void chartDot(final int dimension_x, final int dimension_y, final int coo
final int x = (coord_x - offsets[dimension_x]) * pixels[dimension_x] / scales[dimension_x];
final int y = (coord_y - offsets[dimension_y]) * pixels[dimension_y] / scales[dimension_y];
if (dotsize == 1) plot(leftborder + x, height - bottomborder - y, 100);
else dot(leftborder + x, height - bottomborder - y, dotsize, true);
else dot(leftborder + x, height - bottomborder - y, dotsize, true, 100);
if (anot != null) PrintTool.print(this, leftborder + x + dotsize + 2 + ((anotAngle == 315) ? -9 : 0), height - bottomborder - y + ((anotAngle == 315) ? -3 : 0), anotAngle, anot, (anotAngle == 0) ? -1 : ((anotAngle == 315) ? 1 : 0));
}

Expand Down
10 changes: 5 additions & 5 deletions source/net/yacy/visualization/CircleTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static int[] getCircleCoords(final int radius) {
return circles[radius - 1];
}

public static void circle(final RasterPlotter matrix, final int xc, final int yc, final int radius) {
public static void circle(final RasterPlotter matrix, final int xc, final int yc, final int radius, int intensity) {
if (radius == 0) {
matrix.plot(xc, yc, 100);
} else {
Expand All @@ -108,10 +108,10 @@ public static void circle(final RasterPlotter matrix, final int xc, final int yc
for (int i = (c.length / 2) - 1; i >= 0; i--) {
x = c[2 * i ];
y = c[2 * i + 1];
matrix.plot(xc + x , yc - y - 1, 100); // quadrant 1
matrix.plot(xc - x + 1, yc - y - 1, 100); // quadrant 2
matrix.plot(xc + x , yc + y , 100); // quadrant 4
matrix.plot(xc - x + 1, yc + y , 100); // quadrant 3
matrix.plot(xc + x , yc - y - 1, intensity); // quadrant 1
matrix.plot(xc - x + 1, yc - y - 1, intensity); // quadrant 2
matrix.plot(xc + x , yc + y , intensity); // quadrant 4
matrix.plot(xc - x + 1, yc + y , intensity); // quadrant 3
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/net/yacy/visualization/GraphPlotter.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public RasterPlotter draw(
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, 6, true);
image.dot(x, y, 6, true, 100);
image.setColor(color_text);
PrintTool.print(image, x, y + 10, 0, name.toUpperCase(), 0);
}
Expand Down
Loading

0 comments on commit 29dc416

Please sign in to comment.