/** * GraphNode.java, an object that stores information about a graph node for * Tree Applicatons.
* Extends: KeyedItem.
* Author: Matt Markham */ public class GraphNode extends KeyedItem { private int xCoord, yCoord; boolean mark; GraphNode (Comparable item) { super(item); mark=false; } GraphNode (Comparable item, int x, int y) { super(item); xCoord=x; yCoord=y; mark=false; } /** * Returns the x-coordinate of the current Graph Node.
* Preconditions: None.
* Postconditions: Returns int value of this nodes x position.
* Throws: None */ public int getX() { return xCoord; } /** * Returns the y-coordiante of the current Graph Node.
* Preconditions: None.
* Postconditions: Returns int value of this nodes y position.
* Throws: None */ public int getY() { return yCoord; } /** * Returns true if node is marked, false if it is not.
* Preconditions: None.
* Postconditions: returns true if node is marked, false if it is not. * Throws: None. */ public boolean isMarked() { return mark; } /** * Sets value of mark to true or false.
* Preconditions: Must be passed in a boolean.
* Postconditions: Sets mark to passed-in boolean.
* Throws: None. */ public void setMarked(boolean setbool) { mark=setbool; } public boolean equals (GraphNode node) { return ((node.getX() == xCoord)&&(node.getY()==yCoord) && (node.getKey().compareTo(this.getKey())==0)); } }