org.problets.lib.conceptmap.view
Class TreeView

java.lang.Object
  extended by org.problets.lib.conceptmap.view.TreeView
Direct Known Subclasses:
CollapsibleTreeView, NavigableTreeView, UserBuiltTreeView

public abstract class TreeView
extends java.lang.Object

Performs the painting of the tree model.

Author:
Eric Fernades, Adrian Maries

Constructor Summary
TreeView(TreeModel inTreeModel)
          Creates a TreeView object using the tree model as argument.
 
Method Summary
 void draw(java.awt.Graphics g)
          Performs the painting of the tree view.
 NodeView findNode(java.util.Vector fullName)
          Attempts to recursively locate an node given a full name in vector format.
 int getColumnsInTree()
          Returns the number of columns the tree has.
 int getLeftColumn()
          Returns the x-coordinate of the upper left corner of the tree view.
 NodeView getMouseoverVisibleNode()
          Returns the node view whose mouseover is visible.
 NodeView getRoot()
          Returns the root of the tree.
 int getRowsInTree()
          Returns the number of rows the tree has.
 int getTopRow()
          Returns the y-coordinate of the upper left corner of the tree view.
 TreeModel getTreeModel()
          Returns the tree model which this tree view represents.
 MouseClickedInfo handleMouseClicked(int xCoord, int yCoord)
          Handles the mouseClicked event.
 boolean handleMouseDragged(int xCoord, int yCoord)
          Handles the mouseDragged event for a user-built tree.
 boolean handleMouseMoved(int xCoord, int yCoord)
          Handles the mouseMoved event.
 MousePressedInfo handleMousePressed(java.awt.event.MouseEvent e)
          Handles the mousePressed event.
 boolean handleMouseReleased(int xCoord, int yCoord)
          Handles the mouseReleased event for a user-built tree.
 boolean highlightNode(java.lang.String textName, boolean highlighted)
          Sets the highlighting status (highlighted or not highlighted, based on the specified parameter) given the name of the node in text format.
 boolean highlightNode(java.util.Vector fullName, boolean highlighted)
          Sets the highlighting status of the node (highlighted or not highlighted, based on the specified parameter) given the name of the node in vector format.
 boolean highlightPath(java.lang.String textName, boolean highlighted)
          Sets the highlighting status of the node and all its ancestors (highlighted or not highlighted, based on the specified parameter) given the name of the node in text format.
 boolean highlightPath(java.util.Vector fullName, boolean highlighted)
          Sets the highlighting status of the node and all its ancestors (highlighted or not highlighted, based on the specified parameter) given the name of the node in vector format.
 void layout()
          Determines the layout of the panel by recursively asking the nodes to determine their own layout.
static void main(java.lang.String[] args)
           
 void setColumnsInTree(int inColumnsInTree)
          Sets the number of columns the tree has.
 void setCoord(int inWidth, int inHeight, int horizSpacing, int verticalSpacing)
          Sets the coordinates of each node view in the tree.
 void setExpandedUpToDepth(int depth)
          Sets the tree expanded up to the specified depth
 void setLeftColumn(int inLeftColumn)
          Sets the number of the leftmost column in the tree view .
 void setRowsInTree(int inRowsInTree)
          Sets the number of rows the tree has.
 void setTextFont(java.awt.Font font)
          Sets the font used when displaying the names of the nodes in the tree.
 void setTopRow(int inTopRow)
          Sets the number of the upper row in the tree view.
 void updateSize()
          Updates the number of rows and columns of the tree.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeView

public TreeView(TreeModel inTreeModel)
Creates a TreeView object using the tree model as argument.

Parameters:
inTreeModel - the model for this view
Method Detail

draw

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

Parameters:
g - the graphics context

layout

public void layout()
Determines the layout of the panel by recursively asking the nodes to determine their own layout.


getRoot

public NodeView getRoot()
Returns the root of the tree.

Returns:
the root of the tree

getTreeModel

public TreeModel getTreeModel()
Returns the tree model which this tree view represents.

Returns:
the tree model this tree view represents

findNode

public NodeView findNode(java.util.Vector fullName)
Attempts to recursively locate an node given a full name in vector format. If the node is found, it is returned. Otherwise, null is returned.

Parameters:
fullName - the full name of the node in vector format
Returns:
the node whose name is passed as argument

getMouseoverVisibleNode

public NodeView getMouseoverVisibleNode()
Returns the node view whose mouseover is visible.

Returns:
the node view whose mouseover is visible

