net.sourceforge.olduvai.treejuxtaposer
Class AccordionTreeDrawerFinal

java.lang.Object
  extended by net.sourceforge.olduvai.accordiondrawer.AccordionDrawer
      extended by net.sourceforge.olduvai.treejuxtaposer.drawer.AccordionTreeDrawer
          extended by net.sourceforge.olduvai.treejuxtaposer.AccordionTreeDrawerFinal
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.media.opengl.GLEventListener

public class AccordionTreeDrawerFinal
extends AccordionTreeDrawer

A class that implements the abstract methods left in AccordionTreeDrawer, mainly user interface and application-specific hooks for TreeJuxtaposer.

Version:
2.1
Author:
Tamara Munzner, Serdar Tasiran, Li Zhang, Yunhong Zhou, James Slack
See Also:
TreeJuxtaposer, AccordionTreeDrawer, AccordionDrawer

Field Summary
private  int actionmode
          state of interaction: 0, 1, 2, 3, 4, 5, 6, 7, 11
private static int actionmodeDefault
          ActionMode: default to mouseover action
private static int ALL
          BOTH X and Y directions
private static int ALL_GROUPS
          After a user selects 'a' for all groups, keytarget will be set to this value.
private static int DEVELOPER
          Developer mode for keytarget
private  int[] dragEnd
          The X/Y pixel location of a mouse dragging action at it's current position.
private  int[] dragStart
          The X/Y pixel location of a mouse dragging action at the start.
private  int growDirectionDefault
          Growing direction, default to 1
protected static int HORIZ
          HORIZ direction X
protected  boolean jump
          true: do jump cuts, false: use the number default number of steps in each animation
private  int keytarget
          Store previous keystroke if a developer key action happened (".")
private static int keytargetDefault
          Default key target is Mouse over interaction M_ACT in StateFrame
private static int MOUSEOVER
          ActionMode: Base state of cursor interaction, no action buttons pushed, any node that is under the cursor will be highlighted.
private  TreeNode mouseOverNode
          The current 'focus' object under the cursor, a TreeNode.
private static int MOVE_STUCKPOS
          ActionMode: move a stuck line (hidden feature)
private static int NODE
          Mark mode: single node
private static int NONE
          value of NONE for keytarget and actionmode
private  TreeNode pickedNode
          The currently picked node (flash drawing).
private  TreeNode pickedNodeOld
          The previously picked node (flash drawing).
private static int RECT_CREATE
          ActionMode: Mouse drag to create an interaction box
private static int RECT_FREEMOVE
          ActionMode: Mouse movement with active interaction box (no drag)
private static int RECT_FREEMOVEAGAIN
          ActionMode: Mouse movement after dragging the active interaction box (no current drag)
private static int RECT_RESHAPE
          ActionMode: Mouse dragging movement with active interaction box
private  int selectionResolutionDefault
          Mark mode default: 1
private static int ST_FREEMOVE
          ActionMode: Free move state with shift pressed
private static int ST_FREEMOVEAGAIN
          ActionMode: Free move state with shift pressed following a reshape
private static int ST_RESHAPE
          ActionMode: Free move state with shift pressed during a mouse drag event
private static int SUBTREE
          Mark mode: subtree
private  TreeJuxtaposer tj
          The treejuxtaposer object for referencing the program instance that responds to user actions found in this class.
protected static int VERT
          VERT direction Y
 
Fields inherited from class net.sourceforge.olduvai.treejuxtaposer.drawer.AccordionTreeDrawer
countDrawnFrame, countDrawnScene, cumFrameTime, drawnlabelsize, flashLabelBox, fullyQualified, internalDrawCount, labelAtLeaves, labelbuffer, labeloffset, labelPixels, leafDrawCount, lineLength, linePixel, linePos, maxFontHeight, minFontHeight, objectColor, pickFuzz, pixelDiv, popupFontHeight, rootNode, tree
 
