Class NodeAndLinkAnimatingJPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--DrawingJPanel
                                |
                                +--NodeAndLinkAnimatingJPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.awt.event.ComponentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class NodeAndLinkAnimatingJPanel
extends DrawingJPanel
implements java.awt.event.ActionListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int DEFAULT_DELAY
          The default delay for animation (90).
 
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
NodeAndLinkAnimatingJPanel()
          Sole Constructor for the JPanel that paints the node using the AnimatingTree drawNode method.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Listens to action events.
protected  void animate(java.awt.Graphics2D g2)
          Method actually called to complete the drawing of the panel.
 void drawLines(java.awt.Graphics2D g2)
          Draws the lines in the given panel using the Graphics2D.
 DrawingTree getAnimatingNode()
          Gets the head of the tree currently drawn in the Panel.
protected  javax.swing.Timer getAnimationTimer()
          Gets the animation timer for the animation of the panel.
 java.awt.Paint getLeftLinePaint()
          Gets the paint for the left line drawing.
 java.awt.Paint getRightLinePaint()
          Gets the paint for the right line drawing.
 boolean isDrawingLines()
          Gets whether the animation is drawing lines or a node.
protected  void makeDrawTreeGraphics()
          Makes the drawing graphics.
 void paintComponent(java.awt.Graphics g)
          Overides paintComponenet and is called whenever the Panel needs to be painted.
 void setAnimatingNode(DrawingTree animatingNode)
          Set the node for drawing.
protected  void setAnimationTimer(javax.swing.Timer animationTimer)
          Sets the animation timer for the animation of the panel.
 void setComponentShown(boolean componentShown)
          Sets whether the tree is shown or not.
 void setDelayRate(int t)
          Sets the delay rate for the timer for the animation.
 void setDrawingLines(boolean drawingLines)
          Sets whether the animation is drawing lines or a node.
 void setLeftLinePaint(java.awt.Paint leftLinePaint)
          Sets the paint for the left line drawing.
 void setRightLinePaint(java.awt.Paint rightLinePaint)
          Sets the paint for the right line drawing.
 
Methods inherited from class DrawingJPanel
componentHidden, componentMoved, componentResized, componentShown, draw, drawTree, getDrawingArea, getDrawTreeGraphics, getDrawTreeImage, isComponentShown, isDrawTree, makeDrawTreeImage, setDrawingArea, setDrawTree, setDrawTreeGraphics, setDrawTreeImage
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, paint, paintBorder, paintChildren, 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, imageUpdate, 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

DEFAULT_DELAY

public static final int DEFAULT_DELAY
The default delay for animation (90).

See Also:
Constant Field Values
Constructor Detail

NodeAndLinkAnimatingJPanel

public NodeAndLinkAnimatingJPanel()
Sole Constructor for the JPanel that paints the node using the AnimatingTree drawNode method. The JPanel only makes a new image on a resize and otherwise, double-buffers the graphics by leaving the image unmodified.

Method Detail

isDrawingLines

public boolean isDrawingLines()
Gets whether the animation is drawing lines or a node. If the panel is drawing lines, returns true.

Returns:
true if the panel is drawing lines.

getAnimatingNode

public DrawingTree getAnimatingNode()
Gets the head of the tree currently drawn in the Panel.

Returns:
TreeHead the tree head.

getAnimationTimer

protected javax.swing.Timer getAnimationTimer()
Gets the animation timer for the animation of the panel.

Returns:
javax.swing.Timer defining the steps of animation.

getRightLinePaint

public java.awt.Paint getRightLinePaint()
Gets the paint for the right line drawing.

Returns:
Paint right Line Paint.

getLeftLinePaint

public java.awt.Paint getLeftLinePaint()
Gets the paint for the left line drawing.

Returns:
Paint left Line Paint.

setDrawingLines

public void setDrawingLines(boolean drawingLines)
Sets whether the animation is drawing lines or a node. If the panel is drawing lines, sets true.

Parameters:
drawingLines - true if the panel is drawing lines.

setRightLinePaint

public void setRightLinePaint(java.awt.Paint rightLinePaint)
Sets the paint for the right line drawing.

Parameters:
rightLinePaint - right Line Paint.

setLeftLinePaint

public void setLeftLinePaint(java.awt.Paint leftLinePaint)
Sets the paint for the left line drawing.

Parameters:
leftLinePaint - left Line Paint.

setDelayRate

public void setDelayRate(int t)
Sets the delay rate for the timer for the animation. param t int delay rate.


setAnimationTimer

protected void setAnimationTimer(javax.swing.Timer animationTimer)
Sets the animation timer for the animation of the panel.

Parameters:
animationTimer - javax.swing.Timer defining the steps of animation.

setAnimatingNode

public void setAnimatingNode(DrawingTree animatingNode)
Set the node for drawing. This method should be called for each change in node.


setComponentShown

public void setComponentShown(boolean componentShown)
Sets whether the tree is shown or not.

Overrides:
setComponentShown in class DrawingJPanel
Parameters:
componentShown - boolean flag as to whether the tree is shown.

makeDrawTreeGraphics

protected void makeDrawTreeGraphics()
Makes the drawing graphics. Uses the image made from makeDrawTreeImage. This is overiden, to remake the transforms.

Overrides:
makeDrawTreeGraphics in class DrawingJPanel

animate

protected void animate(java.awt.Graphics2D g2)
Method actually called to complete the drawing of the panel. The node is animated to fill the entire graphics given within the panel.

Parameters:
g2 - Graphics2D to animate the node within.

drawLines

public void drawLines(java.awt.Graphics2D g2)
Draws the lines in the given panel using the Graphics2D.

Parameters:
g2 - Graphics2D to draw the lines within.

paintComponent

public void paintComponent(java.awt.Graphics g)
Overides paintComponenet and is called whenever the Panel needs to be painted. The painting includes painting the image and then painting the animation (if any).

Overrides:
paintComponent in class DrawingJPanel
Parameters:
g - Graphics to which the component is drawn.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Listens to action events.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - ActionEvent that contains information about the tree.