|
From: Arne V. <cob...@us...> - 2004-04-19 22:35:10
|
Update of /cvsroot/jrobin/src/org/jrobin/graph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30568/src/org/jrobin/graph Modified Files: Gprint.java Grapher.java ChartGraphics.java TimeAxisUnit.java ValueGrid.java ValueAxisUnit.java Source.java Log Message: JRobin 1.3.1 DEBUG UPDATE - testing purposes - Bug fixes for bugs #0000032 and #0000033 - Improved Value Grid calculation - Improved Time Grid calculation for monthly gridlines - Fixed possible Trime Grid shift between minor and major lines - Modified right aligned title padding (signature overlap) Index: Grapher.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Grapher.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Grapher.java 30 Mar 2004 22:57:45 -0000 1.8 --- Grapher.java 19 Apr 2004 22:35:00 -0000 1.9 *************** *** 194,200 **** plotOverlay( graphics ); // draw a possible image overlay - - plotSignature( graphics ); // draw the JRobin signature // Dispose graphics context --- 194,199 ---- plotOverlay( graphics ); // draw a possible image overlay + plotSignature( graphics ); // draw the JRobin signature // Dispose graphics context *************** *** 254,260 **** plotOverlay( graphics ); // draw a possible image overlay - - plotSignature( graphics ); // draw the JRobin signature // Dispose graphics context --- 253,258 ---- plotOverlay( graphics ); // draw a possible image overlay + plotSignature( graphics ); // draw the JRobin signature // Dispose graphics context *************** *** 333,337 **** veList[ vePos++ ] = ve; } ! // Add all Pdefs to the source table for ( int i = 0; i < pdefList.length; i++ ) --- 331,335 ---- veList[ vePos++ ] = ve; } ! // Add all Pdefs to the source table for ( int i = 0; i < pdefList.length; i++ ) *************** *** 482,486 **** double min = src.getAggregate( Source.AGG_MINIMUM ); double max = src.getAggregate( Source.AGG_MAXIMUM ); ! // If the plotdef is a stack, evaluate ALL previous values to find a possible max if ( plotDefs[i].plotType == PlotDef.PLOT_STACK && i >= 1 ) --- 480,484 ---- double min = src.getAggregate( Source.AGG_MINIMUM ); double max = src.getAggregate( Source.AGG_MAXIMUM ); ! // If the plotdef is a stack, evaluate ALL previous values to find a possible max if ( plotDefs[i].plotType == PlotDef.PLOT_STACK && i >= 1 ) *************** *** 526,530 **** lowerValue = vGrid.getLowerValue(); upperValue = vGrid.getUpperValue(); ! // Use a special graph 'object' that takes care of resizing and reversing y coordinates ChartGraphics g = new ChartGraphics( graphics ); --- 524,528 ---- lowerValue = vGrid.getLowerValue(); upperValue = vGrid.getUpperValue(); ! // Use a special graph 'object' that takes care of resizing and reversing y coordinates ChartGraphics g = new ChartGraphics( graphics ); *************** *** 901,905 **** else if ( tkn == Comment.TKN_ARF ) { newLine = true; ! posx = imgWidth - RBORDER_SPACE - (tmpStr.length() * tfont_width); } else if ( tkn == Comment.TKN_ACF ) { --- 899,903 ---- else if ( tkn == Comment.TKN_ARF ) { newLine = true; ! posx = imgWidth - RBORDER_SPACE - (tmpStr.length() * tfont_width) - tfont_width; } else if ( tkn == Comment.TKN_ACF ) { *************** *** 910,914 **** posx = LBORDER_SPACE; else if ( tkn == Comment.TKN_AR ) ! posx = imgWidth - RBORDER_SPACE - (tmpStr.length() * tfont_width); else if ( tkn == Comment.TKN_AC ) posx = imgWidth / 2 - (tmpStr.length() * tfont_width) / 2; --- 908,912 ---- posx = LBORDER_SPACE; else if ( tkn == Comment.TKN_AR ) ! posx = imgWidth - RBORDER_SPACE - (tmpStr.length() * tfont_width) - tfont_width; else if ( tkn == Comment.TKN_AC ) posx = imgWidth / 2 - (tmpStr.length() * tfont_width) / 2; Index: ValueAxisUnit.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueAxisUnit.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ValueAxisUnit.java 30 Mar 2004 22:57:45 -0000 1.4 --- ValueAxisUnit.java 19 Apr 2004 22:35:00 -0000 1.5 *************** *** 226,233 **** double value = ovalue * gridFactor; ! int valueInt = new Double(value).intValue(); ! int roundStep = new Double(gridStep).intValue(); if ( roundStep == 0 ) roundStep = 1; ! int num = valueInt / roundStep; // int mod = valueInt % roundStep; double gridValue = (roundStep * (num + 1)) * 1.0d; --- 226,233 ---- double value = ovalue * gridFactor; ! long valueInt = new Double(value).longValue(); ! long roundStep = new Double(gridStep).longValue(); if ( roundStep == 0 ) roundStep = 1; ! long num = valueInt / roundStep; // int mod = valueInt % roundStep; double gridValue = (roundStep * (num + 1)) * 1.0d; *************** *** 236,240 **** value = ovalue * mGridFactor; ! roundStep = new Double(mGridStep).intValue(); if ( roundStep == 0 ) roundStep = 1; num = valueInt / roundStep; --- 236,240 ---- value = ovalue * mGridFactor; ! roundStep = new Double(mGridStep).longValue(); if ( roundStep == 0 ) roundStep = 1; num = valueInt / roundStep; Index: ValueGrid.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueGrid.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ValueGrid.java 30 Mar 2004 22:57:45 -0000 1.4 --- ValueGrid.java 19 Apr 2004 22:35:00 -0000 1.5 *************** *** 174,181 **** else if ( shifted <= 5 ) vAxis = new ValueAxisUnit( 0.5 * mod * scaleValues[scaleIndex], 1.0 * mod * scaleValues[scaleIndex] ); - else if ( shifted <= 9 ) - vAxis = new ValueAxisUnit( 0.5 * mod * scaleValues[scaleIndex], 2.0 * mod * scaleValues[scaleIndex] ); else ! vAxis = new ValueAxisUnit( 0.1 * mod * scaleValues[scaleIndex], 0.5 * mod * scaleValues[scaleIndex] ); } } --- 174,179 ---- else if ( shifted <= 5 ) vAxis = new ValueAxisUnit( 0.5 * mod * scaleValues[scaleIndex], 1.0 * mod * scaleValues[scaleIndex] ); else ! vAxis = new ValueAxisUnit( 0.5 * mod * scaleValues[scaleIndex], 2.0 * mod * scaleValues[scaleIndex] ); } } Index: ChartGraphics.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ChartGraphics.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ChartGraphics.java 7 Nov 2003 08:23:19 -0000 1.1 --- ChartGraphics.java 19 Apr 2004 22:35:00 -0000 1.2 *************** *** 141,145 **** yStart = lower; yEnd = upper; ! if ( yEnd != yStart ) heightDelta = height * 1.0d / (( yEnd - yStart) * 1.0d); --- 141,145 ---- yStart = lower; yEnd = upper; ! if ( yEnd != yStart ) heightDelta = height * 1.0d / (( yEnd - yStart) * 1.0d); *************** *** 168,173 **** int tmp = new Double( (value - ( yStart < 0 ? 0 : Math.abs(yStart) ) ) * heightDelta).intValue(); ! ! return ( tmp > value * heightDelta ? tmp - 1 : tmp ); } --- 168,173 ---- int tmp = new Double( (value - ( yStart < 0 ? 0 : Math.abs(yStart) ) ) * heightDelta).intValue(); ! ! return ( tmp > value * heightDelta ? tmp - 1 : tmp ); } Index: Source.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Source.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Source.java 30 Mar 2004 22:57:45 -0000 1.5 --- Source.java 19 Apr 2004 22:35:00 -0000 1.6 *************** *** 42,47 **** protected static final int AGG_FIRST = 3; protected static final int AGG_LAST = 4; ! protected static final String[] aggregates = { "MINIMUM", "MAXIMUM", "AVERAGE", "FIRST", "LAST" }; private String name; protected double[] values; --- 42,48 ---- protected static final int AGG_FIRST = 3; protected static final int AGG_LAST = 4; + protected static final int AGG_TOTAL = 5; ! protected static final String[] aggregates = { "MINIMUM", "MAXIMUM", "AVERAGE", "FIRST", "LAST", "TOTAL" }; private String name; protected double[] values; *************** *** 54,58 **** private long lastTime = 0; private long totalTime = 0; ! // ================================================================ --- 55,59 ---- private long lastTime = 0; private long totalTime = 0; ! double testval = 0; // ================================================================ *************** *** 97,101 **** * Gets a specific aggregate of this datasource. * Requested aggregate can be one of the following: ! * <code>AGG_MINIMUM, AGG_MAXIMUM, AGG_AVERAGE, AGG_FIRST</code> * and <code>AGG_LAST</code>. * @param aggType Type of the aggregate requested. --- 98,102 ---- * Gets a specific aggregate of this datasource. * Requested aggregate can be one of the following: ! * <code>AGG_MINIMUM, AGG_MAXIMUM, AGG_AVERAGE, AGG_FIRST, AGG_TOTAL</code> * and <code>AGG_LAST</code>. * @param aggType Type of the aggregate requested. *************** *** 125,129 **** if ( values != null && values.length > 0) return values[values.length - 1]; ! break; } --- 126,133 ---- if ( values != null && values.length > 0) return values[values.length - 1]; ! break; ! ! case AGG_TOTAL: ! return testval; } *************** *** 160,163 **** --- 164,168 ---- { long timeDelta = time - lastTime; + testval += value; totalValue += timeDelta * ( value + lastValue ) / 2.0; totalTime += timeDelta; Index: TimeAxisUnit.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/TimeAxisUnit.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TimeAxisUnit.java 1 Mar 2004 08:50:25 -0000 1.4 --- TimeAxisUnit.java 19 Apr 2004 22:35:00 -0000 1.5 *************** *** 47,60 **** Calendar.YEAR }; - private static final int[] nullValue = - { - 0, - 0, - 0, - 1, - 1, - 0, - 1970 // Should never be used, but put there to avoid index out of bounds - }; // Indices in the calendarUnit table --- 47,50 ---- *************** *** 79,88 **** private int minGridTimeUnit = HOUR; // minor grid ! private int minGridUnitSteps = 1; private int majGridTimeUnit = HOUR; // major grid ! private int majGridUnitSteps = 6; ! private boolean centerLabels = false; ! private SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm", Locale.ENGLISH ); --- 69,78 ---- private int minGridTimeUnit = HOUR; // minor grid ! private int minGridUnitSteps = 1; private int majGridTimeUnit = HOUR; // major grid ! private int majGridUnitSteps = 6; ! private boolean centerLabels = false; ! private SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm", Locale.ENGLISH ); *************** *** 250,257 **** { t.setTimeInMillis( exactStart ); ! for (int i = 0; i < calendarUnit.length && i <= unit; i++) ! t.set( calendarUnit[i], nullValue[i] ); if ( unit == WEEK ) t.set( Calendar.DAY_OF_WEEK, t.getFirstDayOfWeek() ); } --- 240,260 ---- { t.setTimeInMillis( exactStart ); ! ! t.setFirstDayOfWeek(Calendar.MONDAY); ! for (int i = 0; i < HOUR && i <= unit; i++) ! t.set( calendarUnit[i], 0 ); ! ! if ( unit >= HOUR ) ! t.set( Calendar.HOUR_OF_DAY, 0 ); ! if ( unit == WEEK ) t.set( Calendar.DAY_OF_WEEK, t.getFirstDayOfWeek() ); + else if ( unit == MONTH ) + t.set( Calendar.DAY_OF_MONTH, 1 ); + else if ( unit == YEAR ) + { + t.set( Calendar.DATE, 1 ); + t.set( Calendar.MONTH, 0 ); + } } *************** *** 266,269 **** --- 269,273 ---- { t.add( calendarUnit[unit], unitSteps ); + return t.getTimeInMillis(); } Index: Gprint.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Gprint.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Gprint.java 1 Mar 2004 08:50:25 -0000 1.3 --- Gprint.java 19 Apr 2004 22:35:00 -0000 1.4 *************** *** 88,91 **** --- 88,93 ---- else if ( consolFunc.equalsIgnoreCase("FIRST") ) aggregate = Source.AGG_FIRST; + else if ( consolFunc.equalsIgnoreCase("TOTAL") ) + aggregate = Source.AGG_TOTAL; else throw new RrdException( "Invalid consolidation function specified." ); |