added 'corona' for crawling peers in network graphic

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@909 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 20 years ago
parent 4cf0d1eb6d
commit dced5c761e

@ -106,7 +106,7 @@ public class NetworkPicture {
while (e.hasMoreElements() && count < maxCount) { while (e.hasMoreElements() && count < maxCount) {
seed = (yacySeed) e.nextElement(); seed = (yacySeed) e.nextElement();
if (seed != null) { if (seed != null) {
drawPeer(img, width / 2, height / 2, innerradius, outerradius, seed, "000040", "B0FFB0"); drawPeer(img, width / 2, height / 2, innerradius, outerradius, seed, "000040", "608860", "B0FFB0");
count++; count++;
} }
} }
@ -120,7 +120,7 @@ public class NetworkPicture {
if (seed != null) { if (seed != null) {
lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenTime()) / 1000 / 60); lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenTime()) / 1000 / 60);
if (lastseen > 120) break; // we have enough, this list is sorted so we don't miss anything if (lastseen > 120) break; // we have enough, this list is sorted so we don't miss anything
drawPeer(img, width / 2, height / 2, innerradius, outerradius, seed, "101010", "802000"); drawPeer(img, width / 2, height / 2, innerradius, outerradius, seed, "101010", "401000", "802000");
count++; count++;
} }
} }
@ -134,17 +134,18 @@ public class NetworkPicture {
if (seed != null) { if (seed != null) {
lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenTime()) / 1000 / 60); lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenTime()) / 1000 / 60);
if (lastseen > 120) break; // we have enough, this list is sorted so we don't miss anything if (lastseen > 120) break; // we have enough, this list is sorted so we don't miss anything
drawPeer(img, width / 2, height / 2, innerradius, outerradius, seed, "202000", "A0A000"); drawPeer(img, width / 2, height / 2, innerradius, outerradius, seed, "202000", "505000", "A0A000");
count++; count++;
} }
} }
totalCount += count; totalCount += count;
// draw my own peer // draw my own peer
drawPeer(img, width / 2, height / 2, innerradius, outerradius, yacyCore.seedDB.mySeed, "800000", "FFFFFF"); drawPeer(img, width / 2, height / 2, innerradius, outerradius, yacyCore.seedDB.mySeed, "800000", "AAAAAA", "FFFFFF");
// draw description // draw description
img.setColor("FFFFFF"); img.setColor("FFFFFF");
img.setMode(ImagePainter.MODE_ADD);
img.print(2, 8, "THE YACY NETWORK", true); img.print(2, 8, "THE YACY NETWORK", true);
img.print(2, 16, "DRAWING OF " + totalCount + " SELECTED PEERS", true); img.print(2, 16, "DRAWING OF " + totalCount + " SELECTED PEERS", true);
img.print(width - 2, 8, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), false); img.print(width - 2, 8, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), false);
@ -152,7 +153,7 @@ public class NetworkPicture {
return img.toImage(true); return img.toImage(true);
} }
private static void drawPeer(ImagePainter img, int x, int y, int innerradius, int outerradius, yacySeed seed, String colorDot, String colorText) { private static void drawPeer(ImagePainter img, int x, int y, int innerradius, int outerradius, yacySeed seed, String colorDot, String colorLine, String colorText) {
String name = seed.getName().toUpperCase(); String name = seed.getName().toUpperCase();
if (name.length() < shortestName) shortestName = name.length(); if (name.length() < shortestName) shortestName = name.length();
if (name.length() > longestName) longestName = name.length(); if (name.length() > longestName) longestName = name.length();
@ -162,11 +163,29 @@ public class NetworkPicture {
if (linelength > outerradius) linelength = outerradius; if (linelength > outerradius) linelength = outerradius;
int dotsize = 6 + 2 * (int) (seed.getLinkCount() / 500000L); int dotsize = 6 + 2 * (int) (seed.getLinkCount() / 500000L);
if (dotsize > 18) dotsize = 18; if (dotsize > 18) dotsize = 18;
img.setMode(ImagePainter.MODE_ADD);
// draw dot
img.setColor(colorDot); img.setColor(colorDot);
img.arcDot(x, y, innerradius, dotsize, angle); img.arcDot(x, y, innerradius, angle, dotsize);
img.setColor(colorText); // draw line to text
img.setColor(colorLine);
img.arcLine(x, y, innerradius + 18, innerradius + linelength, angle); img.arcLine(x, y, innerradius + 18, innerradius + linelength, angle);
// draw text
img.setColor(colorText);
img.arcPrint(x, y, innerradius + linelength, angle, name); img.arcPrint(x, y, innerradius + linelength, angle, name);
// draw corona around dot for crawling activity
int ppm10 = seed.getPPM() / 10;
if (ppm10 > 0) {
if (ppm10 > 3) ppm10 = 3;
img.setMode(ImagePainter.MODE_SUB);
img.setColor("303030");
img.arcArc(x, y, innerradius, angle, dotsize + 1, dotsize + ppm10 + 1, 0, 360);
img.setMode(ImagePainter.MODE_ADD);
img.setColor("200000");
img.arcArc(x, y, innerradius, angle, dotsize + ppm10 , dotsize + ppm10 , 0, 360);
img.setColor("500000");
img.arcArc(x, y, innerradius, angle, dotsize + ppm10 + 1, dotsize + ppm10 + 1, 0, 360);
}
} }
} }

