From: Arne V. <cob...@us...> - 2004-10-27 20:36:42
|
Update of /cvsroot/jrobin/src/org/jrobin/graph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8709/org/jrobin/graph Modified Files: CustomArea.java RrdExporter.java Source.java ValueExtractor.java ValueGrid.java Removed Files: RrdtoolGraph.java Log Message: JRobin 1.4.1 - Fixing bug #0000067 - Improved grid with constant value Index: ValueExtractor.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueExtractor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ValueExtractor.java 25 Jul 2004 12:28:49 -0000 1.4 --- ValueExtractor.java 27 Oct 2004 20:36:26 -0000 1.5 *************** *** 87,91 **** // -- Protected methods // ================================================================ ! int prepareSources( Source[] sources, int offset ) { int tblPos = offset; --- 87,91 ---- // -- Protected methods // ================================================================ ! int prepareSources( Source[] sources, int offset, long startTime, long endTime ) { int tblPos = offset; *************** *** 97,100 **** --- 97,101 ---- for (int x = 0; x < dsValues[i].length; x++) { + sources[tblPos].setTimespan( startTime, endTime ); sources[tblPos++].setFetchedStep( steps[i] ); } Index: ValueGrid.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueGrid.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ValueGrid.java 25 Jul 2004 12:28:49 -0000 1.13 --- ValueGrid.java 27 Oct 2004 20:36:26 -0000 1.14 *************** *** 141,144 **** --- 141,151 ---- upper = 0.9; + if ( upper == lower ) + { + double origUpper = upper; + upper = origUpper + origUpper/100; + lower = origUpper - origUpper/100; + } + // Determine nice axis grid double shifted = Math.abs(upper - lower); Index: CustomArea.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/CustomArea.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CustomArea.java 9 Jul 2004 12:22:15 -0000 1.5 --- CustomArea.java 27 Oct 2004 20:36:26 -0000 1.6 *************** *** 30,33 **** --- 30,34 ---- import org.jrobin.core.RrdException; import org.jrobin.core.XmlWriter; + import org.jrobin.core.Util; /** *************** *** 110,123 **** // Get Y positions ! if ( yVal1 == Double.MIN_VALUE ) ay = g.getMinY(); ! else if ( yVal1 == Double.MAX_VALUE ) ay = g.getMaxY(); else ay = g.getY( yVal1 ); ! if ( yVal2 == Double.MIN_VALUE ) ny = g.getMinY(); ! else if ( yVal2 == Double.MAX_VALUE ) ny = g.getMaxY(); else --- 111,124 ---- // Get Y positions ! if ( yVal1 == Util.MIN_DOUBLE ) ay = g.getMinY(); ! else if ( yVal1 == Util.MAX_DOUBLE ) ay = g.getMaxY(); else ay = g.getY( yVal1 ); ! if ( yVal2 == Util.MIN_DOUBLE ) ny = g.getMinY(); ! else if ( yVal2 == Util.MAX_DOUBLE ) ny = g.getMaxY(); else *************** *** 135,139 **** // Set the stackvalues // Always use the y value of the second specified point to stack on ! if ( yVal2 != Double.MAX_VALUE ) for (int i = 0; i < stackValues.length; i++) if ( xValues[i] < ax || xValues[i] > nx ) --- 136,140 ---- // Set the stackvalues // Always use the y value of the second specified point to stack on ! if ( yVal2 != Util.MAX_DOUBLE ) for (int i = 0; i < stackValues.length; i++) if ( xValues[i] < ax || xValues[i] > nx ) *************** *** 155,166 **** { long time = timestamps[tblPos]; ! // Out of range if ( time > xVal2 || time < xVal1 ) return Double.NaN; ! ! if ( yVal2 == Double.MAX_VALUE ) return Double.NaN; ! return yVal2; } --- 156,167 ---- { long time = timestamps[tblPos]; ! // Out of range if ( time > xVal2 || time < xVal1 ) return Double.NaN; ! ! if ( yVal2 == Util.MAX_DOUBLE ) return Double.NaN; ! return yVal2; } Index: Source.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Source.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Source.java 25 Jul 2004 12:28:49 -0000 1.12 --- Source.java 27 Oct 2004 20:36:26 -0000 1.13 *************** *** 61,64 **** --- 61,66 ---- private long totalTime = 0; + private long startTime, endTime; + private int stPos = 0; private int lastStPos = 0; // Last value position requested *************** *** 75,80 **** this.name = name; } ! ! // ================================================================ // -- Protected methods --- 77,81 ---- this.name = name; } ! // ================================================================ // -- Protected methods *************** *** 91,98 **** // The first sample is before the time range we want, and as such // should not be counted for data aggregation ! if ( pos > 0 && pos < aggregatePoints ) aggregate( time, val ); } void setFetchedStep( long step ) { this.step = step; --- 92,105 ---- // The first sample is before the time range we want, and as such // should not be counted for data aggregation ! if ( pos < aggregatePoints ) aggregate( time, val ); } + void setTimespan( long startTime, long endTime ) + { + this.startTime = startTime; + this.endTime = endTime; + } + void setFetchedStep( long step ) { this.step = step; *************** *** 155,159 **** t = ( t < preciseTime ? t + step : t ); ! if ( preciseTime < lastPreciseTime ) // Backward fetching is weird, start over, we prolly in a new iteration stPos = 0; --- 162,166 ---- t = ( t < preciseTime ? t + step : t ); ! if ( preciseTime < lastPreciseTime ) // Backward fetching is weird, start over, we're prolly in a new iteration stPos = 0; *************** *** 199,203 **** case AGG_FIRST: if ( values != null && values.length > 0) ! return values[0]; break; --- 206,210 ---- case AGG_FIRST: if ( values != null && values.length > 0) ! return values[ values.length > 1 ? 1 : 0 ]; break; *************** *** 235,255 **** * @param value Double value of the datapoint. */ ! private void aggregate( long time, double value ) { if ( Double.isInfinite(value) ) return; ! min = Util.min( min, value ); ! max = Util.max( max, value ); ! ! if ( !Double.isNaN(lastValue) && !Double.isNaN(value) ) { long timeDelta = time - lastTime; ! totalValue += timeDelta * ( value + lastValue ) / 2.0; totalTime += timeDelta; } ! lastTime = time; lastValue = value; } --- 242,265 ---- * @param value Double value of the datapoint. */ ! private void aggregate( long time, double value ) { if ( Double.isInfinite(value) ) return; ! if ( time > endTime ) ! time = endTime; ! ! if ( lastTime > 0 && !Double.isNaN(value) && value != Double.MIN_VALUE && value != Double.MAX_VALUE ) { + min = Util.min( min, value ); + max = Util.max( max, value ); + long timeDelta = time - lastTime; ! totalValue += timeDelta * value; totalTime += timeDelta; } ! lastTime = ( time < startTime ? startTime : time ); lastValue = value; } Index: RrdExporter.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdExporter.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RrdExporter.java 25 Jul 2004 12:28:49 -0000 1.6 --- RrdExporter.java 27 Oct 2004 20:36:26 -0000 1.7 *************** *** 327,331 **** int pos = 0; for (int j = 0; j < veList.length; j++) ! pos = veList[j].prepareSources( sources, pos ); // **************************************************************************************** // --- 327,331 ---- int pos = 0; for (int j = 0; j < veList.length; j++) ! pos = veList[j].prepareSources( sources, pos, startTime, endTime ); // **************************************************************************************** // --- RrdtoolGraph.java DELETED --- |