Example #1
0
  /**
   * A classpath, separated by the path separator, will contain a series of .jar/.zip files or
   * directories containing .class files, or containing subdirectories that have .class files.
   *
   * @param path the input classpath
   * @return array of possible package names
   */
  public static String[] packageListFromClassPath(String path) {
    Hashtable<String, Object> table = new Hashtable<String, Object>();
    String pieces[] = PApplet.split(path, File.pathSeparatorChar);

    for (int i = 0; i < pieces.length; i++) {
      // System.out.println("checking piece '" + pieces[i] + "'");
      if (pieces[i].length() == 0) {
        continue;
      }

      if (pieces[i].toLowerCase().endsWith(".jar") || pieces[i].toLowerCase().endsWith(".zip")) {
        // System.out.println("checking " + pieces[i]);
        packageListFromZip(pieces[i], table);

      } else { // it's another type of file or directory
        File dir = new File(pieces[i]);
        if (dir.exists() && dir.isDirectory()) {
          packageListFromFolder(dir, null, table);
          // importCount = magicImportsRecursive(dir, null,
          //                                  table);
          // imports, importCount);
        }
      }
    }
    int tableCount = table.size();
    String output[] = new String[tableCount];
    int index = 0;
    Enumeration<String> e = table.keys();
    while (e.hasMoreElements()) {
      output[index++] = (e.nextElement()).replace('/', '.');
    }
    // System.arraycopy(imports, 0, output, 0, importCount);
    // PApplet.printarr(output);
    return output;
  }
 /** Prints out classpath elements per line. Used for debugging only. */
 public static void showClassPath() {
   System.out.println("------Classpath------");
   String cps[] =
       PApplet.split(System.getProperty("java.class.path"), Base.isWindows() ? ';' : ':');
   for (int i = 0; i < cps.length; i++) {
     System.out.println(cps[i]);
   }
   System.out.println("---------------------");
 }
/*      */   public XMLElement getChild(String path)
/*      */   {
/*  563 */     if (path.indexOf('/') != -1) {
/*  564 */       return getChildRecursive(PApplet.split(path, '/'), 0);
/*      */     }
/*  566 */     int childCount = getChildCount();
/*  567 */     for (int i = 0; i < childCount; i++) {
/*  568 */       XMLElement kid = getChild(i);
/*  569 */       String kidName = kid.getName();
/*  570 */       if ((kidName != null) && (kidName.equals(path))) {
/*  571 */         return kid;
/*      */       }
/*      */     }
/*  574 */     return null;
/*      */   }
Example #4
0
  static public Font getFont(String attr) {
    boolean replace = false;
    String value = get(attr);
    if (value == null) {
      //System.out.println("reset 1");
      value = getDefault(attr);
      replace = true;
    }

    String[] pieces = PApplet.split(value, ',');
    if (pieces.length != 3) {
      value = getDefault(attr);
      //System.out.println("reset 2 for " + attr);
      pieces = PApplet.split(value, ',');
      //PApplet.println(pieces);
      replace = true;
    }

    String name = pieces[0];
    int style = Font.PLAIN;  // equals zero
    if (pieces[1].indexOf("bold") != -1) {
      style |= Font.BOLD;
    }
    if (pieces[1].indexOf("italic") != -1) {
      style |= Font.ITALIC;
    }
    int size = PApplet.parseInt(pieces[2], 12);
    Font font = new Font(name, style, size);

    // replace bad font with the default
    if (replace) {
      set(attr, value);
    }

    return font;
  }
Example #5
0
 /**
  * Get a child by its name or path.
  *
  * @param name element name or path/to/element
  * @return the first matching element or null if no match
  */
 public XML getChild(String name) {
   if (name.length() > 0 && name.charAt(0) == '/') {
     throw new IllegalArgumentException("getChild() should not begin with a slash");
   }
   if (name.indexOf('/') != -1) {
     return getChildRecursive(PApplet.split(name, '/'), 0);
   }
   int childCount = getChildCount();
   for (int i = 0; i < childCount; i++) {
     XML kid = getChild(i);
     String kidName = kid.getName();
     if (kidName != null && kidName.equals(name)) {
       return kid;
     }
   }
   return null;
 }
