@Override public void add(final int index, final Figure figure) { super.add(index, (SVGBezierFigure) figure); }
@Override public SVGPathFigure clone() { SVGPathFigure that = (SVGPathFigure) super.clone(); return that; }
public <T> void removeAttribute(AttributeKey<T> key) { if (hasAttribute(key)) { T oldValue = get(key); attributes.remove(key); fireAttributeChanged(key, oldValue, key.getDefaultValue()); } }
/** * Sets an attribute of the figure. * AttributeKey name and semantics are defined by the class implementing * the figure interface. */ @Override public <T> void set(AttributeKey<T> key, T newValue) { if (forbiddenAttributes == null || !forbiddenAttributes.contains(key)) { Object oldValue = attributes.put(key, newValue); setAttributeOnChildren(key, newValue); fireAttributeChanged(key, oldValue, newValue); } }
public void drawFigure(Graphics2D g) { drawChildren(g); if (get(FILL_COLOR) != null) { g.setColor(get(FILL_COLOR)); drawFill(g); } if (get(STROKE_COLOR) != null && get(STROKE_WIDTH) > 0d) { g.setStroke(AttributeKeys.getStroke(this)); g.setColor(get(STROKE_COLOR)); drawStroke(g); } if (get(TEXT_COLOR) != null) { if (get(TEXT_SHADOW_COLOR) != null && get(TEXT_SHADOW_OFFSET) != null) { Dimension2DDouble d = get(TEXT_SHADOW_OFFSET); g.translate(d.width, d.height); g.setColor(get(TEXT_SHADOW_COLOR)); drawText(g); g.translate(-d.width, -d.height); } g.setColor(get(TEXT_COLOR)); drawText(g); } }
@Override public Object getAttributesRestoreData() { LinkedList<Object> list = new LinkedList<Object>(); list.add(new HashMap<AttributeKey, Object>(getAttributes())); for (Figure child : getChildren()) { list.add(child.getAttributesRestoreData()); } return list; }
@SuppressWarnings("unchecked") protected void readAttributes(DOMInput in) throws IOException { if (in.getElementCount("a") > 0) { in.openElement("a"); for (int i = in.getElementCount() - 1; i >= 0; i--) { in.openElement(i); String name = in.getTagName(); Object value = in.readObject(); AttributeKey key = getAttributeKey(name); if (key != null && key.isAssignable(value)) { if (forbiddenAttributes == null || !forbiddenAttributes.contains(key)) { set(key, value); } } in.closeElement(); } in.closeElement(); } }
public double getStrokeMiterLimitFactor() { Number value = (Number) get(AttributeKeys.STROKE_MITER_LIMIT); return (value != null) ? value.doubleValue() : 10f; }
protected void writeAttributes(DOMOutput out) throws IOException { Figure prototype = (Figure) out.getPrototype(); boolean isElementOpen = false; for (Map.Entry<AttributeKey, Object> entry : attributes.entrySet()) { AttributeKey key = entry.getKey(); if (forbiddenAttributes == null || !forbiddenAttributes.contains(key)) { @SuppressWarnings("unchecked") Object prototypeValue = prototype.get(key); @SuppressWarnings("unchecked") Object attributeValue = get(key); if (prototypeValue != attributeValue || (prototypeValue != null && attributeValue != null && !prototypeValue.equals(attributeValue))) { if (!isElementOpen) { out.openElement("a"); isElementOpen = true; } out.openElement(key.getKey()); out.writeObject(entry.getValue()); out.closeElement(); } } } if (isElementOpen) { out.closeElement(); } }
@Override public ODGPathFigure clone() { ODGPathFigure that = (ODGPathFigure) super.clone(); return that; }
@Override public void add(final int index, final Figure figure) { super.add(index, (ODGBezierFigure) figure); }
@Override @SuppressWarnings("unchecked") public AbstractDrawing clone() { AbstractDrawing that = (AbstractDrawing) super.clone(); that.inputFormats = (this.inputFormats == null) ? null : (LinkedList<InputFormat>) this.inputFormats.clone(); that.outputFormats = (this.outputFormats == null) ? null : (LinkedList<OutputFormat>) this.outputFormats.clone(); return that; } }