package classes; import java.util.ArrayList; import java.util.HashMap; public class CpsUpperNode extends AbstractCpsObject { private ArrayList nodes; private ArrayList nodeEdges; private ArrayList oldEdges; private HashMap nodesIdx; public CpsUpperNode(String nodeName) { super(nodeName); this.setConnections(new ArrayList()); this.setImage("/Images/upper_node.png"); this.setSav("CVS"); this.setID(IdCounter.nextId()); this.setNodes(new ArrayList()); this.setNodeEdges(new ArrayList()); this.setOldEdges(new ArrayList()); this.setNodesIdx(new HashMap()); // TODO Auto-generated constructor stub } /** * @return the nodes */ public ArrayList getNodes() { return nodes; } /** * @param nodes * the nodes to set */ public void setNodes(ArrayList nodes) { this.nodes = nodes; } /** * @return the nodeEdges */ public ArrayList getNodeEdges() { return nodeEdges; } /** * @param nodeEdges * the nodeEdges to set */ public void setNodeEdges(ArrayList nodeEdges) { this.nodeEdges = nodeEdges; } /** * @return the oldEdges */ public ArrayList getOldEdges() { return oldEdges; } /** * @param oldEdges * the oldEdges to set */ public void setOldEdges(ArrayList oldEdges) { this.oldEdges = oldEdges; } /** * @return the nodesIdx */ public HashMap getNodesIdx() { return nodesIdx; } /** * @param nodesIdx * the nodesIdx to set */ public void setNodesIdx(HashMap nodesIdx) { this.nodesIdx = nodesIdx; } public ArrayList getNumHolonObj() { ArrayList onlyHolonObj = new ArrayList(); for (AbstractCpsObject temp : getNodes()) { if (temp instanceof HolonObject) { onlyHolonObj.add((HolonObject) temp); } } return onlyHolonObj; } public ArrayList getNumSwitches() { ArrayList onlySwitsches = new ArrayList(); for (AbstractCpsObject temp : getNodes()) { if (temp instanceof HolonSwitch) { onlySwitsches.add((HolonSwitch) temp); } } return onlySwitsches; } public ArrayList getNumUpperNodes() { ArrayList onlyUpperNodes = new ArrayList(); for (AbstractCpsObject temp : getNodes()) { if (temp instanceof CpsUpperNode) { onlyUpperNodes.add((CpsUpperNode) temp); } } return onlyUpperNodes; } public AbstractCpsObject searchObj(int ID) { AbstractCpsObject result = null; for (AbstractCpsObject obj : getNodes()) { if (obj.getID() == ID) { result = obj; break; } } return result; } }