📄 rrdgraphdef.java
字号:
* @param legend Legend to be printed on the graph.
* @param lineWidth Width of the line in pixels.
* @throws RrdException Thrown if invalid graph source name is supplied.
*/
public void line( String sourceName, Color color, String legend, int lineWidth ) throws RrdException
{
plotDefs.add( new Line(sourceName, color, lineWidth) );
addLegend( legend, color );
}
/**
* 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 <code>gprint</code> or <code>comment</code>.
* @param t1 Timestamp (X axis) of the start point of the line.
* @param v1 Value (Y axis) of the start point of the line.
* @param t2 Timestamp (X axis) of the end point of the line.
* @param v2 Value (Y axis) of the end point of the line.
* @param color Line color to be used.
* @param legend Legend to be printed on the graph.
* @param lineWidth Width of the line in pixels.
* @throws RrdException Thrown if invalid graph source name is supplied.
*/
public void line( GregorianCalendar t1, double v1, GregorianCalendar t2, double v2, Color color, String legend, int lineWidth ) throws RrdException
{
plotDefs.add( new CustomLine( t1.getTimeInMillis() / 1000, v1, t2.getTimeInMillis() / 1000, v2, color, lineWidth ) );
addLegend( legend, color );
}
/**
* 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 <code>gprint</code> or <code>comment</code>.
*
* @param sourceName Graph source name.
* @param color Filling collor to be used for area plot.
* @param legend Legend to be printed on the graph.
* @throws RrdException Thrown if invalid graph source name is supplied.
*/
public void area( String sourceName, Color color, String legend ) throws RrdException
{
plotDefs.add( new Area(sourceName, color) );
addLegend( legend, color );
}
/**
* 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 <code>gprint</code> or <code>comment</code>.
* @param t1 Timestamp (X axis) of the bottom-left corner of the area.
* @param v1 Value (Y axis) of the bottom-left corner of the area.
* @param t2 Timestamp (X axis) of the upper-right corner of the area.
* @param v2 Value (Y axis) of the upper-right corner of the area.
* @param color Filling collor to be used for area plot.
* @param legend Legend to be printed on the graph.
* @throws RrdException Thrown if invalid graph source name is supplied.
*/
public void area( GregorianCalendar t1, double v1, GregorianCalendar t2, double v2, Color color, String legend ) throws RrdException
{
plotDefs.add( new CustomArea( t1.getTimeInMillis() / 1000, v1, t2.getTimeInMillis() / 1000, v2, color ) );
addLegend( legend, color );
}
/**
* 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 <code>gprint</code> or <code>comment</code>.
* @param sourceName Graph source name.
* @param color Collor to be used.
* @param legend Legend to be printed on the graph.
* @throws RrdException Thrown if invalid graph source name is supplied.
*/
public void stack( String sourceName, Color color, String legend ) throws RrdException
{
plotDefs.add( new Stack(sourceName, color) );
addLegend( legend, color );
}
/**
* Adds horizontal rule to the graph definition. The legend allows for the same
* alignment options as <code>gprint</code> or <code>comment</code>.
* @param value Rule posiotion.
* @param color Rule color.
* @param legend Legend to be added to the graph.
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void hrule(double value, Color color, String legend) throws RrdException {
plotDefs.add( new CustomLine( Long.MIN_VALUE, value, Long.MAX_VALUE, value, color ) );
addLegend( legend, color );
}
/**
* Adds horizontal rule to the graph definition. The legend allows for the same
* alignment options as <code>gprint</code> or <code>comment</code>.
* @param value Rule posiotion.
* @param color Rule color.
* @param legend Legend to be added to the graph.
* @param lineWidth Width of the hrule line in pixels.
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void hrule(double value, Color color, String legend, int lineWidth) throws RrdException {
plotDefs.add( new CustomLine( Long.MIN_VALUE, value, Long.MAX_VALUE, value, color, lineWidth ) );
addLegend( legend, color );
}
/**
* Adds a vertical rule to the graph definition. The legend allows for the same
* alignment options as <code>gprint</code> or <code>comment</code>.
* @param timestamp Rule position (specific moment in time)
* @param color Rule color.
* @param legend Legend to be added to the graph.
*/
public void vrule( GregorianCalendar timestamp, Color color, String legend ) throws RrdException {
long timeSecs = timestamp.getTimeInMillis() / 1000;
plotDefs.add( new CustomLine( timeSecs, Double.MIN_VALUE, timeSecs, Double.MAX_VALUE, color ) );
addLegend( legend, color );
}
/**
* Adds a vertical rule to the graph definition. The legend allows for the same
* alignment options as <code>gprint</code> or <code>comment</code>.
*
* @param timestamp Rule position (specific moment in time)
* @param color Rule color.
* @param legend Legend to be added to the graph.
* @param lineWidth Width of the vrule in pixels.
*/
public void vrule( GregorianCalendar timestamp, Color color, String legend, int lineWidth ) throws RrdException {
long timeSecs = timestamp.getTimeInMillis() / 1000;
plotDefs.add( new CustomLine( timeSecs, Double.MIN_VALUE, timeSecs, Double.MAX_VALUE, color, lineWidth ) );
addLegend( legend, color );
}
/**
* Adds comment to the graph definition. A comment on the graph will be left, center or right aligned
* if the format string ends with <code>@l</code>, <code>@c</code> or <code>@r</code>,
* respectively. It is also possible to align text without adding a linefeed by using
* <code>@L</code>, <code>@R</code> and <code>@C</code> as markers. After a GPRINT some
* whitespace is appended by default. To suppress this whitespace put a <code>@G</code>
* marker at the very end of the string. By putting a <code>@g</code> marker instead all
* whitespace inside the string at very beginning or end will be removed also.
*
* @param text Comment
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void comment(String text) throws RrdException {
addComment( new Comment(text) );
}
/**
* Adds a comment that will contain the current time, to the graph definition. Normal comment codes
* apply, but a special marker <code>@t</code> 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 <em>java.text.SimpleDateFormat</em>.
*
* @param text Comment text (must contain @t marker).
* @param pattern SimpleDateFormat pattern to format the timestamp with.
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void time( String text, String pattern ) throws RrdException {
addComment( new TimeText( text, pattern ) );
}
/**
* Adds a comment that will contain the current time, to the graph definition. Normal comment codes
* apply, but a special marker <code>@t</code> 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.
*
* @param text Comment text (must contain @t marker).
* @param format DateFormat object to format the timestamp with.
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void time( String text, DateFormat format ) throws RrdException {
addComment( new TimeText( text, format ) );
}
/**
* Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes
* apply, but a special marker <code>@t</code> 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 <em>java.text.SimpleDateFormat</em>.
*
* @param text Comment text (must contain @t marker).
* @param pattern SimpleDateFormat pattern to format the timestamp with.
* @param timestamp Timestamp (in seconds) that should be formatted.
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void time( String text, String pattern, long timestamp ) throws RrdException {
addComment( new TimeText( text, pattern, timestamp ) );
}
/**
* Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes
* apply, but a special marker <code>@t</code> 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.
*
* @param text Comment text (must contain @t marker).
* @param format DateFormat object to format the timestamp with.
* @param timestamp Timestamp (in seconds) that should be formatted.
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void time( String text, DateFormat format, long timestamp ) throws RrdException {
addComment( new TimeText( text, format, timestamp ) );
}
/**
* Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes
* apply, but a special marker <code>@t</code> 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 <em>java.text.SimpleDateFormat</em>.
*
* @param text Comment text (must contain @t marker).
* @param pattern SimpleDateFormat pattern to format the timestamp with.
* @param date Timestamp (as Date object) that should be formatted.
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void time( String text, String pattern, Date date ) throws RrdException {
addComment( new TimeText( text, pattern, date ) );
}
/**
* Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes
* apply, but a special marker <code>@t</code> 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.
*
* @param text Comment text (must contain @t marker).
* @param format DateFormat object to format the timestamp with.
* @param date Timestamp (as Date object) that should be formatted.
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void time( String text, DateFormat format, Date date ) throws RrdException {
addComment( new TimeText( text, format, date ) );
}
/**
* Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes
* apply, but a special marker <code>@t</code> 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 <em>java.text.SimpleDateFormat</em>.
*
* @param text Comment text (must contain @t marker).
* @param pattern SimpleDateFormat pattern to format the timestamp with.
* @param cal Timestamp (as Calendar) that should be formatted.
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void time( String text, String pattern, Calendar cal) throws RrdException {
addComment( new TimeText( text, pattern, cal ) );
}
/**
* Adds a comment that will contain the given timestamp, to the graph definition. Normal comment codes
* apply, but a special marker <code>@t</code> 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.
*
* @param text Comment text (must contain @t marker).
* @param format DateFormat object to format the timestamp with.
* @param cal Timestamp (as Calendar) that should be formatted.
* @throws RrdException Thrown in case of JRobin specific error.
*/
public void time( String text, DateFormat format, Calendar cal) throws RrdException {
addComment( new TimeText( text, format, cal ) );
}
/**
* <p>Calculate the chosen consolidation function <code>consolFun</code> over
* the graph <code>sourceName</code> and prints the result
* on the graph using the specified <code>format</code> string.</p>
*
* <p>In the format string there should be a
* <code>@n</code> marker (replace <code>n</code> with the desired number of decimals)
* in the place where the number should be printed. If an additional <code>@s</code> is
* found in the format, the value will be scaled and an appropriate SI magnitude
* unit will be printed in place of the <code>@s</code> marker. If you specify
* <code>@S</code> instead of <code>@s</code>, the value will be scaled with the scale
* factor used in the last gprint directive (uniform value scaling).</p>
*
* <p>The text printed on the graph will be left, center or right aligned
* if the format string ends with <code>@l</code>, <code>@c</code> or <code>@r</code>,
* respectively. It is also possible to align text without adding a linefeed by using
* <code>@L</code>, <code>@R</code> and <code>@C</code> as markers. After a GPRINT some
* whitespace is appended by default. To suppress this whitespace put a <code>@G</code>
* marker at the very end of the string. By putting a <code>@g</code> marker instead all
* whitespace inside the string at very beginning or end will be removed also.</p>
*
* @param sourceName Graph source name
* @param consolFun Consolidation function to be used for calculation ("AVERAGE",
* "MIN", "MAX", "LAST" or "TOTAL" (since 1.3.1)
* @param format Format string. For example: "speed is @5.2 @sbits/sec@c",
* "temperature = @0 degrees"
* @throws RrdException Thrown in case of JRobin specific error
*/
public void gprint(String sourceName, String consolFun, String format) throws RrdException
{
addComment( new Gprint(sourceName, consolFun, format) );
}
/**
* <p>See the {@link #gprint(java.lang.String, java.lang.String, java.lang.String) 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.
* </p>
*
* @param sourceName Graph source name
* @param consolFun Consolidation function to be used for calculation ("AVERAGE", "MIN", "MAX", "LAST"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -