torero.gui
Class GrammarTreeCellRenderer

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--torero.gui.GrammarTreeCellRenderer
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable, TreeCellRenderer

public class GrammarTreeCellRenderer
extends JPanel
implements TreeCellRenderer

Cell renderer class used to render GrammarNodes. Used by the JTree to render the treenodes.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
Component.AccessibleAWTComponent
 
Field Summary
protected  Color backgroundNonSelectionColor
          Color to use for the background when the node isn't selected.
protected  Color backgroundSelectionColor
          Color to use for the background when a node is selected.
protected  Color borderSelectionColor
          Color to use for the background when the node isn't selected.
protected  Icon closedIcon
          Icon used to show non-leaf nodes that aren't expanded.
protected  boolean hasFocus
          True if has focus.
protected  Icon leafIcon
          Icon used to show leaf nodes.
protected  Icon openIcon
          Icon used to show non-leaf nodes that are expanded.
protected  boolean selected
          Is the value currently selected.
protected  Color textNonSelectionColor
          Color to use for the foreground for non-selected nodes.
protected  Color textSelectionColor
          Color to use for the foreground for selected nodes.
 
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
GrammarTreeCellRenderer()
          Creates a new GrammarTreeCellRenderer, and does the initialization.
 
Method Summary
 void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
          Not implemented.
 void firePropertyChange(String propertyName, byte oldValue, byte newValue)
          Not implemented.
 void firePropertyChange(String propertyName, char oldValue, char newValue)
          Not implemented.
 void firePropertyChange(String propertyName, double oldValue, double newValue)
          Not implemented.
 void firePropertyChange(String propertyName, float oldValue, float newValue)
          Not implemented.
 void firePropertyChange(String propertyName, int oldValue, int newValue)
          Not implemented.
 void firePropertyChange(String propertyName, long oldValue, long newValue)
          Not implemented.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          Not implemented.
 void firePropertyChange(String propertyName, short oldValue, short newValue)
          Not implemented.
 Color getBackgroundNonSelectionColor()
          Returns the background color to be used for non selected nodes.
 Color getBackgroundSelectionColor()
          Returns the color to use for the background if node is selected.
 Color getBorderSelectionColor()
          Returns the color the border is drawn.
 Dimension getPreferredSize()
          Get the preferred size for the rendered component.
 Color getTextNonSelectionColor()
          Returns the color the text is drawn with when the node isn't selected.
 Color getTextSelectionColor()
          Returns the color the text is drawn with when the node is selected.
 Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean focus)
          Renders the node value and returns a rendered component which can be put on a rendererPane.
 void repaint(long tm, int x, int y, int width, int height)
          Not implemented.
 void repaint(Rectangle r)
          Not implemented.
 void revalidate()
          Overridden for performance reasons.
 void setBackgroundNonSelectionColor(Color newColor)
          Sets the background color to be used for non selected nodes.
 void setBackgroundSelectionColor(Color newColor)
          Sets the color to use for the background if node is selected.
 void setBorderSelectionColor(Color newColor)
          Sets the color to use for the border.
 void setTextNonSelectionColor(Color newColor)
          Sets the color the text is drawn with when the node isn't selected.
 void setTextSelectionColor(Color newColor)
          Sets the color the text is drawn with when the node is selected.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

selected

protected boolean selected
Is the value currently selected.

hasFocus

protected boolean hasFocus
True if has focus.

closedIcon

protected transient Icon closedIcon
Icon used to show non-leaf nodes that aren't expanded.

leafIcon

protected transient Icon leafIcon
Icon used to show leaf nodes.

openIcon

protected transient Icon openIcon
Icon used to show non-leaf nodes that are expanded.

textSelectionColor

protected Color textSelectionColor
Color to use for the foreground for selected nodes.

textNonSelectionColor

protected Color textNonSelectionColor
Color to use for the foreground for non-selected nodes.

backgroundSelectionColor

protected Color backgroundSelectionColor
Color to use for the background when a node is selected.

backgroundNonSelectionColor

protected Color backgroundNonSelectionColor
Color to use for the background when the node isn't selected.

borderSelectionColor