Fields inherited from class net.sourceforge.olduvai.accordiondrawer.AccordionDrawer
backgroundColor, backplane, baseBox, basePass, bff, canvas, clearCount, continueFrame, continueStart, debugOutput, defaultFocusCell, DEFAULTFONTFAMILY, DEFAULTLABELFONT, DEFAULTLABELFONTSIZE, DEFAULTTITLEFONT, DEFAULTTITLEFONTSIZE, dequeueChunkPerTimeCheck, dimbrite, dimcolors, doBox, doDoubleBuffer, doingFlash, doublebuffer, drawBackground, drawGeoms, drawGrid, drawlabels, drawnLabels, dumpstats, dynamicStart, dynamicTime, FAR_FROM_STUCK, flashBox, flashBoxOld, flashBoxWidth, flashCol, flashGeom, flashGeomOld, flashX, flashXOld, flashY, flashYOld, focusCell, fontInitialized, forceRedraw, frameNum, gridplane, groupPass, hiliteplane, ignoreProgressive, inflateIncr, interactionplane, key, labelBackColor, labelBackHiColor, labelbgplane, labelColor, labeldrawback, labelHiColor, labelplane, labelposright, linkednav, loaded, MAX_STUCK_X, MAX_STUCK_Y, MIN_STUCK_X, MIN_STUCK_Y, minCellDims, minContextInside, minContextPeriphery, mouseDragging, mouseMoveAnimSteps, mouseMoveAnimStepsNPR, mouseNow, mousePrev, noflash, now, numAnimSteps, numCellsDrawnThisFrame, objplane, rubberbandColor, showdiffs, snapShotExtension, snapshotName, snapShotWriter, splitAxis, startFrame, stats, takeSnapshot, textPass, ToDrawQ, toMove, uniformSplits, winsize, X, Y
 
Constructor Summary
AccordionTreeDrawerFinal(Tree t, int w, int h, TreeJuxtaposer thetj, javax.swing.JProgressBar jpb)
          Constructor for a drawer with defined key and mouse interaction methods, and bindings from the drawer to the TreeJuxtaposer application.
 
Method Summary
 void actionmodeReset()
          Initialize or reset the state of all object state.
private  int closeToStuck()
          Helper function to determine if the cursor is close to a stuck line, within pickFuzz.
protected  void customGLInit(javax.media.opengl.GL gl)
          Stub function.
private  void drawActiveSubtreeBox()
          Make an InteractionBox from the GridCells nearest to the box of the cursor position, and update the view with a flash draw.
private  int findChildNumber(TreeNode parentNode, TreeNode originalNode)
          Find the child index of the originalNode as a child of the parent node
 void flashDown()
          Function to handle a down arrow action by the user.
 void flashLeft()
          Function to handle a left arrow action by the user.
 void flashRight()
          Function to handle a right arrow action by the user.
 void flashUp()
          Function to handle an up arrow action by the user.
 java.util.ArrayList getColorsForCellGeom(CellGeom c)
          Wrapper for TreeJuxtaposer call to TreeJuxtaposer.getColorsForRange(int, int, AccordionTreeDrawer).
 java.util.ArrayList getColorsForRange(int objmin, int objmax)
          Wrapper function for TreeJuxtaposer.getColorsForRange(int, int, AccordionTreeDrawer)
 RangeList getRangeByKey(int key)
          Get the range list (marked group) by the given key
 void keyPressed(java.awt.event.KeyEvent e)
          Capture the press of a key.
 void keyReleased(java.awt.event.KeyEvent e)
          Capture the release of a keystroke.
 void keyTyped(java.awt.event.KeyEvent e)
          Used when hitting a key should trigger an atomic action.
 void mouseClicked(java.awt.event.MouseEvent e)
          Mouse click function, currently not fully supported, but can be used to move stuck positions.
 void mouseDragged(java.awt.event.MouseEvent e)
          Mouse drag function, for updating mouse position events during a mouse press, such as stretching.
 void mouseEntered(java.awt.event.MouseEvent e)
          Mouse entry function.
 void mouseExited(java.awt.event.MouseEvent e)
          Mouse exit function, for when mouse leaves drawing canvas' parent.
 void mouseMoved(java.awt.event.MouseEvent e)
          Mouse movement function, for updating mouse position events, such as highlighting.
private  boolean mouseOutOfWindow(java.awt.event.MouseEvent e)
          Helper to determine if the cursor is out of the canvas.
private  void mouseover(int x, int y)
          Simple cursor location update and picking, called by mouseMoved(MouseEvent).
 void mousePressed(java.awt.event.MouseEvent e)
          Mouse press function, for updating interaction box events, setting up new boxes or stretching a created one.
 void mouseReleased(java.awt.event.MouseEvent e)
          Mouse release function, for updating mouse position events, such as highlighting.
private  void newMouseOver(TreeNode originalNode, TreeNode newNode)
          Called by any of the arrow action functions, to update the drawer with a flash draw.
private  void reshaperectangle(InteractionBox stretchBox, boolean doOther)
          Box stretching function used by mouseDragged(MouseEvent).
private  TreeNode rightAlignFind(TreeNode parentNode, TreeNode originalNode, int originalNodeChildNumber, boolean goingDown)
          Find the right aligned cell that is below (above) the original node, using the parent node as reference.
 void seedQueue()
          Wrapper function for TreeJuxtaposer.seedQueue(AccordionTreeDrawerFinal).
 java.lang.String toString()
          Convert tree into name used by screen shot writer.
 
