draw the names of other peers which receive/send dht into the network

graphic
pull/1/head
Michael Peter Christen 12 years ago
parent b528448332
commit ed1d5bace6

@ -11,7 +11,7 @@
<script type="text/javascript">
<!--
imagestub = "NetworkPicture.png?width=1024&height=720&bgcolor=FFFFFF&ct=9000&coronaangle=";
imagestub = "NetworkPicture.png?width=1024&height=720&bgcolor=FFFFFF&ct=15000&coronaangle=";
imageanimindex = 0;
imageloadindex = 0;
imagecycles = 0;

@ -73,8 +73,8 @@ public class NetworkPicture
return buffer;
}
int width = 1024; // 640x480 = VGA, 768x576 = SD/4:3, 1024x576 =SD/16:9 1280x720 = HD/16:9, 1920x1080 = FULL HD/16:9
int height = 576;
int width = 1280; // 640x480 = VGA, 768x576 = SD/4:3, 1024x576 =SD/16:9 1280x720 = HD/16:9, 1920x1080 = FULL HD/16:9
int height = 720;
int passiveLimit = 1440; // minutes; 1440 = 1 day; 720 = 12 hours; 1440 = 24 hours, 10080 = 1 week;
int potentialLimit = 1440;
int maxCount = 9000;
@ -107,12 +107,12 @@ public class NetworkPicture
if ( height < 240 ) {
height = 240;
}
if ( height > 1080 ) {
height = 1080;
if ( height > 1280 ) {
height = 1280;
}
if ( !authorized ) {
width = Math.min(1024, width);
height = Math.min(1024, height);
width = Math.min(1280, width);
height = Math.min(1280, height);
}
if ( passiveLimit > 1000000 ) {
passiveLimit = 1000000;

@ -312,16 +312,16 @@ public class NetworkGraph {
}
private static void drawNetworkPictureDHT(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final Seed mySeed, final Seed otherSeed, final String colorLine, final int coronaangle, final boolean out, final int cyc) {
// find positions (== angle) of the two peers
final int angleMy = cyc + (int) (360.0d * Distribution.horizontalDHTPosition(ASCII.getBytes(mySeed.hash)) / DOUBLE_LONG_MAX_VALUE);
final int angleOther = cyc + (int) (360.0d * Distribution.horizontalDHTPosition(ASCII.getBytes(otherSeed.hash)) / DOUBLE_LONG_MAX_VALUE);
// draw line
Long colorLine_l = Long.parseLong(colorLine, 16);
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleMy, !out,
colorLine_l, null, 12, (coronaangle < 0) ? -1 : coronaangle / 30, 2, true);
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleOther, out,
colorLine_l, null, 12, (coronaangle < 0) ? -1 : coronaangle / 30, 2, true);
img.arcConnect(centerX, centerY, innerradius - 20, angleMy, angleOther, out,
colorLine_l, 100, null, 100, 12, (coronaangle < 0) ? -1 : coronaangle / 30, 2, true);
// paint the line from my peer to the inner border of the network circle
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleMy, !out, colorLine_l, null, 12, (coronaangle < 0) ? -1 : coronaangle / 30, 2, true);
// paint the line from the other peer to the inner border of the network circle
img.arcLine(centerX, centerY, innerradius, innerradius - 20, angleOther, out, colorLine_l, null, 12, (coronaangle < 0) ? -1 : coronaangle / 30, 2, true);
// paint a line between the two inner border points of my peer and the other peer
img.arcConnect(centerX, centerY, innerradius - 20, angleMy, angleOther, out, colorLine_l, 100, null, 100, 12, (coronaangle < 0) ? -1 : coronaangle / 30, 2, true, otherSeed.getName(), colorLine_l);
}
private static class drawNetworkPicturePeerJob {

@ -110,6 +110,15 @@ public class PrintTool {
private static final int arcDist = 8;
/**
* print a string at the distance of a circle
* @param matrix the RasterPlotter
* @param cx center of circle, x
* @param cy center of circle, y
* @param radius radius == distance of text from circle center
* @param angle angle == position of text on a circle in distance of radius
* @param message the message to be printed
*/
public static void arcPrint(final RasterPlotter matrix, final int cx, final int cy, final int radius, final double angle, final String message) {
final int x = cx + (int) ((radius + 1) * Math.cos(RasterPlotter.PI180 * angle));
final int y = cy - (int) ((radius + 1) * Math.sin(RasterPlotter.PI180 * angle));

@ -298,6 +298,22 @@ public class RasterPlotter {
line(Ax, Ay, Bx, By, null, intensity, null, -1, -1, -1, -1, false);
}
/**
* draw a line using Bresenham's line drawing algorithm.
* The line will be plotted together with dots on it, if wanted.
* @param Ax
* @param Ay
* @param Bx
* @param By
* @param colorLine
* @param intensityLine
* @param colorDot
* @param intensityDot
* @param dotDist
* @param dotPos
* @param dotRadius
* @param dotFilled
*/
public void line(
int Ax, int Ay, final int Bx, final int By,
final Long colorLine, final int intensityLine,
@ -448,6 +464,21 @@ public class RasterPlotter {
}
}
/**
* draw a portion of a line from the center of a circle
* @param cx center of circle, x
* @param cy center of circle, y
* @param innerRadius inner radius of line
* @param outerRadius outer radius of line
* @param angle angle within the circle for the line
* @param in direction, if true: inward. This is the moving direction of dots, if dotRadius is alternated from 0 to 360
* @param colorLine the color of the line
* @param colorDot the color of the dot
* @param dotDist the distance of two dots
* @param dotPos the start position of the first dot
* @param dotRadius the radius of the dot
* @param dotFilled if true: dot is filled.
*/
public void arcLine(final int cx, final int cy, final int innerRadius, final int outerRadius, final double angle, final boolean in,
final Long colorLine, final Long colorDot, final int dotDist, final int dotPos, final int dotRadius, final boolean dotFilled) {
final double a = PI180 * angle;
@ -480,15 +511,35 @@ public class RasterPlotter {
dot(x, y, dotRadius, true, 100);
}
/**
* draw a connecting line between two points o a circle
* @param cx center of circle, x
* @param cy center of circle, y
* @param arcRadius radius of circle
* @param angle1 position of dot 1 on circle
* @param angle2 position of dot 2 on circle
* @param in direction of dots on line; in=true means: inwards
* @param colorLine
* @param intensityLine
* @param colorDot
* @param intensityDot
* @param dotDist
* @param dotPos
* @param dotRadius
* @param dotFilled
*/
public void arcConnect(final int cx, final int cy, final int arcRadius, final double angle1, final double angle2, final boolean in,
final Long colorLine, final int intensityLine,
final Long colorDot, final int intensityDot, final int dotDist, final int dotPos, final int dotRadius, final boolean dotFilled) {
final Long colorDot, final int intensityDot, final int dotDist, final int dotPos, final int dotRadius, final boolean dotFilled,
final String message, final Long colorMessage) {
final double a1 = PI180 * angle1;
final double a2 = PI180 * angle2;
// find positions of points
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));
// draw the line
if (in) {
line(x1, y1, x2, y2,
colorLine, intensityLine,
@ -498,6 +549,16 @@ public class RasterPlotter {
colorLine, intensityLine,
colorDot, intensityDot, dotDist, dotPos, dotRadius, dotFilled);
}
// draw a name on the line
if (message != null && message.length() > 0) {
this.setColor(colorMessage);
int xm = (x1 + 5 * x2) / 6;
int ym = (y1 + 5 * y2) / 6;
if (ym < cy) ym += 6; else ym -=6;
if (xm < cx) xm += 6; else xm -=6;
if (xm > cx) xm -= 6 * message.length();
PrintTool.print(this, xm, ym, 0, message.toUpperCase(), -1);
}
}
public void arcArc(final int cx, final int cy, final int arcRadius, final double angle,

Loading…
Cancel
Save