public class XYPlot extends AbstractPlot implements Navigable, AxisListener
Class that displays data in an two dimensional coordinate system (x-y plot). It also serves as a base class for many other plot types.
To create a new XYPlot
simply create a new instance
using one or more data sources. Example:
DataTable data = new DataTable(Integer.class, Integer.class); data.add( 1, 2); data.add(-5, 0); XYPlot plot = new XYPlot(data);
Modifier and Type | Class and Description |
---|---|
static class |
XYPlot.XYLegend
Class that displays a legend in an
XYPlot . |
static class |
XYPlot.XYNavigationDirection
Constants which determine the direction of zoom and pan actions.
|
static class |
XYPlot.XYPlotArea2D
Class that represents the drawing area of an
XYPlot . |
static class |
XYPlot.XYPlotNavigator
Navigator implementation for two-dimensional plots.
|
Modifier and Type | Field and Description |
---|---|
static String |
AXIS_X
Key for specifying the x-axis of an xy-plot.
|
static String |
AXIS_X2
Key for specifying the secondary x-axis of an xy-plot.
|
static String |
AXIS_Y
Key for specifying the y-axis of an xy-plot.
|
static String |
AXIS_Y2
Key for specifying the secondary y-axis of an xy-plot.
|
BACKGROUND, BORDER, COLOR, LEGEND, LEGEND_DISTANCE, LEGEND_LOCATION, TITLE, TITLE_FONT
Constructor and Description |
---|
XYPlot(DataSource... data)
Initializes a new instance object with the specified data sources and
reasonable default settings.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
DataSource source,
boolean visible)
Inserts the specified data series to the plot at a specified position.
|
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 |
draw(DrawingContext context)
Draws the
Drawable with the specified drawing context. |
AreaRenderer |
getAreaRenderer(DataSource s)
Returns the
AreaRenderer for the specified data source. |
LineRenderer |
getLineRenderer(DataSource s)
Returns the
LineRenderer for the specified data source. |
Navigator |
getNavigator()
Returns a navigator instance that can control the current object.
|
PointRenderer |
getPointRenderer(DataSource s)
Returns the
PointRenderer for the specified data source. |
protected void |
layoutAxes()
Calculates the bounds of the axes.
|
void |
rangeChanged(Axis axis,
Number min,
Number max)
Notified if the range of an axis has changed.
|
void |
setAreaRenderer(DataSource s,
AreaRenderer areaRenderer)
Sets the
AreaRenderer for a certain data source to the specified
value. |
void |
setAxisRenderer(String axisName,
AxisRenderer renderer)
Sets the renderer for the axis with the specified name.
|
void |
setLineRenderer(DataSource s,
LineRenderer lineRenderer)
Sets the
LineRenderer for a certain data source to the specified
value. |
void |
setPointRenderer(DataSource s,
PointRenderer pointRenderer)
Sets the
PointRenderer for a certain data source to the
specified value. |
add, add, autoscaleAxes, autoscaleAxis, clear, contains, dataAdded, dataChanged, dataRemoved, dataUpdated, drawAxes, drawLegend, get, getAxesNames, getAxis, getAxisComponent, getAxisMax, getAxisMin, getAxisRenderer, getData, getLegend, getLegendContainer, getMapping, getPlotArea, getTitle, getVisibleData, isVisible, layout, layoutLegend, remove, removeAxis, setAxis, setLegend, setMapping, setPlotArea, settingChanged, setVisible
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 static final String AXIS_X
public static final String AXIS_X2
public static final String AXIS_Y
public static final String AXIS_Y2
public XYPlot(DataSource... data)
data
- Data to be displayed.protected void createDefaultAxes()
AbstractPlot
createDefaultAxes
in class AbstractPlot
protected void createDefaultAxisRenderers()
AbstractPlot
createDefaultAxisRenderers
in class AbstractPlot
protected void layoutAxes()
AbstractPlot
layoutAxes
in class AbstractPlot
public PointRenderer getPointRenderer(DataSource s)
PointRenderer
for the specified data source.s
- Data source.public void setPointRenderer(DataSource s, PointRenderer pointRenderer)
PointRenderer
for a certain data source to the
specified value.s
- Data source.pointRenderer
- PointRenderer to be set.public LineRenderer getLineRenderer(DataSource s)
LineRenderer
for the specified data source.s
- Data source.LineRenderer
.public void setLineRenderer(DataSource s, LineRenderer lineRenderer)
LineRenderer
for a certain data source to the specified
value.s
- Data source.lineRenderer
- LineRenderer
to be set.public AreaRenderer getAreaRenderer(DataSource s)
AreaRenderer
for the specified data source.s
- Data source.AreaRenderer
.public void setAreaRenderer(DataSource s, AreaRenderer areaRenderer)
AreaRenderer
for a certain data source to the specified
value.s
- Data source.areaRenderer
- AreaRenderer
to be set.public void setAxisRenderer(String axisName, AxisRenderer renderer)
AbstractPlot
setAxisRenderer
in interface Plot
setAxisRenderer
in class AbstractPlot
axisName
- Name of the axis to be rendered.renderer
- Instance to render the axis.public void add(int index, DataSource source, boolean visible)
AbstractPlot
add
in interface Plot
add
in class AbstractPlot
index
- Position.source
- Data series.visible
- true
if the series should be displayed,
false
otherwise.public Navigator getNavigator()
getNavigator
in interface Navigable
public void draw(DrawingContext context)
AbstractPlot
Drawable
with the specified drawing context.draw
in interface Drawable
draw
in class AbstractPlot
context
- Environment used for drawingpublic void rangeChanged(Axis axis, Number min, Number max)
rangeChanged
in interface AxisListener
axis
- Axis instance that has changed.min
- New minimum value.max
- New maximum value.Copyright © 2009-2013. All Rights Reserved.