com.threerings.editor.swing
Class BasePropertyEditor

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.samskivert.swing.CollapsiblePanel
                      extended by com.threerings.editor.swing.BasePropertyEditor
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
EditorPanel, ObjectPanel, PropertyEditor, QuaternionPanel, Transform2DPanel, Transform3DPanel, Vector2fPanel, Vector3fPanel

public abstract class BasePropertyEditor
extends CollapsiblePanel
implements ActionListener

Abstract base class for PropertyEditor and EditorPanel.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected static Icon _collapseIcon
          Collapse/expand icons.
protected  EditorContext _ctx
          Provides access to common services.
protected static Icon _expandIcon
          Collapse/expand icons.
protected  JButton _highlight
          The highlight button.
protected  boolean _highlighted
          If the border should be highlighted.
protected static Icon _highlightIcon
          Collapse/expand icons.
protected  MessageManager _msgmgr
          The message manager to use for translations.
protected  MessageBundle _msgs
          The default message bundle.
protected static int BASE_BACKGROUND
          The base background value that we darken to indicate nesting.
protected static int DEFAULT_BACKGROUND
          The default background value.
protected static Dimension PANEL_BUTTON_SIZE
          The size of the panel buttons.
protected static int SHADE_DECREMENT
          The number of units to darken for each shade.
 
Fields inherited from class com.samskivert.swing.CollapsiblePanel
_content, _downIcon, _trigger, _upIcon
 
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
BasePropertyEditor()
           
 
Method Summary
 void actionPerformed(ActionEvent event)
           
 void addChangeListener(ChangeListener listener)
          Adds a listener for change events.
protected  void copyPropertyPath(String path)
          Copies the path of the property under the mouse cursor to the clipboard.
protected  JButton createButton(Icon icon)
          Creates a button with the supplied text.
protected  Color darkenColor(int color, float shades)
           
protected  void fireStateChanged()
          Fires a state changed event.
protected  Color getBackgroundColor(Property[] lineage)
          Returns a background color darkened and colored for this level.
protected  int getColor(String name)
          Returns a label for the supplied name, translating it if a translation exists.
protected  int getColor(String name, MessageBundle msgs, int defaultColor)
          Returns a label for the supplied name, translating it if a translation exists.
protected  int getColor(String name, String bundle, int defaultColor)
          Returns a label for the supplied name, translating it if a translation exists.
protected  Color getDarkerBackground(float shades)
          Returns a background color darkened by the specified number of shades.
 String getLabel(Class<?> type)
          Returns a label for the supplied type.
protected  String getLabel(String name)
          Returns a label for the supplied name, translating it if a translation exists.
protected  String getLabel(String name, MessageBundle msgs)
          Returns a label for the supplied name, translating it if a translation exists.
protected  String getLabel(String name, String bundle)
          Returns a label for the supplied name, translating it if a translation exists.
 String[] getLabels(String[] names)
          Returns an array of labels for the supplied names, translating those that have translations.
 String[] getLabels(String[] names, MessageBundle msgs)
          Returns an array of labels for the supplied names, translating those that have translations.
 String[] getLabels(String[] names, String bundle)
          Returns an array of labels for the supplied names, translating those that have translations.
 String getMousePath()
          Returns the path of the property under the mouse cursor relative to this property.
protected  String getMousePath(Point pt)
          Returns the path of the property under the mouse cursor relative to this property.
protected  int getPropertyColor(Property[] lineage)
           
protected  Icon loadIcon(String name, EditorContext ctx)
          Loads the named icon.
protected  void makeCollapsible(EditorContext ctx, String title)
          Adds the collapsible button to the panel.
 void removeChangeListener(ChangeListener listener)
          Removes a change event listener.
protected  void updateBorder(String title)
          Updates the border.
 
Methods inherited from class com.samskivert.swing.CollapsiblePanel
getContent, isCollapsed, setCollapsed, setGap, setTrigger, setTriggerContainer, setTriggerContainer, setTriggerContainer
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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
 
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