Example #6
0
  public FloatHash(PApplet parent, String filename) {
    String[] lines = parent.loadStrings(filename);
    keys = new String[lines.length];
    values = new float[lines.length];

    //    boolean csv = (lines[0].indexOf('\t') == -1);

    for (int i = 0; i < lines.length; i++) {
      //      String[] pieces = csv ? Table.splitLineCSV(lines[i]) : PApplet.split(lines[i], '\t');
      String[] pieces = PApplet.split(lines[i], '\t');
      if (pieces.length == 2) {
        keys[count] = pieces[0];
        values[count] = PApplet.parseFloat(pieces[1]);
        count++;
      }
    }
  }
/*      */   public XMLElement[] getChildren(String path)
/*      */   {
/*  641 */     if (path.indexOf('/') != -1) {
/*  642 */       return getChildrenRecursive(PApplet.split(path, '/'), 0);
/*      */     }
/*      */     
/*      */ 
/*  646 */     if (Character.isDigit(path.charAt(0))) {
/*  647 */       return new XMLElement[] { getChild(Integer.parseInt(path)) };
/*      */     }
/*  649 */     int childCount = getChildCount();
/*  650 */     XMLElement[] matches = new XMLElement[childCount];
/*  651 */     int matchCount = 0;
/*  652 */     for (int i = 0; i < childCount; i++) {
/*  653 */       XMLElement kid = getChild(i);
/*  654 */       String kidName = kid.getName();
/*  655 */       if ((kidName != null) && (kidName.equals(path))) {
/*  656 */         matches[(matchCount++)] = kid;
/*      */       }
/*      */     }
/*  659 */     return (XMLElement[])PApplet.subset(matches, 0, matchCount);
/*      */   }
Example #8
0
 /**
  * Get any children that match this name or path. Similar to getChild(), but will grab multiple
  * matches rather than only the first.
  *
  * @param name element name or path/to/element
  * @return array of child elements that match
  * @author processing.org
  */
 public XML[] getChildren(String name) {
   if (name.length() > 0 && name.charAt(0) == '/') {
     throw new IllegalArgumentException("getChildren() should not begin with a slash");
   }
   if (name.indexOf('/') != -1) {
     return getChildrenRecursive(PApplet.split(name, '/'), 0);
   }
   // if it's a number, do an index instead
   // (returns a single element array, since this will be a single match
   if (Character.isDigit(name.charAt(0))) {
     return new XML[] {getChild(Integer.parseInt(name))};
   }
   int childCount = getChildCount();
   XML[] matches = new XML[childCount];
   int matchCount = 0;
   for (int i = 0; i < childCount; i++) {
     XML kid = getChild(i);
     String kidName = kid.getName();
     if (kidName != null && kidName.equals(name)) {
       matches[matchCount++] = kid;
     }
   }
   return (XML[]) PApplet.subset(matches, 0, matchCount);
 }
