org.das2.graph
Class AttachedLabel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.das2.graph.DasCanvasComponent
                  extended by org.das2.graph.AttachedLabel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Cloneable, Editable

public class AttachedLabel
extends DasCanvasComponent
implements java.lang.Cloneable

A canvas component for labeling things that is positioned just outside of a row,column box.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.das2.graph.DasCanvasComponent
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  java.lang.String axisLabel
           
static int BOTTOM
          This value indicates that the axis should be located at the bottom of its cell
static int HORIZONTAL
          This value indicates that the axis should be oriented horizontally
static int LEFT
          This value indicates that the axis should be located to the left of its cell
static int RIGHT
          This value indicateds that the axis should be located to the right of its cell
static int TOP
          This value indicates that the axis should be located at the top of its cell
static int VERTICAL
          This value indicates that the axis should be oriented vertically
 
Fields inherited from class org.das2.graph.DasCanvasComponent
mouseAdapter, 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
AttachedLabel(java.lang.String label, int orientation, double emOffset)
          constructs an AttachedLabel.
 
Method Summary
 java.lang.Object clone()
          clones the component
 java.awt.Shape getActiveRegion()
          returns the active region of the canvas component, which is not necessarily the bounds.
 int getDevicePosition()
          Deprecated. It's not clear how this should be used, and it does not appear to be used within dasCore and dasApps.
 int getDLength()
           
 double getEmOffset()
          Getter for property emOffset.
 java.lang.String getLabel()
          Accessor method for the title property of this axis.
protected  java.awt.Rectangle getLabelBounds()
          get the Rectangle precisely enclosing the label.
 java.awt.Font getLabelFont()
          get the current font of the compoennt.
 int getOrientation()
          return orientation int
protected  int getTitlePositionOffset()
          calculates the distance from the box to the label.
 boolean isHorizontal()
          true if the label is horizontal
protected static java.lang.String orientationToString(int i)
          return a string for the int orientation encoding.
protected  void paintComponent(java.awt.Graphics graphics)
          paints the axis component.
protected  void paintHorizontalLabel(java.awt.Graphics2D g)
          Paint the axis if it is horizontal
protected  void paintVerticalLabel(java.awt.Graphics2D g)
          Paint the axis if it is vertical
protected static int parseOrientationString(java.lang.String orientationString)
           
 void resize()
          revalidate component after resize.
 void setEmOffset(double emOffset)
          Setter for property emOffset.
 void setLabel(java.lang.String t)
          Mutator method for the title property of this axis.
 void setLabelFont(java.awt.Font labelFont)
          set the font of the label.
 void setOrientation(int orientation)
          Sets the side of the row,column box to locate the label.
 
Methods inherited from class org.das2.graph.DasCanvasComponent
acceptContext, addMouseModule, coalesceEvents, getActions, getCanvas, getColumn, getDasMouseInputAdapter, getDasName, getEmSize, getFont, getMouseAdapter, getRow, installComponent, processDasUpdateEvent, processEvent, removeMouseModule, setBounds, setBounds, setColumn, setDasMouseInputAdapter, setDasName, setRow, showProperties, toString, uninstallComponent, update, updateImmediately
 
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, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOP

public static final int TOP
This value indicates that the axis should be located at the top of its cell

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
This value indicates that the axis should be located at the bottom of its cell

See Also:
Constant Field Values

LEFT

public static final int LEFT
This value indicates that the axis should be located to the left of its cell

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
This value indicateds that the axis should be located to the right of its cell

See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
This value indicates that the axis should be oriented horizontally

See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
This value indicates that the axis should be oriented vertically

See Also:
Constant Field Values

axisLabel

protected java.lang.String axisLabel
Constructor Detail

AttachedLabel

public AttachedLabel(java.lang.String label,
                     int orientation,
                     double emOffset)
constructs an AttachedLabel.

Parameters:
label - The granny string to be displayed.
orientation - identifies the side of the box. See TOP, BOTTOM, LEFT, RIGHT.
emOffset - The offset from the edge of the box to the label, in "ems"-- the roughly the width of a letter "M," and more precisely the size of the current font.
Method Detail

setOrientation

public void setOrientation(int orientation)
Sets the side of the row,column box to locate the label.

Parameters:
orientation - should be one of AttachedLabel.TOP, AttachedLabel.BOTTOM, AttachedLabel.LEFT, AttachedLabel.RIGHT

setLabel

public void setLabel(java.lang.String t)
Mutator method for the title property of this axis. The title for this axis is displayed below the ticks for horizontal axes or to left of the ticks for vertical axes.

Parameters:
t - The new title for this axis

getLabel

public java.lang.String getLabel()
Accessor method for the title property of this axis.

Returns:
A String instance that contains the title displayed for this axis, or null if the axis has no title.

getDevicePosition

public final int getDevicePosition()
Deprecated. It's not clear how this should be used, and it does not appear to be used within dasCore and dasApps.

Returns:
the pixel position of the label.

getDLength

public int getDLength()
Returns:
returns the length in pixels of the axis.

paintComponent

protected void paintComponent(java.awt.Graphics graphics)
paints the axis component. The tickV's and bounds should be calculated at this point

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
graphics -

paintHorizontalLabel

protected void paintHorizontalLabel(java.awt.Graphics2D g)
Paint the axis if it is horizontal


paintVerticalLabel

protected void paintVerticalLabel(java.awt.Graphics2D g)
Paint the axis if it is vertical


getTitlePositionOffset

protected int getTitlePositionOffset()
calculates the distance from the box to the label.

Returns:
integer distance in pixels.

getLabelFont

public java.awt.Font getLabelFont()
get the current font of the compoennt.

Returns:
Font of the component.

setLabelFont

public void setLabelFont(java.awt.Font labelFont)
set the font of the label.

Parameters:
labelFont - Font for the component. Currently this is ignored.

clone

public java.lang.Object clone()
clones the component

Overrides:
clone in class java.lang.Object
Returns:
clone of this.

resize

public void resize()
revalidate component after resize.

Overrides:
resize in class DasCanvasComponent

getLabelBounds

protected java.awt.Rectangle getLabelBounds()
get the Rectangle precisely enclosing the label.

Returns:
Rectangle in canvas space.

getOrientation

public int getOrientation()
return orientation int

Returns:
AttachedLabel.TOP, etc.

isHorizontal

public boolean isHorizontal()
true if the label is horizontal

Returns:
true if the label is horizontal

orientationToString

protected static java.lang.String orientationToString(int i)
return a string for the int orientation encoding.

Parameters:
i -
Returns:
"top", "right", etc.

parseOrientationString

protected static int parseOrientationString(java.lang.String orientationString)
Parameters:
orientationString - left, right, horizontal, etc.
Returns:
the int encoding for the orientation parameter,

getActiveRegion

public java.awt.Shape getActiveRegion()
Description copied from class: DasCanvasComponent
returns the active region of the canvas component, which is not necessarily the bounds.

Overrides:
getActiveRegion in class DasCanvasComponent
Returns:
the bounds of the label

getEmOffset

public double getEmOffset()
Getter for property emOffset.

Returns:
Value of property emOffset.

setEmOffset

public void setEmOffset(double emOffset)
Setter for property emOffset.

Parameters:
emOffset - New value of property emOffset.