- enhanced circle drawing speed

- beautified 'moving dot' feature (using smaller and correctly positioned dots)
- added moving dots to DHT transfer

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7500 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 6e93a3eb2f
commit 82f262f685

@ -94,7 +94,7 @@ public class AccessPicture_p {
picture.gridDot(centerx, centery, 50, i * 60 + coronaangle / 6, i * 60 + 30 + coronaangle / 6);
}
} else {
picture.gridDot(centerx, centery, 50, 0, 360);
picture.gridDot(centerx, centery, 50);
}
//picture.gridDot(centerx, centery, 31, false);
picture.setColor(color_text);
@ -129,15 +129,15 @@ public class AccessPicture_p {
for (int i = 0; i < hosts.length; i++) {
if (hosts[i] != null) {
picture.setColor(color_dot);
picture.gridDot(gridLeft, i * 2 + 1, 7, 0, 360);
picture.gridDot(gridLeft, i * 2 + 1, 8, 0, 360);
picture.gridDot(gridLeft, i * 2 + 1, 7);
picture.gridDot(gridLeft, i * 2 + 1, 8);
picture.setColor(color_text);
picture.gridPrint(gridLeft, i * 2 + 1, 8, hosts[i].toUpperCase(), "COUNT = " + count[i] + ", TIME > " + ((time[i] >= 60000) ? ((time[i] / 60000) + " MINUTES") : ((time[i] / 1000) + " SECONDS")), -1);
if (corona) {
picture.gridLine((centerx - gridLeft) / 2, i * 2 + 1, gridLeft, i * 2 + 1,
color_line, 100, "111111", 100, 12, 11 - coronaangle / 30, 1, true);
picture.gridLine(centerx, centery, (centerx - gridLeft) / 2, i * 2 + 1,
color_line, 100, "111111", 100, 12, 11 - coronaangle / 30, 1, true);
picture.gridLine((centerx - gridLeft) / 2 - 2, i * 2 + 1, gridLeft, i * 2 + 1,
color_line, 100, "AAAAAA", 100, 12, 11 - coronaangle / 30, 0, true);
picture.gridLine(centerx, centery, (centerx - gridLeft) / 2 - 2, i * 2 + 1,
color_line, 100, "AAAAAA", 100, 12, 11 - coronaangle / 30, 0, true);
} else {
picture.setColor(color_line);
picture.gridLine(gridLeft, i * 2 + 1, (centerx - gridLeft) / 2, i * 2 + 1);
@ -164,15 +164,15 @@ public class AccessPicture_p {
for (int i = 0; i < hosts.length; i++) {
if (hosts[i] != null) {
picture.setColor(color_dot);
picture.gridDot(gridRight, i * 2 + 1, 7, 0, 360);
picture.gridDot(gridRight, i * 2 + 1, 8, 0, 360);
picture.gridDot(gridRight, i * 2 + 1, 7);
picture.gridDot(gridRight, i * 2 + 1, 8);
picture.setColor(color_text);
picture.gridPrint(gridRight, i * 2 + 1, 8, hosts[i].toUpperCase(), count[i] + " BYTES, " + time[i] + " MS DUE", 1);
if (corona) {
picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2, i * 2 + 1,
color_line, 100, "111111", 100, 12, coronaangle / 30, 1, true);
picture.gridLine(centerx, centery, centerx + (gridRight - centerx) / 2, i * 2 + 1,
color_line, 100, "111111", 100, 12, coronaangle / 30, 1, true);
picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2 + 2, i * 2 + 1,
color_line, 100, "AAAAAA", 100, 12, 11 - coronaangle / 30, 0, true);
picture.gridLine(centerx, centery, centerx + (gridRight - centerx) / 2 + 2, i * 2 + 1,
color_line, 100, "AAAAAA", 100, 12, coronaangle / 30, 0, true);
} else {
picture.setColor(color_line);
picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2, i * 2 + 1);

@ -108,7 +108,7 @@ public class imagetest {
int angle;
for (byte c = (byte) 'A'; c <= 'Z'; c++) {
angle = (c - (byte) 'A') * 360 / ((byte) 'Z' - (byte) 'A');
img.arcLine(550, 400, 81, 100, angle, null, null, -1, -1, -1, false);
img.arcLine(550, 400, 81, 100, angle, true, null, null, -1, -1, -1, false);
PrintTool.arcPrint(img, 550, 400, 100, angle, "ANGLE" + angle + ":" + (char) c);
}
return img;

@ -137,7 +137,7 @@ public class NetworkGraph {
if (primarySearches[j] == null) continue;
eventPicture.setColor((primarySearches[j].isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(primarySearches[j].target().hash.getBytes(), null)) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, 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
@ -146,8 +146,8 @@ public class NetworkGraph {
if (secondarySearches[j] == null) continue;
eventPicture.setColor((secondarySearches[j].isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(secondarySearches[j].target().hash.getBytes(), null)) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1, null, null, -1, -1, -1, false);
eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1, 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);
}
}
@ -159,7 +159,7 @@ public class NetworkGraph {
long[] positions = seedDB.scheme.dhtPositions(i.next());
for (int j = 0; j < positions.length; j++) {
angle = (int) (360.0 * (((double) positions[j]) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, null, null, -1, -1, -1, false);
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false);
}
}
@ -258,14 +258,14 @@ public class NetworkGraph {
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);
drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTIN, coronaangle, false);
}
}
for (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);
drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTOUT, coronaangle, true);
}
}
}
@ -280,14 +280,16 @@ public class NetworkGraph {
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) {
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) {
final int angleMy = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(mySeed.hash.getBytes(), null)) / ((double) Long.MAX_VALUE)));
final int angleOther = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(otherSeed.hash.getBytes(), null)) / ((double) Long.MAX_VALUE)));
// draw line
img.setColor(colorLine);
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleMy, null, null, -1, -1, -1, false);
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleOther, null, null, -1, -1, -1, false);
img.arcConnect(centerX, centerY, innerradius - 20, angleMy, angleOther);
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleMy, !out,
colorLine, null, 12, (coronaangle < 0) ? -1 : coronaangle / 30, 2, true);
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleOther, out,
colorLine, null, 12, (coronaangle < 0) ? -1 : coronaangle / 30, 2, true);
img.arcConnect(centerX, centerY, innerradius - 20, angleMy, angleOther, out,
colorLine, 100, null, 100, 12, (coronaangle < 0) ? -1 : coronaangle / 30, 2, true);
}
private static void drawNetworkPicturePeer(
@ -309,7 +311,7 @@ public class NetworkGraph {
img.setColor(colorDot);
img.arcDot(centerX, centerY, innerradius, angle, dotsize);
// draw line to text
img.arcLine(centerX, centerY, innerradius + 18, innerradius + linelength, angle, colorLine, "111111", 12, coronaangle / 30, 1, true);
img.arcLine(centerX, centerY, innerradius + 18, innerradius + linelength, angle, true, colorLine, "444444", 12, coronaangle / 30, 0, true);
// draw text
img.setColor(colorText);
PrintTool.arcPrint(img, centerX, centerY, innerradius + linelength, angle, name);

@ -34,8 +34,7 @@ import java.util.Set;
public class CircleTool {
private static int[][] circles = new int[0][];
private static int[][] circles = new int[0][];
private static int[] getCircleCoords(final int radius) {
if ((radius - 1) < circles.length) return circles[radius - 1];
@ -44,7 +43,7 @@ public class CircleTool {
Set<String> crds = new HashSet<String>();
crds.add("0|0");
String co;
for (int i = Math.max(0, circles.length - 5); i < circles.length; i++) {
for (int i = Math.max(0, circles.length - 2); i < circles.length; i++) {
for (int j = 0; j < circles[i].length; j = j + 2) {
co = circles[i][j] + "|" + circles[i][j + 1];
if (!(crds.contains(co))) crds.add(co);
@ -58,18 +57,20 @@ public class CircleTool {
// compute more lines in new circles
int x, y;
List<int[]> crc;
int r1;
for (int r = circles.length; r < newCircles.length; r++) {
r1 = r + 1;
crc = new ArrayList<int[]>();
for (int a = 0; a <= 2 * (r + 1); a++) {
x = (int) ((r + 1) * Math.cos(Math.PI * a / (4 * (r + 1))));
y = (int) ((r + 1) * Math.sin(Math.PI * a / (4 * (r + 1))));
x = (int) (r1 * Math.cos(Math.PI * a / (4 * r1)));
y = (int) (r1 * Math.sin(Math.PI * a / (4 * r1)));
co = x + "|" + y;
if (!(crds.contains(co))) {
crc.add(new int[]{x, y});
crds.add(co);
}
x = (int) ((r + 0.5) * Math.cos(Math.PI * a / (4 * (r + 1))));
y = (int) ((r + 0.5) * Math.sin(Math.PI * a / (4 * (r + 1))));
x = (int) (((double) r + 0.5) * Math.cos(Math.PI * a / (4 * r1)));
y = (int) (((double) r + 0.5) * Math.sin(Math.PI * a / (4 * r1)));
co = x + "|" + y;
if (!(crds.contains(co))) {
crc.add(new int[]{x, y});
@ -80,10 +81,11 @@ public class CircleTool {
//System.out.print("Radius " + r + " => " + crc.size() + " points: ");
newCircles[r] = new int[2 * (crc.size() - 1)];
int[] coords;
int i2 = 0;
for (int i = 0; i < crc.size() - 1; i++) {
coords = crc.get(i);
newCircles[r][2 * i ] = coords[0];
newCircles[r][2 * i + 1] = coords[1];
newCircles[r][i2++] = coords[0];
newCircles[r][i2++] = coords[1];
//System.out.print(circles[r][i][0] + "," +circles[r][i][1] + "; ");
}
//System.out.println();
@ -101,13 +103,15 @@ public class CircleTool {
public static void circle(final RasterPlotter matrix, final int xc, final int yc, final int radius, int intensity) {
if (radius == 0) {
matrix.plot(xc, yc, 100);
//matrix.plot(xc, yc, 100);
} else {
final int[] c = getCircleCoords(radius);
int x, y;
for (int i = (c.length / 2) - 1; i >= 0; i--) {
x = c[2 * i ];
y = c[2 * i + 1];
int limit = c.length / 2;
int i2 = 0;
for (int i = 0; i < limit; i++) {
x = c[i2++];
y = c[i2++];
matrix.plot(xc + x , yc - y - 1, intensity); // quadrant 1
matrix.plot(xc - x + 1, yc - y - 1, intensity); // quadrant 2
matrix.plot(xc + x , yc + y , intensity); // quadrant 4
@ -124,7 +128,7 @@ public class CircleTool {
while ( toArc > 360) toArc -=360;
while ( toArc < 0 ) toArc +=360;
if (radius == 0) {
matrix.plot(xc, yc, 100);
//matrix.plot(xc, yc, 100);
} else {
final int[] c = getCircleCoords(radius);
final int q = c.length / 2;

@ -0,0 +1,44 @@
package net.yacy.visualization;
import java.util.ArrayList;
import java.util.List;
public class GridTree {
private String name, description;
private List<GridTree> children;
public GridTree(String name, String description) {
this.name = name;
this.description = description;
this.children = null;
}
public void addChild(GridTree child) {
if (this.children == null) this.children = new ArrayList<GridTree>();
this.children.add(child);
}
public boolean isLeaf() {
return this.children == null;
}
public int depth() {
if (this.isLeaf()) return 1;
int maxChildDepth = 0;
for (GridTree child: children) {
maxChildDepth = Math.max(maxChildDepth, child.depth());
}
return maxChildDepth + 1;
}
public int width() {
if (this.isLeaf()) return 1;
int maxChildDepth = 0;
for (GridTree child: children) {
maxChildDepth = Math.max(maxChildDepth, child.depth());
}
return maxChildDepth + 1;
}
}

@ -141,7 +141,8 @@ public class HexGridPlotter extends RasterPlotter {
plot(x1, y1, (horizontal == 2) ? intensityLine : intensityLine * 8 / 10);
if (dotc == dotPos) {
if (colorDot != null) this.setColor(colorDot);
if (dotRadius > 0) this.dot(x1, y1, dotRadius, dotFilled, intensityDot);
if (dotRadius == 0) this.plot(x1, y1, intensityDot);
else if (dotRadius > 0) this.dot(x1, y1, dotRadius, dotFilled, intensityDot);
}
dotc++;
if (dotc == dotDist) dotc = 0;

@ -229,7 +229,8 @@ public class RasterPlotter {
plot(Ax, Ay, intensityLine);
if (dotc == dotPos) {
if (colorDot != null) this.setColor(colorDot);
if (dotRadius > 0) this.dot(Ax, Ay, dotRadius, dotFilled, intensityDot);
if (dotRadius == 0) this.plot(Ax, Ay, intensityDot);
else if (dotRadius > 0) this.dot(Ax, Ay, dotRadius, dotFilled, intensityDot);
}
dotc++;
if (dotc == dotDist) dotc = 0;
@ -251,7 +252,8 @@ public class RasterPlotter {
plot(Ax, Ay, intensityLine);
if (dotc == dotPos) {
if (colorDot != null) this.setColor(colorDot);
if (dotRadius > 0) this.dot(Ax, Ay, dotRadius, dotFilled, intensityDot);
if (dotRadius == 0) this.plot(Ax, Ay, intensityDot);
else if (dotRadius > 0) this.dot(Ax, Ay, dotRadius, dotFilled, intensityDot);
}
dotc++;
if (dotc == dotDist) dotc = 0;
@ -316,6 +318,7 @@ public class RasterPlotter {
}
public void arcLine(final int cx, final int cy, final int innerRadius, final int outerRadius, final int angle,
boolean in,
String colorLine, String colorDot, int dotDist, int dotPos, int dotRadius, boolean dotFilled) {
final double a = Math.PI * ((double) angle) / 180.0;
final double cosa = Math.cos(a);
@ -325,11 +328,19 @@ public class RasterPlotter {
final int xo = cx + (int) (outerRadius * cosa);
final int yo = cy - (int) (outerRadius * sina);
//line(xi, yi, xo, yo, 100);
line(
xo, yo, xi, yi,
colorLine, 100,
colorDot, 100, dotDist, dotPos, dotRadius, dotFilled
);
if (in) {
line(
xo, yo, xi, yi,
colorLine, 100,
colorDot, 100, dotDist, dotPos, dotRadius, dotFilled
);
} else {
line(
xi, yi, xo, yo,
colorLine, 100,
colorDot, 100, dotDist, dotPos, dotRadius, dotFilled
);
}
}
public void arcDot(final int cx, final int cy, final int arcRadius, final int angle, final int dotRadius) {
@ -339,14 +350,25 @@ public class RasterPlotter {
dot(x, y, dotRadius, true, 100);
}
public void arcConnect(final int cx, final int cy, final int arcRadius, final int angle1, final int angle2) {
public void arcConnect(final int cx, final int cy, final int arcRadius, final int angle1, final int angle2,
boolean in,
String colorLine, final int intensityLine,
String colorDot, final int intensityDot, int dotDist, int dotPos, int dotRadius, boolean dotFilled) {
final double a1 = Math.PI * ((double) angle1) / 180.0;
final double a2 = Math.PI * ((double) angle2) / 180.0;
final int x1 = cx + (int) (arcRadius * Math.cos(a1));
final int y1 = cy - (int) (arcRadius * Math.sin(a1));
final int x2 = cx + (int) (arcRadius * Math.cos(a2));
final int y2 = cy - (int) (arcRadius * Math.sin(a2));
line(x1, y1, x2, y2, 100);
if (in) {
line(x1, y1, x2, y2,
colorLine, intensityLine,
colorDot, intensityDot, dotDist, dotPos, dotRadius, dotFilled);
} else {
line(x2, y2, x1, y1,
colorLine, intensityLine,
colorDot, intensityDot, dotDist, dotPos, dotRadius, dotFilled);
}
}
public void arcArc(final int cx, final int cy, final int arcRadius, final int angle, final int innerRadius, final int outerRadius, final int fromArc, final int toArc) {

Loading…
Cancel
Save