Example #9
0
  public Level(String filename, PixelPie pie) {
    XML file = pie.app.loadXML(filename);

    // Get level properties, if any.
    if (file.getChild("properties") != null) {
      properties = new StringDict();
      for (XML child : file.getChild("properties").getChildren("property")) {
        properties.set(child.getString("name"), child.getString("value"));
      }
    }

    // Get tile dimensions.
    tileWidth = file.getInt("tilewidth");
    tileHeight = file.getInt("tileheight");

    // Get Row and Column count.
    levelColumns = file.getInt("width");
    levelRows = file.getInt("height");

    // Get level dimensions.
    levelWidth = levelColumns * tileWidth;
    levelHeight = levelRows * tileHeight;

    // Get tileSets.
    tileSets = file.getChildren("tileset");

    // Get objects.
    objects = file.getChildren("objectgroup");

    // Get scripts.
    scripts = new HashMap<String, Script>();
    for (XML objectType : objects) {
      String objectName = objectType.getString("name");

      // Check type of object.
      if (objectName.substring(0, 1).equals("(")) {

        // Break up name into parts.
        String[] nameParts = PApplet.split(objectName, " ");

        // If script.
        if (nameParts[0].equals("(script)")) {

          // Grab script name.
          String name = nameParts[1];

          // Initialize coordinates array (if any).
          IntDict scriptCoords = new IntDict();

          // Check for objects in script layer. Get coordinates from these objects.
          if (objectType.getChild("object") != null) {
            for (XML coordObj : objectType.getChildren("object")) {

              // Check if object has a name, if not, skip it.
              if (coordObj.getString("name") == null) {
                pie.log.printlg("Script coordinate container does not have a name. Ignoring.");
                continue;
              }

              // Figure out object type.
              int coordType = 0;
              if (coordObj.hasChildren()) {
                coordType = (coordObj.getChild("polyline") != null) ? 2 : 1;
              }

              // Process coordinates depending on object type.
              switch (coordType) {

                  // If rectangle, take top-left corner.
                case 0:
                  scriptCoords.set(
                      coordObj.getString("name"),
                      PixelPie.coordToArray(coordObj.getInt("x"), coordObj.getInt("y"), this));
                  break;

                  // If ellipse, take center.
                case 1:
                  scriptCoords.set(
                      coordObj.getString("name"),
                      PixelPie.coordToArray(
                          coordObj.getInt("x") + coordObj.getInt("width") / 2,
                          coordObj.getInt("y") + coordObj.getInt("height") / 2,
                          this));
                  break;

                  // If poly line, record each point.
                case 2:
                  String[] coordsArray =
                      PApplet.split(coordObj.getChild("polyline").getString("points"), " ");
                  int startX = Integer.parseInt(objectType.getChild("object").getString("x"));
                  int startY = Integer.parseInt(objectType.getChild("object").getString("y"));
                  for (int i = 0; i < coordsArray.length; i++) {
                    scriptCoords.set(
                        coordObj.getString("name") + "_" + PApplet.nf(i, 2),
                        PixelPie.coordToArray(
                            startX + Integer.parseInt(PApplet.split(coordsArray[i], ",")[0]),
                            startY + Integer.parseInt(PApplet.split(coordsArray[i], ",")[1]),
                            this));
                  }
                  break;
              }
            }
          } else {
            scriptCoords = null;
          }

          // Get the total amount of frames.
          int endFrame = 0;
          for (XML obj : objectType.getChild("properties").getChildren("property")) {
            endFrame = PApplet.max(endFrame, PixelPie.getScriptFrame(obj.getString("name")));
          }

          // Create the scriptAction container "children".
          HashMap<String, ScriptAction[]> children = new HashMap<String, ScriptAction[]>();

          // Create the script object.
          Script Script = new Script(endFrame, scriptCoords, children, pie);
          scripts.put(name, Script);

          // Create scriptAction temporary container. This one uses a HashMap so we can dynamically
          // add scriptActions to it.
          HashMap<String, ArrayList<ScriptAction>> scriptTemp =
              new HashMap<String, ArrayList<ScriptAction>>();

          // Add scriptActions to the temporary container.
          for (XML obj : objectType.getChild("properties").getChildren("property")) {
            String frame = PApplet.str(PixelPie.getScriptFrame(obj.getString("name")));

            // Create scriptAction object from parameters.
            String[] actionArray = PApplet.split(obj.getString("value"), "(");
            String params = actionArray[1].substring(0, actionArray[1].length() - 1);
            ScriptAction action = null;
            // try {action = (scriptAction) Class.forName(app.getClass().getName() + "$script_" +
            // actionArray[0]).getDeclaredConstructors()[0].newInstance(new Object[]{app, params,
            // Script});}
            try {
              action =
                  (ScriptAction)
                      Class.forName(pie.app.getClass().getName() + "$script_" + actionArray[0])
                          .getDeclaredConstructors()[0]
                          .newInstance(new Object[] {pie.app});
              action.setup(params, Script);
            } catch (Exception e) {
              pie.log.printlg(e);
            }

            // Check whether there is an entry in the scriptTemp array.
            if (scriptTemp.get(frame) != null) {
              scriptTemp.get(frame).add(action);
            } else {
              // Initiate Arraylist.
              scriptTemp.put(frame, new ArrayList<ScriptAction>());
              scriptTemp.get(frame).add(action);
            }
          }

          // Turn over contents of temporary container to "children" array.
          for (@SuppressWarnings("rawtypes") Map.Entry entry : scriptTemp.entrySet()) {
            ScriptAction[] tempActions = new ScriptAction[scriptTemp.get(entry.getKey()).size()];
            for (int i = 0; i < scriptTemp.get(entry.getKey()).size(); i++) {
              tempActions[i] = scriptTemp.get(entry.getKey()).get(i);
            }
            children.put(entry.getKey().toString(), tempActions);
          }
        }
      }
    }

    // Load level layers.
    XML[] layers = file.getChildren("layer");

    // Count number of background and level layers.
    for (int i = 0; i < layers.length; i++) {
      if (layers[i].getString("name").substring(0, 4).equals("(bg)")) {
        backgroundLayers++;
      } else {
        levelLayers++;
      }
    }

    // Initiate arrays.
    background = new int[backgroundLayers][levelColumns * levelRows];
    levelMap = new int[levelLayers][levelColumns * levelRows];
    bgScroll = new float[backgroundLayers];

    // Process each layer.
    int currentLayer = 0;
    int bgCurrentLayer = 0;
    for (int i = 0; i < layers.length; i++) {

      // If it's a background layer...
      if (layers[i].getString("name").substring(0, 4).equals("(bg)")) {

        // Get properties.
        HashMap<String, String> prop = new HashMap<String, String>();
        for (XML property : layers[i].getChild("properties").getChildren("property")) {
          prop.put(property.getString("name"), property.getString("value"));
        }

        // Process the scroll rate.
        bgScroll[bgCurrentLayer] =
            PApplet.constrain(Float.parseFloat(PixelPie.getProp(prop, "scroll")), 0, 1);

        // Process each background tile.
        XML[] tiles = layers[i].getChild("data").getChildren("tile");
        for (int k = 0; k < tiles.length; k++) {
          background[bgCurrentLayer][k] = tiles[k].getInt("gid");
        }

        // Increase background layer counter.
        bgCurrentLayer++;
      }

      // Else, load layer as normal.
      else {
        // Load each tile.
        XML[] tiles = layers[i].getChild("data").getChildren("tile");
        for (int k = 0; k < tiles.length; k++) {
          levelMap[currentLayer][k] = tiles[k].getInt("gid");
        }
        currentLayer++;
      }
    }
  }