protected Color borderSelectionColor
Color to use for the background when the node isn't selected.
Constructor Detail

GrammarTreeCellRenderer

public GrammarTreeCellRenderer()
Creates a new GrammarTreeCellRenderer, and does the initialization.
Method Detail

getTreeCellRendererComponent

public Component getTreeCellRendererComponent(JTree tree,
                                              Object value,
                                              boolean selected,
                                              boolean expanded,
                                              boolean leaf,
                                              int row,
                                              boolean focus)
Renders the node value and returns a rendered component which can be put on a rendererPane.
Specified by:
getTreeCellRendererComponent in interface TreeCellRenderer
Parameters:
tree - the tree for which the node should be rendered.
value - must be of type GrammarNode, otherwise a ClassCastException is thrown.
selected - true if the node is selected
expanded - true if the node is expanded
leaf - true if the node is a leaf
row - ignored (this kind of tree has no "row")
focus - true if the node is focused
Returns:
the rendered component.
See Also:
TreeCellRenderer

getPreferredSize

public Dimension getPreferredSize()
Get the preferred size for the rendered component.
Overrides:
getPreferredSize in class JComponent
Returns:
the preferred size

revalidate

public void revalidate()
Overridden for performance reasons.
Overrides:
revalidate in class JComponent

repaint

public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Not implemented.
Overrides:
repaint in class JComponent

repaint

public void repaint(Rectangle r)
Not implemented.
Overrides:
repaint in class JComponent

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
Not implemented.
Overrides:
firePropertyChange in class JComponent

firePropertyChange

public void firePropertyChange(String propertyName,
                               byte oldValue,
                               byte newValue)
Not implemented.
Overrides:
firePropertyChange in class JComponent

firePropertyChange

public void firePropertyChange(String propertyName,
                               char oldValue,
                               char newValue)
Not implemented.
Overrides:
firePropertyChange in class JComponent

firePropertyChange

public void firePropertyChange(String propertyName,
                               short oldValue,
                               short newValue)
Not implemented.
Overrides:
firePropertyChange in class JComponent

firePropertyChange

public void firePropertyChange(String propertyName,
                               int oldValue,
                               int newValue)
Not implemented.
Overrides:
firePropertyChange in class JComponent

firePropertyChange

public void firePropertyChange(String propertyName,
                               long oldValue,
                               long newValue)
Not implemented.
Overrides:
firePropertyChange in class JComponent

firePropertyChange

public void firePropertyChange(String propertyName,
                               float oldValue,
                               float newValue)
Not implemented.
Overrides:
firePropertyChange in class JComponent

firePropertyChange

public void firePropertyChange(String propertyName,
                               double oldValue,
                               double newValue)
Not implemented.
Overrides:
firePropertyChange in class JComponent

firePropertyChange

public void firePropertyChange(String propertyName,
                               boolean oldValue,
                               boolean newValue)
Not implemented.
Overrides:
firePropertyChange in class JComponent

setTextSelectionColor

public void setTextSelectionColor(Color newColor)
Sets the color the text is drawn with when the node is selected.

getTextSelectionColor

public Color getTextSelectionColor()
Returns the color the text is drawn with when the node is selected.

setTextNonSelectionColor

public void setTextNonSelectionColor(Color newColor)
Sets the color the text is drawn with when the node isn't selected.

getTextNonSelectionColor

public Color getTextNonSelectionColor()
Returns the color the text is drawn with when the node isn't selected.

setBackgroundSelectionColor

public void setBackgroundSelectionColor(Color newColor)
Sets the color to use for the background if node is selected.

getBackgroundSelectionColor

public Color getBackgroundSelectionColor()
Returns the color to use for the background if node is selected.

setBackgroundNonSelectionColor

public void setBackgroundNonSelectionColor(Color newColor)
Sets the background color to be used for non selected nodes.

getBackgroundNonSelectionColor

public Color getBackgroundNonSelectionColor()
Returns the background color to be used for non selected nodes.

setBorderSelectionColor

public void setBorderSelectionColor(Color newColor)
Sets the color to use for the border.

getBorderSelectionColor

public Color getBorderSelectionColor()
Returns the color the border is drawn.