Package de.gsi.chart.plugins
Class ChartPlugin
- java.lang.Object
-
- de.gsi.chart.plugins.ChartPlugin
-
- Direct Known Subclasses:
AbstractDataFormattingPlugin,AbstractValueIndicator,ChartOverlay,EditAxis,Panner,ParameterMeasurements,TableViewer,Zoomer
public abstract class ChartPlugin extends java.lang.ObjectRepresents an add-on to a Chart that can either annotate/decorate the chart or perform some interactions with it.Concrete plugin implementations may add custom nodes to the chart via
getChartChildren()which returns an observable and modifiable list of nodes that will be added to theXYChartPaneon top of charts.Plugins may also listen and react to events (e.g. mouse events) generated on the
XYChartPaneviaregisterInputEventHandler(EventType, EventHandler)method.- Author:
- Grzegorz Kruk, braeun - modified to be able to use XYChart class, rstein - modified to new Chart, XYChart API
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedChartPlugin()Creates a new instance of the ChartPlugin.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.beans.property.BooleanPropertyaddButtonsToToolBarProperty()Whentruethe corresponding control buttons are added to the chart tool barjavafx.beans.property.ObjectProperty<Chart>chartProperty()The associatedChart.ChartgetChart()Returns the value of thechartProperty().javafx.collections.ObservableList<javafx.scene.Node>getChartChildren()Returns a list containing nodes that should be added to the list of child nodes of the associated XYChart's plot area children.protected javafx.geometry.Point2DgetLocationInPlotArea(javafx.scene.input.MouseEvent event)Converts mouse location within the scene to the location relative to the plot area.booleanisAddButtonsToToolBar()Returns the value of theaddButtonsToToolBarProperty().voidlayoutChildren()Optional method that allows the plug-in to react in case the size of the chart that it belongs to has changed.protected voidregisterInputEventHandler(javafx.event.EventType<? extends javafx.scene.input.InputEvent> eventType, javafx.event.EventHandler<? extends javafx.scene.input.InputEvent> handler)Registers event handlers that should be added to theXYChartPanenode when the plugin is added to the pane and are removed once the plugin is removed from the pane.voidsetAddButtonsToToolBar(boolean state)Sets the value of theaddButtonsToToolBarProperty().voidsetChart(Chart chart)Called by theChartwhen the plugin is added to it.protected de.gsi.dataset.spi.utils.Tuple<java.lang.Number,java.lang.Number>toDataPoint(Axis yAxis, javafx.geometry.Point2D displayPoint)Converts given display point within the plot area coordinates to the corresponding data point within data coordinates.protected javafx.geometry.Point2DtoDisplayPoint(Axis yAxis, double x, double y)Converts given point in data coordinates to a point in display coordinates.
-
-
-
Method Detail
-
chartProperty
public final javafx.beans.property.ObjectProperty<Chart> chartProperty()
The associatedChart. Initialised when the plug-in is added to the Chart, set tonullwhen removed.- Returns:
- the chart property
-
getChart
public final Chart getChart()
Returns the value of thechartProperty().- Returns:
- the associated Chart or
null
-
setChart
public final void setChart(Chart chart)
Called by theChartwhen the plugin is added to it.- Parameters:
chart- the chart pane
-
addButtonsToToolBarProperty
public final javafx.beans.property.BooleanProperty addButtonsToToolBarProperty()
Whentruethe corresponding control buttons are added to the chart tool bar- Returns:
- the sliderVisible property
-
setAddButtonsToToolBar
public final void setAddButtonsToToolBar(boolean state)
Sets the value of theaddButtonsToToolBarProperty().- Parameters:
state- iftruethe corresponding control buttons are added to the chart tool bar
-
isAddButtonsToToolBar
public final boolean isAddButtonsToToolBar()
Returns the value of theaddButtonsToToolBarProperty().- Returns:
truethe corresponding control buttons are added to the chart tool bar
-
registerInputEventHandler
protected final void registerInputEventHandler(javafx.event.EventType<? extends javafx.scene.input.InputEvent> eventType, javafx.event.EventHandler<? extends javafx.scene.input.InputEvent> handler)Registers event handlers that should be added to theXYChartPanenode when the plugin is added to the pane and are removed once the plugin is removed from the pane.- Parameters:
eventType- the event type on which the handler should be calledhandler- the event handler to be added to the chart
-
getChartChildren
public final javafx.collections.ObservableList<javafx.scene.Node> getChartChildren()
Returns a list containing nodes that should be added to the list of child nodes of the associated XYChart's plot area children.The method should be used by concrete implementations to add nodes that should be added to the chart area.
- Returns:
- non-null list of nodes to be added to the chart's plot area
-
layoutChildren
public void layoutChildren()
Optional method that allows the plug-in to react in case the size of the chart that it belongs to has changed.
-
getLocationInPlotArea
protected final javafx.geometry.Point2D getLocationInPlotArea(javafx.scene.input.MouseEvent event)
Converts mouse location within the scene to the location relative to the plot area.- Parameters:
event- mouse event- Returns:
- location within the plot area
-
toDisplayPoint
protected final javafx.geometry.Point2D toDisplayPoint(Axis yAxis, double x, double y)
Converts given point in data coordinates to a point in display coordinates.- Parameters:
yAxis- the corresponding y-axis (number axis)x- the X coordinate (can be generic non-number, ie. CategoryAxis)y- the Y coordinate on the yAxis (Number based)- Returns:
- corresponding display point within the plot area
-
toDataPoint
protected final de.gsi.dataset.spi.utils.Tuple<java.lang.Number,java.lang.Number> toDataPoint(Axis yAxis, javafx.geometry.Point2D displayPoint)
Converts given display point within the plot area coordinates to the corresponding data point within data coordinates.- Parameters:
yAxis- the number-based y axisdisplayPoint- the display point to be converted- Returns:
- the data point
-
-