Example #10
0
 /** Parses a VertexList from the string produced by VertexList.toDataString(). */
 public UVertexList(String in) {
   String[] tok = PApplet.split(in, "\t");
   v = new UVec3[tok.length];
   for (int i = 0; i < tok.length; i++) add(UVec3.parse(tok[i]));
 }
Example #11
0
  protected String[] getMachineParams() {
    ArrayList<String> params = new ArrayList<String>();

    // params.add("-Xint"); // interpreted mode
    // params.add("-Xprof");  // profiler
    // params.add("-Xaprof");  // allocation profiler
    // params.add("-Xrunhprof:cpu=samples");  // old-style profiler

    // TODO change this to use run.args = true, run.args.0, run.args.1, etc.
    // so that spaces can be included in the arg names
    String options = Preferences.get("run.options");
    if (options.length() > 0) {
      String pieces[] = PApplet.split(options, ' ');
      for (int i = 0; i < pieces.length; i++) {
        String p = pieces[i].trim();
        if (p.length() > 0) {
          params.add(p);
        }
      }
    }

    //    params.add("-Djava.ext.dirs=nuffing");

    if (Preferences.getBoolean("run.options.memory")) {
      params.add("-Xms" + Preferences.get("run.options.memory.initial") + "m");
      params.add("-Xmx" + Preferences.get("run.options.memory.maximum") + "m");
    }

    if (Base.isMacOS()) {
      params.add("-Xdock:name=" + build.getSketchClassName());
      //      params.add("-Dcom.apple.mrj.application.apple.menu.about.name=" +
      //                 sketch.getMainClassName());
    }
    // sketch.libraryPath might be ""
    // librariesClassPath will always have sep char prepended
    params.add(
        "-Djava.library.path="
            + build.getJavaLibraryPath()
            + File.pathSeparator
            + System.getProperty("java.library.path"));

    params.add("-cp");
    params.add(build.getClassPath());
    //    params.add(sketch.getClassPath() +
    //        File.pathSeparator +
    //        Base.librariesClassPath);

    // enable assertions
    // http://dev.processing.org/bugs/show_bug.cgi?id=1188
    params.add("-ea");
    // PApplet.println(PApplet.split(sketch.classPath, ':'));

    String outgoing[] = new String[params.size()];
    params.toArray(outgoing);

    //    PApplet.println(outgoing);
    //    PApplet.println(PApplet.split(outgoing[0], ":"));
    //    PApplet.println();
    //    PApplet.println("class path");
    //    PApplet.println(PApplet.split(outgoing[2], ":"));

    return outgoing;
    // return (String[]) params.toArray();

    //  System.out.println("sketch class path");
    //  PApplet.println(PApplet.split(sketch.classPath, ';'));
    //  System.out.println();
    //  System.out.println("libraries class path");
    //  PApplet.println(PApplet.split(Base.librariesClassPath, ';'));
    //  System.out.println();
  }
