public class PlotPanel<P,A>
extends javax.swing.JComponent
implements java.awt.event.ActionListener
It is supplied at construction time with various objects capable of
acquiring (presumably from a GUI) information required to specify a plot,
and its replot
method conceptually acquires
all that information and prepares a plot accordingly.
The plot is cached to an icon (probably an image) which is in
turn painted by paintComponent
.
replot
should therefore be called any time the plot
information has changed, or may have changed.
In actual fact replot
additionally
expends a lot of effort to work out whether it can avoid doing some or
all of the work required for the plot on each occasion,
by caching and attempting to re-use the restults of various
computational steps if they have not become outdated.
The capability to do this as efficiently as possible drives quite a bit
of the design of the rest of the plotting framework, in particular
the requirement that a number of the objects determining plot content
can be assessed for equality to tell whether they have changed
materially since last time.
This component manages all the storage and caching of expensive (memory-intensive) resources: layer plans and data stores. Such resources should not be cached or otherwise held on to by long-lived reference elsewhere in the application.
This component also manages threading to get computation done in appropriate threads (and not on the EDT). At time of writing there are probably some improvements that can be made in that respect.
This component is an ActionListener - receiving any action will prompt a (potential) replot.
javax.swing.JComponent.AccessibleJComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
PlotPanel(uk.ac.starlink.ttools.plot2.data.DataStoreFactory storeFact,
uk.ac.starlink.ttools.plot2.SurfaceFactory<P,A> surfFact,
Factory<uk.ac.starlink.ttools.plot2.Ganger<P,A>> gangerFact,
Factory<ZoneDef<P,A>[]> zonesFact,
Factory<PlotPosition> posFact,
uk.ac.starlink.ttools.plot2.paper.PaperTypeSelector ptSel,
uk.ac.starlink.ttools.plot2.paper.Compositor compositor,
ToggleButtonModel sketchModel,
javax.swing.BoundedRangeModel progModel,
ToggleButtonModel showProgressModel,
ToggleButtonModel axisLockModel,
ToggleButtonModel auxLockModel)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent evt)
Invokes replot.
|
void |
addChangeListener(javax.swing.event.ChangeListener listener)
Adds a listener which will be messaged when the content of the
displayed plot actually changes.
|
void |
clearData()
Clears state to initial values, cancels any plots in progress,
and disposes of potentially expensive memory assets.
|
javax.swing.Icon |
createExportIcon(boolean forceBitmap)
Returns an icon corresponding to the current state of this panel.
|
GuiPointCloud |
createGuiPointCloud(int iz)
Returns a point cloud that describes all the point positions included
in a given zone for the most recent plot.
|
GuiPointCloud |
createPartialGuiPointCloud(int iz)
Returns a point cloud like that from
createGuiPointCloud(int)
but for partial positions - ones for which data positions will have
one or more missing (NaN) coordinates. |
uk.ac.starlink.ttools.plot2.data.DataStore |
getDataStore()
Returns the data store used in the most recent completed plot.
|
uk.ac.starlink.ttools.plot2.Gang |
getGang()
Returns zone arrangement gang for the most recently completed plot.
|
uk.ac.starlink.ttools.plot2.Surface |
getLatestSurface(int iz)
Returns the best guess for the plot surface of a given zone
which will be displayed next.
|
uk.ac.starlink.ttools.plot2.PlotLayer[] |
getPlotLayers(int iz)
Returns the plot layers painted in a given zone
for the most recent completed plot.
|
uk.ac.starlink.ttools.plot2.ReportMap[] |
getReports(int iz)
Returns the plot reports for a given zone
generated by the most recent completed plot.
|
uk.ac.starlink.ttools.plot2.Surface |
getSurface(int iz)
Returns the plot surface of a given zone
for the most recent completed plot.
|
int |
getZoneCount()
Returns the number of zones in the most recently completed plot.
|
ZoneId |
getZoneId(int iz)
Returns the zone ID of a given zone for the most recently
completed plot.
|
int |
getZoneIndex(java.awt.Point pos)
Returns the zone index for the surface whose data bounds enclose
a given graphics position.
|
protected void |
paintComponent(java.awt.Graphics g)
Paints the most recently cached plot icons.
|
void |
removeChangeListener(javax.swing.event.ChangeListener listener)
Removes a listener previously added.
|
void |
replot()
Call this on the event dispatch thread to indicate that the plot
inputs may have changed, to trigger a new plot.
|
void |
setHighlights(java.util.Map<uk.ac.starlink.ttools.plot2.SubCloud,double[]> highlightMap)
Sets a list of points which should be highlighted in the plot.
|
void |
setNavDecoration(uk.ac.starlink.ttools.plot2.Decoration navDec)
Sets a decoration giving visual feedback for navigation gestures.
|
void |
submitExtraAnnotator(java.lang.Runnable annotator)
Submits a runnable to run when the plot is not changing.
|
void |
submitPlotAnnotator(java.lang.Runnable annotator)
Submits a runnable to run on the same queue as the plot itself.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public PlotPanel(uk.ac.starlink.ttools.plot2.data.DataStoreFactory storeFact, uk.ac.starlink.ttools.plot2.SurfaceFactory<P,A> surfFact, Factory<uk.ac.starlink.ttools.plot2.Ganger<P,A>> gangerFact, Factory<ZoneDef<P,A>[]> zonesFact, Factory<PlotPosition> posFact, uk.ac.starlink.ttools.plot2.paper.PaperTypeSelector ptSel, uk.ac.starlink.ttools.plot2.paper.Compositor compositor, ToggleButtonModel sketchModel, javax.swing.BoundedRangeModel progModel, ToggleButtonModel showProgressModel, ToggleButtonModel axisLockModel, ToggleButtonModel auxLockModel)
Information flow is, or should be, one way - this component reads the data and the plot does not have side-effects on its constituent components, since passing information both ways generally leads to a lot of confusion. In fact as currently written one GUI compoent, the AxisController, is passed in and can be affected. It would be better to sanitize that.
A progress bar model is used so that progress can be logged whenever a scan through the data of one or several tables is under way. An alternative would be to pass a JProgressBar itself, so that a new model could be inserted every time a new progress operation started. That would actually be easier to use, but doing it this way makes it more obvious if multiple progress operations are happening concurrently, which as it stands they should not be.
storeFact
- data store factory implementationsurfFact
- surface factorygangerFact
- factory for defining how multi-zone plots are groupedzonesFact
- acquires per-zone informationposFact
- supplier of plot position settingsptSel
- rendering policycompositor
- compositor for composition of transparent pixelssketchModel
- model to decide whether intermediate sketch frames
are posted for slow plotsprogModel
- progress bar model for showing plot progressshowProgressModel
- model to decide whether data scan operations
are reported to the progress bar modelaxisLockModel
- model to determine whether axis auto-rescaling
should be inhibitedauxLockModel
- model to determine whether aux range auto-rescaling
should be inhibitedpublic void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed
in interface java.awt.event.ActionListener
public void replot()
public void submitExtraAnnotator(java.lang.Runnable annotator)
annotator
- runnable, typically for annotating the plot
in some sensepublic void submitPlotAnnotator(java.lang.Runnable annotator)
createGuiPointCloud
method
so that progress is logged as appropriate.annotator
- runnable to run on the plot queuepublic uk.ac.starlink.ttools.plot2.data.DataStore getDataStore()
public uk.ac.starlink.ttools.plot2.Gang getGang()
public int getZoneCount()
public int getZoneIndex(java.awt.Point pos)
pos
- graphics position to querypublic ZoneId getZoneId(int iz)
iz
- zone indexpublic uk.ac.starlink.ttools.plot2.Surface getSurface(int iz)
iz
- zone indexpublic uk.ac.starlink.ttools.plot2.PlotLayer[] getPlotLayers(int iz)
iz
- zone indexpublic uk.ac.starlink.ttools.plot2.ReportMap[] getReports(int iz)
iz
- zone indexpublic GuiPointCloud createGuiPointCloud(int iz)
iz
- zone indexpublic GuiPointCloud createPartialGuiPointCloud(int iz)
createGuiPointCloud(int)
but for partial positions - ones for which data positions will have
one or more missing (NaN) coordinates.iz
- zone indexSubCloud.createPartialSubClouds(uk.ac.starlink.ttools.plot2.PlotLayer[], boolean)
public uk.ac.starlink.ttools.plot2.Surface getLatestSurface(int iz)
iz
- zone indexpublic void clearData()
public void setHighlights(java.util.Map<uk.ac.starlink.ttools.plot2.SubCloud,double[]> highlightMap)
highlightMap
- sequence of data positions labelled by SubCloudpublic void setNavDecoration(uk.ac.starlink.ttools.plot2.Decoration navDec)
navDec
- navigation decoration, or null to erase itprotected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public void addChangeListener(javax.swing.event.ChangeListener listener)
listener
- plot change listenerpublic void removeChangeListener(javax.swing.event.ChangeListener listener)
listener
- plot change listenerpublic javax.swing.Icon createExportIcon(boolean forceBitmap)
forceBitmap
- true to force bitmap output of vector graphics,
false to use default behaviourCopyright © 2003-2017 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.