final long communicationTimeout,
final String networkName, final String networkTitle, final String color_back,
final int cyc) {
final RasterPlotter.DrawMode drawMode = (RasterPlotter.darkColor(color_back)) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB;
final RasterPlotter networkPicture = new RasterPlotter(width, height, drawMode, color_back);
if (seedDB == null) return networkPicture; // no other peers known
final int maxradius = Math.min(width, height) / 2;
final int innerradius = maxradius * 4 / 10;
final int outerradius = maxradius - 20;
// draw network circle
networkPicture.setColor(COL_DHTCIRCLE);
networkPicture.arc(width / 2, height / 2, innerradius - 20, innerradius + 20, 100);
//System.out.println("Seed Maximum distance is " + yacySeed.maxDHTDistance);
//System.out.println("Seed Minimum distance is " + yacySeed.minDHTNumber);
yacySeed seed;
long lastseen;
// draw connected senior and principals
int count = 0;
int totalCount = 0;
Iterator<yacySeed> e = seedDB.seedsConnected(true, false, null, (float) 0.0);
while (e.hasNext() && count < maxCount) {
seed = e.next();
if (seed == null) {
Log.logWarning("NetworkGraph", "connected seed == null");
continue;
}
//Log.logInfo("NetworkGraph", "drawing peer " + seed.getName());
drawNetworkPicturePeer(networkPicture, width / 2, height / 2, innerradius, outerradius, seed, COL_ACTIVE_DOT, COL_ACTIVE_LINE, COL_ACTIVE_TEXT, coronaangle, cyc);
count++;
}
totalCount += count;
// draw disconnected senior and principals that have been seen lately
count = 0;
e = seedDB.seedsSortedDisconnected(false, yacySeed.LASTSEEN);
while (e.hasNext() && count < maxCount) {
seed = e.next();
if (seed == null) {
Log.logWarning("NetworkGraph", "disconnected seed == null");
continue;
}
lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenUTC()) / 1000 / 60);
if (lastseen > passiveLimit) {
break; // we have enough, this list is sorted so we don't miss anything
}
drawNetworkPicturePeer(networkPicture, width / 2, height / 2, innerradius, outerradius, seed, COL_PASSIVE_DOT, COL_PASSIVE_LINE, COL_PASSIVE_TEXT, coronaangle, cyc);
count++;
}
totalCount += count;
// draw juniors that have been seen lately
count = 0;
e = seedDB.seedsSortedPotential(false, yacySeed.LASTSEEN);
while (e.hasNext() && count < maxCount) {
seed = e.next();
if (seed == null) {
Log.logWarning("NetworkGraph", "potential seed == null");
continue;
}
lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenUTC()) / 1000 / 60);
if (lastseen > potentialLimit) {
break; // we have enough, this list is sorted so we don't miss anything
}
drawNetworkPicturePeer(networkPicture, width / 2, height / 2, innerradius, outerradius, seed, COL_POTENTIAL_DOT, COL_POTENTIAL_LINE, COL_POTENTIAL_TEXT, coronaangle, cyc);
count++;
}
totalCount += count;
// draw my own peer
drawNetworkPicturePeer(networkPicture, width / 2, height / 2, innerradius, outerradius, seedDB.mySeed(), COL_MYPEER_DOT, COL_MYPEER_LINE, COL_MYPEER_TEXT, coronaangle, cyc);
// draw DHT activity
if (communicationTimeout >= 0) {
final Date horizon = new Date(System.currentTimeMillis() - communicationTimeout);
for (final Hit event: yacyChannel.channels(yacyChannel.DHTRECEIVE)) {
if (event == null || event.getPubDate() == null) continue;
if (event.getPubDate().after(horizon)) {
//System.out.println("*** NETWORK-DHTRECEIVE: " + event.getLink());
drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTIN, coronaangle, false, cyc);
}
}
for (final 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());
drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTOUT, coronaangle, true, cyc);
}
}
}
// draw description
networkPicture.setColor(COL_HEADLINE);
PrintTool.print(networkPicture, 2, 6, 0, "YACY NETWORK '" + networkName.toUpperCase() + "'", -1);
PrintTool.print(networkPicture, 2, 14, 0, networkTitle.toUpperCase(), -1);
PrintTool.print(networkPicture, width - 2, 6, 0, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), 1);
PrintTool.print(networkPicture, width - 2, 14, 0, "DRAWING OF " + totalCount + " SELECTED PEERS", 1);