public abstract class AbstractPlot extends DrawableContainer implements Plot, DataListener
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(java.lang.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.
|
java.util.Collection<java.lang.String> |
getAxesNames()
Returns a collection of all names of the axes stored in this plot.
|
Axis |
getAxis(java.lang.String name)
Returns the axis with the specified name.
|
protected Drawable |
getAxisComponent(java.lang.String axisName)
Returns the component that is used to draw the specified axis.
|
protected java.lang.Double |
getAxisMax(java.lang.String axisName)
Returns the maximum value of the axis specified by
axisName . |
protected java.lang.Double |
getAxisMin(java.lang.String axisName)
Returns the minimum value of the axis specified by
axisName . |
AxisRenderer |
getAxisRenderer(java.lang.String axisName)
Returns the renderer for the axis with the specified name.
|
java.awt.Paint |
getBackground()
Returns the paint which is used to fill the background of the plot.
|
java.awt.Paint |
getBorderColor()
Returns the paint which is used to fill the border of the plot.
|
java.awt.Stroke |
getBorderStroke()
Returns the stroke which is used to paint the border of the plot.
|
java.util.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.
|
double |
getLegendDistance()
Returns the spacing between the plot area and the legend.
|
Location |
getLegendLocation()
Returns the current positioning of the legend inside the plot.
|
java.lang.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.
|
java.util.List<DataSource> |
getVisibleData()
Returns a list of all visible data series stored in the plot.
|
boolean |
isLegendVisible()
Returns whether the legend is shown.
|
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.
|
protected void |
refreshLegendLayout()
Refreshes the positioning and spacing of the legend.
|
boolean |
remove(DataSource source)
Deletes the specified data series from the plot.
|
void |
removeAxis(java.lang.String name)
Removes the axis with the specified name.
|
void |
setAxis(java.lang.String name,
Axis axis)
Sets the axis with the specified name and the associated
AxisRenderer . |
void |
setAxisRenderer(java.lang.String axisName,
AxisRenderer renderer)
Sets the renderer for the axis with the specified name.
|
void |
setBackground(java.awt.Paint background)
Sets the paint which will be used to fill the background of the plot.
|
void |
setBorderColor(java.awt.Paint color)
Sets the paint which will be used to fill the border of the plot.
|
void |
setBorderStroke(java.awt.Stroke border)
Sets the stroke which will be used to paint the border of the plot.
|
protected void |
setLegend(Legend legend)
Sets the legend to the specified value.
|
void |
setLegendDistance(double distance)
Sets the spacing between the plot area and the legend.
|
void |
setLegendLocation(Location location)
Sets the positioning of the legend inside the plot.
|
void |
setLegendVisible(boolean legendVisible)
Sets whether the legend will be shown.
|
void |
setMapping(DataSource source,
java.lang.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 |
setVisible(DataSource source,
boolean visible)
Changes the visibility of the specified data series.
|
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
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 Axis getAxis(java.lang.String name)
public void setAxis(java.lang.String name, Axis axis)
AxisRenderer
.public void removeAxis(java.lang.String name)
removeAxis
in interface Plot
name
- Name of the axis to be removed.public java.util.Collection<java.lang.String> getAxesNames()
getAxesNames
in interface Plot
protected void createDefaultAxes()
protected void createDefaultAxisRenderers()
protected void autoscaleAxes()
Axis.setAutoscaled(boolean)
public void autoscaleAxis(java.lang.String axisName)
autoscaleAxis
in interface Plot
axisName
- Name of the axis that should be scaled.Axis.setAutoscaled(boolean)
public AxisRenderer getAxisRenderer(java.lang.String axisName)
getAxisRenderer
in interface Plot
axisName
- Axis name.public void setAxisRenderer(java.lang.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(java.lang.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.protected void refreshLegendLayout()
public java.awt.Paint getBackground()
Plot
getBackground
in interface Plot
public void setBackground(java.awt.Paint background)
Plot
setBackground
in interface Plot
background
- Paint which will be used to fill the background of the
plot.public java.awt.Stroke getBorderStroke()
Plot
getBorderStroke
in interface Plot
public void setBorderStroke(java.awt.Stroke border)
Plot
setBorderStroke
in interface Plot
border
- Stroke which will be used to paint the border of the plot.public java.awt.Paint getBorderColor()
Plot
getBorderColor
in interface Plot
public void setBorderColor(java.awt.Paint color)
Plot
setBorderColor
in interface Plot
color
- Paint which will be used to fill the border of the plot.public boolean isLegendVisible()
Plot
isLegendVisible
in interface Plot
true
if the legend is shown,
false
if the legend is hidden.public void setLegendVisible(boolean legendVisible)
Plot
setLegendVisible
in interface Plot
legendVisible
- true
if the legend should be shown,
false
if the legend should be hidden.public Location getLegendLocation()
Plot
getLegendLocation
in interface Plot
public void setLegendLocation(Location location)
Plot
setLegendLocation
in interface Plot
location
- Positioning of the legend inside the plot.public double getLegendDistance()
Plot
getLegendDistance
in interface Plot
public void setLegendDistance(double distance)
Plot
setLegendDistance
in interface Plot
distance
- Spacing between the plot area and the legend relative to font
height.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 java.lang.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, java.lang.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 java.lang.Double getAxisMin(java.lang.String axisName)
axisName
.axisName
- Name of the axis.0.0
if no
minimum value can be determined.protected java.lang.Double getAxisMax(java.lang.String axisName)
axisName
.axisName
- Name of the axis.0.0
if no
maximum value can be determined.public java.util.List<DataSource> getData()
public java.util.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.