From: Ben Morrow Date: Sun, 18 Aug 2013 01:51:57 +0000 (-0700) Subject: use a hashtable so we can name graphic instances X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2ca063885e4bcf5c22f48c396959b37417694a6a;p=SugarCubes.git use a hashtable so we can name graphic instances --- diff --git a/BenMorrow.pde b/BenMorrow.pde index cf88145..a86189b 100644 --- a/BenMorrow.pde +++ b/BenMorrow.pde @@ -49,7 +49,7 @@ class GranimTestPattern extends GranimPattern { super(glucose); RedThreeGraphic myReds = new RedThreeGraphic(); - addGraphic(myReds); + addGraphic("string_name",myReds); } diff --git a/GranimPattern.pde b/GranimPattern.pde index 708a1ab..2fd33e1 100644 --- a/GranimPattern.pde +++ b/GranimPattern.pde @@ -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 displayList; + Hashtable displayList; GranimPattern(GLucose glucose) { super(glucose); - displayList = new ArrayList(); + displayList = new Hashtable(); } - 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 drawList = model.points.subList(g.position, g.position + g.graphicBuffer.size());