public abstract class AbstractPlot extends StylableContainer implements Plot, DataListener
BACKGROUND, BORDER, COLOR, LEGEND, LEGEND_DISTANCE, LEGEND_LOCATION, TITLE, TITLE_FONT
Constructor and Description |
---|
AbstractPlot(DataSource... series)
Initializes a new
AbstractPlot instance with the specified data series. |
Modifier and Type | Method and Description |
---|---|
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.
|
protected void |
autoscaleAxes()
Tries to automatically set the ranges of all axes that are set to auto-scale.
|
void |
autoscaleAxis(String axisName)
Tries to automatically set the ranges of the axes specified by the name
if it is set to auto-scale.
|
void |
clear()
Removes all data series from this plot.
|
boolean |
contains(DataSource source)
Returns whether the plot contains the specified data series.
|
protected void |
createDefaultAxes()
Creates all axes that are defined by the current plot type.
|
protected void |
createDefaultAxisRenderers()
Creates all axis renderers that are defined by the current plot type.
|
void |
dataAdded(DataSource source,
DataChangeEvent... events)
Method that is invoked when data has been added.
|
protected void |
dataChanged(DataSource source,
DataChangeEvent... events)
Method that is invoked when data has been added, updated, or removed.
|
void |
dataRemoved(DataSource source,
DataChangeEvent... events)
Method that is invoked when data has been removed.
|
void |
dataUpdated(DataSource source,
DataChangeEvent... events)
Method that is invoked when data has been updated.
|
void |
draw(DrawingContext context)
Draws the
Drawable with the specified drawing context. |
protected void |
drawAxes(DrawingContext context)
Draws the plot's axes into the specified drawing context.
|
protected void |
drawLegend(DrawingContext context)
Draws the plot's legend into the specified drawing context.
|
DataSource |
get(int index)
Returns the data series at a specified index.
|
Collection<String> |
getAxesNames()
Returns a collection of all names of the axes stored in this plot.
|
Axis |
getAxis(String name)
Returns the axis with the specified name.
|
protected Drawable |
getAxisComponent(String axisName)
Returns the component that is used to draw the specified axis.
|
protected Double |
getAxisMax(String axisName)
Returns the maximum value of the axis specified by
axisName . |
protected Double |
getAxisMin(String axisName)
Returns the minimum value of the axis specified by
axisName . |
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 component.
|
protected Container |
getLegendContainer()
Returns the object containing the Legend.
|
String[] |
getMapping(DataSource source)
Returns the mapping of data source columns to axis names.
|
PlotArea |
getPlotArea()
Returns the drawing area of this plot.
|
Label |
getTitle()
Returns the title component 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 |
layout()
Recalculates this container's layout.
|
protected void |
layoutAxes()
Calculates the bounds of the axes.
|
protected void |
layoutLegend()
Calculates the bounds of the legend component.
|
boolean |
remove(DataSource source)
Deletes the specified data series from the plot.
|
void |
removeAxis(String name)
Removes the axis with the specified name.
|
void |
setAxis(String name,
Axis axis)
Sets the axis with the specified name and the associated
AxisRenderer . |
void |
setAxisRenderer(String axisName,
AxisRenderer renderer)
Sets the renderer for the axis with the specified name.
|
protected void |
setLegend(Legend legend)
Sets the legend to the specified value.
|
void |
setMapping(DataSource source,
String... axisNames)
Sets the mapping of data source columns to axis names.
|
protected void |
setPlotArea(PlotArea plotArea)
Sets the drawing area to the specified value.
|
void |
settingChanged(SettingChangeEvent event)
Invoked if a setting has changed.
|
void |
setVisible(DataSource source,
boolean visible)
Changes the visibility of the specified data series.
|
getSetting, removeSetting, removeSettingDefault, setSetting, setSettingDefault
add, add, drawComponents, getConstraints, getDrawableAt, getInsets, getLayout, getPreferredSize, iterator, remove, setBounds, setBounds, setInsets, setLayout, size
getBounds, getHeight, getWidth, getX, getY
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBounds, getHeight, getPreferredSize, getWidth, getX, getY, setBounds, setBounds
add, add, getBounds, getConstraints, getDrawableAt, getInsets, getLayout, remove, setBounds, setInsets, setLayout, size
getSetting, removeSetting, removeSettingDefault, setSetting, setSettingDefault
public AbstractPlot(DataSource... series)
AbstractPlot
instance with the specified data series.
The series will be visible by default.series
- Initial data series to be displayed.public void draw(DrawingContext context)
Drawable
with the specified drawing context.draw
in interface Drawable
draw
in class DrawableContainer
context
- Environment used for drawingprotected void drawAxes(DrawingContext context)
context
- Environment used for drawing.protected void drawLegend(DrawingContext context)
context
- Environment used for drawing.public void layout()
DrawableContainer
layout
in interface Container
layout
in class DrawableContainer
protected void layoutAxes()
protected void layoutLegend()
public void setAxis(String name, Axis axis)
AxisRenderer
.public void removeAxis(String name)
removeAxis
in interface Plot
name
- Name of the axis to be removed.public Collection<String> getAxesNames()
getAxesNames
in interface Plot
protected void createDefaultAxes()
protected void createDefaultAxisRenderers()
protected void autoscaleAxes()
Axis.setAutoscaled(boolean)
public void autoscaleAxis(String axisName)
autoscaleAxis
in interface Plot
axisName
- Name of the axis that should be scaled.Axis.setAutoscaled(boolean)
public AxisRenderer getAxisRenderer(String axisName)
getAxisRenderer
in interface Plot
axisName
- Axis name.public void setAxisRenderer(String axisName, AxisRenderer renderer)
setAxisRenderer
in interface Plot
axisName
- Name of the axis to be rendered.renderer
- Instance to render the axis.protected Drawable getAxisComponent(String axisName)
axisName
- Name of the axis.public PlotArea getPlotArea()
getPlotArea
in interface Plot
PlotArea2D
.protected void setPlotArea(PlotArea plotArea)
plotArea
- PlotArea2D
to be set.public Label getTitle()
protected Container getLegendContainer()
public Legend getLegend()
protected void setLegend(Legend legend)
legend
- Legend to be set.public void settingChanged(SettingChangeEvent event)
settingChanged
in interface SettingsListener
settingChanged
in class StylableContainer
event
- Event containing information about the changed setting.public void add(DataSource source)
public void add(DataSource source, boolean visible)
public void add(int index, DataSource source, boolean visible)
public boolean contains(DataSource source)
public DataSource get(int index)
public boolean remove(DataSource source)
public void clear()
public String[] getMapping(DataSource source)
source
. If no mapping exists
null
will be stored in the array.getMapping
in interface Plot
source
- Data source.null
if no mapping exists for the column.public void setMapping(DataSource source, String... axisNames)
source
will be mapped to first element of axisNames
.
Axis names with value null
will be ignored.setMapping
in interface Plot
source
- Data source.axisNames
- Sequence of axis names in the order of the columns.protected Double getAxisMin(String axisName)
axisName
.axisName
- Name of the axis.0.0
if no
minimum value can be determined.protected Double getAxisMax(String axisName)
axisName
.axisName
- Name of the axis.0.0
if no
maximum value can be determined.public List<DataSource> getData()
public List<DataSource> getVisibleData()
getVisibleData
in interface Plot
public boolean isVisible(DataSource source)
public void setVisible(DataSource source, boolean visible)
setVisible
in interface Plot
source
- Data series.visible
- true
if the series should be visible,
false
otherwise.public void dataAdded(DataSource source, DataChangeEvent... events)
DataListener
s and should not be called manually.dataAdded
in interface DataListener
source
- Data source that has been changed.events
- Optional event object describing the data values that
have been added.public void dataUpdated(DataSource source, DataChangeEvent... events)
DataListener
s and should not be called manually.dataUpdated
in interface DataListener
source
- Data source that has been changed.events
- Optional event object describing the data values that
have been updated.public void dataRemoved(DataSource source, DataChangeEvent... events)
DataListener
s and should not be called manually.dataRemoved
in interface DataListener
source
- Data source that has been changed.events
- Optional event object describing the data values that
have been removed.protected void dataChanged(DataSource source, DataChangeEvent... events)
source
- Data source that has been changed.events
- Optional event object describing the data values that
have been changed.Copyright © 2009-2013. All Rights Reserved.