@Override public boolean add(Figure figure) { add(getChildCount(), figure); return true; }
public void addAll(Collection<? extends Figure> figures) { addAll(getChildCount(), figures); }
@Override public void add(int index, Figure figure) { basicAdd(index, figure); if (getDrawing() != null) { figure.addNotify(getDrawing()); } fireFigureAdded(figure, index); invalidate(); }
@Override public void basicAdd(Figure figure) { basicAdd(getChildCount(), figure); }
/** * Brings a figure to the front of the drawing. * * @param figure that is part of the drawing */ public void bringToFront(Figure figure) { if (basicRemove(figure) != -1) { basicAdd(figure); fireAreaInvalidated(figure.getDrawingArea()); } }
/** * Removes all specified children. * * @see #add */ public void removeAll(Collection<? extends Figure> figures) { willChange(); for (Figure f : new LinkedList<Figure>(figures)) { remove(f); } changed(); }
@Override public boolean remove(final Figure figure) { int index = children.indexOf(figure); if (index == -1) { return false; } else { basicRemoveChild(index); if (getDrawing() != null) { figure.removeNotify(getDrawing()); } fireFigureRemoved(figure, index); return true; } }
/** * Removes all children. * * @see #add */ @Override public void basicRemoveAllChildren() { for (Figure f : new LinkedList<Figure>(getChildren())) { basicRemove(f); } }
@Override public Figure removeChild(int index) { Figure removed = basicRemoveChild(index); if (getDrawing() != null) { removed.removeNotify(getDrawing()); } return removed; }
@Override public AbstractAttributedCompositeFigure clone() { AbstractAttributedCompositeFigure that = (AbstractAttributedCompositeFigure) super.clone(); that.attributes = new HashMap<AttributeKey, Object>(this.attributes); if (this.forbiddenAttributes != null) { that.forbiddenAttributes = new HashSet<AttributeKey>(this.forbiddenAttributes); } return that; }
public void basicAddAll(int index, Collection<? extends Figure> newFigures) { for (Figure f : newFigures) { basicAdd(index++, f); } }
public AbstractCompositeFigure() { eventHandler = createEventHandler(); }
/** * Removes all children. * * @see #add */ public void basicRemoveAll(Collection<? extends Figure> figures) { for (Figure f : figures) { basicRemove(f); } }
@Override public int basicRemove(Figure child) { int index = children.indexOf(child); if (index != -1) { basicRemoveChild(index); } return index; }
@Override public void addNotify(Drawing drawing) { super.addNotify(drawing); if (getPresentationFigure() != null) { getPresentationFigure().addNotify(drawing); } }
@Override public boolean contains(Point2D.Double p) { boolean contains = super.contains(p); if (!contains && getPresentationFigure() != null) { contains = getPresentationFigure().contains(p); } return contains; }
/** * Sends a figure to the back of the composite figure. * * @param figure that is part of this composite figure */ public void sendToBack(Figure figure) { if (basicRemove(figure) != -1) { basicAdd(0, figure); fireAreaInvalidated(figure.getDrawingArea()); } }
@Override @SuppressWarnings("unchecked") public GraphicalCompositeFigure clone() { GraphicalCompositeFigure that = (GraphicalCompositeFigure) super.clone(); that.presentationFigure = (this.presentationFigure == null) ? null : (Figure) this.presentationFigure.clone(); if (that.presentationFigure != null) { that.presentationFigure.addFigureListener(that.presentationFigureHandler); } that.attributes=(HashMap<AttributeKey, Object>) this.attributes.clone(); that.forbiddenAttributes= this.forbiddenAttributes==null?null:(HashSet<AttributeKey>) this.forbiddenAttributes.clone(); return that; }
@Override public void read(DOMInput in) throws IOException { in.openElement("children"); for (int i = 0; i < in.getElementCount(); i++) { basicAdd((Figure) in.readObject(i)); } in.closeElement(); }
@Override public AbstractCompositeFigure clone() { AbstractCompositeFigure that = (AbstractCompositeFigure) super.clone(); that.children = new ArrayList<Figure>(); that.eventHandler = that.createEventHandler(); for (Figure thisChild : this.children) { Figure thatChild = (Figure) thisChild.clone(); that.children.add(thatChild); thatChild.addFigureListener(that.eventHandler); } return that; }