EDU.ksu.cis.viewer
Class TreeComponent

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--EDU.ksu.cis.viewer.TreeComponent

public class TreeComponent
extends JPanel

A component displaying a graphical representation of a tree. TreeComponents can be constructed quickly from TreeDrawings. The actual rendering is done by the underlying TreeDrawing. The preferred size is determined automatically, so that calls to setPrefferedSize have no effect. Because this component should not have children, no children are rendered, even if they are added. The colors of the drawing are determined by the underlying TreeDrawing, so the foreground color is unused.

Author:
Rod Howell (howell@cis.ksu.edu)
See Also:
TreeDrawing, Serialized Form

Inner classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
static Font DEFAULT_FONT
          The default Font.
 
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
 
Constructor Summary
TreeComponent(TreeDrawing tree)
          Constructs a new TreeComponent displaying the given TreeDrawing using the default font.
TreeComponent(TreeDrawing tree, Font fnt)
          Constructs a new TreeComponent displaying the given TreeDrawing using the given Font.
 
Method Summary
 Dimension getPreferredSize()
          Returns the preferred size of this component.
protected  void paintChildren(Graphics g)
          As this component should have no children, this method does nothing.
protected  void paintComponent(Graphics g)
          Paints this component on the given graphics context.
 
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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, 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, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, 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, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, 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

DEFAULT_FONT

public static final Font DEFAULT_FONT
The default Font.
Constructor Detail

TreeComponent

public TreeComponent(TreeDrawing tree)
              throws NullPointerException
Constructs a new TreeComponent displaying the given TreeDrawing using the default font.
Throws:
NullPointerException - if tree is null

TreeComponent

public TreeComponent(TreeDrawing tree,
                     Font fnt)
              throws NullPointerException
Constructs a new TreeComponent displaying the given TreeDrawing using the given Font.
Throws:
NullPointerException - if either argument is null
Method Detail

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of this component. This value is based solely on the underlying TreeDrawing and the component's current font. Any value set using setPreferredSize is ignored.
Overrides:
getPreferredSize in class JComponent
Returns:
the preferred size of the drawing

paintComponent

protected void paintComponent(Graphics g)
Paints this component on the given graphics context.
Overrides:
paintComponent in class JComponent
Parameters:
g - The graphics context to use for painting.

paintChildren

protected void paintChildren(Graphics g)
As this component should have no children, this method does nothing.
Overrides:
paintChildren in class JComponent