Class Path


public class Path extends Element
A path in a PDF file defines shapes. Paths in PDF files are used to draw lines, define filled areas, and define boundaries for clipping graphics. A path is composed of straight and curved line segments.
  • Constructor Details

    • Path

      public Path()
      Create a path.

    • Path

      public Path(GraphicState graphicState)
      Create a path with a given graphic state.

      Parameters:
      graphicState - the initial graphic state for the path
  • Method Details

    • delete

      public void delete()
      Overrides:
      delete in class Element
    • getGraphicState

      public GraphicState getGraphicState()
      Get the graphic state of the current path.

      May return null if this element does not have a GraphicState.

    • setGraphicState

      public void setGraphicState(GraphicState gstate)
      Set the Graphic State of the current path.
      Parameters:
      gstate - the new/updated Graphic State for the path.
    • getPaintOp

      public EnumSet<PathPaintOpFlags> getPaintOp()
      Gets the fill and stroke attributes of a path.

      Returns:
      the PathPaintOpFlags flags describing the fill and stroke attributes.
    • setPaintOp

      public void setPaintOp(EnumSet<PathPaintOpFlags> paintops)
      Sets the fill and stroke attributes of a path.

      Parameters:
      paintops - the flags describing the fill and stroke attributes.
    • moveTo

      public void moveTo(Point Point)
      Moves the current point of the path to the given point.
      Parameters:
      Point - the coordinates of the new current point.
    • addLine

      public void addLine(Point Point)
      Adds a line to the current path from the current path position. The given point becomes the new current position.

      Parameters:
      Point - the coordinates of the endpoint of the new line.
    • addRect

      public void addRect(Point Point, double Width, double Height)
      Adds a rectangle to the current path with the lower left corner at the give point, and with the width and height specified.

      Parameters:
      Point - the coordinates of the lower left corner of the new rectangle.
      Width - the width of the new rectangle.
      Height - the height of the new rectangle.
    • addCurve

      public void addCurve(Point Point1, Point Point2, Point Point3)
      Adds a Bezier curve from the current path using the first two points specified as Bezier control points ending at the third point. The new current point is then set to the third point.

      Parameters:
      Point1 - first Bezier control point
      Point2 - second Bezier control point
      Point3 - the ending Point of the Bezier curve which will also be the current point of the current path.
    • addCurveV

      public void addCurveV(Point Point1, Point Point2)
      Adds a Bezier curve from the current path. This extends from the current path to the point Point2 using the current point and the first point specified as Bezier control points ending at the second point. The new current point is then set to the second point.

      Parameters:
      Point1 - first Bezier control point
      Point2 - the ending Point of the Bezier curve which will also be the new current point of the path.
    • addCurveY

      public void addCurveY(Point Point1, Point Point2)
      Adds a Bezier curve from the current path. This extends from the current path to the point Point2 using the two points specified as Bezier control points ending at the second point. The new current point is then set to the second point.

      Parameters:
      Point1 - first Bezier control point
      Point2 - second Bezier control point and the ending Point of the Bezier curve which will also be the new current point of the path.
    • closePath

      public void closePath()
      Closes the current subpath.

    • clone

      public Path clone()
      Makes a copy of the path.

      Make a copy of an path to obtain a new path that has a distinct set of attributes.

      Overrides:
      clone in class Element
      Returns:
      The copied path.
    • clone

      public Path clone(EnumSet<ElementCloneFlags> cloneFlags)
      Makes a copy of the path.

      Make a copy of an path to obtain a new path that has a distinct set of attributes.

      Overrides:
      clone in class Element
      Parameters:
      cloneFlags - Flags that modify the cloning operation.
      Returns:
      The copied path.
    • getSegments

      public List<Segment> getSegments()
      Get the segments of the path.

      Returns a list of Segment objects, one for each segment in the path.

    • setSegments

      public void setSegments(List<Segment> segments)
      Set the segments of the path.

      Parameters:
      segments - The segments in the path. This list must have at least one element.
    • colorConvert

      public Path colorConvert(Document document, ColorProfile prof, RenderIntent intent, boolean embed)
      Applies the specified ICC ColorProfile to the Path

      Parameters:
      document - The document the element belongs to.
      prof - The ICC ColorProfile to be applied.
      intent - The ICC Rendering Intent for the ColorProfile
      embed - If true, embed the color space and make the object calibrated. If it is false and the target profile is CMYK, RGB, or Gray, the colors space of the resulting object, after conversion, will be DeviceCMYK, DeviceRGB, or DeviceGray, respectively.
      Returns:
      A new Path with the applied ICC ColorProfile.