Update of /cvsroot/jrobin/src/org/jrobin/graph In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9082/org/jrobin/graph Modified Files: Area.java CommentText.java Def.java GifEncoder.java ImageWorker.java LegendComposer.java Line.java Normalizer.java PathIterator.java PrintText.java RrdGraph.java RrdGraphConstants.java RrdGraphDef.java RrdGraphDefTemplate.java RrdGraphInfo.java Source.java Stack.java TimeAxis.java ValueAxis.java ValueAxisLogarithmic.java ValueAxisMrtg.java ValueScaler.java Added Files: CDef.java PDef.java SDef.java Log Message: Adding the new 1.5.4 code Index: ValueAxis.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueAxis.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ValueAxis.java 6 Sep 2005 20:40:55 -0000 1.1.1.1 --- ValueAxis.java 21 Dec 2006 18:02:44 -0000 1.2 *************** *** 31,47 **** class ValueAxis implements RrdGraphConstants { private static final YLab[] ylab = { ! new YLab(0.1, 1, 2, 5, 10), ! new YLab(0.2, 1, 5, 10, 20), ! new YLab(0.5, 1, 2, 4, 10), ! new YLab(1.0, 1, 2, 5, 10), ! new YLab(2.0, 1, 5, 10, 20), ! new YLab(5.0, 1, 2, 4, 10), ! new YLab(10.0, 1, 2, 5, 10), ! new YLab(20.0, 1, 5, 10, 20), ! new YLab(50.0, 1, 2, 4, 10), ! new YLab(100.0, 1, 2, 5, 10), ! new YLab(200.0, 1, 5, 10, 20), ! new YLab(500.0, 1, 2, 4, 10), ! new YLab(0.0, 0, 0, 0, 0) }; --- 31,47 ---- class ValueAxis implements RrdGraphConstants { private static final YLab[] ylab = { ! new YLab(0.1, 1, 2, 5, 10), ! new YLab(0.2, 1, 5, 10, 20), ! new YLab(0.5, 1, 2, 4, 10), ! new YLab(1.0, 1, 2, 5, 10), ! new YLab(2.0, 1, 5, 10, 20), ! new YLab(5.0, 1, 2, 4, 10), ! new YLab(10.0, 1, 2, 5, 10), ! new YLab(20.0, 1, 5, 10, 20), ! new YLab(50.0, 1, 2, 4, 10), ! new YLab(100.0, 1, 2, 5, 10), ! new YLab(200.0, 1, 5, 10, 20), ! new YLab(500.0, 1, 2, 4, 10), ! new YLab(0.0, 0, 0, 0, 0) }; *************** *** 159,166 **** } else { ! graph_label = Util.sprintf("%4.0f %c", scaledstep * i, im.symbol); } } ! int length = (int)(worker.getStringWidth(graph_label, font)); worker.drawString(graph_label, x0 - length - PADDING_VLABEL, y + labelOffset, font, fontColor); worker.drawLine(x0 - 2, y, x0 + 2, y, mGridColor, TICK_STROKE); --- 159,166 ---- } else { ! graph_label = Util.sprintf("%4.0f %c", scaledstep * i, im.symbol); } } ! int length = (int) (worker.getStringWidth(graph_label, font)); worker.drawString(graph_label, x0 - length - PADDING_VLABEL, y + labelOffset, font, fontColor); worker.drawLine(x0 - 2, y, x0 + 2, y, mGridColor, TICK_STROKE); *************** *** 184,188 **** YLab(double grid, int lfac1, int lfac2, int lfac3, int lfac4) { this.grid = grid; ! lfac = new int[]{lfac1, lfac2, lfac3, lfac4}; } } --- 184,188 ---- YLab(double grid, int lfac1, int lfac2, int lfac3, int lfac4) { this.grid = grid; ! lfac = new int[] {lfac1, lfac2, lfac3, lfac4}; } } --- NEW FILE: SDef.java --- /* ============================================================ * JRobin : Pure java implementation of RRDTool's functionality * ============================================================ * * Project Info: http://www.jrobin.org * Project Lead: Sasa Markovic (sa...@jr...) * * Developers: Sasa Markovic (sa...@jr...) * * * (C) Copyright 2003-2005, 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 org.jrobin.graph; import org.jrobin.data.DataProcessor; class SDef extends Source { private String defName, consolFun; SDef(String name, String defName, String consolFun) { super(name); this.defName = defName; this.consolFun = consolFun; } void requestData(DataProcessor dproc) { dproc.addDatasource(name, defName, consolFun); } } Index: ImageWorker.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ImageWorker.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ImageWorker.java 6 Sep 2005 20:40:55 -0000 1.1.1.1 --- ImageWorker.java 21 Dec 2006 18:02:43 -0000 1.2 *************** *** 49,53 **** void resize(int width, int height) { ! if(gd != null) { gd.dispose(); } --- 49,53 ---- void resize(int width, int height) { ! if (gd != null) { gd.dispose(); } *************** *** 87,94 **** gd.setPaint(paint); PathIterator path = new PathIterator(yTop); ! for(int[] pos = path.getNextPath(); pos != null; pos = path.getNextPath()) { int start = pos[0], end = pos[1], n = end - start; int[] xDev = new int[n + 2], yDev = new int[n + 2]; ! for(int i = start; i < end; i++) { xDev[i - start] = (int) x[i]; yDev[i - start] = (int) yTop[i]; --- 87,94 ---- gd.setPaint(paint); PathIterator path = new PathIterator(yTop); ! for (int[] pos = path.getNextPath(); pos != null; pos = path.getNextPath()) { int start = pos[0], end = pos[1], n = end - start; int[] xDev = new int[n + 2], yDev = new int[n + 2]; ! for (int i = start; i < end; i++) { xDev[i - start] = (int) x[i]; yDev[i - start] = (int) yTop[i]; *************** *** 105,112 **** gd.setPaint(paint); PathIterator path = new PathIterator(yTop); ! for(int[] pos = path.getNextPath(); pos != null; pos = path.getNextPath()) { int start = pos[0], end = pos[1], n = end - start; int[] xDev = new int[n * 2], yDev = new int[n * 2]; ! for(int i = start; i < end; i++) { int ix1 = i - start, ix2 = n * 2 - 1 - i + start; xDev[ix1] = xDev[ix2] = (int) x[i]; --- 105,112 ---- gd.setPaint(paint); PathIterator path = new PathIterator(yTop); ! for (int[] pos = path.getNextPath(); pos != null; pos = path.getNextPath()) { int start = pos[0], end = pos[1], n = end - start; int[] xDev = new int[n * 2], yDev = new int[n * 2]; ! for (int i = start; i < end; i++) { int ix1 = i - start, ix2 = n * 2 - 1 - i + start; xDev[ix1] = xDev[ix2] = (int) x[i]; *************** *** 136,143 **** gd.setStroke(stroke); PathIterator path = new PathIterator(y); ! for(int[] pos = path.getNextPath(); pos != null; pos = path.getNextPath()) { int start = pos[0], end = pos[1]; int[] xDev = new int[end - start], yDev = new int[end - start]; ! for(int i = start; i < end; i++) { xDev[i - start] = (int) x[i]; yDev[i - start] = (int) y[i]; --- 136,143 ---- gd.setStroke(stroke); PathIterator path = new PathIterator(y); ! for (int[] pos = path.getNextPath(); pos != null; pos = path.getNextPath()) { int start = pos[0], end = pos[1]; int[] xDev = new int[end - start], yDev = new int[end - start]; ! for (int i = start; i < end; i++) { xDev[i - start] = (int) x[i]; yDev[i - start] = (int) y[i]; *************** *** 164,168 **** double getStringWidth(String text, Font font) { ! return font.getStringBounds(text, 0, text.length(), gd.getFontRenderContext()).getBounds().getWidth(); } --- 164,168 ---- double getStringWidth(String text, Font font) { ! return font.getStringBounds(text, 0, text.length(), gd.getFontRenderContext()).getBounds().getWidth(); } *************** *** 177,188 **** void saveImage(OutputStream stream, String type, float quality) throws IOException { ! if(type.equalsIgnoreCase("png")) { ImageIO.write(img, "png", stream); } ! else if(type.equalsIgnoreCase("gif")) { GifEncoder gifEncoder = new GifEncoder(img); gifEncoder.encode(stream); } ! else if(type.equalsIgnoreCase("jpg") || type.equalsIgnoreCase("jpeg")) { JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(stream); JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(img); --- 177,188 ---- void saveImage(OutputStream stream, String type, float quality) throws IOException { ! if (type.equalsIgnoreCase("png")) { ImageIO.write(img, "png", stream); } ! else if (type.equalsIgnoreCase("gif")) { GifEncoder gifEncoder = new GifEncoder(img); gifEncoder.encode(stream); } ! else if (type.equalsIgnoreCase("jpg") || type.equalsIgnoreCase("jpeg")) { JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(stream); JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(img); --- NEW FILE: CDef.java --- /* ============================================================ * JRobin : Pure java implementation of RRDTool's functionality * ============================================================ * * Project Info: http://www.jrobin.org * Project Lead: Sasa Markovic (sa...@jr...) * * Developers: Sasa Markovic (sa...@jr...) * * * (C) Copyright 2003-2005, 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 org.jrobin.graph; import org.jrobin.data.DataProcessor; class CDef extends Source { private final String rpnExpression; CDef(String name, String rpnExpression) { super(name); this.rpnExpression = rpnExpression; } void requestData(DataProcessor dproc) { dproc.addDatasource(name, rpnExpression); } } Index: ValueAxisLogarithmic.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueAxisLogarithmic.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ValueAxisLogarithmic.java 6 Sep 2005 20:40:55 -0000 1.1.1.1 --- ValueAxisLogarithmic.java 21 Dec 2006 18:02:44 -0000 1.2 *************** *** 31,42 **** class ValueAxisLogarithmic implements RrdGraphConstants { private static final double[][] yloglab = { ! {1e9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, ! {1e3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, ! {1e1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, ! /* { 1e1, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, */ ! {1e1, 1, 2.5, 5, 7.5, 0, 0, 0, 0, 0, 0, 0}, ! {1e1, 1, 2, 4, 6, 8, 0, 0, 0, 0, 0, 0}, ! {1e1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0}, ! {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; --- 31,42 ---- class ValueAxisLogarithmic implements RrdGraphConstants { private static final double[][] yloglab = { ! {1e9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, ! {1e3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, ! {1e1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, ! /* { 1e1, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, */ ! {1e1, 1, 2.5, 5, 7.5, 0, 0, 0, 0, 0, 0, 0}, ! {1e1, 1, 2, 4, 6, 8, 0, 0, 0, 0, 0, 0}, ! {1e1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0}, ! {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; *************** *** 88,92 **** value <= im.maxval; value *= yloglab[minoridx][0]) { ! if (value < im.minval) continue; int i = 0; while (yloglab[minoridx][++i] > 0) { --- 88,94 ---- value <= im.maxval; value *= yloglab[minoridx][0]) { ! if (value < im.minval) { ! continue; ! } int i = 0; while (yloglab[minoridx][++i] > 0) { Index: ValueAxisMrtg.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueAxisMrtg.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ValueAxisMrtg.java 6 Sep 2005 20:40:55 -0000 1.1.1.1 --- ValueAxisMrtg.java 21 Dec 2006 18:02:44 -0000 1.2 *************** *** 58,62 **** } else { ! labfmt = Util.sprintf("%%4.%df", 1 - ((im.scaledstep / im.magfact > 10.0 || Math.ceil(im.scaledstep / im.magfact) == im.scaledstep / im.magfact)? 1: 0)); } if (im.symbol != ' ' || im.unit != null) { --- 58,62 ---- } else { ! labfmt = Util.sprintf("%%4.%df", 1 - ((im.scaledstep / im.magfact > 10.0 || Math.ceil(im.scaledstep / im.magfact) == im.scaledstep / im.magfact) ? 1 : 0)); } if (im.symbol != ' ' || im.unit != null) { *************** *** 73,77 **** if (y >= im.yorigin - im.ysize && y <= im.yorigin) { String graph_label = Util.sprintf(labfmt, im.scaledstep / im.magfact * (i - im.quadrant)); ! int length = (int)(worker.getStringWidth(graph_label, font)); worker.drawString(graph_label, xLeft - length - PADDING_VLABEL, y + labelOffset, font, fontColor); worker.drawLine(xLeft - 2, y, xLeft + 2, y, mGridColor, TICK_STROKE); --- 73,77 ---- if (y >= im.yorigin - im.ysize && y <= im.yorigin) { String graph_label = Util.sprintf(labfmt, im.scaledstep / im.magfact * (i - im.quadrant)); ! int length = (int) (worker.getStringWidth(graph_label, font)); worker.drawString(graph_label, xLeft - length - PADDING_VLABEL, y + labelOffset, font, fontColor); worker.drawLine(xLeft - 2, y, xLeft + 2, y, mGridColor, TICK_STROKE); Index: Def.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Def.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Def.java 9 Jul 2004 12:22:15 -0000 1.3 --- Def.java 21 Dec 2006 18:02:43 -0000 1.4 *************** *** 1,66 **** ! /* ============================================================ ! * JRobin : Pure java implementation of RRDTool's functionality ! * ============================================================ ! * ! * Project Info: http://www.jrobin.org ! * Project Lead: Sasa Markovic (sa...@jr...) ! * ! * Developers: Sasa Markovic (sa...@jr...) ! * Arne Vandamme (cob...@jr...) ! * ! * (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 org.jrobin.graph; ! ! /** ! * <p>Represents a fetched datasource for a graph. A Def collects all his datavalues from an existing ! * RRD file.</p> ! * ! * @author Arne Vandamme (cob...@jr...) ! */ ! class Def extends Source ! { ! // ================================================================ ! // -- Constructors ! // ================================================================ ! /** ! * Constructs a new Def object holding a number of fetched datapoints for a graph. ! * @param name Name of the datasource in the graph definition. ! * @param numPoints Number of points used as graph resolution (size of the value table). ! */ ! Def( String name, int numPoints, int aggregatePoints ) ! { ! super(name); ! values = new double[ numPoints ]; ! this.aggregatePoints = aggregatePoints; ! } ! ! ! // ================================================================ ! // -- Protected methods ! // ================================================================ ! /** ! * Sets the value of a specific datapoint for this Def. ! * @param pos Position (index in the value table) of the new datapoint. ! * @param timestamp Timestamp of the new datapoint in number of seconds. ! * @param val Double value of the new datapoint. ! */ ! void set( int pos, long timestamp, double val ) ! { ! super.set( pos, timestamp, val ); ! values[pos] = val; ! } ! ! } --- 1,53 ---- ! /* ============================================================ ! * JRobin : Pure java implementation of RRDTool's functionality ! * ============================================================ ! * ! * Project Info: http://www.jrobin.org ! * Project Lead: Sasa Markovic (sa...@jr...) ! * ! * Developers: Sasa Markovic (sa...@jr...) ! * ! * ! * (C) Copyright 2003-2005, 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 org.jrobin.graph; ! ! import org.jrobin.data.DataProcessor; ! ! class Def extends Source { ! private final String rrdPath, dsName, consolFun, backend; ! ! Def(String name, String rrdPath, String dsName, String consolFun) { ! this(name, rrdPath, dsName, consolFun, null); ! } ! ! Def(String name, String rrdPath, String dsName, String consolFun, String backend) { ! super(name); ! this.rrdPath = rrdPath; ! this.dsName = dsName; ! this.consolFun = consolFun; ! this.backend = backend; ! } ! ! void requestData(DataProcessor dproc) { ! if (backend == null) { ! dproc.addDatasource(name, rrdPath, dsName, consolFun); ! } ! else { ! dproc.addDatasource(name, rrdPath, dsName, consolFun, backend); ! } ! } ! } Index: RrdGraphConstants.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraphConstants.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** RrdGraphConstants.java 6 Sep 2005 20:40:55 -0000 1.1.1.1 --- RrdGraphConstants.java 21 Dec 2006 18:02:44 -0000 1.2 *************** *** 33,192 **** */ public interface RrdGraphConstants { ! /** Default graph starting time */ String DEFAULT_START = "end-1d"; ! /** Default graph ending time */ String DEFAULT_END = "now"; ! /** Constant to represent second */ int SECOND = Calendar.SECOND; ! /** Constant to represent minute */ int MINUTE = Calendar.MINUTE; ! /** Constant to represent hour */ int HOUR = Calendar.HOUR_OF_DAY; ! /** Constant to represent day */ int DAY = Calendar.DAY_OF_MONTH; ! /** Constant to represent week */ int WEEK = Calendar.WEEK_OF_YEAR; ! /** Constant to represent month */ int MONTH = Calendar.MONTH; ! /** Constant to represent year */ int YEAR = Calendar.YEAR; ! /** Constant to represent Monday */ int MONDAY = Calendar.MONDAY; ! /** Constant to represent Tuesday */ int TUESDAY = Calendar.TUESDAY; ! /** Constant to represent Wednesday */ int WEDNESDAY = Calendar.WEDNESDAY; ! /** Constant to represent Thursday */ int THURSDAY = Calendar.THURSDAY; ! /** Constant to represent Friday */ int FRIDAY = Calendar.FRIDAY; ! /** Constant to represent Saturday */ int SATURDAY = Calendar.SATURDAY; ! /** Constant to represent Sunday */ int SUNDAY = Calendar.SUNDAY; ! /** Index of the canvas color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} */ int COLOR_CANVAS = 0; ! /** Index of the background color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} */ int COLOR_BACK = 1; ! /** Index of the top-left graph shade color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} */ int COLOR_SHADEA = 2; ! /** Index of the bottom-right graph shade color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} */ int COLOR_SHADEB = 3; ! /** Index of the minor grid color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} */ int COLOR_GRID = 4; ! /** Index of the major grid color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} */ int COLOR_MGRID = 5; ! /** Index of the font color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} */ int COLOR_FONT = 6; ! /** Index of the frame color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} */ int COLOR_FRAME = 7; ! /** Index of the arrow color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} */ int COLOR_ARROW = 8; ! /** Allowed color names which can be used in {@link RrdGraphDef#setColor(String, java.awt.Paint)} method */ String[] COLOR_NAMES = { ! "canvas", "back", "shadea", "shadeb", "grid", "mgrid", "font", "frame", "arrow" }; ! /** Default first day of the week (obtained from the default locale) */ int FIRST_DAY_OF_WEEK = Calendar.getInstance(Locale.getDefault()).getFirstDayOfWeek(); ! /** Default graph canvas color */ Color DEFAULT_CANVAS_COLOR = Color.WHITE; ! /** Default graph background color */ Color DEFAULT_BACK_COLOR = new Color(245, 245, 245); ! /** Default top-left graph shade color */ Color DEFAULT_SHADEA_COLOR = new Color(200, 200, 200); ! /** Default bottom-right graph shade color */ Color DEFAULT_SHADEB_COLOR = new Color(150, 150, 150); ! /** Default minor grid color */ Color DEFAULT_GRID_COLOR = new Color(140, 140, 140); ! /** Default major grid color */ Color DEFAULT_MGRID_COLOR = new Color(130, 30, 30); ! /** Default font color */ Color DEFAULT_FONT_COLOR = Color.BLACK; ! /** Default frame color */ Color DEFAULT_FRAME_COLOR = Color.BLACK; ! /** Default arrow color */ Color DEFAULT_ARROW_COLOR = Color.RED; ! /** Constant to represent left alignment marker */ String ALIGN_LEFT_MARKER = "\\l"; ! /** Constant to represent centered alignment marker */ String ALIGN_CENTER_MARKER = "\\c"; ! /** Constant to represent right alignment marker */ String ALIGN_RIGHT_MARKER = "\\r"; ! /** Constant to represent justified alignment marker */ String ALIGN_JUSTIFIED_MARKER = "\\j"; ! /** Constant to represent "glue" marker */ String GLUE_MARKER = "\\g"; ! /** Constant to represent vertical spacing marker */ String VERTICAL_SPACING_MARKER = "\\s"; ! /** Constant to represent no justification markers */ String NO_JUSTIFICATION_MARKER = "\\J"; ! /** Used internally */ String[] MARKERS = { ! ALIGN_LEFT_MARKER, ALIGN_CENTER_MARKER, ALIGN_RIGHT_MARKER, ! ALIGN_JUSTIFIED_MARKER, GLUE_MARKER, VERTICAL_SPACING_MARKER, NO_JUSTIFICATION_MARKER }; ! /** Constant to represent in-memory image name */ String IN_MEMORY_IMAGE = "-"; ! /** Default units length */ int DEFAULT_UNITS_LENGTH = 9; ! /** Default graph width */ int DEFAULT_WIDTH = 400; ! /** Default graph height */ int DEFAULT_HEIGHT = 100; ! /** Default image format */ String DEFAULT_IMAGE_FORMAT = "gif"; ! /** Default image quality, used only for jpeg graphs */ float DEFAULT_IMAGE_QUALITY = 0.8F; // only for jpegs, not used for png/gif ! /** Default value base */ double DEFAULT_BASE = 1000; ! /** Default font name, determined based on the current operating system */ String DEFAULT_FONT_NAME = System.getProperty("os.name").toLowerCase().contains("windows") ? "Lucida Sans Typewriter" : "Monospaced"; ! /** Default graph small font */ Font DEFAULT_SMALL_FONT = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10); ! /** Default graph large font */ Font DEFAULT_LARGE_FONT = new Font(DEFAULT_FONT_NAME, Font.BOLD, 12); ! /** Used internally */ double LEGEND_LEADING = 1.2; // chars ! /** Used internally */ double LEGEND_LEADING_SMALL = 0.7; // chars ! /** Used internally */ double LEGEND_BOX_SPACE = 1.2; // chars ! /** Used internally */ double LEGEND_BOX = 0.9; // chars ! /** Used internally */ int LEGEND_INTERSPACING = 2; // chars ! /** Used internally */ int PADDING_LEFT = 10; // pix ! /** Used internally */ int PADDING_TOP = 12; // pix ! /** Used internally */ int PADDING_TITLE = 6; // pix ! /** Used internally */ int PADDING_RIGHT = 16; // pix ! /** Used internally */ int PADDING_PLOT = 2; //chars ! /** Used internally */ int PADDING_LEGEND = 2; // chars ! /** Used internally */ int PADDING_BOTTOM = 6; // pix ! /** Used internally */ int PADDING_VLABEL = 7; // pix ! /** Stroke used to draw grid */ Stroke GRID_STROKE = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, new float[] {1, 1}, 0); ! /** Stroke used to draw ticks */ Stroke TICK_STROKE = new BasicStroke(1); } --- 33,330 ---- */ public interface RrdGraphConstants { ! /** ! * Default graph starting time ! */ String DEFAULT_START = "end-1d"; ! /** ! * Default graph ending time ! */ String DEFAULT_END = "now"; ! /** ! * Constant to represent second ! */ int SECOND = Calendar.SECOND; ! /** ! * Constant to represent minute ! */ int MINUTE = Calendar.MINUTE; ! /** ! * Constant to represent hour ! */ int HOUR = Calendar.HOUR_OF_DAY; ! /** ! * Constant to represent day ! */ int DAY = Calendar.DAY_OF_MONTH; ! /** ! * Constant to represent week ! */ int WEEK = Calendar.WEEK_OF_YEAR; ! /** ! * Constant to represent month ! */ int MONTH = Calendar.MONTH; ! /** ! * Constant to represent year ! */ int YEAR = Calendar.YEAR; ! /** ! * Constant to represent Monday ! */ int MONDAY = Calendar.MONDAY; ! /** ! * Constant to represent Tuesday ! */ int TUESDAY = Calendar.TUESDAY; ! /** ! * Constant to represent Wednesday ! */ int WEDNESDAY = Calendar.WEDNESDAY; ! /** ! * Constant to represent Thursday ! */ int THURSDAY = Calendar.THURSDAY; ! /** ! * Constant to represent Friday ! */ int FRIDAY = Calendar.FRIDAY; ! /** ! * Constant to represent Saturday ! */ int SATURDAY = Calendar.SATURDAY; ! /** ! * Constant to represent Sunday ! */ int SUNDAY = Calendar.SUNDAY; ! /** ! * Index of the canvas color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} ! */ int COLOR_CANVAS = 0; ! /** ! * Index of the background color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} ! */ int COLOR_BACK = 1; ! /** ! * Index of the top-left graph shade color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} ! */ int COLOR_SHADEA = 2; ! /** ! * Index of the bottom-right graph shade color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} ! */ int COLOR_SHADEB = 3; ! /** ! * Index of the minor grid color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} ! */ int COLOR_GRID = 4; ! /** ! * Index of the major grid color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} ! */ int COLOR_MGRID = 5; ! /** ! * Index of the font color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} ! */ int COLOR_FONT = 6; ! /** ! * Index of the frame color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} ! */ int COLOR_FRAME = 7; ! /** ! * Index of the arrow color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)} ! */ int COLOR_ARROW = 8; ! /** ! * Allowed color names which can be used in {@link RrdGraphDef#setColor(String, java.awt.Paint)} method ! */ String[] COLOR_NAMES = { ! "canvas", "back", "shadea", "shadeb", "grid", "mgrid", "font", "frame", "arrow" }; ! /** ! * Default first day of the week (obtained from the default locale) ! */ int FIRST_DAY_OF_WEEK = Calendar.getInstance(Locale.getDefault()).getFirstDayOfWeek(); ! /** ! * Default graph canvas color ! */ Color DEFAULT_CANVAS_COLOR = Color.WHITE; ! /** ! * Default graph background color ! */ Color DEFAULT_BACK_COLOR = new Color(245, 245, 245); ! /** ! * Default top-left graph shade color ! */ Color DEFAULT_SHADEA_COLOR = new Color(200, 200, 200); ! /** ! * Default bottom-right graph shade color ! */ Color DEFAULT_SHADEB_COLOR = new Color(150, 150, 150); ! /** ! * Default minor grid color ! */ Color DEFAULT_GRID_COLOR = new Color(140, 140, 140); ! /** ! * Default major grid color ! */ Color DEFAULT_MGRID_COLOR = new Color(130, 30, 30); ! /** ! * Default font color ! */ Color DEFAULT_FONT_COLOR = Color.BLACK; ! /** ! * Default frame color ! */ Color DEFAULT_FRAME_COLOR = Color.BLACK; ! /** ! * Default arrow color ! */ Color DEFAULT_ARROW_COLOR = Color.RED; ! /** ! * Constant to represent left alignment marker ! */ String ALIGN_LEFT_MARKER = "\\l"; ! /** ! * Constant to represent centered alignment marker ! */ String ALIGN_CENTER_MARKER = "\\c"; ! /** ! * Constant to represent right alignment marker ! */ String ALIGN_RIGHT_MARKER = "\\r"; ! /** ! * Constant to represent justified alignment marker ! */ String ALIGN_JUSTIFIED_MARKER = "\\j"; ! /** ! * Constant to represent "glue" marker ! */ String GLUE_MARKER = "\\g"; ! /** ! * Constant to represent vertical spacing marker ! */ String VERTICAL_SPACING_MARKER = "\\s"; ! /** ! * Constant to represent no justification markers ! */ String NO_JUSTIFICATION_MARKER = "\\J"; ! /** ! * Used internally ! */ String[] MARKERS = { ! ALIGN_LEFT_MARKER, ALIGN_CENTER_MARKER, ALIGN_RIGHT_MARKER, ! ALIGN_JUSTIFIED_MARKER, GLUE_MARKER, VERTICAL_SPACING_MARKER, NO_JUSTIFICATION_MARKER }; ! /** ! * Constant to represent in-memory image name ! */ String IN_MEMORY_IMAGE = "-"; ! /** ! * Default units length ! */ int DEFAULT_UNITS_LENGTH = 9; ! /** ! * Default graph width ! */ int DEFAULT_WIDTH = 400; ! /** ! * Default graph height ! */ int DEFAULT_HEIGHT = 100; ! /** ! * Default image format ! */ String DEFAULT_IMAGE_FORMAT = "gif"; ! /** ! * Default image quality, used only for jpeg graphs ! */ float DEFAULT_IMAGE_QUALITY = 0.8F; // only for jpegs, not used for png/gif ! /** ! * Default value base ! */ double DEFAULT_BASE = 1000; ! /** ! * Default font name, determined based on the current operating system ! */ String DEFAULT_FONT_NAME = System.getProperty("os.name").toLowerCase().contains("windows") ? "Lucida Sans Typewriter" : "Monospaced"; ! /** ! * Default graph small font ! */ Font DEFAULT_SMALL_FONT = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10); ! /** ! * Default graph large font ! */ Font DEFAULT_LARGE_FONT = new Font(DEFAULT_FONT_NAME, Font.BOLD, 12); ! /** ! * Used internally ! */ double LEGEND_LEADING = 1.2; // chars ! /** ! * Used internally ! */ double LEGEND_LEADING_SMALL = 0.7; // chars ! /** ! * Used internally ! */ double LEGEND_BOX_SPACE = 1.2; // chars ! /** ! * Used internally ! */ double LEGEND_BOX = 0.9; // chars ! /** ! * Used internally ! */ int LEGEND_INTERSPACING = 2; // chars ! /** ! * Used internally ! */ int PADDING_LEFT = 10; // pix ! /** ! * Used internally ! */ int PADDING_TOP = 12; // pix ! /** ! * Used internally ! */ int PADDING_TITLE = 6; // pix ! /** ! * Used internally ! */ int PADDING_RIGHT = 16; // pix ! /** ! * Used internally ! */ int PADDING_PLOT = 2; //chars ! /** ! * Used internally ! */ int PADDING_LEGEND = 2; // chars ! /** ! * Used internally ! */ int PADDING_BOTTOM = 6; // pix ! /** ! * Used internally ! */ int PADDING_VLABEL = 7; // pix ! /** ! * Stroke used to draw grid ! */ Stroke GRID_STROKE = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, new float[] {1, 1}, 0); ! /** ! * Stroke used to draw ticks ! */ Stroke TICK_STROKE = new BasicStroke(1); } Index: GifEncoder.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/GifEncoder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GifEncoder.java 7 Nov 2003 09:53:35 -0000 1.2 --- GifEncoder.java 21 Dec 2006 18:02:43 -0000 1.3 *************** *** 1,692 **** ! /* ============================================================ ! * JRobin : Pure java implementation of RRDTool's functionality ! * ============================================================ ! * ! * Project Info: http://www.jrobin.org ! * Project Lead: Sasa Markovic (sa...@jr...) ! * ! * Developers: Sasa Markovic (sa...@jr...) ! * Arne Vandamme (cob...@jr...) ! * [...1399 lines suppressed...] ! return ciPixels; ! } ! } ! ! ! final class Put { ! static void ascii(String s, OutputStream os) throws IOException { ! byte[] bytes = new byte[s.length()]; ! for (int i = 0; i < bytes.length; ++i) { ! bytes[i] = (byte) s.charAt(i); ! } ! os.write(bytes); ! } ! ! static void leShort(int i16, OutputStream os) throws IOException { ! os.write(i16 & 0xff); ! os.write(i16 >> 8 & 0xff); ! } } \ No newline at end of file Index: Source.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Source.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Source.java 23 Jan 2005 20:31:26 -0000 1.15 --- Source.java 21 Dec 2006 18:02:44 -0000 1.16 *************** *** 1,261 **** ! /* ============================================================ ! * JRobin : Pure java implementation of RRDTool's functionality ! * ============================================================ ! * ! * Project Info: http://www.jrobin.org ! * Project Lead: Sasa Markovic (sa...@jr...) ! * ! * Developers: Sasa Markovic (sa...@jr...) ! * Arne Vandamme (cob...@jr...) ! * ! * (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 org.jrobin.graph; ! ! import org.jrobin.core.Util; ! ! /** ! * <p>Class used to represent a number of datapoints for a graph.</p> ! * ! * @author Arne Vandamme (cob...@jr...) ! */ ! class Source ! { ! // ================================================================ ! // -- Members ! // ================================================================ ! protected static final int AGG_MINIMUM = 0; ! protected static final int AGG_MAXIMUM = 1; ! protected static final int AGG_AVERAGE = 2; ! protected static final int AGG_FIRST = 3; ! protected static final int AGG_LAST = 4; ! protected static final int AGG_TOTAL = 5; ! ! protected static final String[] aggregates = { "MINIMUM", "MAXIMUM", "AVERAGE", "FIRST", "LAST", "TOTAL" }; ! private String name; ! ! protected int aggregatePoints; ! protected double[] values; ! ! private double min = Double.NaN; ! private double max = Double.NaN; ! private double totalValue = 0; ! private double nextValue = Double.POSITIVE_INFINITY; ! ! protected long step = 0; ! private long lastPreciseTime = 0; // Last time requested ! private long lastTime = 0; ! private long totalTime = 0; ! ! private long startTime, endTime; ! ! private int stPos = 0; ! private int lastStPos = 0; // Last value position requested ! ! // ================================================================ ! // -- Constructors ! // ================================================================ ! /** ! * Constructs a new Source object holding a number of datapoints for a graph. ! * @param name Name of the datasource in the graph definition. ! */ ! Source( String name ) ! { ! this.name = name; ! } ! ! // ================================================================ ! // -- Protected methods ! // ================================================================ ! /** ! * Stub method, sets the value of a specific datapoint. ! * Forces this point to be used in aggregate function calculating. ! * @param pos Position (index in the value table) of the new datapoint. ! * @param time Timestamp of the new datapoint in number of seconds. ! * @param val Double value of the new datapoint. ! */ ! void set( int pos, long time, double val ) ! { ! // The first sample is before the time range we want, and as such ! // should not be counted for data aggregation ! if ( pos < aggregatePoints ) ! aggregate( time, val ); ! } ! ! void setFetchSettings( long step, long startTime, long endTime ) ! { ! this.step = step; ! this.startTime = startTime; ! this.endTime = endTime; ! } ! ! long getStep() { ! return step; ! } ! ! /** ! * Get the double value of a datapoint. ! * ! * @param pos Index in the value table of the datapoint. ! * @return The double value of the requested datapoint. ! */ ! double get( int pos ) ! { ! if ( pos < 0 ) ! return Double.NaN; ! if ( pos > values.length ) ! return Double.NaN; ! ! double val = values[pos]; ! ! if ( Double.isInfinite(val) ) ! { ! // Return the next value if we fetched it before ! if ( !Double.isInfinite(nextValue) && pos >= lastStPos ) ! return nextValue; ! ! lastStPos = pos; ! ! // Try to fetch the next value ! for ( int i = pos + 1; i < values.length; i++ ) ! { ! if ( !Double.isInfinite(values[i]) ) ! { ! nextValue = values[i]; ! ! return nextValue; ! } ! } ! ! // No more next value ! nextValue = Double.NaN; ! ! return nextValue; ! } ! else ! nextValue = Double.POSITIVE_INFINITY; ! ! lastStPos = pos; ! ! return values[pos]; ! } ! ! double get( long preciseTime, long[] reducedTimestamps ) ! { ! long t = Util.normalize( preciseTime, step ); ! t = ( t < preciseTime ? t + step : t ); ! ! if ( preciseTime < lastPreciseTime ) // Backward fetching is weird, start over, we're prolly in a new iteration ! stPos = 0; ! ! lastPreciseTime = preciseTime; ! ! while ( stPos < reducedTimestamps.length - 1 ) ! { ! if ( reducedTimestamps[ stPos + 1 ] <= t ) ! stPos++; ! else ! return get( stPos ); ! } ! ! if ( t <= reducedTimestamps[stPos] ) ! return get( stPos ); ! ! return Double.NaN; ! } ! ! /** ! * Gets a specific aggregate of this datasource. ! * Requested aggregate can be one of the following: ! * <code>AGG_MINIMUM, AGG_MAXIMUM, AGG_AVERAGE, AGG_FIRST, AGG_TOTAL</code> ! * and <code>AGG_LAST</code>. ! * @param aggType Type of the aggregate requested. ! * @return The double value of the requested aggregate. ! */ ! double getAggregate( int aggType ) ! { ! switch ( aggType ) ! { ! case AGG_MINIMUM: ! return min; ! ! case AGG_MAXIMUM: ! return max; ! ! case AGG_AVERAGE: ! if ( totalTime > 0 ) ! return totalValue / totalTime; ! break; ! ! case AGG_FIRST: ! if ( values != null && values.length > 0) ! return values[ values.length > 1 ? 1 : 0 ]; ! break; ! ! case AGG_LAST: ! if ( values != null && values.length > 0) ! return values[values.length - 1]; ! break; ! ! case AGG_TOTAL: ! return totalValue; ! } ! ! return Double.NaN; ! } ! ! String getName() { ! return name; ! } ! ! double[] getValues() { ! return values; ! } ! ! long getSampleCount() { ! return ( values != null ? values.length : 0 ); ! } ! ! ! // ================================================================ ! // -- Private methods ! // ================================================================ ! /** ! * Adds a datapoint to the aggregate function calculation. ! * @param time Timestamp in seconds of the datapoint. ! * @param value Double value of the datapoint. ! */ ! private void aggregate( long time, double value ) ! { ! if ( Double.isInfinite(value) ) ! return; ! ! if ( time > endTime ) ! time = endTime; ! ! if ( lastTime > 0 && !Double.isNaN(value) && value != Util.MIN_DOUBLE && value != Util.MAX_DOUBLE ) ! { ! min = Util.min( min, value ); ! max = Util.max( max, value ); ! ! long timeDelta = time - lastTime; ! ! totalValue += timeDelta * value; ! totalTime += timeDelta; ! } ! ! lastTime = ( time < startTime ? startTime : time ); ! } ! } --- 1,37 ---- ! /* ============================================================ ! * JRobin : Pure java implementation of RRDTool's functionality ! * ============================================================ ! * ! * Project Info: http://www.jrobin.org ! * Project Lead: Sasa Markovic (sa...@jr...) ! * ! * Developers: Sasa Markovic (sa...@jr...) ! * ! * ! * (C) Copyright 2003-2005, 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 org.jrobin.graph; ! ! import org.jrobin.data.DataProcessor; ! ! abstract class Source { ! final String name; ! ! Source(String name) { ! this.name = name; ! } ! ! abstract void requestData(DataProcessor dproc); ! } Index: TimeAxis.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/TimeAxis.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TimeAxis.java 6 Sep 2005 20:40:55 -0000 1.1.1.1 --- TimeAxis.java 21 Dec 2006 18:02:44 -0000 1.2 *************** *** 33,51 **** class TimeAxis implements RrdGraphConstants { private static final TimeAxisSetting[] tickSettings = { ! new TimeAxisSetting(0, SECOND, 30, MINUTE, 5, MINUTE, 5, 0, "HH:mm"), ! new TimeAxisSetting(2, MINUTE, 1, MINUTE, 5, MINUTE, 5, 0, "HH:mm"), ! new TimeAxisSetting(5, MINUTE, 2, MINUTE, 10, MINUTE, 10, 0, "HH:mm"), ! new TimeAxisSetting(10, MINUTE, 5, MINUTE, 20, MINUTE, 20, 0, "HH:mm"), ! new TimeAxisSetting(30, MINUTE, 10, HOUR, 1, HOUR, 1, 0, "HH:mm"), ! new TimeAxisSetting(60, MINUTE, 30, HOUR, 2, HOUR, 2, 0, "HH:mm"), ! new TimeAxisSetting(180, HOUR, 1, HOUR, 6, HOUR, 6, 0, "HH:mm"), ! new TimeAxisSetting(600, HOUR, 6, DAY, 1, DAY, 1, 24 * 3600, "EEE"), ! new TimeAxisSetting(1800, HOUR, 12, DAY, 1, DAY, 2, 24 * 3600, "EEE"), ! new TimeAxisSetting(3600, DAY, 1, WEEK, 1, WEEK, 1, 7 * 24 * 3600, "'Week 'w"), ! new TimeAxisSetting(3 * 3600, WEEK, 1, MONTH, 1, WEEK, 2, 7 * 24 * 3600, "'Week 'w"), ! new TimeAxisSetting(6 * 3600, MONTH, 1, MONTH, 1, MONTH, 1, 30 * 24 * 3600, "MMM"), ! new TimeAxisSetting(48 * 3600, MONTH, 1, MONTH, 3, MONTH, 3, 30 * 24 * 3600, "MMM"), ! new TimeAxisSetting(10 * 24 * 3600, YEAR, 1, YEAR, 1, YEAR, 1, 365 * 24 * 3600, "yy"), ! new TimeAxisSetting(-1, MONTH, 0, MONTH, 0, MONTH, 0, 0, "") }; --- 33,51 ---- class TimeAxis implements RrdGraphConstants { private static final TimeAxisSetting[] tickSettings = { ! new TimeAxisSetting(0, SECOND, 30, MINUTE, 5, MINUTE, 5, 0, "HH:mm"), ! new TimeAxisSetting(2, MINUTE, 1, MINUTE, 5, MINUTE, 5, 0, "HH:mm"), ! new TimeAxisSetting(5, MINUTE, 2, MINUTE, 10, MINUTE, 10, 0, "HH:mm"), ! new TimeAxisSetting(10, MINUTE, 5, MINUTE, 20, MINUTE, 20, 0, "HH:mm"), ! new TimeAxisSetting(30, MINUTE, 10, HOUR, 1, HOUR, 1, 0, "HH:mm"), ! new TimeAxisSetting(60, MINUTE, 30, HOUR, 2, HOUR, 2, 0, "HH:mm"), ! new TimeAxisSetting(180, HOUR, 1, HOUR, 6, HOUR, 6, 0, "HH:mm"), ! new TimeAxisSetting(600, HOUR, 6, DAY, 1, DAY, 1, 24 * 3600, "EEE"), ! new TimeAxisSetting(1800, HOUR, 12, DAY, 1, DAY, 2, 24 * 3600, "EEE"), ! new TimeAxisSetting(3600, DAY, 1, WEEK, 1, WEEK, 1, 7 * 24 * 3600, "'Week 'w"), ! new TimeAxisSetting(3 * 3600, WEEK, 1, MONTH, 1, WEEK, 2, 7 * 24 * 3600, "'Week 'w"), ! new TimeAxisSetting(6 * 3600, MONTH, 1, MONTH, 1, MONTH, 1, 30 * 24 * 3600, "MMM"), ! new TimeAxisSetting(48 * 3600, MONTH, 1, MONTH, 3, MONTH, 3, 30 * 24 * 3600, "MMM"), ! new TimeAxisSetting(10 * 24 * 3600, YEAR, 1, YEAR, 1, YEAR, 1, 365 * 24 * 3600, "yy"), ! new TimeAxisSetting(-1, MONTH, 0, MONTH, 0, MONTH, 0, 0, "") }; *************** *** 57,61 **** TimeAxis(RrdGraph rrdGraph) { this.rrdGraph = rrdGraph; ! this.secPerPix = (rrdGraph.im.end - rrdGraph.im.start) / rrdGraph.im.xsize; this.calendar = Calendar.getInstance(Locale.getDefault()); this.calendar.setFirstDayOfWeek(rrdGraph.gdef.firstDayOfWeek); --- 57,63 ---- TimeAxis(RrdGraph rrdGraph) { this.rrdGraph = rrdGraph; ! if (rrdGraph.im.xsize > 0) { ! this.secPerPix = (rrdGraph.im.end - rrdGraph.im.start) / rrdGraph.im.xsize; ! } this.calendar = Calendar.getInstance(Locale.getDefault()); this.calendar.setFirstDayOfWeek(rrdGraph.gdef.firstDayOfWeek); *************** *** 64,67 **** --- 66,72 ---- void draw() { chooseTickSettings(); + if (tickSetting == null) { + return; + } drawMinor(); drawMajor(); *************** *** 123,127 **** private static String formatLabel(String format, Date date) { ! if(format.contains("%")) { // strftime like format string return String.format(format, date); --- 128,132 ---- private static String formatLabel(String format, Date date) { ! if (format.contains("%")) { // strftime like format string return String.format(format, date); Index: Stack.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Stack.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Stack.java 6 Apr 2005 20:10:10 -0000 1.6 --- Stack.java 21 Dec 2006 18:02:44 -0000 1.7 *************** *** 1,96 **** ! /* ============================================================ ! * JRobin : Pure java implementation of RRDTool's functionality ! * ============================================================ ! * ! * Project Info: http://www.jrobin.org ! * Project Lead: Sasa Markovic (sa...@jr...) ! * ! * Developers: Sasa Markovic (sa...@jr...) ! * Arne Vandamme (cob...@jr...) ! * ! * (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 org.jrobin.graph; ! ! import java.awt.Color; ! ! import org.jrobin.core.RrdException; ! import org.jrobin.core.XmlWriter; ! ! /** ! * <p>Class used to represent a stacked datasource plotted in a graph. The datasource ! * will be drawn as a line or an area, depending on PlotDef on which it is stacked.</p> ! * ! * @author Arne Vandamme (cob...@jr...) ! */ ! class Stack extends PlotDef ! { ! // ================================================================ ! // -- Constructors ! // ================================================================ ! /** ! * Constructs a <code>Stack</code> PlotDef object based on a datasource name and a graph color. ! * @param sourceName Name of the graph definition <code>Source</code> containing the datapoints. ! * @param color Color of the resulting area or line, if no color is specified, the PlotDef will not be drawn. ! */ ! Stack( String sourceName, Color color ) ! { ! super( sourceName, color ); ! this.plotType = PlotDef.PLOT_STACK; ! } ! ! ! // ================================================================ ! // -- Protected methods ! // ================================================================ ! /** ! * Draws the actual PlotDef on the chart, depending on the type of the previous PlotDef, ! * the Stack will be drawn as a <code>Line</code> or an <code>Area</code>. ! * @param g ChartGraphics object representing the graphing area. ! * @param xValues List of relative chart area X positions corresponding to the datapoints. ! * @param stackValues Datapoint values of previous PlotDefs, used to stack on if necessary. ! * @param lastPlotType Type of the previous PlotDef, used to determine PlotDef type of a stack. ! */ ! void draw( ChartGraphics g, int[] xValues, double[] stackValues, int lastPlotType ) throws RrdException ! { ! PlotDef stack = null; ! ! try ! { ! if ( lastPlotType == PlotDef.PLOT_LINE ) ! stack = new Line( source, values, color, true, visible ); ! else if ( lastPlotType == PlotDef.PLOT_AREA ) ! stack = new Area( source, values, color, true, visible ); ! ! stack.sourceName = sourceName; ! stack.processor = processor; ! ! stack.draw( g, xValues, stackValues, lastPlotType ); ! } ! catch (Exception e) ! { ! throw new RrdException( "Could not stack source: " + sourceName ); ! } ! ! } ! ! void exportXmlTemplate( XmlWriter xml, String legend ) { ! xml.startTag("stack"); ! xml.writeTag("datasource", sourceName); ! xml.writeTag("color", color); ! xml.writeTag("legend", legend); ! xml.closeTag(); // stack ! } ! } --- 1,64 ---- ! /* ============================================================ ! * JRobin : Pure java implementation of RRDTool's functionality ! * ============================================================ ! * ! * Project Info: http://www.jrobin.org ! * Project Lead: Sasa Markovic (sa...@jr...) ! * ! * Developers: Sasa Markovic (sa...@jr...) ! * ! * ! * (C) Copyright 2003-2005, 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 org.jrobin.graph; ! ! import org.jrobin.core.RrdException; ! import org.jrobin.data.DataProcessor; ! ! import java.awt.*; ! ! class Stack extends SourcedPlotElement { ! private final SourcedPlotElement parent; ! ! Stack(SourcedPlotElement parent, String srcName, Paint color) { ! super(srcName, color); ! this.parent = parent; ! } ! ! void assignValues(DataProcessor dproc) throws RrdException { ! double[] parentValues = parent.getValues(); ! double[] procValues = dproc.getValues(srcName); ! values = new double[procValues.length]; ! for (int i = 0; i < values.length; i++) { ! values[i] = parentValues[i] + procValues[i]; ! } ! } ! ! float getParentLineWidth() { ! if (parent instanceof Line) { ! return ((Line) parent).width; ! } ! else if (parent instanceof Area) { ! return -1F; ! } ! else /* if(parent instanceof Stack) */ { ! return ((Stack) parent).getParentLineWidth(); ! } ! } ! ! Paint getParentColor() { ! return parent.color; ! } ! } Index: PrintText.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/PrintText.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PrintText.java 6 Sep 2005 20:40:55 -0000 1.1.1.1 --- PrintText.java 21 Dec 2006 18:02:44 -0000 1.2 *************** *** 55,59 **** double value = dproc.getAggregate(srcName, consolFun); Matcher matcher = UNIT_PATTERN.matcher(resolvedText); ! if(matcher.find()) { // unit specified ValueScaler.Scaled scaled = valueScaler.scale(value, matcher.group(2).equals("s")); --- 55,59 ---- double value = dproc.getAggregate(srcName, consolFun); Matcher matcher = UNIT_PATTERN.matcher(resolvedText); ! if (matcher.find()) { // unit specified ValueScaler.Scaled scaled = valueScaler.scale(value, matcher.group(2).equals("s")); Index: RrdGraphInfo.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraphInfo.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** RrdGraphInfo.java 6 Sep 2005 20:40:55 -0000 1.1.1.1 --- RrdGraphInfo.java 21 Dec 2006 18:02:44 -0000 1.2 *************** *** 49,52 **** --- 49,53 ---- /** * Returns filename of the graph + * * @return filename of the graph. '-' denotes in-memory graph (no file created) */ *************** *** 57,60 **** --- 58,62 ---- /** * Returns total graph width + * * @return total graph width */ *************** *** 65,68 **** --- 67,71 ---- /** * Returns total graph height + * * @return total graph height */ *************** *** 73,76 **** --- 76,80 ---- /** * Returns graph bytes + * * @return Graph bytes */ *************** *** 81,84 **** --- 85,89 ---- /** * Returns PRINT lines requested by {@link RrdGraphDef#print(String, String, String)} method. + * * @return An array of formatted PRINT lines */ *************** *** 89,92 **** --- 94,98 ---- /** * Returns image information requested by {@link RrdGraphDef#setImageInfo(String)} method + * * @return Image information */ *************** *** 97,100 **** --- 103,107 ---- /** * Returns the number of bytes in the graph file + * * @return Length of the graph file */ *************** *** 105,116 **** /** * Dumps complete graph information. Useful for debugging purposes. * @return String containing complete graph information */ public String dump() { StringBuffer b = new StringBuffer(); ! b.append("filename = \"" + getFilename() + "\"\n"); ! b.append("width = " + getWidth() + ", height = " + getHeight() + "\n"); ! b.append("byteCount = " + getByteCount() + "\n"); ! b.append("imginfo = \"" + getImgInfo() + "\"\n"); String[] plines = getPrintLines(); if (plines.length == 0) { --- 112,124 ---- /** * Dumps complete graph information. Useful for debugging purposes. + * * @return String containing complete graph information */ public String dump() { StringBuffer b = new StringBuffer(); ! b.append("filename = \"").append(getFilename()).append("\"\n"); ! b.append("width = ").append(getWidth()).append(", height = ").append(getHeight()).append("\n"); ! b.append("byteCount = ").append(getByteCount()).append("\n"); ! b.append("imginfo = \"").append(getImgInfo()).append("\"\n"); String[] plines = getPrintLines(); if (plines.length == 0) { *************** *** 119,123 **** else { for (int i = 0; i < plines.length; i++) { ! b.append("print[" + i + "] = \"" + plines[i] + "\"\n"); } } --- 127,131 ---- else { for (int i = 0; i < plines.length; i++) { ! b.append("print[").append(i).append("] = \"").append(plines[i]).append("\"\n"); } } Index: ValueScaler.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueScaler.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ValueScaler.java 6 Sep 2005 20:40:55 -0000 1.1.1.1 --- ValueScaler.java 21 Dec 2006 18:02:44 -0000 1.2 *************** *** 28,32 **** static final String UNIT_UNKNOWN = "?"; static final String UNIT_SYMBOLS[] = { ! "a", "f", "p", "n", "u", "m", " ", "k", "M", "G", "T", "P", "E" }; static final int SYMB_CENTER = 6; --- 28,32 ---- static final String UNIT_UNKNOWN = "?"; static final String UNIT_SYMBOLS[] = { ! "a", "f", "p", "n", "u", "m", " ", "k", "M", "G", "T", "P", "E" }; static final int SYMB_CENTER = 6; *************** *** 42,49 **** Scaled scale(double value, boolean mustRescale) { Scaled scaled; ! if(mustRescale) { scaled = rescale(value); } ! else if(magfact >= 0) { // already scaled, need not rescale scaled = new Scaled(value / magfact, unit); --- 42,49 ---- Scaled scale(double value, boolean mustRescale) { Scaled scaled; ! if (mustRescale) { scaled = rescale(value); } ! else if (magfact >= 0) { // already scaled, need not rescale scaled = new Scaled(value / magfact, unit); *************** *** 53,57 **** scaled = rescale(value); // if zero, scale again on the next try ! if(scaled.value == 0.0 || Double.isNaN(scaled.value)) { magfact = -1.0; } --- 53,57 ---- scaled = rescale(value); // if zero, scale again on the next try ! if (scaled.value == 0.0 || Double.isNaN(scaled.value)) { magfact = -1.0; } Index: RrdGraphDefTemplate.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraphDefTemplate.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RrdGraphDefTemplate.java 6 Apr 2005 20:10:10 -0000 1.12 --- RrdGraphDefTemplate.java 21 Dec 2006 18:02:44 -0000 1.13 *************** *** 1,906 **** ! /* ============================================================ ! * JRobin : Pure java implementation of RRDTool's functionality ! * ============================================================ ! * ! * Project Info: http://www.jrobin.org ! * Project Lead: Sasa Markovic (sa...@jr...); ! * ! * (C) Copyright 2003, by Sasa Markovic. ! * ! * Developers: Sasa Markovic (sa...@jr...) [...1862 lines s... [truncated message content] |