cytoscape.visual.ui
Class ValueDisplayer
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JButton
cytoscape.visual.ui.ValueDisplayer
- All Implemented Interfaces:
- ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants
public class ValueDisplayer
- extends JButton
Given an Object, figures out the class of the object and creates a JButton
suitable for displaying the value of that object. When the button is
pressed, it should pop up a user interface to change the value.
The class interested in the selection of the ValueDisplayer should add
an ItemListener to the button. The ItemListener is triggered when the user's
selection changes.
- See Also:
- Serialized Form
Field Summary |
static byte |
ARROW
Display and get input for an arrowhead |
static byte |
COLOR
Display and get input for a color |
protected byte |
dispType
Holds the type of UI this ValueDisplayer will pop up. |
static byte |
DOUBLE
Display and get input for a double |
static byte |
FONT
Display and get input for a font |
static DecimalFormat |
formatter
Formatting for numeric types. |
static byte |
INT
Display and get input for an int |
static byte |
LINETYPE
Display and get input for a linetype |
static byte |
NODESHAPE
Display and get input for node shape |
static byte |
STRING
Display and get input for a string |
Fields inherited from class javax.swing.AbstractButton |
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY |
Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Methods inherited from class javax.swing.AbstractButton |
addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, 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, 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, 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 |
formatter
public static DecimalFormat formatter
- Formatting for numeric types.
COLOR
public static final byte COLOR
- Display and get input for a color
- See Also:
- Constant Field Values
LINETYPE
public static final byte LINETYPE
- Display and get input for a linetype
- See Also:
- Constant Field Values
ARROW
public static final byte ARROW
- Display and get input for an arrowhead
- See Also:
- Constant Field Values
STRING
public static final byte STRING
- Display and get input for a string
- See Also:
- Constant Field Values
DOUBLE
public static final byte DOUBLE
- Display and get input for a double
- See Also:
- Constant Field Values
NODESHAPE
public static final byte NODESHAPE
- Display and get input for node shape
- See Also:
- Constant Field Values
INT
public static final byte INT
- Display and get input for an int
- See Also:
- Constant Field Values
FONT
public static final byte FONT
- Display and get input for a font
- See Also:
- Constant Field Values
dispType
protected byte dispType
- Holds the type of UI this ValueDisplayer will pop up.
getSelectedItem
public Object getSelectedItem()
- Provided for convenience.
- Returns:
- User-selected object displayed by this ValueDisplayer
- See Also:
getValue()
getValue
public Object getValue()
- Returns an object representing the user input. The return value is always
an object type. It may be a String, Number, Arrow, LineType, or Byte
depending on what type the ValueDisplayer was initialized with.
- Returns:
- User-selected object displayed by this ValueDisplayer
getInputListener
public ActionListener getInputListener()
- Returns the ActionListener that will pop up the input UI when triggered.
Attach this to a component to trigger input on a click.
getType
public byte getType()
- Returns the type of input this ValueDisplayer displays/gets input for
setEnabled
public void setEnabled(boolean b)
- Set the ValueDisplayer active/inactive.
- Overrides:
setEnabled
in class AbstractButton
- Parameters:
b
- true to enable, false to disable
getDisplayForColor
public static ValueDisplayer getDisplayForColor(JDialog parent,
String title,
Color c)
fireItemSelected
protected void fireItemSelected()
- This method fires the itemListeners. Item listeners are notified only when
a new selection of the underlying value of the ValueDisplayer is made.
Typically this should only be called by listeners that underlie the
internal structure of the ValueDisplayer
setObject
public void setObject(Object o)
throws ClassCastException
- Externally sets the object displayed. Ensure that the class is the same.
Does not fire an itemSelected event.
- Throws:
ClassCastException
- if caller attempts to set an object
different from what was being represented.
getBlankDisplayFor
public static ValueDisplayer getBlankDisplayFor(JDialog parent,
String title,
byte type)
- Get a blank or default display/input pair for a given type of input.
- Parameters:
parent
- The parent dialog for the returned ValueDisplayertitle
- Title to display for input dialogtype
- Type of input, one of COLOR
, LINETYPE
,
NODESHAPE
, ARROW
, STRING
,
DOUBLE
, INT
, FONT
- Returns:
- ValueDisplayer initialized for given input
- Throws:
ClassCastException
- if you didn't pass in a known type
getBlankDisplayFor
public static ValueDisplayer getBlankDisplayFor(JDialog parent,
String title,
Object sampleObj)
- Get a blank or default display/input pair for the given sample object,
which itself is ignored.
- Parameters:
parent
- The parent dialog for the returned ValueDisplayertitle
- Title to display for input dialogo
-
- Returns:
- ValueDisplayer initialized for given input
- Throws:
ClassCastException
- if you didn't pass in a known type
getDisplayFor
public static ValueDisplayer getDisplayFor(JDialog parent,
String title,
Object o)
throws ClassCastException
- Get a display/input pair initialized to a given type of input. If sending
fonts, must send fonts as gotten from
GraphicsEnvrionment
- Parameters:
parent
- The parent dialog for the returned ValueDisplayero
- Object to represent. Should be a Color
,
LineType
, node shape (byte), arrow,
string, or number
- Returns:
- ValueDisplayer displaying the given object and accepting
input for given object
- Throws:
ClassCastException
- if you didn't pass in a known type