Class Plot
- java.lang.Object
-
- jcckit.plot.Plot
-
- All Implemented Interfaces:
DataListener
public class Plot extends Object implements DataListener
A plot is determined by aCoordinateSystem,Curves, an optional annotation layer and an optionalLegend. When rendered these components are draw in this order.Registrated
PlotListenerswill be informed when the plot changes.A
DataPlotcan be connected with a Plot instance. This is done with the methodconnect()which registrates this Plot instance as aDataListenerat the connected DataPlot. After an receivedDataEventshas been handled the registrated PlotListeners will receive aPlotEventof the typePlotEventType.DATA_PLOT_CHANGED.- Author:
- Franz-Josef Elmer
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOORDINATE_SYSTEM_KEYConfiguration parameter key.static StringCURVE_FACTORY_KEYConfiguration parameter key.static StringINITIAL_HINT_FOR_NEXT_CURVE_KEYConfiguration parameter key.static StringLEGEND_KEYConfiguration parameter key.static StringLEGEND_VISIBLE_KEYConfiguration parameter key.
-
Constructor Summary
Constructors Constructor Description Plot(ConfigParameters config)Creates an instance from the specified configuration parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPlotListener(PlotListener listener)Adds the specifiedPlotListener.voidconnect(DataPlot dataPlot)Connect the specifiedDataPlotwith this instance.voiddataChanged(DataEvent event)Handles the receivedDataEventand notifiesPlotListenersby an event of the typePlotEventType.DATA_CURVE_CHANGEDorPlotEventType.DATA_PLOT_CHANGED.GraphicalElementgetAnnotation()Returns the annotation layer.GraphicalCompositegetCompletePlot()Creates a graphical representation of the complete plot.GraphicalElementgetCoordinateSystem()Returns the view of the coordinate system.GraphicalElement[]getCurves()Returns the graphical representations of all curves.GraphicalElementgetLegend()Returns the graphical representations of the legend.booleanisLegendVisible()Returns true if the legend is visible.protected voidnotifyListeners(PlotEvent event)Sends all registratedPlotListenersthe specified event.voidremovePlotListener(PlotListener listener)Removes the specfiedPlotListener.voidsetAnnotation(GraphicalElement annotation)Sets the annotation layer.voidsetCoordinateSystem(CoordinateSystem coordinateSystem)Sets the coordinate system.DataPointtransform(GraphPoint point)Transforms a point from device-independent coordinates into data coordinates.
-
-
-
Field Detail
-
COORDINATE_SYSTEM_KEY
public static final String COORDINATE_SYSTEM_KEY
Configuration parameter key.- See Also:
- Constant Field Values
-
CURVE_FACTORY_KEY
public static final String CURVE_FACTORY_KEY
Configuration parameter key.- See Also:
- Constant Field Values
-
LEGEND_VISIBLE_KEY
public static final String LEGEND_VISIBLE_KEY
Configuration parameter key.- See Also:
- Constant Field Values
-
LEGEND_KEY
public static final String LEGEND_KEY
Configuration parameter key.- See Also:
- Constant Field Values
-
INITIAL_HINT_FOR_NEXT_CURVE_KEY
public static final String INITIAL_HINT_FOR_NEXT_CURVE_KEY
Configuration parameter key.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Plot
public Plot(ConfigParameters config)
Creates an instance from the specified configuration parameters.Key & Default Value Type Mandatory Description coordinateSystem = CartesianCoordinateSystemConfigParameters no Definition of the CoordinateSystem.curveFactory = SimpleCurveFactoryConfigParameters no Definition of the CurveFactory.initialHintForNextCurve = null ConfigParameters no Definition of the initial Hintwhich is needed by someSymbolFactorieslikeBarFactory.legend = default values of LegendConfigParameters no Configuration parameters of a Legend.legendVisible = true boolean no If true the Legendwill be created.
-
-
Method Detail
-
setCoordinateSystem
public void setCoordinateSystem(CoordinateSystem coordinateSystem)
Sets the coordinate system. All curves will be regenerated and aPlotEventof typePlotEventType.COODINATE_SYSTEM_CHANGEDwill be fired.- Parameters:
coordinateSystem- New coordinate system.
-
addPlotListener
public void addPlotListener(PlotListener listener)
Adds the specifiedPlotListener. Does nothing if already added.
-
removePlotListener
public void removePlotListener(PlotListener listener)
Removes the specfiedPlotListener. Does nothing if already removed.
-
notifyListeners
protected void notifyListeners(PlotEvent event)
Sends all registratedPlotListenersthe specified event.
-
connect
public void connect(DataPlot dataPlot)
Connect the specifiedDataPlotwith this instance.If this Plot instance is already connected with a DataPlot the connection will be released and a
PlotEventof the typePlotEventType.DATA_PLOT_DISCONNECTEDwill be sent to all registratedPlotListeners.It registers itself at dataPlot and all its
DataCurves.Finally all curves will be generated and a PlotEvent of the type
PlotEventType.DATA_PLOT_CONNECTEDwill be transmitted.- Parameters:
dataPlot- Data to be connected with this plot instance. Can be null in order to disconnect this instance from any DataPlot.
-
transform
public DataPoint transform(GraphPoint point)
Transforms a point from device-independent coordinates into data coordinates.- Parameters:
point- Point in device-independent coordinates.- Returns:
- transform point.
-
getCompletePlot
public GraphicalComposite getCompletePlot()
Creates a graphical representation of the complete plot.- Returns:
- GraphicalComposite containing the views of the coordinate system, the curves, and optionally the legend (in this order).
-
getCoordinateSystem
public GraphicalElement getCoordinateSystem()
Returns the view of the coordinate system.
-
getCurves
public GraphicalElement[] getCurves()
Returns the graphical representations of all curves.
-
getAnnotation
public GraphicalElement getAnnotation()
Returns the annotation layer.- Returns:
- null if no annotation layer.
-
setAnnotation
public void setAnnotation(GraphicalElement annotation)
Sets the annotation layer.- Parameters:
annotation- Any kind of graphics which will be drawn on the top of the curves but may be covered by the legend. Can be null.
-
isLegendVisible
public boolean isLegendVisible()
Returns true if the legend is visible.
-
getLegend
public GraphicalElement getLegend()
Returns the graphical representations of the legend.
-
dataChanged
public void dataChanged(DataEvent event)
Handles the receivedDataEventand notifiesPlotListenersby an event of the typePlotEventType.DATA_CURVE_CHANGEDorPlotEventType.DATA_PLOT_CHANGED. The following table shows what this method does:Source of event All hints for the next curve are null? Action Type of sent PlotEventDataCurveYes Recreate changed curve. DATA_CURVE_CHANGED DataCurveNo Recreate changed curve and all curves with large curve index. DATA_PLOT_CHANGED DataPlot- Recreate all curves and Legendview.DATA_PLOT_CHANGED - Specified by:
dataChangedin interfaceDataListener- Parameters:
event- Data event informing where and what happened.
-
-