org.das2.graph
Class DasCanvasComponent

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.das2.graph.DasCanvasComponent
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, Editable
Direct Known Subclasses:
Arrow, AttachedLabel, ColumnColumnConnector, DasAnnotation, DasAxis, DasLabel, DasPlot, Legend, RowRowConnector, TimeRangeLabel

public abstract class DasCanvasComponent
extends javax.swing.JComponent
implements Editable

See Also:
Serialized Form

Nested Class Summary
protected static class DasCanvasComponent.CanvasComponentAction
           
 
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
protected  DasMouseInputAdapter mouseAdapter
           
static javax.swing.Action PROPERTIES_ACTION
           
 
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.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DasCanvasComponent()
          constructs a DasCanvasComponent, creating the DasMouseInputAdapter for it and assigning a default name to it.
 
Method Summary
 boolean acceptContext(int x, int y)
          returns true if the component is suitable context for the point.
 void addMouseModule(MouseModule module)
          Add the MouseModule to the list of MouseModules attached to the component via the DasMouseInputAdapter.
protected  java.awt.AWTEvent coalesceEvents(java.awt.AWTEvent existingEvent, java.awt.AWTEvent newEvent)
          Potentially coalesce an event being posted with an existing event.
 javax.swing.Action[] getActions()
           
 java.awt.Shape getActiveRegion()
          returns the active region of the canvas component, which is not necessarily the bounds.
 DasCanvas getCanvas()
          get the DasCanvas which contains this DasCanvasComponent.
 DasColumn getColumn()
          accessor for the DasColumn used for positioning the component.
 DasMouseInputAdapter getDasMouseInputAdapter()
          Getter for property dasMouseInputAdapter, the DasMouseInputAdapter handling mouse input for the component.
 java.lang.String getDasName()
          Get the String identifier for the component which identifies the component within the application.
 double getEmSize()
          convenient method intended to encourage use of em's.
 java.awt.Font getFont()
           
 DasMouseInputAdapter getMouseAdapter()
          Deprecated. use getDasMouseInputAdapter instead
 DasRow getRow()
          accessor for the DasRow used for positioning the component.
protected  void installComponent()
           
protected  void processDasUpdateEvent(DasUpdateEvent e)
           
protected  void processEvent(java.awt.AWTEvent e)
          Processes events occurring on this component.
 void removeMouseModule(MouseModule module)
          Remove the MouseModule from the list of MouseModules attached to the component via the DasMouseInputAdapter.
 void resize()
          Called by the DasCanvas layout manager to request this component to set its bounds.
 void setBounds(int x, int y, int width, int height)
           
 void setBounds(java.awt.Rectangle r)
           
 void setColumn(DasColumn c)
          set the DasColumn for positioning the component horizontally.
 void setDasMouseInputAdapter(DasMouseInputAdapter dasMouseInputAdapter)
          Setter for property dasMouseInputAdapter.
 void setDasName(java.lang.String name)
          Set the String identifier for the component which identifies the component within the application.
 void setRow(DasRow r)
          set the DasRow for positioning the component vertically.
 void showProperties()
          popup the PropertyEditor for editing the state of this component.
 java.lang.String toString()
           
protected  void uninstallComponent()
           
 void update()
          posts an update event on the SystemEventQueue, indicating that work needs to be done to get the get the component back into a valid state.
protected  void updateImmediately()
          This method is called when a DasUpdateEvent is processed.
 
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, paintComponent, 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
 
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, 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, 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, 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, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTIES_ACTION

public static final javax.swing.Action PROPERTIES_ACTION

mouseAdapter

protected DasMouseInputAdapter mouseAdapter
Constructor Detail

DasCanvasComponent

public DasCanvasComponent()
constructs a DasCanvasComponent, creating the DasMouseInputAdapter for it and assigning a default name to it.

Method Detail

addMouseModule

public void addMouseModule(MouseModule module)
Add the MouseModule to the list of MouseModules attached to the component via the DasMouseInputAdapter. MouseModules will appear the in the order that they are added.


removeMouseModule

public void removeMouseModule(MouseModule module)
Remove the MouseModule from the list of MouseModules attached to the component via the DasMouseInputAdapter.


getRow

public DasRow getRow()
accessor for the DasRow used for positioning the component.

Returns:
DasRow used for positioning the component.

getColumn

public DasColumn getColumn()
accessor for the DasColumn used for positioning the component.

Returns:
DasColumn used for positioning the component.

resize

public void resize()
Called by the DasCanvas layout manager to request this component to set its bounds.


setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Overrides:
setBounds in class java.awt.Component

setBounds

public void setBounds(java.awt.Rectangle r)
Overrides:
setBounds in class java.awt.Component

setRow

public void setRow(DasRow r)
set the DasRow for positioning the component vertically. The current row is disconnected, and a propertyChange is fired.


setColumn

public void setColumn(DasColumn c)
set the DasColumn for positioning the component horizontally. The current column is disconnected, and a propertyChange is fired.


