package commons.graph.model;
/**
 * A node is identified uniquely by it's label.
 * @author ks
 */
public class Node
{

public String  parent;
public String  label;
public int     children;
public double  x;
public double  y;
public boolean visible = true;
public Point   vp1;
public Point   vp2;
public int screen_x; // set after first paint, used for mouseover
public int screen_y; // set after first paint, used for mouseover


public Node(String parent, String label)
{
   this.parent = parent;
   this.label = label;
}

public int hashCode ()
{
   return label.hashCode();
}

public boolean equals (Object other)
{
   if (!(other instanceof Node)) return false;
   return ((Node) other).label.equals(label);
}

public boolean intersects(int x, int y)
{
   return vp1.x <= x && vp1.y <= y && x <= vp2.x && y <= vp2.y;
}

public boolean intersects(double x, double y)
{
   return vp1.x <= x && vp1.y <= y && x <= vp2.x && y <= vp2.y;
}

public String toString ()
{
   return parent + "/" + label + "@" + ((int) x) + "x" + ((int) y) + "(" + (vp1==null?"":vp1.toString()) + "-" + (vp2==null?"":vp2.toString()) + ")";
}
}
