de.erichseifert.gral.plots
Class Plot

java.lang.Object
  extended by de.erichseifert.gral.AbstractDrawable
      extended by de.erichseifert.gral.DrawableContainer
          extended by de.erichseifert.gral.plots.Plot
All Implemented Interfaces:
Container, DataListener, Drawable, SettingsListener, SettingsStorage, Iterable<Drawable>
Direct Known Subclasses:
PiePlot, XYPlot

public abstract class Plot
extends DrawableContainer
implements SettingsStorage, SettingsListener, DataListener

Abstract class that displays data in a plot. Functionality includes:


Field Summary
static Settings.Key ANTIALISING
          Key for specifying the whether antialiasing is enabled.
static Settings.Key BACKGROUND
          Key for specifying the Paint instance to be used to paint the background of the plot.
static Settings.Key BORDER
          Key for specifying the Stroke instance to be used to paint the border of the plot.
static Settings.Key COLOR
          Key for specifying the Paint instance to be used to fill the border of the plot.
static Settings.Key LEGEND
          Key for specifying whether the legend should be shown.
static Settings.Key LEGEND_LOCATION
          Key for specifying the positioning of the legend using a DrawableConstants.Location value.
static Settings.Key LEGEND_MARGIN
          Key for specifying the Insets2D that describes the legend's margin.
static Settings.Key TITLE
          Key for specifying the String instance for the title of the plot.
 
Constructor Summary
Plot(DataSource... series)
          Initializes a new Plot instance with the specified data series.
 
Method Summary
 void add(DataSource source)
          Adds a new data series to the plot which is visible by default.
 void add(DataSource source, boolean visible)
          Adds a new data series to the plot.
 void add(int index, DataSource source, boolean visible)
          Inserts the specified data series to the plot at a specified position.
 void clear()
          Removes all data series from this plot.
 boolean contains(DataSource source)
          Returns whether the plot contains the specified data series.
 void dataChanged(DataSource data)
          Method that is invoked by objects that provide support for DataListeners.
 void draw(DrawingContext context)
          Draws the Drawable with the specified Graphics2D object.
 DataSource get(int index)
          Returns the data series at a specified index.
 Collection<Axis> getAxes()
          Returns a Collection of all axes stored in this plot.
 Axis getAxis(String name)
          Returns the axis with the specified name.
 AxisRenderer getAxisRenderer(Axis axis)
          Returns the renderer for the specified axis.
 AxisRenderer getAxisRenderer(String axisName)
          Returns the renderer for the axis with the specified name.
 List<DataSource> getData()
          Returns a list of all data series stored in the plot.
 Legend getLegend()
          Returns the legend.
 PlotArea getPlotArea()
          Returns the drawing area of this plot.
<T> T
getSetting(Settings.Key key)
          Returns the setting with the specified key.
 Label getTitle()
          Returns the title of this plot.
 List<DataSource> getVisibleData()
          Returns a list of all visible data series stored in the plot.
 boolean isVisible(DataSource source)
          Returns whether the specified data series is drawn.
 void refresh()
          Causes the plot data to be be updated.
 boolean remove(DataSource source)
          Deletes the specified data series from the plot.
 void removeAxis(String name)
          Removes the axis with the specified name.
<T> void
removeSetting(Settings.Key key)
          Removes the setting with the specified key.
<T> void
removeSettingDefault(Settings.Key key)
          Removes the default setting with the specified key.
 void setAxis(String name, Axis axis)
          Sets the axis with the specified name and the associated AxisRenderer.
 void setAxisRenderer(Axis axis, AxisRenderer renderer)
          Sets the renderer for the specified axis.
 void setAxisRenderer(String axisName, AxisRenderer renderer)
          Sets the renderer for the axis with the specified name.
<T> void
setSetting(Settings.Key key, T value)
          Sets the setting with the specified key to the specified value.
<T> void
setSettingDefault(Settings.Key key, T value)
          Sets a default value for the setting with the specified key.
 void settingChanged(SettingChangeEvent event)
          Invoked if a setting has changed.
 void setVisible(DataSource source, boolean visible)
          Changes the visibility of the specified data series.
 
Methods inherited from class de.erichseifert.gral.DrawableContainer
add, add, getConstraints, getInsets, getLayout, getPreferredSize, iterator, remove, setBounds, setBounds, setInsets, setLayout, size
 
Methods inherited from class de.erichseifert.gral.AbstractDrawable
getBounds, getHeight, getWidth, getX, getY
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.erichseifert.gral.Container
getBounds
 

Field Detail

TITLE

public static final Settings.Key TITLE
Key for specifying the String instance for the title of the plot.


BACKGROUND

public static final Settings.Key BACKGROUND
Key for specifying the Paint instance to be used to paint the background of the plot.


BORDER

public static final Settings.Key BORDER
Key for specifying the Stroke instance to be used to paint the border of the plot.


COLOR

public static final Settings.Key COLOR
Key for specifying the Paint instance to be used to fill the border of the plot.


ANTIALISING

public static final Settings.Key ANTIALISING
Key for specifying the whether antialiasing is enabled.


LEGEND

public static final Settings.Key LEGEND
Key for specifying whether the legend should be shown.


LEGEND_LOCATION

public static final Settings.Key LEGEND_LOCATION
Key for specifying the positioning of the legend using a DrawableConstants.Location value.


LEGEND_MARGIN

public static final Settings.Key LEGEND_MARGIN
Key for specifying the Insets2D that describes the legend's margin.

Constructor Detail

Plot

public Plot(DataSource... series)
Initializes a new Plot instance with the specified data series. The series will be visible by default.

Parameters:
series - Initial data series to be displayed.
Method Detail

draw

