Beispiel #1
0
 @Override
 public String toString() {
   if (conditions.isEmpty()) {
     return "Empty list";
   } else {
     StringBuilder value = new StringBuilder("(");
     value.append(conditions.get(0));
     for (int i = 1; i < conditions.size(); i++) {
       value.append(" ").append(operator).append(" ").append(conditions.get(i));
     }
     return value.append(")").toString();
   }
 }
Beispiel #2
0
 /**
  * Translates the shape to match its top left corner with (0, 0)
  *
  * @return the translation made in X and Y axis
  */
 public Integer[] removeOffset() {
   int i = 0;
   int minX = points.get(i++);
   int minY = points.get(i++);
   while (i < getPoints().size()) {
     int points = getPoints().get(i++);
     boolean x = true;
     for (int j = 0; j < points * 2; j++) {
       int value = getPoints().get(i++);
       if (x) {
         minX = Math.min(value, minX);
       } else {
         minY = Math.min(value, minY);
       }
       x = !x;
     }
   }
   EAdList<Integer> newPoints = new EAdList<Integer>();
   i = 0;
   newPoints.add(points.get(i++) - minX);
   newPoints.add(points.get(i++) - minY);
   while (i < getPoints().size()) {
     int points = getPoints().get(i++);
     newPoints.add(points);
     boolean x = true;
     for (int j = 0; j < points * 2; j++) {
       int value = getPoints().get(i++);
       if (x) {
         newPoints.add(value - minX);
       } else {
         newPoints.add(value - minY);
       }
       x = !x;
     }
   }
   this.setPoints(newPoints);
   return new Integer[] {minX, minY};
 }
Beispiel #3
0
  /**
   * Returns a descriptive string for a given object.
   *
   * @param o object to drive into.
   * @return
   */
  @SuppressWarnings("unchecked")
  private void appendDescription(
      EditorModel m, Object o, StringBuilder sb, int depth, int maxDepth) {
    if (maxDepth == depth) {
      return;
    }

    String indent = new String(new char[depth * 2]).replace('\0', ' ');

    if (o == null) {
      sb.append("(null)");
      return;
    }

    String id = "" + m.getEditorId(o);
    String cname = o.getClass().getSimpleName();
    if (o instanceof BasicElement) {
      sb.append(indent + cname + " (" + id + ")" + "\n");
      if (depth != maxDepth) {
        appendDependencies(this, m, sb);
      }
      appendParams(m, o, sb, depth, maxDepth);

    } else if (o instanceof EAdList) {
      EAdList target = (EAdList) o;
      sb.append(indent + cname + " (" + id + ")" + "\n");
      if (target.size() == 0) {
        sb.append(indent + "  (empty)\n");
      } else if (depth == maxDepth - 1) {
        sb.append(indent + "  (" + target.size() + " elements inside)\n");
      } else {
        for (int i = 0; i < target.size(); i++) {
          // visit all children-values of this list
          Object inner = target.get(i);
          if (inner != null) {
            appendDescription(m, inner, sb, depth + 1, maxDepth);
          }
        }
      }
    } else if (o instanceof EAdMap) {
      EAdMap<?> target = (EAdMap<?>) o;
      sb.append(indent + cname + " (" + id + ")" + "\n");
      int i = 0;
      if (target.size() == 0) {
        sb.append(indent + "  (empty)\n");
      } else if (depth == maxDepth - 1) {
        sb.append(indent + "  (" + target.size() + " elements inside)\n");
      } else {
        for (Map.Entry<?, ?> e : target.entrySet()) {
          if (e.getKey() != null) {
            appendDescription(m, e.getKey(), sb, depth + 1, maxDepth);
          }
          sb.append(indent + "  -m->\n");
          if (e.getValue() != null) {
            appendDescription(m, e.getValue(), sb, depth + 1, maxDepth);
          }
          i++;
        }
      }
    } else if (o instanceof EAdParam) {
      sb.append(indent + ((EAdParam) o).toStringData());
    } else if (o instanceof AssetDescriptor) {
      sb.append(indent + "asset" + " (" + id + "): " + ((AssetDescriptor) o).getId() + "\n");
      appendParams(m, o, sb, depth, maxDepth);
      if (depth != maxDepth) {
        appendDependencies(this, m, sb);
      }
    } else if (o instanceof Class) {
      sb.append(indent + ((Class<?>) o).getName() + "\n");
    } else {
      sb.append(indent + " (" + cname + "~" + o.toString() + ")\n");
    }
  }