adavid.swing
Class LTreeNode

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--adavid.swing.LTreeNode

public class LTreeNode
extends javax.swing.JComponent
implements java.awt.event.MouseListener

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int OFFSET
          graphical information to draw the node (not the cell)
 
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
LTreeNode(LTreeContent object)
          constructor: takes the content of the node ; the node will be displayed with a cell
 
Method Summary
 java.awt.Component add(java.awt.Component c)
          add a component or a node ; this is general and makes this tree structure powerful and flexible
 void addLTreeListener(LTreeListener listener)
          add a listener for this node
 java.awt.Component addSilent(java.awt.Component c)
          same as above but without expand
 void collapse()
          collapse this node and hide its sub nodes
 void delete()
          the node deletes itself if it is not the root
 void expand()
          expands this node and shows its sub nodes
 LTreeNode getParentNode()
          returns the parent node
 java.awt.Dimension getPreferredSize()
          returns the preferred size of this node, which has been computed with the sub nodes if the node is expanded
 void hasChanged()
          important function ; has to be called whenever a node is changed and needs to be updated/displayed
 boolean isExpanded()
          returns true if this node is expanded
 void mouseClicked(java.awt.event.MouseEvent e)
          useless methods of MouseListener
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          collapse or expands if one clicks on the triangle
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paintComponent(java.awt.Graphics g)
          paint this component (node) ; basically paints a triangle if necessary (if there is a content ; the cell is painted by the container function paintComponents(..)
 void removeAllNodes()
          removes all sub nodes attached to this node
 void removeNode(LTreeNode node)
          remove a sub node attached to this node
 void restoreViewport()
          restore the saved view port position
 void saveViewport()
          save the view port of the (maybe) parent viewport this is useful because JScrollPane looses track of the position of the view port
 void setPopup(javax.swing.JPopupMenu popup)
          set the popup of this node
 void unselect()
          unselect his node
 
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, getAccessibleContext, 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, getUIClassID, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateUI
 
Methods inherited from class java.awt.Container
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

OFFSET

public static final int OFFSET
graphical information to draw the node (not the cell)
Constructor Detail

LTreeNode

public LTreeNode(LTreeContent object)
constructor: takes the content of the node ; the node will be displayed with a cell
Method Detail

delete

public void delete()
the node deletes itself if it is not the root

getParentNode

public LTreeNode getParentNode()
returns the parent node

isExpanded

public boolean isExpanded()
returns true if this node is expanded

add

public java.awt.Component add(java.awt.Component c)
add a component or a node ; this is general and makes this tree structure powerful and flexible
Overrides:
add in class java.awt.Container

addSilent

public java.awt.Component addSilent(java.awt.Component c)
same as above but without expand

getPreferredSize

public java.awt.Dimension getPreferredSize()
returns the preferred size of this node, which has been computed with the sub nodes if the node is expanded
Overrides:
getPreferredSize in class javax.swing.JComponent

removeNode

public void removeNode(LTreeNode node)
remove a sub node attached to this node

removeAllNodes

public void removeAllNodes()
removes all sub nodes attached to this node

expand

public void expand()
expands this node and shows its sub nodes

collapse

public void collapse()
collapse this node and hide its sub nodes

saveViewport

public void saveViewport()
save the view port of the (maybe) parent viewport this is useful because JScrollPane looses track of the position of the view port

restoreViewport

public void restoreViewport()
restore the saved view port position

hasChanged

public void hasChanged()
important function ; has to be called whenever a node is changed and needs to be updated/displayed

paintComponent

public void paintComponent(java.awt.Graphics g)
paint this component (node) ; basically paints a triangle if necessary (if there is a content ; the cell is painted by the container function paintComponents(..)
Overrides:
paintComponent in class javax.swing.JComponent

setPopup

public void setPopup(javax.swing.JPopupMenu popup)
set the popup of this node

addLTreeListener

public void addLTreeListener(LTreeListener listener)
add a listener for this node

unselect

public void unselect()
unselect his node

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
collapse or expands if one clicks on the triangle
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
useless methods of MouseListener
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener