Update of /cvsroot/freenet/freenet/src/freenet/node/rt
In directory sc8-pr-cvs1:/tmp/cvs-serv22541/src/freenet/node/rt
Modified Files:
ResponseTimeEstimator.java
Log Message:
Initialize bitmaps with proper viewport (a viewport of (0,0,1,1) isn't of much use for
anything).
Draw estimator lines with lines instead of with dots.
Modify bitmap viewport scale calculation to enable drawing to (0,Y).
Fix bug in OCM PeerHandler HTML causing duplicate rendering of 'Transfer rate
(min/max) Xbytes/second/Xbytes/second' section on max detail level.
Darker colors in the PeerHandler HTML routing graphs. Easier to read and better for
flux lines drawing.
Index: ResponseTimeEstimator.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/ResponseTimeEstimator.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -w -r1.32 -r1.33
--- ResponseTimeEstimator.java 4 Nov 2003 08:24:59 -0000 1.32
+++ ResponseTimeEstimator.java 4 Nov 2003 12:32:11 -0000 1.33
@@ -18,6 +18,7 @@
import freenet.support.graph.BitmapEncoder;
import freenet.support.graph.Color;
import freenet.support.graph.DibEncoder;
+import freenet.support.graph.Rectangle;
// class Key {
@@ -712,60 +713,52 @@
return nf.format(((double)x) / (16*1000)) +
"bytes/second";
throw new IllegalArgumentException("unknown type");
}
+ private GraphDataSet generateGraphData(int samples,BigInteger
keyspaceStepLength, int age){
+ GraphDataSet g = new GraphDataSet();
+ g.val = new int[samples];
+
+ BigInteger at = BigInteger.ZERO;
+ for (int i = 0; i < samples; i++) {
+ g.val[i] = guess(at, age);
+ g.lowest = Math.min(g.lowest, g.val[i]);
+ g.highest = Math.max(g.highest, g.val[i]);
+ at = at.add(keyspaceStepLength);
+ }
+ return g;
+ }
public void drapGraphOnImage(boolean dontClipPoints, Bitmap
bmp,boolean drawHistoryIfPossible, Color lineCol, Color crossCol) {
- BigInteger a = Key.keyspace.subtract(BigInteger.ONE);
- BigInteger b = a.divide(BigInteger.valueOf(bmp.getWidth()));
LinkedList l = new LinkedList();
int lowest=Integer.MAX_VALUE;
int highest=0;
+ BigInteger keyspaceLastKey =
Key.keyspace.subtract(BigInteger.ONE);
+ BigInteger keyspaceStepLength =
keyspaceLastKey.divide(BigInteger.valueOf(bmp.getWidth())); //Pregenerate these values
to save us some later calculations
- if(drawHistoryIfPossible && store instanceof
HistoryKeepingRoutingPointStore &&
((HistoryKeepingRoutingPointStore)store).historySize()>0)
- {
- Color nextColor= nextColor = Color.add(lineCol,new
Color(30,30,30)); //Start a bit lighter
+ int maxAge = 0;
+ if(drawHistoryIfPossible && store instanceof
HistoryKeepingRoutingPointStore &&
((HistoryKeepingRoutingPointStore)store).historySize()>0){
HistoryKeepingRoutingPointStore hstore =
(HistoryKeepingRoutingPointStore)store;
- synchronized (hstore) {
- for (int i2 = 1; i2 < hstore.historySize();
i2++) {
- BigInteger at = BigInteger.ZERO;
- GraphDataSet g = new GraphDataSet();
- g.val = new int[bmp.getWidth()];
- g.lineCol = nextColor;
- g.crossCol = null;
- for (int i = 0; i < bmp.getWidth();
i++) {
- g.val[i] = guess(at, i2);
- g.lowest = Math.min(g.lowest,
g.val[i]);
- lowest = Math.min(g.lowest,
lowest);
- g.highest =
Math.max(g.highest, g.val[i]);
- highest = Math.max(g.highest,
highest);
- at = at.add(b);
- }
- l.add(g);
- nextColor = Color.add(nextColor,new
Color(10,10,10)); //The older, the lighter
+ maxAge = hstore.historySize();
}
- }
- }
- GraphDataSet g = new GraphDataSet();
- g.val = new int[bmp.getWidth()];
+ synchronized (store) {
+ for (int i2 = 0; i2 <= maxAge; i2++) {
+ GraphDataSet g =
generateGraphData(bmp.getWidth(), keyspaceStepLength,i2);
g.lineCol = lineCol;
- g.crossCol = crossCol;
- BigInteger at = BigInteger.ZERO;
- for (int i = 0; i < bmp.getWidth(); i++) {
- g.val[i] = guess(at);
- g.lowest = Math.min(g.lowest, g.val[i]);
+ g.crossCol = null;
lowest = Math.min(g.lowest, lowest);
- g.highest = Math.max(g.highest, g.val[i]);
highest = Math.max(g.highest, highest);
- at = at.add(b);
+ l.addFirst(g); //Make sure we draw the
recentmost graph last (=on top of the others)
+ if(i2>1)
+ lineCol = Color.add(lineCol, new
Color(4, 4, 4)); //The older in the history, the lighter
+ else
+ lineCol = Color.add(lineCol, new
Color(50, 50, 50)); //Make a larger step when we initially go into history values
+ }
}
- l.add(g);
Iterator it = l.iterator();
while(it.hasNext()){
GraphDataSet n = (GraphDataSet)it.next();
- //n.lowest = g.lowest;
- //n.highest = g.highest;
n.lowest = lowest;
n.highest = highest;
- drapGraphOnImage(dontClipPoints, bmp, n,b);
+ drapGraphOnImage(dontClipPoints, bmp,
n,keyspaceStepLength);
}
}
private class GraphDataSet{
@@ -774,7 +767,7 @@
int lowest=Integer.MAX_VALUE;
int highest=0;
}
- private void drapGraphOnImage(boolean dontClipPoints, Bitmap bmp,
GraphDataSet g,BigInteger b) {
+ private void drapGraphOnImage(boolean dontClipPoints, Bitmap bmp,
GraphDataSet g,BigInteger keyspaceStepLength) {
if(g.crossCol != null){ //Only consider recent max/min if we
are actually going to draw the crosses
RecentReports.LowestHighestPair lowestAndHighestRecent
= recent.getLowestAndHighest(dontClipPoints);
@@ -788,14 +781,14 @@
double multiplier = ((double) bmp.getHeight() - 1) / ((double)
(g.highest - g.lowest));
if (g.lineCol != null) {
bmp.setPenColor(g.lineCol);
- //int initposition = (int) ((g.val[0] - g.lowest) *
multiplier);
- //initposition = bmp.getHeight() - (initposition + 1);
- //bmp.moveTo(0,initposition);
- for (int i = 0; i < bmp.getWidth(); i++) {
+ int initposition = (int) ((g.val[0] - g.lowest) *
multiplier);
+ initposition = bmp.getHeight() - (initposition + 1);
+ bmp.moveTo(0,initposition);
+ for (int i = 1; i < bmp.getWidth(); i++) {
int position = (int) ((g.val[i] - g.lowest) *
multiplier);
position = bmp.getHeight() - (position + 1);
- bmp.setPixel(i, position);
- //bmp.drawTo(i,position);
+ //bmp.setPixel(i, position);
+ bmp.drawTo(i,position);
}
}
@@ -807,7 +800,7 @@
Enumeration e = recent.enumeration();
while (e.hasMoreElements()) {
RecentReports.KeyTimePair kt =
(RecentReports.KeyTimePair) e.nextElement();
- int w = kt.key.divide(b).intValue();
+ int w =
kt.key.divide(keyspaceStepLength).intValue();
int h = (int) ((kt.time - g.lowest) *
multiplier);
h = Math.max(h, 0);
h = Math.min(bmp.getHeight() - 1, h);
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs