Class LineGraphDrawable
java.lang.Object
org.pentaho.reporting.libraries.libsparklines.LineGraphDrawable
A very fast and very simple line-graph drawable. This code is based on the LineGraph class writen by Larry Ogrodnek
but instead of producing a low-resolution image, this class writes the content into a Graphics2D context.
- Author:
- Thomas Morgner
-
Constructor Summary
ConstructorDescriptionCreates a default bargraph drawable with some sensible default colors and spacings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(Graphics2D graphics, Rectangle2D drawArea) Draws the bar-graph into the given Graphics2D context in the given area.Returns the color for the background of the graph.getColor()
Returns the main color for the bars.Number[]
getData()
Returns the numeric data for the drawable or null, if the drawable has no data.int
Returns the spacing between the bars.void
setBackground
(Color background) Defines the color for the background of the graph.void
Defines the main color for the bars.void
Defines the numeric data for the drawable or null, if the drawable has no data.void
setLastColor
(Color lastColor) void
setSpacing
(int spacing) Defines the spacing between the bars.
-
Constructor Details
-
LineGraphDrawable
public LineGraphDrawable()Creates a default bargraph drawable with some sensible default colors and spacings.
-
-
Method Details
-
getData
Returns the numeric data for the drawable or null, if the drawable has no data.- Returns:
- the data.
-
setData
Defines the numeric data for the drawable or null, if the drawable has no data.- Parameters:
data
- the data (can be null).
-
getColor
Returns the main color for the bars.- Returns:
- the main color for the bars, never null.
-
setColor
Defines the main color for the bars.- Parameters:
color
- the main color for the bars, never null.
-
getBackground
Returns the color for the background of the graph. This property can be null, in which case the bar will have a transparent background.- Returns:
- color for the background or null, if the graph has a transparent background color.
-
setBackground
Defines the color for the background of the graph. This property can be null, in which case the bar will have a transparent background.- Parameters:
background
- the background or null, if the graph has a transparent background color.
-
getSpacing
public int getSpacing()Returns the spacing between the bars.- Returns:
- the spacing between the bars.
-
setSpacing
public void setSpacing(int spacing) Defines the spacing between the bars.- Parameters:
spacing
- the spacing between the bars.
-
getLastColor
-
setLastColor
-
draw
Draws the bar-graph into the given Graphics2D context in the given area. This method will not draw a graph if the data given is null or empty.- Parameters:
graphics
- the graphics context on which the bargraph should be rendered.drawArea
- the area on which the bargraph should be drawn.
-