You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(11) |
Oct
(60) |
Nov
(68) |
Dec
(10) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(10) |
Feb
(15) |
Mar
(30) |
Apr
(20) |
May
(32) |
Jun
(30) |
Jul
(61) |
Aug
(13) |
Sep
(14) |
Oct
(13) |
Nov
(28) |
Dec
(10) |
2005 |
Jan
(7) |
Feb
(5) |
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(15) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(20) |
Aug
(35) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(14) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
Update of /cvsroot/jrobin/src/jrobin/core In directory sc8-pr-cvs1:/tmp/cvs-serv23539/jrobin/core Modified Files: ArcState.java Archive.java Datasource.java Header.java Robin.java RrdDb.java RrdException.java Log Message: More methods (getters) exposed. Necessary for jrobin.inspector package (but could be useful for other developers too) Index: ArcState.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/ArcState.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ArcState.java 24 Sep 2003 11:32:24 -0000 1.2 --- ArcState.java 6 Oct 2003 08:50:59 -0000 1.3 *************** *** 25,32 **** import java.io.IOException; ! /** ! * ! */ ! class ArcState implements RrdUpdater { private Archive parentArc; --- 25,30 ---- import java.io.IOException; ! // TODO: Fix javadoc, class made public ! public class ArcState implements RrdUpdater { private Archive parentArc; *************** *** 64,68 **** } ! long getNanSteps() throws IOException { return nanSteps.get(); } --- 62,66 ---- } ! public long getNanSteps() throws IOException { return nanSteps.get(); } *************** *** 72,76 **** } ! double getAccumValue() throws IOException { return accumValue.get(); } --- 70,74 ---- } ! public double getAccumValue() throws IOException { return accumValue.get(); } Index: Archive.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Archive.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Archive.java 29 Sep 2003 13:27:52 -0000 1.3 --- Archive.java 6 Oct 2003 08:50:59 -0000 1.4 *************** *** 25,33 **** import java.io.IOException; ! /** ! * ! */ ! class Archive implements RrdUpdater { ! RrdDb parentDb; // definition private RrdString consolFun; --- 25,31 ---- import java.io.IOException; ! // TODO: FIX JAVADOC, CLASS MADE PUBLIC ! public class Archive implements RrdUpdater { ! private RrdDb parentDb; // definition private RrdString consolFun; *************** *** 92,96 **** } ! long getArcStep() throws IOException { long step = parentDb.getHeader().getStep(); return step * steps.get(); --- 90,94 ---- } ! public long getArcStep() throws IOException { long step = parentDb.getHeader().getStep(); return step * steps.get(); *************** *** 187,207 **** } ! String getConsolFun() throws IOException { return consolFun.get(); } ! double getXff() throws IOException { return xff.get(); } ! int getSteps() throws IOException { return steps.get(); } ! int getRows() throws IOException{ return rows.get(); } ! long getStartTime() throws IOException { long endTime = getEndTime(); long arcStep = getArcStep(); --- 185,205 ---- } ! public String getConsolFun() throws IOException { return consolFun.get(); } ! public double getXff() throws IOException { return xff.get(); } ! public int getSteps() throws IOException { return steps.get(); } ! public int getRows() throws IOException{ return rows.get(); } ! public long getStartTime() throws IOException { long endTime = getEndTime(); long arcStep = getArcStep(); *************** *** 210,217 **** } ! long getEndTime() throws IOException { long arcStep = getArcStep(); long lastUpdateTime = parentDb.getHeader().getLastUpdateTime(); return Util.normalize(lastUpdateTime, arcStep); } --- 208,223 ---- } ! public long getEndTime() throws IOException { long arcStep = getArcStep(); long lastUpdateTime = parentDb.getHeader().getLastUpdateTime(); return Util.normalize(lastUpdateTime, arcStep); + } + + public ArcState getArcState(int dsIndex) { + return states[dsIndex]; + } + + public Robin getRobin(int dsIndex) { + return robins[dsIndex]; } Index: Datasource.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Datasource.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Datasource.java 29 Sep 2003 13:27:53 -0000 1.3 --- Datasource.java 6 Oct 2003 08:50:59 -0000 1.4 *************** *** 28,32 **** * */ ! class Datasource implements RrdUpdater { private RrdDb parentDb; // definition --- 28,32 ---- * */ ! public class Datasource implements RrdUpdater { private RrdDb parentDb; // definition *************** *** 89,110 **** } ! String getDsName() throws IOException { return dsName.get(); } ! String getDsType() throws IOException { return dsType.get(); } ! long getHeartbeat() throws IOException { return heartbeat.get(); } ! double getMinValue() throws IOException { return minValue.get(); } ! double getMaxValue() throws IOException { return maxValue.get(); } --- 89,122 ---- } ! public String getDsName() throws IOException { return dsName.get(); } ! public String getDsType() throws IOException { return dsType.get(); } ! public long getHeartbeat() throws IOException { return heartbeat.get(); } ! public double getMinValue() throws IOException { return minValue.get(); } ! public double getMaxValue() throws IOException { return maxValue.get(); + } + + public double getLastValue() throws IOException { + return lastValue.get(); + } + + public double getAccumValue() throws IOException { + return accumValue.get(); + } + + public long getNanSeconds() throws IOException { + return nanSeconds.get(); } Index: Header.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Header.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Header.java 24 Sep 2003 11:32:24 -0000 1.2 --- Header.java 6 Oct 2003 08:50:59 -0000 1.3 *************** *** 25,32 **** import java.io.IOException; /** * */ ! class Header implements RrdUpdater { static final String SIGNATURE = "JRobin, version 0.1"; static final String RRDTOOL_VERSION = "0001"; --- 25,34 ---- import java.io.IOException; + // TODO: Fix javadoc, class made public! + /** * */ ! public class Header implements RrdUpdater { static final String SIGNATURE = "JRobin, version 0.1"; static final String RRDTOOL_VERSION = "0001"; *************** *** 39,45 **** private RrdLong lastUpdateTime; ! Header(RrdDb parentDb) throws IOException { this.parentDb = parentDb; signature = new RrdString(this); step = new RrdLong(this); dsCount = new RrdInt(this); --- 41,50 ---- private RrdLong lastUpdateTime; ! Header(RrdDb parentDb) throws IOException, RrdException { this.parentDb = parentDb; signature = new RrdString(this); + if(!signature.get().equals(SIGNATURE)) { + throw new RrdException("Not a JRobin RRD file"); + } step = new RrdLong(this); dsCount = new RrdInt(this); *************** *** 70,90 **** } ! String getSignature() throws IOException { return signature.get(); } ! long getLastUpdateTime() throws IOException { return lastUpdateTime.get(); } ! long getStep() throws IOException { return step.get(); } ! int getDsCount() throws IOException { return dsCount.get(); } ! int getArcCount() throws IOException { return arcCount.get(); } --- 75,95 ---- } ! public String getSignature() throws IOException { return signature.get(); } ! public long getLastUpdateTime() throws IOException { return lastUpdateTime.get(); } ! public long getStep() throws IOException { return step.get(); } ! public int getDsCount() throws IOException { return dsCount.get(); } ! public int getArcCount() throws IOException { return arcCount.get(); } Index: Robin.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Robin.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Robin.java 4 Sep 2003 13:26:41 -0000 1.1 --- Robin.java 6 Oct 2003 08:50:59 -0000 1.2 *************** *** 25,32 **** import java.io.IOException; ! /** ! * ! */ ! class Robin implements RrdUpdater { private Archive parentArc; --- 25,30 ---- import java.io.IOException; ! // TODO: Fix javadoc, class made public ! public class Robin implements RrdUpdater { private Archive parentArc; *************** *** 50,54 **** } ! double[] getValues() throws IOException { double[] result = new double[rows]; int start = pointer.get(); --- 48,52 ---- } ! public double[] getValues() throws IOException { double[] result = new double[rows]; int start = pointer.get(); Index: RrdDb.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/RrdDb.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RrdDb.java 29 Sep 2003 11:25:05 -0000 1.5 --- RrdDb.java 6 Oct 2003 08:50:59 -0000 1.6 *************** *** 135,154 **** public RrdDb(String path) throws IOException, RrdException { ! initializeSetup(path); ! // restore header ! header = new Header(this); ! // restore datasources ! int dsCount = header.getDsCount(); ! datasources = new Datasource[dsCount]; ! for(int i = 0; i < dsCount; i++) { ! datasources[i] = new Datasource(this); } ! // restore archives ! int arcCount = header.getArcCount(); ! archives = new Archive[arcCount]; ! for(int i = 0; i < arcCount; i++) { ! archives[i] = new Archive(this); } - finalizeSetup(false); } --- 135,159 ---- public RrdDb(String path) throws IOException, RrdException { ! try { ! initializeSetup(path); ! // restore header ! header = new Header(this); ! // restore datasources ! int dsCount = header.getDsCount(); ! datasources = new Datasource[dsCount]; ! for(int i = 0; i < dsCount; i++) { ! datasources[i] = new Datasource(this); ! } ! // restore archives ! int arcCount = header.getArcCount(); ! archives = new Archive[arcCount]; ! for(int i = 0; i < arcCount; i++) { ! archives[i] = new Archive(this); ! } ! finalizeSetup(false); } ! catch(RuntimeException e) { ! throw new RrdException(e); } } *************** *** 238,243 **** } ! Header getHeader() { return header; } --- 243,257 ---- } ! // TODO: ADD JAVADOC for methods made public! ! public Header getHeader() { return header; + } + + public Datasource getDatasource(int dsIndex) { + return datasources[dsIndex]; + } + + public Archive getArchive(int arcIndex) { + return archives[arcIndex]; } Index: RrdException.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/RrdException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RrdException.java 4 Sep 2003 13:26:41 -0000 1.1 --- RrdException.java 6 Oct 2003 08:50:59 -0000 1.2 *************** *** 41,43 **** --- 41,47 ---- } + public RrdException(Exception e) { + super(e); + } + } |
From: <cob...@us...> - 2003-10-03 10:10:00
|
Update of /cvsroot/jrobin/src/jrobin/graph In directory sc8-pr-cvs1:/tmp/cvs-serv5725/src/jrobin/graph Modified Files: RrdGraphDef.java Grapher.java ValueAxisUnit.java Log Message: GRAPH LIB UPDATES Add graph coloring options setChartLeftPadding() fixed bug with getNiceHigher() Index: RrdGraphDef.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/RrdGraphDef.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RrdGraphDef.java 30 Sep 2003 21:45:21 -0000 1.4 --- RrdGraphDef.java 3 Oct 2003 10:09:52 -0000 1.5 *************** *** 153,163 **** private BasicStroke borderStroke; ! private Color borderColor; ! private Range valueRange; private boolean logarithmic = false; private double valueStep = 0; ! private Color backColor; /** --- 153,172 ---- private BasicStroke borderStroke; ! private Range valueRange; private boolean logarithmic = false; private double valueStep = 0; ! private Color borderColor; // null value is special here ! private Color backColor = new Color( 245, 245, 245 ); ! private Color canvasColor = Color.WHITE; ! private Color fontColor = Color.BLACK; ! private Color majorGridColor = new Color(130,30,30); ! private Color minorGridColor = new Color(140,140,140); ! private Color axisColor = new Color(130,30,30); ! private Color arrowColor = Color.RED; ! private Color frameColor = Color.LIGHT_GRAY; ! ! private int chart_lpadding = Grapher.CHART_LPADDING; /** *************** *** 550,562 **** } /** ! * Sets graph background color. If not set, back color defaults to light gray. * @param backColor Graph background color. */ ! public void setBackColor(Color backColor) { this.backColor = backColor; } /** * Determines if the minor grid for the X axis needs to be drawn. * @param visible True if minor grid needs to be drawn, false if not. --- 559,583 ---- } + Color getCanvasColor() { + return canvasColor; + } + /** ! * Sets image background color. If not set, back color defaults to a very light gray. * @param backColor Graph background color. */ ! public void setBackColor( Color backColor ) { this.backColor = backColor; } /** + * Sets graph area background color. If not set, back color defaults to white. + * @param backColor Graph area background color. + */ + public void setCanvasColor( Color canvasColor ) { + this.canvasColor = canvasColor; + } + + /** * Determines if the minor grid for the X axis needs to be drawn. * @param visible True if minor grid needs to be drawn, false if not. *************** *** 688,691 **** --- 709,796 ---- public boolean getShowLegend() { return this.showLegend; + } + + /** + * Sets the color of the font on the graph. + * @param c The color to be used. + */ + public void setFontColor( Color c ) { + this.fontColor = c; + } + + public Color getFontColor() { + return this.fontColor; + } + + /** + * Determines the color of the major grid. + * @param c Color to use + */ + public void setMajorGridColor( Color c ) { + this.majorGridColor = c; + } + + public Color getMajorGridColor() { + return majorGridColor; + } + + /** + * Determines the color of the minor grid. + * @param c Color to use + */ + public void setMinorGridColor( Color c ) { + this.minorGridColor = c; + } + + public Color getMinorGridColor() { + return minorGridColor; + } + + /** + * Determines the color of canvas frame. + * @param c Color to use + */ + public void setFrameColor( Color c ) { + this.frameColor = c; + } + + public Color getFrameColor() { + return frameColor; + } + + /** + * Determines the color of X axis. + * @param c Color to use + */ + public void setAxisColor( Color c ) { + this.axisColor = c; + } + + public Color getAxisColor() { + return axisColor; + } + + /** + * Determines the color of the small axis arrow. + * @param c Color to use + */ + public void setArrowColor( Color c ) { + this.arrowColor = c; + } + + public Color getArrowColor() { + return arrowColor; + } + + /** + * Set the number of pixels on the left of the canvas area ( value marker space ) + * @param lp Number of pixels used, defaults to 50 + */ + public void setChartLeftPadding( int lp ) { + this.chart_lpadding = lp; + } + + public int getChartLeftPadding() { + return this.chart_lpadding; } Index: Grapher.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/Grapher.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Grapher.java 30 Sep 2003 21:45:21 -0000 1.4 --- Grapher.java 3 Oct 2003 10:09:52 -0000 1.5 *************** *** 25,36 **** import jrobin.core.RrdException; - import java.awt.geom.*; import java.awt.*; - import java.awt.font.*; import java.awt.image.*; import java.io.IOException; import java.text.SimpleDateFormat; - import java.util.ArrayList; class Grapher --- 25,33 ---- *************** *** 47,56 **** private static final int RBORDER_SPACE = 10; ! private static final int CHART_UPADDING = 5; ! private static int CHART_BPADDING = 25; ! private static final int CHART_RPADDING = 10; ! private static int CHART_LPADDING = 50; ! private static final int CHART_BPADDING_NM = 10; // No legend makers on the axis ! private static final int CHART_LPADDING_NM = 10; private static final int LINE_PADDING = 4; --- 44,53 ---- private static final int RBORDER_SPACE = 10; ! public static final int CHART_UPADDING = 5; ! public static int CHART_BPADDING = 25; ! public static final int CHART_RPADDING = 10; ! public static int CHART_LPADDING = 50; // Default lpadding ! public static final int CHART_BPADDING_NM = 10; // No legend makers on the axis ! public static final int CHART_LPADDING_NM = 10; private static final int LINE_PADDING = 4; *************** *** 66,69 **** --- 63,69 ---- private boolean vLabelCentered = false; private long vLabelGridWidth = 0; + + private Color fontColor, gridColor, mGridColor, axisColor, frameColor, arrowColor; + private int chart_lpadding; private int imgWidth, imgHeight; // Dimensions of the entire image *************** *** 82,85 **** --- 82,92 ---- { this.graphDef = graphDef; + this.fontColor = graphDef.getFontColor(); + this.gridColor = graphDef.getMinorGridColor(); + this.mGridColor = graphDef.getMajorGridColor(); + this.arrowColor = graphDef.getArrowColor(); + this.axisColor = graphDef.getAxisColor(); + this.frameColor = graphDef.getFrameColor(); + StringBuffer buff = new StringBuffer(GRAPH_RESPECT); //graphDef.comment( buff.reverse().toString() ); *************** *** 108,112 **** // Padding depends on grid visibility ! CHART_LPADDING = ( graphDef.getMajorGridY() ? Grapher.CHART_LPADDING : CHART_LPADDING_NM ); CHART_BPADDING = ( graphDef.getMajorGridX() ? Grapher.CHART_BPADDING : CHART_BPADDING_NM ); --- 115,119 ---- // Padding depends on grid visibility ! chart_lpadding = ( graphDef.getMajorGridY() ? graphDef.getChartLeftPadding() : CHART_LPADDING_NM ); CHART_BPADDING = ( graphDef.getMajorGridX() ? Grapher.CHART_BPADDING : CHART_BPADDING_NM ); *************** *** 121,125 **** x_offset = LBORDER_SPACE; if ( graphDef.getValueAxisLabel() != null ) x_offset += font_height + LINE_PADDING; ! imgWidth = chartWidth + x_offset + RBORDER_SPACE + CHART_LPADDING + CHART_RPADDING; y_offset = UBORDER_SPACE; --- 128,132 ---- x_offset = LBORDER_SPACE; if ( graphDef.getValueAxisLabel() != null ) x_offset += font_height + LINE_PADDING; ! imgWidth = chartWidth + x_offset + RBORDER_SPACE + chart_lpadding + CHART_RPADDING; y_offset = UBORDER_SPACE; *************** *** 164,168 **** g.setFont( SUBTITLE_FONT ); ! int lux = x_offset + CHART_LPADDING; int luy = y_offset + CHART_UPADDING; --- 171,175 ---- g.setFont( SUBTITLE_FONT ); ! int lux = x_offset + chart_lpadding; int luy = y_offset + CHART_UPADDING; *************** *** 185,191 **** int tmpy = luy + chartHeight; ! g.setColor( new Color(130,30,30) ); g.drawLine( lux - 4, tmpy, tmpx + 4, tmpy ); ! g.setColor( Color.RED ); g.drawLine( tmpx + 4, tmpy - 3, tmpx + 4, tmpy + 3); g.drawLine( tmpx + 4, tmpy - 3, tmpx + 9, tmpy); --- 192,199 ---- int tmpy = luy + chartHeight; ! // Draw axis and arrow ! g.setColor( axisColor ); g.drawLine( lux - 4, tmpy, tmpx + 4, tmpy ); ! g.setColor( arrowColor ); g.drawLine( tmpx + 4, tmpy - 3, tmpx + 4, tmpy + 3); g.drawLine( tmpx + 4, tmpy - 3, tmpx + 9, tmpy); *************** *** 207,211 **** if ( majorX && timeList[i].isLabel() ) { ! g.setColor( new Color(130,30,30) ); g.setStroke( dStroke ); g.drawLine( pos, luy, pos, luy + chartHeight); --- 215,219 ---- if ( majorX && timeList[i].isLabel() ) { ! g.setColor( mGridColor ); g.setStroke( dStroke ); g.drawLine( pos, luy, pos, luy + chartHeight); *************** *** 219,236 **** if ( vLabelCentered ) { ! if ( pos + pixWidth <= lux + chartWidth ) { ! g.setColor( Color.BLACK ); ! g.drawString( timeList[i].text, pos + 2 + pixWidth/2 - txtDistance, luy + chartHeight + font_height + LINE_PADDING ); ! } } else if ( (pos - lux > txtDistance + 2) && (pos + txtDistance + 2 < lux + chartWidth) ) ! { ! g.setColor( Color.BLACK ); ! g.drawString( timeList[i].text, pos - txtDistance, luy + chartHeight + font_height + LINE_PADDING ); ! } } else if ( minorX ) { ! g.setColor( new Color(140,140,140) ); g.setStroke( dStroke ); g.drawLine( pos, luy, pos, luy + chartHeight); --- 227,239 ---- if ( vLabelCentered ) { ! if ( pos + pixWidth <= lux + chartWidth ) ! drawString( g, timeList[i].text, pos + 2 + pixWidth/2 - txtDistance, luy + chartHeight + font_height + LINE_PADDING ); } else if ( (pos - lux > txtDistance + 2) && (pos + txtDistance + 2 < lux + chartWidth) ) ! drawString( g, timeList[i].text, pos - txtDistance, luy + chartHeight + font_height + LINE_PADDING ); } else if ( minorX ) { ! g.setColor( gridColor ); g.setStroke( dStroke ); g.drawLine( pos, luy, pos, luy + chartHeight); *************** *** 252,256 **** if ( majorY && valueList[i].isLabel() ) { ! g.setColor( new Color(130,30,30) ); g.setStroke( dStroke ); g.drawLine( graphOriginX, graphOriginY - valRel, graphOriginX + chartWidth, graphOriginY - valRel ); --- 255,259 ---- if ( majorY && valueList[i].isLabel() ) { ! g.setColor( mGridColor ); g.setStroke( dStroke ); g.drawLine( graphOriginX, graphOriginY - valRel, graphOriginX + chartWidth, graphOriginY - valRel ); *************** *** 258,267 **** g.drawLine( graphOriginX - 2, graphOriginY - valRel, graphOriginX + 2, graphOriginY - valRel); g.drawLine( graphOriginX + chartWidth - 2, graphOriginY - valRel, graphOriginX + chartWidth + 2, graphOriginY - valRel ); ! g.setColor( Color.BLACK ); ! g.drawString( valueList[i].text, graphOriginX - (valueList[i].text.length() * font_width) - 7, graphOriginY - valRel + font_height/2 - 1 ); } else if ( minorY ) { ! g.setColor( new Color(140,140,140) ); g.setStroke( dStroke ); g.drawLine( graphOriginX, graphOriginY - valRel, graphOriginX + chartWidth, graphOriginY - valRel ); --- 261,269 ---- g.drawLine( graphOriginX - 2, graphOriginY - valRel, graphOriginX + 2, graphOriginY - valRel); g.drawLine( graphOriginX + chartWidth - 2, graphOriginY - valRel, graphOriginX + chartWidth + 2, graphOriginY - valRel ); ! drawString( g, valueList[i].text, graphOriginX - (valueList[i].text.length() * font_width) - 7, graphOriginY - valRel + font_height/2 - 1 ); } else if ( minorY ) { ! g.setColor( gridColor ); g.setStroke( dStroke ); g.drawLine( graphOriginX, graphOriginY - valRel, graphOriginX + chartWidth, graphOriginY - valRel ); *************** *** 299,305 **** g.setColor( ((Legend) cl[i]).getColor() ); g.fillRect( posx, posy - 9, 10, 10 ); ! g.setColor( Color.BLACK ); g.drawRect( posx, posy - 9, 10, 10 ); - g.setColor( Color.BLACK ); posx += 10 + (3*font_width - 10); } --- 301,306 ---- g.setColor( ((Legend) cl[i]).getColor() ); g.fillRect( posx, posy - 9, 10, 10 ); ! g.setColor( fontColor ); g.drawRect( posx, posy - 9, 10, 10 ); posx += 10 + (3*font_width - 10); } *************** *** 311,315 **** comment = comment.substring(lf + 1); ! g.drawString(str, posx, posy); posy += font_height + LINE_PADDING; --- 312,316 ---- comment = comment.substring(lf + 1); ! drawString(g, str, posx, posy); posy += font_height + LINE_PADDING; *************** *** 324,328 **** case Comment.ALIGN_CENTER: posx = imgWidth / 2 - (comment.length()*font_width)/2; ! g.drawString(comment, posx, posy); posy += font_height + LINE_PADDING; posx = LBORDER_SPACE; --- 325,329 ---- case Comment.ALIGN_CENTER: posx = imgWidth / 2 - (comment.length()*font_width)/2; ! drawString(g, comment, posx, posy); posy += font_height + LINE_PADDING; posx = LBORDER_SPACE; *************** *** 331,335 **** case Comment.ALIGN_LEFT: posx = LBORDER_SPACE; ! g.drawString(comment, posx, posy); posy += font_height + LINE_PADDING; posx = LBORDER_SPACE; --- 332,336 ---- case Comment.ALIGN_LEFT: posx = LBORDER_SPACE; ! drawString(g, comment, posx, posy); posy += font_height + LINE_PADDING; posx = LBORDER_SPACE; *************** *** 338,342 **** case Comment.ALIGN_RIGHT: posx = imgWidth - comment.length()*font_width - RBORDER_SPACE; ! g.drawString(comment, posx, posy); posy += font_height + LINE_PADDING; posx = LBORDER_SPACE; --- 339,343 ---- case Comment.ALIGN_RIGHT: posx = imgWidth - comment.length()*font_width - RBORDER_SPACE; ! drawString(g, comment, posx, posy); posy += font_height + LINE_PADDING; posx = LBORDER_SPACE; *************** *** 345,349 **** default: comment = comment + SPACER; ! g.drawString(comment, posx, posy); posx += font_width * comment.length(); } --- 346,350 ---- default: comment = comment + SPACER; ! drawString(g, comment, posx, posy); posx += font_width * comment.length(); } *************** *** 359,367 **** private void plotChart( Graphics2D graphics ) { ! int lux = x_offset + CHART_LPADDING; int luy = y_offset + CHART_UPADDING; ! graphics.setColor(Color.LIGHT_GRAY); ! graphics.drawRect( lux, luy, chartWidth, chartHeight); double val; --- 360,370 ---- private void plotChart( Graphics2D graphics ) { ! int lux = x_offset + chart_lpadding; int luy = y_offset + CHART_UPADDING; ! graphics.setColor( graphDef.getCanvasColor() ); ! graphics.fillRect( lux, luy, chartWidth, chartHeight ); ! graphics.setColor( frameColor ); ! graphics.drawRect( lux, luy, chartWidth, chartHeight ); double val; *************** *** 540,543 **** --- 543,554 ---- } + private void drawString( Graphics2D g, String str, int x, int y ) + { + Color oc = g.getColor(); + g.setColor( fontColor ); + g.drawString( str, x, y ); + g.setColor( oc ); + } + /** * Plots the labels for the vertical axis. *************** *** 554,558 **** g.setFont( SUBTITLE_FONT ); g.rotate( -Math.PI/2.0 ); ! g.drawString( valueAxisLabel, - y_offset - CHART_UPADDING - chartHeight / 2 - labelWidth / 2, --- 565,569 ---- g.setFont( SUBTITLE_FONT ); g.rotate( -Math.PI/2.0 ); ! drawString( g, valueAxisLabel, - y_offset - CHART_UPADDING - chartHeight / 2 - labelWidth / 2, *************** *** 579,583 **** g.setColor( Color.BLACK ); g.setFont( TITLE_FONT ); ! g.drawString( title, imgWidth / 2 - titleWidth / 2, tf_height + UBORDER_SPACE ); } } --- 590,594 ---- g.setColor( Color.BLACK ); g.setFont( TITLE_FONT ); ! drawString( g, title, imgWidth / 2 - titleWidth / 2, tf_height + UBORDER_SPACE ); } } *************** *** 886,890 **** if ( !upperFromRange ) upperValue = v.getNiceHigher( upperValue ); if ( !lowerFromRange ) lowerValue = v.getNiceLower( lowerValue ); ! return v.getValueMarkers( lowerValue, upperValue ); } --- 897,901 ---- if ( !upperFromRange ) upperValue = v.getNiceHigher( upperValue ); if ( !lowerFromRange ) lowerValue = v.getNiceLower( lowerValue ); ! return v.getValueMarkers( lowerValue, upperValue ); } Index: ValueAxisUnit.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/ValueAxisUnit.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ValueAxisUnit.java 30 Sep 2003 21:45:21 -0000 1.3 --- ValueAxisUnit.java 3 Oct 2003 10:09:52 -0000 1.4 *************** *** 170,173 **** --- 170,174 ---- int valueInt = new Double(value).intValue(); int roundStep = new Double(gridUnit * gridParts).intValue(); + if ( roundStep == 0 ) roundStep = 1; int num = valueInt / roundStep; int mod = valueInt % roundStep; *************** *** 183,186 **** --- 184,188 ---- value = ovalue * mGridFactor; roundStep = new Double(mGridUnit * mGridParts).intValue(); + if ( roundStep == 0 ) roundStep = 1; num = valueInt / roundStep; mod = valueInt % roundStep; *************** *** 221,224 **** --- 223,227 ---- int valueInt = new Double(value).intValue(); int roundStep = new Double(gridUnit * gridParts).intValue(); + if ( roundStep == 0 ) roundStep = 1; int num = valueInt / roundStep; int mod = valueInt % roundStep; *************** *** 229,232 **** --- 232,236 ---- value = ovalue * mGridFactor; roundStep = new Double(mGridUnit * mGridParts).intValue(); + if ( roundStep == 0 ) roundStep = 1; num = valueInt / roundStep; mod = valueInt % roundStep; |
From: <cob...@us...> - 2003-10-03 10:09:59
|
Update of /cvsroot/jrobin/src/jrobin/demo In directory sc8-pr-cvs1:/tmp/cvs-serv5725/src/jrobin/demo Modified Files: JRobinComplexGraph.java Log Message: GRAPH LIB UPDATES Add graph coloring options setChartLeftPadding() fixed bug with getNiceHigher() Index: JRobinComplexGraph.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/demo/JRobinComplexGraph.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JRobinComplexGraph.java 30 Sep 2003 21:45:22 -0000 1.3 --- JRobinComplexGraph.java 3 Oct 2003 10:09:52 -0000 1.4 *************** *** 75,79 **** gDef.area("p75t90", new Color(0xff,0x66,0x00), "75 - 90%"); gDef.area("p90t100", new Color(0xcc,0x33,0x00), "90 - 100%"); ! gDef.rule(10.0, Color.ORANGE, null); gDef.gprint("busy", "AVERAGE", " Average:@5.1@s%"); gDef.gprint("busy", "LAST", "Current: @5.1@s%"); --- 75,79 ---- gDef.area("p75t90", new Color(0xff,0x66,0x00), "75 - 90%"); gDef.area("p90t100", new Color(0xcc,0x33,0x00), "90 - 100%"); ! //gDef.rule(10.0, Color.ORANGE, null); gDef.gprint("busy", "AVERAGE", " Average:@5.1@s%"); gDef.gprint("busy", "LAST", "Current: @5.1@s%"); *************** *** 97,107 **** gDef.comment("-------------------------------------------------------------------------------@c"); gDef.comment("Generated: " + new Date() + "@r"); ! //gDef.setBackColor( Color.ORANGE ); gDef.setValueAxisLabel("server load"); //gDef.setGridX( false ); //gDef.setGridY( false ); ! gDef.setImageBorder( Color.DARK_GRAY, 1 ); gDef.setFrontGrid(false); gDef.setShowLegend(true); // Create actual graph RrdGraph graph = new RrdGraph(gDef); --- 97,115 ---- gDef.comment("-------------------------------------------------------------------------------@c"); gDef.comment("Generated: " + new Date() + "@r"); ! gDef.setBackColor( Color.DARK_GRAY ); ! gDef.setCanvasColor( Color.LIGHT_GRAY ); gDef.setValueAxisLabel("server load"); + gDef.setFontColor( Color.WHITE ); //gDef.setGridX( false ); //gDef.setGridY( false ); ! gDef.setImageBorder( Color.BLACK, 1 ); gDef.setFrontGrid(false); gDef.setShowLegend(true); + gDef.setMajorGridColor(Color.BLACK); + gDef.setMinorGridColor( new Color( 130, 30, 30) ); + gDef.setFrameColor( Color.YELLOW ); + gDef.setAxisColor( Color.RED ); + gDef.setArrowColor( Color.GREEN ); + gDef.setChartLeftPadding( 40 ); // Create actual graph RrdGraph graph = new RrdGraph(gDef); *************** *** 111,115 **** // -- New graph RrdGraphDef gd = new RrdGraphDef(); ! gd.setBackColor( Color.WHITE ); gd.setTimePeriod( start, end ); gd.datasource("in2", "c:/test.rrd", "ifInOctets", "AVERAGE"); --- 119,123 ---- // -- New graph RrdGraphDef gd = new RrdGraphDef(); ! //gd.setBackColor( Color.WHITE ); gd.setTimePeriod( start, end ); gd.datasource("in2", "c:/test.rrd", "ifInOctets", "AVERAGE"); *************** *** 125,129 **** ////////////////////////////// gd = new RrdGraphDef(); ! gd.setBackColor( Color.WHITE ); gd.setTimePeriod( start, end ); gd.datasource("in2", "c:/test.rrd", "ifInUcastPkts", "AVERAGE"); --- 133,137 ---- ////////////////////////////// gd = new RrdGraphDef(); ! //gd.setBackColor( Color.WHITE ); gd.setTimePeriod( start, end ); gd.datasource("in2", "c:/test.rrd", "ifInUcastPkts", "AVERAGE"); |
From: <sa...@us...> - 2003-10-03 08:08:03
|
Update of /cvsroot/jrobin/src/jrobin/mrtg/server In directory sc8-pr-cvs1:/tmp/cvs-serv14283/jrobin/mrtg/server Modified Files: Grapher.java Log Message: Colors reversed... Index: Grapher.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/mrtg/server/Grapher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Grapher.java 30 Sep 2003 21:45:21 -0000 1.2 --- Grapher.java 3 Oct 2003 08:07:51 -0000 1.3 *************** *** 65,70 **** gDef.datasource("in8", "in,8,*"); gDef.datasource("out8", "out,8,*"); ! gDef.area("in8", Color.GREEN, "input traffic"); ! gDef.line("out8", Color.BLUE, "output traffic\n"); gDef.comment("\n"); gDef.gprint("in8", "AVERAGE", "Average input: @7.2 @sbits/s"); --- 65,70 ---- gDef.datasource("in8", "in,8,*"); gDef.datasource("out8", "out,8,*"); ! gDef.area("out8", Color.GREEN, "output traffic\n"); ! gDef.line("in8", Color.BLUE, "input traffic"); gDef.comment("\n"); gDef.gprint("in8", "AVERAGE", "Average input: @7.2 @sbits/s"); |
From: <sa...@us...> - 2003-10-02 09:30:43
|
Update of /cvsroot/jrobin/src/jrobin/mrtg/client In directory sc8-pr-cvs1:/tmp/cvs-serv30096/jrobin/mrtg/client Modified Files: GraphFrame.java Log Message: Minor improvements to MRTG demo app (popup menus, etc...) Index: GraphFrame.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/mrtg/client/GraphFrame.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GraphFrame.java 4 Sep 2003 13:28:18 -0000 1.1 --- GraphFrame.java 2 Oct 2003 09:30:40 -0000 1.2 *************** *** 23,26 **** --- 23,28 ---- package jrobin.mrtg.client; + import jrobin.mrtg.MrtgException; + import javax.swing.*; import javax.swing.border.BevelBorder; *************** *** 117,120 **** --- 119,123 ---- graphLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); content.add(graphLabel, BorderLayout.CENTER); + // botom panel JPanel bottomPanel = new JPanel(); *************** *** 155,158 **** --- 158,213 ---- mainContent.add(box, BorderLayout.EAST); + // popup menu + final JPopupMenu popup = new JPopupMenu(); + JMenuItem leftMenuItem = new JMenuItem("<< Left"); + leftMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + shift(false); + } + }); + JMenuItem rightMenuItem = new JMenuItem("Right >>"); + rightMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + shift(true); + } + }); + JMenuItem refreshMenuItem = new JMenuItem("Refresh graph"); + refreshMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + refreshButton.doClick(); + } + }); + JMenuItem saveMenuItem = new JMenuItem("Save graph..."); + saveMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + save(); + } + }); + JMenuItem closeMenuItem = new JMenuItem("Close window"); + closeMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + close(); + } + }); + if(type != TYPE_CUSTOM) { + popup.add(leftMenuItem); + popup.add(rightMenuItem); + } + popup.add(refreshMenuItem); + popup.addSeparator(); + popup.add(saveMenuItem); + popup.addSeparator(); + popup.add(closeMenuItem); + MouseAdapter adapter = new MouseAdapter() { + public void mousePressed(MouseEvent e) { showPopup(e); } + public void mouseReleased(MouseEvent e) { showPopup(e); } + private void showPopup(MouseEvent e) { + if (e.isPopupTrigger()) { + popup.show(e.getComponent(), e.getX(), e.getY()); + } + } + }; + graphLabel.addMouseListener(adapter); + // populate controls fillDays(startDay); fillDays(endDay); *************** *** 173,176 **** --- 228,236 ---- rightButton.setMnemonic(KeyEvent.VK_R); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + try { + setIconImage(Resources.getImage(Client.ICON)); + } catch (MrtgException e) { + e.printStackTrace(); + } Util.centerOnScreen(this); } |
From: <sa...@us...> - 2003-10-01 14:39:02
|
Update of /cvsroot/jrobin/src/jrobin/mrtg/client In directory sc8-pr-cvs1:/tmp/cvs-serv27632/jrobin/mrtg/client Modified Files: Client.java Log Message: Custom graph option added to interfaces's popup menu Index: Client.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/mrtg/client/Client.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Client.java 4 Sep 2003 13:28:18 -0000 1.1 --- Client.java 1 Oct 2003 14:38:56 -0000 1.2 *************** *** 282,285 **** --- 282,290 ---- linksPopupMenu.add(linksPopupYearlyGraphMenuItem); linksPopupMenu.addSeparator(); + linksPopupCustomGraphMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { graph(GraphFrame.TYPE_CUSTOM); } + }); + linksPopupMenu.add(linksPopupCustomGraphMenuItem); + linksPopupMenu.addSeparator(); linksPopupRemoveLinkMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { removeLink(); } |
Update of /cvsroot/jrobin/src/jrobin/graph In directory sc8-pr-cvs1:/tmp/cvs-serv8118/src/jrobin/graph Modified Files: TimeAxisUnit.java RrdGraph.java RrdGraphDef.java ChartGraphics.java Grapher.java ValueAxisUnit.java Range.java Log Message: GRAPH LIB UPDATES Fix zero comment line problem Option to disable the legend Option to bring grid to front or back Option to set rigid grid lines Option to set fixed upper and lower value Add change border option Possibility to disable grid lines (no minor grid) Fix background color option Better Time and Value axis markers Index: TimeAxisUnit.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/TimeAxisUnit.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TimeAxisUnit.java 25 Sep 2003 21:58:05 -0000 1.2 --- TimeAxisUnit.java 30 Sep 2003 21:45:21 -0000 1.3 *************** *** 43,46 **** --- 43,56 ---- 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 *************** *** 84,88 **** t.setTimeInMillis( exactStart ); for (int i = 0; i < calendarUnit.length && i <= unit; i++) ! t.set( calendarUnit[i], 0 ); } --- 94,100 ---- 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() ); } Index: RrdGraph.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/RrdGraph.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RrdGraph.java 22 Sep 2003 17:15:17 -0000 1.2 --- RrdGraph.java 30 Sep 2003 21:45:21 -0000 1.3 *************** *** 115,118 **** --- 115,127 ---- public byte[] getPNGBytes(int width, int height) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + try + { + BufferedImage gImage = grapher.createImage( width, height ); + + ImageIO.write( (RenderedImage) gImage, "png", outputStream ); + } + catch ( RrdException e ) { + e.printStackTrace(); + } //ChartUtilities.writeBufferedImageAsPNG(outputStream, getBufferedImage(width, height)); return outputStream.toByteArray(); Index: RrdGraphDef.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/RrdGraphDef.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RrdGraphDef.java 25 Sep 2003 21:58:05 -0000 1.3 --- RrdGraphDef.java 30 Sep 2003 21:45:21 -0000 1.4 *************** *** 134,142 **** private int timeUnit, timeUnitCount; private SimpleDateFormat timeFormat; ! private long endTime = Util.getTime(); ! private long startTime = endTime - 86400L; private String title = null; // Default to null, to check private String timeAxisLabel = ""; private String valueAxisLabel = null; private Range valueRange; private boolean logarithmic = false; --- 134,158 ---- private int timeUnit, timeUnitCount; private SimpleDateFormat timeFormat; ! private long endTime = Util.getTime(); ! private long startTime = endTime - 86400L; private String title = null; // Default to null, to check private String timeAxisLabel = ""; private String valueAxisLabel = null; + + // Visibility of grid settings + private boolean gridX = true; + private boolean gridY = true; + private boolean minorGridX = true; + private boolean minorGridY = true; + private boolean majorGridX = true; + private boolean majorGridY = true; + private boolean rigidGrid = false; + private boolean frontGrid = true; + + private boolean showLegend = true; + + private BasicStroke borderStroke; + private Color borderColor; + private Range valueRange; private boolean logarithmic = false; *************** *** 541,544 **** --- 557,692 ---- this.backColor = backColor; } + + /** + * Determines if the minor grid for the X axis needs to be drawn. + * @param visible True if minor grid needs to be drawn, false if not. + */ + public void setMinorGridX( boolean visible ) { + this.minorGridX = visible; + } + + /** + * Determines if the minor grid for the X axis needs to be drawn. + * @param visible True if minor grid needs to be drawn, false if not. + */ + public void setMinorGridY( boolean visible ) { + this.minorGridY = visible; + } + + public boolean getMinorGridX() { + return minorGridX; + } + + public boolean getMinorGridY() { + return minorGridY; + } + + /** + * Determines if the major grid with labels for the X axis needs to be drawn. + * @param visible True if major grid needs to be drawn, false if not. + */ + public void setMajorGridX( boolean visible ) { + this.majorGridX = visible; + } + + /** + * Determines if the major grid for the X axis needs to be drawn. + * @param visible True if major grid needs to be drawn, false if not. + */ + public void setMajorGridY( boolean visible ) { + this.majorGridY = visible; + } + + public boolean getMajorGridX() { + return majorGridX; + } + + public boolean getMajorGridY() { + return majorGridY; + } + + /** + * Determines if the X axis grid should be drawn. + * This will not change the left padding of the drawing area. + * @param visible True if grid needs to be drawn, false if not. + */ + public void setGridX( boolean visible ) { + this.gridX = visible; + } + + /** + * Determines if the Y axis grid should be drawn. + * This will not change the bottom padding of the drawing area. + * @param visible True if grid needs to be drawn, false if not. + */ + public void setGridY( boolean visible ) { + this.gridY = visible; + } + public boolean getGridX() { + return gridX; + } + + public boolean getGridY() { + return gridY; + } + + /** + * Specifies the settings of the image border + * @param c Bordercolor of the image + * @param w Pixel width of the image border + */ + public void setImageBorder( Color c, int w ) { + this.borderStroke = new BasicStroke( w ); + if ( c != null ) + this.borderColor = c; + } + + public Color getImageBorderColor() { + return borderColor; + } + + public BasicStroke getImageBorderStroke() { + return borderStroke; + } + + /** + * Determines if the grid should have rigid upper and lower limits. + * If so the upper and lower limit will not autoscale depending on the + * graph values. + * @param rigid True if the grid should have rigid limits + */ + public void setRigidGrid( boolean rigid ) { + this.rigidGrid = rigid; + } + + public boolean getRigidGrid() { + return this.rigidGrid; + } + + /** + * Determine if the graph grid is in front of the graphs itself, or behind it. + * Default is in front of the graph itself. + * @param frontGrid True if the grid is in front of the graphs + */ + public void setFrontGrid( boolean frontGrid ) { + this.frontGrid = frontGrid; + } + + public boolean getFrontGrid() { + return this.frontGrid; + } + + /** + * Determine if the legend should be visible or not, default: visible. + * @param showLegend True if the legend is visible + */ + public void setShowLegend( boolean showLegend ) { + this.showLegend = showLegend; + } + + public boolean getShowLegend() { + return this.showLegend; + } + } Index: ChartGraphics.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/ChartGraphics.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ChartGraphics.java 25 Sep 2003 21:58:05 -0000 1.2 --- ChartGraphics.java 30 Sep 2003 21:45:21 -0000 1.3 *************** *** 94,98 **** if ( Double.isNaN(value) ) return Integer.MIN_VALUE; ! int tmp = new Double(value * heightDelta).intValue(); return ( tmp > value * heightDelta ? tmp - 1 : tmp ); } --- 94,99 ---- if ( Double.isNaN(value) ) return Integer.MIN_VALUE; ! int tmp = new Double( (value - ( yStart < 0 ? 0 : Math.abs(yStart) ) ) * heightDelta).intValue(); ! return ( tmp > value * heightDelta ? tmp - 1 : tmp ); } Index: Grapher.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/Grapher.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Grapher.java 25 Sep 2003 21:58:05 -0000 1.3 --- Grapher.java 30 Sep 2003 21:45:21 -0000 1.4 *************** *** 48,54 **** private static final int CHART_UPADDING = 5; ! private static final int CHART_BPADDING = 25; private static final int CHART_RPADDING = 10; ! private static final int CHART_LPADDING = 50; private static final int LINE_PADDING = 4; --- 48,56 ---- private static final int CHART_UPADDING = 5; ! private static int CHART_BPADDING = 25; private static final int CHART_RPADDING = 10; ! private static int CHART_LPADDING = 50; ! private static final int CHART_BPADDING_NM = 10; // No legend makers on the axis ! private static final int CHART_LPADDING_NM = 10; private static final int LINE_PADDING = 4; *************** *** 71,75 **** private int graphOriginX, graphOriginY, x_offset, y_offset; ! private double lowerValue = 0.0d, upperValue = 0.0d; --- 73,77 ---- private int graphOriginX, graphOriginY, x_offset, y_offset; ! private double lowerValue = Double.MAX_VALUE, upperValue = Double.MIN_VALUE; *************** *** 105,108 **** --- 107,114 ---- if ( cWidth > GRAPH_RESOLUTION ) numPoints = cWidth; + // Padding depends on grid visibility + CHART_LPADDING = ( graphDef.getMajorGridY() ? Grapher.CHART_LPADDING : CHART_LPADDING_NM ); + CHART_BPADDING = ( graphDef.getMajorGridX() ? Grapher.CHART_BPADDING : CHART_BPADDING_NM ); + // Calculate the complete image dimensions for the creation of the bufferedimage font_height = SUBTITLE_FONT.getSize(); // Determine font dimensions for regular comment font *************** *** 111,115 **** tfont_width = tfont_height / 2 + 1; ! commentBlock = calculateCommentBlock(); // Size of all lines below chart x_offset = LBORDER_SPACE; --- 117,121 ---- tfont_width = tfont_height / 2 + 1; ! commentBlock = ( graphDef.getShowLegend() ? calculateCommentBlock() : 0 ); // Size of all lines below chart x_offset = LBORDER_SPACE; *************** *** 135,139 **** plotChart( graphics ); ! plotComments( graphics ); } catch (IOException e) --- 141,146 ---- plotChart( graphics ); ! if ( graphDef.getShowLegend() ) ! plotComments( graphics ); } catch (IOException e) *************** *** 147,150 **** --- 154,159 ---- } + System.out.println( "Graph created ok." ); + return bImg; } *************** *** 157,160 **** --- 166,176 ---- int lux = x_offset + CHART_LPADDING; int luy = y_offset + CHART_UPADDING; + + boolean gridX = graphDef.getGridX(); + boolean gridY = graphDef.getGridY(); + boolean minorX = graphDef.getMinorGridX(); + boolean minorY = graphDef.getMinorGridY(); + boolean majorX = graphDef.getMajorGridX(); + boolean majorY = graphDef.getMajorGridY(); long start = graphDef.getStartTime(); *************** *** 176,253 **** g.drawLine( tmpx + 4, tmpy + 3, tmpx + 9, tmpy); ! int pixWidth = 0; ! if (vLabelCentered) ! pixWidth = (chartGraph.getX( vLabelGridWidth ) - chartGraph.getX( 0 )); ! ! for (int i = 0; i < timeList.length; i++) { ! secTime = timeList[i].timestamp / 1000; ! int posRel = chartGraph.getX(secTime); ! int pos = lux + posRel; ! ! if ( posRel >= 0 ) { ! if ( timeList[i].isLabel() ) ! { ! g.setColor( new Color(130,30,30) ); ! g.setStroke( dStroke ); ! g.drawLine( pos, luy, pos, luy + chartHeight); ! g.setStroke( new BasicStroke() ); ! g.drawLine( pos, luy - 2, pos, luy + 2); ! g.drawLine( pos, luy + chartHeight - 2, pos, luy + chartHeight + 2); ! // Only draw label itself if we are far enough from the side axis ! // Use extra 2 pixel padding (3 pixels from border total at least) ! int txtDistance = (timeList[i].text.length() * font_width) / 2; ! ! if ( vLabelCentered ) { ! if ( pos + pixWidth <= lux + chartWidth ) { g.setColor( Color.BLACK ); ! g.drawString( timeList[i].text, pos + 2 + pixWidth/2 - txtDistance, luy + chartHeight + font_height + LINE_PADDING ); } } ! else if ( (pos - lux > txtDistance + 2) && (pos + txtDistance + 2 < lux + chartWidth) ) ! { ! g.setColor( Color.BLACK ); ! g.drawString( timeList[i].text, pos - txtDistance, luy + chartHeight + font_height + LINE_PADDING ); } } ! else ! { g.setColor( new Color(140,140,140) ); g.setStroke( dStroke ); ! g.drawLine( pos, luy, pos, luy + chartHeight); g.setStroke( new BasicStroke() ); ! g.drawLine( pos, luy - 1, pos, luy + 1); ! g.drawLine( pos, luy + chartHeight - 1, pos, luy + chartHeight + 1); ! } - } - } - for (int i = 0; i < valueList.length; i++) - { - int valRel = chartGraph.getY( valueList[i].value ); - - if ( valueList[i].isLabel() ) - { - g.setColor( new Color(130,30,30) ); - g.setStroke( dStroke ); - g.drawLine( graphOriginX, graphOriginY - valRel, graphOriginX + chartWidth, graphOriginY - valRel ); - g.setStroke( new BasicStroke() ); - g.drawLine( graphOriginX - 2, graphOriginY - valRel, graphOriginX + 2, graphOriginY - valRel); - g.drawLine( graphOriginX + chartWidth - 2, graphOriginY - valRel, graphOriginX + chartWidth + 2, graphOriginY - valRel ); - g.setColor( Color.BLACK ); - g.drawString( valueList[i].text, graphOriginX - (valueList[i].text.length() * font_width) - 7, graphOriginY - valRel + font_height/2 - 1 ); } - else - { - g.setColor( new Color(140,140,140) ); - g.setStroke( dStroke ); - g.drawLine( graphOriginX, graphOriginY - valRel, graphOriginX + chartWidth, graphOriginY - valRel ); - g.setStroke( new BasicStroke() ); - g.drawLine( graphOriginX - 1, graphOriginY - valRel, graphOriginX + 1, graphOriginY - valRel); - g.drawLine( graphOriginX + chartWidth - 1, graphOriginY - valRel, graphOriginX + chartWidth + 1, graphOriginY - valRel ); - } - } } --- 192,275 ---- g.drawLine( tmpx + 4, tmpy + 3, tmpx + 9, tmpy); ! if ( gridX ) { ! int pixWidth = 0; ! if (vLabelCentered) ! pixWidth = (chartGraph.getX( vLabelGridWidth ) - chartGraph.getX( 0 )); ! ! for (int i = 0; i < timeList.length; i++) ! { ! secTime = timeList[i].timestamp / 1000; ! int posRel = chartGraph.getX(secTime); ! int pos = lux + posRel; ! ! if ( posRel >= 0 ) { ! if ( majorX && timeList[i].isLabel() ) { ! g.setColor( new Color(130,30,30) ); ! g.setStroke( dStroke ); ! g.drawLine( pos, luy, pos, luy + chartHeight); ! g.setStroke( new BasicStroke() ); ! g.drawLine( pos, luy - 2, pos, luy + 2); ! g.drawLine( pos, luy + chartHeight - 2, pos, luy + chartHeight + 2); ! // Only draw label itself if we are far enough from the side axis ! // Use extra 2 pixel padding (3 pixels from border total at least) ! int txtDistance = (timeList[i].text.length() * font_width) / 2; ! ! if ( vLabelCentered ) ! { ! if ( pos + pixWidth <= lux + chartWidth ) { ! g.setColor( Color.BLACK ); ! g.drawString( timeList[i].text, pos + 2 + pixWidth/2 - txtDistance, luy + chartHeight + font_height + LINE_PADDING ); ! } ! } ! else if ( (pos - lux > txtDistance + 2) && (pos + txtDistance + 2 < lux + chartWidth) ) ! { g.setColor( Color.BLACK ); ! g.drawString( timeList[i].text, pos - txtDistance, luy + chartHeight + font_height + LINE_PADDING ); } } ! else if ( minorX ) ! { ! g.setColor( new Color(140,140,140) ); ! g.setStroke( dStroke ); ! g.drawLine( pos, luy, pos, luy + chartHeight); ! g.setStroke( new BasicStroke() ); ! g.drawLine( pos, luy - 1, pos, luy + 1); ! g.drawLine( pos, luy + chartHeight - 1, pos, luy + chartHeight + 1); ! } } ! } ! } ! ! if ( gridY ) ! { ! for (int i = 0; i < valueList.length; i++) ! { ! int valRel = chartGraph.getY( valueList[i].value ); ! ! if ( majorY && valueList[i].isLabel() ) ! { ! g.setColor( new Color(130,30,30) ); ! g.setStroke( dStroke ); ! g.drawLine( graphOriginX, graphOriginY - valRel, graphOriginX + chartWidth, graphOriginY - valRel ); ! g.setStroke( new BasicStroke() ); ! g.drawLine( graphOriginX - 2, graphOriginY - valRel, graphOriginX + 2, graphOriginY - valRel); ! g.drawLine( graphOriginX + chartWidth - 2, graphOriginY - valRel, graphOriginX + chartWidth + 2, graphOriginY - valRel ); ! g.setColor( Color.BLACK ); ! g.drawString( valueList[i].text, graphOriginX - (valueList[i].text.length() * font_width) - 7, graphOriginY - valRel + font_height/2 - 1 ); ! } ! else if ( minorY ) ! { g.setColor( new Color(140,140,140) ); g.setStroke( dStroke ); ! g.drawLine( graphOriginX, graphOriginY - valRel, graphOriginX + chartWidth, graphOriginY - valRel ); g.setStroke( new BasicStroke() ); ! g.drawLine( graphOriginX - 1, graphOriginY - valRel, graphOriginX + 1, graphOriginY - valRel); ! g.drawLine( graphOriginX + chartWidth - 1, graphOriginY - valRel, graphOriginX + chartWidth + 1, graphOriginY - valRel ); } } } } *************** *** 370,377 **** g.setMeasurements( chartWidth, chartHeight ); g.setXRange( graphDef.getStartTime(), graphDef.getEndTime() ); ! ValueMarker[] vlist = calculateValueMarkers(); TimeMarker[] tlist = calculateTimeMarkers(); ! // Upper and lower were set in value markers double diff = 1.0d; --- 392,399 ---- g.setMeasurements( chartWidth, chartHeight ); g.setXRange( graphDef.getStartTime(), graphDef.getEndTime() ); ! ValueMarker[] vlist = calculateValueMarkers(); TimeMarker[] tlist = calculateTimeMarkers(); ! // Upper and lower were set in value markers double diff = 1.0d; *************** *** 383,387 **** g.setYRange( lowerValue, upperValue ); ! //plotChartGrid( g, tlist, vlist ); graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); --- 405,409 ---- g.setYRange( lowerValue, upperValue ); ! if ( !graphDef.getFrontGrid() ) plotChartGrid( g, tlist, vlist ); graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); *************** *** 426,430 **** graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF ); ! plotChartGrid( g, tlist, vlist ); } --- 448,452 ---- graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF ); ! if ( graphDef.getFrontGrid() ) plotChartGrid( g, tlist, vlist ); } *************** *** 572,583 **** // Border ! g.setColor( new Color( 0xdc, 0xdc, 0xdc ) ); ! g.fillRect( 0, 0, 2, imgHeight - 1 ); ! g.fillRect( 0, 0, imgWidth - 1, 2 ); ! g.setColor( Color.GRAY ); ! g.drawLine( 0, imgHeight - 1, imgWidth, imgHeight - 1 ); ! g.drawLine( imgWidth - 1, 0, imgWidth - 1, imgHeight ); ! g.drawLine( 1, imgHeight - 2, imgWidth, imgHeight - 2 ); ! g.drawLine( imgWidth - 2, 1, imgWidth - 2, imgHeight ); plotImageTitle( g ); --- 594,619 ---- // Border ! Color bc = graphDef.getImageBorderColor(); ! BasicStroke bs = graphDef.getImageBorderStroke(); ! ! if ( bc != null && bs != null ) ! { ! g.setColor( bc ); ! g.setStroke( bs ); ! int w = new Float(bs.getLineWidth()).intValue(); ! if ( w > 0 ) g.drawRect( w / 2, w / 2, imgWidth - w, imgHeight - w); ! g.setStroke( new BasicStroke() ); ! } ! else ! { ! g.setColor( new Color( 0xdc, 0xdc, 0xdc ) ); ! g.fillRect( 0, 0, 2, imgHeight - 1 ); ! g.fillRect( 0, 0, imgWidth - 1, 2 ); ! g.setColor( Color.GRAY ); ! g.drawLine( 0, imgHeight - 1, imgWidth, imgHeight - 1 ); ! g.drawLine( imgWidth - 1, 0, imgWidth - 1, imgHeight ); ! g.drawLine( 1, imgHeight - 2, imgWidth, imgHeight - 2 ); ! g.drawLine( imgWidth - 2, 1, imgWidth - 2, imgHeight ); ! } plotImageTitle( g ); *************** *** 595,599 **** Comment[] list = graphDef.getComments(); ! int commentLines = 1; for (int i = 0; i < list.length; i++) --- 631,635 ---- Comment[] list = graphDef.getComments(); ! int commentLines = (list.length > 0 ? 1 : 0); for (int i = 0; i < list.length; i++) *************** *** 619,647 **** /* - JFreeChart createJFreeChart() throws RrdException, IOException { - PlotDef[] plotDefs = graphDef.getPlotDefs(); - OverlayGraph[] graphs = graphDef.getGraphs(); - if(plotDefs.length == 0) { - throw new RrdException("Nothing to plot"); - } - calculateSeries(); - OverlaidXYPlot plot = new OverlaidXYPlot(createTimeAxis(), createValueAxis()); - for(int i = 0; i < graphs.length; i++) { - plot.add(graphs[i].getXYPlot()); - } - JFreeChart chart = new JFreeChart("", plot); - chart.setTitle(new TextTitle(graphDef.getTitle(), TITLE_FONT)); - Color backColor = graphDef.getBackColor(); - if(backColor == null) { - backColor = BACK_COLOR; - } - chart.setBackgroundPaint(backColor); - StandardLegend legend = (StandardLegend) chart.getLegend(); - legend.setOutlinePaint(backColor); - legend.setBackgroundPaint(backColor); - addSubtitles(chart); - return chart; - } - private void calculateSeries() throws RrdException, IOException { Source[] sources = graphDef.getSources(); --- 655,658 ---- *************** *** 663,674 **** } - private ValueAxis createTimeAxis() { - HorizontalDateAxis axis = new HorizontalDateAxis(graphDef.getTimeAxisLabel()); - axis.setLowerMargin(0.0); - axis.setUpperMargin(0.0); - axis.setTickUnit(calculateDateTickUnit()); - return axis; - } - private DateTickUnit calculateDateTickUnit() { SimpleDateFormat simpleDateFormat = graphDef.getTimeFormat(); --- 674,677 ---- *************** *** 752,791 **** return axis; } - - private void addSubtitles(JFreeChart chart) throws RrdException { - String currentLine = ""; - ArrayList subtitles = new ArrayList(); - Comment[] comments = graphDef.getComments(); - int lastScaleIndex = ValueScaler.NO_SCALE; - for(int i = 0; i < comments.length; i++) { - if(currentLine.length() > 0) { - currentLine += SPACER; - } - Comment comment = comments[i]; - // uniform scaling is now supported - comment.setScaleIndex(lastScaleIndex); - currentLine += comment.getMessage(); - lastScaleIndex = comment.getScaleIndex(); - if(comment.isAlignSet()) { - // should finish current line - int align = comment.getAlign(); - TextTitle subtitle = new TextTitle(currentLine, SUBTITLE_FONT, Color.BLACK, - TextTitle.BOTTOM, align, TextTitle.DEFAULT_VERTICAL_ALIGNMENT, SUBTITLE_SPACER); - subtitles.add(subtitle); - currentLine = ""; - } - } - if(currentLine.length() > 0) { - TextTitle subtitle = new TextTitle(currentLine, SUBTITLE_FONT, - Color.BLACK, TextTitle.BOTTOM, DEFAULT_ALIGN, - TextTitle.DEFAULT_VERTICAL_ALIGNMENT, SUBTITLE_SPACER); - subtitles.add(subtitle); - } - for(int i = subtitles.size() - 1; i >= 0; i--) { - TextTitle subtitle = (TextTitle) subtitles.get(i); - chart.addSubtitle(subtitle); - } - } */ private TimeMarker[] calculateTimeMarkers() { --- 755,764 ---- return axis; } */ + + /** + * + * @return List of timemarkers to plot + */ private TimeMarker[] calculateTimeMarkers() { *************** *** 806,837 **** vLabelCentered = false; ! if(days <= 2.0 / 24.0) { ! t = new TimeAxisUnit( TimeAxisUnit.MINUTE, 10, new SimpleDateFormat("mm")); } ! else if (days <= 1) ! t = new TimeAxisUnit( TimeAxisUnit.HOUR, 1, TimeAxisUnit.HOUR, 6, new SimpleDateFormat("HH:mm")); ! else if(days <= 2) { ! t = new TimeAxisUnit( TimeAxisUnit.HOUR, 2, new SimpleDateFormat("HH")); } ! else if(days <= 3) { ! t = new TimeAxisUnit( TimeAxisUnit.HOUR, 6, new SimpleDateFormat("HH:mm")); } ! else if(days <= 8) { ! t = new TimeAxisUnit( TimeAxisUnit.DAY, 1, new SimpleDateFormat("EEE dd MMM")); } ! else if (days <= 32) { ! //t = new TimeAxisUnit( TimeAxisUnit.HOUR, 24, TimeAxisUnit.DAY, 1, new SimpleDateFormat("dd")); ! t = new TimeAxisUnit( TimeAxisUnit.DAY, 1, TimeAxisUnit.WEEK, 1, new SimpleDateFormat("'week' ww")); vLabelCentered = true; ! } ! else if(days <= 63) { t = new TimeAxisUnit( TimeAxisUnit.DAY, 1, TimeAxisUnit.WEEK, 1, new SimpleDateFormat("'week' ww")); ! //t = new TimeAxisUnit( TimeAxisUnit.WEEK, 2, new SimpleDateFormat("dd")); } ! else if(days <= 120) { ! t = new TimeAxisUnit( TimeAxisUnit.WEEK, 4, new SimpleDateFormat("dd")); } else { ! t = new TimeAxisUnit( TimeAxisUnit.MONTH, 1, new SimpleDateFormat("MMM")); } --- 779,830 ---- vLabelCentered = false; ! if (days <= 2.0 / 24.0) { ! t = new TimeAxisUnit( TimeAxisUnit.MINUTE, 5, TimeAxisUnit.MINUTE, 10, new SimpleDateFormat("HH:mm")); } ! else if (days <= 3.0 / 24.0) { ! t = new TimeAxisUnit( TimeAxisUnit.MINUTE, 5, TimeAxisUnit.MINUTE, 20, new SimpleDateFormat("HH:mm")); } ! else if (days <= 5.0 / 24.0) { ! t = new TimeAxisUnit( TimeAxisUnit.MINUTE, 10, TimeAxisUnit.MINUTE, 30, new SimpleDateFormat("HH:mm")); } ! else if (days <= 10.0 / 24.0) { ! t = new TimeAxisUnit( TimeAxisUnit.MINUTE, 15, TimeAxisUnit.HOUR, 1, new SimpleDateFormat("HH:mm")); } ! else if (days <= 15.0 / 24.0) { ! t = new TimeAxisUnit( TimeAxisUnit.MINUTE, 30, TimeAxisUnit.HOUR, 2, new SimpleDateFormat("HH:mm")); ! //t = new TimeAxisUnit( TimeAxisUnit.HOUR, 2, TimeAxisUnit.HOUR, 6, new SimpleDateFormat("HH:mm")); ! } ! else if(days <= 20.0 / 24.0) { ! t = new TimeAxisUnit( TimeAxisUnit.HOUR, 1, TimeAxisUnit.HOUR, 1, new SimpleDateFormat("HH")); vLabelCentered = true; ! } ! else if(days <= 36.0 / 24.0) { ! t = new TimeAxisUnit( TimeAxisUnit.HOUR, 1, TimeAxisUnit.HOUR, 4, new SimpleDateFormat("HH:mm")); ! } ! else if (days <= 2) { ! t = new TimeAxisUnit( TimeAxisUnit.HOUR, 2, TimeAxisUnit.HOUR, 6, new SimpleDateFormat("HH:mm")); ! } ! else if (days <= 3) { ! t = new TimeAxisUnit( TimeAxisUnit.HOUR, 3, TimeAxisUnit.HOUR, 12, new SimpleDateFormat("HH:mm")); ! } ! else if(days <= 7) { ! t = new TimeAxisUnit( TimeAxisUnit.HOUR, 6, TimeAxisUnit.DAY, 1, new SimpleDateFormat("EEE dd")); ! vLabelCentered = true; ! } ! else if(days <= 14) { ! t = new TimeAxisUnit( TimeAxisUnit.HOUR, 12, TimeAxisUnit.DAY, 1, new SimpleDateFormat("dd")); ! vLabelCentered = true; ! } ! else if (days <= 43) { t = new TimeAxisUnit( TimeAxisUnit.DAY, 1, TimeAxisUnit.WEEK, 1, new SimpleDateFormat("'week' ww")); ! vLabelCentered = true; } ! else if(days <= 157) { ! t = new TimeAxisUnit( TimeAxisUnit.WEEK, 1, TimeAxisUnit.WEEK, 1, new SimpleDateFormat("ww")); ! vLabelCentered = true; } else { ! t = new TimeAxisUnit( TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, new SimpleDateFormat("MMM")); ! vLabelCentered = true; } *************** *** 841,850 **** } private ValueMarker[] calculateValueMarkers() { ! ValueAxisUnit v = null; ! ! double range = upperValue - lowerValue; double shifted = ( Math.abs(upperValue) > Math.abs(lowerValue) ? Math.abs(upperValue) : Math.abs(lowerValue) ); double mod = 1.0; --- 834,867 ---- } + /** + * + * @return List of value markers to plot + */ private ValueMarker[] calculateValueMarkers() { ! ValueAxisUnit v = null; ! boolean lowerFromRange = false; ! boolean upperFromRange = false; ! boolean rigid = graphDef.getRigidGrid(); + // Exceptional case + if ( upperValue == 0 && upperValue == lowerValue ) + upperValue = 0.9; + + Range vr = graphDef.getValueRange(); + if ( vr != null ) + { + double rLower = vr.getLowerValue(); + if ( !Double.isNaN(rLower) && (rigid || rLower < lowerValue) ) { + lowerValue = rLower; + lowerFromRange = true; + } + double rUpper = vr.getUpperValue(); + if ( !Double.isNaN(rUpper) && (rigid || rUpper > upperValue) ) { + upperValue = rUpper; + upperFromRange = true; + } + } + double shifted = ( Math.abs(upperValue) > Math.abs(lowerValue) ? Math.abs(upperValue) : Math.abs(lowerValue) ); double mod = 1.0; *************** *** 861,873 **** v = new ValueAxisUnit( 1, 0.2*mod, 1, 1.0*mod ); else if ( shifted <= 5 ) ! v = new ValueAxisUnit( 1, 0.5*mod, 1, 1.0*mod ); else if ( shifted <= 9 ) v = new ValueAxisUnit( 1, 0.5*mod, 1, 2.0*mod ); else v = new ValueAxisUnit( 1, 1.0*mod, 1, 5.0*mod ); - - upperValue = v.getNiceHigher( upperValue ); - lowerValue = v.getNiceLower( lowerValue ); return v.getValueMarkers( lowerValue, upperValue ); } --- 878,890 ---- v = new ValueAxisUnit( 1, 0.2*mod, 1, 1.0*mod ); else if ( shifted <= 5 ) ! v = new ValueAxisUnit( 1, 0.5*mod, 1, 1.0*mod ); else if ( shifted <= 9 ) v = new ValueAxisUnit( 1, 0.5*mod, 1, 2.0*mod ); else v = new ValueAxisUnit( 1, 1.0*mod, 1, 5.0*mod ); + if ( !upperFromRange ) upperValue = v.getNiceHigher( upperValue ); + if ( !lowerFromRange ) lowerValue = v.getNiceLower( lowerValue ); + return v.getValueMarkers( lowerValue, upperValue ); } Index: ValueAxisUnit.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/ValueAxisUnit.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ValueAxisUnit.java 25 Sep 2003 21:58:05 -0000 1.2 --- ValueAxisUnit.java 30 Sep 2003 21:45:21 -0000 1.3 *************** *** 68,71 **** --- 68,75 ---- } + private double round( double value ) + { + return new java.math.BigDecimal(value).setScale(14 , java.math.BigDecimal.ROUND_HALF_EVEN).doubleValue(); + } public ValueMarker[] getValueMarkers( double lower, double upper ) *************** *** 76,87 **** // Find the first visible gridpoint if ( lower > 0 ) { ! while ( minPoint <= lower ) minPoint += gridStep; ! while ( majPoint <= lower ) majPoint += mGridStep; } else { ! while ( minPoint >= lower ) minPoint -= gridStep; ! while ( majPoint >= lower ) majPoint -= mGridStep; // Go one up to make it visible ! minPoint += gridStep; ! majPoint += mGridStep; } --- 80,91 ---- // Find the first visible gridpoint if ( lower > 0 ) { ! while ( minPoint < lower ) minPoint += gridStep; ! while ( majPoint < lower ) majPoint += mGridStep; } else { ! while ( minPoint > lower ) minPoint -= gridStep; ! while ( majPoint > lower ) majPoint -= mGridStep; // Go one up to make it visible ! if (minPoint != lower ) minPoint += gridStep; ! if (majPoint != lower ) majPoint += mGridStep; } *************** *** 92,99 **** while ( minPoint <= upper && majPoint <= upper ) { if ( minPoint < majPoint ) { markerList.add( new ValueMarker(minPoint, "", false) ); ! minPoint += gridStep; } else --- 96,104 ---- while ( minPoint <= upper && majPoint <= upper ) { + //System.out.println( minPoint + "||" + majPoint ); if ( minPoint < majPoint ) { markerList.add( new ValueMarker(minPoint, "", false) ); ! minPoint = round( minPoint + gridStep ); } else *************** *** 110,120 **** { markerList.add( new ValueMarker(majPoint, str, true) ); ! minPoint += gridStep; ! majPoint += mGridStep; } else { markerList.add( new ValueMarker(majPoint, str, true) ); ! majPoint += mGridStep; } } --- 115,125 ---- { markerList.add( new ValueMarker(majPoint, str, true) ); ! minPoint = round( minPoint + gridStep ); ! majPoint = round( majPoint + mGridStep ); } else { markerList.add( new ValueMarker(majPoint, str, true) ); ! majPoint = round( majPoint + mGridStep ); } } *************** *** 124,128 **** { markerList.add( new ValueMarker(minPoint, "", false) ); ! minPoint += gridStep; } --- 129,133 ---- { markerList.add( new ValueMarker(minPoint, "", false) ); ! minPoint = round( minPoint + gridStep ); } *************** *** 138,142 **** markerList.add( new ValueMarker(majPoint, str, true) ); ! majPoint += mGridStep; } --- 143,147 ---- markerList.add( new ValueMarker(majPoint, str, true) ); ! majPoint = round( majPoint + mGridStep ); } *************** *** 144,186 **** } ! public double getNiceLower( double value ) { int valueInt = new Double(value).intValue(); int roundStep = new Double(gridUnit * gridParts).intValue(); int num = valueInt / roundStep; int mod = valueInt % roundStep; ! double gridValue = (roundStep * (num - 1)) * 1.0d; ! if ( gridValue - value < (gridParts * gridUnit) / 4 ) gridValue -= roundStep; roundStep = new Double(mGridUnit * mGridParts).intValue(); num = valueInt / roundStep; mod = valueInt % roundStep; ! double mGridValue = (roundStep * (num - 1)) * 1.0d; ! if ( value != 0.0d ) { ! if ( mGridValue - gridValue < (mGridParts * mGridUnit) / 2) ! return mGridValue; else ! return gridValue; } ! return value; ! ! /* ! int valueInt = new Double(value).intValue(); ! int num = valueInt / roundStep; ! int mod = valueInt % roundStep; ! ! if ( value != 0 ) ! return (roundStep * (num - 1)) * 1.0d; ! ! return value; ! */ } ! public double getNiceHigher( double value ) { int valueInt = new Double(value).intValue(); int roundStep = new Double(gridUnit * gridParts).intValue(); --- 149,222 ---- } ! public double getNiceLower( double ovalue ) { + // Add some checks + double gridParts = this.gridParts; + double mGridParts = this.mGridParts; + double gridFactor = 1.0; + double mGridFactor = 1.0; + + if ( gridUnit * gridParts < 1.0 ) { + gridParts *= 100; + gridFactor = 100; + } + + if ( mGridUnit * mGridParts < 1.0 ) { + mGridParts *= 100; + mGridFactor = 100; + } + + double value = ovalue * gridFactor; int valueInt = new Double(value).intValue(); int roundStep = new Double(gridUnit * gridParts).intValue(); int num = valueInt / roundStep; int mod = valueInt % roundStep; ! double gridValue = (roundStep * num) * 1.0d; ! if ( gridValue > value ) ! gridValue -= roundStep; ! ! if ( num == 0 && value >= 0 ) ! gridValue = 0.0; ! else if ( Math.abs(gridValue - value) < (gridParts * gridUnit) / 16 ) gridValue -= roundStep; + value = ovalue * mGridFactor; roundStep = new Double(mGridUnit * mGridParts).intValue(); num = valueInt / roundStep; mod = valueInt % roundStep; ! double mGridValue = (roundStep * num) * 1.0d; ! if ( mGridValue > value ) ! mGridValue -= roundStep; ! if ( value != 0.0d ) { ! if ( Math.abs(mGridValue - gridValue) < (mGridParts * mGridUnit) / 2) ! return mGridValue / mGridFactor; else ! return gridValue / gridFactor; } ! return ovalue; } ! public double getNiceHigher( double ovalue ) { + // Add some checks + double gridParts = this.gridParts; + double mGridParts = this.mGridParts; + double gridFactor = 1.0; + double mGridFactor = 1.0; + + if ( gridUnit * gridParts < 1.0 ) { + gridParts *= 100; + gridFactor = 100; + } + + if ( mGridUnit * mGridParts < 1.0 ) { + mGridParts *= 100; + mGridFactor = 100; + } + + double value = ovalue * gridFactor; int valueInt = new Double(value).intValue(); int roundStep = new Double(gridUnit * gridParts).intValue(); *************** *** 188,194 **** int mod = valueInt % roundStep; double gridValue = (roundStep * (num + 1)) * 1.0d; ! if ( gridValue - value < (gridParts * gridUnit) / 4 ) gridValue += roundStep; roundStep = new Double(mGridUnit * mGridParts).intValue(); num = valueInt / roundStep; --- 224,231 ---- int mod = valueInt % roundStep; double gridValue = (roundStep * (num + 1)) * 1.0d; ! if ( gridValue - value < (gridParts * gridUnit) / 8 ) gridValue += roundStep; + value = ovalue * mGridFactor; roundStep = new Double(mGridUnit * mGridParts).intValue(); num = valueInt / roundStep; *************** *** 198,208 **** if ( value != 0.0d ) { ! if ( mGridValue - gridValue < (mGridParts * mGridUnit) / 2) ! return mGridValue; else ! return gridValue; } ! return value; } } --- 235,245 ---- if ( value != 0.0d ) { ! if ( Math.abs(mGridValue - gridValue) < (mGridParts * mGridUnit) / 2) ! return mGridValue / mGridFactor; else ! return gridValue / gridFactor; } ! return ovalue; } } Index: Range.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/Range.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Range.java 22 Sep 2003 17:15:17 -0000 1.1 --- Range.java 30 Sep 2003 21:45:21 -0000 1.2 *************** *** 25,29 **** class Range { ! private double lower, upper; Range ( double lower, double upper ) --- 25,30 ---- class Range { ! private double lower = Double.NaN; ! private double upper = Double.NaN; Range ( double lower, double upper ) *************** *** 31,34 **** --- 32,43 ---- this.lower = lower; this.upper = upper; + } + + double getLowerValue() { + return lower; + } + + double getUpperValue() { + return upper; } } |
From: <cob...@us...> - 2003-09-30 21:45:27
|
Update of /cvsroot/jrobin/src/jrobin/demo In directory sc8-pr-cvs1:/tmp/cvs-serv8118/src/jrobin/demo Modified Files: JRobinMinMaxDemo.java JRobinComplexGraph.java Log Message: GRAPH LIB UPDATES Fix zero comment line problem Option to disable the legend Option to bring grid to front or back Option to set rigid grid lines Option to set fixed upper and lower value Add change border option Possibility to disable grid lines (no minor grid) Fix background color option Better Time and Value axis markers Index: JRobinMinMaxDemo.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/demo/JRobinMinMaxDemo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JRobinMinMaxDemo.java 22 Sep 2003 17:15:17 -0000 1.2 --- JRobinMinMaxDemo.java 30 Sep 2003 21:45:22 -0000 1.3 *************** *** 27,30 **** --- 27,31 ---- import jrobin.graph.RrdGraphDef; + import java.io.*; import java.awt.*; import java.io.IOException; *************** *** 99,103 **** RrdGraph graph = new RrdGraph(gDef); //graph.saveAsPNG(pngFile, 550, 250); ! graph.saveAsPNG(pngFile, 0, 0); } --- 100,111 ---- RrdGraph graph = new RrdGraph(gDef); //graph.saveAsPNG(pngFile, 550, 250); ! //graph.saveAsPNG(pngFile, 0, 0); ! ! byte[] l = graph.getPNGBytes(0, 0); ! System.out.println(l.length); ! FileOutputStream fl = new FileOutputStream("/byte.png"); ! fl.write(l); ! fl.close(); ! } Index: JRobinComplexGraph.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/demo/JRobinComplexGraph.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JRobinComplexGraph.java 25 Sep 2003 21:58:05 -0000 1.2 --- JRobinComplexGraph.java 30 Sep 2003 21:45:22 -0000 1.3 *************** *** 43,48 **** public static void main(String[] args) { ! GregorianCalendar start = new GregorianCalendar(2003, 7, 23, 00, 00); ! GregorianCalendar end = new GregorianCalendar(2003, 7, 24, 00, 00); RrdGraphDef gDef = new RrdGraphDef(); --- 43,49 ---- public static void main(String[] args) { ! GregorianCalendar start = new GregorianCalendar(2003, 7, 23, 0, 0); ! GregorianCalendar end = new GregorianCalendar(2003, 7, 24, 0, 0); ! RrdGraphDef gDef = new RrdGraphDef(); *************** *** 74,78 **** gDef.area("p75t90", new Color(0xff,0x66,0x00), "75 - 90%"); gDef.area("p90t100", new Color(0xcc,0x33,0x00), "90 - 100%"); ! gDef.rule(10.0, Color.YELLOW, null); gDef.gprint("busy", "AVERAGE", " Average:@5.1@s%"); gDef.gprint("busy", "LAST", "Current: @5.1@s%"); --- 75,79 ---- gDef.area("p75t90", new Color(0xff,0x66,0x00), "75 - 90%"); gDef.area("p90t100", new Color(0xcc,0x33,0x00), "90 - 100%"); ! gDef.rule(10.0, Color.ORANGE, null); gDef.gprint("busy", "AVERAGE", " Average:@5.1@s%"); gDef.gprint("busy", "LAST", "Current: @5.1@s%"); *************** *** 96,102 **** gDef.comment("-------------------------------------------------------------------------------@c"); gDef.comment("Generated: " + new Date() + "@r"); ! gDef.setBackColor( Color.WHITE ); gDef.setValueAxisLabel("server load"); ! // Create actual graph RrdGraph graph = new RrdGraph(gDef); --- 97,107 ---- gDef.comment("-------------------------------------------------------------------------------@c"); gDef.comment("Generated: " + new Date() + "@r"); ! //gDef.setBackColor( Color.ORANGE ); gDef.setValueAxisLabel("server load"); ! //gDef.setGridX( false ); ! //gDef.setGridY( false ); ! gDef.setImageBorder( Color.DARK_GRAY, 1 ); ! gDef.setFrontGrid(false); ! gDef.setShowLegend(true); // Create actual graph RrdGraph graph = new RrdGraph(gDef); *************** *** 114,118 **** gd.area("in", Color.GREEN, null); gd.line("out", Color.BLUE, null); ! RrdGraph graph2 = new RrdGraph(gd); graph2.saveAsPNG("/traff.png", 0, 0); --- 119,123 ---- gd.area("in", Color.GREEN, null); gd.line("out", Color.BLUE, null); ! gd.setRigidGrid(true); RrdGraph graph2 = new RrdGraph(gd); graph2.saveAsPNG("/traff.png", 0, 0); *************** *** 140,143 **** --- 145,149 ---- graph2 = new RrdGraph(gd); graph2.saveAsPNG("/ftp.png", 0, 0); + //graph.saveAsPNG("c:/demo.png", 495, 200); |
From: <cob...@us...> - 2003-09-30 21:45:27
|
Update of /cvsroot/jrobin/src/jrobin/mrtg/server In directory sc8-pr-cvs1:/tmp/cvs-serv8118/src/jrobin/mrtg/server Modified Files: Grapher.java Log Message: GRAPH LIB UPDATES Fix zero comment line problem Option to disable the legend Option to bring grid to front or back Option to set rigid grid lines Option to set fixed upper and lower value Add change border option Possibility to disable grid lines (no minor grid) Fix background color option Better Time and Value axis markers Index: Grapher.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/mrtg/server/Grapher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Grapher.java 4 Sep 2003 13:28:38 -0000 1.1 --- Grapher.java 30 Sep 2003 21:45:21 -0000 1.2 *************** *** 32,36 **** class Grapher { ! static final int GRAPH_WIDTH = 600, GRAPH_HEIGHT = 400; private String ifDescr, host, alias; --- 32,36 ---- class Grapher { ! static final int GRAPH_WIDTH = 502, GRAPH_HEIGHT = 234; private String ifDescr, host, alias; *************** *** 56,59 **** --- 56,60 ---- RrdGraphDef gDef = new RrdGraphDef(); try { + gDef.setImageBorder(Color.WHITE, 0); // Don't show border gDef.setTimePeriod(start, stop); gDef.setTitle(ifDescr + "@" + host); *************** *** 64,76 **** gDef.datasource("in8", "in,8,*"); gDef.datasource("out8", "out,8,*"); ! gDef.area("out8", Color.GREEN, "output traffic"); ! gDef.line("in8", Color.BLUE, "input traffic"); ! gDef.gprint("in8", "AVERAGE", "avgIn=@2 @sbits/sec"); ! gDef.gprint("in8", "MAX", "maxIn=@2 @Sbits/sec@r"); ! gDef.gprint("out8", "AVERAGE", "avgOut=@2 @sbits/sec"); ! gDef.gprint("out8", "MAX", "maxOut=@2 @Sbits/sec@r"); ! gDef.comment("Start time: " + new Date(start * 1000L)); ! gDef.comment("End time: " + new Date(stop * 1000L + 1) + "@r"); ! gDef.comment("Description on device: " + alias + "@r"); return new RrdGraph(gDef); } catch (RrdException e) { --- 65,80 ---- gDef.datasource("in8", "in,8,*"); gDef.datasource("out8", "out,8,*"); ! gDef.area("in8", Color.GREEN, "input traffic"); ! gDef.line("out8", Color.BLUE, "output traffic\n"); ! gDef.comment("\n"); ! gDef.gprint("in8", "AVERAGE", "Average input: @7.2 @sbits/s"); ! gDef.gprint("in8", "MAX", "Maximum input: @7.2 @Sbits/s\n"); ! gDef.gprint("out8", "AVERAGE", "Average output:@7.2 @sbits/s"); ! gDef.gprint("out8", "MAX", "Maximum output:@7.2 @Sbits/s\n"); ! gDef.comment("\n"); ! gDef.comment("Description on device: " + alias); ! gDef.comment("\n"); ! gDef.comment("Graph from " + new Date(start * 1000L)); ! gDef.comment("to " + new Date(stop * 1000L + 1)); return new RrdGraph(gDef); } catch (RrdException e) { |
From: <sa...@us...> - 2003-09-29 14:19:56
|
Update of /cvsroot/jrobin/src/jrobin/core In directory sc8-pr-cvs1:/tmp/cvs-serv4459/jrobin/core Modified Files: Archive.java Datasource.java XmlReader.java Log Message: Removed 'public' from methods which could have 'package' visibility Index: Archive.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Archive.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Archive.java 24 Sep 2003 11:32:24 -0000 1.2 --- Archive.java 29 Sep 2003 13:27:52 -0000 1.3 *************** *** 191,203 **** } ! public double getXff() throws IOException { return xff.get(); } ! public int getSteps() throws IOException { return steps.get(); } ! public int getRows() throws IOException{ return rows.get(); } --- 191,203 ---- } ! double getXff() throws IOException { return xff.get(); } ! int getSteps() throws IOException { return steps.get(); } ! int getRows() throws IOException{ return rows.get(); } *************** *** 216,220 **** } ! public FetchPoint[] fetch(FetchRequest request) throws IOException, RrdException { long arcStep = getArcStep(); long fetchStart = Util.normalize(request.getFetchStart(), arcStep); --- 216,220 ---- } ! FetchPoint[] fetch(FetchRequest request) throws IOException, RrdException { long arcStep = getArcStep(); long fetchStart = Util.normalize(request.getFetchStart(), arcStep); Index: Datasource.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Datasource.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Datasource.java 24 Sep 2003 11:32:24 -0000 1.2 --- Datasource.java 29 Sep 2003 13:27:53 -0000 1.3 *************** *** 93,109 **** } ! public String getDsType() throws IOException { return dsType.get(); } ! public long getHeartbeat() throws IOException { return heartbeat.get(); } ! public double getMinValue() throws IOException { return minValue.get(); } ! public double getMaxValue() throws IOException { return maxValue.get(); } --- 93,109 ---- } ! String getDsType() throws IOException { return dsType.get(); } ! long getHeartbeat() throws IOException { return heartbeat.get(); } ! double getMinValue() throws IOException { return minValue.get(); } ! double getMaxValue() throws IOException { return maxValue.get(); } Index: XmlReader.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/XmlReader.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XmlReader.java 29 Sep 2003 11:25:05 -0000 1.2 --- XmlReader.java 29 Sep 2003 13:27:53 -0000 1.3 *************** *** 39,43 **** private Node[] dsNodes, arcNodes; ! public XmlReader(String xmlFilePath) throws IOException, RrdException { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); --- 39,43 ---- private Node[] dsNodes, arcNodes; ! XmlReader(String xmlFilePath) throws IOException, RrdException { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
From: <sa...@us...> - 2003-09-29 11:25:31
|
Update of /cvsroot/jrobin/src/jrobin/core In directory sc8-pr-cvs1:/tmp/cvs-serv10847/jrobin/core Modified Files: RrdDb.java Util.java XmlReader.java XmlWriter.java Log Message: More optimized XML import/export methods. Index: RrdDb.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/RrdDb.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RrdDb.java 24 Sep 2003 11:32:24 -0000 1.4 --- RrdDb.java 29 Sep 2003 11:25:05 -0000 1.5 *************** *** 191,194 **** --- 191,196 ---- archives[i] = new Archive(this, reader, i); } + // XMLReader is a rather huge DOM tree, release memory ASAP + reader = null; // finalize finalizeSetup(true); *************** *** 513,517 **** public synchronized void dumpXml(String filename) throws IOException, RrdException { ! OutputStream destination = new BufferedOutputStream(new FileOutputStream(filename, false)); dumpXml(destination); destination.close(); --- 515,519 ---- public synchronized void dumpXml(String filename) throws IOException, RrdException { ! OutputStream destination = new FileOutputStream(filename, false); dumpXml(destination); destination.close(); Index: Util.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Util.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Util.java 24 Sep 2003 11:32:24 -0000 1.3 --- Util.java 29 Sep 2003 11:25:05 -0000 1.4 *************** *** 110,112 **** --- 110,124 ---- } + public static double parseDouble(String valueStr) { + double value; + try { + value = Double.parseDouble(valueStr); + } + catch(NumberFormatException nfe) { + // Arne Vandamme fixed bug on UNKN value from Windows + value = Double.NaN; + } + return value; + } + } Index: XmlReader.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/XmlReader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlReader.java 4 Sep 2003 13:26:41 -0000 1.1 --- XmlReader.java 29 Sep 2003 11:25:05 -0000 1.2 *************** *** 29,45 **** import org.xml.sax.SAXException; ! import javax.xml.parsers.DocumentBuilder; ! import javax.xml.parsers.DocumentBuilderFactory; ! import javax.xml.parsers.FactoryConfigurationError; ! import javax.xml.parsers.ParserConfigurationException; ! import java.io.File; import java.io.IOException; import java.util.ArrayList; class XmlReader { ! private Document doc; private Element root; ! private Node[] dsNodes; ! private Node[] arcNodes; public XmlReader(String xmlFilePath) throws IOException, RrdException { --- 29,41 ---- import org.xml.sax.SAXException; ! import javax.xml.parsers.*; import java.io.IOException; + import java.io.File; import java.util.ArrayList; class XmlReader { ! private Element root; ! private Node[] dsNodes, arcNodes; public XmlReader(String xmlFilePath) throws IOException, RrdException { *************** *** 49,53 **** factory.setNamespaceAware(false); DocumentBuilder builder = factory.newDocumentBuilder(); ! doc = builder.parse(new File(xmlFilePath)); root = doc.getDocumentElement(); dsNodes = getChildNodes(root, "ds"); --- 45,49 ---- factory.setNamespaceAware(false); DocumentBuilder builder = factory.newDocumentBuilder(); ! Document doc = builder.parse(new File(xmlFilePath)); root = doc.getDocumentElement(); dsNodes = getChildNodes(root, "ds"); *************** *** 151,159 **** Node[] vNodes = getChildNodes(rows[i], "v"); Node vNode = vNodes[dsIndex]; ! values[i] = Double.parseDouble(vNode.getFirstChild().getNodeValue().trim()); } return values; } static Node[] getChildNodes(Node parentNode, String childName) { ArrayList nodes = new ArrayList(); --- 147,157 ---- Node[] vNodes = getChildNodes(rows[i], "v"); Node vNode = vNodes[dsIndex]; ! values[i] = Util.parseDouble(vNode.getFirstChild().getNodeValue().trim()); } return values; } + // utility functions for DOM tree traversing + static Node[] getChildNodes(Node parentNode, String childName) { ArrayList nodes = new ArrayList(); *************** *** 198,210 **** static double getChildValueAsDouble(Node parentNode, String childName) throws RrdException { - // Arne Vandamme fixed bug on UNKN value from Windows String valueStr = getChildValue(parentNode, childName); ! try { ! return Double.parseDouble(valueStr); ! } ! catch (NumberFormatException nfe) { ! return Double.NaN; ! } } ! ! } --- 196,201 ---- static double getChildValueAsDouble(Node parentNode, String childName) throws RrdException { String valueStr = getChildValue(parentNode, childName); ! return Util.parseDouble(valueStr); } ! } \ No newline at end of file Index: XmlWriter.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/XmlWriter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlWriter.java 24 Sep 2003 11:32:24 -0000 1.1 --- XmlWriter.java 29 Sep 2003 11:25:05 -0000 1.2 *************** *** 25,29 **** import java.io.OutputStream; import java.io.PrintWriter; ! import java.util.ArrayList; import java.text.DecimalFormat; --- 25,29 ---- import java.io.OutputStream; import java.io.PrintWriter; ! import java.util.Stack; import java.text.DecimalFormat; *************** *** 47,51 **** void closeTag() { ! String tag = openTags.pop(); indent.setLength(indent.length() - INDENT_STR.length()); writer.println(indent + "</" + tag + ">"); --- 47,51 ---- void closeTag() { ! String tag = (String) openTags.pop(); indent.setLength(indent.length() - INDENT_STR.length()); writer.println(indent + "</" + tag + ">"); *************** *** 87,108 **** void writeComment(Object comment) { writer.println(indent + "<!-- " + comment + " -->"); - } - - private class Stack { - private ArrayList stack = new ArrayList(); - - void push(String tag) { - stack.add(tag); - } - - String pop() { - int last = stack.size() - 1; - if(last >= 0) { - String tag = (String) stack.get(last); - stack.remove(last); - return tag; - } - return null; - } } } --- 87,90 ---- |
Update of /cvsroot/jrobin/src/jrobin/graph In directory sc8-pr-cvs1:/tmp/cvs-serv4323/src/jrobin/graph Modified Files: TimeAxisUnit.java RrdGraphDef.java ChartGraphics.java Grapher.java ValueAxisUnit.java PlotDef.java Log Message: - value / time axis scaling modified - added hrule legend - fine tuned grid plotting - UNK values don't get drawn anymore - added line widths Index: TimeAxisUnit.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/TimeAxisUnit.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TimeAxisUnit.java 22 Sep 2003 17:15:17 -0000 1.1 --- TimeAxisUnit.java 25 Sep 2003 21:58:05 -0000 1.2 *************** *** 43,47 **** Calendar.YEAR }; ! final String[] bla = {"second", "minute", "hour", "day", "week", "month", "year"}; // Indices in the calendarUnit table static final int SECOND = 0; --- 43,47 ---- Calendar.YEAR }; ! // Indices in the calendarUnit table static final int SECOND = 0; *************** *** 106,112 **** // Find first visible grid point ! long minPoint, majPoint; ! while ( (majPoint = getNextPoint(cMaj, mGridTime, mGridUnits)) < start ); ! while ( (minPoint = getNextPoint(cMin, gridTime, gridUnits)) < start ); ArrayList markerList = new ArrayList(); --- 106,116 ---- // Find first visible grid point ! long minPoint = cMin.getTimeInMillis(); ! long majPoint = cMaj.getTimeInMillis(); ! ! while ( majPoint < start ) ! majPoint = getNextPoint(cMaj, mGridTime, mGridUnits); ! while ( minPoint < start ) ! minPoint = getNextPoint(cMin, gridTime, gridUnits); ArrayList markerList = new ArrayList(); *************** *** 118,122 **** // // In short: the first while() loop is not *necessary* to get correct results ! while ( minPoint < stop && majPoint < stop ) { if ( minPoint < majPoint ) --- 122,126 ---- // // In short: the first while() loop is not *necessary* to get correct results ! while ( minPoint <= stop && majPoint <= stop ) { if ( minPoint < majPoint ) *************** *** 138,142 **** } ! while ( minPoint < stop ) { markerList.add( new TimeMarker( minPoint, "", false ) ); --- 142,146 ---- } ! while ( minPoint <= stop ) { markerList.add( new TimeMarker( minPoint, "", false ) ); *************** *** 144,148 **** } ! while ( majPoint < stop ) { markerList.add( new TimeMarker( majPoint, df.format(cMaj.getTime()), true ) ); --- 148,152 ---- } ! while ( majPoint <= stop ) { markerList.add( new TimeMarker( majPoint, df.format(cMaj.getTime()), true ) ); *************** *** 151,154 **** --- 155,169 ---- return (TimeMarker[]) markerList.toArray( new TimeMarker[0] ); + } + + + public long getMajorGridWidth() + { + Calendar c = Calendar.getInstance(); + long now = c.getTimeInMillis() / 1000; + + c.add( calendarUnit[mGridTime], mGridUnits ); + + return (c.getTimeInMillis() / 1000) - now; } } Index: RrdGraphDef.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/RrdGraphDef.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RrdGraphDef.java 22 Sep 2003 17:15:17 -0000 1.2 --- RrdGraphDef.java 25 Sep 2003 21:58:05 -0000 1.3 *************** *** 218,222 **** graphs.add(new OverlayGraph(plotDef)); // Add comment line for the legend ! addComment( new Legend(plotDef.getColor(), plotDef.getLegend()) ); } --- 218,223 ---- graphs.add(new OverlayGraph(plotDef)); // Add comment line for the legend ! if ( plotDef.getLegend() != null ) ! addComment( new Legend(plotDef.getColor(), plotDef.getLegend()) ); } *************** *** 235,238 **** --- 236,241 ---- graphs.add(new OverlayGraph(hruleDef)); sources.add(hruleDef.getSource()); + if ( hruleDef.getLegend() != null ) + addComment( new Legend(hruleDef.getColor(), hruleDef.getLegend()) ); } Index: ChartGraphics.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/ChartGraphics.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ChartGraphics.java 22 Sep 2003 17:15:17 -0000 1.1 --- ChartGraphics.java 25 Sep 2003 21:58:05 -0000 1.2 *************** *** 92,95 **** --- 92,97 ---- int getY( double value ) { + if ( Double.isNaN(value) ) return Integer.MIN_VALUE; + int tmp = new Double(value * heightDelta).intValue(); return ( tmp > value * heightDelta ? tmp - 1 : tmp ); Index: Grapher.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/Grapher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Grapher.java 22 Sep 2003 17:15:17 -0000 1.2 --- Grapher.java 25 Sep 2003 21:58:05 -0000 1.3 *************** *** 53,57 **** private static final int LINE_PADDING = 4; ! static final Font TITLE_FONT = new Font("Lucida Sans Typewriter", Font.BOLD, 12); static final Font SUBTITLE_FONT = new Font("Lucida Sans Typewriter", Font.PLAIN, 10); --- 53,57 ---- private static final int LINE_PADDING = 4; ! static final Font TITLE_FONT = new Font("Lucida Sans Typewriter", Font.BOLD, 12); static final Font SUBTITLE_FONT = new Font("Lucida Sans Typewriter", Font.PLAIN, 10); *************** *** 61,65 **** static final String GRAPH_RESPECT = "niboRJ htiw detaerC"; private int numPoints = GRAPH_RESOLUTION; ! private int imgWidth, imgHeight; // Dimensions of the entire image private int chartWidth, chartHeight; // Dimensions of the chart area within the image --- 61,68 ---- static final String GRAPH_RESPECT = "niboRJ htiw detaerC"; private int numPoints = GRAPH_RESOLUTION; ! ! private boolean vLabelCentered = false; ! private long vLabelGridWidth = 0; ! private int imgWidth, imgHeight; // Dimensions of the entire image private int chartWidth, chartHeight; // Dimensions of the chart area within the image *************** *** 70,73 **** --- 73,77 ---- private double lowerValue = 0.0d, upperValue = 0.0d; + private RrdGraphDef graphDef; *************** *** 99,102 **** --- 103,108 ---- chartHeight = ( cHeight == 0 ? DEFAULT_HEIGHT : cHeight ); + if ( cWidth > GRAPH_RESOLUTION ) numPoints = cWidth; + // Calculate the complete image dimensions for the creation of the bufferedimage font_height = SUBTITLE_FONT.getSize(); // Determine font dimensions for regular comment font *************** *** 137,141 **** catch (Exception e) { ! throw new RrdException( e.getMessage() ); } --- 143,148 ---- catch (Exception e) { ! //throw new RrdException( e.getMessage() ); ! e.printStackTrace(); } *************** *** 169,179 **** g.drawLine( tmpx + 4, tmpy + 3, tmpx + 9, tmpy); for (int i = 0; i < timeList.length; i++) { ! secTime = timeList[i].timestamp / 1000; ! int posRel = chartGraph.getX(secTime); ! int pos = lux + posRel; ! if ( posRel > 2 ) { if ( timeList[i].isLabel() ) { --- 176,190 ---- g.drawLine( tmpx + 4, tmpy + 3, tmpx + 9, tmpy); + int pixWidth = 0; + if (vLabelCentered) + pixWidth = (chartGraph.getX( vLabelGridWidth ) - chartGraph.getX( 0 )); + for (int i = 0; i < timeList.length; i++) { ! secTime = timeList[i].timestamp / 1000; ! int posRel = chartGraph.getX(secTime); ! int pos = lux + posRel; ! if ( posRel >= 0 ) { if ( timeList[i].isLabel() ) { *************** *** 187,191 **** // Use extra 2 pixel padding (3 pixels from border total at least) int txtDistance = (timeList[i].text.length() * font_width) / 2; ! if ( (pos - lux > txtDistance + 2) && (pos + txtDistance + 2 < lux + chartWidth) ) { g.setColor( Color.BLACK ); --- 198,210 ---- // Use extra 2 pixel padding (3 pixels from border total at least) int txtDistance = (timeList[i].text.length() * font_width) / 2; ! ! if ( vLabelCentered ) ! { ! if ( pos + pixWidth <= lux + chartWidth ) { ! g.setColor( Color.BLACK ); ! g.drawString( timeList[i].text, pos + 2 + pixWidth/2 - txtDistance, luy + chartHeight + font_height + LINE_PADDING ); ! } ! } ! else if ( (pos - lux > txtDistance + 2) && (pos + txtDistance + 2 < lux + chartWidth) ) { g.setColor( Color.BLACK ); *************** *** 364,368 **** g.setYRange( lowerValue, upperValue ); ! plotChartGrid( g, tlist, vlist ); graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); --- 383,387 ---- g.setYRange( lowerValue, upperValue ); ! //plotChartGrid( g, tlist, vlist ); graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); *************** *** 380,389 **** g.setColor( plotDefs[i].getColor() ); ! switch ( plotDefs[i].getType() ) { case PlotDef.PLOT_LINE: drawLine( g, parentSeries, source, false ); lastPlotType = PlotDef.PLOT_LINE; break; case PlotDef.PLOT_AREA: --- 399,410 ---- g.setColor( plotDefs[i].getColor() ); ! switch ( plotDefs[i].getType() ) { case PlotDef.PLOT_LINE: + graphics.setStroke( new BasicStroke(plotDefs[i].getLineWidth()) ); drawLine( g, parentSeries, source, false ); lastPlotType = PlotDef.PLOT_LINE; + graphics.setStroke( new BasicStroke() ); break; case PlotDef.PLOT_AREA: *************** *** 404,407 **** --- 425,430 ---- graphics.setClip( 0, 0, imgWidth, imgHeight); graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF ); + + plotChartGrid( g, tlist, vlist ); } *************** *** 416,423 **** int ax = 0, ay = 0; int nx = 0, ny = 0, last = -1; ! RrdSecond[] times = (RrdSecond[]) s.getSeries().times.toArray( new RrdSecond[0] ); Double[] values = (Double[]) s.getSeries().values.toArray( new Double[0] ); ! for (int i = 0; i < times.length; i++) { --- 439,446 ---- int ax = 0, ay = 0; int nx = 0, ny = 0, last = -1; ! RrdSecond[] times = (RrdSecond[]) s.getSeries().times.toArray( new RrdSecond[0] ); Double[] values = (Double[]) s.getSeries().values.toArray( new Double[0] ); ! for (int i = 0; i < times.length; i++) { *************** *** 427,431 **** ny += p[i]; ! g.drawLine( ax, ay, nx, ny ); p[i] = ny; --- 450,455 ---- ny += p[i]; ! if ( ax != 0 && ay != Integer.MIN_VALUE && ny != Integer.MIN_VALUE ) ! g.drawLine( ax, ay, nx, ny ); p[i] = ny; *************** *** 461,465 **** } ! g.drawLine( nx, py, nx, ny ); p[i] = ny; --- 485,490 ---- } ! if ( ax != 0 && py != Integer.MIN_VALUE && ny != Integer.MIN_VALUE ) ! g.drawLine( nx, py, nx, ny ); p[i] = ny; *************** *** 779,789 **** long endTime = graphDef.getEndTime(); double days = (endTime - startTime) / 86400.0; if(days <= 2.0 / 24.0) { t = new TimeAxisUnit( TimeAxisUnit.MINUTE, 10, new SimpleDateFormat("mm")); } ! else if (days <= 1) { ! //t = new TimeAxisUnit( TimeAxisUnit.HOUR, 6, new SimpleDateFormat("HH:mm")); t = new TimeAxisUnit( TimeAxisUnit.HOUR, 1, TimeAxisUnit.HOUR, 6, new SimpleDateFormat("HH:mm")); - } else if(days <= 2) { t = new TimeAxisUnit( TimeAxisUnit.HOUR, 2, new SimpleDateFormat("HH")); --- 804,814 ---- long endTime = graphDef.getEndTime(); double days = (endTime - startTime) / 86400.0; + + vLabelCentered = false; if(days <= 2.0 / 24.0) { t = new TimeAxisUnit( TimeAxisUnit.MINUTE, 10, new SimpleDateFormat("mm")); } ! else if (days <= 1) t = new TimeAxisUnit( TimeAxisUnit.HOUR, 1, TimeAxisUnit.HOUR, 6, new SimpleDateFormat("HH:mm")); else if(days <= 2) { t = new TimeAxisUnit( TimeAxisUnit.HOUR, 2, new SimpleDateFormat("HH")); *************** *** 795,803 **** t = new TimeAxisUnit( TimeAxisUnit.DAY, 1, new SimpleDateFormat("EEE dd MMM")); } ! else if(days <= 32) { ! t = new TimeAxisUnit( TimeAxisUnit.WEEK, 1, new SimpleDateFormat("'week' ww")); ! } else if(days <= 63) { ! t = new TimeAxisUnit( TimeAxisUnit.WEEK, 2, new SimpleDateFormat("dd")); } else if(days <= 120) { --- 820,831 ---- t = new TimeAxisUnit( TimeAxisUnit.DAY, 1, new SimpleDateFormat("EEE dd MMM")); } ! else if (days <= 32) { ! //t = new TimeAxisUnit( TimeAxisUnit.HOUR, 24, TimeAxisUnit.DAY, 1, new SimpleDateFormat("dd")); ! t = new TimeAxisUnit( TimeAxisUnit.DAY, 1, TimeAxisUnit.WEEK, 1, new SimpleDateFormat("'week' ww")); ! vLabelCentered = true; ! } else if(days <= 63) { ! t = new TimeAxisUnit( TimeAxisUnit.DAY, 1, TimeAxisUnit.WEEK, 1, new SimpleDateFormat("'week' ww")); ! //t = new TimeAxisUnit( TimeAxisUnit.WEEK, 2, new SimpleDateFormat("dd")); } else if(days <= 120) { *************** *** 807,811 **** t = new TimeAxisUnit( TimeAxisUnit.MONTH, 1, new SimpleDateFormat("MMM")); } ! return t.getTimeMarkers( graphDef.getStartTime(), graphDef.getEndTime() ); } --- 835,841 ---- t = new TimeAxisUnit( TimeAxisUnit.MONTH, 1, new SimpleDateFormat("MMM")); } ! ! vLabelGridWidth = t.getMajorGridWidth(); ! return t.getTimeMarkers( graphDef.getStartTime(), graphDef.getEndTime() ); } *************** *** 815,842 **** ValueAxisUnit v = null; - int shifted = 1; double range = upperValue - lowerValue; ! if ( range <= 5 ) ! v = new ValueAxisUnit( 1, 1, 1 ); ! else if ( range <= 20 ) ! v = new ValueAxisUnit( 5d, 2.5, 5 ); ! else if ( range <= 40 ) ! v = new ValueAxisUnit( 5d, 2.5, 5 ); ! else if ( range <= 80 ) ! v = new ValueAxisUnit( 20d, 10d, 20 ); ! else if ( range <= 100 ) ! v = new ValueAxisUnit( 1, 10d, 5, 10d ); ! //v = new ValueAxisUnit( 25d, 12.5, 20 ); ! else if ( range <= 2500 ) ! v = new ValueAxisUnit( 500d, 250d, 500 ); ! else if ( range <= 5000 ) ! v = new ValueAxisUnit( 500d, 125d, 500 ); else ! v = new ValueAxisUnit( 1000d, 500d, 1000 ); - upperValue = v.getNiceHigher( upperValue ); - lowerValue = v.getNiceLower( lowerValue ); - return v.getValueMarkers( lowerValue, upperValue ); } --- 845,873 ---- ValueAxisUnit v = null; double range = upperValue - lowerValue; ! double shifted = ( Math.abs(upperValue) > Math.abs(lowerValue) ? Math.abs(upperValue) : Math.abs(lowerValue) ); ! double mod = 1.0; ! while ( shifted > 10 ) { ! shifted /= 10; ! mod *= 10; ! } ! while ( shifted < 1 ) { ! shifted *= 10; ! mod /= 10; ! } ! ! if ( shifted <= 3 ) ! v = new ValueAxisUnit( 1, 0.2*mod, 1, 1.0*mod ); ! else if ( shifted <= 5 ) ! v = new ValueAxisUnit( 1, 0.5*mod, 1, 1.0*mod ); ! else if ( shifted <= 9 ) ! v = new ValueAxisUnit( 1, 0.5*mod, 1, 2.0*mod ); else ! v = new ValueAxisUnit( 1, 1.0*mod, 1, 5.0*mod ); ! ! upperValue = v.getNiceHigher( upperValue ); ! lowerValue = v.getNiceLower( lowerValue ); return v.getValueMarkers( lowerValue, upperValue ); } Index: ValueAxisUnit.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/ValueAxisUnit.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ValueAxisUnit.java 22 Sep 2003 17:15:17 -0000 1.1 --- ValueAxisUnit.java 25 Sep 2003 21:58:05 -0000 1.2 *************** *** 63,67 **** this.mGridUnit = mGridUnit; this.mGridParts = mGridParts; ! gridStep = gridUnit * gridParts; mGridStep = mGridUnit * mGridParts; --- 63,67 ---- this.mGridUnit = mGridUnit; this.mGridParts = mGridParts; ! gridStep = gridUnit * gridParts; mGridStep = mGridUnit * mGridParts; *************** *** 86,90 **** } - System.out.println( gridStep + "::" + mGridStep ); // Now get all time markers. // Again we choose to use a series of loops as to avoid unnecessary drawing. --- 86,89 ---- *************** *** 147,150 **** --- 146,173 ---- public double getNiceLower( double value ) { + int valueInt = new Double(value).intValue(); + int roundStep = new Double(gridUnit * gridParts).intValue(); + int num = valueInt / roundStep; + int mod = valueInt % roundStep; + double gridValue = (roundStep * (num - 1)) * 1.0d; + if ( gridValue - value < (gridParts * gridUnit) / 4 ) + gridValue -= roundStep; + + roundStep = new Double(mGridUnit * mGridParts).intValue(); + num = valueInt / roundStep; + mod = valueInt % roundStep; + double mGridValue = (roundStep * (num - 1)) * 1.0d; + + if ( value != 0.0d ) + { + if ( mGridValue - gridValue < (mGridParts * mGridUnit) / 2) + return mGridValue; + else + return gridValue; + } + + return value; + + /* int valueInt = new Double(value).intValue(); int num = valueInt / roundStep; *************** *** 155,168 **** return value; } public double getNiceHigher( double value ) { ! int valueInt = new Double(value).intValue(); ! int num = valueInt / roundStep; ! int mod = valueInt % roundStep; if ( value != 0.0d ) ! return (roundStep * (num + 1)) * 1.0d; return value; --- 178,206 ---- return value; + */ } public double getNiceHigher( double value ) { ! int valueInt = new Double(value).intValue(); ! int roundStep = new Double(gridUnit * gridParts).intValue(); ! int num = valueInt / roundStep; ! int mod = valueInt % roundStep; ! double gridValue = (roundStep * (num + 1)) * 1.0d; ! if ( gridValue - value < (gridParts * gridUnit) / 4 ) ! gridValue += roundStep; ! ! roundStep = new Double(mGridUnit * mGridParts).intValue(); ! num = valueInt / roundStep; ! mod = valueInt % roundStep; ! double mGridValue = (roundStep * (num + 1)) * 1.0d; if ( value != 0.0d ) ! { ! if ( mGridValue - gridValue < (mGridParts * mGridUnit) / 2) ! return mGridValue; ! else ! return gridValue; ! } return value; Index: PlotDef.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/PlotDef.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PlotDef.java 22 Sep 2003 17:15:17 -0000 1.2 --- PlotDef.java 25 Sep 2003 21:58:05 -0000 1.3 *************** *** 48,52 **** this.color = color; this.legend = legend; - System.out.println( legend ); } --- 48,51 ---- |
From: <cob...@us...> - 2003-09-25 21:58:11
|
Update of /cvsroot/jrobin/src/jrobin/demo In directory sc8-pr-cvs1:/tmp/cvs-serv4323/src/jrobin/demo Modified Files: JRobinComplexGraph.java Log Message: - value / time axis scaling modified - added hrule legend - fine tuned grid plotting - UNK values don't get drawn anymore - added line widths Index: JRobinComplexGraph.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/demo/JRobinComplexGraph.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JRobinComplexGraph.java 22 Sep 2003 17:15:18 -0000 1.1 --- JRobinComplexGraph.java 25 Sep 2003 21:58:05 -0000 1.2 *************** *** 43,48 **** public static void main(String[] args) { ! GregorianCalendar start = new GregorianCalendar(2003, 7, 21, 23, 59); ! GregorianCalendar end = new GregorianCalendar(2003, 7, 22, 23, 59); RrdGraphDef gDef = new RrdGraphDef(); --- 43,48 ---- public static void main(String[] args) { ! GregorianCalendar start = new GregorianCalendar(2003, 7, 23, 00, 00); ! GregorianCalendar end = new GregorianCalendar(2003, 7, 24, 00, 00); RrdGraphDef gDef = new RrdGraphDef(); *************** *** 74,77 **** --- 74,78 ---- gDef.area("p75t90", new Color(0xff,0x66,0x00), "75 - 90%"); gDef.area("p90t100", new Color(0xcc,0x33,0x00), "90 - 100%"); + gDef.rule(10.0, Color.YELLOW, null); gDef.gprint("busy", "AVERAGE", " Average:@5.1@s%"); gDef.gprint("busy", "LAST", "Current: @5.1@s%"); *************** *** 80,84 **** gDef.comment("Server load\n"); gDef.comment(" "); ! gDef.line("load", new Color(0x00,0x00,0x00), "Load average (5 min)"); //gDef.area("load", Color.RED, " hmm \n"); //gDef.stack("p75t90", Color.GREEN, " hmm \n"); --- 81,85 ---- gDef.comment("Server load\n"); gDef.comment(" "); ! gDef.line("load", new Color(0x00,0x00,0x00), "Load average (5 min)" ); //gDef.area("load", Color.RED, " hmm \n"); //gDef.stack("p75t90", Color.GREEN, " hmm \n"); *************** *** 101,104 **** --- 102,144 ---- RrdGraph graph = new RrdGraph(gDef); graph.saveAsPNG("/zzzzzz.png", 0, 0); + + + // -- New graph + RrdGraphDef gd = new RrdGraphDef(); + gd.setBackColor( Color.WHITE ); + gd.setTimePeriod( start, end ); + gd.datasource("in2", "c:/test.rrd", "ifInOctets", "AVERAGE"); + gd.datasource("out2", "c:/test.rrd", "ifOutOctets", "AVERAGE"); + gd.datasource("in", "in2,8,*"); + gd.datasource("out", "out2,8,*"); + gd.area("in", Color.GREEN, null); + gd.line("out", Color.BLUE, null); + + RrdGraph graph2 = new RrdGraph(gd); + graph2.saveAsPNG("/traff.png", 0, 0); + + ////////////////////////////// + gd = new RrdGraphDef(); + gd.setBackColor( Color.WHITE ); + gd.setTimePeriod( start, end ); + gd.datasource("in2", "c:/test.rrd", "ifInUcastPkts", "AVERAGE"); + gd.datasource("out2", "c:/test.rrd", "ifOutUcastPkts", "AVERAGE"); + gd.datasource("in", "in2,8,*"); + gd.datasource("out", "out2,8,*"); + gd.area("in", Color.GREEN, null); + gd.line("out", Color.BLUE, null); + + graph2 = new RrdGraph(gd); + graph2.saveAsPNG("/pkts.png", 0, 0); + + gd = new RrdGraphDef(); + gd.setBackColor( Color.WHITE ); + gd.setTimePeriod( start, end ); + gd.datasource("ftp", "c:/test.rrd", "ftpUsers", "AVERAGE"); + gd.area("ftp", Color.BLUE, null); + + graph2 = new RrdGraph(gd); + graph2.saveAsPNG("/ftp.png", 0, 0); + //graph.saveAsPNG("c:/demo.png", 495, 200); } |
Update of /cvsroot/jrobin/src/jrobin/core In directory sc8-pr-cvs1:/tmp/cvs-serv26350/jrobin/core Modified Files: ArcState.java Archive.java Datasource.java Header.java RrdDb.java Util.java Added Files: XmlWriter.java Log Message: Removed DOM model for XML export --- NEW FILE: XmlWriter.java --- /* ============================================================ * JRobin : Pure java implementation of RRDTool's functionality * ============================================================ * * Project Info: http://www.sourceforge.net/projects/jrobin * Project Lead: Sasa Markovic (sa...@eu...); * * (C) Copyright 2003, by Sasa Markovic. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */ package jrobin.core; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.text.DecimalFormat; class XmlWriter { static final DecimalFormat df = new DecimalFormat("0.0000000000E00"); static final String INDENT_STR = " "; private PrintWriter writer; private StringBuffer indent = new StringBuffer(""); private Stack openTags = new Stack(); XmlWriter(OutputStream stream) { writer = new PrintWriter(stream); } void startTag(String tag) { writer.println(indent + "<" + tag + ">"); openTags.push(tag); indent.append(INDENT_STR); } void closeTag() { String tag = openTags.pop(); indent.setLength(indent.length() - INDENT_STR.length()); writer.println(indent + "</" + tag + ">"); } void writeTag(String tag, Object value) { writer.println(indent + "<" + tag + ">" + value + "</" + tag + ">"); } void writeTag(String tag, int value) { writeTag(tag, "" + value); } void writeTag(String tag, long value) { writeTag(tag, "" + value); } void writeTag(String tag, double value, String nanString) { if(Double.isNaN(value)) { writeTag(tag, nanString); } else { writeTag(tag, df.format(value)); } } void writeTag(String tag, double value) { writeTag(tag, value, "" + Double.NaN); } void finish() { writer.flush(); } protected void finalize() { writer.close(); } void writeComment(Object comment) { writer.println(indent + "<!-- " + comment + " -->"); } private class Stack { private ArrayList stack = new ArrayList(); void push(String tag) { stack.add(tag); } String pop() { int last = stack.size() - 1; if(last >= 0) { String tag = (String) stack.get(last); stack.remove(last); return tag; } return null; } } } Index: ArcState.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/ArcState.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ArcState.java 4 Sep 2003 13:26:41 -0000 1.1 --- ArcState.java 24 Sep 2003 11:32:24 -0000 1.2 *************** *** 23,29 **** package jrobin.core; - import org.w3c.dom.Document; - import org.w3c.dom.Element; - import java.io.IOException; --- 23,26 ---- *************** *** 79,92 **** } ! void appendXml(Element parent) throws IOException { ! Document doc = parent.getOwnerDocument(); ! Element dsElem = doc.createElement("ds"); ! Element valueElem = doc.createElement("value"); ! valueElem.appendChild(doc.createTextNode(Util.formatDoubleXml(accumValue.get()))); ! Element unknownElem = doc.createElement("unknown_datapoints"); ! unknownElem.appendChild(doc.createTextNode("" + nanSteps.get())); ! parent.appendChild(dsElem); ! dsElem.appendChild(valueElem); ! dsElem.appendChild(unknownElem); } --- 76,84 ---- } ! void appendXml(XmlWriter writer) throws IOException { ! writer.startTag("ds"); ! writer.writeTag("value", accumValue.get()); ! writer.writeTag("unknown_datapoints", nanSteps.get()); ! writer.closeTag(); // ds } Index: Archive.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Archive.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Archive.java 4 Sep 2003 13:26:41 -0000 1.1 --- Archive.java 24 Sep 2003 11:32:24 -0000 1.2 *************** *** 23,30 **** package jrobin.core; - import org.w3c.dom.Document; - import org.w3c.dom.Element; - import org.w3c.dom.Node; - import java.io.IOException; --- 23,26 ---- *************** *** 246,288 **** } ! void appendXml(Element parent) throws IOException { ! Document doc = parent.getOwnerDocument(); ! Element rraElem = doc.createElement("rra"); ! Element cfElem = doc.createElement("cf"); ! cfElem.appendChild(doc.createTextNode(consolFun.get())); ! long arcStep = getArcStep(); ! Node pdpComment = doc.createComment(arcStep + " seconds"); ! Element pdpElem = doc.createElement("pdp_per_row"); ! pdpElem.appendChild(doc.createTextNode("" + steps.get())); ! Element xffElem = doc.createElement("xff"); ! xffElem.appendChild(doc.createTextNode("" + Util.formatDoubleXml(xff.get()))); ! // dump state ! Element cdpElem = doc.createElement("cdp_prep"); for(int i = 0; i < states.length; i++) { ! states[i].appendXml(cdpElem); } ! // put icing on the cake: dump database ! Element dbElem = doc.createElement("database"); long startTime = getStartTime(); for(int i = 0; i < rows.get(); i++) { ! long time = startTime + i * arcStep; ! Node rowComment = doc.createComment(Util.getDate(time) + " / " + time); ! dbElem.appendChild(rowComment); ! Element rowElem = doc.createElement("row"); for(int j = 0; j < robins.length; j++) { ! Element vElem = doc.createElement("v"); ! vElem.appendChild(doc.createTextNode(Util.formatDoubleXml(robins[j].getValue(i)))); ! rowElem.appendChild(vElem); } ! dbElem.appendChild(rowElem); } ! // compose everything ! parent.appendChild(rraElem); ! rraElem.appendChild(cfElem); ! rraElem.appendChild(pdpComment); ! rraElem.appendChild(pdpElem); ! rraElem.appendChild(xffElem); ! rraElem.appendChild(cdpElem); ! rraElem.appendChild(dbElem); } --- 242,269 ---- } ! void appendXml(XmlWriter writer) throws IOException { ! writer.startTag("rra"); ! writer.writeTag("cf", consolFun.get()); ! writer.writeComment(getArcStep() + " seconds"); ! writer.writeTag("pdp_per_row", steps.get()); ! writer.writeTag("xff", xff.get()); ! writer.startTag("cdp_prep"); for(int i = 0; i < states.length; i++) { ! states[i].appendXml(writer); } ! writer.closeTag(); // cdp_prep ! writer.startTag("database"); long startTime = getStartTime(); for(int i = 0; i < rows.get(); i++) { ! long time = startTime + i * getArcStep(); ! writer.writeComment(Util.getDate(time) + " / " + time); ! writer.startTag("row"); for(int j = 0; j < robins.length; j++) { ! writer.writeTag("v", robins[j].getValue(i)); } ! writer.closeTag(); // row } ! writer.closeTag(); // database ! writer.closeTag(); // rra } Index: Datasource.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Datasource.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Datasource.java 4 Sep 2003 13:26:41 -0000 1.1 --- Datasource.java 24 Sep 2003 11:32:24 -0000 1.2 *************** *** 23,30 **** package jrobin.core; - import org.w3c.dom.Document; - import org.w3c.dom.Element; - import org.w3c.dom.Node; - import java.io.IOException; --- 23,26 ---- *************** *** 207,241 **** } ! void appendXml(Element parent) throws IOException { ! Document doc = parent.getOwnerDocument(); ! Element dsElem = doc.createElement("ds"); ! Element nameElem = doc.createElement("name"); ! nameElem.appendChild(doc.createTextNode(dsName.get())); ! Element typeElem = doc.createElement("type"); ! typeElem.appendChild(doc.createTextNode(dsType.get())); ! Element hearbeatElem = doc.createElement("minimal_heartbeat"); ! hearbeatElem.appendChild(doc.createTextNode("" + heartbeat.get())); ! Element minElem = doc.createElement("min"); ! minElem.appendChild(doc.createTextNode(Util.formatDoubleXml(minValue.get()))); ! Element maxElem = doc.createElement("max"); ! maxElem.appendChild(doc.createTextNode(Util.formatDoubleXml(maxValue.get()))); ! Node stateComment = doc.createComment("PDP Status"); ! Element lastDsElem = doc.createElement("last_ds"); ! lastDsElem.appendChild(doc.createTextNode("" + Util.formatDoubleXml(lastValue.get()))); ! Element valueElem = doc.createElement("value"); ! valueElem.appendChild(doc.createTextNode("" + Util.formatDoubleXml(accumValue.get()))); ! Element unknownElem = doc.createElement("unknown_sec"); ! unknownElem.appendChild(doc.createTextNode("" + nanSeconds.get())); ! // compose ! parent.appendChild(dsElem); ! dsElem.appendChild(nameElem); ! dsElem.appendChild(typeElem); ! dsElem.appendChild(hearbeatElem); ! dsElem.appendChild(minElem); ! dsElem.appendChild(maxElem); ! dsElem.appendChild(stateComment); ! dsElem.appendChild(lastDsElem); ! dsElem.appendChild(valueElem); ! dsElem.appendChild(unknownElem); } --- 203,218 ---- } ! void appendXml(XmlWriter writer) throws IOException { ! writer.startTag("ds"); ! writer.writeTag("name", dsName.get()); ! writer.writeTag("type", dsType.get()); ! writer.writeTag("minimal_heartbeat", heartbeat.get()); ! writer.writeTag("min", minValue.get()); ! writer.writeTag("max", maxValue.get()); ! writer.writeComment("PDP Status"); ! writer.writeTag("last_ds", lastValue.get(), "UNKN"); ! writer.writeTag("value", accumValue.get()); ! writer.writeTag("unknown_sec", nanSeconds.get()); ! writer.closeTag(); // ds } Index: Header.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Header.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Header.java 4 Sep 2003 13:26:41 -0000 1.1 --- Header.java 24 Sep 2003 11:32:24 -0000 1.2 *************** *** 23,30 **** package jrobin.core; - import org.w3c.dom.Document; - import org.w3c.dom.Element; - import org.w3c.dom.Node; - import java.io.IOException; --- 23,26 ---- *************** *** 111,129 **** } ! void appendXml(Element parent) throws IOException { ! Document doc = parent.getOwnerDocument(); ! Element versionElem = doc.createElement("version"); ! versionElem.appendChild(doc.createTextNode(RRDTOOL_VERSION)); ! Element stepElem = doc.createElement("step"); ! stepElem.appendChild(doc.createTextNode("" + step.get())); ! Node stepComment = doc.createComment("Seconds"); ! Element lastElem = doc.createElement("lastupdate"); ! lastElem.appendChild(doc.createTextNode("" + lastUpdateTime.get())); ! Node lastComment = doc.createComment("" + Util.getDate(lastUpdateTime.get())); ! parent.appendChild(versionElem); ! parent.appendChild(stepComment); ! parent.appendChild(stepElem); ! parent.appendChild(lastComment); ! parent.appendChild(lastElem); } --- 107,116 ---- } ! void appendXml(XmlWriter writer) throws IOException { ! writer.writeTag("version", RRDTOOL_VERSION); ! writer.writeComment("Seconds"); ! writer.writeTag("step", step.get()); ! writer.writeComment(Util.getDate(lastUpdateTime.get())); ! writer.writeTag("lastupdate", lastUpdateTime.get()); } Index: RrdDb.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/RrdDb.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RrdDb.java 23 Sep 2003 13:39:20 -0000 1.3 --- RrdDb.java 24 Sep 2003 11:32:24 -0000 1.4 *************** *** 23,36 **** package jrobin.core; - import org.w3c.dom.DOMException; - import org.w3c.dom.Document; - import org.w3c.dom.Element; - - import javax.xml.parsers.DocumentBuilder; - import javax.xml.parsers.DocumentBuilderFactory; - import javax.xml.parsers.ParserConfigurationException; - import javax.xml.transform.*; - import javax.xml.transform.dom.DOMSource; - import javax.xml.transform.stream.StreamResult; import java.io.*; --- 23,26 ---- *************** *** 470,519 **** * @param destination Output stream to receive XML data * @throws IOException Thrown in case of I/O related error - * @throws RrdException Thrown in case of JRobin specific error */ ! public synchronized void dumpXml(OutputStream destination) throws IOException, RrdException { ! // create XML document ! DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); ! factory.setValidating(false); ! factory.setNamespaceAware(false); ! try { ! DocumentBuilder builder = factory.newDocumentBuilder(); ! Document doc = builder.newDocument(); ! // create root element ! Element root = doc.createElement("rrd"); ! doc.appendChild(root); ! // dump header ! header.appendXml(root); ! // dump datasources ! for(int i = 0; i < datasources.length; i++) { ! datasources[i].appendXml(root); ! } ! // dump archives ! for(int i = 0; i < archives.length; i++) { ! archives[i].appendXml(root); ! } ! // serialize DOM object ! TransformerFactory tFactory = TransformerFactory.newInstance(); ! Transformer transformer = tFactory.newTransformer(); ! transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); ! transformer.setOutputProperty(OutputKeys.METHOD, "xml"); ! transformer.setOutputProperty(OutputKeys.INDENT, "yes"); ! transformer.setOutputProperty(OutputKeys.MEDIA_TYPE, "text/xml"); ! transformer.setOutputProperty(OutputKeys.STANDALONE, "yes"); ! ! DOMSource source = new DOMSource(root); ! StreamResult result = new StreamResult(destination); ! transformer.transform(source, result); ! } catch (ParserConfigurationException e) { ! throw new RrdException("XML Error: " + e); ! } catch (DOMException e) { ! throw new RrdException("XML Error: " + e); ! } catch (TransformerFactoryConfigurationError e) { ! throw new RrdException("XML Error: " + e); ! } catch (TransformerException e) { ! throw new RrdException("XML Error: " + e); ! } catch (IllegalArgumentException e) { ! throw new RrdException("XML Error: " + e); } } --- 460,479 ---- * @param destination Output stream to receive XML data * @throws IOException Thrown in case of I/O related error */ ! public synchronized void dumpXml(OutputStream destination) throws IOException { ! XmlWriter writer = new XmlWriter(destination); ! writer.startTag("rrd"); ! // dump header ! header.appendXml(writer); ! // dump datasources ! for(int i = 0; i < datasources.length; i++) { ! datasources[i].appendXml(writer); ! } ! // dump archives ! for(int i = 0; i < archives.length; i++) { ! archives[i].appendXml(writer); } + writer.closeTag(); + writer.finish(); } *************** *** 553,557 **** public synchronized void dumpXml(String filename) throws IOException, RrdException { - // OutputStream destination = new BufferedOutputStream(new FileOutputStream(filename, false)); OutputStream destination = new BufferedOutputStream(new FileOutputStream(filename, false)); dumpXml(destination); --- 513,516 ---- Index: Util.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Util.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Util.java 23 Sep 2003 08:31:34 -0000 1.2 --- Util.java 24 Sep 2003 11:32:24 -0000 1.3 *************** *** 94,104 **** } - static String formatDoubleXml(double x) { - if(Double.isNaN(x)) { - return "" + Double.NaN; - } - return df.format(x); - } - static void debug(String message) { if(RrdDb.DEBUG) { --- 94,97 ---- |
From: <sa...@us...> - 2003-09-23 13:39:25
|
Update of /cvsroot/jrobin/src/jrobin/graph In directory sc8-pr-cvs1:/tmp/cvs-serv13583/jrobin/graph Modified Files: Def.java Source.java ValueExtractor.java Log Message: BUGFIX: removed problem with the last point int the graph - was NaN in most cases Index: Def.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/Def.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Def.java 4 Sep 2003 13:27:14 -0000 1.1 --- Def.java 23 Sep 2003 13:39:21 -0000 1.2 *************** *** 49,53 **** void setInterval(long start, long end) throws RrdException, IOException { RrdDb rrd = new RrdDb(rrdPath); ! FetchRequest request = rrd.createFetchRequest(consolFun, start, end); FetchPoint[] fetchPoints = request.fetch(); int numPoints = fetchPoints.length; --- 49,54 ---- void setInterval(long start, long end) throws RrdException, IOException { RrdDb rrd = new RrdDb(rrdPath); ! long rrdStep = rrd.getRrdDef().getStep(); ! FetchRequest request = rrd.createFetchRequest(consolFun, start, end + rrdStep); FetchPoint[] fetchPoints = request.fetch(); int numPoints = fetchPoints.length; Index: Source.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/Source.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Source.java 4 Sep 2003 13:27:14 -0000 1.1 --- Source.java 23 Sep 2003 13:39:21 -0000 1.2 *************** *** 33,41 **** abstract class Source { protected String name = ""; ! private double min; ! private double max; ! private double last; ! private double sum; ! private int count; private RrdTimeSeries series; --- 33,41 ---- abstract class Source { protected String name = ""; ! ! private long lastTime, totalTime; ! private double aggMin, aggMax, aggLast; ! private double lastValue, totalValue; ! private RrdTimeSeries series; *************** *** 59,63 **** double value = getValue(timestamp, values); series.add(timestamp, value); ! aggregate(value); values.add(name, value); return value; --- 59,63 ---- double value = getValue(timestamp, values); series.add(timestamp, value); ! aggregate(timestamp, value); values.add(name, value); return value; *************** *** 69,88 **** } ! private void aggregate(double value) { ! min = Util.min(min, value); ! max = Util.max(max, value); ! last = value; ! if(!Double.isNaN(value)) { ! sum += value; ! count++; } } private void reset() { ! min = Double.NaN; ! max = Double.NaN; ! last = Double.NaN; ! sum = 0.0; ! count = 0; series = new RrdTimeSeries(name); } --- 69,90 ---- } ! private void aggregate(long time, double value) { ! aggMin = Util.min(aggMin, value); ! aggMax = Util.max(aggMax, value); ! aggLast = value; ! if(!Double.isNaN(lastValue) && !Double.isNaN(value)) { ! long dt = time - lastTime; ! totalValue += dt * (value + lastValue) / 2.0; ! totalTime += dt; } + lastTime = time; + lastValue = value; } private void reset() { ! lastTime = totalTime = 0; ! aggMin = aggMax = aggLast = lastValue = Double.NaN; ! totalValue = 0.0; ! series = new RrdTimeSeries(name); } *************** *** 90,104 **** double getAggregate(String consolFun) throws RrdException { if(consolFun.equals("MAX")) { ! return max; } else if(consolFun.equals("MIN")) { ! return min; } else if(consolFun.equals("LAST")) { ! return last; } else if(consolFun.equals("AVERAGE")) { ! if(count > 0) { ! return sum / count; } else { --- 92,106 ---- double getAggregate(String consolFun) throws RrdException { if(consolFun.equals("MAX")) { ! return aggMax; } else if(consolFun.equals("MIN")) { ! return aggMin; } else if(consolFun.equals("LAST")) { ! return aggLast; } else if(consolFun.equals("AVERAGE")) { ! if(totalTime > 0) { ! return totalValue / totalTime; } else { Index: ValueExtractor.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/graph/ValueExtractor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ValueExtractor.java 4 Sep 2003 13:27:14 -0000 1.1 --- ValueExtractor.java 23 Sep 2003 13:39:21 -0000 1.2 *************** *** 27,35 **** class ValueExtractor { private DataPoint[] points; private int pos = 0; ValueExtractor(DataPoint[] points) throws RrdException { this.points = points; ! if(points.length < 2) { throw new RrdException("At least two datapoints are required"); } --- 27,37 ---- class ValueExtractor { private DataPoint[] points; + private int numPoints; private int pos = 0; ValueExtractor(DataPoint[] points) throws RrdException { this.points = points; ! this.numPoints = points.length; ! if(numPoints < 2) { throw new RrdException("At least two datapoints are required"); } *************** *** 40,44 **** throw new RrdException("Backward reading not allowed"); } ! while(pos < points.length - 1) { if(points[pos].getTime() <= timestamp && timestamp < points[pos + 1].getTime()) { return points[pos + 1].getValue(); --- 42,46 ---- throw new RrdException("Backward reading not allowed"); } ! while(pos < numPoints - 1) { if(points[pos].getTime() <= timestamp && timestamp < points[pos + 1].getTime()) { return points[pos + 1].getValue(); |
From: <sa...@us...> - 2003-09-23 13:39:24
|
Update of /cvsroot/jrobin/src/jrobin/core In directory sc8-pr-cvs1:/tmp/cvs-serv13583/jrobin/core Modified Files: RrdDb.java Log Message: BUGFIX: removed problem with the last point int the graph - was NaN in most cases Index: RrdDb.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/RrdDb.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RrdDb.java 22 Sep 2003 14:57:27 -0000 1.2 --- RrdDb.java 23 Sep 2003 13:39:20 -0000 1.3 *************** *** 553,557 **** public synchronized void dumpXml(String filename) throws IOException, RrdException { ! OutputStream destination = new BufferedOutputStream(new FileOutputStream(filename, false)); dumpXml(destination); destination.close(); --- 553,558 ---- public synchronized void dumpXml(String filename) throws IOException, RrdException { ! // OutputStream destination = new BufferedOutputStream(new FileOutputStream(filename, false)); ! OutputStream destination = new BufferedOutputStream(new FileOutputStream(filename, false)); dumpXml(destination); destination.close(); |
From: <sa...@us...> - 2003-09-23 08:31:44
|
Update of /cvsroot/jrobin/src/jrobin/core In directory sc8-pr-cvs1:/tmp/cvs-serv26114/jrobin/core Modified Files: Util.java Log Message: Added single whitespace, just to check if CVS sends email when the repository is updated Index: Util.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Util.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Util.java 4 Sep 2003 13:26:41 -0000 1.1 --- Util.java 23 Sep 2003 08:31:34 -0000 1.2 *************** *** 27,31 **** /** ! * Class defines various utility functions used in JRobin. * * @author <a href="mailto:sa...@eu...">Sasa Markovic</a> --- 27,31 ---- /** ! * Class defines various utility functions used in JRobin. * * @author <a href="mailto:sa...@eu...">Sasa Markovic</a> |