org.jrobin.graph
Class RrdGraphDef

java.lang.Object
  extended by org.jrobin.graph.RrdExportDef
      extended by org.jrobin.graph.RrdGraphDef
All Implemented Interfaces:
Serializable

public class RrdGraphDef
extends RrdExportDef
implements Serializable

Class used to collect information for a JRobin graph. JRobin graphs have many options and this class has methods and properties to set them.

The JRobin graph package was designed to create graphs that have the same look as the RRDTool counter parts. Almost all the same graphing options are available, with some extra's like more advanced text alignment and custom point-to-point lines and area's.

To learn more about RDTool's graphs see RRDTool's rrdgraph man page. This man page is important: JRobin uses the same concept of graph sources definition (DEF directives) and supports RPN extensions in complex datasource definitions (RRDTool's CDEF directives).

RrdGraphDef class does not actually create any graph. It just collects necessary information. Graph will be created when you pass RrdGraphDef object to a RrdGraph, either by passing it to the constructor or using the setGraphDef() method.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jrobin.graph.RrdExportDef
cdefList, edefList, exportList, fetchSources, pdefList, STRICT_EXPLICIT_OFF, STRICT_EXPLICIT_ON, STRICT_IMPLICIT_OFF, STRICT_IMPLICIT_ON
 
Constructor Summary
RrdGraphDef()
          Constructs a new default JRobin graph object.
RrdGraphDef(Date start, Date end)
          Constructs a new JRobin graph object, with a specified time span to be presented on the graph.
RrdGraphDef(GregorianCalendar start, GregorianCalendar end)
          Constructs a new JRobin graph object, with a specified time span to be presented on the graph.
RrdGraphDef(long startTime, long endTime)
          Constructs a new JRobin graph object, with a specified time span to be presented on the graph.
 
Method Summary
 void area(GregorianCalendar t1, double v1, GregorianCalendar t2, double v2, Color color, String legend)
          Adds area plot to the graph definition, based on two points.
 void area(String sourceName, Color color, String legend)
          Adds area plot to the graph definition, using the specified color and legend.
 void comment(String text)
          Adds comment to the graph definition.
protected  boolean drawFrontGrid()
           
 void exportXmlTemplate(OutputStream stream)
          Exports RrdGraphDef (graph definition) object in XML format to output stream.
protected  Color getArrowColor()
           
protected  Color getAxisColor()
           
protected  Color getBackColor()
           
protected  File getBackground()
           
protected  double getBaseValue()
           
protected  Color getBorderColor()
           
protected  BasicStroke getBorderStroke()
           
protected  Color getCanvasColor()
           
protected  int getChartLeftPadding()
           
protected  int getCommentLineCount()
           
protected  org.jrobin.graph.Comment[] getComments()
           
protected  Font getDefaultFont()
           
protected  Color getDefaultFontColor()
           
protected  int getFirstDayOfWeek()
           
protected  Color getFrameColor()
           
protected  org.jrobin.graph.GridRange getGridRange()
           
protected  Color getImageBorderColor()
           
protected  BasicStroke getImageBorderStroke()
           
protected  Color getMajorGridColor()
           
protected  Color getMinorGridColor()
           
protected  File getOverlay()
           
protected  org.jrobin.graph.PlotDef[] getPlotDefs()
           
protected  int getScaleIndex()
           
protected  TimeAxisUnit getTimeAxis()
           
protected  org.jrobin.graph.Title getTitle()
           
protected  Font getTitleFont()
           
protected  Color getTitleFontColor()
           
protected  org.jrobin.graph.ValueAxisUnit getValueAxis()
           
protected  String getVerticalLabel()
           
 void gprint(String sourceName, String consolFun, String format)
          Calculate the chosen consolidation function consolFun over the graph sourceName and prints the result on the graph using the specified format string.
 void gprint(String sourceName, String consolFun, String format, double base)
          See the gprint() method for more details.
 void hrule(double value, Color color, String legend)
          Adds horizontal rule to the graph definition.
 void hrule(double value, Color color, String legend, int lineWidth)
          Adds horizontal rule to the graph definition.
protected  boolean isFrontGrid()
           
protected  boolean isLazy()
           
 void line(GregorianCalendar t1, double v1, GregorianCalendar t2, double v2, Color color, String legend, int lineWidth)
          Adds line plot to the graph definition, based on two points.
 void line(String sourceName, Color color, String legend)
          Adds line plot to the graph definition, using the specified color and legend.
 void line(String sourceName, Color color, String legend, int lineWidth)
          Adds line plot to the graph definition, using the specified color, legend and line width.
 void setAntiAliasing(boolean aa)
          Set the anti-aliasing option for the drawing area of the graph.
 void setArrowColor(Color c)
          Determines the color of the small axis arrow on the chart X axis.
 void setAxisColor(Color c)
          Determines the color of chart X axis.
 void setBackColor(Color backColor)
          Sets image background color.
 void setBackground(String fileName)
          Sets a background image to use for the graph.
 void setBaseValue(double base)
          Sets the base for value scaling.
 void setCanvasColor(Color canvasColor)
          Sets chart area background color.
 void setChartLeftPadding(int lp)
          Set the number of pixels on the left of the chart area ( value marker space ).
 void setDefaultFont(Font f)
          Sets the default font to be used in the graph as a java.awt.Font object.
 void setDefaultFontColor(Color c)
          Sets the color of the default font used in the graph as a java.awt.Color object.
 void setFirstDayOfWeek(int day)
          Sets the first day of a calendar week, defaults to monday if not set.
 void setFrameColor(Color c)
          Determines the color of chart area frame.
 void setFrontGrid(boolean frontGrid)
          Determine if the graph grid is in front of the chart itself, or behind it.
 void setGridRange(double lower, double upper, boolean rigid)
          Sets value range that will be presented in the graph.
 void setGridX(boolean visible)
          Determines if the X axis grid should be drawn.
 void setGridY(boolean visible)
          Determines if the Y axis grid should be drawn.
 void setImageBorder(Color c, int w)
          Specifies the settings of the image border.
 void setLazy(boolean lazyGeneration)
          Sets the 'lazy' flag for this GraphDef.
 void setLowerLimit(double lower)
          This sets the lower limit of the grid to the specified value, see setGridRange(double, double, boolean).
 void setMajorGridColor(Color c)
          Sets the color of the chart's major grid.
 void setMajorGridX(boolean visible)
          Determines if the major grid with labels for the X axis needs to be drawn.
 void setMajorGridY(boolean visible)
          Determines if the major grid with labels for the Y axis needs to be drawn.
 void setMinorGridColor(Color c)
          Determines the color of chart's the minor grid.
 void setMinorGridX(boolean visible)
          Determines if the minor grid for the X axis needs to be drawn.
 void setMinorGridY(boolean visible)
          Determines if the minor grid for the Y axis needs to be drawn.
 void setOverlay(String fileName)
          Sets a overlay image to use for the graph.
 void setShowLegend(boolean showLegend)
          Determine if the legend should be visible or not, default: visible.
 void setShowSignature(boolean showSignature)
          Determine if the default JRobin signature should be visible, default: yes.
 void setTimeAxis(int minGridTimeUnit, int minGridUnitSteps, int majGridTimeUnit, int majGridUnitSteps, String dateFormat, boolean centerLabels)
          This sets the grid and labels on the X axis.
 void setTimeAxisLabel(String label)
          Sets horizontal (time) axis label.
 void setTitle(String title)
          Sets graph title.
 void setTitleFont(Font f)
          Sets the font to be used for the graph title as a java.awt.Font object.
 void setTitleFontColor(Color c)
          Sets the color of the title font used in the graph as a java.awt.Color object.
 void setUnitsExponent(int e)
          This sets the 10** exponent scaling of the Y-axis values.
 void setValueAxis(double gridStep, double labelStep)
          This sets the grid and labels on the Y axis.
 void setVerticalLabel(String label)
          Sets vertical (value) axis label.
protected  boolean showGridX()
           
protected  boolean showGridY()
           
protected  boolean showLegend()
           
protected  boolean showMajorGridX()
           
protected  boolean showMajorGridY()
           
protected  boolean showMinorGridX()
           
protected  boolean showMinorGridY()
           
protected  boolean showSignature()
           
 void stack(String sourceName, Color color, String legend)
          Adds stacked plot to the graph definition, using the specified color and legend.
 void time(String text, DateFormat format)
          Adds a comment that will contain the current time, to the graph definition.
 void time(String text, DateFormat format, Calendar cal)
          Adds a comment that will contain the given timestamp, to the graph definition.
 void time(String text, DateFormat format, Date date)
          Adds a comment that will contain the given timestamp, to the graph definition.
 void time(String text, DateFormat format, long timestamp)
          Adds a comment that will contain the given timestamp, to the graph definition.
 void time(String text, String pattern)
          Adds a comment that will contain the current time, to the graph definition.
 void time(String text, String pattern, Calendar cal)
          Adds a comment that will contain the given timestamp, to the graph definition.
 void time(String text, String pattern, Date date)
          Adds a comment that will contain the given timestamp, to the graph definition.
 void time(String text, String pattern, long timestamp)
          Adds a comment that will contain the given timestamp, to the graph definition.
protected  boolean useAntiAliasing()
           
 void vrule(GregorianCalendar timestamp, Color color, String legend)
          Adds a vertical rule to the graph definition.
 void vrule(GregorianCalendar timestamp, Color color, String legend, int lineWidth)
          Adds a vertical rule to the graph definition.
 
Methods inherited from class org.jrobin.graph.RrdExportDef
addExportData, datasource, datasource, datasource, datasource, datasource, datasource, datasource, export, export, exportXmlTemplate, exportXmlTemplate, getCdefs, getEndTime, getExportData, getExportDatasources, getFetchSources, getNumDefs, getNumSdefs, getPdefs, getResolution, getStartTime, getXmlTemplate, isStrict, setDatasources, setResolution, setStrictExport, setTimePeriod, setTimePeriod, setTimePeriod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RrdGraphDef

public RrdGraphDef()
Constructs a new default JRobin graph object.


RrdGraphDef

public RrdGraphDef(long startTime,
                   long endTime)
            throws RrdException
Constructs a new JRobin graph object, with a specified time span to be presented on the graph. Using timestamps defined as number of seconds since the epoch.

Parameters:
startTime - Starting timestamp in seconds.
endTime - Ending timestamp in seconds.
Throws:
RrdException - Thrown if invalid parameters are supplied.

RrdGraphDef

public RrdGraphDef(Date start,
                   Date end)
            throws RrdException
Constructs a new JRobin graph object, with a specified time span to be presented on the graph. Time spam defined using java.util.Date objects.

Parameters:
start - Starting time.
end - Ending time.
Throws:
RrdException - Thrown in case of invalid parameters.

RrdGraphDef

public RrdGraphDef(GregorianCalendar start,
                   GregorianCalendar end)
            throws RrdException
Constructs a new JRobin graph object, with a specified time span to be presented on the graph. Time spam defined using java.util.GregorianCalendar objects.

Parameters:
start - Starting time.
end - Ending time.
Throws:
RrdException - Thrown in case of invalid parameters.
Method Detail

setLazy

public void setLazy(boolean lazyGeneration)
Sets the 'lazy' flag for this GraphDef. This means that upon graph generation and saving to a file, JRobin will first check that if that file already exists, the 'last modified' timestamp of the file is smaller than 'last update' timestamp of the used datasources. Only if that is indeed the case and the image file is outdated, will the graph be generated.

Parameters:
lazyGeneration - True if the script should only generate.

setTitle

public void setTitle(String title)
              throws RrdException
Sets graph title.

Parameters:
title - Graph title.
Throws:
RrdException

setVerticalLabel

public void setVerticalLabel(String label)
Sets vertical (value) axis label.

Parameters:
label - Vertical axis label.

setTimeAxisLabel

public void setTimeAxisLabel(String label)
                      throws RrdException
Sets horizontal (time) axis label.

A horizontal axis label is always center aligned by default, with an extra linefeed to add some space before the regular comment lines start. If you wish to remove the extra line of whitespace you should specify the alignment in the label using @c, @l or @r. Using the @C, @L or @R markers will align the text appropriately, and leave the extra line of whitespace intact.

It is possible to use multiple lines and multiple alignment markers for the axis label, in that case you should specify alignment for every part of the label to get it to display correctly. When using multiple lines, no markers will be added to the end of the last line by default.

Parameters:
label - Horizontal axis label.
Throws:
RrdException

setBackColor

public void setBackColor(Color backColor)
Sets image background color. If not set, back color defaults to a very light gray.

Parameters:
backColor - Graph background color.

setCanvasColor

public void setCanvasColor(Color canvasColor)
Sets chart area background color. If not set, canvas color defaults to white.

Parameters:
canvasColor - Chart area background color.

setImageBorder

public void setImageBorder(Color c,
                           int w)
Specifies the settings of the image border. Default is sort of beveled border around the image. To disable the image border, just specify a pixel width of 0.

Parameters:
c - Bordercolor of the image.
w - Pixel width of the image border.

setTitleFontColor

public void setTitleFontColor(Color c)
Sets the color of the title font used in the graph as a java.awt.Color object. Default title font color is black.

Parameters:
c - The color to be used.

setDefaultFontColor

public void setDefaultFontColor(Color c)
Sets the color of the default font used in the graph as a java.awt.Color object. Default font color is black.

Parameters:
c - The color to be used.

setTitleFont

public void setTitleFont(Font f)
Sets the font to be used for the graph title as a java.awt.Font object. Default title font is "Lucida Sans Typewriter", with BOLD attributes and a size of 12 points.

Parameters:
f - The Font to be used.

setDefaultFont

public void setDefaultFont(Font f)
Sets the default font to be used in the graph as a java.awt.Font object. Default font is "Lucida Sans Typewriter", with PLAIN attributes and a size of 10 points.

Parameters:
f - The Font to be used.

setMajorGridColor

public void setMajorGridColor(Color c)
Sets the color of the chart's major grid. Grid labels have the same color as the default font.

Parameters:
c - Color to use.

setMinorGridColor

public void setMinorGridColor(Color c)
Determines the color of chart's the minor grid.

Parameters:
c - Color to use.

setFrameColor

public void setFrameColor(Color c)
Determines the color of chart area frame.

Parameters:
c - Color to use.

setAxisColor

public void setAxisColor(Color c)
Determines the color of chart X axis.

Parameters:
c - Color to use.

setArrowColor

public void setArrowColor(Color c)
Determines the color of the small axis arrow on the chart X axis.

Parameters:
c - Color to use.

setMinorGridX

public void setMinorGridX(boolean visible)
Determines if the minor grid for the X axis needs to be drawn.

Parameters:
visible - True if minor grid needs to be drawn, false if not.

setMinorGridY

public void setMinorGridY(boolean visible)
Determines if the minor grid for the Y axis needs to be drawn.

Parameters:
visible - True if minor grid needs to be drawn, false if not.

setMajorGridX

public void setMajorGridX(boolean visible)
Determines if the major grid with labels for the X axis needs to be drawn.

Parameters:
visible - True if major grid needs to be drawn, false if not.

setMajorGridY

public void setMajorGridY(boolean visible)
Determines if the major grid with labels for the Y axis needs to be drawn.

Parameters:
visible - True if major grid needs to be drawn, false if not.

setGridX

public void setGridX(boolean visible)
Determines if the X axis grid should be drawn.

Parameters:
visible - True if grid needs to be drawn, false if not.

setGridY

public void setGridY(boolean visible)
Determines if the Y axis grid should be drawn.

Parameters:
visible - True if grid needs to be drawn, false if not.

setFrontGrid

public void setFrontGrid(boolean frontGrid)
Determine if the graph grid is in front of the chart itself, or behind it. Default is in front of the chart.

Parameters:
frontGrid - True if the grid is in front of the chart.

setShowLegend

public void setShowLegend(boolean showLegend)
Determine if the legend should be visible or not, default: visible. Invisible legend area means no comments will be plotted, and the graph will be smaller in height.

Parameters:
showLegend - True if the legend is visible.

setShowSignature

public void setShowSignature(boolean showSignature)
Determine if the default JRobin signature should be visible, default: yes. The signature text is "www.jrobin.org" and the signature is centered at the bottom of the graph. Unless you have a good reason not to draw the signature, please be so kind as to leave the signature visible. Disabling the signature can give a minor performance boost.

Parameters:
showSignature - True if the signature is visible.

setAntiAliasing

public void setAntiAliasing(boolean aa)
Set the anti-aliasing option for the drawing area of the graph. Default uses anti-aliasing.

Parameters:
aa - True if anti-aliasing is on, false if off

setChartLeftPadding

public void setChartLeftPadding(int lp)
Set the number of pixels on the left of the chart area ( value marker space ).

Parameters:
lp - Number of pixels used, defaults to 50.

setBackground

public void setBackground(String fileName)
Sets a background image to use for the graph. The image can be any of the supported imageio formats, default .gif, .jpg or .png. Please note: if the provided file does not exit at graph creation time, the corresponding graph will be created without the background image, and without any exception being thrown.

Parameters:
fileName - Filename of the image to use

setOverlay

public void setOverlay(String fileName)
Sets a overlay image to use for the graph. The image can be any of the supported imageio formats, default .gif, .jpg or .png. All pixels with the color white RGB (255, 255, 255) will be treated as transparent. Please note: if the provided file does not exit at graph creation time, the corresponding graph will be created without the overlay image, and without any exception being thrown.

Parameters:
fileName - Filename of the image to use

setBaseValue

public void setBaseValue(double base)
Sets the base for value scaling. If you are graphing memory this should be set to 1024 so that one Kb is 1024 bytes. As a default the base value is set to 1000, under the assumption you will be measuring network traffic, in wich case 1 kb/s equals 1000 b/s.

Parameters:
base - Value to set as base for scaling.

setUnitsExponent

public void setUnitsExponent(int e)
This sets the 10** exponent scaling of the Y-axis values. Normally values will be scaled to the appropriate units (k, M, etc.). However you may wish to display units always in k (Kilo, 10e3) even if the data is in the M (Mega, 10e6) range for instance. Value should be an integer which is a multiple of 3 between -18 and 18 inclusive. It is the exponent on the units you which to use. For example, use 3 to display the y-axis values in k (Kilo, 10e3, thousands), use -6 to display the y-axis values in u (Micro, 10e-6, millionths). Use a value of 0 to prevent any scaling of the y-axis values.

Parameters:
e - Exponent value to use

setGridRange

public void setGridRange(double lower,
                         double upper,
                         boolean rigid)
Sets value range that will be presented in the graph. If not set, graph limits will be autoscaled. If you wish to specify one limit but leave the other auto-scaled, specify the value as Double.NaN fot the limit that should be auto-scaled.

Parameters:
lower - Lower limit.
upper - Upper limit.
rigid - Rigid grid, won't autoscale limits.

setLowerLimit

public void setLowerLimit(double lower)
This sets the lower limit of the grid to the specified value, see setGridRange(double, double, boolean). This is the equivalent of: setGridRange( lower, Double.NaN, false );

Parameters:
lower - Lower limit.

setValueAxis

public void setValueAxis(double gridStep,
                         double labelStep)
This sets the grid and labels on the Y axis. Minor grid lines appear at gridStep, major grid lines accompanied by a label will appear every labelStep value.

Parameters:
gridStep - Value step on which a minor grid line will appear.
labelStep - Value step on which a major grid line with value label will appear.

setTimeAxis

public void setTimeAxis(int minGridTimeUnit,
                        int minGridUnitSteps,
                        int majGridTimeUnit,
                        int majGridUnitSteps,
                        String dateFormat,
                        boolean centerLabels)
This sets the grid and labels on the X axis. There are both minor and major grid lines, the major lines are accompanied by a time label. To define a grid line you must define a specific time unit, and a number of time steps. A grid line will appear everey steps*unit. Possible units are defined in the TimeAxisUnit class, and are SECOND, MINUTE, HOUR, DAY, WEEK, MONTH and YEAR.

Parameters:
minGridTimeUnit - Time unit for the minor grid lines.
minGridUnitSteps - Time unit steps for the minor grid lines.
majGridTimeUnit - Time unit for the major grid lines.
majGridUnitSteps - Time unit steps for the major grid lines.
dateFormat - Format string of the time labels, according to java.text.SimpleDateFormat specifications.
centerLabels - True if the time label should be centered in the area between two major grid lines.

setFirstDayOfWeek

public void setFirstDayOfWeek(int day)
Sets the first day of a calendar week, defaults to monday if not set.

Parameters:
day - Weekday, 0 for sunday, 6 for saturday.

line

public void line(String sourceName,
                 Color color,
                 String legend)
          throws RrdException
Adds line plot to the graph definition, using the specified color and legend. This method takes exactly the same parameters as RRDTool's LINE1 directive (line width is set to 1). The legend allows for the same alignment options as gprint or comment.

Parameters:
sourceName - Graph source name.
color - Line collor to be used.
legend - Legend to be printed on the graph.
Throws:
RrdException - Thrown if invalid graph source name is supplied.

line

public void line(String sourceName,
                 Color color,
                 String legend,
                 int lineWidth)
          throws RrdException
Adds line plot to the graph definition, using the specified color, legend and line width. This method takes exactly the same parameters as RRDTool's LINE directive. The legend allows for the same alignment options as gprint or comment.

Parameters:
sourceName - Graph source name.
color - Line color to be used.
legend - Legend to be printed on the graph.
lineWidth - Width of the line in pixels.
Throws:
RrdException - Thrown if invalid graph source name is supplied.

line

public void line(GregorianCalendar t1,
                 double v1,
                 GregorianCalendar t2,
                 double v2,
                 Color color,
                 String legend,
                 int lineWidth)
          throws RrdException
Adds line plot to the graph definition, based on two points. Start and end point of the line are specified. The legend allows for the same alignment options as gprint or comment.

Parameters:
t1 - Timestamp (X axis) of the start point of the line.
v1 - Value (Y axis) of the start point of the line.
t2 - Timestamp (X axis) of the end point of the line.
v2 - Value (Y axis) of the end point of the line.
color - Line color to be used.
legend - Legend to be printed on the graph.
lineWidth - Width of the line in pixels.
Throws:
RrdException - Thrown if invalid graph source name is supplied.

area

public void area(String sourceName,
                 Color color,
                 String legend)
          throws RrdException
Adds area plot to the graph definition, using the specified color and legend. This method takes exactly the same parameters as RRDTool's AREA directive. The legend allows for the same alignment options as gprint or comment.

Parameters:
sourceName - Graph source name.
color - Filling collor to be used for area plot.
legend - Legend to be printed on the graph.
Throws:
RrdException - Thrown if invalid graph source name is supplied.

area

public void area(GregorianCalendar t1,
                 double v1,
                 GregorianCalendar t2,
                 double v2,
                 Color color,
                 String legend)
          throws RrdException
Adds area plot to the graph definition, based on two points. Points specified are the bottom-left corner and the upper-right corner. When stacked onto such an area, a stack is always placed on top of the "upper border" of the rectangle (value of the second point). The legend allows for the same alignment options as gprint or comment.

Parameters:
t1 - Timestamp (X axis) of the bottom-left corner of the area.
v1 - Value (Y axis) of the bottom-left corner of the area.
t2 - Timestamp (X axis) of the upper-right corner of the area.
v2 - Value (Y axis) of the upper-right corner of the area.
color - Filling collor to be used for area plot.
legend - Legend to be printed on the graph.
Throws:
RrdException - Thrown if invalid graph source name is supplied.

stack

public void stack(String sourceName,
                  Color color,
                  String legend)
           throws RrdException
Adds stacked plot to the graph definition, using the specified color and legend. This method takes exactly the same parameters as RRDTool's STACK directive. The legend allows for the same alignment options as gprint or comment.

Parameters:
sourceName - Graph source name.
color - Collor to be used.
legend - Legend to be printed on the graph.
Throws:
RrdException - Thrown if invalid graph source name is supplied.

hrule

public void hrule(double value,
                  Color color,
                  String legend)
           throws RrdException
Adds horizontal rule to the graph definition. The legend allows for the same alignment options as gprint or comment.

Parameters:
value - Rule posiotion.
color - Rule color.
legend - Legend to be added to the graph.
Throws:
RrdException - Thrown in case of JRobin specific error.

hrule

public void hrule(double value,
                  Color color,
                  String legend,
                  int lineWidth)
           throws RrdException
Adds horizontal rule to the graph definition. The legend allows for the same alignment options as gprint or comment.

Parameters:
value - Rule posiotion.
color - Rule color.
legend - Legend to be added to the graph.
lineWidth - Width of the hrule line in pixels.
Throws:
RrdException - Thrown in case of JRobin specific error.

vrule

public void vrule(GregorianCalendar timestamp,
                  Color color,
                  String legend)
           throws RrdException
Adds a vertical rule to the graph definition. The legend allows for the same alignment options as gprint or comment.

Parameters:
timestamp - Rule position (specific moment in time)
color - Rule color.
legend - Legend to be added to the graph.
Throws:
RrdException

vrule

public void vrule(GregorianCalendar timestamp,
                  Color color,
                  String legend,
                  int lineWidth)
           throws RrdException
Adds a vertical rule to the graph definition. The legend allows for the same alignment options as gprint or comment.

Parameters:
timestamp - Rule position (specific moment in time)
color - Rule color.
legend - Legend to be added to the graph.
lineWidth - Width of the vrule in pixels.
Throws:
RrdException

comment

public void comment(String text)
             throws RrdException
Adds comment to the graph definition. A comment on the graph will be left, center or right aligned if the format string ends with @l, @c or @r, respectively. It is also possible to align text without adding a linefeed by using @L, @R and @C as markers. After a GPRINT some whitespace is appended by default. To suppress this whitespace put a @G marker at the very end of the string. By putting a @g marker instead all whitespace inside the string at very beginning or end will be removed also.

Parameters:
text - Comment
Throws:
RrdException - Thrown in case of JRobin specific error.

time

public void time(String text,
                 String pattern)
          throws RrdException
Adds a comment that will contain the current time, to the graph definition. Normal comment codes apply, but a special marker @t should be present for the location of the timestamp. The actual format of the printed timestamp is determined by the pattern parameter, for information on possible patterns, see java.text.SimpleDateFormat.

Parameters:
text - Comment text (must contain @t marker).
pattern - SimpleDateFormat pattern to format the timestamp with.
Throws:
RrdException - Thrown in case of JRobin specific error.

time

public void time(String text,
                 DateFormat format)
          throws RrdException
Adds a comment that will contain the current time, to the graph definition. Normal comment codes apply, but a special marker @t should be present for the location of the timestamp. The actual format of the printed timestamp is determined by the DateFormat passed as a parameter.

Parameters:
text - Comment text (must contain @t marker).
format - DateFormat object to format the timestamp with.
Throws:
RrdException - Thrown in case of JRobin specific error.

time

public void time(String text,
                 String pattern,
                 long timestamp)
          throws RrdException
Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes apply, but a special marker @t should be present for the location of the timestamp. The actual format of the printed timestamp is determined by the pattern parameter, for information on possible patterns, see java.text.SimpleDateFormat.

Parameters:
text - Comment text (must contain @t marker).
pattern - SimpleDateFormat pattern to format the timestamp with.
timestamp - Timestamp (in seconds) that should be formatted.
Throws:
RrdException - Thrown in case of JRobin specific error.

time

public void time(String text,
                 DateFormat format,
                 long timestamp)
          throws RrdException
Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes apply, but a special marker @t should be present for the location of the timestamp. The actual format of the printed timestamp is determined by the DateFormat passed as a parameter.

Parameters:
text - Comment text (must contain @t marker).
format - DateFormat object to format the timestamp with.
timestamp - Timestamp (in seconds) that should be formatted.
Throws:
RrdException - Thrown in case of JRobin specific error.

time

public void time(String text,
                 String pattern,
                 Date date)
          throws RrdException
Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes apply, but a special marker @t should be present for the location of the timestamp. The actual format of the printed timestamp is determined by the pattern parameter, for information on possible patterns, see java.text.SimpleDateFormat.

Parameters:
text - Comment text (must contain @t marker).
pattern - SimpleDateFormat pattern to format the timestamp with.
date - Timestamp (as Date object) that should be formatted.
Throws:
RrdException - Thrown in case of JRobin specific error.

time

public void time(String text,
                 DateFormat format,
                 Date date)
          throws RrdException
Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes apply, but a special marker @t should be present for the location of the timestamp. The actual format of the printed timestamp is determined by the DateFormat passed as a parameter.

Parameters:
text - Comment text (must contain @t marker).
format - DateFormat object to format the timestamp with.
date - Timestamp (as Date object) that should be formatted.
Throws:
RrdException - Thrown in case of JRobin specific error.

time

public void time(String text,
                 String pattern,
                 Calendar cal)
          throws RrdException
Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes apply, but a special marker @t should be present for the location of the timestamp. The actual format of the printed timestamp is determined by the pattern parameter, for information on possible patterns, see java.text.SimpleDateFormat.

Parameters:
text - Comment text (must contain @t marker).
pattern - SimpleDateFormat pattern to format the timestamp with.
cal - Timestamp (as Calendar) that should be formatted.
Throws:
RrdException - Thrown in case of JRobin specific error.

time

public void time(String text,
                 DateFormat format,
                 Calendar cal)
          throws RrdException
Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes apply, but a special marker @t should be present for the location of the timestamp. The actual format of the printed timestamp is determined by the DateFormat passed as a parameter.

Parameters:
text - Comment text (must contain @t marker).
format - DateFormat object to format the timestamp with.
cal - Timestamp (as Calendar) that should be formatted.
Throws:
RrdException - Thrown in case of JRobin specific error.

gprint

public void gprint(String sourceName,
                   String consolFun,
                   String format)
            throws RrdException

Calculate the chosen consolidation function consolFun over the graph sourceName and prints the result on the graph using the specified format string.

In the format string there should be a @n marker (replace n with the desired number of decimals) in the place where the number should be printed. If an additional @s is found in the format, the value will be scaled and an appropriate SI magnitude unit will be printed in place of the @s marker. If you specify @S instead of @s, the value will be scaled with the scale factor used in the last gprint directive (uniform value scaling).

The text printed on the graph will be left, center or right aligned if the format string ends with @l, @c or @r, respectively. It is also possible to align text without adding a linefeed by using @L, @R and @C as markers. After a GPRINT some whitespace is appended by default. To suppress this whitespace put a @G marker at the very end of the string. By putting a @g marker instead all whitespace inside the string at very beginning or end will be removed also.

Parameters:
sourceName - Graph source name
consolFun - Consolidation function to be used for calculation ("AVERAGE", "MIN", "MAX", "LAST" or "TOTAL" (since 1.3.1)
format - Format string. For example: "speed is @5.2 @sbits/sec@c", "temperature = @0 degrees"
Throws:
RrdException - Thrown in case of JRobin specific error

gprint

public void gprint(String sourceName,
                   String consolFun,
                   String format,
                   double base)
            throws RrdException

See the gprint() method for more details. This gprint implementation allows a specific base value to be specified for this particular gprint only, the specified base value can be different than the global base value used through the entire graph for the drawing. The resulting value of the gprint will be formatted according to the specified base value.

Parameters:
sourceName - Graph source name
consolFun - Consolidation function to be used for calculation ("AVERAGE", "MIN", "MAX", "LAST" or "TOTAL" (since 1.3.1)
format - Format string. For example: "speed is @5.2 @sbits/sec@c", "temperature = @0 degrees"
base - Base value for the formatting, defaults to the graphing base value
Throws:
RrdException - Thrown in case of JRobin specific error

exportXmlTemplate

public void exportXmlTemplate(OutputStream stream)
Exports RrdGraphDef (graph definition) object in XML format to output stream. Generated code can be parsed with RrdGraphDefTemplate class.

Overrides:
exportXmlTemplate in class RrdExportDef
Parameters:
stream - Output stream to send XML code to

isLazy

protected boolean isLazy()

getTitle

protected org.jrobin.graph.Title getTitle()

getVerticalLabel

protected String getVerticalLabel()

getBackColor

protected Color getBackColor()

getCanvasColor

protected Color getCanvasColor()

getImageBorderColor

protected Color getImageBorderColor()

getImageBorderStroke

protected BasicStroke getImageBorderStroke()

getTitleFontColor

protected Color getTitleFontColor()

getDefaultFontColor

protected Color getDefaultFontColor()

getTitleFont

protected Font getTitleFont()

getDefaultFont

protected Font getDefaultFont()

getMajorGridColor

protected Color getMajorGridColor()

getMinorGridColor

protected Color getMinorGridColor()

getFrameColor

protected Color getFrameColor()

getAxisColor

protected Color getAxisColor()

getArrowColor

protected Color getArrowColor()

getBorderColor

protected Color getBorderColor()

getBorderStroke

protected BasicStroke getBorderStroke()

showMinorGridX

protected boolean showMinorGridX()

showMinorGridY

protected boolean showMinorGridY()

showMajorGridX

protected boolean showMajorGridX()

showMajorGridY

protected boolean showMajorGridY()

showGridX

protected boolean showGridX()

showGridY

protected boolean showGridY()

drawFrontGrid

protected boolean drawFrontGrid()

showLegend

protected boolean showLegend()

showSignature

protected boolean showSignature()

isFrontGrid

protected boolean isFrontGrid()

useAntiAliasing

protected boolean useAntiAliasing()

getChartLeftPadding

protected int getChartLeftPadding()

getBackground

protected File getBackground()

getOverlay

protected File getOverlay()

getBaseValue

protected double getBaseValue()

getScaleIndex

protected int getScaleIndex()

getGridRange

protected org.jrobin.graph.GridRange getGridRange()

getValueAxis

protected org.jrobin.graph.ValueAxisUnit getValueAxis()

getTimeAxis

protected TimeAxisUnit getTimeAxis()

getFirstDayOfWeek

protected int getFirstDayOfWeek()

getPlotDefs

protected org.jrobin.graph.PlotDef[] getPlotDefs()

getComments

protected org.jrobin.graph.Comment[] getComments()

getCommentLineCount

protected int getCommentLineCount()