/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info: http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2007, by :
* Corporate:
* EADS Astrium
* Individual:
* Claude Cazenave
*
* $Id: TestGatedRectangle.java,v 1.4 2009/01/20 17:52:33 ogor Exp $
*
* Changes
* -------
* 2 oct. 2008 : Initial public release
*
*/
package simtools.diagram.test;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.List;
import jsynoptic.plugins.circuit.CircuitGate;
import simtools.diagram.DiagramSelection;
import simtools.diagram.Element;
import simtools.diagram.ElementSelection;
import simtools.diagram.gate.Connection;
import simtools.diagram.gate.Gate;
import simtools.diagram.gate.GatedComponent;
import simtools.diagram.gate.GatedComponentSelection;
import simtools.shapes.GatesHolder;
/**
* @author zxpletran007
*
*/
public class TestGatedRectangle extends Rectangle implements GatedComponent, Element {
private static final long serialVersionUID = 1570200687450264506L;
private GatesHolder gateHolder;
protected Gate northGate, southGate, eastGate, westGate;
public TestGatedRectangle(int x, int y, int w, int h) {
super(x, y, w, h);
gateHolder = new GatesHolder(this);
addGate(northGate = new Gate(this, Gate.NORTH));
addGate(southGate = new Gate(this, Gate.SOUTH));
addGate(eastGate = new Gate(this, Gate.EAST));
addGate(westGate = new Gate(this, Gate.WEST));
}
public Rectangle getGateBounds(){
return this;
}
public TestGatedRectangle cloneTestGatedRectangle() {
TestGatedRectangle clone = (TestGatedRectangle)super.clone();
clone.gateHolder = gateHolder.cloneGateHolder(clone);
clone.northGate = (CircuitGate)northGate.cloneGate(clone);
clone.addGate(clone.northGate);
clone.southGate = (CircuitGate)southGate.cloneGate(clone);
clone.addGate(clone.southGate);
clone.eastGate = (CircuitGate)eastGate.cloneGate(clone);
clone.addGate(clone.eastGate);
clone.westGate = (CircuitGate)westGate.cloneGate(clone);
clone.addGate(clone.westGate);
return clone;
}
/* (non-Javadoc)
* @see simtools.diagram.gate.GatedComponent#getGateAnchor(simtools.diagram.gate.Gate)
*/
public Point getGateAnchor(Gate gate) {
return gateHolder.getGateAnchor(gate);
}
/* (non-Javadoc)
* @see simtools.diagram.gate.GatedComponent#getGateAt(int, int)
*/
public Gate getGateAt(int ox, int oy) {
return gateHolder.getGateAt(ox, oy);
}
/* (non-Javadoc)
* @see simtools.diagram.gate.GatedComponent#getGates()
*/
public List getGates() {
return gateHolder.getGates();
}
/* (non-Javadoc)
* @see simtools.diagram.gate.GatedComponent#addGate(simtools.diagram.gate.Gate)
*/
public void addGate(Gate gate) {
gateHolder.addGate(gate);
}
public void removeGate(Gate gate) {
gateHolder.removeGate(gate);
}
public void connectionAddedAt(Gate gate, Connection connection) {
}
public void connectionRemovedAt(Gate gate, Connection connection) {
}
public ElementSelection createSelection(Point shapeOrigin, DiagramSelection ds){
return new GatedComponentSelection(this, shapeOrigin, ds);
}
public void processShapeRemoving() {
// TODO Auto-generated method stub
}
public void processShapeRestoring() {
// TODO Auto-generated method stub
}
}