Class ArrayShapePlotter

  • All Implemented Interfaces:
    ModePlotter<ShapeStyle>, ShapeModePlotter, Plotter<ShapeStyle>

    public class ArrayShapePlotter
    extends ShapePlotter
    ShapePlotter subclass that plots multiple shapes for each row, based on array-valued coordinates. This class provides some additional functionality specific to array-valued positions.

    This plotter does not report positions and point clouds in the usual way, since each row typically corresponds to a large region of the plot surface, and reporting a single point is not very helpful. Instead, the PlotLayers it supplies are doctored to adjust the coordinate ranges to cover the whole of the relevant area for the plotted rows.

    Since:
    27 Jan 2021
    Author:
    Mark Taylor
    • Constructor Detail

      • ArrayShapePlotter

        public ArrayShapePlotter​(java.lang.String name,
                                 ShapeForm form,
                                 ShapeMode mode)
        Constructor.
        Parameters:
        name - plotter name
        form - multiple shape determiner
        mode - colour determiner
    • Method Detail

      • getModeCoordsIndex

        public int getModeCoordsIndex​(DataGeom geom)
        Description copied from class: ShapePlotter
        Returns the index into a dataspec used by this plotter at which the first of its ShapeMode's "extra" coordinates is found.
        Overrides:
        getModeCoordsIndex in class ShapePlotter
        Parameters:
        geom - data position coordinate description
        Returns:
        index of first mode-specific coordinate
      • createLayer

        public PlotLayer createLayer​(DataGeom pointDataGeom,
                                     DataSpec dataSpec,
                                     ShapeStyle style)
        Description copied from interface: Plotter
        Creates a PlotLayer based on the given geometry, data and style.

        The style parameter is the result of a call to Plotter.createStyle(uk.ac.starlink.ttools.plot2.config.ConfigMap).

        The dataSpec parameter must contain the coordinates defined by this plotter's CoordGroup.

        The pointDataGeom parameter is only used if getCoordGroup(). getPositionCount returns a non-zero value, otherwise the plot does not have point positions.

        It is legal to supply null for any of the parameters; if insufficient data is supplied to generate a plot, then the method should return null.

        Creating a layer should be cheap; layers may be created and not used.

        Specified by:
        createLayer in interface Plotter<ShapeStyle>
        Overrides:
        createLayer in class ShapePlotter
        Parameters:
        pointDataGeom - indicates base position coordinates and their mapping to points in the data space; if non-null, the data geom's DataGeom.hasPosition() method will return true
        dataSpec - specifies the data required for the plot
        style - data style as obtained from createStyle
        Returns:
        new plot layer, or null if no drawing will take place
      • createArrayShapePlotters

        public static ArrayShapePlotter[] createArrayShapePlotters​(ShapeForm[] forms,
                                                                   ShapeMode[] modes)
        Creates an array of ArrayShapePlotters, using all combinations of the specified list of ShapeForms and ShapeModes. Since these implement the ModePlotter interface, other parts of the UI may be able to group them.
        Parameters:
        forms - array of shape forms
        modes - array of shape modes
        Returns:
        forms.length*modes.length-element array of plotters
      • matchesAxis

        public static boolean matchesAxis​(java.lang.String axName,
                                          Input input)
        Utility method that identifies whether an Input corresponds to a named axis. This is an ad hoc method put in place to assist in working out how to annotate axes on which array plots are represented.
        Parameters:
        axName - geometric axis name, e.g. "X"
        input - coordinate input specification
        Returns:
        true iff the input corresponds to an array value specifier intended for the named axis
      • createXYArrayReader

        public static java.util.function.Function<Tuple,​XYArrayData> createXYArrayReader​(FloatingArrayCoord xsCoord,
                                                                                               FloatingArrayCoord ysCoord,
                                                                                               int icXs,
                                                                                               int icYs,
                                                                                               DataSpec dataSpec)
        Returns a reader for matched X/Y array data for use with array plotters. If null is returned from this function, no plotting should be done.
        Parameters:
        xsCoord - coordinate for X array
        ysCoord - coordinate for Y array
        icXs - X array coordinate index in group
        icYs - Y array coordinate index in group
        dataSpec - data specification
        Returns:
        thread-safe function to map tuples to XYArrayData; the function returns null for tuples that should not be plotted/accumulated