de.erichseifert.gral.plots
Class XYPlot
- java.lang.Object
-
- de.erichseifert.gral.graphics.AbstractDrawable
-
- de.erichseifert.gral.graphics.DrawableContainer
-
- de.erichseifert.gral.plots.AbstractPlot
-
- de.erichseifert.gral.plots.XYPlot
-
- All Implemented Interfaces:
- DataListener, Container, Drawable, Navigable, AxisListener, Plot, java.io.Serializable, java.lang.Iterable<Drawable>
- Direct Known Subclasses:
- BarPlot, BoxPlot, RasterPlot
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
XYPlotsimply 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);
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classXYPlot.XYLegendClass that displays a legend in anXYPlot.static classXYPlot.XYNavigationDirectionConstants which determine the direction of zoom and pan actions.static classXYPlot.XYPlotArea2DClass that represents the drawing area of anXYPlot.static classXYPlot.XYPlotNavigatorNavigator implementation for two-dimensional plots.
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringAXIS_XKey for specifying the x-axis of an xy-plot.static java.lang.StringAXIS_X2Key for specifying the secondary x-axis of an xy-plot.static java.lang.StringAXIS_YKey for specifying the y-axis of an xy-plot.static java.lang.StringAXIS_Y2Key for specifying the secondary y-axis of an xy-plot.
-
Constructor Summary
Constructors Constructor and Description XYPlot(DataSource... data)Initializes a new instance object with the specified data sources and reasonable default settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(int index, DataSource source, boolean visible)Inserts the specified data series to the plot at a specified position.voidaddPointRenderer(DataSource s, PointRenderer pointRenderer)Adds aPointRendererfor the specified data source.voiddraw(DrawingContext context)Draws theDrawablewith the specified drawing context.java.util.List<AreaRenderer>getAreaRenderers(DataSource s)Returns allAreaRenderers for the specified data source.java.util.List<LineRenderer>getLineRenderers(DataSource s)Returns allLineRenderers that display the data of the specified data source.NavigatorgetNavigator()Returns a navigator instance that can control the current object.java.util.List<PointRenderer>getPointRenderers(DataSource s)Returns allPointRenderers that display the data of the specified data source.voidrangeChanged(Axis axis, java.lang.Number min, java.lang.Number max)Notified if the range of an axis has changed.voidremovePointRenderer(DataSource s, PointRenderer pointRenderer)Decouples the specifiedPointRendererfrom the rendering of the specified data source.voidsetAreaRenderers(DataSource s, AreaRenderer areaRendererFirst, AreaRenderer... areaRenderers)Sets theAreaRenderers for a certain data source to the specified value.voidsetAreaRenderers(DataSource s, java.util.List<AreaRenderer> areaRenderers)Sets theAreaRenderers for a certain data source to the specified value.voidsetAxisRenderer(java.lang.String axisName, AxisRenderer renderer)Sets the renderer for the axis with the specified name.voidsetLineRenderers(DataSource s, LineRenderer lineRendererFirst, LineRenderer... lineRenderers)Sets theLineRenderers for a certain data source to the specified value.voidsetLineRenderers(DataSource s, java.util.List<LineRenderer> lineRenderers)Sets theLineRenderers for a certain data source to the specified value.voidsetPointRenderers(DataSource s, java.util.List<PointRenderer> pointRenderers)Sets thePointRenderers for a certain data source to the specified value.voidsetPointRenderers(DataSource s, PointRenderer pointRendererFirst, PointRenderer... pointRenderers)Sets thePointRenderers for a certain data source to the specified value.-
Methods inherited from class de.erichseifert.gral.plots.AbstractPlot
add, add, autoscaleAxis, clear, contains, dataAdded, dataRemoved, dataUpdated, get, getAxesNames, getAxis, getAxisRenderer, getBackground, getBorderColor, getBorderStroke, getData, getFont, getLegend, getLegendDistance, getLegendLocation, getMapping, getPlotArea, getTitle, getVisibleData, isLegendVisible, isVisible, layout, remove, removeAxis, setAxis, setBackground, setBorderColor, setBorderStroke, setFont, setLegendDistance, setLegendLocation, setLegendVisible, setMapping, setVisible
-
Methods inherited from class de.erichseifert.gral.graphics.DrawableContainer
add, add, contains, getConstraints, getDrawables, getDrawablesAt, getInsets, getLayout, getPreferredSize, iterator, remove, setBounds, setBounds, setInsets, setLayout, size
-
Methods inherited from class de.erichseifert.gral.graphics.AbstractDrawable
getBounds, getHeight, getWidth, getX, getY, setPosition
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.erichseifert.gral.graphics.Drawable
getBounds, getHeight, getPreferredSize, getWidth, getX, getY, setBounds, setBounds, setPosition
-
Methods inherited from interface de.erichseifert.gral.graphics.Container
add, add, contains, getBounds, getConstraints, getDrawables, getDrawablesAt, getInsets, getLayout, remove, setBounds, setInsets, setLayout, size
-
-
-
-
Field Detail
-
AXIS_X
public static final java.lang.String AXIS_X
Key for specifying the x-axis of an xy-plot.- See Also:
- Constant Field Values
-
AXIS_X2
public static final java.lang.String AXIS_X2
Key for specifying the secondary x-axis of an xy-plot.- See Also:
- Constant Field Values
-
AXIS_Y
public static final java.lang.String AXIS_Y
Key for specifying the y-axis of an xy-plot.- See Also:
- Constant Field Values
-
AXIS_Y2
public static final java.lang.String AXIS_Y2
Key for specifying the secondary y-axis of an xy-plot.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XYPlot
public XYPlot(DataSource... data)
Initializes a new instance object with the specified data sources and reasonable default settings.- Parameters:
data- Data to be displayed.
-
-
Method Detail
-
getPointRenderers
public java.util.List<PointRenderer> getPointRenderers(DataSource s)
Returns allPointRenderers that display the data of the specified data source.- Parameters:
s- Data source in question.- Returns:
- Renderers being applied on the specified data source.
-
addPointRenderer
public void addPointRenderer(DataSource s, PointRenderer pointRenderer)
Adds aPointRendererfor the specified data source.- Parameters:
s- Data to be rendered.pointRenderer- PointRenderer to be used.
-
removePointRenderer
public void removePointRenderer(DataSource s, PointRenderer pointRenderer)
Decouples the specifiedPointRendererfrom the rendering of the specified data source.- Parameters:
s- Data to be rendered no longer.pointRenderer- PointRenderer to be removed.
-
setPointRenderers
public void setPointRenderers(DataSource s, java.util.List<PointRenderer> pointRenderers)
Sets thePointRenderers for a certain data source to the specified value.- Parameters:
s- Data source.pointRenderers- PointRenderers to be set.
-
setPointRenderers
public void setPointRenderers(DataSource s, PointRenderer pointRendererFirst, PointRenderer... pointRenderers)
Sets thePointRenderers for a certain data source to the specified value.- Parameters:
s- Data source.pointRendererFirst- First PointRenderer.pointRenderers- Remaining PointRenderers to be set.
-
getLineRenderers
public java.util.List<LineRenderer> getLineRenderers(DataSource s)
Returns allLineRenderers that display the data of the specified data source.- Parameters:
s- Data source in question.- Returns:
- Renderers being applied on the specified data source.
-
setLineRenderers
public void setLineRenderers(DataSource s, java.util.List<LineRenderer> lineRenderers)
Sets theLineRenderers for a certain data source to the specified value.- Parameters:
s- Data source.lineRenderers-LineRenderers to be set.
-
setLineRenderers
public void setLineRenderers(DataSource s, LineRenderer lineRendererFirst, LineRenderer... lineRenderers)
Sets theLineRenderers for a certain data source to the specified value.- Parameters:
s- Data source.lineRendererFirst- FirstLineRendererto be set.lineRenderers- RemainingLineRenderers to be set.
-
getAreaRenderers
public java.util.List<AreaRenderer> getAreaRenderers(DataSource s)
Returns allAreaRenderers for the specified data source.- Parameters:
s- Data source.- Returns:
AreaRenderers used to render theDataSource.
-
setAreaRenderers
public void setAreaRenderers(DataSource s, java.util.List<AreaRenderer> areaRenderers)
Sets theAreaRenderers for a certain data source to the specified value.- Parameters:
s- Data source.areaRenderers-AreaRenderers to be set.
-
setAreaRenderers
public void setAreaRenderers(DataSource s, AreaRenderer areaRendererFirst, AreaRenderer... areaRenderers)
Sets theAreaRenderers for a certain data source to the specified value.- Parameters:
s- Data source.areaRendererFirst- FirstAreaRendererto be set.areaRenderers- RemainingAreaRenderers to be set.
-
setAxisRenderer
public void setAxisRenderer(java.lang.String axisName, AxisRenderer renderer)Description copied from class:AbstractPlotSets the renderer for the axis with the specified name.- Specified by:
setAxisRendererin interfacePlot- Overrides:
setAxisRendererin classAbstractPlot- Parameters:
axisName- Name of the axis to be rendered.renderer- Instance to render the axis.
-
add
public void add(int index, DataSource source, boolean visible)Description copied from class:AbstractPlotInserts the specified data series to the plot at a specified position.- Specified by:
addin interfacePlot- Overrides:
addin classAbstractPlot- Parameters:
index- Position.source- Data series.visible-trueif the series should be displayed,falseotherwise.
-
getNavigator
public Navigator getNavigator()
Returns a navigator instance that can control the current object.- Specified by:
getNavigatorin interfaceNavigable- Returns:
- A navigator instance.
-
draw
public void draw(DrawingContext context)
Description copied from class:AbstractPlotDraws theDrawablewith the specified drawing context.- Specified by:
drawin interfaceDrawable- Overrides:
drawin classAbstractPlot- Parameters:
context- Environment used for drawing
-
rangeChanged
public void rangeChanged(Axis axis, java.lang.Number min, java.lang.Number max)
Notified if the range of an axis has changed.- Specified by:
rangeChangedin interfaceAxisListener- Parameters:
axis- Axis instance that has changed.min- New minimum value.max- New maximum value.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG