spv.graphics
Class AbstractSensitiveCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by spv.graphics.GraphicsCanvasDecorator
                  extended by spv.graphics.AbstractSensitiveCanvas
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, GraphicsCanvas, PlottableGraphics
Direct Known Subclasses:
AnnotationCanvas, AxisCanvas, MeasurementCanvas, WCSSettingsCanvas

abstract class AbstractSensitiveCanvas
extends GraphicsCanvasDecorator

Sensitive canvas.

This is an invisibleControls canvas that senses mouse movements and clicks near "sensitive" regions. These are rectangles specified in canvas (Graphics) coordinates. When the mouse is clicked inside such a region, the activate() abstract method is called. It is up to the subclasses to implement specific behavior.

Version:
1.0 - 05Dec02
Author:
Ivo Busko (Space Telescope Science Institute)

Nested Class Summary
protected  class AbstractSensitiveCanvas.CursorIconControl
          This class provides a mouse motion listener that senses when the mouse cursor is inside one of the sensitive regions, and changes the curor icon to a "hand".
protected  class AbstractSensitiveCanvas.MouseControl
          This class capture mouse click events.
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static java.awt.Cursor inside_cursor
           
protected  java.util.ArrayList<java.awt.geom.Rectangle2D> sense_regions
           
 
Fields inherited from class spv.graphics.GraphicsCanvasDecorator
decorated_canvas, decorator, ignore_cursor, printing
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
protected AbstractSensitiveCanvas(GraphicsCanvas graphic_canvas)
          Constructor.
 
Method Summary
protected abstract  void activate(int region)
          This method gets called when the mouse is clicked inside a sensitive region.
protected abstract  void activate(int region, boolean showFields)
           
 void draw(java.awt.Graphics g)
          Performs the drawing operations.
protected  void setSensitiveRegions(java.awt.geom.Rectangle2D[] regions)
          Sets the sensitive regions.
protected  void unsetSensitiveRegions()
          Unsets the sensitive regions.
 
Methods inherited from class spv.graphics.GraphicsCanvasDecorator
addToChart, attachDataSet, attachRange, clearInternalReferences, disableIntegrator, enableIntegrator, eraseMarkers, eraseMarkers, getAnnotations, getAnnotationSets, getAxisType, getBottomBorder, getCanvasViewport, getDataSets, getGraphics2D, getIntegrationRegions, getJComponent, getLeftBorder, getLogarithm, getOriginalObject, getOriginalObjectID, getPlottableObject, getRightBorder, getSystemCursor, getTopBorder, getTransform, getWCSViewport, getXUnits, getYUnits, ignoreCursorEvent, isMeasurementEnabled, isMouseClickEnabled, paintComponent, plot, print, print, removeAnnotation, reset, reset2, setAnnotations, setAnnotationSets, setAxisType, setBorders, setCursorDashPattern, setDecorator, setIntegrationRegions, setLogarithm, setMarkers, setMinimumSizes, setOriginalObject, setOriginalObjectGraphicsID, setOriginalObjectID, setPlottableObject, setSizes, setSystemCursor, setTitles, setWCSViewport, setXAutoLog, setXUnits, setYAutoLog, setYUnits, stopCursorObservation, undoWCSViewport
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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
 
Methods inherited from class java.awt.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, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.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, 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, hide, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inside_cursor

private static final java.awt.Cursor inside_cursor

sense_regions

protected java.util.ArrayList<java.awt.geom.Rectangle2D> sense_regions
Constructor Detail

AbstractSensitiveCanvas

protected AbstractSensitiveCanvas(GraphicsCanvas graphic_canvas)
Constructor.

Parameters:
graphic_canvas - the GraphicsCanvas object to be made sensitive to mouse clicks.
Method Detail

setSensitiveRegions

protected void setSensitiveRegions(java.awt.geom.Rectangle2D[] regions)
Sets the sensitive regions.

Parameters:
regions - the sensitive regions

unsetSensitiveRegions

protected void unsetSensitiveRegions()
Unsets the sensitive regions.


activate

protected abstract void activate(int region)
This method gets called when the mouse is clicked inside a sensitive region.

Parameters:
region - the region to be activated

activate

protected abstract void activate(int region,
                                 boolean showFields)

draw

public void draw(java.awt.Graphics g)
Performs the drawing operations. This method is a no-op since this class does not perform any actual drawing operations (the canvas is invisible...)

Specified by:
draw in interface PlottableGraphics
Specified by:
draw in class GraphicsCanvasDecorator
Parameters:
g - the Graphics context where to draw