Skip to content

Commit

Permalink
crawling peers now produce waves in network graphic
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@912 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Oct 11, 2005
1 parent b45ffec commit b80b2fb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
19 changes: 17 additions & 2 deletions htroot/NetworkPicture.java
Expand Up @@ -80,15 +80,15 @@ public static BufferedImage respond(httpHeader header, serverObjects post, serve
shortestName = 10;
longestName = 12;

ImagePainter img = new ImagePainter(width, height, 0);
ImagePainter img = new ImagePainter(width, height, "000010");
img.setMode(ImagePainter.MODE_ADD);

if (yacyCore.seedDB == null) return img.toImage(true); // no other peers known
int size = yacyCore.seedDB.sizeConnected();
if (size == 0) return img.toImage(true); // no other peers known

// draw network circle
img.setColor("004020");
img.setColor("008020");
img.arc(width / 2, height / 2, innerradius - 20, innerradius + 20, 0, 360);

//System.out.println("Seed Maximum distance is " + yacySeed.maxDHTDistance);
Expand Down Expand Up @@ -177,6 +177,20 @@ private static void drawPeer(ImagePainter img, int x, int y, int innerradius, in
int ppm10 = seed.getPPM() / 10;
if (ppm10 > 0) {
if (ppm10 > 3) ppm10 = 3;
// draw a wave around crawling peers
long strength;
img.setMode(ImagePainter.MODE_SUB);
img.setColor("303030");
img.arcArc(x, y, innerradius, angle, dotsize + 1, dotsize + 1, 0, 360);
int waveradius = innerradius / 2;
for (int r = 0; r < waveradius; r++) {
strength = (waveradius - r) * (long) (0x08 * ppm10 * (1.0 + Math.sin(Math.PI * 16 * r / waveradius))) / waveradius;
//System.out.println("r = " + r + ", Strength = " + strength);
img.setColor((strength << 16) | (strength << 8) | strength);
img.arcArc(x, y, innerradius, angle, dotsize + r, dotsize + r, 0, 360);
}
/*
// draw corona
img.setMode(ImagePainter.MODE_SUB);
img.setColor("303030");
img.arcArc(x, y, innerradius, angle, dotsize + 1, dotsize + ppm10 + 1, 0, 360);
Expand All @@ -185,6 +199,7 @@ private static void drawPeer(ImagePainter img, int x, int y, int innerradius, in
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);
*/
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/de/anomic/plasma/plasmaWordIndexDistribution.java
Expand Up @@ -264,7 +264,7 @@ public int performTransferIndex(int indexCount, int peerCount, boolean delete) {
}
return indexCount;
} else {
log.logSevere("Index distribution failed. Too less peers (" + hc + ") received the index, not deleted locally.");
log.logSevere("Index distribution failed. Too few peers (" + hc + ") received the index, not deleted locally.");
return -1;
}
}
Expand Down
8 changes: 6 additions & 2 deletions source/de/anomic/tools/ImagePainter.java
Expand Up @@ -98,6 +98,10 @@ public class ImagePainter {
private int defaultColR, defaultColG, defaultColB;
private byte defaultMode;

public ImagePainter(int width, int height, String backgroundColor) {
this(width, height, colNum(backgroundColor));
}

public ImagePainter(int width, int height, long backgroundColor) {
this.width = width;
this.height = height;
Expand All @@ -118,12 +122,12 @@ public ImagePainter(int width, int height, long backgroundColor) {
}
}

private long colNum(String col) {
private static long colNum(String col) {
return Long.parseLong(col, 16);
//return Integer.parseInt(col.substring(0,2), 16) << 16 | Integer.parseInt(col.substring(2,4), 16) << 8 | Integer.parseInt(col.substring(4,6), 16);
}

private String colStr(long c) {
private static String colStr(long c) {
String s = Long.toHexString(c);
while (s.length() < 6) s = "0" + s;
return s;
Expand Down

0 comments on commit b80b2fb

Please sign in to comment.