You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
2.4 KiB
Java
116 lines
2.4 KiB
Java
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<br>
|
|
* The Univeristy Of Manchester<br>
|
|
* Medical Informatics Group<br>
|
|
* Date: Jan 15, 2004<br><br>
|
|
*
|
|
* matthew.horridge@cs.man.ac.uk<br>
|
|
* www.cs.man.ac.uk/~horridgm<br><br>
|
|
*
|
|
*/
|
|
public class Node
|
|
{
|
|
private Object userObject;
|
|
private String label;
|
|
private Ellipse2D.Double ellipse;
|
|
|
|
private Point pos;
|
|
|
|
/**
|
|
* Constructs a <code>Node</code> that represents the specified object.
|
|
* @param userObject The object that the <code>Node</code> 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 <code>setUserObject(Object o)</code>
|
|
* @return The userObject, or <code>null</code> if no object has been set.
|
|
*/
|
|
public Object getUserObject()
|
|
{
|
|
return userObject;
|
|
}
|
|
|
|
/**
|
|
* Sets the (x,y) position of the <code>Node</code>.
|
|
* @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 <code>Node</code>.
|
|
* @return A <code>Point</code> containing the x,y position of the <code>Node</code>.
|
|
*/
|
|
public Point getPosition()
|
|
{
|
|
return pos;
|
|
}
|
|
|
|
/**
|
|
* Sets the <code>Node's</code> size.
|
|
* @param width The width of the <code>Node</code>.
|
|
* @param height The height of the <code>Node</code>.
|
|
*/
|
|
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 <code>Node</code>.
|
|
* @return A <code>Dimension</code> containing the width and height
|
|
* of the <code>Node</code>.
|
|
*/
|
|
public Dimension getSize()
|
|
{
|
|
return ellipse.getBounds().getSize();
|
|
}
|
|
|
|
/**
|
|
* Returns the <code>Shape</code> of the <code>Node</code>.
|
|
* @return The <code>Shape</code> of the <code>Node</code>.
|
|
*/
|
|
public Shape getShape()
|
|
{
|
|
return ellipse;
|
|
}
|
|
}
|