public abstract class GraphicsWindow extends AuxWindow
The basic way that plotting works is as follows. Almost all the
controls visible on the GraphicsWindow do nothing except trigger
the replot action getReplotListener()
when their state changes,
which schedules a replot to occur later on the event dispatch thread.
When the replot is executed, the getPlotState()
method is
called which goes through all the controls and assembles a
PlotState
object (of a class which is probably specific to
the window implementation). Only if this PlotState differs
from the last gathered PlotState will any actual plotting action take
place. This means that we don't worry about triggering loads of
replot actions - as long as the state doesn't change materially
between one and the next, they're cheap. If the state does change
materially, then a new plot is required. The work done for plotting
depends on the details of how the PlotState has changed - in some cases
new data will be acquired (PointSelection.readPoints
is called - possibly expensive),
but if the data is the same as before, the plot just
needs to be redrawn (usually quite fast, since the various plotting
classes are written as efficiently as possible).
It is therefore very important for performance reasons that you can
tell whether one plot state differs from the last one. Since the
PlotState is a newly created object each time, its equals()
method is used - so PlotState.equals()
must be written
with great care. There's an assertion in this class which tests that
two PlotStates gathered at the same time are equal, so you should find
out if your equals() method is calling two equal states unequal.
If it's calling two unequal states equal, then you'll find that the
plot doesn't get updated when state changes.
Modifier and Type | Class and Description |
---|---|
protected class |
GraphicsWindow.ExportAction
Actions for exporting the plot to a file.
|
protected class |
GraphicsWindow.ReplotListener
General purpose listener which replots given an event.
|
JFrame.AccessibleJFrame
Frame.AccessibleAWTFrame
Window.AccessibleAWTWindow, Window.Type
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
GraphicsWindow(String viewName,
uk.ac.starlink.ttools.plot.TablePlot plot,
String[] axisNames,
int naux,
boolean hasLabels,
ErrorModeSelectionModel[] errorModeModels,
Component parent)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected AxesSelector |
addExtraAxes(AxesSelector axsel)
Adds additional axes to a given AxesSelector as appropriate for this
window.
|
protected void |
addNewSubsets(BitSet pointsMask)
Adds a new row subset to tables associated with this window as
appropriate.
|
uk.ac.starlink.ttools.plot.Range[] |
calculateRanges(uk.ac.starlink.ttools.plot.PlotData data,
uk.ac.starlink.ttools.plot.PlotState state)
Calculates data ranges for a given data set.
|
JMenu |
createErrorModeMenu()
Constructs and returns a menu which can be used to select error modes
for this window.
|
static ErrorModeSelectionModel[] |
createErrorModeModels(String[] axisNames)
Creates a default set of ErrorModeSelectionModels given a list of
axis names.
|
JMenu |
createErrorRendererMenu(uk.ac.starlink.ttools.plot.ErrorRenderer[] renderers)
Constructs and returns a menu which can be used to select error styles
to be imposed at once on all subsets.
|
JMenu |
createMarkerStyleMenu(uk.ac.starlink.ttools.plot.StyleSet[] styleSets)
Constructs and returns a menu for selecting marker styles.
|
protected uk.ac.starlink.ttools.plot.PlotState |
createPlotState()
Constructs a new PlotState.
|
protected PointSelector |
createPointSelector()
Returns a new PointSelector instance to be used for selecting
points to be plotted.
|
protected abstract StyleEditor |
createStyleEditor()
Creates a style editor suitable for this window.
|
void |
dispose() |
protected void |
doReplot(uk.ac.starlink.ttools.plot.PlotState state)
Performs an actual plot.
|
static uk.ac.starlink.ttools.plot.StyleSet[] |
fixDefaultErrorRenderers(uk.ac.starlink.ttools.plot.ErrorRenderer erend,
uk.ac.starlink.ttools.plot.StyleSet[] styleSets)
Utility method to adjust an array of style sets so that all its
members use a given error renderer by default.
|
int |
getAuxAxisCount()
Returns the total (maximum) number of auxiliary axes used by this
window.
|
Action |
getAxisEditAction()
Returns an action which can be used to configure axes manually.
|
AxisWindow |
getAxisWindow()
Returns the axis configuration window associated with this window.
|
int |
getColumnIndex(TableColumn tcol)
Returns the index in the TableModel (not the TableColumnModel) of
the given TableColumn.
|
uk.ac.starlink.ttools.plot.Range[] |
getDataRanges()
Returns the most recently calculated data range objects.
|
abstract uk.ac.starlink.ttools.plot.StyleSet |
getDefaultStyles(int npoint)
Returns a StyleSet which can supply markers.
|
ErrorModeSelectionModel[] |
getErrorModeModels()
Returns the models for selecting error modes.
|
JMenu |
getExportMenu()
Returns the menu which contains export actions.
|
JComponent |
getExtrasPanel()
Returns a panel into which additional window-specific control
components can be added.
|
ToggleButtonModel[] |
getFlipModels()
Returns an array of button models representing the inversion state
for each axis.
|
ToggleButtonModel |
getGridModel()
Returns the button model used to select whether a grid will be
drawn or not.
|
ToggleButtonModel |
getLegendModel()
Returns the model which indicates whether the legend is visible or not.
|
ToggleButtonModel[] |
getLogModels()
Returns an array of button models representing the log/linear state
for each axis.
|
int |
getMainRangeCount()
Returns the number of axes whose ranges can be reset excluding any
auxiliary axes.
|
double |
getPadRatio()
Returns the ratio by which the data ranges calculated by the
GraphicsWindow implememetation of
calculateRanges(uk.ac.starlink.topcat.plot.PointSelection, uk.ac.starlink.topcat.plot.Points, uk.ac.starlink.ttools.plot.PlotState) are
padded. |
uk.ac.starlink.ttools.plot.TablePlot |
getPlot()
Returns the plot object for this window.
|
protected abstract JComponent |
getPlotPanel()
Returns the component containing the graphics output of this
window.
|
uk.ac.starlink.ttools.plot.PlotState |
getPlotState()
Returns an object which characterises the choices the user has
made in the GUI to indicate the plot that s/he wants to see.
|
Points |
getPoints()
Returns the most recently read Points object.
|
PointSelectorSet |
getPointSelectors()
Returns the PointSelectorSet component used by this window.
|
JToolBar |
getPointSelectorToolBar()
Returns the toolbar used for controls specific to the PointSelector
component.
|
Action |
getReplotAction()
Returns an action which can be used to force a replot of the plot.
|
protected GraphicsWindow.ReplotListener |
getReplotListener()
Returns a listener which will perform a replot when any event occurs.
|
Action |
getRescaleAction()
Returns an action which will recalculate data ranges, clear
view ranges, and replot the data.
|
static uk.ac.starlink.ttools.plot.StyleSet[] |
getStandardMarkStyleSets()
Returns an array of StyleSets which dispense
MarkStyle objects,
suitable for general purpose scatter plots. |
Box |
getStatusBox()
Returns a line suitable for putting status information into.
|
MutableStyleSet |
getStyles()
Returns a style set suitable for use with a new PointSelector.
|
uk.ac.starlink.ttools.plot.Range[] |
getViewRanges()
Returns an array of ranges which may be set to determine the
actual range of visible data displayed by this plot.
|
int |
getVisibleAuxAxisCount()
Returns the number of currently visible auxiliary axes for this window.
|
protected void |
init()
Perform initialisation which can't be done in the constructor
(typically because it calls potentially overridden methods).
|
protected boolean |
isLegendInteresting(uk.ac.starlink.ttools.plot.PlotState state)
Indicates whether the legend is worth showing for a given plot state.
|
void |
replot()
Redraws the plot if any of the characteristics indicated by the
currently-requested plot state have changed since the last time
it was done.
|
void |
setGuidePointCount(int npoint)
Provides a hint to this window how many points it's likely to be
plotting.
|
void |
setMainTable(TopcatModel tcModel)
Sets the main table in the point selector component.
|
void |
setPadRatio(double pad)
Sets the ratio by which the data ranges calculated by the
GraphicsWindow implementation of
calculateRanges(uk.ac.starlink.topcat.plot.PointSelection, uk.ac.starlink.topcat.plot.Points, uk.ac.starlink.ttools.plot.PlotState) are
padded. |
void |
setStyles(uk.ac.starlink.ttools.plot.StyleSet styleSet)
Sets the style set to use for this window.
|
void |
setVisible(boolean visible) |
addHelp, beep, confirm, createImportTableAction, createSaveTableAction, getBodyPanel, getControlPanel, getHelpMenu, getIconImage, getMainArea, getSponsorLogos, getToolBar, getWindowMenu, makeTitledBorder, makeVisible, placeProgressBar, positionAfter, recursiveSetEnabled, setBusy, setCloseIsExit, setMainHeading
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, show, toBack, toFront
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getFont, postEvent
public GraphicsWindow(String viewName, uk.ac.starlink.ttools.plot.TablePlot plot, String[] axisNames, int naux, boolean hasLabels, ErrorModeSelectionModel[] errorModeModels, Component parent)
axisNames
array, which also defines the dimensionality.
The naux
variable gives a maximum number of auxiliary
axes which will be managed by this window - these give extra
dimensions which can be mapped to, for instance, colour changes in
plotted points. If no auxiliary axes are required, supply
naux=0
.viewName
- name of the view windowplot
- component which draws the plotaxisNames
- array of labels by which each main axis is knownnaux
- number of auxiliary axeserrorModeModels
- array of selecction models for error modesparent
- parent window - may be used for positioningpublic void setVisible(boolean visible)
setVisible
in class AuxWindow
protected void init()
public JComponent getExtrasPanel()
public int getMainRangeCount()
public void setGuidePointCount(int npoint)
npoint
- approximate number of data points that may be plottedpublic void setPadRatio(double pad)
calculateRanges(uk.ac.starlink.topcat.plot.PointSelection, uk.ac.starlink.topcat.plot.Points, uk.ac.starlink.ttools.plot.PlotState)
are
padded.pad
- padding ratio (typically a few percent)public double getPadRatio()
calculateRanges(uk.ac.starlink.topcat.plot.PointSelection, uk.ac.starlink.topcat.plot.Points, uk.ac.starlink.ttools.plot.PlotState)
are
padded.public JToolBar getPointSelectorToolBar()
public JMenu getExportMenu()
public JMenu createMarkerStyleMenu(uk.ac.starlink.ttools.plot.StyleSet[] styleSets)
styleSets
- style sets to be presented in the menupublic JMenu createErrorModeMenu()
public JMenu createErrorRendererMenu(uk.ac.starlink.ttools.plot.ErrorRenderer[] renderers)
renderers
- full list of renderers which may be used to
draw errorspublic PointSelectorSet getPointSelectors()
public uk.ac.starlink.ttools.plot.Range[] getDataRanges()
calculateRanges(uk.ac.starlink.topcat.plot.PointSelection, uk.ac.starlink.topcat.plot.Points, uk.ac.starlink.ttools.plot.PlotState)
,
which probably occurred during the last data read or rescale
operation. They describe the natural ranges of the data,
which typically means that they defibe an N-dimensional region
into which all the current data points fall.public uk.ac.starlink.ttools.plot.Range[] getViewRanges()
getDataRanges()
. The actual range of visible data will
generally be got by combining the data range with the visible
range on each axis. Elements of the returned array may have
their states altered, but should not be replaced, since
these elements are kept up to date by the editors in the axis window.public ToggleButtonModel[] getFlipModels()
public ToggleButtonModel[] getLogModels()
public ErrorModeSelectionModel[] getErrorModeModels()
public ToggleButtonModel getLegendModel()
public Points getPoints()
public Box getStatusBox()
public int getAuxAxisCount()
public int getVisibleAuxAxisCount()
public uk.ac.starlink.ttools.plot.TablePlot getPlot()
protected abstract JComponent getPlotPanel()
protected void doReplot(uk.ac.starlink.ttools.plot.PlotState state)
state
- plot state determining details of plot configurationprotected PointSelector createPointSelector()
protected AxesSelector addExtraAxes(AxesSelector axsel)
axsel
object.
This method is called by GraphicsWindow
's implementation
of createPointSelector()
.
axsel
- basic axes selectorprotected abstract StyleEditor createStyleEditor()
public abstract uk.ac.starlink.ttools.plot.StyleSet getDefaultStyles(int npoint)
npoint
may be used as a hint for how many
points are expected to be drawn with it.npoint
- approximate number of points - use -1 for unknownpublic void setStyles(uk.ac.starlink.ttools.plot.StyleSet styleSet)
styleSet
- new style setpublic MutableStyleSet getStyles()
setStyles(uk.ac.starlink.ttools.plot.StyleSet)
,
but it is based on it - it will dispense styles from the same set,
but avoid styles already dispensed to other selectors.protected uk.ac.starlink.ttools.plot.PlotState createPlotState()
getPlotState()
prior to the PlotState configuration done there. Thus if a
subclass wants to provide and configure a particular state
(for instance one of a specialised subclass of PlotState) it can
override this method to do so.
The default implementation just invokes new PlotState()
.public uk.ac.starlink.ttools.plot.PlotState getPlotState()
The GraphicsWindow
implementation of this method
as well as populating the state with standard information
also calls PointSelection.readPoints(javax.swing.BoundedRangeModel)
and calculateRanges(uk.ac.starlink.topcat.plot.PointSelection, uk.ac.starlink.topcat.plot.Points, uk.ac.starlink.ttools.plot.PlotState)
if necessary.
public ToggleButtonModel getGridModel()
public Action getReplotAction()
public Action getRescaleAction()
public Action getAxisEditAction()
public void setMainTable(TopcatModel tcModel)
tcModel
- new tablepublic void replot()
This method schedules a replot on the event dispatch thread, so it may be called from any thread.
protected boolean isLegendInteresting(uk.ac.starlink.ttools.plot.PlotState state)
state
- plot stateprotected GraphicsWindow.ReplotListener getReplotListener()
public AxisWindow getAxisWindow()
protected void addNewSubsets(BitSet pointsMask)
pointsMask
- bit vector giving included pointspublic uk.ac.starlink.ttools.plot.Range[] calculateRanges(uk.ac.starlink.ttools.plot.PlotData data, uk.ac.starlink.ttools.plot.PlotState state)
getDataRanges()
.data
- point data for the plotstate
- plot statepublic int getColumnIndex(TableColumn tcol)
tcol
- the column whose index is to be foundtcol
in the table modelpublic static ErrorModeSelectionModel[] createErrorModeModels(String[] axisNames)
axisNames
- array of axis namespublic static uk.ac.starlink.ttools.plot.StyleSet[] getStandardMarkStyleSets()
MarkStyle
objects,
suitable for general purpose scatter plots.public static uk.ac.starlink.ttools.plot.StyleSet[] fixDefaultErrorRenderers(uk.ac.starlink.ttools.plot.ErrorRenderer erend, uk.ac.starlink.ttools.plot.StyleSet[] styleSets)
erend
- desired default error rendererstyleSets
- input style set arrayCopyright © 2003-2025 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.