Example #12
0
  /**
   * Format this XML data as a String.
   *
   * @webref xml:method
   * @brief Formats XML data as a String
   * @param indent -1 for a single line (and no declaration), >= 0 for indents and newlines
   * @return the content
   * @see XML#toString()
   */
  public String format(int indent) {
    try {
      // entities = doctype.getEntities()
      boolean useIndentAmount = false;
      TransformerFactory factory = TransformerFactory.newInstance();
      if (indent != -1) {
        try {
          factory.setAttribute("indent-number", indent);
        } catch (IllegalArgumentException e) {
          useIndentAmount = true;
        }
      }
      Transformer transformer = factory.newTransformer();

      // Add the XML declaration at the top if this node is the root and we're
      // not writing to a single line (indent = -1 means single line).
      if (indent == -1 || parent == null) {
        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
      } else {
        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
      }

      //      transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "sample.dtd");

      transformer.setOutputProperty(OutputKeys.METHOD, "xml");

      //      transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "yes");  // huh?

      //      transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC,
      //          "-//W3C//DTD XHTML 1.0 Transitional//EN");
      //      transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,
      //          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd");

      // For Android, because (at least 2.3.3) doesn't like indent-number
      if (useIndentAmount) {
        transformer.setOutputProperty(
            "{http://xml.apache.org/xslt}indent-amount", String.valueOf(indent));
      }

      //      transformer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
      //      transformer.setOutputProperty(OutputKeys.ENCODING,"UTF8");
      transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
      //      transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS

      // Always indent, otherwise the XML declaration will just be jammed
      // onto the first line with the XML code as well.
      transformer.setOutputProperty(OutputKeys.INDENT, "yes");

      //      Properties p = transformer.getOutputProperties();
      //      for (Object key : p.keySet()) {
      //        System.out.println(key + " -> " + p.get(key));
      //      }

      // If you smell something, that's because this code stinks. No matter
      // the settings of the Transformer object, if the XML document already
      // has whitespace elements, it won't bother re-indenting/re-formatting.
      // So instead, transform the data once into a single line string.
      // If indent is -1, then we're done. Otherwise re-run and the settings
      // of the factory will kick in. If you know a better way to do this,
      // please contribute. I've wasted too much of my Sunday on it. But at
      // least the Giants are getting blown out by the Falcons.

      final String decl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
      final String sep = System.getProperty("line.separator");

      StringWriter tempWriter = new StringWriter();
      StreamResult tempResult = new StreamResult(tempWriter);
      transformer.transform(new DOMSource(node), tempResult);
      String[] tempLines = PApplet.split(tempWriter.toString(), sep);
      //      PApplet.println(tempLines);
      if (tempLines[0].startsWith("<?xml")) {
        // Remove XML declaration from the top before slamming into one line
        int declEnd = tempLines[0].indexOf("?>") + 2;
        // if (tempLines[0].length() == decl.length()) {
        if (tempLines[0].length() == declEnd) {
          // If it's all the XML declaration, remove it
          //          PApplet.println("removing first line");
          tempLines = PApplet.subset(tempLines, 1);
        } else {
          //          PApplet.println("removing part of first line");
          // If the first node has been moved to this line, be more careful
          // tempLines[0] = tempLines[0].substring(decl.length());
          tempLines[0] = tempLines[0].substring(declEnd);
        }
      }
      String singleLine = PApplet.join(PApplet.trim(tempLines), "");
      if (indent == -1) {
        return singleLine;
      }

      // Might just be whitespace, which won't be valid XML for parsing below.
      // https://github.com/processing/processing/issues/1796
      // Since indent is not -1, that means they want valid XML,
      // so we'll give them the single line plus the decl... Lame? sure.
      if (singleLine.trim().length() == 0) {
        // You want whitespace? I've got your whitespace right here.
        return decl + sep + singleLine;
      }

      // Since the indent is not -1, bring back the XML declaration
      // transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");

      StringWriter stringWriter = new StringWriter();
      StreamResult xmlOutput = new StreamResult(stringWriter);
      //      DOMSource source = new DOMSource(node);
      Source source = new StreamSource(new StringReader(singleLine));
      transformer.transform(source, xmlOutput);
      String outgoing = stringWriter.toString();

      // Add the XML declaration to the top if it's not there already
      if (outgoing.startsWith(decl)) {
        int declen = decl.length();
        int seplen = sep.length();
        if (outgoing.length() > declen + seplen
            && !outgoing.substring(declen, declen + seplen).equals(sep)) {
          // make sure there's a line break between the XML decl and the code
          return outgoing.substring(0, decl.length()) + sep + outgoing.substring(decl.length());
        }
        return outgoing;
      } else {
        return decl + sep + outgoing;
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
  /**
   * Processes import statements to obtain classpaths of contributed libraries. This would be needed
   * for compilation check. Also, adds stuff(jar files, class files, candy) from the code folder.
   * And it looks messed up.
   */
  private void prepareCompilerClasspath() {
    if (!loadCompClass) return;
    // System.out.println("1..");
    classpathJars = new ArrayList<URL>();
    String entry = "";
    boolean codeFolderChecked = false;
    for (ImportStatement impstat : programImports) {
      String item = impstat.importName;
      int dot = item.lastIndexOf('.');
      entry = (dot == -1) ? item : item.substring(0, dot);

      entry = entry.substring(6).trim();
      // System.out.println("Entry--" + entry);
      if (ignorableImport(entry)) {
        // System.out.println("Ignoring: " + entry);
        continue;
      }
      Library library = null;

      // Try to get the library classpath and add it to the list
      try {
        library = editor.getMode().getLibrary(entry);
        // System.out.println("lib->" + library.getClassPath() + "<-");
        String libraryPath[] =
            PApplet.split(library.getClassPath().substring(1).trim(), File.pathSeparatorChar);
        for (int i = 0; i < libraryPath.length; i++) {
          // System.out.println(entry + " ::"
          // + new File(libraryPath[i]).toURI().toURL());
          classpathJars.add(new File(libraryPath[i]).toURI().toURL());
        }
        // System.out.println("-- ");
        // classpath[count] = (new File(library.getClassPath()
        // .substring(1))).toURI().toURL();
        // System.out.println("  found ");
        // System.out.println(library.getClassPath().substring(1));
      } catch (Exception e) {
        if (library == null && !codeFolderChecked) {
          // System.out.println(1);
          // Look around in the code folder for jar files
          if (editor.getSketch().hasCodeFolder()) {
            File codeFolder = editor.getSketch().getCodeFolder();

            // get a list of .jar files in the "code" folder
            // (class files in subfolders should also be picked up)
            String codeFolderClassPath = Base.contentsToClassPath(codeFolder);
            codeFolderChecked = true;
            if (codeFolderClassPath.equalsIgnoreCase("")) {
              System.err.println(
                  "XQMODE: Yikes! Can't find \""
                      + entry
                      + "\" library! Line: "
                      + impstat.lineNumber
                      + " in tab: "
                      + editor.getSketch().getCode(impstat.tab).getPrettyName());
              System.out.println(
                  "Please make sure that the library is present in <sketchbook "
                      + "folder>/libraries folder or in the code folder of your sketch");
            }
            String codeFolderPath[] =
                PApplet.split(codeFolderClassPath.substring(1).trim(), File.pathSeparatorChar);
            try {
              for (int i = 0; i < codeFolderPath.length; i++) {
                classpathJars.add(new File(codeFolderPath[i]).toURI().toURL());
              }

            } catch (Exception e2) {
              System.out.println("Yikes! codefolder, prepareImports(): " + e2);
            }
          } else {
            System.err.println(
                "XQMODE: Yikes! Can't find \""
                    + entry
                    + "\" library! Line: "
                    + impstat.lineNumber
                    + " in tab: "
                    + editor.getSketch().getCode(impstat.tab).getPrettyName());
            System.out.println(
                "Please make sure that the library is present in <sketchbook "
                    + "folder>/libraries folder or in the code folder of your sketch");
          }

        } else {
          System.err.println("Yikes! There was some problem in prepareImports(): " + e);
          System.err.println("I was processing: " + entry);

          // e.printStackTrace();
        }
      }
    }
  }
Example #14
0
  /**
   * Change internal settings based on what was chosen in the prefs,
   * then send a message to the editor saying that it's time to do the same.
   */
  protected void applyFrame() {
    // put each of the settings into the table
    setBoolean("build.verbose", verboseCompilationBox.isSelected());
    setBoolean("upload.verbose", verboseUploadBox.isSelected());
    setBoolean("upload.verify", verifyUploadBox.isSelected());

//    setBoolean("sketchbook.closing_last_window_quits",
//               closingLastQuitsBox.isSelected());
    //setBoolean("sketchbook.prompt", sketchPromptBox.isSelected());
    //setBoolean("sketchbook.auto_clean", sketchCleanBox.isSelected());

    // if the sketchbook path has changed, rebuild the menus
    String oldPath = get("sketchbook.path");
    String newPath = sketchbookLocationField.getText();
    if (!newPath.equals(oldPath)) {
      editor.base.rebuildSketchbookMenus();
      set("sketchbook.path", newPath);
    }

    setBoolean("editor.external", externalEditorBox.isSelected());
    setBoolean("update.check", checkUpdatesBox.isSelected());

    /*
      // was gonna use this to check memory settings,
      // but it quickly gets much too messy
    if (getBoolean("run.options.memory")) {
      Process process = Runtime.getRuntime().exec(new String[] {
          "java", "-Xms" + memoryMin + "m", "-Xmx" + memoryMax + "m"
        });
      processInput = new SystemOutSiphon(process.getInputStream());
      processError = new MessageSiphon(process.getErrorStream(), this);
    }
    */

    String newSizeText = fontSizeField.getText();
    try {
      int newSize = Integer.parseInt(newSizeText.trim());
      String pieces[] = PApplet.split(get("editor.font"), ',');
      pieces[2] = String.valueOf(newSize);
      set("editor.font", PApplet.join(pieces, ','));

    } catch (Exception e) {
      System.err.println(I18n.format(_("ignoring invalid font size {0}"), newSizeText));
    }

    if (autoAssociateBox != null) {
      setBoolean("platform.auto_file_type_associations",
                 autoAssociateBox.isSelected());
    }

    setBoolean("editor.update_extension", updateExtensionBox.isSelected());

    // adds the selected language to the preferences file
    Object newItem = comboLanguage.getSelectedItem();
    int pos = (Arrays.asList(languages)).indexOf(newItem.toString());  // position in the languages array
    set("editor.languages.current",(Arrays.asList(languagesISO)).get(pos));

    set("tftp.secretPass",tftpPassField.getText());
    if (domainPortField.getText().contains(":")){
      set("tftp.domain",domainPortField.getText().split(":")[0]);
      try{
        set("tftp.port",String.valueOf(Integer.parseInt(domainPortField.getText().split(":")[1])));
      }catch (NumberFormatException nfe){
        set("tftp.port","69");
      }
    }else{
      set("tftp.domain",domainPortField.getText());
      set("tftp.port","69");
    }
    if ("".equals(autoResetPortField.getText())){
      set("tftp.autoreset","46969");
    }else{
      try{
        set("tftp.autoreset",String.valueOf(Integer.parseInt(autoResetPortField.getText())));
      }catch (NumberFormatException nfe){
        set("tftp.autoreset","46969");
      }
    }

      editor.applyPreferences();
  }