use a hashtable so we can name graphic instances
authorBen Morrow <childoftv@gmail.com>
Sun, 18 Aug 2013 01:51:57 +0000 (18:51 -0700)
committerBen Morrow <childoftv@gmail.com>
Sun, 18 Aug 2013 01:51:57 +0000 (18:51 -0700)
BenMorrow.pde
GranimPattern.pde

index cf88145f061a5ddebf4846ae2bfb94521a6d59ce..a86189b60e6c47882bb09dc46360441312e2283a 100644 (file)
@@ -49,7 +49,7 @@ class GranimTestPattern extends GranimPattern
        {
                super(glucose);
                RedThreeGraphic myReds = new RedThreeGraphic();
-               addGraphic(myReds);
+               addGraphic("string_name",myReds);
        }
 
 
index 708a1ab90ca336242f0738de739e752f122cd482..2fd33e15c2a0541caef2d33fc09ddea8c70af1af 100644 (file)
@@ -1,3 +1,4 @@
+import java.util.Hashtable;
 class Graphic
 {
        public int position  = 0;
@@ -12,22 +13,22 @@ class Graphic
 };
 class GranimPattern extends SCPattern
 {
-       ArrayList<Graphic> displayList;
+       Hashtable<String,Graphic> displayList;
 
        GranimPattern(GLucose glucose)
        {
                super(glucose);
-               displayList = new ArrayList<Graphic>();
+               displayList = new Hashtable<String,Graphic>();
        }
 
-       public void addGraphic(Graphic g)
+       public void addGraphic(String name, Graphic g)
        {
-               displayList.add(g);
+               displayList.put(name,g);
        }
 
        public void run(int deltaMs) 
        {
-               for(Graphic g : displayList)
+               for(Graphic g : displayList.values())
                {
                        List<Point> drawList = model.points.subList(g.position, g.position + g.graphicBuffer.size());