- added more options to access grid picture, web structure picture and network graphics

- remove test class


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7770 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent efcd21e0ed
commit 2683162ec5

@ -11,7 +11,7 @@
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
imagestub = "AccessPicture_p.png?width=1024&height=576&bgcolor=FFFFFF&ct=5000&coronaangle="; imagestub = "AccessPicture_p.png?width=1024&height=576&colorback=FFFFFF&amp;colortext=AAAAAA&amp;colorgrid=333333&amp;colordot=33CC33&amp;colorline=555555&ct=5000&coronaangle=";
imageanimindex = 0; imageanimindex = 0;
imageloadindex = 0; imageloadindex = 0;
imagecycles = 0; imagecycles = 0;
@ -53,7 +53,7 @@
<p>This images shows incoming connections to your YaCy peer and outgoing connections from your peer to other peers and web servers</p> <p>This images shows incoming connections to your YaCy peer and outgoing connections from your peer to other peers and web servers</p>
<div class="left"> <div class="left">
<p> <p>
<a href="AccessPicture_p.png?width=1024&amp;height=576&amp;bgcolor=FFFFFF"><img id="AccessPicture" src="AccessPicture_p.png?width=1024&amp;height=576&amp;bgcolor=FFFFFF&amp;coronaangle=0" alt="YaCy Access Grid" width="1024" height="576" /></a> <a href="AccessPicture_p.png?width=1024&amp;height=576&amp;colorback=FFFFFF&amp;colortext=AAAAAA&amp;colorgrid=333333&amp;colordot=33CC33&amp;colorline=555555"><img id="AccessPicture" src="AccessPicture_p.png?width=1024&amp;height=576&amp;bgcolor=FFFFFF&amp;coronaangle=0" alt="YaCy Access Grid" width="1024" height="576" /></a>
</p> </p>
</div> </div>

