Interface Positionable<T extends Drawable<T>>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.awt.Point getPos()
      Get the position of the element
      double getRotation()
      Get an elements rotation
      default int getX()
      Get the X-position of the element
      default int getY()
      Get the Y-position of the element.
      double internalGetRotation()  
      void internalSetPos​(int x, int y)  
      void internalSetRotation​(double rotation)  
      default T move​(int x, int y)
      Moves this drawable by the specified x and y.
      default T moveHorizontal​(int x)
      Moves this drawable by the specified x and y.
      default T moveVertical​(int y)
      Moves this drawable by the specified x and y.
      default T rotate​(double rotation)
      Rotate this element by rotation degrees.
      default T setPos​(int x, int y)
      Set the position of the element.
      default T setRotation​(double rotation)
      Set an elements rotation to rotation degrees.
      default T setX​(int x)
      Set the X-position of the object
      default T setY​(int y)
      Set the Y-position of the element
      • Methods inherited from interface paintingcanvas.animation.Animatable

        Modifier and Type Method Description
        default AnimationBuilder colorTo​(int hex, double duration)
        Change the color of this to the specified color over duration seconds.
        default AnimationBuilder colorTo​(int r, int g, int b, double duration)
        Change the color of this to the specified color over duration seconds.
        default AnimationBuilder colorTo​(int r, int g, int b, int a, double duration)
        Change the color of this to the specified color over duration seconds.
        default AnimationBuilder colorTo​(java.awt.Color color, double duration)
        Change the color of this to the specified color over duration seconds.
        default AnimationBuilder colorTo​(java.lang.String name, double duration)
        Change the color of this to the specified color over duration seconds.
        default AnimationBuilder colorTo​(Hue hue, double duration)
        Change the color of this to the specified color over duration seconds.
        Drawable<?> drawable()
        Get the Drawable element from this Animatable.
        default AnimationBuilder fadeIn​(double duration)
        Fade this in over duration seconds.
        default AnimationBuilder fadeOut​(double duration)
        Fade this out over duration seconds.
        default AnimationBuilder moveBy​(int x, int y, double duration)
        Move this by the specified x and y over duration seconds.
        default AnimationBuilder moveHorizontalBy​(int x, double duration)
        Move this by the specified x horizontally over duration seconds.
        default AnimationBuilder moveTo​(int x, int y, double duration)
        Move this to the specified x and y over duration seconds
        default AnimationBuilder moveVerticalBy​(int y, double duration)
        Move this by the specified y vertically over duration seconds.
        default AnimationBuilder rotateBy​(int angle, double duration)
        Rotate this by angle degrees over duration seconds.
        default AnimationBuilder rotateTo​(int angle, double duration)
        Rotate this to the specified angle degrees over duration seconds.
      • Methods inherited from interface paintingcanvas.drawable.Drawable

        Modifier and Type Method Description
        default AnimationBuilder animate()
        Start animating this object.
        default T bringToFront()
        Brings the object in front of all other objects.
        java.awt.Point center​(java.awt.Graphics2D g)
        Get the object's centerpoint
        default Drawable<?> drawable()
        Get the Drawable element from this Animatable.
        default void erase()
        Erase this object from the canvas.
        int getLayer()
        Gets the current layer of the object.
        T getThis()  
        T hide()
        Hide the Object.
        void internalSetLayer​(int layer)  
        void render​(java.awt.Graphics2D g)
        Actually render the object itself
        default T sendToBack()
        Puts the object behind all other objects.
        default T setLayer​(int layer)
        Puts the object on a specific layer.
        T show()
        Show the Object
    • Method Detail

      • internalSetPos

        void internalSetPos​(int x,
                            int y)
      • internalGetRotation

        double internalGetRotation()
      • internalSetRotation

        void internalSetRotation​(double rotation)
      • getPos

        java.awt.Point getPos()
        Get the position of the element
        Returns:
        the position of the element as a Point
        See Also:
        setPos(int, int)
      • getRotation

        double getRotation()
        Get an elements rotation
        
         Circle o = new Circle(100, 100, 20);
         o.setRotation(90); // Sets the elements rotation to 90°
         let i = o.getRotation(); // Gets the rotation
         assert i == 90;
         
        Returns:
        the rotation of the object
        See Also:
        rotate(double)
      • getX

        default int getX()
        Get the X-position of the element
        Returns:
        the X-position of the element
        See Also:
        getY(), setX(int)
      • setX

        default T setX​(int x)
        Set the X-position of the object
        Parameters:
        x - the new X-position of the Object
        Returns:
        the original object to allow method chaining
        See Also:
        getX(), setY(int)
      • getY

        default int getY()
        Get the Y-position of the element.
        Returns:
        the Y-position of the object
        See Also:
        getY(), setX(int)
      • setY

        default T setY​(int y)
        Set the Y-position of the element
        Parameters:
        y - the new Y-position of the Object
        Returns:
        the original object to allow method chaining
        See Also:
        setX(int), getY()
      • setPos

        default T setPos​(int x,
                         int y)
        Set the position of the element.
        Parameters:
        x - the new absolute X-position of the element
        y - the new absolute Y-position of the element
        Returns:
        the original object to allow method chaining
        See Also:
        getPos(), setX(int), setY(int)
      • move

        default T move​(int x,
                       int y)
        Moves this drawable by the specified x and y.
        
         Circle c = new Circle(100, 100, 20);
         // moves this circle 10 pixels to the right and 10 pixels down
         c.move(10, 10);
         // moves this circle 10 pixels to the left and 10 pixels up
         c.move(-10, -10);
         
        Parameters:
        x - the x to move by
        y - the y to move by
        Returns:
        the original object to allow method chaining
        See Also:
        setPos(int, int), moveHorizontal(int), moveVertical(int)
      • moveHorizontal

        default T moveHorizontal​(int x)
        Moves this drawable by the specified x and y.
        
         Circle c = new Circle(100, 100, 20);
         // moves this circle 10 pixels to the right
         c.moveHorizontal(10);
         
        Parameters:
        x - the x to move by
        Returns:
        the original object to allow method chaining
        See Also:
        setPos(int, int), moveVertical(int)
      • moveVertical

        default T moveVertical​(int y)
        Moves this drawable by the specified x and y.
        
         Circle c = new Circle(100, 100, 20);
         // moves this circle 10 pixels down
         c.moveVertical(10);
         
        Parameters:
        y - the y to move by
        Returns:
        the original object to allow method chaining
        See Also:
        setPos(int, int), moveHorizontal(int)
      • rotate

        default T rotate​(double rotation)
        Rotate this element by rotation degrees.
        
         Circle o = new Circle(100, 100, 20);
        
         // Calling rotate(90) twice makes the object rotate 180°
         o.rotate(90);
         o.rotate(90);
         
        Parameters:
        rotation - Change in rotation. (Degrees)
        Returns:
        the original object to allow method chaining
        See Also:
        setRotation(double)
      • setRotation

        default T setRotation​(double rotation)
        Set an elements rotation to rotation degrees.
        
         Circle o = new Circle(100, 100, 20);
         o.setRotation(90); // Sets the elements rotation to 90°
         
        Parameters:
        rotation - Absolute rotation. (Degrees)
        Returns:
        the original object to allow method chaining
        See Also:
        rotate(double)