org.problets.lib.conceptmap.view
Class NodeView

java.lang.Object
  extended by org.problets.lib.conceptmap.view.NodeView
Direct Known Subclasses:
CollapsibleNodeView, NavigableNodeView, UserBuiltNodeView

public class NodeView
extends java.lang.Object

The NodeView class performs the painting for each node. Each node instantiates a view for painting its node. The locations for the painting are set by the model while layoutModel() is being called. At the end of each paint operation, the current actual coordinates used for the drawing are saved. If a button press/release occurs, that location will be compared to these values to determine if this NodeView was selected.

Author:
Eric Fernandes, Adrian Maries July 2005

Field Summary
static int NO_NODE_PRESSED
           
static int NO_NODE_RELEASED
           
static int NON_ROOT_PRESSED
           
static int NON_ROOT_RELEASED
           
static int ROOT_PRESSED
           
static int ROOT_RELEASED
           
 
Constructor Summary
NodeView(NodeView inParent, NodeModel inNodeModel)
          Creates a NodeView object using the parent node view and the node model as arguments.
 
Method Summary
 void draw(java.awt.Graphics g)
          This method is called by the tree view to request a painting of a regular node view.
 NodeView findNode(java.util.Vector fullName)
          Attempts to find a node view given the full path.
 LinkView getChildLink(int index)
          Returns the link view at the specified position in the vector of child links.
 NodeView getChildNode(int index)
          Returns the node view at the specified position in the vector of child nodes.
 int getCurrentXEnd()
          Returns this node's current ending x-coordinate.
 int getCurrentXStart()
          Returns this node's current starting x-coordinate.
 int getCurrentYEnd()
          Returns this node's current ending y-coordinate.
 int getCurrentYStart()
          Returns this node's current starting y-coordinate.
 int getIndex(java.lang.String name)
          Returns the index of the child node whose name is passed as argument.
 boolean getIsExpanded()
          Indicates if this node's children are expanded.
 boolean getIsHighlighted()
          Indicates if this node is highlighted.
 boolean getIsVisible()
          Indicates if this node is visible.
 int getMaxHeightOfDescendants()
          Recursively determine the maximum height of this node's descendants.
 int getMaxWidthOfDescendants()
          Recursively determine the maximum width of this node view's descendants.
 boolean getMouseoverVisible()
          Returns the status of the flag responsible for this node's visibility.
 NodeView getMouseoverVisibleNode()
          Returns the node view whose mouseover is visible.
 NodeModel getNodeModel()
          Returns the node model which this view represents.
 int getNumChildren()
          Returns the number of children this node view has.
 NodeView getParent()
          Returns this node's parent.
 MouseClickedInfo handleMouseClicked(int xCoord, int yCoord)
          Handles the mouseClicked event.
 boolean handleMouseDragged(int xCoord, int yCoord)
          Handles the mouseDragged event.
 boolean handleMouseMoved(int xCoord, int yCoord)
          Handles the mouseMoved event.
 MousePressedInfo handleMousePressed(java.awt.event.MouseEvent e)
          Handles the mousePressed event.
 int handleMouseReleased(int xCoord, int yCoord)
          Handles the mouseReleased event.
 NodeView isOnChildLinks(int x, int y)
          Method overridden by UserBuiltNodeView in order to check if any mouse event (given by the coordinates passed as arguments) occurred inside any of this node view's child links.
 boolean isOnNode(int x, int y)
          Checks if any mouse event (given by the coordinates passed as arguments) occurred inside this node view.
 int layout(int upperLeftCornerColumn, int upperLeftCornerRow, int depth, int height)
          Lays out this node and all its children.