showProperties

public void showProperties()
popup the PropertyEditor for editing the state of this component.


toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component
Returns:
a concise String representation of the object.

updateImmediately

protected void updateImmediately()
This method is called when a DasUpdateEvent is processed. The default implementation does nothing. If a subclass needs to do any expensive operations involved in updating, they should be done by overriding this method so that the AWT Event Queue can coalesce update events.


update

public void update()
posts an update event on the SystemEventQueue, indicating that work needs to be done to get the get the component back into a valid state.


processEvent

protected void processEvent(java.awt.AWTEvent e)
Processes events occurring on this component. By default this method calls the appropriate process<event type>Event method for the given class of event.

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Overrides:
processEvent in class java.awt.Container
Parameters:
e - the event
See Also:
Component.processComponentEvent(java.awt.event.ComponentEvent), Component.processFocusEvent(java.awt.event.FocusEvent), Component.processKeyEvent(java.awt.event.KeyEvent), Component.processMouseEvent(java.awt.event.MouseEvent), Component.processMouseMotionEvent(java.awt.event.MouseEvent), Component.processInputMethodEvent(java.awt.event.InputMethodEvent), Component.processHierarchyEvent(java.awt.event.HierarchyEvent), Component.processMouseWheelEvent(java.awt.event.MouseWheelEvent), processDasUpdateEvent(org.das2.event.DasUpdateEvent)

processDasUpdateEvent

protected void processDasUpdateEvent(DasUpdateEvent e)

coalesceEvents

protected java.awt.AWTEvent coalesceEvents(java.awt.AWTEvent existingEvent,
                                           java.awt.AWTEvent newEvent)
Potentially coalesce an event being posted with an existing event. This method is called by EventQueue.postEvent if an event with the same ID as the event to be posted is found in the queue (both events must have this component as their source). This method either returns a coalesced event which replaces the existing event (and the new event is then discarded), or null to indicate that no combining should be done (add the second event to the end of the queue). Either event parameter may be modified and returned, as the other one is discarded unless null is returned.

This implementation of coalesceEvents coalesces DasUpdateEvents, returning the existingEvent parameter

Overrides:
coalesceEvents in class java.awt.Component
Parameters:
existingEvent - the event already on the EventQueue
newEvent - the event being posted to the EventQueue
Returns:
a coalesced event, or null indicating that no coalescing was done

installComponent

protected void installComponent()

uninstallComponent

protected void uninstallComponent()

getFont

public java.awt.Font getFont()
Specified by:
getFont in interface java.awt.MenuContainer
Overrides:
getFont in class java.awt.Component

getEmSize

public double getEmSize()
convenient method intended to encourage use of em's. returns the em size for the canvas. We define the em size as the height of the component's font.

Returns:
the height of the component's font.

getCanvas

public DasCanvas getCanvas()
get the DasCanvas which contains this DasCanvasComponent.

Returns:
the DasCanvas which contains this DasCanvasComponent.

getDasName

public java.lang.String getDasName()
Get the String identifier for the component which identifies the component within the application. This name should be consistent between sessions of an application, where applicable, for persistent state support.

Returns:
the name of the component.

setDasName

public void setDasName(java.lang.String name)
                throws DasNameException
Set the String identifier for the component which identifies the component within the application. This name should be consistent between sessions of an application, where applicable, for persistent state support. For example, "timeAxis1" or "theTimeAxis"

Parameters:
name - unique String identifying the component within the application.
Throws:
DasNameException

getActiveRegion

public java.awt.Shape getActiveRegion()
returns the active region of the canvas component, which is not necessarily the bounds.


acceptContext

public boolean acceptContext(int x,
                             int y)
returns true if the component is suitable context for the point. For example, the operator right-clicks at the point, is this point a transparent region of the component, and accepting context would be confusing to the operator? This was first introduced to support the annotation component, which draws a compact background bubble around a message, which is typically smaller than its bounds, plus an arrow.

Parameters:
x -
y -
Returns:
true if the component accepts the context at this point.

getMouseAdapter

public DasMouseInputAdapter getMouseAdapter()
Deprecated. use getDasMouseInputAdapter instead

accessor to the DasMouseInputAdapter handling mouse input for the component. Note there is also getDasMouseInputAdapter.

Returns:
DasMouseInputAdaptor handling mouse input for the component.

getActions

public javax.swing.Action[] getActions()

getDasMouseInputAdapter

public DasMouseInputAdapter getDasMouseInputAdapter()
Getter for property dasMouseInputAdapter, the DasMouseInputAdapter handling mouse input for the component.

Returns:
Value of property dasMouseInputAdapter.

setDasMouseInputAdapter

public void setDasMouseInputAdapter(DasMouseInputAdapter dasMouseInputAdapter)
Setter for property dasMouseInputAdapter.

Parameters:
dasMouseInputAdapter - New value of property dasMouseInputAdapter.