Beispiel #1
0
  // made synchronized for 0087
  // attempted to remove synchronized for 0136 to fix bug #775 (no luck tho)
  // http://dev.processing.org/bugs/show_bug.cgi?id=775
  public synchronized void message(String s) {
    //    System.out.println("M" + s.length() + ":" + s.trim()); // + "MMM" + s.length());

    // this eats the CRLFs on the lines.. oops.. do it later
    // if (s.trim().length() == 0) return;

    // this is PApplet sending a message (via System.out.println)
    // that signals that the applet has been quit.
    if (s.indexOf(PApplet.EXTERNAL_STOP) == 0) {
      // System.out.println("external: quit");
      if (editor != null) {
        //        editor.internalCloseRunner();  // [091124]
        //        editor.handleStop();  // prior to 0192
        editor.internalCloseRunner(); // 0192
      }
      return;
    }

    // this is the PApplet sending us a message that the applet
    // is being moved to a new window location
    if (s.indexOf(PApplet.EXTERNAL_MOVE) == 0) {
      String nums = s.substring(s.indexOf(' ') + 1).trim();
      int space = nums.indexOf(' ');
      int left = Integer.parseInt(nums.substring(0, space));
      int top = Integer.parseInt(nums.substring(space + 1));
      // this is only fired when connected to an editor
      editor.setSketchLocation(new Point(left, top));
      // System.out.println("external: move to " + left + " " + top);
      return;
    }

    // these are used for debugging, in case there are concerns
    // that some errors aren't coming through properly
    //    if (s.length() > 2) {
    //      System.err.println(newMessage);
    //      System.err.println("message " + s.length() + ":" + s);
    //    }

    // always shove out the message, since it might not fall under
    // the same setup as we're expecting
    sketchErr.print(s);
    // System.err.println("[" + s.length() + "] " + s);
    sketchErr.flush();
  }