getRowsInTree

public int getRowsInTree()
Returns the number of rows the tree has.

Returns:
the number of rows the tree has

getColumnsInTree

public int getColumnsInTree()
Returns the number of columns the tree has.

Returns:
the number of columns the tree has

getLeftColumn

public int getLeftColumn()
Returns the x-coordinate of the upper left corner of the tree view.

Returns:
the x-coordinate of the upper left corner of the tree view

getTopRow

public int getTopRow()
Returns the y-coordinate of the upper left corner of the tree view.

Returns:
the y-coordinate of the upper left corner of the tree view

setTextFont

public void setTextFont(java.awt.Font font)
Sets the font used when displaying the names of the nodes in the tree.

Parameters:
font - the font used when displaying the names of the fonts in the tree

setExpandedUpToDepth

public void setExpandedUpToDepth(int depth)
Sets the tree expanded up to the specified depth

Parameters:
the - depth up to which the tree is expanded

updateSize

public void updateSize()
Updates the number of rows and columns of the tree.


highlightNode

public boolean highlightNode(java.lang.String textName,
                             boolean highlighted)
Sets the highlighting status (highlighted or not highlighted, based on the specified parameter) given the name of the node in text format.

Parameters:
textName - the name of the node to be highlighted in vector format
highlighted - the highlighting status of the node
Returns:
true if the node was found

highlightNode

public boolean highlightNode(java.util.Vector fullName,
                             boolean highlighted)
Sets the highlighting status of the node (highlighted or not highlighted, based on the specified parameter) given the name of the node in vector format.

Parameters:
fullName - the name of the node to be highlighted in vector format
highlighted - the highlighting status of the node
Returns:
true if the node was found

highlightPath

public boolean highlightPath(java.lang.String textName,
                             boolean highlighted)
Sets the highlighting status of the node and all its ancestors (highlighted or not highlighted, based on the specified parameter) given the name of the node in text format.

Parameters:
textName - the name of the node to be highlighted in vector format
highlighted - the highlighting status of the node
Returns:
true if the node was found

highlightPath

public boolean highlightPath(java.util.Vector fullName,
                             boolean highlighted)
Sets the highlighting status of the node and all its ancestors (highlighted or not highlighted, based on the specified parameter) given the name of the node in vector format.

Parameters:
fullName - the name of the node to be highlighted in vector format
highlighted - the highlighting status of the node
Returns:
true if the node was found

setRowsInTree

public void setRowsInTree(int inRowsInTree)
Sets the number of rows the tree has.

Parameters:
inRowsInTree - the number of rows the tree has

setColumnsInTree

public void setColumnsInTree(int inColumnsInTree)
Sets the number of columns the tree has.

Parameters:
inColumnsInTree - the number of columns the tree has

setLeftColumn

public void setLeftColumn(int inLeftColumn)
Sets the number of the leftmost column in the tree view .

Parameters:
inLeftColumn - the number of the leftmost column in the tree view corner of the tree view

setTopRow

public void setTopRow(int inTopRow)
Sets the number of the upper row in the tree view.

Parameters:
inTopRow - the number of the upper row in the tree view corner of the tree view

setCoord

public void setCoord(int inWidth,
                     int inHeight,
                     int horizSpacing,
                     int verticalSpacing)
Sets the coordinates of each node view in the tree.

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

handleMouseClicked

public MouseClickedInfo handleMouseClicked(int xCoord,
                                           int yCoord)
Handles the mouseClicked event.

Parameters:
xCoord - the x-coordinate of the mouse event
yCoord - the y-coordinate of the mouse event
Returns:
true if a click occurred inside the forest view, false otherwise

handleMouseMoved

public boolean handleMouseMoved(int xCoord,
                                int yCoord)
Handles the mouseMoved event.

Parameters:
xCoord - the x-coordinate of the mouse event
yCoord - the y-coordinate of the mouse event
Returns:
true if the mouse has been moved onto the forest view (but no buttons have been pressed), false otherwise

handleMousePressed

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

Parameters:
e - the mousePressed event
Returns:
a MousePressedInfo object

handleMouseReleased

public boolean handleMouseReleased(int xCoord,
                                   int yCoord)
Handles the mouseReleased event for a user-built tree.

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 forest, false otherwise

handleMouseDragged

public boolean handleMouseDragged(int xCoord,
                                  int yCoord)
Handles the mouseDragged event for a user-built tree.

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 forest and dragged, false otherwise

main

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