Newer
Older
MagnetRON / src / org / ntlab / deltaViewer / Vertex.java
package org.ntlab.deltaViewer;

import com.mxgraph.model.mxICell;

/**
 * JGraphX Vertex.
 * 
 * @author Nitta Lab.
 */
public class Vertex {
	String label;
	Object cell;
	double initialX;
	double initialY;
	double x;
	double y;
	double width;
	double height;
	
	public Vertex(String label, Object cell) {
		this.label = label;
		this.cell = cell;
	}

	public Vertex(String label, Object cell, double initialX, double initialY) {
		this.label = label;
		this.cell = cell;
		this.initialX = initialX;
		this.initialY = initialY;
	}

	public Vertex(String label, Object cell, double x, double y, double width, double height) {
		this.label = label;
		this.cell = cell;
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		((mxICell)cell).getGeometry().setX(x);
		((mxICell)cell).getGeometry().setY(y);
		((mxICell)cell).getGeometry().setWidth(width);
		((mxICell)cell).getGeometry().setHeight(height);
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public Object getCell() {
		return cell;
	}

	public void setCell(Object cell) {
		this.cell = cell;
	}
	
	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
		((mxICell)cell).getGeometry().setX(x);
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
		((mxICell)cell).getGeometry().setY(y);
	}

	public double getWidth() {
		return width;
	}

	public void setWidth(double width) {
		this.width = width;
		((mxICell)cell).getGeometry().setWidth(width);
	}

	public double getHeight() {
		return height;
	}

	public void setHeight(double height) {
		this.height = height;
		((mxICell)cell).getGeometry().setHeight(height);
	}
	
	public double getInitialX() {
		return initialX;
	}

	public double getInitialY() {
		return initialY;
	}

	public void resetCellPosition() {
		((mxICell)cell).getGeometry().setX(initialX);
		((mxICell)cell).getGeometry().setY(initialY);
	}
}