Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17607/src/net/sourceforge/bprocessor/model
Modified Files:
Space.java
Log Message:
Materials can now be saved and loaded, and there is a "global" monitoring of all materials.
Index: Space.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** Space.java 7 May 2006 16:58:53 -0000 1.31
--- Space.java 15 May 2006 10:33:09 -0000 1.32
***************
*** 82,85 ****
--- 82,90 ----
private long nextSurfaceId;
+ /** The materials */
+ private HashMap materials;
+ /** The next surface id */
+ private long nextMaterialId;
+
/** The modellor */
private Modellor modellor;
***************
*** 112,115 ****
--- 117,121 ----
surfaces = new HashMap();
elements = new HashMap();
+ materials = new HashMap();
empty = new Space("Void", FUNCTIONAL, false);
this.add(empty);
***************
*** 614,617 ****
--- 620,685 ----
/**
+ * Add a material
+ * @param material The material
+ */
+ public void add(Material material) {
+ if (container) {
+ Long id = new Long(nextMaterialId++);
+ material.setId(id);
+ materials.put(id, material);
+ } else {
+ throw new Error("adding material to non-container " + this);
+ }
+ }
+
+ /**
+ * Remove a material
+ * @param material The material
+ */
+ public void remove(Material material) {
+ edges.remove(material.getId());
+ material.setId(null);
+ }
+
+ /**
+ * Insert a material
+ * @param material The material
+ * @return The material
+ */
+ public Material insert(Material material) {
+ add(material);
+ return material;
+ }
+
+ /**
+ * Delete a material
+ * @param material The material
+ */
+ public void delete(Material material) {
+ remove(material);
+ }
+
+ /**
+ * Return the materials
+ * @return The materials
+ */
+ public Collection getMaterials() {
+ if (container) {
+ return materials.values();
+ } else {
+ return EMPTY;
+ }
+ }
+
+ /**
+ * Return the material
+ * @param id The id
+ * @return The material
+ */
+ public Material getMaterial(long id) {
+ return (Material) materials.get(new Long(id));
+ }
+
+ /**
* Find vertex based upon location and delta
* @param x The x coordinate
***************
*** 881,884 ****
--- 949,953 ----
ArrayList res = new ArrayList();
res.add(new Attribute("Name", getName()));
+ res.add(new Attribute("ID", getId().toString()));
res.add(new Attribute("Description", getDescription()));
return res;
|