Methods inherited from class net.sourceforge.olduvai.treejuxtaposer.drawer.AccordionTreeDrawer
addToDrawQueue, decreaseLabelBuffer, decreaseMaxFontHeight, decreaseMinFontHeight, doFlash, drawGeom, drawPostFrame, drawPostScene, drawPreContFrame, drawPreNewFrame, drawRange, drawRange, finalize, flashDraw, getCanvasDrawable, getLabelBuffer, getLeaf, getListOfLeaves, getMaxFontHeight, getMinFontHeight, getNodeByKey, getNodeByName, getObjectColor, getTree, increaseLabelBuffer, increaseMaxFontHeight, increaseMinFontHeight, initCells, makeBox, pickGeom, preDraw, resetSplitValues, setLabelBuffer, setLabelBuffer, setMaxFontHeight, setMinFontHeight, setObjectColor, shutdown
 
Methods inherited from class net.sourceforge.olduvai.accordiondrawer.AccordionDrawer
animatedReset, clear, clearQueue, continueFrame, createBoxFromCells, createBoxFromCells, createRectFromPick, decreaseLineThickness, display, displayChanged, doFrameMove, doSnapshot, drawEnd, drawFrame, drawSplits, drawStart, drawText, endAllTransitions, forceRedraw, getBackgroundColor, getBFF, getCanvas, getDescent, getDimBrite, getDimColors, getDoubleBuffer, getDrawGeoms, getDrawGrid, getDrawLabels, getDrawnLabels, getDumpStats, getFlashBox, getFlashCol, getFrameNum, getGL, gethiliteplane, getInflateIncr, getKey, getLabelBackColor, getLabelBackHiColor, getLabelColor, getLabelDrawBack, getLabelHiColor, getLabelplane, getLabelPosRight, getLineThickness, getLinkedNav, getMinCellDims, getMouseMoveAnimSteps, getNoFlash, getNumAnimSteps, getObjplane, getPixelSize, getRubberbandColor, getSplitAxis, getToDrawQ, getWinMax, getWinsize, increaseLineThickness, incrementFrameNumber, init, initializeFont, initSplitLines, isDoingFlash, keepDrawing, keepMoving, moveStuckPosition, newPixelDiv, newSnapshotName, requestRedraw, reset, resetGridUniform, resetHighlightPlane, resetObjectPlane, reshape, s2w, s2w, s2w, saveScreenShot, setBackgroundColor, setCellHighlight, setClearColor, setColorGL, setColorGLAlpha, setDimBrite, setDimColors, setDoubleBuffer, setDrawGeoms, setDrawGrid, setDrawLabels, setDrawSplits, setDumpStats, setFlash, setFocusCell, setHighlightPlane, setInflateIncr, setKey, setLabelBackColor, setLabelBackHiColor, setLabelColor, setLabelDrawBack, setLabelHiColor, setLabelPosRight, setLineThickness, setLinkedNav, setMinCellDims, setMouseMoveAnimSteps, setNoFlash, setNumAnimSteps, setObjectPlane, setRubberbandColor, startNewFrame, stringWidth, toggleDimBrite, toggleDimColors, toggleDrawGeoms, toggleDrawGrid, toggleDrawLabels, toggleDrawSplits, toggleDumpStats, toggleLabelDrawBack, toggleLabelPosRight, toggleLinkedNav, toggleNoFlash, w2s, whoCalledMe
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tj

private TreeJuxtaposer tj
The treejuxtaposer object for referencing the program instance that responds to user actions found in this class.


dragStart

private int[] dragStart
The X/Y pixel location of a mouse dragging action at the start.


dragEnd

private int[] dragEnd
The X/Y pixel location of a mouse dragging action at it's current position.


mouseOverNode

private TreeNode mouseOverNode
The current 'focus' object under the cursor, a TreeNode.


HORIZ

protected static final int HORIZ
HORIZ direction X

See Also:
Constant Field Values

VERT

protected static final int VERT
VERT direction Y

See Also:
Constant Field Values

ALL

private static final int ALL
BOTH X and Y directions

See Also:
Constant Field Values

growDirectionDefault

private int growDirectionDefault
Growing direction, default to 1


ALL_GROUPS

private static final int ALL_GROUPS
After a user selects 'a' for all groups, keytarget will be set to this value. The next key can be a 'c' for clearing the marks from all groups.

See Also:
Constant Field Values

NODE

private static final int NODE
Mark mode: single node

See Also:
Constant Field Values

