|
|
/home/brennan/Software/sensix/source/C^4/NodeGroup.javaGo to the documentation of this file.00001 00010 /* 00011 * Copyright 2008. Los Alamos National Security, LLC. This material 00012 * was produced under U.S. Government contract DE-AC52-06NA25396 for 00013 * Los Alamos National Laboratory (LANL), which is operated by Los 00014 * Alamos National Security, LLC, for the Department of Energy. The 00015 * U.S. Government has rights to use, reproduce, and distribute this 00016 * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, 00017 * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL 00018 * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to 00019 * produce derivative works, such modified software should be clearly 00020 * marked, so as not to confuse it with the version available from LANL. 00021 * 00022 * Additionally, this program is free software; you can redistribute 00023 * it and/or modify it under the terms of the GNU General Public 00024 * License as published by the Free Software Foundation; version 2 of 00025 * the License. Accordingly, this program is distributed in the hope 00026 * it will be useful, but WITHOUT ANY WARRANTY; without even the 00027 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00028 * PURPOSE. See the GNU General Public License for more details. 00029 * 00030 * You should have received a copy of the GNU General Public License 00031 * along with this program; if not, write to the Free Software 00032 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00033 */ 00034 00035 import java.util.*; 00036 import java.awt.Color; 00037 00038 00039 public class NodeGroup implements java.io.Serializable 00040 { 00041 protected Vector<Node> nodes; 00042 protected double radio_range; 00043 protected int level; 00044 00045 transient boolean rand_color; 00046 protected int red; 00047 protected int green; 00048 protected int blue; 00049 00050 public NodeGroup() { 00051 nodes = new Vector<Node>(); 00052 radio_range = 7.0; 00053 level = 3; 00054 rand_color = true; 00055 } 00056 00057 public NodeGroup(NodeGroup ng) { 00058 this(); 00059 00060 for (int i=0; i<ng.getNodes().size(); i++) { 00061 Node n = new Node((Node)ng.getNodes().elementAt(i)); 00062 n.setMygroup(this); 00063 n.setSeq_num(i); 00064 nodes.addElement(n); 00065 } 00066 00067 radio_range = ng.getRadioRange(); 00068 level = ng.getLevel(); 00069 00070 red = ng.getRed(); 00071 green = ng.getGreen(); 00072 blue = ng.getBlue(); 00073 rand_color = false; 00074 } 00075 00076 public double getRadioRange() { return radio_range; } 00077 00078 public int getLevel() { return level; } 00079 00080 public Vector<Node> getNodes() { return nodes; } 00081 00082 public int getRed() { return red; } 00083 00084 public int getGreen() { return green; } 00085 00086 public int getBlue() { return blue; } 00087 00088 public Color getColor() { 00089 return new Color(red, green, blue); 00090 } 00091 00092 00093 public boolean isRandColor() { return rand_color; } 00094 00095 public void setRadioRange(double d) { radio_range = d; } 00096 00097 public void setLevel(int i) { level = i; } 00098 00099 public void setNodes(Vector<Node> v) { nodes = v; } 00100 00101 public void setRed(int i) { 00102 red = i; 00103 rand_color = false; 00104 } 00105 00106 public void setGreen(int i) { 00107 green = i; 00108 rand_color = false; 00109 } 00110 00111 public void setBlue(int i) { 00112 blue = i; 00113 rand_color = false; 00114 } 00115 00116 public void setColor(Color c) { 00117 red = c.getRed(); 00118 green = c.getGreen(); 00119 blue = c.getBlue(); 00120 rand_color = false; 00121 } 00122 00123 00124 public String toString() { 00125 return nodes.size() + " level " + level + " nodes\n"; 00126 } 00127 } |