Class Line

    • Constructor Summary

      Constructors 
      Constructor Description
      Line​(int x1, int y1, int x2, int y2)
      Create a new Line element.
      Line​(int x1, int y1, int x2, int y2, java.awt.Color color)
      Create a new Line element.
      Line​(int x1, int y1, int x2, int y2, java.lang.String color)
      Create a new Line element colored a hue name or hex code
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.Point center​(java.awt.Graphics2D g)
      Get the object's centerpoint
      java.awt.Point getEndpoint()
      Get the endpoint of the line
      java.awt.Point getStartpoint()
      Get the startpoint of the line
      Line getThis()  
      Line setEndpoint​(int x, int y)
      Set the endpoint of the line
      Line setStartpoint​(int x, int y)
      Get the startpoint of the line
      Line setStroke​(int thickness, java.awt.Color color)  
      Line setStroke​(java.awt.Stroke stroke)
      Set the stroke of the line
      Line setThickness​(int thickness)
      Set the thickness of the line
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • 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.Colorable

        Modifier and Type Method Description
        java.awt.Color getColor()
        Get the current color of an element as a Color
        void internalSetColor​(java.awt.Color color)  
        default T setColor​(int hex)
        Set the color of this to the specified color.
        default T setColor​(int r, int g, int b)
        Set the color of this to the specified color.
        default T setColor​(int r, int g, int b, int a)
        Set the color of this to the specified color See Wikipedia for how this works.
        default T setColor​(java.awt.Color color)
        Set the color of the object with a Color object.
        default T setColor​(java.lang.String name)
        Set the color of the object with a hue name or hex code.
        default T setColor​(Hue hue)
        Set the color of the object with a Hue object.
      • 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
      • Methods inherited from interface paintingcanvas.drawable.Positionable

        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
    • Constructor Detail

      • Line

        public Line​(int x1,
                    int y1,
                    int x2,
                    int y2)
        Create a new Line element.
        
         // Create a new Line from (100, 100) to (200, 200)
         Line line = new Line(100, 100, 200, 200);
         
        Parameters:
        x1 - the X-position of the startpoint
        y1 - the Y-position of the startpoint
        x2 - the X-position of the endpoint
        y2 - the Y-position of the endpoint
      • Line

        public Line​(int x1,
                    int y1,
                    int x2,
                    int y2,
                    java.awt.Color color)
        Create a new Line element.
        
         // Create a new Line from (100, 100) to (200, 200)
         Line line = new Line(100, 100, 200, 200, new Color(255, 0, 0));
         
        Parameters:
        x1 - the X-position of the startpoint
        y1 - the Y-position of the startpoint
        x2 - the X-position of the endpoint
        y2 - the Y-position of the endpoint
        color - the color of the line
      • Line

        public Line​(int x1,
                    int y1,
                    int x2,
                    int y2,
                    java.lang.String color)
        Create a new Line element colored a hue name or hex code
        Parameters:
        x1 - the X-position of the startpoint
        y1 - the Y-position of the startpoint
        x2 - the X-position of the endpoint
        y2 - the Y-position of the endpoint
        color - the name of the color (case-insensitive)
        See Also:
        Misc.stringToColor(String)
    • Method Detail

      • setStroke

        public Line setStroke​(int thickness,
                              java.awt.Color color)
      • setStroke

        public Line setStroke​(java.awt.Stroke stroke)
        Set the stroke of the line
        Parameters:
        stroke - a Stroke object to define this line's stroke
        Returns:
        the original object to allow method chaining
      • setThickness

        public Line setThickness​(int thickness)
        Set the thickness of the line
        Parameters:
        thickness - the thickness of the line in pixels
        Returns:
        the original object to allow method chaining
      • getEndpoint

        public java.awt.Point getEndpoint()
        Get the endpoint of the line
        
         import java.awt.Point;
        
         Point p = line.getEndpoint();
         int x = p.x;
         int y = p.y;
         
        Returns:
        a Point object representing the startpoint of the line
      • getStartpoint

        public java.awt.Point getStartpoint()
        Get the startpoint of the line
        
         import java.awt.Point;
        
         Point p = line.getStartpoint();
         int x = p.x;
         int y = p.y;
         
        Returns:
        a Point object representing the startpoint of the line
      • setStartpoint

        public Line setStartpoint​(int x,
                                  int y)
        Get the startpoint of the line
        Parameters:
        x - the new X-position of the startpoint
        y - the new Y-position of the startpoint
        Returns:
        the original object to allow method chaining
      • setEndpoint

        public Line setEndpoint​(int x,
                                int y)
        Set the endpoint of the line
        Parameters:
        x - the new X-position of the endpoint
        y - the new Y-position of the endpoint
        Returns:
        the original object to allow method chaining
      • center

        public java.awt.Point center​(java.awt.Graphics2D g)
        Description copied from interface: Drawable
        Get the object's centerpoint
        
         import java.awt.Point;
        
         Point p = drawable.getStartpoint();
         int x = p.x;
         int y = p.y;
         
        Parameters:
        g - Graphics context
        Returns:
        the object's center-point
      • getThis

        public Line getThis()