Package doodlepad

Class Path


public class Path extends Shape
A class that implements a general graphical path object.
  • Constructor Details

    • Path

      public Path()
      Constructor for objects of class Path
    • Path

      public Path(Pad pad)
      Constructor for objects of class Path
      Parameters:
      pad - The Pad to which this object should be added.
    • Path

      public Path(Layer layer)
      Constructor for objects of class Path
      Parameters:
      layer - The Layer object to which the Path should be added, or null if not to add to a Layer.
  • Method Details

    • toString

      public String toString()
      Generate a representation of the Path object.
      Overrides:
      toString in class Shape
      Returns:
      String representation
    • moveTo

      public void moveTo(double x, double y)
      Add a moveTo operation to the Path object
      Parameters:
      x - The x-coordinate of the moveTo point.
      y - The y-coordinate of the moveTo point.
    • lineTo

      public void lineTo(double x, double y)
      Add a line to the Path object
      Parameters:
      x - The x-coordinate of the line endpoint.
      y - The y-coordinate of the line endpoint.
    • quadTo

      public void quadTo(double cx1, double cy1, double x, double y)
      Add a quadratic curve to the Path object
      Parameters:
      cx1 - The x-coordinate of the control point.
      cy1 - The y-coordinate of the control point.
      x - The x-coordinate of the endpoint.
      y - The y-coordinate of the endpoint.
    • curveTo

      public void curveTo(double cx1, double cy1, double cx2, double cy2, double x, double y)
      Add a curve to the Path object.
      Parameters:
      cx1 - The x-coordinate of the first control point.
      cy1 - The y-coordinate of the first control point.
      cx2 - The x-coordinate of the second control point.
      cy2 - The y-coordinate of the second control point.
      x - The x-coordinate of the curve endpoint.
      y - The y-coordinate of the curve endpoint.
    • closePath

      public void closePath()
      Close the Path object.
    • setLocation

      public void setLocation(double x, double y)
      Update all path operations to reflect new position
      Overrides:
      setLocation in class Shape
      Parameters:
      x - New x position of upper-left corner
      y - New y position of upper-left corner
    • setSize

      public void setSize(double w, double h)
      Update all path operations to reflect new size
      Overrides:
      setSize in class Shape
      Parameters:
      w - New width
      h - New height
    • draw

      public void draw(Graphics2D g)
      Draw the Path object
      Specified by:
      draw in class Shape
      Parameters:
      g - The Graphics2D object on which to draw the Path