//Copyright (c)2005 Holobloc Inc.
//Contributed to the OOONEIDA FBench project under the Common Public License.
package fbench.graph.model;
import java.awt.Point;
import java.util.Vector;
import fbench.dom.events.MutationListener;
import fbench.graph.ECState;
import fbench.graph.GraphElement;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
/**
* A GraphModel for an IEC 61499 ECC Element.
*
* @author JHC
* @version 20051028/JHC
*/
public class ECC extends GraphModel {
Vector<ECState> allStates = null;
public ECC() {
super();
}
//private MutationListener ml;
public ECC(Element el) {
super(el);
//ml = MutationListener.forElement(getElement());
}
public Vector getGraph() {
allStates = new Vector<ECState>();
NodeList states = element.getElementsByTagName("ECState");
NodeList trans = element.getElementsByTagName("ECTransition");
Vector ans = new Vector(states.getLength() + trans.getLength());
for (int i = 0; i < states.getLength(); i++)
ans.add(new ECState((Element) states.item(i), (i == 0)));
for (int i = 0; i < trans.getLength(); i++) {
GraphElement ge = GraphElement.forElement((Element) trans.item(i));
if (ge != null)
ans.add(ge);
}
return ans;
}
public ECState getStateAt(Point p){
for(ECState state : allStates){
if(state.contains(p))
return state;
}
return null;
}
}