Package diva.canvas

Class AbstractFigureContainer

    • Constructor Detail

      • AbstractFigureContainer

        public AbstractFigureContainer()
    • Method Detail

      • decorate

        public void decorate​(Figure child,
                             FigureDecorator decorator)
        Decorate a child figure, replacing the reference to the child figure with the decorator.
        Specified by:
        decorate in interface FigureContainer
        Parameters:
        child - The child figure.
        decorator - The decorator.
      • contains

        public abstract boolean contains​(Figure f)
        Test if the given figure is a child of this composite.
        Specified by:
        contains in interface FigureContainer
        Specified by:
        contains in interface FigureSet
        Parameters:
        f - The figure to be searched for
        Returns:
        true if the figure is contained.
      • figures

        public abstract java.util.Iterator figures()
        Return an iteration of the children, in an undefined order.
        Specified by:
        figures in interface FigureSet
        Returns:
        The iterator.
      • figuresFromBack

        public abstract java.util.Iterator figuresFromBack()
        Return an iteration of the children, from back to front. This is the order in which the children are painted.
        Specified by:
        figuresFromBack in interface FigureSet
        Returns:
        The iterator
      • figuresFromFront

        public abstract java.util.Iterator figuresFromFront()
        Return an iteration of the children, from front to back. This is the order in which events are intercepted.
        Specified by:
        figuresFromFront in interface FigureSet
        Returns:
        The iterator
      • getFigureCount

        public abstract int getFigureCount()
        Return the number of child figures in this container.
        Specified by:
        getFigureCount in interface FigureContainer
        Returns:
        The number of figures.
      • paint

        public void paint​(java.awt.Graphics2D g)
        Paint this composite figure onto a 2D graphics object. If the layer is not visible, return immediately. Otherwise paint all children from back to front.
        Specified by:
        paint in interface VisibleComponent
        Specified by:
        paint in class AbstractFigure
        Parameters:
        g - The 2D graphics object that this object it to be painted upon.
      • pick

        public Figure pick​(java.awt.geom.Rectangle2D region)
        Given a rectangle, return the top-most descendent figure that it hits. If none does, return null.
        Specified by:
        pick in interface FigureContainer
        Parameters:
        region - The rectangle
        Returns:
        The figure
      • pick

        public Figure pick​(java.awt.geom.Rectangle2D region,
                           Filter filter)
        Given a rectangle, return the top-most descendent figure that it hits that is accepted by the given filter. If none does, return null.
        Specified by:
        pick in interface FigureContainer
        Parameters:
        region - The rectangle
        filter - The filter
        Returns:
        the Figure or null.
      • repaint

        public void repaint​(DamageRegion d)
        Accept notification that a repaint has occurred somewhere in the hierarchy below this container. This default implementation simply forwards the notification to its parent.
        Specified by:
        repaint in interface CanvasComponent
        Overrides:
        repaint in class AbstractFigure
        Parameters:
        d - The region where a repaint has occurred.
      • replaceChild

        protected abstract void replaceChild​(Figure child,
                                             Figure replacement)
        Replace the first figure with the second. This is a hook method for the decorate() and undecorate() methods, and should not be called by other methods. Implementors can assume that the first figure is a child of this container, and that the second is not.
        Parameters:
        child - The figure to be replaced.
        replacement - The replacement figure.
      • transform

        public void transform​(java.awt.geom.AffineTransform at)
        Transform this figure with the supplied transform. This default implementation simply forwards the transform call to each child.
        Specified by:
        transform in interface Figure
        Specified by:
        transform in class AbstractFigure
        Parameters:
        at - The transform to be used.
      • translate

        public void translate​(double x,
                              double y)
        Translate this figure by the given distance. This default implementation simply forwards the translate call to each child.
        Specified by:
        translate in interface Figure
        Overrides:
        translate in class AbstractFigure
        Parameters:
        x - The x value to be moved.
        y - The y value to be moved.
      • undecorate

        public void undecorate​(FigureDecorator decorator)
        Remove a figure from the given decorator and add it back into this container.
        Specified by:
        undecorate in interface FigureContainer
        Parameters:
        decorator - The decorator