SUBTREE

private static final int SUBTREE
Mark mode: subtree

See Also:
Constant Field Values

selectionResolutionDefault

private int selectionResolutionDefault
Mark mode default: 1


keytarget

private int keytarget
Store previous keystroke if a developer key action happened (".")


DEVELOPER

private static final int DEVELOPER
Developer mode for keytarget

See Also:
Constant Field Values

NONE

private static final int NONE
value of NONE for keytarget and actionmode

See Also:
Constant Field Values

keytargetDefault

private static final int keytargetDefault
Default key target is Mouse over interaction M_ACT in StateFrame

See Also:
Constant Field Values

actionmode

private int actionmode
state of interaction: 0, 1, 2, 3, 4, 5, 6, 7, 11


MOUSEOVER

private static final int MOUSEOVER
ActionMode: Base state of cursor interaction, no action buttons pushed, any node that is under the cursor will be highlighted.

See Also:
Constant Field Values

ST_FREEMOVE

private static final int ST_FREEMOVE
ActionMode: Free move state with shift pressed

See Also:
Constant Field Values

ST_FREEMOVEAGAIN

private static final int ST_FREEMOVEAGAIN
ActionMode: Free move state with shift pressed following a reshape

See Also:
Constant Field Values

ST_RESHAPE

private static final int ST_RESHAPE
ActionMode: Free move state with shift pressed during a mouse drag event

See Also:
Constant Field Values

RECT_CREATE

private static final int RECT_CREATE
ActionMode: Mouse drag to create an interaction box

See Also:
Constant Field Values

RECT_FREEMOVE

private static final int RECT_FREEMOVE
ActionMode: Mouse movement with active interaction box (no drag)

See Also:
Constant Field Values

RECT_FREEMOVEAGAIN

private static final int RECT_FREEMOVEAGAIN
ActionMode: Mouse movement after dragging the active interaction box (no current drag)

See Also:
Constant Field Values

RECT_RESHAPE

private static final int RECT_RESHAPE
ActionMode: Mouse dragging movement with active interaction box

See Also:
Constant Field Values

actionmodeDefault

private static final int actionmodeDefault
ActionMode: default to mouseover action

See Also:
Constant Field Values

MOVE_STUCKPOS

private static final int MOVE_STUCKPOS
ActionMode: move a stuck line (hidden feature)

See Also:
Constant Field Values

jump

protected boolean jump
true: do jump cuts, false: use the number default number of steps in each animation


pickedNode

private TreeNode pickedNode
The currently picked node (flash drawing).


pickedNodeOld

private TreeNode pickedNodeOld
The previously picked node (flash drawing).

Constructor Detail

AccordionTreeDrawerFinal

public AccordionTreeDrawerFinal(Tree t,
                                int w,
                                int h,
                                TreeJuxtaposer thetj,
                                javax.swing.JProgressBar jpb)
Constructor for a drawer with defined key and mouse interaction methods, and bindings from the drawer to the TreeJuxtaposer application.

Parameters:
t - Tree for this drawer.
w - width of the canvas in pixels.
h - height of the canvas in pixels.
thetj - TreeJuxtaposer object that uses this drawer.
jpb - Progress bar.
Method Detail

getColorsForRange

public java.util.ArrayList getColorsForRange(int objmin,
                                             int objmax)
Wrapper function for TreeJuxtaposer.getColorsForRange(int, int, AccordionTreeDrawer)

Specified by:
getColorsForRange in class AccordionTreeDrawer
Parameters:
objmin - start of range to get colors for.
objmax - end of range to get colors for.
Returns:
List of java color object that are drawn in the given range. Only the first really matters as that color is the highest priority.

drawActiveSubtreeBox

private void drawActiveSubtreeBox()
Make an InteractionBox from the GridCells nearest to the box of the cursor position, and update the view with a flash draw.


actionmodeReset

public void actionmodeReset()
Initialize or reset the state of all object state. Return all flags to a known stable state, unset all interaction boxes.


mouseover

private void mouseover(int x,
                       int y)
Simple cursor location update and picking, called by mouseMoved(MouseEvent).

Parameters:
x - cursor horizontal position.
y - cursor vertical position.

reshaperectangle

private void reshaperectangle(InteractionBox stretchBox,
                              boolean doOther)
Box stretching function used by mouseDragged(MouseEvent).

Parameters:
stretchBox - Box that is stretching, following a call to InteractionBox.updateDrag(int[]).
doOther - if true, will also stretch interaction boxes in other drawers, for linked navigation.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Mouse entry function. When mouse enters, focus the canvas window, which brings the canvas to the front of other windows.

