Package doodlepad

Class Layer

java.lang.Object
doodlepad.Layer
All Implemented Interfaces:
Iterable<Shape>

public class Layer extends Object implements Iterable<Shape>
An object representing a drawing layer for the Pad class. Each Layer maintains its own collection of Shapes.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Layer(Pad pad)
    Layer constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a shape to the shapes list
    void
    Remove all shapes from the DoodlePad
    void
    Clear the Pad reference
    Return the Pad that holds this layer
    Return an ArrayList of selected Shape objects currently managed by the Pad instance
    Return an ArrayList of Shape objects currently managed by the Pad instance
    Clone the Layer's current AffineTransform.
    Return an iterator for loop over Shapes
    void
    Remove a shape from the shapes list
    void
    Repaint Layer by delegating to parent Pad object.
    void
    Resets the Layer to have no transformation.
    void
    rotate(double angle)
    Add a rotation angle to Layer transform.
    void
    rotate(double angle, double cx, double cy)
    Add a rotation angle to Layer transform.
    void
    scale(double factor)
    Add a scale factor to Layer transform.
    void
    scale(double xFactor, double yFactor)
    Add a scale factor to Layer transform.
    void
    scale(double factor, double cx, double cy)
    Add a scale factor to Layer transform.
    void
    scale(double xFactor, double yFactor, double cx, double cy)
    Add a scale factor to Layer transform.
    void
    Set a new AffineTransform for the Layer.
    void
    Move shape to the back of diagram
    void
    Move shape to the front of diagram
    void
    translate(double deltaX, double deltaY)
    Add a translate to Layer transform.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • Layer

      public Layer(Pad pad)
      Layer constructor
      Parameters:
      pad - The Pad that holds this Layer
  • Method Details

    • getPad

      public Pad getPad()
      Return the Pad that holds this layer
      Returns:
      Pad
    • clearPad

      public void clearPad()
      Clear the Pad reference
    • getShapes

      public ArrayList<Shape> getShapes()
      Return an ArrayList of Shape objects currently managed by the Pad instance
      Returns:
      An ArrayList<Shape> of all Shapes being managed
    • getSelectedShapes

      public ArrayList<Shape> getSelectedShapes()
      Return an ArrayList of selected Shape objects currently managed by the Pad instance
      Returns:
      An ArrayList<Shape> of all selected Shapes being managed
    • iterator

      public Iterator<Shape> iterator()
      Return an iterator for loop over Shapes
      Specified by:
      iterator in interface Iterable<Shape>
      Returns:
      Iterator<Shape> for Shapes
    • addShape

      public void addShape(Shape s)
      Add a shape to the shapes list
      Parameters:
      s - The Shape object to add to the Pad
    • removeShape

      public void removeShape(Shape s)
      Remove a shape from the shapes list
      Parameters:
      s - The Shape to remove
    • clear

      public void clear()
      Remove all shapes from the DoodlePad
    • toFront

      public void toFront(Shape s)
      Move shape to the front of diagram
      Parameters:
      s - The Shape to bring to the front of the display list.
    • toBack

      public void toBack(Shape s)
      Move shape to the back of diagram
      Parameters:
      s - The Shape to move to the back of the display list.
    • rotate

      public void rotate(double angle)
      Add a rotation angle to Layer transform.
      Parameters:
      angle - Adds the rotation angle to the current transform (radians)
    • rotate

      public void rotate(double angle, double cx, double cy)
      Add a rotation angle to Layer transform.
      Parameters:
      angle - Adds the rotation angle to the current transform (degrees)
      cx - x-coordinate of point about which rotation occurs
      cy - y-coordinate of point about which rotation occurs
    • translate

      public void translate(double deltaX, double deltaY)
      Add a translate to Layer transform.
      Parameters:
      deltaX - Translate shape in the x-direction by deltaX
      deltaY - Translate shape in the y-direction by deltaY
    • scale

      public void scale(double factor)
      Add a scale factor to Layer transform.
      Parameters:
      factor - Scale the shape by a scale factor
    • scale

      public void scale(double factor, double cx, double cy)
      Add a scale factor to Layer transform.
      Parameters:
      factor - Scale the shape by a scale factor
      cx - x-coordinate of point about which scaling occurs
      cy - y-coordinate of point about which scaling occurs
    • scale

      public void scale(double xFactor, double yFactor)
      Add a scale factor to Layer transform.
      Parameters:
      xFactor - Scale the shape in the x-direction by a xFactor
      yFactor - Scale the shape in the y-direction by a yFactor
    • scale

      public void scale(double xFactor, double yFactor, double cx, double cy)
      Add a scale factor to Layer transform.
      Parameters:
      xFactor - Scale the shape in the x-direction by a xFactor
      yFactor - Scale the shape in the y-direction by a yFactor
      cx - x-coordinate of point about which scaling occurs
      cy - y-coordinate of point about which scaling occurs
    • reset

      public void reset()
      Resets the Layer to have no transformation.
    • getTransform

      public AffineTransform getTransform()
      Clone the Layer's current AffineTransform.
      Returns:
      The cloned AffineTransform.
    • setTransform

      public void setTransform(AffineTransform transform)
      Set a new AffineTransform for the Layer.
      Parameters:
      transform - The new transform.
    • repaint

      public void repaint()
      Repaint Layer by delegating to parent Pad object.