Package org.jCharts
Class Chart
- java.lang.Object
-
- org.jCharts.Chart
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
AxisChart,PieChart2D
public abstract class Chart extends java.lang.Object implements java.io.SerializableBase class of all charts.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.image.BufferedImagebufferedImageprivate ChartPropertieschartPropertiesprivate booleangenerateImageMapprivate java.awt.Graphics2Dgraphics2Dprivate intheightprivate ImageMapimageMapprivate Legendlegendprivate intwidth
-
Constructor Summary
Constructors Constructor Description Chart(LegendProperties legendProperties, ChartProperties chartProperties, int pixelWidth, int pixelHeight)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImagegetBufferedImage()Returns the BufferedImage used to generate the ImageMap.ChartPropertiesgetChartProperties()Returns the general properties Object.booleangetGenerateImageMapFlag()Returns flag indicating whether to generate an ImageMapjava.awt.Graphics2DgetGraphics2D()Shortcut method to get Graphics2D.intgetImageHeight()Returns the BufferedImage heightImageMapgetImageMap()intgetImageWidth()Returns the BufferedImage widthprotected LegendgetLegend()Returns the Legend.booleanhasLegend()Returns flag indicating if there is a Legend.voidrender()Call this to kick off rendering of the chartprotected abstract voidrenderChart()protected floatrenderChartTitle(java.lang.String chartTitle, java.awt.font.FontRenderContext fontRenderContext)Displays the chart title and returns the height of the title PLUS title padding.voidrenderWithImageMap()Renders the chart into a BufferedImage so that we can calculate all the Image Map coordinates.voidsetGraphics2D(java.awt.Graphics2D graphics2D)Sets the graphics object to render the chart on by the encoder.voidsetImageMap(ImageMap imageMap)To optimze performance of the ImageMap Object, we create it once we know how many data elements are in the chart which is dependent on the AxisChart or PieChart2DvoidtoHTML(HTMLGenerator htmlGenerator, java.lang.String imageFileName, ImageMap imageMap)Enables the testing routines to display the contents of this Object.
-
-
-
Field Detail
-
graphics2D
private java.awt.Graphics2D graphics2D
-
width
private int width
-
height
private int height
-
legend
private Legend legend
-
chartProperties
private ChartProperties chartProperties
-
generateImageMap
private boolean generateImageMap
-
imageMap
private ImageMap imageMap
-
bufferedImage
private java.awt.image.BufferedImage bufferedImage
-
-
Constructor Detail
-
Chart
public Chart(LegendProperties legendProperties, ChartProperties chartProperties, int pixelWidth, int pixelHeight)
Constructor- Parameters:
legendProperties-chartProperties-pixelWidth-pixelHeight-
-
-
Method Detail
-
getGenerateImageMapFlag
public boolean getGenerateImageMapFlag()
Returns flag indicating whether to generate an ImageMap- Returns:
- boolean
-
getBufferedImage
public java.awt.image.BufferedImage getBufferedImage()
Returns the BufferedImage used to generate the ImageMap. Only should be called on binary format images, such as PNG and JPG, as it will not work on SVG. This is a HACK and the design of jCharts should do better than this!!!!!!- Returns:
- BufferedImage
-
renderWithImageMap
public void renderWithImageMap() throws ChartDataException, PropertyExceptionRenders the chart into a BufferedImage so that we can calculate all the Image Map coordinates.- Throws:
ChartDataExceptionPropertyException
-
render
public void render() throws ChartDataException, PropertyExceptionCall this to kick off rendering of the chart- Throws:
ChartDataExceptionPropertyException
-
renderChartTitle
protected float renderChartTitle(java.lang.String chartTitle, java.awt.font.FontRenderContext fontRenderContext)Displays the chart title and returns the height of the title PLUS title padding.- Parameters:
chartTitle-fontRenderContext-- Returns:
- float the height required by the title. If no title is displayed, zero is returned.
-
renderChart
protected abstract void renderChart() throws ChartDataException, PropertyException- Throws:
ChartDataExceptionPropertyException
-
getImageWidth
public final int getImageWidth()
Returns the BufferedImage width- Returns:
- int
-
getImageHeight
public final int getImageHeight()
Returns the BufferedImage height- Returns:
- int
-
getChartProperties
public final ChartProperties getChartProperties()
Returns the general properties Object.- Returns:
- ChartProperties
-
getLegend
protected final Legend getLegend()
Returns the Legend. Will be NULL if no Legend is desired.- Returns:
- Legend
-
hasLegend
public final boolean hasLegend()
Returns flag indicating if there is a Legend.- Returns:
- boolean
-
setGraphics2D
public final void setGraphics2D(java.awt.Graphics2D graphics2D)
Sets the graphics object to render the chart on by the encoder.- Parameters:
graphics2D-
-
getGraphics2D
public final java.awt.Graphics2D getGraphics2D()
Shortcut method to get Graphics2D. Be aware that the call BufferedImage.getGraphics() and BufferedImage.createGraphics(), actually create a new Grpahics2D Object on each invocation. This returns the member reference so calls to this are not creating a new Object each time.- Returns:
- Graphics2D
-
setImageMap
public final void setImageMap(ImageMap imageMap)
To optimze performance of the ImageMap Object, we create it once we know how many data elements are in the chart which is dependent on the AxisChart or PieChart2D- Parameters:
imageMap-
-
getImageMap
public final ImageMap getImageMap()
- Returns:
- imageMap
-
toHTML
public void toHTML(HTMLGenerator htmlGenerator, java.lang.String imageFileName, ImageMap imageMap)
Enables the testing routines to display the contents of this Object.- Parameters:
htmlGenerator-imageFileName-imageMap- if this is NULL we are not creating image map data in html
-
-