# Class SurfacePlot

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
uk.ac.starlink.ttools.plot.TablePlot
uk.ac.starlink.ttools.plot.SurfacePlot

All Implemented Interfaces:
  `ImageObserver, MenuContainer, Printable, Serializable`

Direct Known Subclasses:
  `DensityPlot, Histogram, ScatterPlot`

public abstract class SurfacePlot extends TablePlot implements Printable
Abstract superclass for plot components which display on a `PlotSurface`. Note that the PlotSurface is not specified in the constructor but must be set before any plotting is done. This class mainly handles keeping track of the current state (`PlotState` and `PlotSurface` members). The actual work is done by the `paintComponent` method of concrete subclasses.

The details of the plot are determined by a `PlotState` object which indicates what the plot will look like. Setting these values does not itself trigger a change in the component, they only take effect when `paintComponent(Graphics)` is called (e.g. following a `JComponent.repaint(long, int, int, int, int)` call). The drawing of axes and other decorations is done by a decoupled `PlotSurface` object (bridge pattern).

Since:
  11 Nov 2005
Author:
  Mark Taylor
See Also:
  - Serialized Form

## Nested Class Summary

### Nested classes/interfaces inherited from class JComponent

`JComponent.AccessibleJComponent`

### Nested classes/interfaces inherited from class Container

`Container.AccessibleAWTContainer`

### Nested classes/interfaces inherited from class Component

`Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy`

## Field Summary

### Fields inherited from class JComponent

`listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

### Fields inherited from class Component

`accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

### Fields inherited from interface ImageObserver

`ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

### Fields inherited from interface Printable

`NO_SUCH_PAGE, PAGE_EXISTS`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`SurfacePlot()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Rectangle`
`getPlotBounds()`
Returns the bounds of the actual plot.
`PlotSurface`
`getSurface()`
Returns the plotting surface on which this component displays.
`protected void`
`paintComponent(Graphics g)`
`int`
`print(Graphics g, PageFormat pf, int pageIndex)`
Implements the `Printable` interface.
`void`
`setFont(Font font)`
`void`
`setState(PlotState state)`
Sets the plot state for this plot.
`void`
`setSurface(PlotSurface surface)`
Sets the plotting surface which draws axes and other decorations that form the background to the actual plotted points.

### Methods inherited from class TablePlot

`addPlotListener, calculateBounds, firePlotChangedLater, getState, isVectorContext, removePlotListener`

### Methods inherited from class JComponent

`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, getUI, 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, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI`

### Methods inherited from class Container

`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`

### Methods inherited from class Component

`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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### SurfacePlot

protected SurfacePlot()
Constructor.

## Method Details

### setSurface

public void setSurface(PlotSurface surface)
Sets the plotting surface which draws axes and other decorations that form the background to the actual plotted points. This must be called before the component is drawn.

Parameters:
  `surface` - plotting surface implementation

### getSurface

public PlotSurface getSurface()
Returns the plotting surface on which this component displays.

Returns:
  plotting surface

### getPlotBounds

public Rectangle getPlotBounds()
Description copied from class: `TablePlot`
Returns the bounds of the actual plot. This may be used for visual alignment of some items in the window. It is permissible to return just the bounds of the plot component itself, but alignment of other components (legends) may look better if the bounds of the actual plotting region (for instance, excluding external axis labels) is returned.

Specified by:
  `getPlotBounds` in class `TablePlot`
Returns:
  plot region bounds

### setState

public void setState(PlotState state)
Description copied from class: `TablePlot`
Sets the plot state for this plot. This characterises how the plot will be done next time this component is painted.

Overrides:
  `setState` in class `TablePlot`
Parameters:
  `state` - plot state

### setFont

public void setFont(Font font)

Overrides:
  `setFont` in class `JComponent`

### print

public int print(Graphics g, PageFormat pf, int pageIndex)
Implements the `Printable` interface. At time of writing, this method is not used by TOPCAT, though it could be; in particular it is not used to implement the export to EPS functionality. The code is mostly pinched from SPLAT.

Specified by:
  `print` in interface `Printable`

### paintComponent

protected void paintComponent(Graphics g)

Overrides:
  `paintComponent` in class `JComponent`