- java.lang.Object
-
- eu.ess.xaos.ui.plot.Plugin
-
- Direct Known Subclasses:
AbstractNamedPlugin
public abstract class Plugin extends Object
Base forXYChart
plugins.- Author:
- Grzegorz Kruk (original author)., claudio.rosati@esss.se
-
-
Constructor Summary
Constructors Constructor Description Plugin()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
chartConnected(Chart newChart)
Called when the plugin is added to a chart.protected void
chartDisconnected(Chart oldChart)
Called when the plugin has been removed from the chart.static <T> String
formattedValue(Axis<T> axis, T value)
Invokes the protectedAxis.getTickMarkLabel(java.lang.Object)
using introspection.Chart
getChart()
ReturnsChart
associated with this plugin ornull
if this plugin hasn't been added to any chart.protected Legend
getChartLegend()
String
getFailureMessage()
protected Point2D
getLocationInPlotArea(Point2D mouseLocationInScene)
Converts mouse location within the scene to the location relative to the plot area.protected Point2D
getLocationInPlotArea(MouseEvent event)
Converts mouse location within the scene to the location relative to the plot area.abstract String
getName()
protected Bounds
getPlotAreaBounds()
Gets the bounds of the plot area.protected ObservableList<Node>
getPlotChildren()
Returns a list containing nodes that should be added to the list of child nodes of the associated XYChart's plot area children.protected <X> Axis<X>
getXAxis()
Return the XAxis
forgetChart()
.static <X> Axis<X>
getXAxis(Chart chart)
Return the XAxis
for the givenchart
.ValueAxis<?>
getXValueAxis()
static ValueAxis<?>
getXValueAxis(Chart chart)
Return the XValueAxis
for the givenchart
.protected <X> X
getXValueForDisplay(double xDisplayValue)
protected double
getXValueForDisplayAsDouble(double xDisplayValue)
protected <Y> Axis<Y>
getYAxis()
Return the YAxis
forgetChart()
.static <Y> Axis<Y>
getYAxis(Chart chart)
Return the YAxis
for the givenchart
.ValueAxis<?>
getYValueAxis()
static ValueAxis<?>
getYValueAxis(Chart chart)
Return the YValueAxis
for the givenchart
.protected <Y> Y
getYValueForDisplay(double yDisplayValue)
protected double
getYValueForDisplayAsDouble(double yDisplayValue)
boolean
isBindFailed()
protected boolean
isInsidePlotArea(Point2D mouseLocationInScene)
Returnstrue
if the mouse cursor is inside the plot area.protected boolean
isInsidePlotArea(MouseEvent event)
Returnstrue
if the mouse cursor is inside the plot area.<X,Y>
booleanisSeriesVisible(XYChart.Series<X,Y> series)
<X,Y>
voidseriesVisibilityUpdated(Chart chart, XYChart.Series<X,Y> series, int index, boolean visible)
Called by charts when the visibility of a series changed.protected void
setChart(Chart newChart)
Sets (or resets) the chart for this plugin.protected XYChart.Data<?,?>
toDataPoint(Point2D displayPoint)
Converts given point in display coordinates into the corresponding point in data coordinates.protected Point2D
toDisplayPoint(XYChart.Data<?,?> dataPoint)
Converts given point in data coordinates into the corresponding point in display coordinates.
-
-
-
Method Detail
-
getXAxis
public static final <X> Axis<X> getXAxis(Chart chart)
Return the XAxis
for the givenchart
.
-
getXValueAxis
public static final ValueAxis<?> getXValueAxis(Chart chart)
Return the XValueAxis
for the givenchart
.
-
getYAxis
public static final <Y> Axis<Y> getYAxis(Chart chart)
Return the YAxis
for the givenchart
.
-
getYValueAxis
public static final ValueAxis<?> getYValueAxis(Chart chart)
Return the YValueAxis
for the givenchart
.
-
formattedValue
public static final <T> String formattedValue(Axis<T> axis, T value)
Invokes the protectedAxis.getTickMarkLabel(java.lang.Object)
using introspection.- Type Parameters:
T
- The data type of the axis.- Parameters:
axis
- The axis.value
- The value to be formatted.- Returns:
- A string representing the formatted value or
null
.
-
getChart
public final Chart getChart()
ReturnsChart
associated with this plugin ornull
if this plugin hasn't been added to any chart.- Returns:
- The associated chart or
null
.
-
getFailureMessage
public String getFailureMessage()
- Returns:
- The binding failure message or
null
.
-
getName
public abstract String getName()
- Returns:
- The display name of this plugin.
-
getXValueAxis
public final ValueAxis<?> getXValueAxis()
- Returns:
- The X
ValueAxis
for this plugin's chart ornull
.
-
getYValueAxis
public final ValueAxis<?> getYValueAxis()
- Returns:
- The Y
ValueAxis
for this plugin's chart ornull
.
-
isBindFailed
public boolean isBindFailed()
- Returns:
true
if binding failed.
-
isSeriesVisible
public <X,Y> boolean isSeriesVisible(XYChart.Series<X,Y> series)
- Type Parameters:
X
- Type of X values.Y
- Type of Y values.- Parameters:
series
- The dataXYChart.Series
whose visibility is queried.- Returns:
true
if the series'Node
is visible.- Throws:
NullPointerException
- Ifseries
or itsNode
are {code null}.
-
seriesVisibilityUpdated
public <X,Y> void seriesVisibilityUpdated(Chart chart, XYChart.Series<X,Y> series, int index, boolean visible)
Called by charts when the visibility of a series changed.- Type Parameters:
X
- Type of X values.Y
- Type of Y values.- Parameters:
chart
- The chart where theseries
visibility change occurred.series
- TheXYChart.Series
whose visibility changed.index
- Index of (@code series} inside thechart
's data.visible
- The current visibility state of the givenseries
.
-
chartConnected
protected void chartConnected(Chart newChart)
Called when the plugin is added to a chart.Can be overridden by concrete implementations to register e.g. mouse listeners or perform any other initializations.
- Parameters:
newChart
- The chart to which the plugin has been added.
-
chartDisconnected
protected void chartDisconnected(Chart oldChart)
Called when the plugin has been removed from the chart.Can be overridden by concrete implementations to unbind listeners and perform any other cleanup operations.
- Parameters:
oldChart
- The chart from which the plugin has been removed.
-
getChartLegend
protected Legend getChartLegend()
-
getLocationInPlotArea
protected final Point2D getLocationInPlotArea(MouseEvent event)
Converts mouse location within the scene to the location relative to the plot area.- Parameters:
event
- The mouse event.- Returns:
- The location within the plot area.
- Throws:
NullPointerException
- If the plugin hasn't been added to any chart.
-
getLocationInPlotArea
protected final Point2D getLocationInPlotArea(Point2D mouseLocationInScene)
Converts mouse location within the scene to the location relative to the plot area.- Parameters:
mouseLocationInScene
- The mouse location in scene coordinates system.- Returns:
- The location within the plot area.
- Throws:
NullPointerException
- If the plugin hasn't been added to any chart.
-
getPlotAreaBounds
protected final Bounds getPlotAreaBounds()
Gets the bounds of the plot area.- Returns:
- the bounds of the plot area or
null
if the plugin hasn't been added to any chart - Throws:
NullPointerException
- If the plugin hasn't been added to any chart.
-
getPlotChildren
protected final ObservableList<Node> getPlotChildren()
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 any graphical components that should be rendered on the plot area.
- Returns:
- Non-
null
list of nodes to be added to the chart's plot area.
-
getXAxis
protected final <X> Axis<X> getXAxis()
Return the XAxis
forgetChart()
.- Type Parameters:
X
- The type of the X axis.- Returns:
- The X
Axis
ornull
.
-
getXValueForDisplay
protected final <X> X getXValueForDisplay(double xDisplayValue)
- Type Parameters:
X
- The type of the X axis.- Parameters:
xDisplayValue
- The display position on X axis.- Returns:
- The data value for the given display position on the X axis or
null
.
-
getXValueForDisplayAsDouble
protected final double getXValueForDisplayAsDouble(double xDisplayValue)
- Parameters:
xDisplayValue
- The display position on X axis.- Returns:
- The data value for the given display position on the X axis as a double value.
-
getYAxis
protected final <Y> Axis<Y> getYAxis()
Return the YAxis
forgetChart()
.- Type Parameters:
Y
- The type of the Y axis.- Returns:
- The Y
Axis
ornull
.
-
getYValueForDisplay
protected final <Y> Y getYValueForDisplay(double yDisplayValue)
- Type Parameters:
Y
- The type of the Y axis.- Parameters:
yDisplayValue
- The display position on Y axis.- Returns:
- The data value for the given display position on the Y axis or
null
.
-
getYValueForDisplayAsDouble
protected final double getYValueForDisplayAsDouble(double yDisplayValue)
- Parameters:
yDisplayValue
- The display position on Y axis.- Returns:
- The data value for the given display position on the Y axis as a double value.
-
isInsidePlotArea
protected final boolean isInsidePlotArea(MouseEvent event)
Returnstrue
if the mouse cursor is inside the plot area.- Parameters:
event
- TheMouseEvent
containing the cursor position.- Returns:
true
if the mouse cursor is inside the plot area,false
otherwise.- Throws:
NullPointerException
- If the plugin hasn't been added to any chart.
-
isInsidePlotArea
protected final boolean isInsidePlotArea(Point2D mouseLocationInScene)
Returnstrue
if the mouse cursor is inside the plot area.- Parameters:
mouseLocationInScene
- The mouse location in scene coordinates system.- Returns:
true
if the mouse cursor is inside the plot area,false
otherwise.- Throws:
NullPointerException
- If the plugin hasn't been added to any chart.
-
setChart
protected void setChart(Chart newChart)
Sets (or resets) the chart for this plugin.- Parameters:
newChart
- The newChart
of this plugin. Can benull
.
-
toDataPoint
protected final XYChart.Data<?,?> toDataPoint(Point2D displayPoint)
Converts given point in display coordinates into the corresponding point in data coordinates.- Parameters:
displayPoint
- The point in display coordinates to be converted.- Returns:
- The corresponding point in data coordinates.
- Throws:
NullPointerException
- If the plugin hasn't been added to any chart.
-
toDisplayPoint
protected Point2D toDisplayPoint(XYChart.Data<?,?> dataPoint)
Converts given point in data coordinates into the corresponding point in display coordinates.- Parameters:
dataPoint
- The point in data coordinates to be converted.- Returns:
- The corresponding point in display coordinates.
- Throws:
NullPointerException
- If the plugin hasn't been added to any chart.
-
-