@ -32,7 +32,6 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.visualization.HexGridPlotter; import net.yacy.visualization.HexGridPlotter;
import net.yacy.visualization.PrintTool; import net.yacy.visualization.PrintTool;
import net.yacy.visualization.RasterPlotter; import net.yacy.visualization.RasterPlotter;
import net.yacy.visualization.RasterPlotter.DrawMode;
import de.anomic.search.Switchboard; import de.anomic.search.Switchboard;
import de.anomic.server.serverObjects; import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch; import de.anomic.server.serverSwitch;
@ -76,17 +75,18 @@ public class AccessPicture_p {
if (height < 24) height = 24; if (height < 24) height = 24;
if (height > 10000) height = 10000; if (height > 10000) height = 10000;
final HexGridPlotter picture = new HexGridPlotter(width, height, DrawMode.MODE_SUB, color_back, cellsize); final RasterPlotter.DrawMode drawMode = (RasterPlotter.darkColor(color_back)) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB;
final HexGridPlotter picture = new HexGridPlotter(width, height, drawMode, color_back, cellsize);
picture.drawGrid(color_grid); picture.drawGrid(color_grid);
// calculate dimensions for left and right column // calculate dimensions for left and right column
int gridLeft = 0; final int gridLeft = 0;
int gridRight = picture.gridWidth() - 2; int gridRight = picture.gridWidth() - 2;
if ((gridRight & 1) == 0) gridRight--; if ((gridRight & 1) == 0) gridRight--;
// draw home peer // draw home peer
int centerx = (picture.gridWidth() >> 1) - 1; final int centerx = (picture.gridWidth() >> 1) - 1;
int centery = picture.gridHeight() >> 1; final int centery = picture.gridHeight() >> 1;
picture.setColor(color_dot); picture.setColor(color_dot);
picture.gridDot(centerx, centery, 5, true, 100); picture.gridDot(centerx, centery, 5, true, 100);
if (corona) { if (corona) {
@ -101,25 +101,25 @@ public class AccessPicture_p {
picture.gridPrint(centerx, centery, 5, "THIS YACY PEER", "\"" + sb.peers.myName().toUpperCase() + "\"", 0); picture.gridPrint(centerx, centery, 5, "THIS YACY PEER", "\"" + sb.peers.myName().toUpperCase() + "\"", 0);
// left column: collect data for access from outside // left column: collect data for access from outside
int verticalSlots = (picture.gridHeight() >> 1) - 1; final int verticalSlots = (picture.gridHeight() >> 1) - 1;
String[] hosts = new String[verticalSlots]; final String[] hosts = new String[verticalSlots];
int[] time = new int[verticalSlots]; final int[] time = new int[verticalSlots];
int[] count = new int[verticalSlots]; final int[] count = new int[verticalSlots];
for (int i = 0; i < verticalSlots; i++) {hosts[i] = null; time[i] = 0; count[i] = 0;} for (int i = 0; i < verticalSlots; i++) {hosts[i] = null; time[i] = 0; count[i] = 0;}
String host; String host;
int c, h; int c, h;
for (int j = 0; j < times.length; j++) { for (final int time2 : times) {
Iterator<String> i = sb.accessHosts(); final Iterator<String> i = sb.accessHosts();
try { try {
while (i.hasNext()) { while (i.hasNext()) {
host = i.next(); host = i.next();
c = sb.latestAccessCount(host, times[j]); c = sb.latestAccessCount(host, time2);
if (c > 0) { if (c > 0) {
h = (Math.abs(host.hashCode())) % hosts.length; h = (Math.abs(host.hashCode())) % hosts.length;
hosts[h] = host; hosts[h] = host;
count[h] = c; count[h] = c;
time[h] = times[j]; time[h] = time2;
} }
} }
} catch (final ConcurrentModificationException e) {} // we don't want to synchronize this } catch (final ConcurrentModificationException e) {} // we don't want to synchronize this

@ -37,10 +37,9 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.data.meta.DigestURI; import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.logging.Log; import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.order.Base64Order; import net.yacy.kelondro.order.Base64Order;
import net.yacy.visualization.GraphPlotter;
import net.yacy.visualization.PrintTool; import net.yacy.visualization.PrintTool;
import net.yacy.visualization.RasterPlotter; import net.yacy.visualization.RasterPlotter;
import net.yacy.visualization.GraphPlotter;
import de.anomic.search.Switchboard; import de.anomic.search.Switchboard;
import de.anomic.server.serverObjects; import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch; import de.anomic.server.serverSwitch;
@ -65,6 +64,8 @@ public class WebStructurePicture_p {
int nodes = 100; // maximum number of host nodes that are painted int nodes = 100; // maximum number of host nodes that are painted
int time = -1; int time = -1;
String host = null; String host = null;
boolean corona = false;
int coronaangle = 0;
if (post != null) { if (post != null) {
width = post.getInt("width", 1024); width = post.getInt("width", 1024);
@ -78,6 +79,8 @@ public class WebStructurePicture_p {
color_dot = post.get("colordot", color_dot); color_dot = post.get("colordot", color_dot);
color_line = post.get("colorline", color_line); color_line = post.get("colorline", color_line);
color_lineend = post.get("colorlineend", color_lineend); color_lineend = post.get("colorlineend", color_lineend);
corona = post.getBoolean("corona", true);
coronaangle = (corona) ? post.getInt("coronaangle", 0) : -1;
} }
// too small values lead to an error, too big to huge CPU/memory consumption, resulting in possible DOS. // too small values lead to an error, too big to huge CPU/memory consumption, resulting in possible DOS.
@ -99,7 +102,8 @@ public class WebStructurePicture_p {
final RasterPlotter graphPicture; final RasterPlotter graphPicture;
if (host == null) { if (host == null) {
// probably no information available // probably no information available
graphPicture = new RasterPlotter(width, height, RasterPlotter.DrawMode.MODE_SUB, color_back); final RasterPlotter.DrawMode drawMode = (RasterPlotter.darkColor(color_back)) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB;
graphPicture = new RasterPlotter(width, height, drawMode, color_back);
PrintTool.print(graphPicture, width / 2, height / 2, 0, "NO WEB STRUCTURE DATA AVAILABLE.", 0); PrintTool.print(graphPicture, width / 2, height / 2, 0, "NO WEB STRUCTURE DATA AVAILABLE.", 0);
PrintTool.print(graphPicture, width / 2, height / 2 + 16, 0, "START A WEB CRAWL TO OBTAIN STRUCTURE DATA.", 0); PrintTool.print(graphPicture, width / 2, height / 2 + 16, 0, "START A WEB CRAWL TO OBTAIN STRUCTURE DATA.", 0);
} else { } else {
@ -112,7 +116,7 @@ public class WebStructurePicture_p {
// recursively find domains, up to a specific depth // recursively find domains, up to a specific depth
final GraphPlotter graph = new GraphPlotter(); final GraphPlotter graph = new GraphPlotter();
if (host != null && hash != null) place(graph, sb.webStructure, hash, host, nodes, timeout, 0.0, 0.0, 0, depth); if (host != null && hash != null) place(graph, sb.webStructure, hash, host, nodes, timeout, 0.0, 0.0, 0, depth, coronaangle);
//graph.print(); //graph.print();
graphPicture = graph.draw(width, height, 40, 40, 16, 16, color_back, color_dot, color_line, color_lineend, color_text); graphPicture = graph.draw(width, height, 40, 40, 16, 16, color_back, color_dot, color_line, color_lineend, color_text);
@ -127,10 +131,13 @@ public class WebStructurePicture_p {
} }
private static final int place(final GraphPlotter graph, final WebStructureGraph structure, final String centerhash, final String centerhost, int maxnodes, final long timeout, final double x, final double y, int nextlayer, final int maxlayer) { private static final int place(
final GraphPlotter graph, final WebStructureGraph structure, final String centerhash, final String centerhost,
int maxnodes, final long timeout, final double x, final double y, int nextlayer, final int maxlayer,
final int coronaangle) {
// returns the number of nodes that had been placed // returns the number of nodes that had been placed
assert centerhost != null; assert centerhost != null;
GraphPlotter.coordinate center = graph.getPoint(centerhost); final GraphPlotter.coordinate center = graph.getPoint(centerhost);
int mynodes = 0; int mynodes = 0;
if (center == null) { if (center == null) {
graph.addPoint(centerhost, x, y, nextlayer); graph.addPoint(centerhost, x, y, nextlayer);
@ -140,7 +147,7 @@ public class WebStructurePicture_p {
if (nextlayer == maxlayer) return mynodes; if (nextlayer == maxlayer) return mynodes;
nextlayer++; nextlayer++;
final double radius = 1.0 / (1 << nextlayer); final double radius = 1.0 / (1 << nextlayer);
WebStructureGraph.StructureEntry sr = structure.outgoingReferences(centerhash); final WebStructureGraph.StructureEntry sr = structure.outgoingReferences(centerhash);
final Map<String, Integer> next = (sr == null) ? new HashMap<String, Integer>() : sr.references; final Map<String, Integer> next = (sr == null) ? new HashMap<String, Integer>() : sr.references;
Map.Entry<String, Integer> entry; Map.Entry<String, Integer> entry;
String targethash, targethost; String targethash, targethost;
@ -162,7 +169,7 @@ public class WebStructurePicture_p {
targets.add(new String[] {targethash, targethost}); targets.add(new String[] {targethash, targethost});
if (graph.getPoint(targethost) != null) continue; if (graph.getPoint(targethost) != null) continue;
// set a new point. It is placed on a circle around the host point // set a new point. It is placed on a circle around the host point
final double angle = Base64Order.enhancedCoder.cardinal((targethash + "____").getBytes()) / maxlongd * 2 * Math.PI; final double angle = ((Base64Order.enhancedCoder.cardinal((targethash + "____").getBytes()) / maxlongd) + (coronaangle / 360.0d)) * 2.0d * Math.PI;
//System.out.println("ANGLE = " + angle); //System.out.println("ANGLE = " + angle);
rr = radius * 0.25 * (1 - targetrefs / (double) maxtargetrefs); rr = radius * 0.25 * (1 - targetrefs / (double) maxtargetrefs);
re = radius * 0.5 * (thisrefs / (double) maxthisrefs); re = radius * 0.5 * (thisrefs / (double) maxthisrefs);
@ -180,7 +187,7 @@ public class WebStructurePicture_p {
targethost = target[1]; targethost = target[1];
final GraphPlotter.coordinate c = graph.getPoint(targethost); final GraphPlotter.coordinate c = graph.getPoint(targethost);
assert c != null; assert c != null;
nextnodes = ((maxnodes <= 0) || (System.currentTimeMillis() >= timeout)) ? 0 : place(graph, structure, targethash, targethost, maxnodes, timeout, c.x, c.y, nextlayer, maxlayer); nextnodes = ((maxnodes <= 0) || (System.currentTimeMillis() >= timeout)) ? 0 : place(graph, structure, targethash, targethost, maxnodes, timeout, c.x, c.y, nextlayer, maxlayer, coronaangle);
mynodes += nextnodes; mynodes += nextnodes;
maxnodes -= nextnodes; maxnodes -= nextnodes;
graph.setBorder(centerhost, targethost); graph.setBorder(centerhost, targethost);

@ -39,7 +39,6 @@ import net.yacy.cora.document.UTF8;
import net.yacy.kelondro.logging.Log; import net.yacy.kelondro.logging.Log;
import net.yacy.visualization.PrintTool; import net.yacy.visualization.PrintTool;
import net.yacy.visualization.RasterPlotter; import net.yacy.visualization.RasterPlotter;
import de.anomic.search.QueryParams; import de.anomic.search.QueryParams;
import de.anomic.search.SearchEvent; import de.anomic.search.SearchEvent;
import de.anomic.search.SearchEventCache; import de.anomic.search.SearchEventCache;
@ -135,19 +134,19 @@ public class NetworkGraph {
int angle; int angle;
// draw in the primary search peers // draw in the primary search peers
for (int j = 0; j < primarySearches.length; j++) { for (final yacySearch primarySearche : primarySearches) {
if (primarySearches[j] == null) continue; if (primarySearche == null) continue;
eventPicture.setColor((primarySearches[j].isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN); eventPicture.setColor((primarySearche.isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(primarySearches[j].target().hash), null)) / ((double) Long.MAX_VALUE))); angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(primarySearche.target().hash), null)) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false); eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false);
} }
// draw in the secondary search peers // draw in the secondary search peers
if (secondarySearches != null) { if (secondarySearches != null) {
for (int j = 0; j < secondarySearches.length; j++) { for (final yacySearch secondarySearche : secondarySearches) {
if (secondarySearches[j] == null) continue; if (secondarySearche == null) continue;
eventPicture.setColor((secondarySearches[j].isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN); eventPicture.setColor((secondarySearche.isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(secondarySearches[j].target().hash), null)) / ((double) Long.MAX_VALUE))); angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(secondarySearche.target().hash), null)) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1, true, null, null, -1, -1, -1, false); eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1, true, null, null, -1, -1, -1, false);
eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1, true, null, null, -1, -1, -1, false); eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1, true, null, null, -1, -1, -1, false);
} }
@ -158,9 +157,9 @@ public class NetworkGraph {
final Iterator<byte[]> i = query.queryHashes.iterator(); final Iterator<byte[]> i = query.queryHashes.iterator();
eventPicture.setColor(RasterPlotter.GREY); eventPicture.setColor(RasterPlotter.GREY);
while (i.hasNext()) { while (i.hasNext()) {
long[] positions = seedDB.scheme.dhtPositions(i.next()); final long[] positions = seedDB.scheme.dhtPositions(i.next());
for (int j = 0; j < positions.length; j++) { for (final long position : positions) {
angle = (int) (360.0 * (((double) positions[j]) / ((double) Long.MAX_VALUE))); angle = (int) (360.0 * (((double) position) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false); eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false);
} }
} }
@ -177,14 +176,15 @@ public class NetworkGraph {
final int passiveLimit, final int potentialLimit, final int passiveLimit, final int potentialLimit,
final int maxCount, final int coronaangle, final int maxCount, final int coronaangle,
final long communicationTimeout, final long communicationTimeout,
final String networkName, final String networkTitle, final String bgcolor) { final String networkName, final String networkTitle, final String color_back) {
RasterPlotter networkPicture = new RasterPlotter(width, height, (bgcolor.equals("000000")) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB, bgcolor); 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 if (seedDB == null) return networkPicture; // no other peers known
final int maxradius = Math.min(width, height) / 2; final int maxradius = Math.min(width, height) / 2;
final int innerradius = maxradius * 4 / 10; final int innerradius = maxradius * 4 / 10;
int outerradius = maxradius - 20; final int outerradius = maxradius - 20;
// draw network circle // draw network circle
networkPicture.setColor(COL_DHTCIRCLE); networkPicture.setColor(COL_DHTCIRCLE);
@ -253,15 +253,15 @@ public class NetworkGraph {
// draw DHT activity // draw DHT activity
if (communicationTimeout >= 0) { if (communicationTimeout >= 0) {
Date horizon = new Date(System.currentTimeMillis() - communicationTimeout); final Date horizon = new Date(System.currentTimeMillis() - communicationTimeout);
for (Hit event: yacyChannel.channels(yacyChannel.DHTRECEIVE)) { for (final Hit event: yacyChannel.channels(yacyChannel.DHTRECEIVE)) {
if (event == null || event.getPubDate() == null) continue; if (event == null || event.getPubDate() == null) continue;
if (event.getPubDate().after(horizon)) { if (event.getPubDate().after(horizon)) {
//System.out.println("*** NETWORK-DHTRECEIVE: " + event.getLink()); //System.out.println("*** NETWORK-DHTRECEIVE: " + event.getLink());
drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTIN, coronaangle, false); drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTIN, coronaangle, false);
} }
} }
for (Hit event: yacyChannel.channels(yacyChannel.DHTSEND)) { for (final Hit event: yacyChannel.channels(yacyChannel.DHTSEND)) {
if (event == null || event.getPubDate() == null) continue; if (event == null || event.getPubDate() == null) continue;
if (event.getPubDate().after(horizon)) { if (event.getPubDate().after(horizon)) {
//System.out.println("*** NETWORK-DHTSEND: " + event.getLink()); //System.out.println("*** NETWORK-DHTSEND: " + event.getLink());
@ -280,7 +280,7 @@ public class NetworkGraph {
return networkPicture; return networkPicture;
} }
private static void drawNetworkPictureDHT(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final yacySeed mySeed, final yacySeed otherSeed, final String colorLine, final int coronaangle, boolean out) { private static void drawNetworkPictureDHT(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final yacySeed mySeed, final yacySeed otherSeed, final String colorLine, final int coronaangle, final boolean out) {
final int angleMy = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(ASCII.getBytes(mySeed.hash), null)) / ((double) Long.MAX_VALUE))); final int angleMy = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(ASCII.getBytes(mySeed.hash), null)) / ((double) Long.MAX_VALUE)));
final int angleOther = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(ASCII.getBytes(otherSeed.hash), null)) / ((double) Long.MAX_VALUE))); final int angleOther = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(ASCII.getBytes(otherSeed.hash), null)) / ((double) Long.MAX_VALUE)));
// draw line // draw line
@ -317,31 +317,31 @@ public class NetworkGraph {
PrintTool.arcPrint(img, centerX, centerY, innerradius + linelength, angle, name); PrintTool.arcPrint(img, centerX, centerY, innerradius + linelength, angle, name);
// draw corona around dot for crawling activity // draw corona around dot for crawling activity
int ppmx = seed.getPPM() / 30; final int ppmx = seed.getPPM() / 30;
if (coronaangle >= 0 && ppmx > 0) { if (coronaangle >= 0 && ppmx > 0) {
drawCorona(img, centerX, centerY, innerradius, angle, dotsize, ppmx, coronaangle, true, false, 24, 24, 24); // color = 0..63 drawCorona(img, centerX, centerY, innerradius, angle, dotsize, ppmx, coronaangle, true, false, 24, 24, 24); // color = 0..63
} }
// draw corona around dot for query activity // draw corona around dot for query activity
int qphx = ((int) (seed.getQPM() * 4.0)); final int qphx = ((int) (seed.getQPM() * 4.0));
if (coronaangle >= 0 && qphx > 0) { if (coronaangle >= 0 && qphx > 0) {
drawCorona(img, centerX, centerY, innerradius, angle, dotsize, qphx, coronaangle, false, true, 8, 62, 8); // color = 0..63 drawCorona(img, centerX, centerY, innerradius, angle, dotsize, qphx, coronaangle, false, true, 8, 62, 8); // color = 0..63
} }
} }
private static void drawCorona(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, int angle, int dotsize, int strength, int coronaangle, boolean inside, boolean split, int r, int g, int b) { private static void drawCorona(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final int angle, final int dotsize, int strength, final int coronaangle, final boolean inside, final boolean split, final int r, final int g, final int b) {
double ca = Math.PI * 2.0 * ((double) coronaangle) / 360.0; final double ca = Math.PI * 2.0 * (coronaangle) / 360.0;
if (strength > 4) strength = 4; if (strength > 4) strength = 4;
// draw a wave around crawling peers // draw a wave around crawling peers
double wave; double wave;
final int waveradius = innerradius / 2; final int waveradius = innerradius / 2;
int segments = 72; final int segments = 72;
for (int radius = 0; radius < waveradius; radius++) { for (int radius = 0; radius < waveradius; radius++) {
wave = ((double) (waveradius - radius) * strength) * (1.0 + Math.sin(Math.PI * 16 * radius / waveradius + ((inside) ? ca : -ca))) / 2.0 / (double) waveradius; wave = ((double) (waveradius - radius) * strength) * (1.0 + Math.sin(Math.PI * 16 * radius / waveradius + ((inside) ? ca : -ca))) / 2.0 / waveradius;
img.setColor(((((long) (r * wave)) & 0xff) << 16) | (((long) ((g * wave)) & 0xff) << 8) | ((((long) (b * wave))) & 0xff)); img.setColor(((((long) (r * wave)) & 0xff) << 16) | (((long) ((g * wave)) & 0xff) << 8) | ((((long) (b * wave))) & 0xff));
if (split) { if (split) {
for (int i = 0; i < segments; i++) { for (int i = 0; i < segments; i++) {
int a = (coronaangle + 360 * i) / segments; final int a = (coronaangle + 360 * i) / segments;
img.arcArc(centerX, centerY, innerradius, angle, dotsize + radius, dotsize + radius, a, a + 180/segments); img.arcArc(centerX, centerY, innerradius, angle, dotsize + radius, dotsize + radius, a, a + 180/segments);
} }
} else { } else {

@ -1,39 +0,0 @@
package net.yacy;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class screenshot {
/*
try {
Robot robot = new Robot();
Rectangle area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage bufferedImage = robot.createScreenCapture(area);
} catch (AWTException e) {
}
*/
public static void main(final String[] args) throws Exception {
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final Dimension screenSize = toolkit.getScreenSize();
final Rectangle screenRect = new Rectangle(screenSize);
// create screen shot
final Robot robot = new Robot();
final BufferedImage image = robot.createScreenCapture(screenRect);
final String outFileName = "test.png";
// save captured image to PNG file
ImageIO.write(image, "png", new File(outFileName));
// give feedback
System.out.println("Saved screen shot (" + image.getWidth() + " x " + image.getHeight() + " pixels) to file \"" + outFileName + "\".");
}
}

@ -45,21 +45,21 @@ public class GraphPlotter {
// a ymageGraph is a set of points and borders between the points // a ymageGraph is a set of points and borders between the points
// to reference the points, they must all have a nickname // to reference the points, they must all have a nickname
private Map<String, coordinate> points; private final Map<String, coordinate> points;
private Set<String> borders; private final Set<String> borders;
private double leftmost, rightmost, topmost, bottommost; private double leftmost, rightmost, topmost, bottommost;
public GraphPlotter() { public GraphPlotter() {
points = new HashMap<String, coordinate>(); this.points = new HashMap<String, coordinate>();
borders = new HashSet<String>(); this.borders = new HashSet<String>();
leftmost = 1.0; this.leftmost = 1.0;
rightmost = -1.0; this.rightmost = -1.0;
topmost = -1.0; this.topmost = -1.0;
bottommost = 1.0; this.bottommost = 1.0;
} }
public coordinate getPoint(final String name) { public coordinate getPoint(final String name) {
return points.get(name); return this.points.get(name);
} }
public coordinate[] getBorder(final String name) { public coordinate[] getBorder(final String name) {
@ -73,25 +73,25 @@ public class GraphPlotter {
public coordinate addPoint(final String name, final double x, final double y, final int layer) { public coordinate addPoint(final String name, final double x, final double y, final int layer) {
final coordinate newc = new coordinate(x, y, layer); final coordinate newc = new coordinate(x, y, layer);
final coordinate oldc = points.put(name, newc); final coordinate oldc = this.points.put(name, newc);
assert oldc == null; // all add shall be unique assert oldc == null; // all add shall be unique
if (x > rightmost) rightmost = x; if (x > this.rightmost) this.rightmost = x;
if (x < leftmost) leftmost = x; if (x < this.leftmost) this.leftmost = x;
if (y > topmost) topmost = y; if (y > this.topmost) this.topmost = y;
if (y < bottommost) bottommost = y; if (y < this.bottommost) this.bottommost = y;
return newc; return newc;
} }
public boolean hasBorder(final String fromPoint, final String toPoint) { public boolean hasBorder(final String fromPoint, final String toPoint) {
return borders.contains(fromPoint + "-" + toPoint); return this.borders.contains(fromPoint + "-" + toPoint);
} }
public void setBorder(final String fromPoint, final String toPoint) { public void setBorder(final String fromPoint, final String toPoint) {
final coordinate from = points.get(fromPoint); final coordinate from = this.points.get(fromPoint);
final coordinate to = points.get(toPoint); final coordinate to = this.points.get(toPoint);
assert from != null; assert from != null;
assert to != null; assert to != null;
borders.add(fromPoint + "$" + toPoint); this.borders.add(fromPoint + "$" + toPoint);
} }
public static class coordinate { public static class coordinate {
@ -110,7 +110,7 @@ public class GraphPlotter {
public void print() { public void print() {
// for debug purpose: print out all coordinates // for debug purpose: print out all coordinates
final Iterator<Map.Entry<String, coordinate>> i = points.entrySet().iterator(); final Iterator<Map.Entry<String, coordinate>> i = this.points.entrySet().iterator();
Map.Entry<String, coordinate> entry; Map.Entry<String, coordinate> entry;
String name; String name;
coordinate c; coordinate c;
@ -120,7 +120,7 @@ public class GraphPlotter {
c = entry.getValue(); c = entry.getValue();
System.out.println("point(" + c.x + ", " + c.y + ", " + c.layer + ") [" + name + "]"); System.out.println("point(" + c.x + ", " + c.y + ", " + c.layer + ") [" + name + "]");
} }
final Iterator<String> j = borders.iterator(); final Iterator<String> j = this.borders.iterator();
while (j.hasNext()) { while (j.hasNext()) {
System.out.println("border(" + j.next() + ")"); System.out.println("border(" + j.next() + ")");
} }
@ -139,15 +139,14 @@ public class GraphPlotter {
final String color_lineend, final String color_lineend,
final String color_text final String color_text
) { ) {
RasterPlotter.DrawMode drawMode = RasterPlotter.DrawMode.MODE_SUB; final RasterPlotter.DrawMode drawMode = (RasterPlotter.darkColor(color_back)) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB;
if (RasterPlotter.darkColor(color_back)) drawMode = RasterPlotter.DrawMode.MODE_ADD;
final RasterPlotter image = new RasterPlotter(width, height, drawMode, color_back); final RasterPlotter image = new RasterPlotter(width, height, drawMode, color_back);
final double xfactor = ((rightmost - leftmost) == 0.0) ? 0.0 : (width - leftborder - rightborder) / (rightmost - leftmost); final double xfactor = ((this.rightmost - this.leftmost) == 0.0) ? 0.0 : (width - leftborder - rightborder) / (this.rightmost - this.leftmost);
final double yfactor = ((topmost - bottommost) == 0.0) ? 0.0 : (height - topborder - bottomborder) / (topmost - bottommost); final double yfactor = ((this.topmost - this.bottommost) == 0.0) ? 0.0 : (height - topborder - bottomborder) / (this.topmost - this.bottommost);
// draw dots and names // draw dots and names
final Iterator<Map.Entry<String, coordinate>> i = points.entrySet().iterator(); final Iterator<Map.Entry<String, coordinate>> i = this.points.entrySet().iterator();
Map.Entry<String, coordinate> entry; Map.Entry<String, coordinate> entry;
String name; String name;
coordinate c; coordinate c;
@ -156,8 +155,8 @@ public class GraphPlotter {
entry = i.next(); entry = i.next();
name = entry.getKey(); name = entry.getKey();
c = entry.getValue(); c = entry.getValue();
x = (xfactor == 0.0) ? width / 2 : (int) (leftborder + (c.x - leftmost) * xfactor); x = (xfactor == 0.0) ? width / 2 : (int) (leftborder + (c.x - this.leftmost) * xfactor);
y = (yfactor == 0.0) ? height / 2 : (int) (height - bottomborder - (c.y - bottommost) * yfactor); y = (yfactor == 0.0) ? height / 2 : (int) (height - bottomborder - (c.y - this.bottommost) * yfactor);
image.setColor(color_dot); image.setColor(color_dot);
image.dot(x, y, 6, true, 100); image.dot(x, y, 6, true, 100);
image.setColor(color_text); image.setColor(color_text);
@ -165,7 +164,7 @@ public class GraphPlotter {
} }
// draw lines // draw lines
final Iterator<String> j = borders.iterator(); final Iterator<String> j = this.borders.iterator();
coordinate[] border; coordinate[] border;
image.setColor(color_line); image.setColor(color_line);
int x0, x1, y0, y1; int x0, x1, y0, y1;
@ -176,15 +175,15 @@ public class GraphPlotter {
x0 = width / 2; x0 = width / 2;
x1 = width / 2; x1 = width / 2;
} else { } else {
x0 = (int) (leftborder + (border[0].x - leftmost) * xfactor); x0 = (int) (leftborder + (border[0].x - this.leftmost) * xfactor);
x1 = (int) (leftborder + (border[1].x - leftmost) * xfactor); x1 = (int) (leftborder + (border[1].x - this.leftmost) * xfactor);
} }
if (yfactor == 0.0) { if (yfactor == 0.0) {
y0 = height / 2; y0 = height / 2;
y1 = height / 2; y1 = height / 2;
} else { } else {
y0 = (int) (height - bottomborder - (border[0].y - bottommost) * yfactor); y0 = (int) (height - bottomborder - (border[0].y - this.bottommost) * yfactor);
y1 = (int) (height - bottomborder - (border[1].y - bottommost) * yfactor); y1 = (int) (height - bottomborder - (border[1].y - this.bottommost) * yfactor);
} }
// draw the line, with the dot at the beginning of the line // draw the line, with the dot at the beginning of the line
image.lineDot(x1, y1, x0, y0, 3, 4, color_line, color_lineend); image.lineDot(x1, y1, x0, y0, 3, 4, color_line, color_lineend);

Loading…
Cancel
Save