Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

animated network graphic!

orbiter2b4f8f6c06ce
diff --git a/htroot/Network.html b/htroot/Network.html
index 82d6a2071..7e9f23bc1 100644
--- a/htroot/Network.html
+++ b/htroot/Network.html
@@ -8,6 +8,24 @@
float: left;
}
</style>
+
+ <script type="text/javascript">
+ imgname = "NetworkPicture.png?width=768&height=576&bgcolor=FFFFFF&coronaangle=";
+ i = 0;
+ imagearray = new Array(4);
+ for (j = 0; j < 4; j++) {
+ imagearray[j] = new Image(768, 576);
+ angle = j * 90;
+ imagearray[j].src = imgname + angle;
+ }
+ setTimeout("doanimation()", 1000);
+ function doanimation() {
+ document.getElementById("NetworkPicture").src = imagearray[i].src;
+ i++;
+ if (i == 4) { i = 0; }
+ setTimeout("doanimation()", 100);
+ }
+ </script>
</head>
<body id="Network">
@@ -187,7 +205,7 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
</div>
<div class="left"><p>
- <a href="NetworkPicture.png?width=768&amp;height=576&amp;bgcolor=FFFFFF"><img src="NetworkPicture.png?width=768&amp;height=576&amp;bgcolor=FFFFFF" alt="The yacy Network" /></a>
+ <a href="NetworkPicture.png?width=768&height=576&bgcolor=FFFFFF"><img id="NetworkPicture" src="NetworkPicture.png?width=768&height=576&bgcolor=FFFFFF&coronaangle=0" alt="The YaCy Network" /></a>
</p></div>
<div class="left">
Your Peer:
@@ -232,7 +250,7 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
</tr>
</table>
</div>
- <div class="left"><p>
+ <div class="left">
<table border="0">
<tr>
<td>&nbsp;</td>
@@ -264,7 +282,13 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
<td>:</td>
<td>this peer</td>
</tr>
- </table></p>
+ <tr>
+ <td style="background-color:#AAAAAA">&nbsp;</td>
+ <td>waves</td>
+ <td>:</td>
+ <td>crawling activity</td>
+ </tr>
+ </table>
</div>
::
diff --git a/htroot/NetworkPicture.java b/htroot/NetworkPicture.java
index 61c496274..16256c9ff 100644
--- a/htroot/NetworkPicture.java
+++ b/htroot/NetworkPicture.java
@@ -37,6 +37,7 @@ public class NetworkPicture {
public static RasterPlotter respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
final Switchboard sb = (Switchboard) env;
+ final boolean authorized = sb.adminAuthenticated(header) >= 2;
int width = 768;
int height = 576;
@@ -45,6 +46,7 @@ public class NetworkPicture {
int maxCount = 1000;
String bgcolor = NetworkGraph.COL_BACKGROUND;
boolean corona = true;
+ int coronaangle = 0;
if (post != null) {
width = post.getInt("width", 768);
@@ -53,6 +55,7 @@ public class NetworkPicture {
potentialLimit = post.getInt("pol", 1440);
maxCount = post.getInt("max", 1000);
corona = post.get("corona", "true").equals("true");
+ coronaangle = (corona) ? post.getInt("coronaangle", 0) : -1;
bgcolor = post.get("bgcolor", bgcolor);
}
@@ -61,10 +64,14 @@ public class NetworkPicture {
if (width > 1920) width = 1920;
if (height < 240) height = 240;
if (height > 1920) height = 1920;
+ if (!authorized) {
+ width = Math.min(768, width);
+ height = Math.min(576, height);
+ }
if (passiveLimit > 1000000) passiveLimit = 1000000;
if (potentialLimit > 1000000) potentialLimit = 1000000;
if (maxCount > 10000) maxCount = 10000;
- return NetworkGraph.getNetworkPicture(sb.peers, 10000, width, height, passiveLimit, potentialLimit, maxCount, corona, env.getConfig(SwitchboardConstants.NETWORK_NAME, "unspecified"), env.getConfig("network.unit.description", "unspecified"), bgcolor);
+ return NetworkGraph.getNetworkPicture(sb.peers, 10000, width, height, passiveLimit, potentialLimit, maxCount, coronaangle, env.getConfig(SwitchboardConstants.NETWORK_NAME, "unspecified"), env.getConfig("network.unit.description", "unspecified"), bgcolor);
}
}
diff --git a/htroot/SearchEventPicture.java b/htroot/SearchEventPicture.java
index a087e0450..57780624d 100644
--- a/htroot/SearchEventPicture.java
+++ b/htroot/SearchEventPicture.java
@@ -40,7 +40,7 @@ public class SearchEventPicture {
final Switchboard sb = (Switchboard) env;
final String eventID = header.get("event", SearchEventCache.lastEventID);
if (eventID == null) return null;
- final RasterPlotter yp = NetworkGraph.getSearchEventPicture(sb.peers, eventID);
+ final RasterPlotter yp = NetworkGraph.getSearchEventPicture(sb.peers, eventID, 0);
if (yp == null) return new RasterPlotter(1, 1, RasterPlotter.MODE_SUB, "000000"); // empty image
return yp;
diff --git a/source/de/anomic/yacy/graphics/NetworkGraph.java b/source/de/anomic/yacy/graphics/NetworkGraph.java
index f26efc5f9..b3b8f8c97 100644
--- a/source/de/anomic/yacy/graphics/NetworkGraph.java
+++ b/source/de/anomic/yacy/graphics/NetworkGraph.java
@@ -101,19 +101,16 @@ public class NetworkGraph {
}
}
- private static final int LEGEND_BOX_SIZE = 10;
-
- private static RasterPlotter networkPicture = null;
- private static long networkPictureDate = 0;
+ private static final int LEGEND_BOX_SIZE = 10;
private static BufferedImage peerloadPicture = null;
private static long peerloadPictureDate = 0;
- private static RasterPlotter bannerPicture = null; // [MN]
+ private static RasterPlotter bannerPicture = null; // [MN]
private static BufferedImage logo = null; // [MN]
private static long bannerPictureDate = 0; // [MN]
- public static RasterPlotter getSearchEventPicture(final yacySeedDB seedDB, final String eventID) {
+ public static RasterPlotter getSearchEventPicture(final yacySeedDB seedDB, final String eventID, final int coronaangle) {
final SearchEvent event = SearchEventCache.getEvent(eventID);
if (event == null) return null;
final yacySearch[] primarySearches = event.getPrimarySearchThreads();
@@ -121,7 +118,7 @@ public class NetworkGraph {
if (primarySearches == null) return null; // this was a local search and there are no threads
// get a copy of a recent network picture
- final RasterPlotter eventPicture = getNetworkPicture(seedDB, 120000, 640, 480, 300, 300, 1000, true, Switchboard.getSwitchboard().getConfig(SwitchboardConstants.NETWORK_NAME, "unspecified"), Switchboard.getSwitchboard().getConfig("network.unit.description", "unspecified"), COL_BACKGROUND);
+ final RasterPlotter eventPicture = getNetworkPicture(seedDB, 120000, 640, 480, 300, 300, 1000, coronaangle, Switchboard.getSwitchboard().getConfig(SwitchboardConstants.NETWORK_NAME, "unspecified"), Switchboard.getSwitchboard().getConfig("network.unit.description", "unspecified"), COL_BACKGROUND);
//if (eventPicture instanceof ymageMatrix) eventPicture = (ymageMatrix) eventPicture; //new ymageMatrix((ymageMatrix) eventPicture);
// TODO: fix cloning of ymageMatrix pictures
@@ -164,23 +161,19 @@ public class NetworkGraph {
return eventPicture;
}
- public static RasterPlotter getNetworkPicture(final yacySeedDB seedDB, final long maxAge, final int width, final int height, final int passiveLimit, final int potentialLimit, final int maxCount, final boolean corona, final String networkName, final String networkTitle, final String bgcolor) {
- if ((networkPicture == null) || ((System.currentTimeMillis() - networkPictureDate) > maxAge)) {
- drawNetworkPicture(seedDB, width, height, passiveLimit, potentialLimit, maxCount, corona, networkName, networkTitle, bgcolor);
- }
- return networkPicture;
+ public static RasterPlotter getNetworkPicture(final yacySeedDB seedDB, final long maxAge, final int width, final int height, final int passiveLimit, final int potentialLimit, final int maxCount, final int coronaangle, final String networkName, final String networkTitle, final String bgcolor) {
+ return drawNetworkPicture(seedDB, width, height, passiveLimit, potentialLimit, maxCount, coronaangle, networkName, networkTitle, bgcolor);
}
- private static void drawNetworkPicture(final yacySeedDB seedDB, final int width, final int height, final int passiveLimit, final int potentialLimit, final int maxCount, final boolean corona, 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 String networkName, final String networkTitle, final String bgcolor) {
- if (seedDB == null) return; // no other peers known
+ RasterPlotter networkPicture = new RasterPlotter(width, height, (bgcolor.equals("000000")) ? RasterPlotter.MODE_ADD : RasterPlotter.MODE_SUB, bgcolor);
+ if (seedDB == null) return networkPicture; // no other peers known
final int innerradius = Math.min(width, height) / 5;
int outerradius = innerradius + innerradius * seedDB.sizeConnected() / 100;
if (outerradius > innerradius * 2) outerradius = innerradius * 2;
- networkPicture = new RasterPlotter(width, height, (bgcolor.equals("000000")) ? RasterPlotter.MODE_ADD : RasterPlotter.MODE_SUB, bgcolor);
-
// draw network circle
networkPicture.setColor(COL_DHTCIRCLE);
networkPicture.arc(width / 2, height / 2 + 20, innerradius - 20, innerradius + 20, 0, 360);
@@ -199,7 +192,7 @@ public class NetworkGraph {
while (e.hasNext() && count < maxCount) {
seed = e.next();
if (seed != null) {
- drawNetworkPicturePeer(networkPicture, width / 2, height / 2 + 20, innerradius, outerradius, seed, COL_ACTIVE_DOT, COL_ACTIVE_LINE, COL_ACTIVE_TEXT, corona);
+ drawNetworkPicturePeer(networkPicture, width / 2, height / 2 + 20, innerradius, outerradius, seed, COL_ACTIVE_DOT, COL_ACTIVE_LINE, COL_ACTIVE_TEXT, coronaangle);
count++;
}
}
@@ -213,7 +206,7 @@ public class NetworkGraph {
if (seed != null) {
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 + 20, innerradius, outerradius, seed, COL_PASSIVE_DOT, COL_PASSIVE_LINE, COL_PASSIVE_TEXT, corona);
+ drawNetworkPicturePeer(networkPicture, width / 2, height / 2 + 20, innerradius, outerradius, seed, COL_PASSIVE_DOT, COL_PASSIVE_LINE, COL_PASSIVE_TEXT, coronaangle);
count++;
}
}
@@ -227,14 +220,14 @@ public class NetworkGraph {
if (seed != null) {
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 + 20, innerradius, outerradius, seed, COL_POTENTIAL_DOT, COL_POTENTIAL_LINE, COL_POTENTIAL_TEXT, corona);
+ drawNetworkPicturePeer(networkPicture, width / 2, height / 2 + 20, innerradius, outerradius, seed, COL_POTENTIAL_DOT, COL_POTENTIAL_LINE, COL_POTENTIAL_TEXT, coronaangle);
count++;
}
}
totalCount += count;
// draw my own peer
- drawNetworkPicturePeer(networkPicture, width / 2, height / 2 + 20, innerradius, outerradius, seedDB.mySeed(), COL_WE_DOT, COL_WE_LINE, COL_WE_TEXT, corona);
+ drawNetworkPicturePeer(networkPicture, width / 2, height / 2 + 20, innerradius, outerradius, seedDB.mySeed(), COL_WE_DOT, COL_WE_LINE, COL_WE_TEXT, coronaangle);
// draw description
networkPicture.setColor(COL_HEADLINE);
@@ -243,11 +236,10 @@ public class NetworkGraph {
PrintTool.print(networkPicture, width - 2, 8, 0, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), 1);
PrintTool.print(networkPicture, width - 2, 16, 0, "DRAWING OF " + totalCount + " SELECTED PEERS", 1);
- // set timestamp
- networkPictureDate = System.currentTimeMillis();
+ return networkPicture;
}
- private static void drawNetworkPicturePeer(final RasterPlotter img, final int x, final int y, final int innerradius, final int outerradius, final yacySeed seed, final String colorDot, final String colorLine, final String colorText, final boolean corona) {
+ private static void drawNetworkPicturePeer(final RasterPlotter img, final int x, final int y, 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();
@@ -269,7 +261,8 @@ public class NetworkGraph {
// draw corona around dot for crawling activity
int ppm20 = seed.getPPM() / 20;
- if ((corona) && (ppm20 > 0)) {
+ if (coronaangle >= 0 && ppm20 > 0) {
+ double ca = Math.PI * 2.0 * ((double) coronaangle) / 360.0;
if (ppm20 > 3) ppm20 = 3;
// draw a wave around crawling peers
long strength;
@@ -277,7 +270,7 @@ public class NetworkGraph {
img.arcArc(x, y, innerradius, angle, dotsize + 1, dotsize + 1, 0, 360);
final int waveradius = innerradius / 2;
for (int r = 0; r < waveradius; r++) {
- strength = (waveradius - r) * (long) (0x08 * ppm20 * (1.0 + Math.sin(Math.PI * 16 * r / waveradius))) / waveradius;
+ strength = (waveradius - r) * (long) (0x08 * ppm20 * (1.0 + Math.sin(ca + 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);