public ArrayList getPointList(long handId) { ArrayList curList; if (_pointLists.containsKey(handId)) curList = (ArrayList) _pointLists.get(handId); else { curList = new ArrayList(_maxPoints); _pointLists.put(handId, curList); } return curList; }
public void draw() { if (_pointLists.size() <= 0) return; pushStyle(); noFill(); PVector vec; PVector firstVec; PVector screenPos = new PVector(); int colorIndex = 0; // draw the hand lists Iterator<Map.Entry> itrList = _pointLists.entrySet().iterator(); while (itrList.hasNext()) { strokeWeight(2); stroke(_colorList[colorIndex % (_colorList.length - 1)]); ArrayList curList = (ArrayList) itrList.next().getValue(); // draw line firstVec = null; Iterator<PVector> itr = curList.iterator(); beginShape(); while (itr.hasNext()) { vec = itr.next(); if (firstVec == null) firstVec = vec; // calc the screen pos context.convertRealWorldToProjective(vec, screenPos); vertex(screenPos.x, screenPos.y); } endShape(); // draw current pos of the hand if (firstVec != null) { strokeWeight(8); context.convertRealWorldToProjective(firstVec, screenPos); point(screenPos.x, screenPos.y); } colorIndex++; } popStyle(); }
public void OnPointDestroy(long nID) { println("OnPointDestroy, handId: " + nID); // remove list if (_pointLists.containsKey(nID)) _pointLists.remove(nID); }