Пример #1
0
 private void doExtensions(StringWriter setupContent, DynamicNode dnode) {
   if (dnode.hasProperty("draggable")) {
     if (dnode.getProperty("draggable").getBooleanValue()) {
       setupContent.append("setupDraggable(" + dnode.getId() + ",root);\n");
     }
   }
 }
Пример #2
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();
  }
Пример #3
0
 private boolean canResizeHorizontal(DynamicNode node) {
   if (node.getResize() == Resize.Any) return true;
   if (node.getResize() == Resize.HorizontalOnly) return true;
   return false;
 }
Пример #4
0
 private boolean canResizeVertical(DynamicNode node) {
   if (node.getResize() == Resize.Any) return true;
   if (node.getResize() == Resize.VerticalOnly) return true;
   return false;
 }