package classes; import com.google.gson.annotations.Expose; 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; @Expose private int leftBorder; //TODO Delete leftBorder, jet is just set to 0 @Expose private String imgPath = ""; @Expose private int backgroundMode = 0; @Expose private int backgroundWidth = 0; @Expose private int backgroundHeight = 0; 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<>()); } /** * @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; } /** * Set the Background Image; * * @param imagePath * Image Path * @param mode * Image Mode * @param width * Image custom width * @param height * Image custom height */ public void setBackgroundImage(String imagePath, int mode, int width, int height) { imgPath = imagePath; backgroundMode = mode; backgroundWidth = width; backgroundHeight = height; } /** * Get the Background Image Path. * * @return imgPath Path of the Image */ public String getImagePath() { return imgPath; } /** * Get the Background mode. * * @return mode the mode */ public int getBackgroundMode() { return backgroundMode; } /** * Get the Background image Width. * * @return mode the width of the Image */ public int getImageWidht() { return backgroundWidth; } /** * Get the Background image Height. * * @return mode the mode */ public int getImageHeight() { return backgroundHeight; } /** * @return the leftBorder */ public int getLeftBorder() { return leftBorder; } /** * @param leftBorder the leftBorder to set */ public void setLeftBorder(int leftBorder) { this.leftBorder = leftBorder; } @Override public AbstractCpsObject makeCopy() { return this; } }