Class LineGraphDrawable
- java.lang.Object
-
- org.pentaho.reporting.libraries.libsparklines.LineGraphDrawable
-
public class LineGraphDrawable extends Object
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
Constructors Constructor Description LineGraphDrawable()
Creates a default bargraph drawable with some sensible default colors and spacings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
draw(Graphics2D graphics, Rectangle2D drawArea)
Draws the bar-graph into the given Graphics2D context in the given area.Color
getBackground()
Returns the color for the background of the graph.Color
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.Color
getLastColor()
int
getSpacing()
Returns the spacing between the bars.void
setBackground(Color background)
Defines the color for the background of the graph.void
setColor(Color color)
Defines the main color for the bars.void
setData(Number[] data)
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.
-
-
-
Method Detail
-
getData
public Number[] getData()
Returns the numeric data for the drawable or null, if the drawable has no data.- Returns:
- the data.
-
setData
public void setData(Number[] data)
Defines the numeric data for the drawable or null, if the drawable has no data.- Parameters:
data
- the data (can be null).
-
getColor
public Color getColor()
Returns the main color for the bars.- Returns:
- the main color for the bars, never null.
-
setColor
public void setColor(Color color)
Defines the main color for the bars.- Parameters:
color
- the main color for the bars, never null.
-
getBackground
public Color 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
public void setBackground(Color background)
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
public Color getLastColor()
-
setLastColor
public void setLastColor(Color lastColor)
-
draw
public void draw(Graphics2D graphics, Rectangle2D drawArea)
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.
-
-