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();
    }
Пример #3
0
 /** Get a class loader. Create in a restricted context */
 synchronized AppletClassLoader getClassLoader(final URL codebase, final String key) {
   AppletClassLoader c = classloaders.get(key);
   if (c == null) {
     AccessControlContext acc = getAccessControlContext(codebase);
     c =
         AccessController.doPrivileged(
             new PrivilegedAction<AppletClassLoader>() {
               @Override
               public AppletClassLoader run() {
                 AppletClassLoader ac = createClassLoader(codebase);
                 /* Should the creation of the classloader be
                  * within the class synchronized block?  Since
                  * this class is used by the plugin, take care
                  * to avoid deadlocks, or specialize
                  * AppletPanel within the plugin.  It may take
                  * an arbitrary amount of time to create a
                  * class loader (involving getting Jar files
                  * etc.) and may block unrelated applets from
                  * finishing createAppletThread (due to the
                  * class synchronization). If
                  * createAppletThread does not finish quickly,
                  * the applet cannot process other messages,
                  * particularly messages such as destroy
                  * (which timeout when called from the browser).
                  */
                 synchronized (getClass()) {
                   AppletClassLoader res = classloaders.get(key);
                   if (res == null) {
                     classloaders.put(key, ac);
                     return ac;
                   } else {
                     return res;
                   }
                 }
               }
             },
             acc);
   }
   return c;
 }
    public void OnPointDestroy(long nID) {
      println("OnPointDestroy, handId: " + nID);

      // remove list
      if (_pointLists.containsKey(nID)) _pointLists.remove(nID);
    }
Пример #5
0
 /** Flush a class loader. */
 public static synchronized void flushClassLoader(String key) {
   classloaders.remove(key);
 }