Class Pen

java.lang.Object
nl.saxion.app.canvas.pens.Pen
Direct Known Subclasses:
FilledPen

public class Pen extends Object
Pen object is used to draw on the canvas. This will draw lines between points.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
     
    protected int
     
    protected int
     
    protected boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Pen()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    int
    Get the current angle of the pen (in degrees)
    void
    headTo(int degrees)
    Set rotation.
    boolean
    Indicates if the pen is on or off.
    void
    move(int distance)
    Move the pen a certain distance.
    void
    moveTo(int newX, int newY)
    Move the current pen position to the new x and new y provided.
    void
    Reset the angle of the pen (reset to 0 degrees)
    void
    rotate(int degrees)
    Rotate, relatively to the current rotation
    void
    Turn the pen off.
    void
    Turn the pen on.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • penOn

      protected boolean penOn
    • currentX

      protected int currentX
    • currentY

      protected int currentY
    • currentAngle

      protected int currentAngle
  • Constructor Details

    • Pen

      public Pen()
  • Method Details

    • turnOn

      public void turnOn()
      Turn the pen on.
    • turnOff

      public void turnOff()
      Turn the pen off.
    • move

      public void move(int distance)
      Move the pen a certain distance. The angle can be set using `headTo` or `rotate`.
      Parameters:
      distance - Distance in pixel
    • moveTo

      public void moveTo(int newX, int newY)
      Move the current pen position to the new x and new y provided. In case the pen is on, a line will be drawn between the previous point and the new point.
      Parameters:
      newX - New x-coordinate
      newY - New y-coordinate
    • isOn

      public boolean isOn()
      Indicates if the pen is on or off.
      Returns:
      True, if the pen is on.
    • rotate

      public void rotate(int degrees)
      Rotate, relatively to the current rotation
      Parameters:
      degrees - Number of degrees
    • headTo

      public void headTo(int degrees)
      Set rotation. 0 degrees is to right, 90 down, 180 left, 270 up.
      Parameters:
      degrees - Number of degrees
    • getAngle

      public int getAngle()
      Get the current angle of the pen (in degrees)
      Returns:
      Number of degrees
    • resetAngle

      public void resetAngle()
      Reset the angle of the pen (reset to 0 degrees)
    • debug

      public void debug()