package de.unibremen.informatik.hets.graphviz;
//import uk.ac.man.cs.mig.util.graph.graph.Node;
import java.awt.*;
import java.awt.geom.Ellipse2D;
/**
* User: matthewhorridge
* The Univeristy Of Manchester
* Medical Informatics Group
* Date: Jan 15, 2004
*
* matthew.horridge@cs.man.ac.uk
* www.cs.man.ac.uk/~horridgm
*
*/
public class Node
{
private Object userObject;
private String label;
private Ellipse2D.Double ellipse;
private Point pos;
/**
* Constructs a Node
that represents the specified object.
* @param userObject The object that the Node
represents.
*/
public Node(Object userObject)
{
this.userObject = userObject;
ellipse = new Ellipse2D.Double();
pos = new Point();
}
public void setLabel(String l) {
label = l;
}
public String getLabel() {
return label;
}
/**
* Gets the userObject, previously set with setUserObject(Object o)
* @return The userObject, or null
if no object has been set.
*/
public Object getUserObject()
{
return userObject;
}
/**
* Sets the (x,y) position of the Node
.
* @param x The horizontal location.
* @param y The vertical location.
*/
public void setPosition(int x, int y)
{
int w = getSize().width;
int h = getSize().height;
pos.x = x;
pos.y = y;
ellipse.setFrame(x - w / 2, y - h / 2, w, h);
}
/**
* Gets the position of the Node
.
* @return A Point
containing the x,y position of the Node
.
*/
public Point getPosition()
{
return pos;
}
/**
* Sets the Node's
size.
* @param width The width of the Node
.
* @param height The height of the Node
.
*/
public void setSize(int width, int height)
{
int x = getPosition().x;
int y = getPosition().y;
ellipse.setFrame(x - width / 2, y - height / 2, width, height);//setLocation(x - width / 2, y - height / 2);
//rect.setSize(width, height);
}
/**
* Gets the size of the Node
.
* @return A Dimension
containing the width and height
* of the Node
.
*/
public Dimension getSize()
{
return ellipse.getBounds().getSize();
}
/**
* Returns the Shape
of the Node
.
* @return The Shape
of the Node
.
*/
public Shape getShape()
{
return ellipse;
}
}