*) improved peerloadgraphic:

- unnecessary (0 %) pieces are removed
 - percent-values of each thread displayed in legend

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3474 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
auron_x 2007-03-12 19:08:17 +00:00
parent a5d668c0c6
commit d451ad48d3
3 changed files with 24 additions and 18 deletions

View File

@ -62,9 +62,14 @@ public class PeerLoadPicture {
// set respective angles
Iterator it = pieces.values().iterator();
CircleThreadPiece current;
while (it.hasNext()) {
((CircleThreadPiece)it.next()).setAngle(busy_time);
current = (CircleThreadPiece)it.next();
current.setFraction(busy_time);
//remove unneccessary elements
if(current.getAngle() == 0) it.remove();
}
misc.setFraction(busy_time);
// too small values lead to an error, too big to huge CPU/memory consumption,
// resulting in possible DOS.

View File

@ -88,14 +88,15 @@ public class plasmaGrafics {
private final String pieceName;
private final Color color;
private long execTime = 0;
private int angle = 0;
private float fraction = 0;
public CircleThreadPiece(String pieceName, Color color) {
this.pieceName = pieceName;
this.color = color;
}
public int getAngle() { return this.angle; }
public int getAngle() { return (int)Math.round(360f*this.fraction); }
public int getFractionPercent() { return (int)Math.round(100f*this.fraction); }
public Color getColor() { return this.color; }
public long getExecTime() { return this.execTime; }
public String getPieceName() { return this.pieceName; }
@ -103,11 +104,11 @@ public class plasmaGrafics {
public void addExecTime(long execTime) { this.execTime += execTime; }
public void reset() {
this.execTime = 0;
this.angle = 0;
this.fraction = 0;
}
public void setExecTime(long execTime) { this.execTime = execTime; }
public void setAngle(long totalBusyTime) {
this.angle = (int)Math.round(360f * ((float)this.execTime / (float)totalBusyTime));
public void setFraction(long totalBusyTime) {
this.fraction = (float)this.execTime / (float)totalBusyTime;
}
}
@ -316,24 +317,24 @@ public class plasmaGrafics {
int circ_w = Math.min(width,height)-20; //width of the circle (r*2)
int circ_x = width-circ_w-10; //x-coordinate of circle-left
int circ_y = 10; //y-coordinate of circle-top
int curr_arc = 0; //remember current angle
int curr_angle = 0; //remember current angle
int i;
for (i=0; i<pieces.length; i++) {
// draw the piece
g.setColor(pieces[i].getColor());
g.fillArc(circ_x, circ_y, circ_w, circ_w, curr_arc, pieces[i].getAngle());
curr_arc += pieces[i].getAngle();
g.fillArc(circ_x, circ_y, circ_w, circ_w, curr_angle, pieces[i].getAngle());
curr_angle += pieces[i].getAngle();
// draw it's legend line
drawLegendLine(g, 5, height - 5 - 15 * i, pieces[i].getPieceName(), pieces[i].getColor());
drawLegendLine(g, 5, height - 5 - 15 * i, pieces[i].getPieceName()+" ("+pieces[i].getFractionPercent()+" %)", pieces[i].getColor());
}
// fill the rest
g.setColor(fillRest.getColor());
//FIXME: better method to avoid gaps on rounding-differences?
g.fillArc(circ_x, circ_y, circ_w, circ_w, curr_arc, 360 - curr_arc);
drawLegendLine(g, 5, height - 5 - 15 * i, fillRest.getPieceName(), fillRest.getColor());
g.fillArc(circ_x, circ_y, circ_w, circ_w, curr_angle, 360 - curr_angle);
drawLegendLine(g, 5, height - 5 - 15 * i, fillRest.getPieceName()+" ("+fillRest.getFractionPercent()+" %)", fillRest.getColor());
//draw border around the circle
g.setColor(COL_BORDER);

View File

@ -11,15 +11,15 @@ public class ParseVersion extends TestCase {
assertEquals("dev/00000", yacy.combined2prettyVersion("")); // not a number
assertEquals("dev/00000", yacy.combined2prettyVersion(" ")); // not a number
assertEquals("dev/02417", yacy.combined2prettyVersion("0.10002417"));
assertEquals("dev/02440", yacy.combined2prettyVersion("0.10002440"));
assertEquals("dev/02440", yacy.combined2prettyVersion("0.1000244"));
assertEquals("dev/02417", yacy.combined2prettyVersion("0.10002417"));
assertEquals("dev/00000", yacy.combined2prettyVersion("0.100024400")); // input is too long
assertEquals("dev/02440", yacy.combined2prettyVersion("0.10902440"));
assertEquals("0.110/02440", yacy.combined2prettyVersion("0.11002440"));
assertEquals("0.111/02440", yacy.combined2prettyVersion("0.11102440"));
assertEquals("dev/00000", yacy.combined2prettyVersion("0.00000000")); // input is valid - no warning generated
assertEquals("dev/02440", yacy.combined2prettyVersion("0.1090244"));
assertEquals("0.110/02440", yacy.combined2prettyVersion("0.1100244"));
assertEquals("0.111/02440", yacy.combined2prettyVersion("0.1110244"));
assertEquals("dev/00000", yacy.combined2prettyVersion("0.0")); // input is valid - no warning generated
assertEquals("dev/00000", yacy.combined2prettyVersion(" 0.11102440")); // spaces are not allowed
assertEquals("dev/00000", yacy.combined2prettyVersion("0.111244")); // input is too short
assertEquals("dev/00000", yacy.combined2prettyVersion("0.111")); // input is too short
assertEquals("dev/00000", yacy.combined2prettyVersion("0.1112440\t\n")); // \t and \n are not allowed
assertEquals("dev/00000", yacy.combined2prettyVersion("124353432xxxx4546399999")); // not a number + too long
assertEquals("dev/00000", yacy.combined2prettyVersion("123456789x")); // not a number