From: Arne V. <cob...@us...> - 2004-07-20 16:51:42
|
Update of /cvsroot/jrobin/src/org/jrobin/graph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7020/org/jrobin/graph Modified Files: RrdGraphDefTemplate.java ValueGrid.java Log Message: JRobin 1.4.1 - Altered ValueGrid to throw Exception in rare case Index: ValueGrid.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueGrid.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ValueGrid.java 10 Jul 2004 00:07:03 -0000 1.10 --- ValueGrid.java 20 Jul 2004 16:51:27 -0000 1.11 *************** *** 25,28 **** --- 25,30 ---- package org.jrobin.graph; + import org.jrobin.core.RrdException; + /** * <p>Holds specific information about the Value axis grid of the chart.</p> *************** *** 60,64 **** * ValueAxisUnit is null, one will be automatically determined. */ ! ValueGrid( GridRange gr, double low, double up, ValueAxisUnit vAxis, double base ) { double grLower = Double.MAX_VALUE; --- 62,66 ---- * ValueAxisUnit is null, one will be automatically determined. */ ! ValueGrid( GridRange gr, double low, double up, ValueAxisUnit vAxis, double base ) throws RrdException { double grLower = Double.MAX_VALUE; *************** *** 78,92 **** // Fill in the scale values ! double tmp = 1; ! for (int i = 1; i < 7; i++) { ! tmp *= baseValue; ! scaleValues[6 - i] = tmp; ! } ! tmp = 1; ! for (int i = 7; i < scaleValues.length; i++) { ! tmp *= baseValue; ! scaleValues[i] = ( 1 / tmp ); } ! // Set an appropriate value axis it not given yet setValueAxis(); --- 80,97 ---- // Fill in the scale values ! if ( base != baseValue ) ! { ! double tmp = 1; ! for (int i = 1; i < 7; i++) { ! tmp *= baseValue; ! scaleValues[6 - i] = tmp; ! } ! tmp = 1; ! for (int i = 7; i < scaleValues.length; i++) { ! tmp *= baseValue; ! scaleValues[i] = ( 1 / tmp ); ! } } ! // Set an appropriate value axis it not given yet setValueAxis(); *************** *** 122,126 **** * A decent grid is selected based on the value range being used in the chart. */ ! private void setValueAxis() { if ( vAxis != null ) --- 127,131 ---- * A decent grid is selected based on the value range being used in the chart. */ ! private void setValueAxis() throws RrdException { if ( vAxis != null ) *************** *** 131,135 **** if ( Double.isNaN(lower) || lower == Double.MAX_VALUE || lower == Double.MIN_VALUE ) lower = 0; ! if ( !rigid && upper == 0 && upper == lower ) upper = 0.9; --- 136,140 ---- if ( Double.isNaN(lower) || lower == Double.MAX_VALUE || lower == Double.MIN_VALUE ) lower = 0; ! if ( !rigid && upper == 0 && upper == lower ) upper = 0.9; *************** *** 143,151 **** double mod = 1.0; int scaleIndex = scaleValues.length - 1; ! while ( scaleIndex >= 0 && scaleValues[scaleIndex] < shifted ) scaleIndex--; // Keep the rest of division ! shifted = shifted / scaleValues[++scaleIndex]; // While rest > 10, divide by 10 --- 148,161 ---- double mod = 1.0; int scaleIndex = scaleValues.length - 1; ! while ( scaleIndex >= 0 && scaleValues[scaleIndex] < shifted ) scaleIndex--; // Keep the rest of division ! if ( scaleValues[++scaleIndex] != 0 ) // Don't divide by zero, it is silly ! shifted = shifted / scaleValues[scaleIndex]; ! ! // Safety check to avoid infinite loop ! if ( Double.isInfinite(shifted) ) ! throw new RrdException( "ValueGrid failure: u=" + upper + " l=" + lower + " sv=" + scaleValues[scaleIndex] ); // While rest > 10, divide by 10 *************** *** 154,158 **** mod *= 10; } ! while ( shifted < 1.0 ) { shifted *= 10; --- 164,168 ---- mod *= 10; } ! while ( shifted < 1.0 ) { shifted *= 10; Index: RrdGraphDefTemplate.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraphDefTemplate.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RrdGraphDefTemplate.java 13 Jul 2004 12:13:13 -0000 1.9 --- RrdGraphDefTemplate.java 20 Jul 2004 16:51:27 -0000 1.10 *************** *** 383,389 **** String format = getChildValue(childs[i], "format", false ); String pattern = getChildValue(childs[i], "pattern"); - String timestamp = getChildValue(childs[i], "value"); ! rrdGraphDef.time( format, pattern, Util.getGregorianCalendar(timestamp) ); } else if(nodeName.equals("hrule")) { --- 383,394 ---- String format = getChildValue(childs[i], "format", false ); String pattern = getChildValue(childs[i], "pattern"); ! if ( Util.Xml.hasChildNode( childs[i], "value" ) ) ! { ! String timestamp = getChildValue(childs[i], "value"); ! rrdGraphDef.time( format, pattern, Util.getGregorianCalendar(timestamp) ); ! } ! else ! rrdGraphDef.time( format, pattern ); } else if(nodeName.equals("hrule")) { *************** *** 563,567 **** "overlay", "show_legend", "show_signature", "time_axis", "time_axis_label", "title", "title_font", "title_font_color", "units_exponent", "value_axis", ! "vertical_label", "strict_export", "resolution" }); Node[] optionNodes = getChildNodes(rootOptionNode); --- 568,572 ---- "overlay", "show_legend", "show_signature", "time_axis", "time_axis_label", "title", "title_font", "title_font_color", "units_exponent", "value_axis", ! "vertical_label", "strict_export", "resolution", "lower_limit" }); Node[] optionNodes = getChildNodes(rootOptionNode); *************** *** 637,640 **** --- 642,650 ---- rrdGraphDef.setGridRange(lower, upper, rigid); } + // LOWER LIMIT + else if(option.equals("lower_limit")) { + double lower = getValueAsDouble(optionNode); + rrdGraphDef.setLowerLimit( lower ); + } // GRID X? else if(option.equals("grid_x")) { |