Package net.atthegate.server.service.pdf
Class Path
java.lang.Object
net.atthegate.server.service.pdf.Path
- All Implemented Interfaces:
Drawable
Used to create path objects.
The path objects may consist of lines, splines or both.
Please see Example_02.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a point to this path.float[]
Draws this path on the page using the current selected color, pen width, line pattern and line join style.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
Places this path in the specified box at position (0.0, 0.0).void
Places the path inside the spacified box at coordinates (x_offset, y_offset) of the top left corner.void
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.
-
Constructor Details
-
Path
public Path()The default constructor.
-
-
Method Details
-
add
Adds a point to this path.- Parameters:
point
- the point to add.
-
setPattern
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
Places this path in the specified box at position (0.0, 0.0).- Parameters:
box
- the specified box.- Throws:
Exception
-
placeIn
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
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
Scales the path using the specified factor.- Parameters:
factor
- the specified factor.- Throws:
Exception
-
scaleBy
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
Draws this path on the page using the current selected color, pen width, line pattern and line join style.
-