Documentation of 'org.jhotdraw.draw.AbstractCompositeFigure' Java class
AbstractCompositeFigure
org.jhotdraw.draw

Class AbstractCompositeFigure

    • Constructor Detail

      • AbstractCompositeFigure

        public AbstractCompositeFigure()
    • Method Detail

      • createHandles

        public java.util.Collection<Handle> createHandles(int detailLevel)
        Description copied from interface: Figure
        Creates handles used to manipulate the figure.
        Specified by:
        createHandles in interface Figure
        Overrides:
        createHandles in class AbstractFigure
        Parameters:
        detailLevel - The detail level of the handles. Usually this is 0 for bounding box handles and 1 for point handles. The value -1 is used by the SelectAreaTracker and the HandleTracker to highlight figures, over which the mouse pointer is hovering.
        Returns:
        a Collection of handles
        See Also:
        Handle
      • add

        public boolean add(Figure figure)
        Description copied from interface: CompositeFigure
        Adds a child to the figure.

        This is a convenience method for add(getChildCount(), child);

        This method calls figureAdded on all registered CompositeFigureListeners.

        Specified by:
        add in interface CompositeFigure
        Returns:
        true if this CompositeFigure changed as a result of the call
      • add

        public void add(int index,
                        Figure figure)
        Description copied from interface: CompositeFigure
        Adds a child to the figure at the specified index.

        This method calls figureAdded on all registered CompositeFigureListeners.

        Specified by:
        add in interface CompositeFigure
      • addAll

        public void addAll(java.util.Collection<? extends Figure> figures)
      • addAll

        public final void addAll(int index,
                                 java.util.Collection<? extends Figure> figures)
      • basicAdd

        public void basicAdd(Figure figure)
        Description copied from interface: CompositeFigure
        Adds a child to the figure without firing events.

        This method can be used to reinsert a child figure which has been temporarily removed from this CompositeFigure (for example to reorder the sequence of the children) and to efficiently build a drawing from an InputFormat. This is a convenience method for calling basicAdd(getChildCount(), child);.

        Specified by:
        basicAdd in interface CompositeFigure
      • basicAddAll

        public void basicAddAll(int index,
                                java.util.Collection<? extends Figure> newFigures)
      • addNotify

        public void addNotify(Drawing drawing)
        Description copied from interface: Figure
        Informs a figure, that it has been added to a drawing. The figure must inform all FigureListeners that it has been added.
        Specified by:
        addNotify in interface Figure
        Overrides:
        addNotify in class AbstractFigure
      • removeNotify

        public void removeNotify(Drawing drawing)
        Description copied from interface: Figure
        Informs a figure, that it has been removed from a drawing. The figure must inform all FigureListeners that it has been removed.
        Specified by:
        removeNotify in interface Figure
        Overrides:
        removeNotify in class AbstractFigure
      • remove

        public boolean remove(Figure figure)
        Description copied from interface: CompositeFigure
        Removes the specified child. Returns true, if the Figure contained the removed child.

        This is a convenience method for calling removeChild(getChildren().indexOf(child));

        This method calls figureRemoved on all registered CompositeFigureListener's.

        Specified by:
        remove in interface CompositeFigure
      • removeChild

        public Figure removeChild(int index)
        Description copied from interface: CompositeFigure
        Removes the child at the specified index. Returns the removed child figure.

        Calls figureRemoved on all registered CompositeFigureListener's.

        Specified by:
        removeChild in interface CompositeFigure
      • sendToBack

        public void sendToBack(Figure figure)
        Sends a figure to the back of the composite figure.
        Parameters:
        figure - that is part of this composite figure
      • bringToFront

        public void bringToFront(Figure figure)
        Brings a figure to the front of the drawing.
        Parameters:
        figure - that is part of the drawing
      • setBounds

        public void setBounds(java.awt.geom.Point2D.Double anchor,
                              java.awt.geom.Point2D.Double lead)
        Description copied from interface: Figure
        Sets the logical and untransformed bounds of the figure.

        This is used by Tool's which create a new Figure and by Tool's which connect a Figure to another Figure.

        This is a basic operation which does not fire events. Use the following code sequence, if you need event firing:

         figure.willChange();
         figure.setBounds(...);
         figure.changed();
         
        Specified by:
        setBounds in interface Figure
        Overrides:
        setBounds in class AbstractFigure
        Parameters:
        anchor - the start point of the bounds
        lead - the end point of the bounds
        See Also:
        Figure.getBounds()
      • getChildrenFrontToBack

        public java.util.List<Figure> getChildrenFrontToBack()
        Returns an iterator to iterate in Z-order front to back over the children.
      • set

        public <T> void set(AttributeKey<T> key,
                            T value)
        Description copied from interface: Figure
        Sets an attribute on the figure and calls attributeChanged on all registered FigureListeners if the attribute value has changed.

        For efficiency reasons, the drawing is not automatically repainted. If you want the drawing to be repainted when the attribute is changed, you can either use key.set(figure, value); or

         figure.willChange();
         figure.set(...);
         figure.changed();
         
        Specified by:
        set in interface Figure
        See Also:
        AttributeKey.set(org.jhotdraw.draw.Figure, T)
      • get

        public <T> T get(AttributeKey<T> name)
        Description copied from interface: Figure
        Gets an attribute from the Figure.
        Specified by:
        get in interface Figure
        Returns:
        Returns the attribute value. If the Figure does not have an attribute with the specified key, returns key.getDefaultValue().
        See Also:
        AttributeKey.get(org.jhotdraw.draw.Figure)
      • getAttributes

        public java.util.Map<AttributeKey,java.lang.Object> getAttributes()
        Description copied from interface: Figure
        Returns a view to all attributes of this figure. By convention, an unmodifiable map is returned.
        Specified by:
        getAttributes in interface Figure
      • getAttributesRestoreData

        public java.lang.Object getAttributesRestoreData()
        Description copied from interface: Figure
        Gets data which can be used to restore the attributes of the figure after a set has been applied to it.
        Specified by:
        getAttributesRestoreData in interface Figure
      • restoreAttributesTo

        public void restoreAttributesTo(java.lang.Object newData)
        Description copied from interface: Figure
        Restores the attributes of the figure to a previously stored state.
        Specified by:
        restoreAttributesTo in interface Figure
      • contains

        public boolean contains(Figure f)
        Description copied from interface: CompositeFigure
        Returns true if this composite figure contains the specified figure.

        This is a convenience method for calling getChildren().contains(f);.

        Specified by:
        contains in interface CompositeFigure
      • contains

        public boolean contains(java.awt.geom.Point2D.Double p)
        Description copied from interface: Figure
        Checks if a point is contained by the figure.

        This is used for hit testing by Tool's.

        Specified by:
        contains in interface Figure
      • findFigureInside

        @Nullable
        public Figure findFigureInside(java.awt.geom.Point2D.Double p)
        Description copied from interface: Figure
        Finds the innermost figure at the specified location.

        In case of a CompositeFigure, this method descends into its children and into its children's children until the innermost figure is found.

        This functionality is implemented using the Chain of Responsibility design pattern. A figure which is not composed of other figures returns itself if the point is contained by the figure. Composed figures pass the method call down to their children.

        Specified by:
        findFigureInside in interface Figure
        Overrides:
        findFigureInside in class AbstractFigure
        Parameters:
        p - A location on the drawing.
        Returns:
        Returns the innermost figure at the location, or null if the location is not contained in a figure.
      • findChild

        @Nullable
        public Figure findChild(java.awt.geom.Point2D.Double p)
      • findChildIndex

        public int findChildIndex(java.awt.geom.Point2D.Double p)
      • getLayouter

        public Layouter getLayouter()
        Get a Layouter object which encapsulated a layout algorithm for this figure. Typically, a Layouter accesses the child components of this figure and arranges their graphical presentation.
        Specified by:
        getLayouter in interface CompositeFigure
        Returns:
        layout strategy used by this figure
      • layout

        public void layout()
        A layout algorithm is used to define how the child components should be laid out in relation to each other. The task for layouting the child components for presentation is delegated to a Layouter which can be plugged in at runtime.
        Specified by:
        layout in interface CompositeFigure
      • setLayouter

        public void setLayouter(Layouter newLayouter)
        Set a Layouter object which encapsulated a layout algorithm for this figure. Typically, a Layouter accesses the child components of this figure and arranges their graphical presentation. It is a good idea to set the Layouter in the protected initialize() method so it can be recreated if a GraphicalCompositeFigure is read and restored from a StorableInput stream.
        Specified by:
        setLayouter in interface CompositeFigure
        Parameters:
        newLayouter - encapsulation of a layout algorithm.
      • draw

        public void draw(java.awt.Graphics2D g)
        Description copied from interface: Figure
        Draws the figure.
        Specified by:
        draw in interface Figure
        Parameters:
        g - The Graphics2D to draw to.
      • getDecomposition

        public java.util.Collection<Figure> getDecomposition()
        Description copied from interface: Figure
        Returns a decompositon of a figure into its parts. A figure is considered as a part of itself.
        Specified by:
        getDecomposition in interface Figure
        Overrides:
        getDecomposition in class AbstractFigure
      • read

        public void read(DOMInput in)
                  throws java.io.IOException
        Specified by:
        read in interface DOMStorable
        Throws:
        java.io.IOException
      • write

        public void write(DOMOutput out)
                   throws java.io.IOException
        Specified by:
        write in interface DOMStorable
        Throws:
        java.io.IOException
      • restoreTransformTo

        public void restoreTransformTo(java.lang.Object geometry)
        Description copied from interface: Figure
        Restores the transform of the figure to a previously stored state.
        Specified by:
        restoreTransformTo in interface Figure
      • getTransformRestoreData

        public java.lang.Object getTransformRestoreData()
        Description copied from interface: Figure
        Gets data which can be used to restore the transformation of the figure without loss of precision, after a transform has been applied to it.
        Specified by:
        getTransformRestoreData in interface Figure
        See Also:
        Figure.transform(AffineTransform)
      • basicAdd

        public void basicAdd(int index,
                             Figure figure)
        Description copied from interface: CompositeFigure
        Adds a child to the figure at the specified index without firing events.

        This method can be used to reinsert a child figure which has been temporarily removed from this CompositeFigure (for example to reorder the sequence of the children) and to efficiently build a drawing from an InputFormat.

        Specified by:
        basicAdd in interface CompositeFigure
      • basicRemoveChild

        public Figure basicRemoveChild(int index)
        Description copied from interface: CompositeFigure
        Removes the child at the specified index without firing events.

        This method can be used to temporarily remove a child from this CompositeFigure (for example to reorder the sequence of the children).

        Returns the removed child figure.

        Specified by:
        basicRemoveChild in interface CompositeFigure
      • getChildCount

        public int getChildCount()
        Description copied from interface: CompositeFigure
        Returns the number of children.

        This is a convenience method for calling getChildren().size();.

        Specified by:
        getChildCount in interface CompositeFigure
      • getChild

        public Figure getChild(int index)
        Description copied from interface: CompositeFigure
        Returns the child figure at the specified index.

        This is a convenience method for calling getChildren().get(index);.

        Specified by:
        getChild in interface CompositeFigure
      • clone

        public AbstractCompositeFigure clone()
        Description copied from interface: Figure
        Returns a clone of the figure, with clones of all aggregated figures, such as children and decorators. The cloned figure does not clone the list of FigureListeners from its original.
        Specified by:
        clone in interface Figure
        Overrides:
        clone in class AbstractFigure
      • basicRemove

        public int basicRemove(Figure child)
        Description copied from interface: CompositeFigure
        Removes the specified child without firing events.

        This method can be used to temporarily remove a child from this CompositeFigure (for example to reorder the sequence of the children).

        This is a convenience method for calling basicRemove(indexOf(child));.

        Returns the index of the removed figure. Returns -1 if the figure was not a child of this CompositeFigure.

        Specified by:
        basicRemove in interface CompositeFigure
      • indexOf

        public int indexOf(Figure child)
        Description copied from interface: CompositeFigure
        Returns the index of the specified child.

        This is a convenience method for calling getChildren().indexOf(index);.

        Specified by:
        indexOf in interface CompositeFigure
        Returns:
        The index of the child, or -1 if the specified figure is not a child of this CompositeFigure.
      • getDrawingArea

        public java.awt.geom.Rectangle2D.Double getDrawingArea()
        Description copied from interface: Figure
        Returns the drawing area of the figure as a Rectangle.

        The drawing area is used to inform DrawingView about the area that is needed to draw this figure.

        The drawing area needs to be large enough, to take line width, line caps and other decorations into account that exceed the bounds of the Figure.

        Specified by:
        getDrawingArea in interface Figure
      • getBounds

        public java.awt.geom.Rectangle2D.Double getBounds()
        Description copied from interface: Figure
        Returns the untransformed logical bounds of the figure as a Rectangle.

        The bounds are used by Handle objects for adjusting the figure and for aligning the figure on a grid.

        Specified by:
        getBounds in interface Figure

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.