Package uk.ac.starlink.ttools.plot2
Class PlotScene<P,A>
java.lang.Object
uk.ac.starlink.ttools.plot2.PlotScene<P,A>
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 Summary
ConstructorsConstructorDescriptionPlotScene
(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.PlotScene
(SurfaceFactory<P, A> surfFact, PlotLayer[] layers, P profile, Icon legend, float[] legPos, String title, A aspect, ShadeAxisFactory shadeFact, Span shadeFixSpan, PaperTypeSelector ptSel, Compositor compositor, Padding padding, PlotCaching caching) Constructs a PlotScene containing a single plot surface. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.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.findClosestRows
(Surface surface, PlotLayer[] layers, Point point, DataStore dataStore) Assembles and returns a list of row indexes that are plotted close to a given graphics position.A[]
Returns the most recently set aspects.getAuxSpans
(PlotLayer[] layers, Surface surface, Span shadeFixSpan, ShadeAxisFactory shadeFact, Object[] plans, DataStore dataStore) Gathers requested ranging information from data.getGang()
Returns the current plot gang.Returns the Ganger used by this scene.Surface[]
Returns the current plot surfaces.getZoneContent
(int iz) Returns the current zone content for a given zone.int
getZoneIndex
(Point pos) Returns the index of the zone in whose data bounds a given point lies.void
paintScene
(Graphics g, Rectangle extBounds, DataStore dataStore) Paints the contents of this plot to a graphics context.void
prepareScene
(Rectangle extBounds, DataStore dataStore) Ensures that the plot surfaces are ready to plot this scene.boolean
setAspects
(A[] aspects) Sets the aspects of the plot zones.
-
Constructor Details
-
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 groupingsurfFact
- surface factorynz
- number of plot zones in groupzoneContents
- 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 requiredshadeFixSpans
- fixed shader ranges by zone (nz-element array) elements may be null for auto-range or if no shade axisptSel
- paper type selectorcompositor
- compositor for pixel compositioncaching
- plot caching policy
-
PlotScene
public PlotScene(SurfaceFactory<P, A> surfFact, PlotLayer[] layers, P profile, Icon legend, float[] legPos, 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 factorylayers
- plot layers to be paintedprofile
- surface profilelegend
- legend icon if required, or nulllegPos
- legend position if intenal legend is required; 2-element (x,y) array, each element in range 0-1title
- title text, or nullaspect
- plot surface aspectshadeFact
- shader axis factory, or null if not requiredshadeFixSpan
- fixed shader span, or null for auto-rangeptSel
- paper type selectorcompositor
- compositor for pixel compositionpadding
- user requirements for external spacecaching
- plot caching policy
-
-
Method Details
-
getGanger
Returns the Ganger used by this scene.- Returns:
- ganger
-
getGang
Returns the current plot gang.- Returns:
- gang
-
getZoneContent
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. -
prepareScene
Ensures that the plot surfaces are ready to plot this scene. This method is invoked bypaintScene(java.awt.Graphics, java.awt.Rectangle, uk.ac.starlink.ttools.plot2.data.DataStore)
, but may be invoked directly if only the preparation and not the plotting itself is required.- Parameters:
extBounds
- external bounds of the plot, including any space required for axis labels, legend, padding etcdataStore
- data storage object
-
paintScene
Paints the contents of this plot to a graphics context.- Parameters:
g
- graphics contextextBounds
- external bounds of the plot, including any space required for axis labels, legend, padding etcdataStore
- data storage object
-
setAspects
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
Returns the most recently set aspects.- Returns:
- per-zone array of current aspects
-
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
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, 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 plottedlayers
- layers plottedpoint
- graphics position to which the selection event refersdataStore
- 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 groupingsurfFact
- surface factorynz
- number of plot zones in groupcontents
- 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 requiredshadeFixSpans
- fixed shader ranges by zone (nz-element array) elements may be null for auto-range or if no shade axisptSel
- paper type selectorcompositor
- compositor for pixel compositiondataStore
- data storage objectcaching
- plot caching policy on every repaint- Returns:
- new plot component
-
getAuxSpans
@Slow public static Map<AuxScale,Span> getAuxSpans(PlotLayer[] layers, Surface surface, Span shadeFixSpan, ShadeAxisFactory shadeFact, Object[] plans, DataStore dataStore) Gathers requested ranging information from data.- Parameters:
layers
- plot layerssurface
- plot surfaceshadeFixSpan
- fixed shade range limits, if anyshadeFact
- makes shader axis, or nullplans
- array of calculated plan objects, or nulldataStore
- data storage object- Returns:
- ranging information
-