Class TranslationDecorator

  • All Implemented Interfaces:
    Decorator

    public class TranslationDecorator
    extends java.lang.Object
    implements Decorator
    Decorator that translates the paint origin of its component.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Bounds getBounds​(Component component)
      Returns the bounding area of the decorator.
      boolean getClip()  
      Point getOffset()  
      java.awt.geom.AffineTransform getTransform​(Component component)
      Returns the transformation the decorator applies to the component's coordinate space.
      int getX()  
      int getY()  
      java.awt.Graphics2D prepare​(Component component, java.awt.Graphics2D graphics)
      Prepares the graphics context into which the component or prior decorator will paint.
      void setClip​(boolean clip)  
      void setOffset​(int x, int y)  
      void setOffset​(Point offset)  
      void setX​(int x)  
      void setY​(int y)  
      void update()
      Updates the graphics context into which the component or prior decorator was painted.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TranslationDecorator

        public TranslationDecorator()
      • TranslationDecorator

        public TranslationDecorator​(boolean clip)
      • TranslationDecorator

        public TranslationDecorator​(int x,
                                    int y,
                                    boolean clip)
    • Method Detail

      • getX

        public int getX()
      • setX

        public void setX​(int x)
      • getY

        public int getY()
      • setY

        public void setY​(int y)
      • getOffset

        public Point getOffset()
      • setOffset

        public void setOffset​(Point offset)
      • setOffset

        public void setOffset​(int x,
                              int y)
      • getClip

        public boolean getClip()
      • setClip

        public void setClip​(boolean clip)
      • prepare

        public java.awt.Graphics2D prepare​(Component component,
                                           java.awt.Graphics2D graphics)
        Description copied from interface: Decorator
        Prepares the graphics context into which the component or prior decorator will paint. This method is called immediately prior to Component.paint(Graphics2D); decorators are called in descending order.
        Specified by:
        prepare in interface Decorator
        Parameters:
        component - The component the decorator is attached to.
        graphics - The graphics context to draw into.
        Returns:
        The graphics context that should be used by the component or prior decorators.
      • update

        public void update()
        Description copied from interface: Decorator
        Updates the graphics context into which the component or prior decorator was painted. This method is called immediately after Component.paint(Graphics2D); decorators are called in ascending order.

        This default version simply returns, without doing anything (often the appropriate thing to do).

        Specified by:
        update in interface Decorator
      • getBounds

        public Bounds getBounds​(Component component)
        Description copied from interface: Decorator
        Returns the bounding area of the decorator.

        This default simply returns the bounds of the component's size.

        Specified by:
        getBounds in interface Decorator
        Parameters:
        component - The component that the decorator is attached to.
        Returns:
        The decorator's bounds, relative to the component's origin.
      • getTransform

        public java.awt.geom.AffineTransform getTransform​(Component component)
        Description copied from interface: Decorator
        Returns the transformation the decorator applies to the component's coordinate space.

        This default simply returns a new AffineTransform.

        Specified by:
        getTransform in interface Decorator
        Parameters:
        component - The component the decorator is attached to.
        Returns:
        The decorator's transform.