Class Path

java.lang.Object
net.atthegate.server.service.pdf.Path
All Implemented Interfaces:
Drawable

public class Path extends Object implements Drawable
Used to create path objects. The path objects may consist of lines, splines or both. Please see Example_02.
  • Constructor Summary

    Constructors
    Constructor
    Description
    The default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Point point)
    Adds a point to this path.
    float[]
    drawOn(Page page)
    Draws this path on the page using the current selected color, pen width, line pattern and line join style.
    static List<Point>
    getCurvePoints(float x, float y, float r1, float r2, int segment)
    Returns a list containing the start point, first control point, second control point and the end point of elliptical curve segment.
    int
    Returns the line cap style for this path.
    int
    Returns the line join style.
    void
    placeIn(Box box)
    Places this path in the specified box at position (0.0, 0.0).
    void
    placeIn(Box box, double x_offset, double y_offset)
    Places the path inside the spacified box at coordinates (x_offset, y_offset) of the top left corner.
    void
    placeIn(Box box, float x_offset, float y_offset)
    Places the path inside the spacified box at coordinates (x_offset, y_offset) of the top left corner.
    void
    scaleBy(double factor)
    Scales the path using the specified factor.
    void
    scaleBy(float factor)
    Scales the path using the specified factor.
    void
    setClosePath(boolean close_path)
    Sets the close_path variable.
    void
    setColor(int color)
    Sets the pen color that will be used to draw this path.
    void
    setFillShape(boolean fill_shape)
    Sets the fill_shape private variable.
    void
    setLineCapStyle(int style)
    Sets the line cap style.
    void
    setLineJoinStyle(int style)
    Sets the line join style.
    void
    setLocation(float x, float y)
     
    void
    setPattern(String pattern)
    Sets the line dash pattern for this path.
    void
    setWidth(double width)
    Sets the pen width that will be used to draw the lines and splines that are part of this path.
    void
    setWidth(float width)
    Sets the pen width that will be used to draw the lines and splines that are part of this path.

    Methods inherited from class java.lang.Object

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

    • Path

      public Path()
      The default constructor.
  • Method Details

    • add

      public void add(Point point)
      Adds a point to this path.
      Parameters:
      point - the point to add.
    • setPattern

      public void setPattern(String pattern)
      Sets the line dash pattern for this path. The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by a dash array and a dash phase. The elements of the dash array are positive numbers that specify the lengths of alternating dashes and gaps. The dash phase specifies the distance into the dash pattern at which to start the dash. The elements of both the dash array and the dash phase are expressed in user space units.
        Examples of line dash patterns:
      
            "[Array] Phase"     Appearance          Description
            _______________     _________________   ____________________________________
      
            "[] 0"              -----------------   Solid line
            "[3] 0"             ---   ---   ---     3 units on, 3 units off, ...
            "[2] 1"             -  --  --  --  --   1 on, 2 off, 2 on, 2 off, ...
            "[2 1] 0"           -- -- -- -- -- --   2 on, 1 off, 2 on, 1 off, ...
            "[3 5] 6"             ---     ---       2 off, 3 on, 5 off, 3 on, 5 off, ...
            "[2 3] 11"          -   --   --   --    1 on, 3 off, 2 on, 3 off, 2 on, ...
        
      Parameters:
      pattern - the line dash pattern.
    • setWidth

      public void setWidth(double width)
      Sets the pen width that will be used to draw the lines and splines that are part of this path.
      Parameters:
      width - the pen width.
    • setWidth

      public void setWidth(float width)
      Sets the pen width that will be used to draw the lines and splines that are part of this path.
      Parameters:
      width - the pen width.
    • setColor

      public void setColor(int color)
      Sets the pen color that will be used to draw this path.
      Parameters:
      color - the color is specified as an integer.
    • setClosePath

      public void setClosePath(boolean close_path)
      Sets the close_path variable.
      Parameters:
      close_path - if close_path is true a line will be draw between the first and last point of this path.
    • setFillShape

      public void setFillShape(boolean fill_shape)
      Sets the fill_shape private variable. If fill_shape is true - the shape of the path will be filled with the current brush color.
      Parameters:
      fill_shape - the fill_shape flag.
    • setLineCapStyle

      public void setLineCapStyle(int style)
      Sets the line cap style.
      Parameters:
      style - the cap style of this path. Supported values: Cap.BUTT, Cap.ROUND and Cap.PROJECTING_SQUARE
    • getLineCapStyle

      public int getLineCapStyle()
      Returns the line cap style for this path.
      Returns:
      the line cap style for this path.
    • setLineJoinStyle

      public void setLineJoinStyle(int style)
      Sets the line join style.
      Parameters:
      style - the line join style code. Supported values: Join.MITER, Join.ROUND and Join.BEVEL
    • getLineJoinStyle

      public int getLineJoinStyle()
      Returns the line join style.
      Returns:
      the line join style.
    • placeIn

      public void placeIn(Box box) throws Exception
      Places this path in the specified box at position (0.0, 0.0).
      Parameters:
      box - the specified box.
      Throws:
      Exception
    • placeIn

      public void placeIn(Box box, double x_offset, double y_offset) throws Exception
      Places the path inside the spacified box at coordinates (x_offset, y_offset) of the top left corner.
      Parameters:
      box - the specified box.
      x_offset - the x_offset.
      y_offset - the y_offset.
      Throws:
      Exception
    • placeIn

      public void placeIn(Box box, float x_offset, float y_offset) throws Exception
      Places the path inside the spacified box at coordinates (x_offset, y_offset) of the top left corner.
      Parameters:
      box - the specified box.
      x_offset - the x_offset.
      y_offset - the y_offset.
      Throws:
      Exception
    • setLocation

      public void setLocation(float x, float y)
    • scaleBy

      public void scaleBy(double factor) throws Exception
      Scales the path using the specified factor.
      Parameters:
      factor - the specified factor.
      Throws:
      Exception
    • scaleBy

      public void scaleBy(float factor) throws Exception
      Scales the path using the specified factor.
      Parameters:
      factor - the specified factor.
      Throws:
      Exception
    • getCurvePoints

      public static List<Point> getCurvePoints(float x, float y, float r1, float r2, int segment) throws Exception
      Returns a list containing the start point, first control point, second control point and the end point of elliptical curve segment. Please see Example_18.
      Parameters:
      x - the x coordinate of the center of the ellipse.
      y - the y coordinate of the center of the ellipse.
      r1 - the horizontal radius of the ellipse.
      r2 - the vertical radius of the ellipse.
      segment - the segment to draw - please see the Segment class.
      Returns:
      a list of the curve points.
      Throws:
      Exception
    • drawOn

      public float[] drawOn(Page page) throws Exception
      Draws this path on the page using the current selected color, pen width, line pattern and line join style.
      Specified by:
      drawOn in interface Drawable
      Parameters:
      page - the page to draw this path on.
      Returns:
      x and y coordinates of the bottom right corner of this component.
      Throws:
      Exception