Update of /cvsroot/jrobin/src/jrobin/demo In directory sc8-pr-cvs1:/tmp/cvs-serv2871/src/jrobin/demo Modified Files: JRobinComplexGraph.java JRobinGallery.java Added Files: TimeProfile.java ProfileGraphsOld.java JRobinTimeProfiler.java ProfileGraphsNew.java Log Message: Experimental graph2 package major update, but very unfinished --- NEW FILE: TimeProfile.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...) * 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 jrobin.demo; /** * <p>description</p> * * @author Arne Vandamme (arn...@jr...) * @author Sasa Markovic (sa...@jr...) */ public class TimeProfile { String name = ""; long[] defCreation = new long[2]; long[][] creation = new long[2][6]; long[] totalCreation = new long[2]; } --- NEW FILE: ProfileGraphsOld.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...) * 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 jrobin.demo; import java.io.IOException; import java.io.PrintWriter; import java.awt.Color; import java.util.LinkedList; import java.util.GregorianCalendar; import java.util.Date; import jrobin.core.RrdException; import jrobin.core.Util; import jrobin.graph.*; /** * <p>description</p> * * @author Arne Vandamme (arn...@jr...) * @author Sasa Markovic (sa...@jr...) */ class ProfileGraphsOld { private final int DNUM = 0; // profiler num, 0 or 1 (1 = new, 0 = old) private int demoNum; private PrintWriter out; private RrdGraph graph; private JRobinTimeProfiler profiler; // Demo sake private GregorianCalendar startDate = new GregorianCalendar(2003, 7, 24, 00, 00); private GregorianCalendar endDate = new GregorianCalendar(2003, 7, 25, 00, 00); private void addTimingInfo( int profileIndex, LinkedList v ) { int i = profileIndex - 1; while ( ! v.isEmpty() ) { String timetag = (String) v.removeFirst(); String[] s = timetag.split("_"); int num = Integer.parseInt(s[0]); long time = Long.parseLong(s[1]); profiler.profiles[i].creation[DNUM][num] = time; } } ProfileGraphsOld( PrintWriter out, JRobinTimeProfiler profiler ) { this.profiler = profiler; this.out = out; long fullStart, fullStop; fullStart = System.currentTimeMillis(); try { createDemo1(); createDemo2(); createDemo3(); createDemoEx(4); createDemoEx(5); createDemoEx(6); } catch ( Exception e ) { out.println( "\nException occurred: " + e.getMessage() + "\n" ); } fullStop = System.currentTimeMillis(); profiler.oldGraphs = (fullStop - fullStart); //out.println( " Total execution time for graph batch: " + setw( 10, (fullStop - fullStart)) ); } private void createDemo1() throws IOException, RrdException { demoNum = 1; profiler.profiles[demoNum - 1].name = "Simple traffic graph."; long start, stop; // Create Def start = System.currentTimeMillis(); RrdGraphDef def = new RrdGraphDef(); def.setTimePeriod( startDate, endDate ); def.setTitle("ahha"); def.datasource("in2", "/test.rrd", "ifInOctets", "AVERAGE"); def.datasource("out2", "/test.rrd", "ifOutOctets", "AVERAGE"); def.datasource("in", "in2,8,*"); def.datasource("out", "out2,8,*"); def.area("in", Color.RED, "Incoming traffic"); def.gprint("in", "AVERAGE", "(average: @5.2 @sbit/s)\n"); def.line("out", Color.BLUE, "Outgoing traffic"); def.gprint("out", "AVERAGE", "(average: @6.2 @sbit/s)"); stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].defCreation[DNUM] = (stop - start); // Create graph graph = new RrdGraph( def ); graph.saveAsPNG( "/time_demo" + demoNum + "-" + DNUM + ".png", 0, 0 ); // Default size stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].totalCreation[DNUM] = (stop - start); addTimingInfo( demoNum, Util.timeList ); } private void createDemo2() throws IOException, RrdException { demoNum = 2; profiler.profiles[demoNum - 1].name = "Rainbow graph."; long start, stop; // Create Def start = System.currentTimeMillis(); // ============================================================== RrdGraphDef def = new RrdGraphDef(); GregorianCalendar sd = new GregorianCalendar(2003, 4, 1); GregorianCalendar ed = new GregorianCalendar(2003, 5, 1); def.setTimePeriod(sd, ed); long t0 = sd.getTime().getTime() / 1000L; long t1 = ed.getTime().getTime() / 1000L; def.datasource("sine", "TIME," + t0 + ",-," + (t1 - t0) + ",/,7,PI,*,*,SIN"); def.datasource("v2", "/gallery.rrd", "shade", "AVERAGE"); def.datasource("cosine", "TIME," + t0 + ",-," + (t1 - t0) + ",/,3,PI,*,*,COS"); def.datasource("line", "TIME," + t0 + ",-," + (t1 - t0) + ",/,1000,*"); def.datasource("v1", "sine,line,*,ABS"); int n = 40; for(int i = 0; i < n; i++) { long t = t0 + (t1 - t0) * i / n; def.datasource("c" + i, "TIME," + t + ",GT,v2,UNKN,IF"); } for(int i = 0; i < n; i++) { if(i==0) { def.area("c"+i, new Color(255-255*Math.abs(i-n/2)/(n/2),0,0), "Output by night"); } else if(i==n/2) { def.area("c"+i, new Color(255-255*Math.abs(i-n/2)/(n/2),0,0), "Output by day"); } else { def.area("c"+i, new Color(255-255*Math.abs(i-n/2)/(n/2),0,0), null); } } def.line("v2", Color.YELLOW, null); def.line("v1", Color.BLUE, "Input voltage@L", 3); def.line("v1", Color.YELLOW, null, 1); def.setTitle("Voltage measurement"); //def.setVerticalLabel("[Volts]"); def.setValueAxisLabel("[Volts]"); def.comment("fancy looking graphs@r"); //def.setValueStep(100); // ============================================================== stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].defCreation[DNUM] = (stop - start); // Create graph graph = new RrdGraph( def ); graph.saveAsPNG( "/time_demo" + demoNum + "-" + DNUM + ".png", 400, 250 ); // Default size stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].totalCreation[DNUM] = (stop - start); addTimingInfo( demoNum, Util.timeList ); } private void createDemo3() throws IOException, RrdException { demoNum = 3; profiler.profiles[demoNum - 1].name = "Customized complex graph."; long start, stop; // Create Def start = System.currentTimeMillis(); // ============================================================== RrdGraphDef def = new RrdGraphDef(); def.setTimePeriod( startDate, endDate ); //gl.setTitleFont( new Font("Lucida Sans Typewriter", Font.PLAIN, 10) ); def.setTitle( "+------------------------------------------------------------------+@c" + "| Server load...@Land@C...CPU usage |@r" + "+------------------------------------------------------------------+@c" ); //gl.setVerticalLabel("server load"); def.setValueAxisLabel("server load"); def.setBackColor( Color.DARK_GRAY ); def.setCanvasColor( Color.LIGHT_GRAY ); def.setImageBorder( Color.BLACK, 1 ); //gl.setDefaultFontColor( Color.WHITE ); //gl.setTitleFontColor( Color.GREEN ); def.setMajorGridColor(Color.YELLOW); def.setMinorGridColor( new Color( 130, 30, 30) ); def.setFrameColor( Color.BLACK ); def.setAxisColor( Color.RED ); def.setArrowColor( Color.GREEN ); //gl.setGridX( false ); //gl.setGridY( false ); //gl.setFrontGrid(false); def.setShowLegend(true); //gl.setUnitsExponent(3); //gl.setAntiAliasing(false); //gl.setGridRange( 0, 1, false ); def.setValueRange( 0, 1 ); def.setRigidGrid( false ); def.setFontColor( Color.WHITE ); def.datasource("load", "c:/test.rrd", "serverLoad", "AVERAGE"); def.datasource("user", "c:/test.rrd", "serverCPUUser", "AVERAGE"); def.datasource("nice", "c:/test.rrd", "serverCPUNice", "AVERAGE"); def.datasource("system", "c:/test.rrd", "serverCPUSystem", "AVERAGE"); def.datasource("idle", "c:/test.rrd", "serverCPUIdle", "AVERAGE"); def.datasource("total", "user,nice,+,system,+,idle,+"); def.datasource("busy", "user,nice,+,system,+,total,/,100,*"); def.datasource("p25t50", "busy,25,GT,busy,50,LE,load,0,IF,0,IF"); def.datasource("p50t75", "busy,50,GT,busy,75,LE,load,0,IF,0,IF"); def.datasource("p75t90", "busy,75,GT,busy,90,LE,load,0,IF,0,IF"); def.datasource("p90t100", "busy,90,GT,load,0,IF"); def.comment("CPU utilization (%)\n"); def.comment(" "); //gl.hrule( 7.0, Color.YELLOW, null, 10f); def.area("load", new Color(0x66,0x99,0xcc), " 0 - 25%"); def.area("p25t50", new Color(0x00,0x66,0x99), "25 - 50%"); def.comment(" "); def.gprint("busy", "MIN", "Minimum:@5.1@s%"); def.gprint("busy", "MAX", "Maximum: @5.1@S%"); def.comment("\n"); def.comment(" "); def.area("p50t75", new Color(0x66,0x66,0x00), "50 - 75%"); def.area("p75t90", new Color(0xff,0x66,0x00), "75 - 90%"); def.area("p90t100", new Color(0xcc,0x33,0x00), "90 - 100%"); //gDef.rule(10.0, Color.ORANGE, null); def.gprint("busy", "AVERAGE", " Average:@5.1@s%"); def.gprint("busy", "LAST", "Current: @5.1@s%"); def.comment("\n"); def.comment("\n"); def.comment("Server load\n"); def.comment(" "); def.line("load", new Color(0x00,0x00,0x00), "Load average (5 min)" ); //gDef.area("load", Color.RED, " hmm \n"); //gl.stack("p75t90", Color.GREEN, " hmm"); def.comment(" "); def.gprint("load", "MIN", " Minimum: @5.2@s"); def.gprint("load", "MAX", "Maximum: @6.2@s"); def.comment("\n"); def.comment(" "); def.comment(" "); def.gprint("load", "AVERAGE", "Average: @5.2@s"); def.gprint("load", "LAST", "Current: @6.2@s\n"); def.comment("\n"); def.comment("-------------------------------------------------------------------------------@c"); //gl.vrule( new GregorianCalendar(2003, 7, 24, 9, 00), Color.BLUE, "9am", 2f ); //gl.vrule( new GregorianCalendar(2003, 7, 24, 17, 00), Color.BLUE, "5pm", 3f ); def.comment("Generated: " + new Date() + "@R"); // ============================================================== stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].defCreation[DNUM] = (stop - start); // Create graph graph = new RrdGraph( def ); graph.saveAsPNG( "/time_demo" + demoNum + "-" + DNUM + ".png", 0, 0 ); // Default size stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].totalCreation[DNUM] = (stop - start); addTimingInfo( demoNum, Util.timeList ); } private void createDemoEx( int demoNum ) throws IOException, RrdException { profiler.profiles[demoNum - 1].name = "Complex graph (3 RRD files)."; long start, stop; // Create Def start = System.currentTimeMillis(); // ============================================================== RrdGraphDef def = new RrdGraphDef(); def.setTimePeriod( startDate, endDate ); def.setTitle( "+------------------------------------------------------------------+@c" + "| Server load...@Land@C...CPU usage |@r" + "+------------------------------------------------------------------+@c" ); def.setValueAxisLabel("server load"); def.setAntiAliasing(false); def.datasource("load", "c:/test.rrd", "serverLoad", "AVERAGE"); def.datasource("user", "c:/test.rrd", "serverCPUUser", "AVERAGE"); def.datasource("nice", "c:/test1.rrd", "serverCPUNice", "AVERAGE"); def.datasource("system", "c:/test1.rrd", "serverCPUSystem", "AVERAGE"); def.datasource("idle", "c:/test2.rrd", "serverCPUIdle", "AVERAGE"); def.datasource("total", "user,nice,+,system,+,idle,+"); def.datasource("busy", "user,nice,+,system,+,total,/,100,*"); def.datasource("p25t50", "busy,25,GT,busy,50,LE,load,0,IF,0,IF"); def.datasource("p50t75", "busy,50,GT,busy,75,LE,load,0,IF,0,IF"); def.datasource("p75t90", "busy,75,GT,busy,90,LE,load,0,IF,0,IF"); def.datasource("p90t100", "busy,90,GT,load,0,IF"); def.comment("CPU utilization (%)\n"); def.comment(" "); //gl.hrule( 7.0, Color.YELLOW, null, 10f); def.area("load", new Color(0x66,0x99,0xcc), " 0 - 25%"); def.area("p25t50", new Color(0x00,0x66,0x99), "25 - 50%"); def.comment(" "); def.gprint("busy", "MIN", "Minimum:@5.1@s%"); def.gprint("busy", "MAX", "Maximum: @5.1@S%"); def.comment("\n"); def.comment(" "); def.area("p50t75", new Color(0x66,0x66,0x00), "50 - 75%"); def.area("p75t90", new Color(0xff,0x66,0x00), "75 - 90%"); def.area("p90t100", new Color(0xcc,0x33,0x00), "90 - 100%"); //gDef.rule(10.0, Color.ORANGE, null); def.gprint("busy", "AVERAGE", " Average:@5.1@s%"); def.gprint("busy", "LAST", "Current: @5.1@s%"); def.comment("\n"); def.comment("\n"); def.comment("Server load\n"); def.comment(" "); def.line("load", new Color(0x00,0x00,0x00), "Load average (5 min)" ); //gDef.area("load", Color.RED, " hmm \n"); //gl.stack("p75t90", Color.GREEN, " hmm"); def.comment(" "); def.gprint("load", "MIN", " Minimum: @5.2@s"); def.gprint("load", "MAX", "Maximum: @6.2@s"); def.comment("\n"); def.comment(" "); def.comment(" "); def.gprint("load", "AVERAGE", "Average: @5.2@s"); def.gprint("load", "LAST", "Current: @6.2@s\n"); def.comment("\n"); def.comment("-------------------------------------------------------------------------------@c"); //gl.vrule( new GregorianCalendar(2003, 7, 24, 9, 00), Color.BLUE, "9am", 2f ); //gl.vrule( new GregorianCalendar(2003, 7, 24, 17, 00), Color.BLUE, "5pm", 3f ); def.comment("Generated: " + new Date() + "@R"); // ============================================================== stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].defCreation[DNUM] = (stop - start); // Create graph graph = new RrdGraph( def ); graph.saveAsPNG( "/time_demo" + demoNum + "-" + DNUM + ".png", 0, 0 ); // Default size stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].totalCreation[DNUM] = (stop - start); addTimingInfo( demoNum, Util.timeList ); } } --- NEW FILE: JRobinTimeProfiler.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...) * 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 jrobin.demo; import java.io.*; /** * <p>This class is used for time/performance profiling of the 'old' and 'new' JRobin graphing packages.</p> * * @author Arne Vandamme (arn...@jr...) * @author Sasa Markovic (sa...@jr...) */ public class JRobinTimeProfiler { private static int NUM_DEMOS = 6; TimeProfile[] profiles; long oldGraphs, newGraphs; String[] steps = new String[] { "Prepare", "CalculateSeries", "PlotImageBackground", "PlotChart", "PlotComments", "ImageSave", "", "" }; JRobinTimeProfiler( PrintWriter out ) { profiles = new TimeProfile[NUM_DEMOS]; for (int i = 0; i < profiles.length; i++) profiles[i] = new TimeProfile(); new ProfileGraphsOld( out, this ); new ProfileGraphsNew( out, this ); long proc; for (int i = 0; i < profiles.length; i++) { TimeProfile p = profiles[i]; out.println("\n DEMO " + (i + 1) + ": " + p.name + "\n-----------------------------------------------------"); // Graph def creation times proc = ( p.defCreation[0] > 0 ? ((p.defCreation[0] - p.defCreation[1]) * 100 / p.defCreation[0]) : 0); out.println( setwr(25, " 0 - RrdGraphDef creation") + setw(10, p.defCreation[0]) + setw(15, p.defCreation[1]) + setw(10, proc + "%") + "\n" ); // Step creation times for (int j = 0; j < p.creation[0].length; j++) { proc = ( p.creation[0][j] > 0 ? ((p.creation[0][j] - p.creation[1][j]) * 100 / p.creation[0][j]) : 0); out.println( setw(2, "" + (j + 1)) + " - " + setwr(20, steps[j]) + setw(10, p.creation[0][j]) + setw(15, p.creation[1][j]) + setw(10, proc + "%") ); } // Total creation time proc = ( p.totalCreation[0] > 0 ? ((p.totalCreation[0] - p.totalCreation[1]) * 100 / p.totalCreation[0]) : 0); out.println( "\n" + setwr(25, " Total time:") + setw(10, p.totalCreation[0]) + setw(15, p.totalCreation[1]) + setw(10, proc + "%") + "\n" ); } proc = ( oldGraphs > 0 ? ((oldGraphs - newGraphs) * 100 / oldGraphs) : 0); out.println( setwr(25, " Total batch time:") + setw(10, oldGraphs) + setw(15, newGraphs) + setw(10, proc + "%") + "\n" ); out.println("\n\n"); } private String setwr( int num, String str ) { int diff = num - str.length(); StringBuffer prefix = new StringBuffer(""); for (int i = 0; i < diff; i++) prefix.append(' '); return str + prefix.toString(); } private String setw( int num, String str ) { int diff = num - str.length(); StringBuffer prefix = new StringBuffer(""); for (int i = 0; i < diff; i++) prefix.append(' '); return prefix.append(str).toString(); } private String setw( int num, long val ) { return setw(num, "" + val); } public static void main( String[] args ) { PrintWriter out = new PrintWriter( System.out ); new JRobinTimeProfiler( out ); out.close(); } } --- NEW FILE: ProfileGraphsNew.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...) * 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 jrobin.demo; import java.io.IOException; import java.io.PrintWriter; import java.awt.Color; import java.util.Date; import java.util.LinkedList; import java.util.GregorianCalendar; import jrobin.core.RrdException; import jrobin.core.Util; import jrobin.graph2.*; /** * <p>description</p> * * @author Arne Vandamme (arn...@jr...) * @author Sasa Markovic (sa...@jr...) */ public class ProfileGraphsNew { private final int DNUM = 1; // profiler num, 0 or 1 (1 = new, 0 = old) private int demoNum; private PrintWriter out; private RrdGraph graph; private JRobinTimeProfiler profiler; // Demo sake private GregorianCalendar startDate = new GregorianCalendar(2003, 7, 24, 00, 00); private GregorianCalendar endDate = new GregorianCalendar(2003, 7, 25, 00, 00); private void addTimingInfo( int profileIndex, LinkedList v ) { int i = profileIndex - 1; while ( ! v.isEmpty() ) { String timetag = (String) v.removeFirst(); String[] s = timetag.split("_"); int num = Integer.parseInt(s[0]); long time = Long.parseLong(s[1]); profiler.profiles[i].creation[DNUM][num] = time; } } ProfileGraphsNew( PrintWriter out, JRobinTimeProfiler profiler ) { this.profiler = profiler; this.out = out; long fullStart, fullStop; fullStart = System.currentTimeMillis(); try { graph = new RrdGraph(); // Default rrddb pool size createDemo1(); createDemo2(); createDemo3(); createDemoEx(4); createDemoEx(5); createDemoEx(6); graph.closeFiles(); } catch ( Exception e ) { out.println( "\nException occurred: " + e.getMessage() + "\n" ); } fullStop = System.currentTimeMillis(); profiler.newGraphs = (fullStop - fullStart); //out.println( " Total execution time for graph batch: " + setw( 10, (fullStop - fullStart)) ); } private void createDemo1() throws IOException, RrdException { demoNum = 1; long start, stop; // Create Def start = System.currentTimeMillis(); RrdGraphDef def = new RrdGraphDef(); def.setTimePeriod( startDate, endDate ); def.setTitle("ahha"); def.datasource("in2", "/test.rrd", "ifInOctets", "AVERAGE"); def.datasource("out2", "/test.rrd", "ifOutOctets", "AVERAGE"); def.datasource("in", "in2,8,*"); def.datasource("out", "out2,8,*"); def.area("in", Color.RED, "Incoming traffic"); def.gprint("in", "AVERAGE", "(average: @5.2 @sbit/s)\n"); def.line("out", Color.BLUE, "Outgoing traffic"); def.gprint("out", "AVERAGE", "(average: @6.2 @sbit/s)"); stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].defCreation[DNUM] = (stop - start); // Create graph graph.setGraphDef(def); graph.saveAsPNG( "/time_demo1-" + DNUM + ".png" ); // Default size stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].totalCreation[DNUM] = (stop - start); addTimingInfo( 1, Util.timeList ); } private void createDemo2() throws IOException, RrdException { demoNum = 2; long start, stop; // Create Def start = System.currentTimeMillis(); // ============================================================== RrdGraphDef def = new RrdGraphDef(); GregorianCalendar sd = new GregorianCalendar(2003, 4, 1); GregorianCalendar ed = new GregorianCalendar(2003, 5, 1); def.setTimePeriod(sd, ed); long t0 = sd.getTime().getTime() / 1000L; long t1 = ed.getTime().getTime() / 1000L; def.datasource("sine", "TIME," + t0 + ",-," + (t1 - t0) + ",/,7,PI,*,*,SIN"); def.datasource("v2", "/gallery.rrd", "shade", "AVERAGE"); def.datasource("cosine", "TIME," + t0 + ",-," + (t1 - t0) + ",/,3,PI,*,*,COS"); def.datasource("line", "TIME," + t0 + ",-," + (t1 - t0) + ",/,1000,*"); def.datasource("v1", "sine,line,*,ABS"); int n = 40; for(int i = 0; i < n; i++) { long t = t0 + (t1 - t0) * i / n; def.datasource("c" + i, "TIME," + t + ",GT,v2,UNKN,IF"); } for(int i = 0; i < n; i++) { if(i==0) { def.area("c"+i, new Color(255-255*Math.abs(i-n/2)/(n/2),0,0), "Output by night"); } else if(i==n/2) { def.area("c"+i, new Color(255-255*Math.abs(i-n/2)/(n/2),0,0), "Output by day"); } else { def.area("c"+i, new Color(255-255*Math.abs(i-n/2)/(n/2),0,0), null); } } def.line("v2", Color.YELLOW, null); def.line("v1", Color.BLUE, "Input voltage@L", 3); def.line("v1", Color.YELLOW, null, 1); def.setTitle("Voltage measurement"); def.setVerticalLabel("[Volts]"); //def.setValueAxisLabel("[Volts]"); def.comment("fancy looking graphs@r"); //def.setValueStep(100); // ============================================================== stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].defCreation[DNUM] = (stop - start); // Create graph graph.setGraphDef(def); graph.saveAsPNG( "/time_demo" + demoNum + "-" + DNUM + ".png", 400, 250 ); // Default size stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].totalCreation[DNUM] = (stop - start); addTimingInfo( demoNum, Util.timeList ); } private void createDemo3() throws IOException, RrdException { demoNum = 3; profiler.profiles[demoNum - 1].name = "Customized complex graph."; long start, stop; // Create Def start = System.currentTimeMillis(); // ============================================================== RrdGraphDef def = new RrdGraphDef(); def.setTimePeriod( startDate, endDate ); //gl.setTitleFont( new Font("Lucida Sans Typewriter", Font.PLAIN, 10) ); def.setTitle( "+------------------------------------------------------------------+@c" + "| Server load...@Land@C...CPU usage |@r" + "+------------------------------------------------------------------+@c" ); def.setVerticalLabel("server load"); //def.setValueAxisLabel("server load"); def.setBackColor( Color.DARK_GRAY ); def.setCanvasColor( Color.LIGHT_GRAY ); def.setImageBorder( Color.BLACK, 1 ); //gl.setDefaultFontColor( Color.WHITE ); //gl.setTitleFontColor( Color.GREEN ); def.setMajorGridColor(Color.YELLOW); def.setMinorGridColor( new Color( 130, 30, 30) ); def.setFrameColor( Color.BLACK ); def.setAxisColor( Color.RED ); def.setArrowColor( Color.GREEN ); //gl.setGridX( false ); //gl.setGridY( false ); //gl.setFrontGrid(false); def.setShowLegend(true); //gl.setUnitsExponent(3); //gl.setAntiAliasing(false); def.setGridRange( 0, 1, false ); //def.setValueRange( 0, 1 ); //def.setRigidGrid( false ); def.setDefaultFontColor( Color.WHITE ); def.setTitleFontColor( Color.WHITE ); def.datasource("load", "c:/test.rrd", "serverLoad", "AVERAGE"); def.datasource("user", "c:/test.rrd", "serverCPUUser", "AVERAGE"); def.datasource("nice", "c:/test.rrd", "serverCPUNice", "AVERAGE"); def.datasource("system", "c:/test.rrd", "serverCPUSystem", "AVERAGE"); def.datasource("idle", "c:/test.rrd", "serverCPUIdle", "AVERAGE"); def.datasource("total", "user,nice,+,system,+,idle,+"); def.datasource("busy", "user,nice,+,system,+,total,/,100,*"); def.datasource("p25t50", "busy,25,GT,busy,50,LE,load,0,IF,0,IF"); def.datasource("p50t75", "busy,50,GT,busy,75,LE,load,0,IF,0,IF"); def.datasource("p75t90", "busy,75,GT,busy,90,LE,load,0,IF,0,IF"); def.datasource("p90t100", "busy,90,GT,load,0,IF"); def.comment("CPU utilization (%)\n"); def.comment(" "); //gl.hrule( 7.0, Color.YELLOW, null, 10f); def.area("load", new Color(0x66,0x99,0xcc), " 0 - 25%"); def.area("p25t50", new Color(0x00,0x66,0x99), "25 - 50%"); def.comment(" "); def.gprint("busy", "MIN", "Minimum:@5.1@s%"); def.gprint("busy", "MAX", "Maximum: @5.1@S%"); def.comment("\n"); def.comment(" "); def.area("p50t75", new Color(0x66,0x66,0x00), "50 - 75%"); def.area("p75t90", new Color(0xff,0x66,0x00), "75 - 90%"); def.area("p90t100", new Color(0xcc,0x33,0x00), "90 - 100%"); //gDef.rule(10.0, Color.ORANGE, null); def.gprint("busy", "AVERAGE", " Average:@5.1@s%"); def.gprint("busy", "LAST", "Current: @5.1@s%"); def.comment("\n"); def.comment("\n"); def.comment("Server load\n"); def.comment(" "); def.line("load", new Color(0x00,0x00,0x00), "Load average (5 min)" ); //gDef.area("load", Color.RED, " hmm \n"); //gl.stack("p75t90", Color.GREEN, " hmm"); def.comment(" "); def.gprint("load", "MIN", " Minimum: @5.2@s"); def.gprint("load", "MAX", "Maximum: @6.2@s"); def.comment("\n"); def.comment(" "); def.comment(" "); def.gprint("load", "AVERAGE", "Average: @5.2@s"); def.gprint("load", "LAST", "Current: @6.2@s\n"); def.comment("\n"); def.comment("-------------------------------------------------------------------------------@c"); //gl.vrule( new GregorianCalendar(2003, 7, 24, 9, 00), Color.BLUE, "9am", 2f ); //gl.vrule( new GregorianCalendar(2003, 7, 24, 17, 00), Color.BLUE, "5pm", 3f ); def.comment("Generated: " + new Date() + "@R"); // ============================================================== stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].defCreation[DNUM] = (stop - start); // Create graph graph.setGraphDef(def); graph.saveAsPNG( "/time_demo" + demoNum + "-" + DNUM + ".png" ); // Default size stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].totalCreation[DNUM] = (stop - start); addTimingInfo( demoNum, Util.timeList ); } private void createDemoEx( int demoNum ) throws IOException, RrdException { long start, stop; // Create Def start = System.currentTimeMillis(); // ============================================================== RrdGraphDef def = new RrdGraphDef(); def.setTimePeriod( startDate, endDate ); def.setTitle( "+------------------------------------------------------------------+@c" + "| Server load...@Land@C...CPU usage |@r" + "+------------------------------------------------------------------+@c" ); def.setVerticalLabel("server load"); def.setAntiAliasing(false); def.datasource("load", "c:/test.rrd", "serverLoad", "AVERAGE"); def.datasource("user", "c:/test.rrd", "serverCPUUser", "AVERAGE"); def.datasource("nice", "c:/test1.rrd", "serverCPUNice", "AVERAGE"); def.datasource("system", "c:/test1.rrd", "serverCPUSystem", "AVERAGE"); def.datasource("idle", "c:/test2.rrd", "serverCPUIdle", "AVERAGE"); def.datasource("total", "user,nice,+,system,+,idle,+"); def.datasource("busy", "user,nice,+,system,+,total,/,100,*"); def.datasource("p25t50", "busy,25,GT,busy,50,LE,load,0,IF,0,IF"); def.datasource("p50t75", "busy,50,GT,busy,75,LE,load,0,IF,0,IF"); def.datasource("p75t90", "busy,75,GT,busy,90,LE,load,0,IF,0,IF"); def.datasource("p90t100", "busy,90,GT,load,0,IF"); def.comment("CPU utilization (%)\n"); def.comment(" "); //gl.hrule( 7.0, Color.YELLOW, null, 10f); def.area("load", new Color(0x66,0x99,0xcc), " 0 - 25%"); def.area("p25t50", new Color(0x00,0x66,0x99), "25 - 50%"); def.comment(" "); def.gprint("busy", "MIN", "Minimum:@5.1@s%"); def.gprint("busy", "MAX", "Maximum: @5.1@S%"); def.comment("\n"); def.comment(" "); def.area("p50t75", new Color(0x66,0x66,0x00), "50 - 75%"); def.area("p75t90", new Color(0xff,0x66,0x00), "75 - 90%"); def.area("p90t100", new Color(0xcc,0x33,0x00), "90 - 100%"); //gDef.rule(10.0, Color.ORANGE, null); def.gprint("busy", "AVERAGE", " Average:@5.1@s%"); def.gprint("busy", "LAST", "Current: @5.1@s%"); def.comment("\n"); def.comment("\n"); def.comment("Server load\n"); def.comment(" "); def.line("load", new Color(0x00,0x00,0x00), "Load average (5 min)" ); //gDef.area("load", Color.RED, " hmm \n"); //gl.stack("p75t90", Color.GREEN, " hmm"); def.comment(" "); def.gprint("load", "MIN", " Minimum: @5.2@s"); def.gprint("load", "MAX", "Maximum: @6.2@s"); def.comment("\n"); def.comment(" "); def.comment(" "); def.gprint("load", "AVERAGE", "Average: @5.2@s"); def.gprint("load", "LAST", "Current: @6.2@s\n"); def.comment("\n"); def.comment("-------------------------------------------------------------------------------@c"); //gl.vrule( new GregorianCalendar(2003, 7, 24, 9, 00), Color.BLUE, "9am", 2f ); //gl.vrule( new GregorianCalendar(2003, 7, 24, 17, 00), Color.BLUE, "5pm", 3f ); def.comment("Generated: " + new Date() + "@R"); // ============================================================== stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].defCreation[DNUM] = (stop - start); // Create graph graph.setGraphDef(def); graph.saveAsPNG( "/time_demo" + demoNum + "-" + DNUM + ".png" ); // Default size stop = System.currentTimeMillis(); profiler.profiles[demoNum - 1].totalCreation[DNUM] = (stop - start); addTimingInfo( demoNum, Util.timeList ); } } Index: JRobinComplexGraph.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/demo/JRobinComplexGraph.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** JRobinComplexGraph.java 17 Oct 2003 14:46:39 -0000 1.9 --- JRobinComplexGraph.java 21 Oct 2003 19:42:00 -0000 1.10 *************** *** 33,36 **** --- 33,37 ---- import jrobin.graph.*; + import jrobin.graph2.RrdGraph; /** *************** *** 44,57 **** public static void main(String[] args) { ! GregorianCalendar start = new GregorianCalendar(2003, 7, 24, 00, 00); GregorianCalendar end = new GregorianCalendar(2003, 7, 25, 00, 00); - RrdGraphDef gDef = new RrdGraphDef(); - try { gDef.setTimePeriod(start, end); ! gDef.setTitle("Server load baseline projection"); ! //gDef.setOverlay("/pkts.png"); gDef.datasource("load", "c:/test.rrd", "serverLoad", "AVERAGE"); gDef.datasource("user", "c:/test.rrd", "serverCPUUser", "AVERAGE"); --- 45,186 ---- public static void main(String[] args) { ! GregorianCalendar start = new GregorianCalendar(2003, 7, 24, 20, 00); GregorianCalendar end = new GregorianCalendar(2003, 7, 25, 00, 00); try { + // -------------------------------------------------------- + + // Create the graphdef to be used + jrobin.graph2.RrdGraphDef gl = new jrobin.graph2.RrdGraphDef(); + gl.setTimePeriod( start, end ); + //gl.setTitleFont( new Font("Lucida Sans Typewriter", Font.PLAIN, 10) ); + gl.setTitle( "+------------------------------------------------------------------+@c" + + "| Server load...@Land@C...CPU usage |@r" + + "+------------------------------------------------------------------+@c" + ); + gl.setVerticalLabel("server load"); + gl.setBackColor( Color.DARK_GRAY ); + gl.setCanvasColor( Color.LIGHT_GRAY ); + gl.setImageBorder( Color.BLACK, 1 ); + gl.setDefaultFontColor( Color.WHITE ); + gl.setTitleFontColor( Color.GREEN ); + gl.setMajorGridColor(Color.YELLOW); + gl.setMinorGridColor( new Color( 130, 30, 30) ); + gl.setFrameColor( Color.BLACK ); + gl.setAxisColor( Color.RED ); + gl.setArrowColor( Color.GREEN ); + //gl.setGridX( false ); + //gl.setGridY( false ); + //gl.setFrontGrid(false); + gl.setShowLegend(true); + //gl.setUnitsExponent(3); + //gl.setAntiAliasing(false); + gl.setGridRange( 0, 1, false ); + + gl.datasource("load", "c:/test.rrd", "serverLoad", "AVERAGE"); + gl.datasource("user", "c:/test.rrd", "serverCPUUser", "AVERAGE"); + gl.datasource("nice", "c:/test.rrd", "serverCPUNice", "AVERAGE"); + gl.datasource("system", "c:/test.rrd", "serverCPUSystem", "AVERAGE"); + gl.datasource("idle", "c:/test.rrd", "serverCPUIdle", "AVERAGE"); + gl.datasource("total", "user,nice,+,system,+,idle,+"); + gl.datasource("busy", "user,nice,+,system,+,total,/,100,*"); + gl.datasource("p25t50", "busy,25,GT,busy,50,LE,load,0,IF,0,IF"); + gl.datasource("p50t75", "busy,50,GT,busy,75,LE,load,0,IF,0,IF"); + gl.datasource("p75t90", "busy,75,GT,busy,90,LE,load,0,IF,0,IF"); + gl.datasource("p90t100", "busy,90,GT,load,0,IF"); + + gl.comment("CPU utilization (%)\n"); + gl.comment(" "); + //gl.hrule( 7.0, Color.YELLOW, null, 10f); + gl.area("load", new Color(0x66,0x99,0xcc), " 0 - 25%"); + gl.area("p25t50", new Color(0x00,0x66,0x99), "25 - 50%"); + gl.comment(" "); + gl.gprint("busy", "MIN", "Minimum:@5.1@s%"); + gl.gprint("busy", "MAX", "Maximum: @5.1@S%"); + gl.comment("\n"); + gl.comment(" "); + gl.area("p50t75", new Color(0x66,0x66,0x00), "50 - 75%"); + gl.area("p75t90", new Color(0xff,0x66,0x00), "75 - 90%"); + gl.area("p90t100", new Color(0xcc,0x33,0x00), "90 - 100%"); + //gDef.rule(10.0, Color.ORANGE, null); + gl.gprint("busy", "AVERAGE", " Average:@5.1@s%"); + gl.gprint("busy", "LAST", "Current: @5.1@s%"); + gl.comment("\n"); + gl.comment("\n"); + gl.comment("Server load\n"); + gl.comment(" "); + gl.line("load", new Color(0x00,0x00,0x00), "Load average (5 min)" ); + //gDef.area("load", Color.RED, " hmm \n"); + //gl.stack("p75t90", Color.GREEN, " hmm"); + gl.comment(" "); + gl.gprint("load", "MIN", " Minimum: @5.2@s"); + gl.gprint("load", "MAX", "Maximum: @6.2@s"); + gl.comment("\n"); + gl.comment(" "); + gl.comment(" "); + gl.gprint("load", "AVERAGE", "Average: @5.2@s"); + gl.gprint("load", "LAST", "Current: @6.2@s\n"); + gl.comment("\n"); + gl.comment("-------------------------------------------------------------------------------@c"); + //gl.vrule( new GregorianCalendar(2003, 7, 24, 9, 00), Color.BLUE, "9am", 2f ); + //gl.vrule( new GregorianCalendar(2003, 7, 24, 17, 00), Color.BLUE, "5pm", 3f ); + gl.comment("Generated: " + new Date() + "@R"); + + // Create the actual graph + long s1 = Calendar.getInstance().getTimeInMillis(); + jrobin.graph2.RrdGraph gf = new jrobin.graph2.RrdGraph(); + + // Create image as PNG and as JPEG + gf.setGraphDef( gl ); + gf.saveAsPNG( "/demo_graph.png" ); + //gf.saveAsJPEG( "/demo_graph.jpg", 1.0f ); + + + gl = new jrobin.graph2.RrdGraphDef(); + gl.setTimePeriod( start, end ); + gl.setTitle("ahha"); + gl.datasource("in2", "c:/test.rrd", "ifInOctets", "AVERAGE"); + gl.datasource("out2", "c:/test.rrd", "ifOutOctets", "AVERAGE"); + gl.datasource("in", "in2,8,*"); + gl.datasource("out", "out2,8,*"); + gl.area("in", Color.RED, "Incoming traffic"); + gl.gprint("in", "AVERAGE", "(average: @5.2 @sbit/s)\n"); + gl.line("out", Color.BLUE, "Outgoing traffic"); + gl.gprint("out", "AVERAGE", "(average: @6.2 @sbit/s)"); + gf.setGraphDef( gl ); + + gf.saveAsPNG("/demo_graph2.png", 0, 200); + + // Wrap up + gf.closeFiles(); + + // Print out timing information for the new package API + long s2 = Calendar.getInstance().getTimeInMillis(); + System.out.println( "New package: " + (s2 - s1) + " ms" ); + // -------------------------------------------------------- + + + // -------------------------------------------------------- + RrdGraphDef gDef = new RrdGraphDef(); gDef.setTimePeriod(start, end); ! ! gDef.setTitle("Server load\nCPU usage"); ! gDef.setValueAxisLabel("server load"); ! gDef.setBackColor( Color.DARK_GRAY ); ! gDef.setCanvasColor( Color.LIGHT_GRAY ); ! gDef.setImageBorder( Color.BLACK, 1 ); ! gDef.setFontColor( Color.WHITE ); ! gDef.setMajorGridColor(Color.YELLOW); ! gDef.setMinorGridColor( new Color( 130, 30, 30) ); ! gDef.setFrameColor( Color.BLACK ); ! gDef.setAxisColor( Color.RED ); ! gDef.setArrowColor( Color.GREEN ); ! // gDef.setGridX( false ); ! // gDef.setGridY( false ); ! // gDef.setFrontGrid(false); ! gDef.setShowLegend(true); ! // gDef.setAntiAliasing(false); ! gDef.datasource("load", "c:/test.rrd", "serverLoad", "AVERAGE"); gDef.datasource("user", "c:/test.rrd", "serverCPUUser", "AVERAGE"); *************** *** 65,71 **** gDef.datasource("p75t90", "busy,75,GT,busy,90,LE,load,0,IF,0,IF"); gDef.datasource("p90t100", "busy,90,GT,load,0,IF"); gDef.comment("CPU utilization (%)\n"); gDef.comment(" "); ! gDef.hrule( 7.0, Color.YELLOW, null, 10f); gDef.area("load", new Color(0x66,0x99,0xcc), " 0 - 25%"); gDef.area("p25t50", new Color(0x00,0x66,0x99), "25 - 50%"); --- 194,201 ---- gDef.datasource("p75t90", "busy,75,GT,busy,90,LE,load,0,IF,0,IF"); gDef.datasource("p90t100", "busy,90,GT,load,0,IF"); + gDef.comment("CPU utilization (%)\n"); gDef.comment(" "); ! //gDef.hrule( 7.0, Color.YELLOW, null, 10f); gDef.area("load", new Color(0x66,0x99,0xcc), " 0 - 25%"); gDef.area("p25t50", new Color(0x00,0x66,0x99), "25 - 50%"); *************** *** 99,130 **** gDef.comment("\n"); gDef.comment("-------------------------------------------------------------------------------@c"); ! gDef.vrule( new GregorianCalendar(2003, 7, 24, 9, 00), Color.BLUE, "9am", 2f ); ! gDef.vrule( new GregorianCalendar(2003, 7, 24, 17, 00), Color.BLUE, "5pm", 3f ); 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.YELLOW); ! gDef.setMinorGridColor( new Color( 130, 30, 30) ); ! gDef.setFrameColor( Color.BLACK ); ! gDef.setAxisColor( Color.RED ); ! gDef.setArrowColor( Color.GREEN ); //gDef.setChartLeftPadding( 40 ); - //gDef.setAntiAliasing(false); //gDef.setTimeAxis( TimeAxisUnit.HOUR, 6, TimeAxisUnit.DAY, 1, "EEEEE dd MMM", true ); //gDef.setValueAxis( 2.5, 5 ); - // Create actual graph - RrdGraph graph = new RrdGraph(gDef); - graph.saveAsPNG("/zzzzzz.png", 0, 0); - graph.saveAsJPEG("/zzzzzz.jpg", 0, 0, 1f); - //System.exit(0); // -- New graph RrdGraphDef gd = new RrdGraphDef(); --- 229,255 ---- gDef.comment("\n"); gDef.comment("-------------------------------------------------------------------------------@c"); ! //gDef.vrule( new GregorianCalendar(2003, 7, 24, 9, 00), Color.BLUE, "9am", 2f ); ! //gDef.vrule( new GregorianCalendar(2003, 7, 24, 17, 00), Color.BLUE, "5pm", 3f ); gDef.comment("Generated: " + new Date() + "@r"); ! ! // Create actual graph ! s1 = Calendar.getInstance().getTimeInMillis(); ! ! jrobin.graph.RrdGraph graph = new jrobin.graph.RrdGraph(gDef); ! graph.saveAsPNG("/zzzzzz.png", 0, 0); ! //graph.saveAsJPEG("/zzzzzz.jpg", 0, 0, 1f); ! ! //gDef.setOverlay("/pkts.png"); ! ! //gDef.setChartLeftPadding( 40 ); //gDef.setTimeAxis( TimeAxisUnit.HOUR, 6, TimeAxisUnit.DAY, 1, "EEEEE dd MMM", true ); //gDef.setValueAxis( 2.5, 5 ); + // -------------------------------------------------------- + + + // -- New graph RrdGraphDef gd = new RrdGraphDef(); *************** *** 141,147 **** gd.gprint("in", "AVERAGE", "Maximum: @6.2@s"); gd.setRigidGrid(true); ! RrdGraph graph2 = new RrdGraph(gd); graph2.saveAsPNG("/traff.png", 0, 0); ////////////////////////////// gd = new RrdGraphDef(); --- 266,281 ---- gd.gprint("in", "AVERAGE", "Maximum: @6.2@s"); gd.setRigidGrid(true); ! jrobin.graph.RrdGraph graph2 = new jrobin.graph.RrdGraph(gd); graph2.saveAsPNG("/traff.png", 0, 0); + + + // Print out timings for the old graph API + s2 = Calendar.getInstance().getTimeInMillis(); + System.out.println( "Old package: " + (s2 - s1) + " ms" ); + + System.exit(0); + + ////////////////////////////// gd = new RrdGraphDef(); *************** *** 155,159 **** gd.line("out", Color.BLUE, null); //gd.setUnitsExponent(6); ! graph2 = new RrdGraph(gd); graph2.saveAsPNG("/pkts.png", 0, 0); --- 289,293 ---- gd.line("out", Color.BLUE, null); //gd.setUnitsExponent(6); ! graph2 = new jrobin.graph.RrdGraph(gd); graph2.saveAsPNG("/pkts.png", 0, 0); *************** *** 164,168 **** gd.area("ftp", Color.BLUE, null); ! graph2 = new RrdGraph(gd); graph2.saveAsPNG("/ftp.png", 0, 0); --- 298,302 ---- gd.area("ftp", Color.BLUE, null); ! graph2 = new jrobin.graph.RrdGraph(gd); graph2.saveAsPNG("/ftp.png", 0, 0); Index: JRobinGallery.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/demo/JRobinGallery.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JRobinGallery.java 17 Oct 2003 14:41:47 -0000 1.1 --- JRobinGallery.java 21 Oct 2003 19:42:00 -0000 1.2 *************** *** 1,6 **** package jrobin.demo; ! import jrobin.graph.RrdGraphDef; ! import jrobin.graph.RrdGraph; import jrobin.core.RrdException; --- 1,6 ---- package jrobin.demo; ! import jrobin.graph2.RrdGraphDef; ! import jrobin.graph2.RrdGraph; import jrobin.core.RrdException; *************** *** 26,30 **** def.datasource("sine", "TIME," + t0 + ",-," + (t1 - t0) + ",/,7,PI,*,*,SIN"); ! def.datasource("v2", "demo.rrd", "shade", "AVERAGE"); def.datasource("cosine", "TIME," + t0 + ",-," + (t1 - t0) + ",/,3,PI,*,*,COS"); --- 26,30 ---- def.datasource("sine", "TIME," + t0 + ",-," + (t1 - t0) + ",/,7,PI,*,*,SIN"); ! def.datasource("v2", "/gallery.rrd", "shade", "AVERAGE"); def.datasource("cosine", "TIME," + t0 + ",-," + (t1 - t0) + ",/,3,PI,*,*,COS"); *************** *** 48,59 **** } def.line("v2", Color.YELLOW, null); ! def.line("v1", Color.BLUE, "Input voltage", 3); def.line("v1", Color.YELLOW, null, 1); - def.comment("fancy looking graphs@r"); def.setTitle("Voltage measurement"); ! def.setValueAxisLabel("[Volts]"); ! def.setValueStep(100); RrdGraph graph = new RrdGraph(def); ! graph.saveAsPNG("demo7.png", 400, 250); } --- 48,61 ---- } def.line("v2", Color.YELLOW, null); ! def.line("v1", Color.BLUE, "Input voltage@L", 3); def.line("v1", Color.YELLOW, null, 1); def.setTitle("Voltage measurement"); ! def.setVerticalLabel("[Volts]"); ! //def.setValueAxisLabel("[Volts]"); ! def.comment("fancy looking graphs@r"); ! //def.setValueStep(100); RrdGraph graph = new RrdGraph(def); ! graph.saveAsPNG("/demo7.png", 400, 250); ! //graph.saveAsPNG("/demo7.png"); } *************** *** 77,94 **** def.datasource("blank2", "v1,0,LT,v2,0,LT,AND,v1,v2,MAX,0,IF"); def.datasource("median", "v1,v2,+,2,/"); ! def.line("median", Color.YELLOW, "safe zone\n"); def.area("v1", Color.WHITE, null); ! def.stack("diff", Color.YELLOW, "safe zone"); def.area("blank1", Color.WHITE, null); def.area("blank2", Color.WHITE, null); def.line("v1", Color.BLUE, null, 1); def.line("v2", Color.BLUE, null, 1); - def.gprint("absdiff", "MAX", "max safe: @2V"); - def.gprint("absdiff", "AVERAGE", "avg safe: @2V"); - def.comment("fancy looking graphs@r"); def.setTitle("Voltage measurement"); ! def.setValueAxisLabel("[Volts]"); RrdGraph graph = new RrdGraph(def); ! graph.saveAsPNG("demo6.png", 400, 250); } --- 79,98 ---- def.datasource("blank2", "v1,0,LT,v2,0,LT,AND,v1,v2,MAX,0,IF"); def.datasource("median", "v1,v2,+,2,/"); ! def.line("median", Color.YELLOW, null); def.area("v1", Color.WHITE, null); ! def.stack("diff", Color.YELLOW, "safe zone\n"); def.area("blank1", Color.WHITE, null); def.area("blank2", Color.WHITE, null); def.line("v1", Color.BLUE, null, 1); def.line("v2", Color.BLUE, null, 1); def.setTitle("Voltage measurement"); ! def.setVerticalLabel("[Volts]"); ! //def.setValueAxisLabel("[Volts]"); ! def.gprint("absdiff", "MAX", "max safe: @2V"); ! def.gprint("absdiff", "AVERAGE", "avg safe: @2V@L"); ! def.comment("fancy looking graph@r"); RrdGraph graph = new RrdGraph(def); ! //graph.saveAsPNG("/demo6.png"); ! graph.saveAsPNG("/demo6.png", 400, 250); } |