|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.approximatrix.charting.render.AbstractRenderer
com.approximatrix.charting.AbstractChart
com.approximatrix.charting.BufferedChart
public class BufferedChart
BufferedChart creates a chart that renders only once to a buffered image, then simply displays the image rather than performing a full chart rendering. This technique improves performance by only re-rendering the chart when absolutely necessary.
| Nested Class Summary | |
|---|---|
private class |
BufferedChart.RenderThread
Private class for handling drawing the chart on a separate thread. |
| Field Summary | |
|---|---|
private java.awt.image.BufferedImage |
buffer
The image buffer holding the current rendering of the chart |
private java.awt.image.BufferedImage |
drawbuffer
The second buffer where the separate thread will draw |
private boolean |
enableBuffering
Flag indicating buffering is enabled |
protected java.awt.Font |
font
The font to display the render message |
static int |
LINEAR_X_LINEAR_Y
|
static int |
NO_COORDINATE_SYSTEM
|
private boolean |
redraw
Flag indicating a redraw may be necessary |
protected java.lang.String |
render_message
The String displayed during rendering work |
private BufferedChart.RenderThread |
rt
The rendering thread to perform all drawing |
| Fields inherited from class com.approximatrix.charting.AbstractChart |
|---|
bounds, coord, legend, model, rcModel, renderer, title |
| Fields inherited from class com.approximatrix.charting.render.AbstractRenderer |
|---|
listener |
| Constructor Summary | |
|---|---|
protected |
BufferedChart()
Creates new empty DefaultChart. |
|
BufferedChart(ChartDataModel model,
java.lang.String title)
Creates a new BufferedChart with the given model and title string and no coordinate system. |
|
BufferedChart(ChartDataModel model,
java.lang.String title,
int coord)
Creates a new BufferedChart with the given model and title string and a coordinate system. |
|
BufferedChart(ChartDataModel model,
java.lang.String title,
int coord,
java.lang.String xaxis,
java.lang.String yaxis)
Creates a new BufferedChart with the given model and title string and a coordinate system. |
| Method Summary | |
|---|---|
void |
addChartRenderer(AbstractChartRenderer render,
int z)
Adds a ChartRenderer with a specific z-coordinate. |
private void |
assignListeners()
Assigns this chart as the listener for all RenderChange events |
void |
chartDataChanged(ChartDataModelEvent evt)
This method is called, whenever an event is created. |
private java.awt.image.BufferedImage |
createBuffer()
Returns a new BufferedImage that is sized to be the same as this component's bounds. |
private void |
drawBufferImage(java.awt.Graphics2D g)
Draws the current image buffer onto the specified Graphics2D object |
void |
drawChart(java.awt.Graphics2D g)
Does the layout of the title, legend and coordinate system and calls the render method of all those including the ChartRenderers. |
private void |
drawNotification()
Draws a notification that rendering is in process on the buffer image |
java.awt.Font |
getFont()
Returns the font used to display the rendering message. |
java.awt.Dimension |
getPreferredSize()
Should compute the preferred size of the Chart |
java.lang.String |
getRenderMessage()
Returns the current message stating that rendering is occuring |
private void |
initBuffer()
Initializes the image buffer based on current bounds |
private void |
initialize()
Central calling method for initializing the specifics of this bufferd chart. |
private boolean |
invalidBuffer()
Determines if the current buffer is the wrong size |
boolean |
isBuffering()
Returns whether buffering is currently enabled |
void |
notifyDisplayReady()
Called by the render thread to notify its parent that rendering of the chart is complete and available on the drawBuffer |
void |
render(java.awt.Graphics2D g)
The central rendering routine that handles all drawing operations. |
void |
renderUpdateRequested(RenderChangeEvent evt)
This method is called, whenever an event is created. |
void |
setBuffering(boolean value)
Sets whether rendering should be buffered for speed |
void |
setChartDataModel(ChartDataModel model)
Stores the ChartDataModel for this Chart. |
void |
setChartRenderer(java.util.Map render)
Sets the Map with all ChartRenderers. |
void |
setCoordSystem(CoordSystem c)
Sets the coordinate system for this chart, which can be null if the ChartRenderer doesn't need a coordinate system, e.g. |
void |
setFont(java.awt.Font newfont)
Sets the font which messages are rendered int |
void |
setLegend(Legend l)
Sets the legend for this chart. |
void |
setRenderMessage(java.lang.String value)
Sets the current rendering message to be displayed while the render thread is running |
void |
setRowColorModel(RowColorModel rcm)
Sets the RowColorModel for this chart. |
void |
setTitle(Title t)
Sets the title for this chart. |
| Methods inherited from class com.approximatrix.charting.AbstractChart |
|---|
getBounds, getChartDataModel, getChartRenderer, getChartRenderer, getCoordSystem, getLegend, getRowColorModel, getTitle, paintDefault, setBounds |
| Methods inherited from class com.approximatrix.charting.render.AbstractRenderer |
|---|
addRenderChangeListener, clearRenderChangeListeners, fireRenderChangeEvent, getDirectRender, isDifferentBounds, removeRenderChangeListener, setDirectRender |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static int LINEAR_X_LINEAR_Y
public static int NO_COORDINATE_SYSTEM
protected java.lang.String render_message
protected java.awt.Font font
private BufferedChart.RenderThread rt
private java.awt.image.BufferedImage buffer
private java.awt.image.BufferedImage drawbuffer
private boolean redraw
private boolean enableBuffering
| Constructor Detail |
|---|
protected BufferedChart()
public BufferedChart(ChartDataModel model,
java.lang.String title)
model - the ChartDataModeltitle - the title String
public BufferedChart(ChartDataModel model,
java.lang.String title,
int coord)
model - the ChartDataModeltitle - the title Stringcoord - the id of the coordinate system configuration
public BufferedChart(ChartDataModel model,
java.lang.String title,
int coord,
java.lang.String xaxis,
java.lang.String yaxis)
model - the ChartDataModeltitle - the title Stringcoord - the id of the coordinate system configurationxaxis - the x-axis' unityaxis - the y-axis' unit| Method Detail |
|---|
private void initialize()
private void assignListeners()
public java.awt.Dimension getPreferredSize()
getPreferredSize in interface Renderernullprivate void initBuffer()
private java.awt.image.BufferedImage createBuffer()
private boolean invalidBuffer()
public void setBuffering(boolean value)
value - true to enable buffering, false otherwisepublic boolean isBuffering()
public java.awt.Font getFont()
public void setFont(java.awt.Font newfont)
newfont - the new font to use for rendering messagespublic java.lang.String getRenderMessage()
public void setRenderMessage(java.lang.String value)
value - a valid (non-null) String to be displayed during renderingpublic void notifyDisplayReady()
public void render(java.awt.Graphics2D g)
render in interface Chartrender in interface Rendererrender in class AbstractChartg - the actual display Graphics2D object on which to be paintedprivate void drawNotification()
private void drawBufferImage(java.awt.Graphics2D g)
g - the target Graphics2D objectpublic void drawChart(java.awt.Graphics2D g)
g - the Graphics2D object to paint in.public void renderUpdateRequested(RenderChangeEvent evt)
renderUpdateRequested in interface RenderChangeListenerevt - the event objectpublic void chartDataChanged(ChartDataModelEvent evt)
chartDataChanged in interface ChartDataModelListenerevt - the event object
public void addChartRenderer(AbstractChartRenderer render,
int z)
addChartRenderer in interface ChartaddChartRenderer in class AbstractChartrender - the ChartRendererz - the z-coordinate, the highest coordinate is in front.public void setChartRenderer(java.util.Map render)
setChartRenderer in interface ChartsetChartRenderer in class AbstractChartrender - a java.util.Map with all ChartRenderers.public void setCoordSystem(CoordSystem c)
setCoordSystem in interface ChartsetCoordSystem in class AbstractChartc - the CoordSystem objectpublic void setLegend(Legend l)
setLegend in interface ChartsetLegend in class AbstractChartl - the Legendpublic void setTitle(Title t)
setTitle in interface ChartsetTitle in class AbstractChartt - the Title objectpublic void setRowColorModel(RowColorModel rcm)
setRowColorModel in class AbstractChartrcm - the new RowColorModelpublic void setChartDataModel(ChartDataModel model)
setChartDataModel in interface ChartsetChartDataModel in class AbstractChartmodel - the ChartDataModel
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||