Пример #1
0
  private void exportNode(PropWriter w, DynamicNode node, boolean includeVar, File dir) {
    p("doing node: " + node);
    String[] visualOnlyProps = new String[] {"x", "y", "width", "height"};
    List<String> resizeOnlyProps = Arrays.asList("width", "height");

    if (includeVar) {
      w.newObj(node.getId(), AminoAdapter.getScriptClass(node));
    } else {
      w.newObj(AminoAdapter.getScriptClass(node));
    }
    w.indent();
    for (Property prop : node.getProperties()) {
      if (!AminoAdapter.shouldExportProperty(node, prop)) continue;
      p(
          "writing: "
              + prop.getName()
              + " "
              + prop.getRawValue()
              + " exported = "
              + prop.isExported());
      String key = prop.getName();
      if (key.equals("translateX")) key = "x";
      if (key.equals("translateY")) key = "y";
      if (!node.isVisual() && Arrays.asList(visualOnlyProps).contains(key)) continue;
      if (key.equals("width") && !canResizeHorizontal(node)) continue;
      if (key.equals("height") && !canResizeVertical(node)) continue;
      if (key.equals("draggable")) continue;
      if (key.equals("src") && node.getName().equals("Image")) {
        try {
          URL srcURL = new URL(prop.getStringValue());
          File dstFile = calcUniqueImageName(dir);
          StringUtils.copyFile(srcURL, dstFile);
          w.prop(key, dstFile.getName());
          continue;
        } catch (IOException e) {
          e
              .printStackTrace(); // To change body of catch statement use File | Settings | File
                                  // Templates.
        }
      }
      w.prop(key, prop.getRawValue());
    }

    for (SketchNode child : node.children()) {
      w.p(".add(");
      exportNode(w, (DynamicNode) child, false, dir);
      w.p(")");
    }
    if (includeVar) {
      w.p(";");
    }
    w.outdent();
  }
Пример #2
0
 private void execAndWait(String s) throws InterruptedException {
   ProcessBuilder pb = new ProcessBuilder(s, "convert_xml_to_js.js");
   pb.directory(new File("/Users/josh/projects/compilerclass/guitest2/"));
   try {
     Process proc = pb.start();
     proc.waitFor();
     p("processing");
   } catch (IOException e) {
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   }
 }