org.gjt.universe.gui.tree
Class TVRenderer

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JLabel
                          |
                          +--org.gjt.universe.gui.tree.TVRenderer
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants, javax.swing.tree.TreeCellRenderer

public class TVRenderer
extends javax.swing.JLabel
implements javax.swing.tree.TreeCellRenderer

See Also:
Serialized Form

Field Summary
protected static java.lang.String[] colorMap
           
protected static int currentTurn
           
static java.lang.String DKGRAY
           
static java.lang.String GRAY
           
static java.lang.String GREEN
           
protected  boolean hasFocus
           
static java.awt.Color HIDDEN_COLOR
           
static java.lang.String I_NOTE
           
static java.lang.String I_ORDERS
           
static java.lang.String I_UNKNOWN
           
protected static java.util.Hashtable iconTable
           
static java.awt.Color LABEL_COLOR
           
static java.lang.String LTGRAY
           
protected static java.lang.String[] nameMap
           
static java.lang.String RED
           
protected  java.lang.StringBuffer sb
           
protected  java.lang.StringBuffer sb2
           
protected static java.lang.StringBuffer sbTemp
           
protected  boolean selected
           
protected  int treeType
           
static java.lang.String WHITE
           
static java.lang.String YELLOW
           
 
Fields inherited from class javax.swing.JLabel
labelFor
 
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.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TVRenderer()
          Create the Renderer for the TreeViewer.
 
Method Summary
static java.lang.String colorToHex(java.awt.Color c)
          Converts a color to a 6-digit RGB hex.
protected static void createIconTable()
          Creates the table of icons which are used during rendering
protected static javax.swing.ImageIcon getIcon(java.lang.String name)
          Get an icon from the icon table.
static java.lang.String[] getPlayerColorMap()
          Returns data set by setPlayerNameMap(); really should only be called by TreeViewer
static java.lang.String[] getPlayerNameMap()
          Returns data set by setPlayerNameMap(); really should only be called by TreeViewer
 java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree, java.lang.Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
          The main rendering code, as defined by the interface TreeCellRenderer.
protected  java.lang.String makeSimpleText(TVData data)
          This makes a label without the fancy coloring and other options like bold/italics/whatever.
protected  java.lang.String makeTipText(java.lang.String in)
          Convert tabs & newlines that may be in annotations into HTML acceptable text for use in tooltips.
protected static java.lang.String mapIDToOwner(boolean useColor, int ownerID)
          Maps a user id to a name; appends color information if useColor is true.
 void paint(java.awt.Graphics g)
          This paints the focus-box and highlites (selected) box.
static void setCurrentTurn(int value)
          Set the current turn; used for computing how out-of-date data is.
static void setMapping(java.lang.String[] names, java.awt.Color[] colors)
          Map Names & Colors to an index.
 void setModelType(int type)
          Sets the model type; should only be called by TreeViewer.
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

I_NOTE

public static final java.lang.String I_NOTE
See Also:
Constant Field Values

I_UNKNOWN

public static final java.lang.String I_UNKNOWN
See Also:
Constant Field Values

I_ORDERS

public static final java.lang.String I_ORDERS
See Also:
Constant Field Values

GREEN

public static final java.lang.String GREEN
See Also:
Constant Field Values

RED

public static final java.lang.String RED
See Also:
Constant Field Values

YELLOW

public static final java.lang.String YELLOW
See Also:
Constant Field Values

DKGRAY

public static final java.lang.String DKGRAY
See Also:
Constant Field Values

GRAY

public static final java.lang.String GRAY
See Also:
Constant Field Values

LTGRAY

public static final java.lang.String LTGRAY
See Also:
Constant Field Values

WHITE

public static final java.lang.String WHITE
See Also:
Constant Field Values

LABEL_COLOR

public static final java.awt.Color LABEL_COLOR

HIDDEN_COLOR

public static final java.awt.Color HIDDEN_COLOR

iconTable

protected static java.util.Hashtable iconTable

currentTurn

protected static int currentTurn

nameMap

protected static java.lang.String[] nameMap

colorMap

protected static java.lang.String[] colorMap

sbTemp

protected static java.lang.StringBuffer sbTemp

treeType

protected int treeType

selected

protected boolean selected

hasFocus

protected boolean hasFocus

sb

protected java.lang.StringBuffer sb

sb2

protected java.lang.StringBuffer sb2
Constructor Detail

TVRenderer

public TVRenderer()
Create the Renderer for the TreeViewer.

Method Detail

setCurrentTurn

public static void setCurrentTurn(int value)
Set the current turn; used for computing how out-of-date data is. This method should really only be called by TreeViewer.


setMapping

public static void setMapping(java.lang.String[] names,
                              java.awt.Color[] colors)
Map Names & Colors to an index. This method should really only be called by TreeViewer.

Parameters:
names - Array of player names
colors - Array of player colors (display colors)

getPlayerNameMap

public static java.lang.String[] getPlayerNameMap()
Returns data set by setPlayerNameMap(); really should only be called by TreeViewer

Returns:
String array of player names.

getPlayerColorMap

public static java.lang.String[] getPlayerColorMap()
Returns data set by setPlayerNameMap(); really should only be called by TreeViewer

Returns:
String array of HTML colors

setModelType

public void setModelType(int type)
Sets the model type; should only be called by TreeViewer.

Parameters:
type - The model type, as defined in TVModel

mapIDToOwner

protected static java.lang.String mapIDToOwner(boolean useColor,
                                               int ownerID)
Maps a user id to a name; appends color information if useColor is true.

Parameters:
useColor - append color information if true.
ownerID - the owner id (0 to MaxPlayer-1).

createIconTable

protected static void createIconTable()
Creates the table of icons which are used during rendering


getIcon

protected static javax.swing.ImageIcon getIcon(java.lang.String name)
Get an icon from the icon table.


getTreeCellRendererComponent

public java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree,
                                                       java.lang.Object value,
                                                       boolean sel,
                                                       boolean expanded,
                                                       boolean leaf,
                                                       int row,
                                                       boolean hasFocus)
The main rendering code, as defined by the interface TreeCellRenderer.

Specified by:
getTreeCellRendererComponent in interface javax.swing.tree.TreeCellRenderer

paint

public void paint(java.awt.Graphics g)
This paints the focus-box and highlites (selected) box.

Overrides:
paint in class javax.swing.JComponent

makeTipText

protected java.lang.String makeTipText(java.lang.String in)
Convert tabs & newlines that may be in annotations into HTML acceptable text for use in tooltips.


colorToHex

public static java.lang.String colorToHex(java.awt.Color c)
Converts a color to a 6-digit RGB hex.


makeSimpleText

protected java.lang.String makeSimpleText(TVData data)
This makes a label without the fancy coloring and other options like bold/italics/whatever. This is used for 'filtered' data. We use StringBuffer sb2 since StringBuffer sb is used in the main renderer loop and we don't want to conflict.



Copyright © 2001 Universe Dev Team All Rights Reserved.