org.problets.lib.conceptmap.view.userbuilt
Class UserBuiltTreeView

java.lang.Object
  extended by org.problets.lib.conceptmap.view.TreeView
      extended by org.problets.lib.conceptmap.view.userbuilt.UserBuiltTreeView

public class UserBuiltTreeView
extends TreeView

Derived from TreeView. Adds to the functionality of a tree view in order to handle a user-built tree view.

Author:
Adrian Maries

Constructor Summary
UserBuiltTreeView(TreeModel treeModel)
          Creates a UserBuiltTreeView object using the corresponding tree model as argument.
 
Method Summary
 boolean connectTree(int xCoord, int yCoord, UserBuiltNodeView nodeView)
          Connects the node passed as argument to the current node (if they overlap).
 void draw(java.awt.Graphics g)
          Performs the painting of the tree view.
 UserBuiltNodeView getOverlappedNode(int xCoord, int yCoord, UserBuiltNodeView nodeView)
          Returns the node in the tree that is overlapped by the node passed as argument.
 NodeView getTempRoot()
          Returns the temporary root of the tree.
 UserBuiltNodeView handleActionPerformed(int xCoord, int yCoord)
          Handles the actionPerformed event.
 boolean handleMouseDragged(int xCoord, int yCoord)
          Handles the mouseDragged event.
 MousePressedInfo handleMousePressed(java.awt.event.MouseEvent e)
          Handles the mousePressed event.
 boolean handleMouseReleased(int xCoord, int yCoord)
          Handles the mouseReleased.
static void main(java.lang.String[] args)
           
 void setCoord(int inWidth, int inHeight, int horizSpacing, int verticalSpacing)
          Sets the coordinates of each node view in the tree.
 
Methods inherited from class org.problets.lib.conceptmap.view.TreeView
findNode, getColumnsInTree, getLeftColumn, getMouseoverVisibleNode, getRoot, getRowsInTree, getTopRow, getTreeModel, handleMouseClicked, handleMouseMoved, highlightNode, highlightNode, highlightPath, highlightPath, layout, setColumnsInTree, setExpandedUpToDepth, setLeftColumn, setRowsInTree, setTextFont, setTopRow, updateSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserBuiltTreeView

public UserBuiltTreeView(TreeModel treeModel)
Creates a UserBuiltTreeView object using the corresponding tree model as argument.

Parameters:
treeModel - the model representing this view
Method Detail

draw

public void draw(java.awt.Graphics g)
Performs the painting of the tree view.

Overrides:
draw in class TreeView
Parameters:
g - the graphics context

handleMousePressed

public MousePressedInfo handleMousePressed(java.awt.event.MouseEvent e)
Handles the mousePressed event.

Overrides:
handleMousePressed in class TreeView
Parameters:
e - the mousePressed event
Returns:
a MousePressedInfo object

handleMouseReleased

public boolean handleMouseReleased(int xCoord,
                                   int yCoord)
Handles the mouseReleased.

Overrides:
handleMouseReleased in class TreeView
Parameters:
xCoord - the x-coordinate of the mouse event
yCoord - the y-coordinate of the mouse event
Returns:
true if the mouse has been released on the tree, false otherwise

handleMouseDragged

public boolean handleMouseDragged(int xCoord,
                                  int yCoord)
Handles the mouseDragged event.

Overrides:
handleMouseDragged in class TreeView
Parameters:
xCoord - the x-coordinate of the mouse event
yCoord - the y-coordinate of the mouse event
Returns:
true if the mouse has been pressed on the tree and dragged, false otherwise

handleActionPerformed

public UserBuiltNodeView handleActionPerformed(int xCoord,
                                               int yCoord)
Handles the actionPerformed event.

Parameters:
xCoord - the x-coordinate of the last mousePressed event
yCoord - the y-coordinate of the last mousePressed event
Returns:
the target user-built node view of the pressed link

getTempRoot

public NodeView getTempRoot()
Returns the temporary root of the tree.

Returns:
the temporary root of the tree

getOverlappedNode

public UserBuiltNodeView getOverlappedNode(int xCoord,
                                           int yCoord,
                                           UserBuiltNodeView nodeView)
Returns the node in the tree that is overlapped by the node passed as argument.

Parameters:
xCoord - the x-coordinate of the mouse event
yCoord - the y-coordinate of the mouse event
nodeView - the node that overlaps one of the nodes in the current tree
Returns:
the node that is overlapped by the node passed as argument

setCoord

public void setCoord(int inWidth,
                     int inHeight,
                     int horizSpacing,
                     int verticalSpacing)
Sets the coordinates of each node view in the tree. Also saves the width and height of a cell in the grid locally. They are used to set the coordinates of the temporary root of the tree.

Overrides:
setCoord in class TreeView
Parameters:
width - the width of one node view
height - the height of one node view
horizSpacing - the width of one cell in the grid
verticalSpacing - the height of one cell in the grid

connectTree

public boolean connectTree(int xCoord,
                           int yCoord,
                           UserBuiltNodeView nodeView)
Connects the node passed as argument to the current node (if they overlap).

Parameters:
xCoord - the x-coordinate of the mouse event
yCoord - the y-coordinate of the mouse event
nodeView - the node to compare with the current node
Returns:
true if the two nodes overlap

main

public static void main(java.lang.String[] args)