public void draw(DrawingContext context)
Description copied from interface: Drawable
Draws the Drawable with the specified Graphics2D object.

Specified by:
draw in interface Drawable
Overrides:
draw in class DrawableContainer
Parameters:
context - Environment used for drawing

getAxis

public Axis getAxis(String name)
Returns the axis with the specified name.

Parameters:
name - Name of the axis.
Returns:
Axis.

setAxis

public void setAxis(String name,
                    Axis axis)
Sets the axis with the specified name and the associated AxisRenderer.

Parameters:
name - Name of the axis.
axis - Axis.

removeAxis

public void removeAxis(String name)
Removes the axis with the specified name.

Parameters:
name - Name of the axis to be removed.

getAxes

public Collection<Axis> getAxes()
Returns a Collection of all axes stored in this plot.

Returns:
All axes stored in this plot.

getAxisRenderer

public AxisRenderer getAxisRenderer(Axis axis)
Returns the renderer for the specified axis.

Parameters:
axis - Axis.
Returns:
Instance that renders the axis.

getAxisRenderer

public AxisRenderer getAxisRenderer(String axisName)
Returns the renderer for the axis with the specified name.

Parameters:
axisName - Axis name.
Returns:
Instance that renders the axis.

setAxisRenderer

public void setAxisRenderer(Axis axis,
                            AxisRenderer renderer)
Sets the renderer for the specified axis.

Parameters:
axis - Axis to be rendered.
renderer - Instance to render the axis.

setAxisRenderer

public void setAxisRenderer(String axisName,
                            AxisRenderer renderer)
Sets the renderer for the axis with the specified name.

Parameters:
axisName - Name of the axis to be rendered.
renderer - Instance to render the axis.

getPlotArea

public PlotArea getPlotArea()
Returns the drawing area of this plot.

Returns:
PlotArea2D.

getTitle

public Label getTitle()
Returns the title of this plot.

Returns:
Label representing the title.

getLegend

public Legend getLegend()
Returns the legend.

Returns:
Legend.

getSetting

public <T> T getSetting(Settings.Key key)
Description copied from interface: SettingsStorage
Returns the setting with the specified key. If no setting is available, the default setting will be returned.

Specified by:
getSetting in interface SettingsStorage
Type Parameters:
T - Type of setting.
Parameters:
key - Key.
Returns:
Setting.

setSetting

public <T> void setSetting(Settings.Key key,
                           T value)
Description copied from interface: SettingsStorage
Sets the setting with the specified key to the specified value.

Specified by:
setSetting in interface SettingsStorage
Type Parameters:
T - Type of setting.
Parameters:
key - Key.
value - Value to be set.

removeSetting

public <T> void removeSetting(Settings.Key key)
Description copied from interface: SettingsStorage
Removes the setting with the specified key.

Specified by:
removeSetting in interface SettingsStorage
Type Parameters:
T - Type of setting.
Parameters:
key - Key.

setSettingDefault

public <T> void setSettingDefault(Settings.Key key,
                                  T value)
Description copied from interface: SettingsStorage
Sets a default value for the setting with the specified key.

Specified by:
setSettingDefault in interface SettingsStorage
Type Parameters:
T - Type of setting.
Parameters:
key - Key.
value - Value to be set.

removeSettingDefault

public <T> void removeSettingDefault(Settings.Key key)
Description copied from interface: SettingsStorage
Removes the default setting with the specified key.

Specified by:
removeSettingDefault in interface SettingsStorage
Type Parameters:
T - Type of setting.
Parameters:
key - Key.

settingChanged

public void settingChanged(SettingChangeEvent event)
Description copied from interface: SettingsListener
Invoked if a setting has changed.

Specified by:
settingChanged in interface SettingsListener
Parameters:
event - Event containing information about the changed setting.

add

public void add(DataSource source)
Adds a new data series to the plot which is visible by default.

Parameters:
source - Data series.

add

public void add(DataSource source,
                boolean visible)
Adds a new data series to the plot.

Parameters:
source - Data series.
visible - true if the series should be displayed, false otherwise.

add

public void add(int index,
                DataSource source,
                boolean visible)
Inserts the specified data series to the plot at a specified position.

Parameters:
index - Position.
source - Data series.
visible - true if the series should be displayed, false otherwise.

contains

public boolean contains(DataSource source)
Returns whether the plot contains the specified data series.

Parameters:
source - Data series.
Returns:
true if the specified element is stored in the plot, otherwise false

get

public DataSource get(int index)
Returns the data series at a specified index.

Parameters:
index - Position of the data series.
Returns:
Instance of the data series.

remove

public boolean remove(DataSource source)
Deletes the specified data series from the plot.

Parameters:
source - Data series.
Returns:
true if the series existed, otherwise false.

clear

public void clear()
Removes all data series from this plot.


getData

public List<DataSource> getData()
Returns a list of all data series stored in the plot.

Returns:
List of all data series.

getVisibleData

public List<DataSource> getVisibleData()
Returns a list of all visible data series stored in the plot.

Returns:
List of all visible data series.

isVisible

public boolean isVisible(DataSource source)
Returns whether the specified data series is drawn.

Parameters:
source - Data series.
Returns:
true if visible, false otherwise.

setVisible

public void setVisible(DataSource source,
                       boolean visible)
Changes the visibility of the specified data series.

Parameters:
source - Data series.
visible - true if the series should be visible, false otherwise.

dataChanged

public void dataChanged(DataSource data)
Description copied from interface: DataListener
Method that is invoked by objects that provide support for DataListeners.

Specified by:
dataChanged in interface DataListener
Parameters:
data - data that has changed

refresh

public void refresh()
Causes the plot data to be be updated.



Copyright © 2009-2010. All Rights Reserved.