static void main(java.lang.String[] args)
           
 void paintMouseover(java.awt.Graphics g)
          This method is called by the node to request a painting of the mouseover for this node.
 void setCoord(int width, int height, int horizSpacing, int verticalSpacing)
          Sets the coordinates of the node view.
 void setExpandedUpToDepth(int depth)
          Sets the tree expanded up to the specified depth.
 void setIsHighlighted(boolean inIsHighlighted)
          Sets this node as either highlighted or normal.
 void setIsHighlightedAncestorPath(boolean inIsHighlighted)
          Sets this node and all of its ancestors as either highlighted or normal.
 void setIsLastPressed(boolean inIsLastPressed)
          Sets this node's isLastPressed flag.
 void setIsVisible(boolean inIsVisible)
          Sets the flag for this node's visibility.
 void setLinksVisible(boolean isVisible)
          Sets the isVisible flag for this node's child link views.
 void setMouseoverVisible(boolean inMouseoverVisible)
          Sets the flag for this node's mouseover visiblity.
 void setParent(NodeView inParent)
          Sets this node's parent.
 void setTextFont(java.awt.Font inFont)
          Sets the font used when displaying the name of the node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_NODE_PRESSED

public static final int NO_NODE_PRESSED
See Also:
Constant Field Values

NON_ROOT_PRESSED

public static final int NON_ROOT_PRESSED
See Also:
Constant Field Values

ROOT_PRESSED

public static final int ROOT_PRESSED
See Also:
Constant Field Values

NO_NODE_RELEASED

public static final int NO_NODE_RELEASED
See Also:
Constant Field Values

NON_ROOT_RELEASED

public static final int NON_ROOT_RELEASED
See Also:
Constant Field Values

ROOT_RELEASED

public static final int ROOT_RELEASED
See Also:
Constant Field Values
Constructor Detail

NodeView

public NodeView(NodeView inParent,
                NodeModel inNodeModel)
Creates a NodeView object using the parent node view and the node model as arguments.

Parameters:
inParent - the parent node view
inNodeModel - the node model for which this view was created
Method Detail

getMouseoverVisibleNode

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

Returns:
the node view whose mouseover is visible

draw

public void draw(java.awt.Graphics g)
This method is called by the tree view to request a painting of a regular node view.

Parameters:
g - the graphics context

paintMouseover

public void paintMouseover(java.awt.Graphics g)
This method is called by the node to request a painting of the mouseover for this node. The location is based on the current location of the node view.

