Java browser: graph/Node.java

Content of graph/Node.java extracted from visualap.jar

/*
Version 1.0, 30-12-2007, First release
 
IMPORTANT NOTICE, please read:
 
This software is licensed under the terms of the GNU GENERAL PUBLIC LICENSE,
please read the enclosed file license.txt or http://www.gnu.org/licenses/licenses.html
 
Note that this software is freeware and it is not designed, licensed or intended
for use in mission critical, life support and military purposes.
 
The use of this software is at the risk of the user.
*/
 
/* class Node
 
This class is used to create nodes in a graph.
A node can contain an <object>, e.g. a bean.
This class provides support for several features: blabla....
 
 
javalc6
*/
package graph;
import java.awt.*;
import java.awt.image.*;
 
public abstract class Node implements Selectable, Changeable, Labelable, Cloneable, Clearable {
	protected Rectangle dragging=null;
	Point origin = new Point(0, 0);
	protected Dimension dimension = new Dimension(0, 0);
    protected boolean selected=false, changed=false;
    protected String label;
 
// constructor not to be used, XMLEncoder/XMLDecoder
	public Node() {
	}
 
 
// basic constructor
	public Node(Point origin) {
		setOrigin(origin);
	}
 
	public String getLabel() {
		return(label);
	}
 
	public void setLabel(String label) {
		this.label = label;
	}
 
 
	public Point getOrigin() {
		return(origin);
	}
 
	public void setOrigin(Point aOrigin) {
		origin.setLocation(aOrigin);
	}
 
 
	public Object contains(int x, int y) {
		if ((x >= origin.x)&&(x < origin.x + dimension.width)&&(y >= origin.y)&&(y < origin.y + dimension.height)) return this;
		else return null;
	}
 
	public boolean contained(Rectangle r) {
		return(r.contains(new Rectangle(origin, dimension)));
	}
 
	public abstract Node clone() throws CloneNotSupportedException;
 
 
	public abstract Rectangle paint(Graphics g, ImageObserver io);
 
	public void setSelected(boolean sel) {
		selected = sel;
	}
 
	public void setChanged(boolean status) {
		changed = status;
	}
 
	public boolean isChanged() {
		return changed;
	}
 
	public void translate(int x, int y) {
		origin.translate(x,y);
		changed = true;
	}
 
	public void drag(int dx, int dy) {
		dragging.setLocation(origin.x+dx, origin.y+dy);
	}
 
	public void drag(boolean status) {
		if (status) dragging = new Rectangle(origin, dimension);
		else dragging = null;
	}
 
	public abstract  void clear();
 
}
 
Share Share on Facebook Share on Twitter Bookmark on Reddit Share via mail
Privacy Policy Creative Commons Attribution-Share Alike Trovami