From dced5c761efc62386d8fbcf6a1d58457290cac1c Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 10 Oct 2005 16:21:09 +0000 Subject: [PATCH] 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 --- htroot/NetworkPicture.java | 33 +++++++++++++++++++----- source/de/anomic/tools/ImagePainter.java | 22 ++++++++++------ 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/htroot/NetworkPicture.java b/htroot/NetworkPicture.java index 11435a8f7..5d413aa4f 100644 --- a/htroot/NetworkPicture.java +++ b/htroot/NetworkPicture.java @@ -106,7 +106,7 @@ public class NetworkPicture { while (e.hasMoreElements() && count < maxCount) { seed = (yacySeed) e.nextElement(); 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++; } } @@ -120,7 +120,7 @@ public class NetworkPicture { if (seed != null) { 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 - drawPeer(img, width / 2, height / 2, innerradius, outerradius, seed, "101010", "802000"); + drawPeer(img, width / 2, height / 2, innerradius, outerradius, seed, "101010", "401000", "802000"); count++; } } @@ -134,17 +134,18 @@ public class NetworkPicture { if (seed != null) { 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 - drawPeer(img, width / 2, height / 2, innerradius, outerradius, seed, "202000", "A0A000"); + drawPeer(img, width / 2, height / 2, innerradius, outerradius, seed, "202000", "505000", "A0A000"); count++; } } totalCount += count; // 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 img.setColor("FFFFFF"); + img.setMode(ImagePainter.MODE_ADD); img.print(2, 8, "THE YACY NETWORK", true); img.print(2, 16, "DRAWING OF " + totalCount + " SELECTED PEERS", true); img.print(width - 2, 8, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), false); @@ -152,7 +153,7 @@ public class NetworkPicture { 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(); if (name.length() < shortestName) shortestName = name.length(); if (name.length() > longestName) longestName = name.length(); @@ -162,11 +163,29 @@ public class NetworkPicture { if (linelength > outerradius) linelength = outerradius; int dotsize = 6 + 2 * (int) (seed.getLinkCount() / 500000L); if (dotsize > 18) dotsize = 18; + img.setMode(ImagePainter.MODE_ADD); + // draw dot img.setColor(colorDot); - img.arcDot(x, y, innerradius, dotsize, angle); - img.setColor(colorText); + img.arcDot(x, y, innerradius, angle, dotsize); + // draw line to text + img.setColor(colorLine); img.arcLine(x, y, innerradius + 18, innerradius + linelength, angle); + // draw text + img.setColor(colorText); 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); + } } } diff --git a/source/de/anomic/tools/ImagePainter.java b/source/de/anomic/tools/ImagePainter.java index ee5c7fbfb..6bf96e6b3 100644 --- a/source/de/anomic/tools/ImagePainter.java +++ b/source/de/anomic/tools/ImagePainter.java @@ -130,9 +130,9 @@ public class ImagePainter { } public void setColor(long c) { - defaultColR = (byte) (c >> 16); - defaultColG = (byte) ((c >> 8) & 0xff); - defaultColB = (byte) (c & 0xff); + defaultColR = (int) (c >> 16); + defaultColG = (int) ((c >> 8) & 0xff); + defaultColB = (int) (c & 0xff); } public void setColor(String s) { @@ -140,25 +140,25 @@ public class ImagePainter { } public void setMode(byte m) { - defaultMode = m; + this.defaultMode = m; } private void plot(int x, int y) { if ((x < 0) || (x >= width)) return; if ((y < 0) || (y >= height)) return; int n = 3 * (x + y * width); - if (defaultMode == MODE_REPLACE) { + if (this.defaultMode == MODE_REPLACE) { grid[n ] = (byte) defaultColR; grid[n + 1] = (byte) defaultColG; 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 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; grid[n ] = (byte) r; grid[n + 1] = (byte) g; 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 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; @@ -369,12 +369,18 @@ public class ImagePainter { 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 y = cy - (int) (arcRadius * Math.sin(Math.PI * angle / 180)); 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) { /* GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();