Class PathBuilder
java.lang.Object
org.openscience.cdk.renderer.elements.path.PathBuilder
Builder class for paths. All methods for constructing path elements return
a reference to the builder, so that it can be used like:
PathBuilder builder = new PathBuilder(); builder.moveTo(p1).lineTo(p1).close(); GeneralPath path = builder.createPath();
- Author:
- Arvid
- Source code:
- main
- Belongs to CDK module:
- renderbasic
-
Constructor Summary
ConstructorsConstructorDescriptionMake a new path builder with a default color of black.PathBuilder
(Color color) Make a path builder that will make a path with a particular color. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the path.Sets the color if this path.Create and return the final path.cubicTo
(javax.vecmath.Point2d cp1, javax.vecmath.Point2d cp2, javax.vecmath.Point2d ep) Make a cubic curve in the path, with two control points.lineTo
(javax.vecmath.Point2d point) Make a line in the path, from the last point to the given point.moveTo
(javax.vecmath.Point2d point) Make a move in the path, without drawing anything.quadTo
(javax.vecmath.Point2d cp, javax.vecmath.Point2d ep) Make a quadratic curve in the path, with one control point.
-
Constructor Details
-
PathBuilder
public PathBuilder()Make a new path builder with a default color of black. -
PathBuilder
Make a path builder that will make a path with a particular color.- Parameters:
color
- the color of the path
-
-
Method Details
-
moveTo
Make a move in the path, without drawing anything. This is usually used to start a path.- Parameters:
point
- the point to move to- Returns:
- a reference to this builder
-
lineTo
Make a line in the path, from the last point to the given point.- Parameters:
point
- the point to make a line to- Returns:
- a reference to this builder
-
quadTo
Make a quadratic curve in the path, with one control point.- Parameters:
cp
- the control point of the curveep
- the end point of the curve- Returns:
- a reference to this builder
-
cubicTo
public PathBuilder cubicTo(javax.vecmath.Point2d cp1, javax.vecmath.Point2d cp2, javax.vecmath.Point2d ep) Make a cubic curve in the path, with two control points.- Parameters:
cp1
- the first control pointcp2
- the second control pointep
- the end point of the curve- Returns:
- a reference to this builder
-
close
public void close()Close the path. -
color
Sets the color if this path.- Parameters:
color
- the newColor
.- Returns:
- returns itself.
-
createPath
Create and return the final path.- Returns:
- the newly created path
-