Class PlotScene<P,​A>


  • public class PlotScene<P,​A>
    extends java.lang.Object
    Contains the state of a plot, which can be painted to a graphics context. The plot's aspect and dimensions can be changed, which means it can form the basis of a 'live' plot.
    Since:
    5 Dec 2019
    Author:
    Mark Taylor
    • Constructor Detail

      • PlotScene

        public PlotScene​(Ganger<P,​A> ganger,
                         SurfaceFactory<P,​A> surfFact,
                         int nz,
                         ZoneContent[] zoneContents,
                         P[] profiles,
                         A[] aspects,
                         ShadeAxisFactory[] shadeFacts,
                         Span[] shadeFixSpans,
                         PaperTypeSelector ptSel,
                         Compositor compositor,
                         PlotCaching caching)
        Constructs a PlotScene containing multiple plot surfaces.
        Parameters:
        ganger - defines plot surface grouping
        surfFact - surface factory
        nz - number of plot zones in group
        zoneContents - plot content by zone (nz-element array)
        profiles - plot surface profiles by zone (nz-element array)
        aspects - plot surface aspects by zone (nz-element array)
        shadeFacts - shader axis factories by zone (nz-element array), elements may be null if not required
        shadeFixSpans - fixed shader ranges by zone (nz-element array) elements may be null for auto-range or if no shade axis
        ptSel - paper type selector
        compositor - compositor for pixel composition
        caching - plot caching policy
      • PlotScene

        public PlotScene​(SurfaceFactory<P,​A> surfFact,
                         PlotLayer[] layers,
                         P profile,
                         javax.swing.Icon legend,
                         float[] legPos,
                         java.lang.String title,
                         A aspect,
                         ShadeAxisFactory shadeFact,
                         Span shadeFixSpan,
                         PaperTypeSelector ptSel,
                         Compositor compositor,
                         Padding padding,
                         PlotCaching caching)
        Constructs a PlotScene containing a single plot surface.
        Parameters:
        surfFact - surface factory
        layers - plot layers to be painted
        profile - surface profile
        legend - legend icon if required, or null
        legPos - legend position if intenal legend is required; 2-element (x,y) array, each element in range 0-1
        title - title text, or null
        aspect - plot surface aspect
        shadeFact - shader axis factory, or null if not required
        shadeFixSpan - fixed shader span, or null for auto-range
        ptSel - paper type selector
        compositor - compositor for pixel composition
        padding - user requirements for external space
        caching - plot caching policy
    • Method Detail

      • getGanger

        public Ganger<P,​A> getGanger()
        Returns the Ganger used by this scene.
        Returns:
        ganger
      • getGang

        public Gang getGang()
        Returns the current plot gang.
        Returns:
        gang
      • getZoneContent

        public ZoneContent getZoneContent​(int iz)
        Returns the current zone content for a given zone.
        Parameters:
        iz - zone index
        Returns:
        zone content
      • clearPlot

        public void clearPlot()
        Clears the current cached plot image, if any, so that regeneration of the image from the data is forced when the next paint operation is performed; otherwise it may be copied from a cached image.
      • paintScene

        @Slow
        public void paintScene​(java.awt.Graphics g,
                               java.awt.Rectangle extBounds,
                               DataStore dataStore)
        Paints the contents of this plot to a graphics context.
        Parameters:
        g - graphics context
        extBounds - external bounds of the plot, including any space required for axis labels, legend, padding etc
        dataStore - data storage object
      • setAspects

        public boolean setAspects​(A[] aspects)
        Sets the aspects of the plot zones. Note this method does not test or adjust the supplied aspects for consistency with the ganger.
        Parameters:
        aspects - per-zone array of required aspects
        Returns:
        true iff the call resulted in a material change of the scene (requiring a repaint)
      • getAspects

        public A[] getAspects()
        Returns the most recently set aspects.
        Returns:
        per-zone array of current aspects
      • getSurfaces

        public Surface[] getSurfaces()
        Returns the current plot surfaces. They will have been generated by this display's SurfaceFactory. Elements may be null if they are not currently up to date (plot is in process of being repainted).
        Returns:
        per-zone surface array
      • getZoneIndex

        public int getZoneIndex​(java.awt.Point pos)
        Returns the index of the zone in whose data bounds a given point lies.
        Parameters:
        pos - graphics position
        Returns:
        index of zone containing pos, or -1 if none
      • findClosestRows

        @Slow
        public IndicatedRow[] findClosestRows​(Surface surface,
                                              PlotLayer[] layers,
                                              java.awt.Point point,
                                              DataStore dataStore)
        Assembles and returns a list of row indexes that are plotted close to a given graphics position. May return null, if the thread is interrupted, or possibly under other circumstances.
        Parameters:
        surface - plot surface on which layers are plotted
        layers - layers plotted
        point - graphics position to which the selection event refers
        dataStore - data storage object
        Returns:
        per-layer array of closest dataset row objects
      • createGangScene

        @Slow
        public static <P,​A> PlotScene<P,​A> createGangScene​(Ganger<P,​A> ganger,
                                                                       SurfaceFactory<P,​A> surfFact,
                                                                       int nz,
                                                                       ZoneContent[] contents,
                                                                       P[] profiles,
                                                                       ConfigMap[] aspectConfigs,
                                                                       ShadeAxisFactory[] shadeFacts,
                                                                       Span[] shadeFixSpans,
                                                                       PaperTypeSelector ptSel,
                                                                       Compositor compositor,
                                                                       DataStore dataStore,
                                                                       PlotCaching caching)
        Utility method to construct a ganged PlotDisplay, with aspect obtained from a supplied config map. This will perform ranging from data if it is required; in that case, it may take time to execute.
        Parameters:
        ganger - definses plot grouping
        surfFact - surface factory
        nz - number of plot zones in group
        contents - per-zone content information (nz-element array)
        profiles - per-zone profiles (nz-element array)
        aspectConfigs - per-zone config map providing entries for surf.getAspectKeys (nz-element arrays)
        shadeFacts - shader axis factorys by zone (nz-element array), elements may be null if not required
        shadeFixSpans - fixed shader ranges by zone (nz-element array) elements may be null for auto-range or if no shade axis
        ptSel - paper type selector
        compositor - compositor for pixel composition
        dataStore - data storage object
        caching - plot caching policy on every repaint
        Returns:
        new plot component
      • getAuxSpans

        @Slow
        public static java.util.Map<AuxScale,​Span> getAuxSpans​(PlotLayer[] layers,
                                                                     Surface surface,
                                                                     Span shadeFixSpan,
                                                                     ShadeAxisFactory shadeFact,
                                                                     java.lang.Object[] plans,
                                                                     DataStore dataStore)
        Gathers requested ranging information from data.
        Parameters:
        layers - plot layers
        surface - plot surface
        shadeFixSpan - fixed shade range limits, if any
        shadeFact - makes shader axis, or null
        plans - array of calculated plan objects, or null
        dataStore - data storage object
        Returns:
        ranging information