Parameters:
g - the graphics context

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 this node view or any of its descendants, 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 this node or any of its descendants (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 int handleMouseReleased(int xCoord,
                               int yCoord)
Handles the mouseReleased event.

Parameters:
xCoord - the x-coordinate of the mouse event
yCoord - the y-coordinate of the mouse event
Returns:
ROOT_RELEASED if the mouse has been released on a root, NON_ROOT_RELEASED if the mouse was released on a node other than the root and NO_NODE_RELEASED if the was mouse wasn't released on any node

handleMouseDragged

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

Parameters:
xCoord - the x-coordinate of the mouse event
yCoord - the y-coordinate of the mouse event
Returns:
if this node or any of its descendants was dragged, false otherwise

getNodeModel

public NodeModel getNodeModel()
Returns the node model which this view represents.

Returns:
the node model which this view represents

getParent

public NodeView getParent()
Returns this node's parent.

Returns:
this node's parent

getCurrentXStart

public int getCurrentXStart()
Returns this node's current starting x-coordinate.

Returns:
this node's current starting x-coordinate

getCurrentYStart

public int getCurrentYStart()
Returns this node's current starting y-coordinate.

Returns:
this node's current starting y-coordinate

getCurrentXEnd

public int getCurrentXEnd()
Returns this node's current ending x-coordinate.

Returns:
this node's current ending x-coordinate

getCurrentYEnd

public int getCurrentYEnd()
Returns this node's current ending y-coordinate.

Returns:
this node's current ending y-coordinate

isOnNode

public boolean isOnNode(int x,
                        int y)
Checks if any mouse event (given by the coordinates passed as arguments) occurred inside this node view.

Parameters:
x - the x-coordinate of the mouse event
y - the y-coordinate of the mouse event
Returns:
true if a mouse event occurred inside this node view, false otherwise

isOnChildLinks

public NodeView isOnChildLinks(int x,
                               int y)
Method overridden by UserBuiltNodeView in order to check if any mouse event (given by the coordinates passed as arguments) occurred inside any of this node view's child links. Only returns false in NodeView bacause it doesn't need to know if there was any mouse event inside its child links.

Parameters:
x - the x-coordinate of the mouse event
y - the y-coordinate of the mouse event
Returns:
the target node view of the pressed link

getIsHighlighted

public boolean getIsHighlighted()
Indicates if this node is highlighted.

Returns:
true if this node is highlighted, false otherwise

getIsVisible

public boolean getIsVisible()
Indicates if this node is visible.

Returns:
true if this node is visible, false otherwise

getIsExpanded

public boolean getIsExpanded()
Indicates if this node's children are expanded.

Returns:
true if this node's children are expanded, false otherwise

getMouseoverVisible

public boolean getMouseoverVisible()
Returns the status of the flag responsible for this node's visibility.


getNumChildren

public int getNumChildren()
Returns the number of children this node view has.

Returns:
the number of children this node has

getChildNode

public NodeView getChildNode(int index)
Returns the node view at the specified position in the vector of child nodes.

Parameters:
index - an index into the vector of child nodes
Returns:
the node view at the specified position in the vector of childen nodes

getChildLink

public LinkView getChildLink(int index)
Returns the link view at the specified position in the vector of child links.

Parameters:
index - an index into the vector of child links
Returns:
the link view at the specified position in the vector of childen links

getIndex

public int getIndex(java.lang.String name)
Returns the index of the child node whose name is passed as argument.

Parameters:
name - the name of the child node whose index is returned
Returns:
the index of the child node whose name is passed as argument

findNode

public NodeView findNode(java.util.Vector fullName)
Attempts to find a node view given the full path.

Parameters:
fullName - the vector containing the full path to the sought node
Returns:
this node view if it is the one sought, null otherwise

getMaxHeightOfDescendants

public int getMaxHeightOfDescendants()
Recursively determine the maximum height of this node's descendants.

Returns:
the maximum height of this node's descendants Height here refers to vertical dimension of the tree, not its depth/width

getMaxWidthOfDescendants

public int getMaxWidthOfDescendants()
Recursively determine the maximum width of this node view's descendants.

Returns:
the maximum width of this node's descendants

setTextFont

public void setTextFont(java.awt.Font inFont)
Sets the font used when displaying the name of the node.

Parameters:
the - font used when displaying the name of the node

setParent

public void setParent(NodeView inParent)
Sets this node's parent.

Parameters:
inParent - this node's parent

setIsLastPressed

public void setIsLastPressed(boolean inIsLastPressed)
Sets this node's isLastPressed flag.

Parameters:
inIsLastPressed - true if this node view was the last one pressed

setCoord

public void setCoord(int width,
                     int height,
                     int horizSpacing,
                     int verticalSpacing)
Sets the coordinates of the node view.

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

setIsVisible

public void setIsVisible(boolean inIsVisible)
Sets the flag for this node's visibility.

Parameters:
inIsVisible - true if this node is visible, false otherwise

setMouseoverVisible

public void setMouseoverVisible(boolean inMouseoverVisible)
Sets the flag for this node's mouseover visiblity.

Parameters:
inMouseoverVisible - true if this node's mouseover is visible, false otherwise

setExpandedUpToDepth

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

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

setLinksVisible

public void setLinksVisible(boolean isVisible)
Sets the isVisible flag for this node's child link views.

Parameters:
isVisible - true if all this node's child link views are visible, false otherwise

setIsHighlighted

public void setIsHighlighted(boolean inIsHighlighted)
Sets this node as either highlighted or normal.

Parameters:
inIsHighlighted - true if this node is highlighted, false otherwise

setIsHighlightedAncestorPath

public void setIsHighlightedAncestorPath(boolean inIsHighlighted)
Sets this node and all of its ancestors as either highlighted or normal.

Parameters:
inIsHighlighted - true if this node's ancestors are highlighted, false otherwise

layout

public int layout(int upperLeftCornerColumn,
                  int upperLeftCornerRow,
                  int depth,
                  int height)
Lays out this node and all its children.

Parameters:
upperLeftXCoord - the x-coordinate of the upper left corner of the tree
upperLeftYCoord - the y-coordinate of the upper left corner of the tree
depth - this node's depth
height - the height of this node's children
Returns:
the height of the children of this node's parent up to this point

main

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