1 import java.util.LinkedHashMap;
4 public boolean changed = false;
5 public int position = 0;
6 public ArrayList<Integer> graphicBuffer;
9 graphicBuffer = new ArrayList<Integer>();
13 return graphicBuffer.size();
18 class Granim extends Graphic
20 HashMap<String,Graphic> displayList;
24 displayList = new HashMap<String,Graphic>();
26 public Graphic addGraphic(String name, Graphic g)
28 while(width()< g.position+1)
30 graphicBuffer.add(lx.hsb(0,0,0));
33 displayList.put(name , g);
38 public Graphic getGraphicByName(String name)
40 return displayList.get(name);
46 for(Graphic g : displayList.values())
48 if(g instanceof Granim)
50 ((Granim) g).update();
53 changed = changed || g.changed;
56 while(width()< g.position + g.width())
58 graphicBuffer.add(lx.hsb(0,0,0));
70 public void drawOne(Graphic g)
72 graphicBuffer.addAll(g.position,g.graphicBuffer);
78 class GranimPattern extends SCPattern
80 HashMap<String,Graphic> displayList;
82 GranimPattern(GLucose glucose)
85 displayList = new HashMap<String,Graphic>();
88 public Graphic addGraphic(String name, Graphic g)
90 displayList.put(name,g);
94 public Graphic getGraphicByName(String name)
96 return displayList.get(name);
99 public void run(double deltaMs)
103 private Integer[] gbuffer;
104 public void drawToPointList()
106 for(Graphic g : displayList.values())
108 if(g instanceof Granim)
110 ((Granim) g).update();
112 List<LXPoint> drawList = model.points.subList(Math.min(g.position,colors.length-1), Math.min(g.position + g.width(),colors.length-1));
113 //println("drawlistsize "+drawList.size());
115 gbuffer = g.graphicBuffer.toArray(new Integer[0]);
117 for (int i=0; i < drawList.size(); i++)
119 colors[drawList.get(i).index] = gbuffer[i];
127 class RedsGraphic extends Graphic
142 for(int i = 0; i < len ;i++)
144 graphicBuffer.add(lx.hsb(0,255,255));
149 class RedsGranim extends Granim
154 addGraphic("myreds", new RedsGraphic(10));
159 addGraphic("myreds", new RedsGraphic(len));
161 public float count = 0.0;
164 Graphic g=getGraphicByName("myreds");
165 g.position = Math.round(sin(count)*20)+100;
176 class RandomsGranim extends Granim
178 private int _len =0 ;
183 addGraphic("myrandoms", makeGraphic(_len));
185 RandomsGranim(int len)
189 addGraphic("myrandoms", makeGraphic(len));
192 public Graphic makeGraphic(int len)
195 int[] colors= new int[len];
196 for(int i =0;i<len;i++)
198 colors[i]=(int) Math.round(Math.random()*80)+colorLid;
202 return new ColorDotsGraphic(colors);
204 private int count =1;
205 private int instanceCount =0;
209 if(instanceCount<90 && count % 20==0)
212 Graphic h=addGraphic("myrandoms_"+instanceCount, makeGraphic(_len));
213 h.position = instanceCount*(_len+100);
214 //println("one more " + instanceCount+" at "+h.position);
225 class ColorDotsGraphic extends Graphic
227 ColorDotsGraphic(int[] colorSequence)
230 for (int colorVal : colorSequence)
232 graphicBuffer.add(lx.hsb(colorVal, 255, 255));