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, ZoneContent<P, A>[] zoneContents, Trimming[] trimmings, ShadeAxisKit[] shadeKits, PaperTypeSelector ptSel, Compositor compositor, PlotCaching caching) Constructs a PlotScene containing multiple plot surfaces.PlotScene
(SurfaceFactory<P, A> surfFact, ZoneContent<P, A> content, Trimming trimming, ShadeAxisKit shadeKit, PaperTypeSelector ptSel, Compositor compositor, Padding padding, PlotCaching caching) Constructs a PlotScene containing a single plot surface. -
Method Summary
Modifier and TypeMethodDescriptioncalculateNonShadeSpans
(PlotLayer[] layers, Surface surface, Object[] plans, DataStore dataStore) Gathers requested ranging information from data, excluding the AuxScale.COLOR item (the aux shading axis).static Span
calculateShadeSpan
(List<uk.ac.starlink.util.Bi<Surface, PlotLayer>> surfLayers, ShadeAxisKit shadeKit, Object[] plans, DataStore dataStore) Gathers ranging information for the aux shading axis from data.void
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, PlotLayer[][] layerArrays, P[] profiles, ConfigMap[] aspectConfigs, Trimming[] trimmings, ShadeAxisKit[] shadeKits, 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.getGang()
Returns the current plot gang.Returns the Ganger used by this scene.getLayers
(int iz) Returns the plot layers contained in a given zone.Surface[]
Returns the current plot surfaces.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, ZoneContent<P, A>[] zoneContents, Trimming[] trimmings, ShadeAxisKit[] shadeKits, PaperTypeSelector ptSel, Compositor compositor, PlotCaching caching) Constructs a PlotScene containing multiple plot surfaces.The zoneContents array must have a number of entries that matches the zone count of the ganger. The trimmings and shadeKits are supplied as arrays, and in each case may be either a 1- or nzone-element array depending on the Ganger's
Ganger.isTrimmingGlobal()
/Ganger.isShadingGlobal()
flags.- Parameters:
ganger
- defines plot surface groupingsurfFact
- surface factoryzoneContents
- plot content with initial aspect by zone (nz-element array)trimmings
- plot decoration specification by zone (nz- or 1-element array, elements may be null)shadeKits
- shader axis kits by zone (nz- or 1-element array, elements may be null)ptSel
- paper type selectorcompositor
- compositor for pixel compositioncaching
- plot caching policy
-
PlotScene
public PlotScene(SurfaceFactory<P, A> surfFact, ZoneContent<P, A> content, Trimming trimming, ShadeAxisKit shadeKit, PaperTypeSelector ptSel, Compositor compositor, Padding padding, PlotCaching caching) Constructs a PlotScene containing a single plot surface.- Parameters:
surfFact
- surface factorycontent
- plot content with initial aspecttrimming
- specification of additional decorationshadeKit
- shader axis specifier, or null if not requiredptSel
- 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
-
getLayers
Returns the plot layers contained in a given zone.- Parameters:
iz
- zone index- Returns:
- plot layers
-
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, PlotLayer[][] layerArrays, P[] profiles, ConfigMap[] aspectConfigs, Trimming[] trimmings, ShadeAxisKit[] shadeKits, 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.The layerArrays, profiles and aspectConfigs arrays must have the same length as the ganger zone count. The trimmings and shadeKits are supplied as arrays, and in each case may be either a 1- or nzone-element array depending on the Ganger's
Ganger.isTrimmingGlobal()
/Ganger.isShadingGlobal()
flags.- Parameters:
ganger
- defines plot groupingsurfFact
- surface factorylayerArrays
- per-zone layer arrays (nz-element array)profiles
- per-zone profiles (nz-element array); should be result of ganger.adjustProfilesaspectConfigs
- per-zone config map providing entries for surf.getAspectKeys (nz-element arrays)trimmings
- plot decoration specification by zone (nz- or 1-element array,elements may be null)shadeKits
- shader axis specifiers by zone (nz- or 1-element array, elements may be null)ptSel
- paper type selectorcompositor
- compositor for pixel compositiondataStore
- data storage objectcaching
- plot caching policy on every repaint- Returns:
- new plot component
-
calculateNonShadeSpans
@Slow public static Map<AuxScale,Span> calculateNonShadeSpans(PlotLayer[] layers, Surface surface, Object[] plans, DataStore dataStore) Gathers requested ranging information from data, excluding the AuxScale.COLOR item (the aux shading axis). The result is a map with an entry for every AuxScale required by any of the submitted layers, apart from AuxScale.COLOR, which must be calculated separately.- Parameters:
layers
- plot layerssurface
- surface on which layers will be plottedplans
- array of calculated plan objects, or nulldataStore
- data storage object- Returns:
- ranging information
- See Also:
-
calculateShadeSpan
@Slow public static Span calculateShadeSpan(List<uk.ac.starlink.util.Bi<Surface, PlotLayer>> surfLayers, ShadeAxisKit shadeKit, Object[] plans, DataStore dataStore) Gathers ranging information for the aux shading axis from data. The result is a Span relating to the AuxScale.COLOR scale.- Parameters:
surfLayers
- list of paired (surface,layer) items corresponding to the plot that will be performedshadeKit
- specifies shader axis, or nullplans
- array of calculated plan objects, or nulldataStore
- data storage object- Returns:
- AuxScale.COLOR ranging information, or null if none is required by the surfLayers
- See Also:
-