@ -130,9 +130,9 @@ public class ImagePainter {
} }
public void setColor(long c) { public void setColor(long c) {
defaultColR = (byte) (c >> 16); defaultColR = (int) (c >> 16);
defaultColG = (byte) ((c >> 8) & 0xff); defaultColG = (int) ((c >> 8) & 0xff);
defaultColB = (byte) (c & 0xff); defaultColB = (int) (c & 0xff);
} }
public void setColor(String s) { public void setColor(String s) {
@ -140,25 +140,25 @@ public class ImagePainter {
} }
public void setMode(byte m) { public void setMode(byte m) {
defaultMode = m; this.defaultMode = m;
} }
private void plot(int x, int y) { private void plot(int x, int y) {
if ((x < 0) || (x >= width)) return; if ((x < 0) || (x >= width)) return;
if ((y < 0) || (y >= height)) return; if ((y < 0) || (y >= height)) return;
int n = 3 * (x + y * width); int n = 3 * (x + y * width);
if (defaultMode == MODE_REPLACE) { if (this.defaultMode == MODE_REPLACE) {
grid[n ] = (byte) defaultColR; grid[n ] = (byte) defaultColR;
grid[n + 1] = (byte) defaultColG; grid[n + 1] = (byte) defaultColG;
grid[n + 2] = (byte) defaultColB; grid[n + 2] = (byte) defaultColB;
} else if (defaultMode == MODE_ADD) { } else if (this.defaultMode == MODE_ADD) {
int r = ((int) (0xff & grid[n ])) + defaultColR; if (r > 0xff) r = 0xff; int r = ((int) (0xff & grid[n ])) + defaultColR; if (r > 0xff) r = 0xff;
int g = ((int) (0xff & grid[n + 1])) + defaultColG; if (g > 0xff) g = 0xff; int g = ((int) (0xff & grid[n + 1])) + defaultColG; if (g > 0xff) g = 0xff;
int b = ((int) (0xff & grid[n + 2])) + defaultColB; if (b > 0xff) b = 0xff; int b = ((int) (0xff & grid[n + 2])) + defaultColB; if (b > 0xff) b = 0xff;
grid[n ] = (byte) r; grid[n ] = (byte) r;
grid[n + 1] = (byte) g; grid[n + 1] = (byte) g;
grid[n + 2] = (byte) b; grid[n + 2] = (byte) b;
} else if (defaultMode == MODE_SUB) { } else if (this.defaultMode == MODE_SUB) {
int r = ((int) (0xff & grid[n ])) - defaultColR; if (r < 0) r = 0; int r = ((int) (0xff & grid[n ])) - defaultColR; if (r < 0) r = 0;
int g = ((int) (0xff & grid[n + 1])) - defaultColG; if (g < 0) g = 0; int g = ((int) (0xff & grid[n + 1])) - defaultColG; if (g < 0) g = 0;
int b = ((int) (0xff & grid[n + 2])) - defaultColB; if (b < 0) b = 0; int b = ((int) (0xff & grid[n + 2])) - defaultColB; if (b < 0) b = 0;
@ -369,12 +369,18 @@ public class ImagePainter {
line(xi, yi, xo, yo); line(xi, yi, xo, yo);
} }
public void arcDot(int cx, int cy, int arcRadius, int dotRadius, int angle) { public void arcDot(int cx, int cy, int arcRadius, int angle, int dotRadius) {
int x = cx + (int) (arcRadius * Math.cos(Math.PI * angle / 180)); int x = cx + (int) (arcRadius * Math.cos(Math.PI * angle / 180));
int y = cy - (int) (arcRadius * Math.sin(Math.PI * angle / 180)); int y = cy - (int) (arcRadius * Math.sin(Math.PI * angle / 180));
dot(x, y, dotRadius, true); dot(x, y, dotRadius, true);
} }
public void arcArc(int cx, int cy, int arcRadius, int angle, int innerRadius, int outerRadius, int fromArc, int toArc) {
int x = cx + (int) (arcRadius * Math.cos(Math.PI * angle / 180));
int y = cy - (int) (arcRadius * Math.sin(Math.PI * angle / 180));
arc(x, y, innerRadius, outerRadius, fromArc, toArc);
}
public BufferedImage toImage(boolean complementary) { public BufferedImage toImage(boolean complementary) {
/* /*
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

Loading…
Cancel
Save