_ctx

protected EditorContext _ctx
Provides access to common services.


_msgmgr

protected MessageManager _msgmgr
The message manager to use for translations.


_msgs

protected MessageBundle _msgs
The default message bundle.


_highlight

protected JButton _highlight
The highlight button.


_highlighted

protected boolean _highlighted
If the border should be highlighted.


_expandIcon

protected static Icon _expandIcon
Collapse/expand icons.


_collapseIcon

protected static Icon _collapseIcon
Collapse/expand icons.


_highlightIcon

protected static Icon _highlightIcon
Collapse/expand icons.


BASE_BACKGROUND

protected static final int BASE_BACKGROUND
The base background value that we darken to indicate nesting.

See Also:
Constant Field Values

DEFAULT_BACKGROUND

protected static final int DEFAULT_BACKGROUND
The default background value.

See Also:
Constant Field Values

SHADE_DECREMENT

protected static final int SHADE_DECREMENT
The number of units to darken for each shade.

See Also:
Constant Field Values

PANEL_BUTTON_SIZE

protected static final Dimension PANEL_BUTTON_SIZE
The size of the panel buttons.

Constructor Detail

BasePropertyEditor

public BasePropertyEditor()
Method Detail

addChangeListener

public void addChangeListener(ChangeListener listener)
Adds a listener for change events.


removeChangeListener

public void removeChangeListener(ChangeListener listener)
Removes a change event listener.


getLabel

public String getLabel(Class<?> type)
Returns a label for the supplied type.


getLabels

public String[] getLabels(String[] names)
Returns an array of labels for the supplied names, translating those that have translations.


getLabels

public String[] getLabels(String[] names,
                          String bundle)
Returns an array of labels for the supplied names, translating those that have translations.


getLabels

public String[] getLabels(String[] names,
                          MessageBundle msgs)
Returns an array of labels for the supplied names, translating those that have translations.


getMousePath

public String getMousePath()
Returns the path of the property under the mouse cursor relative to this property.


actionPerformed

public void actionPerformed(ActionEvent event)
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class CollapsiblePanel

getMousePath

protected String getMousePath(Point pt)
Returns the path of the property under the mouse cursor relative to this property.

Parameters:
pt - the location of the mouse cursor.

getLabel

protected String getLabel(String name)
Returns a label for the supplied name, translating it if a translation exists.


getLabel

protected String getLabel(String name,
                          String bundle)
Returns a label for the supplied name, translating it if a translation exists.


getLabel

protected String getLabel(String name,
                          MessageBundle msgs)
Returns a label for the supplied name, translating it if a translation exists.


fireStateChanged

protected void fireStateChanged()
Fires a state changed event.


makeCollapsible

protected void makeCollapsible(EditorContext ctx,
                               String title)
Adds the collapsible button to the panel.


loadIcon

protected Icon loadIcon(String name,
                        EditorContext ctx)
Loads the named icon.


createButton

protected JButton createButton(Icon icon)
Creates a button with the supplied text.


getColor

protected int getColor(String name)
Returns a label for the supplied name, translating it if a translation exists.


getColor

protected int getColor(String name,
                       String bundle,
                       int defaultColor)
Returns a label for the supplied name, translating it if a translation exists.


getColor

protected int getColor(String name,
                       MessageBundle msgs,
                       int defaultColor)
Returns a label for the supplied name, translating it if a translation exists.


getPropertyColor

protected int getPropertyColor(Property[] lineage)

getDarkerBackground

protected Color getDarkerBackground(float shades)
Returns a background color darkened by the specified number of shades.


getBackgroundColor

protected Color getBackgroundColor(Property[] lineage)
Returns a background color darkened and colored for this level.


darkenColor

protected Color darkenColor(int color,
                            float shades)

copyPropertyPath

protected void copyPropertyPath(String path)
Copies the path of the property under the mouse cursor to the clipboard.


updateBorder

protected void updateBorder(String title)
Updates the border.