/*---------------------------- Ingeneue source code ?Copyright 2000 by George von Dassow, Eli Meir, Edwin Munro, and Garrett Odell. Permission is granted for use by private individuals and by individuals and groups at all non-profit institutions, as long as those using the software or examining the code do not intend to make a profit from its use, and subject to all other conditions given on the website www.ingenenue.org. www.ingeneue.org contact@ingeneue.org ----------------------------*/ package main; import java.util.*; import java.awt.*; import main.Node; import main.event.NetworkEvent; import main.event.NetworkEventListener; public class Network { public Vector nodes = new Vector(); public int numNodes; String name; final static int cytoplasmicType = 0, membraneBoundType = 1, externalInfluenceType1 = 2; Network(String name) { this.name = name; numNodes = 0; } public NodeTemplate addNode(String node_name) { NodeTemplate node = new NodeTemplate(node_name, numNodes); nodes.addElement(node); numNodes = nodes.size(); return node; } public NodeTemplate addCalculator(String node_name) { NodeTemplate node = addNode(node_name); node.setCalculatorNode(true); return node; } /* public void addNode(String compname, int node_type, Color color, float sfac) { switch(node_type) { case membraneBoundType: nodes.addElement(new Node(compname, Globals.cellNumSides, color, sfac)); break; case externalInfluenceType1: break; default: nodes.addElement(new Node(compname, 1, color,sfac)); break; } numNodes = nodes.size(); } */ public NodeTemplate getNode(int node_num) { return (NodeTemplate)nodes.elementAt(node_num); } public NodeTemplate getNode(String nodename) throws Exception { int i = 0; while(i < nodes.size() && !((NodeTemplate)nodes.elementAt(i)).name.equals(nodename)) i++; if(i < nodes.size()) return ((NodeTemplate)nodes.elementAt(i)); else throw new Exception("Unknown node " + nodename); } public Vector getNodes() { return nodes; } public int getNumNodes() { return nodes.size(); } public Node [] getNodesForCell() { Node [] nodearray = new Node[nodes.size()]; Enumeration enum = nodes.elements(); int i = 0; while(enum.hasMoreElements()) { nodearray[i] = ((NodeTemplate)enum.nextElement()).makeNode(); i++; } return nodearray; } public Vector getAffectorsForNode(int node_num) { return ((NodeTemplate)nodes.elementAt(node_num)).getAffectors(); } public String getName() { return new String(name); } public void setName(String name) { this.name = name; } public void addNetworkListener(NetworkEventListener listener) { } public void removeNetworkListener(NetworkEventListener listener) { } private void sendNetworkEvent(NetworkEvent evt) { } }