Parameters:
e - Mouse event object.

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Mouse exit function, for when mouse leaves drawing canvas' parent. When mouse leaves, transfer focus (key events listeners etc) to the new window.

Parameters:
e - Mouse event object.

mouseOutOfWindow

private boolean mouseOutOfWindow(java.awt.event.MouseEvent e)
Helper to determine if the cursor is out of the canvas.

Parameters:
e - Mouse event, for cursor position.
Returns:
true if cursor is outside drawing window.

closeToStuck

private int closeToStuck()
Helper function to determine if the cursor is close to a stuck line, within pickFuzz.

Returns:
enumerated value of state of cursor with respect to the stuck lines.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Mouse click function, currently not fully supported, but can be used to move stuck positions.

Parameters:
e - The mouse click event.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Mouse press function, for updating interaction box events, setting up new boxes or stretching a created one.

Parameters:
e - The mouse event, for updating the interaction box.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Mouse release function, for updating mouse position events, such as highlighting.

Parameters:
e - The mouse event, for updating interaction boxes.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Mouse drag function, for updating mouse position events during a mouse press, such as stretching.

Parameters:
e - The mouse event, for updating positions of interaction boxes.

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Mouse movement function, for updating mouse position events, such as highlighting. Calls mouseover(int, int).

Parameters:
e - The mouse event, for updating the position.

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Used when hitting a key should trigger an atomic action. Alternative is a keyPressed(KeyEvent)/keyReleased(KeyEvent) pair that could be used in conjunction with mouseclicks.


newMouseOver

private void newMouseOver(TreeNode originalNode,
                          TreeNode newNode)
Called by any of the arrow action functions, to update the drawer with a flash draw.

Parameters:
originalNode - Starting tree node.
newNode - New tree node to highlight.

findChildNumber

private int findChildNumber(TreeNode parentNode,
                            TreeNode originalNode)
Find the child index of the originalNode as a child of the parent node

Parameters:
parentNode - Parent node of the original node
originalNode - Node to get child index of
Returns:
the index of the original node in the parent's list of children

rightAlignFind

private TreeNode rightAlignFind(TreeNode parentNode,
                                TreeNode originalNode,
                                int originalNodeChildNumber,
                                boolean goingDown)
Find the right aligned cell that is below (above) the original node, using the parent node as reference. The last parameter (boolean) is used to determine whether to search down (true) or up (false)

Parameters:
parentNode - parent of the original node
originalNode - the originating node to find a cousin of
originalNodeChildNumber - the index of the original node in the list of its parents children
goingDown - true for down arrow action, false for up arrow
Returns:
the cousin tree node of the original node, as best as possible for up and down arrow actions. Previous movements are forgotten, so up-down actions may not return to original node.

flashLeft

public void flashLeft()
Function to handle a left arrow action by the user.


flashRight

public void flashRight()
Function to handle a right arrow action by the user.


flashDown

public void flashDown()
Function to handle a down arrow action by the user.


flashUp

public void flashUp()
Function to handle an up arrow action by the user.


keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Capture the press of a key. Used to detect arrow cursor movements or a user pressing one of the control keys (eg. shift, control, alt).

Parameters:
e - The key event.

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Capture the release of a keystroke. Used to set action mode when a user releases one of the control keys (eg. shift, control, alt).

Parameters:
e - The key event.

seedQueue

public void seedQueue()
Wrapper function for TreeJuxtaposer.seedQueue(AccordionTreeDrawerFinal).

Specified by:
seedQueue in class AccordionDrawer

getColorsForCellGeom

public java.util.ArrayList getColorsForCellGeom(CellGeom c)
Wrapper for TreeJuxtaposer call to TreeJuxtaposer.getColorsForRange(int, int, AccordionTreeDrawer). Get the color for a given TreeNode.

Specified by:
getColorsForCellGeom in class AccordionDrawer
Parameters:
c - TreeNode to get color for.
Returns:
an array of colors that this node is to be drawn in, in drawing priority.

getRangeByKey

public RangeList getRangeByKey(int key)
Get the range list (marked group) by the given key

Specified by:
getRangeByKey in class AccordionTreeDrawer
Parameters:
key - range ID
Returns:
RangeList marked group that corresponds to the given key.

customGLInit

protected void customGLInit(javax.media.opengl.GL gl)
Stub function.

Specified by:
customGLInit in class AccordionDrawer
See Also:
AccordionDrawer.init(GLAutoDrawable)

toString

public java.lang.String toString()
Convert tree into name used by screen shot writer.

Overrides:
toString in class java.lang.Object
Returns:
Truncated name of file to remove directory location.