public void quadTo(Position p1, Position p2) { checkMoveTo(); points.add(2); points.add((int) p1.getX()); points.add((int) p1.getY()); points.add((int) p2.getX()); points.add((int) p2.getY()); }
public void curveTo(int x1, int y1, int x2, int y2, int x3, int y3) { checkMoveTo(); points.add(3); points.add(x1); points.add(y1); points.add(x2); points.add(y2); points.add(x3); points.add(y3); }
@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(); } }
/** * 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}; }
public ExampleClass() { list.add("hola"); list.add("buenos"); list.add("días"); }
/** * 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"); } }
public Iterator<Condition> getConditionsIterator() { return conditions.iterator(); }
public boolean removeCondition(Condition condition) { if (conditions.size() == 1) return false; else return (conditions.remove(condition)); }
public void replaceCondition(Condition oldCondition, Condition newCondition) { if (conditions.remove(oldCondition)) conditions.add(newCondition); }
public void addCondition(Condition condition) { conditions.add(condition); }
private void checkMoveTo() { if (points.size() == 0) { points.add(0); points.add(0); } }
public void lineTo(Position p) { checkMoveTo(); points.add(1); points.add((int) p.getX()); points.add((int) p.getY()); }
/** * Resets the shape and sets the initial point to x and y * * @param x x coordinate * @param y y coordinate */ public void moveTo(int x, int y) { points.add(x); points.add(y); closed = false; }