Module xaos.ui.plot

Class Plugin

  • Direct Known Subclasses:
    AbstractNamedPlugin

    public abstract class Plugin
    extends Object
    Base for XYChart plugins.
    Author:
    Grzegorz Kruk (original author)., claudio.rosati@esss.se
    • Constructor Detail

      • Plugin

        public Plugin()
    • Method Detail

      • getXAxis

        public static final <X> Axis<X> getXAxis​(Chart chart)
        Return the X Axis for the given chart.
        Type Parameters:
        X - The type of the X axis.
        Parameters:
        chart - The Chart whose X Axis must be returned.
        Returns:
        The X Axis for the given chart or null.
      • getXValueAxis

        public static final ValueAxis<?> getXValueAxis​(Chart chart)
        Return the X ValueAxis for the given chart.
        Parameters:
        chart - The Chart whose X ValueAxis must be returned.
        Returns:
        The X ValueAxis for the given chart or null.
      • getYAxis

        public static final <Y> Axis<Y> getYAxis​(Chart chart)
        Return the Y Axis for the given chart.
        Type Parameters:
        Y - The type of the Y axis.
        Parameters:
        chart - The Chart whose Y Axis must be returned.
        Returns:
        The Y Axis for the given chart or null.
      • getYValueAxis

        public static final ValueAxis<?> getYValueAxis​(Chart chart)
        Return the Y ValueAxis for the given chart.
        Parameters:
        chart - The Chart whose Y ValueAxis must be returned.
        Returns:
        The Y ValueAxis for the given chart or null.
      • formattedValue

        public static final <T> String formattedValue​(Axis<T> axis,
                                                      T value)
        Invokes the protected Axis.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()
        Returns Chart associated with this plugin or null 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 or null.
      • getYValueAxis

        public final ValueAxis<?> getYValueAxis()
        Returns:
        The Y ValueAxis for this plugin's chart or null.
      • 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 data XYChart.Series whose visibility is queried.
        Returns:
        true if the series' Node is visible.
        Throws:
        NullPointerException - If series or its Node 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 the series visibility change occurred.
        series - The XYChart.Series whose visibility changed.
        index - Index of (@code series} inside the chart's data.
        visible - The current visibility state of the given series.
      • 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()
        Returns:
        The Legend of the chart or null if no legend exists or it is not an instance of Legend.
      • 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 X Axis for getChart().
        Type Parameters:
        X - The type of the X axis.
        Returns:
        The X Axis or null.
      • 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 Y Axis for getChart().
        Type Parameters:
        Y - The type of the Y axis.
        Returns:
        The Y Axis or null.
      • 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)
        Returns true if the mouse cursor is inside the plot area.
        Parameters:
        event - The MouseEvent 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)
        Returns true 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 new Chart of this plugin. Can be null.
      • 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.