public class PdfPen extends Object implements Cloneable
// Create a page PdfPage page = new PdfPage(); // Create a brush and set its properties PdfBrush brush = new PdfBrush(); brush.fillColor = Color.RED; brush.brushPattern = PdfBrush.PATTERN_CROSS; // Create a pen and set its properties PdfPen pen = new PdfPen(); pen.capStyle = PdfPen.CAPSTYLE_ROUND; pen.miterLimit = PdfPen.DEFAULT_MITERLIMIT * 2; pen.width = PdfPen.DEFAULT_WIDTH * 50; pen.joinStyle = PdfPen.JOINSTYLE_BEVEL; pen.strokeColor = Color.GREEN; // Set the pen and brush to the page page.setBrush(brush); page.setPen(pen); // Render a PDF element on the page // with the pen and brush page.drawSquare(100, 100, 50, true, true); // Make some changes to the properties of the pen and brush brush.fillColor = Color.YELLOW; brush.brushPattern = PdfBrush.PATTERN_SOLID; pen.strokeColor = Color.RED; // Render another PDF element on the page // with the modified pend and brush page.drawCircle(300, 100, 50, true, true);
Modifier and Type | Field and Description |
---|---|
int |
capStyle
Line-end style for strokes made by the pen.
|
static int |
CAPSTYLE_BUTT
Constant specifying lines whose ends are squared off without
any projection.
|
static int |
CAPSTYLE_PROJECTING_SQUARE
Constant specifying lines whose ends are projected to a
distance that is half the width of the line.
|
static int |
CAPSTYLE_ROUND
Constant specifying lines whose ends are rounded off.
|
float[] |
dashArray |
double |
dashGap |
double |
dashLength |
double |
dashPhase |
static int |
DEFAULT_MITERLIMIT
Constant for a miter limit that specifies that the
miter
length can be at most 10 times the line width.
|
static double |
DEFAULT_WIDTH
Constant specifying a line width that is 1/10th of applicable
measurement unit.
|
int |
joinStyle
Line-join style for strokes made by the pen.
|
static int |
JOINSTYLE_BEVEL
Constant specifying line-join style where the ends are squared
of with
CAPSTYLE_BUTT style. |
static int |
JOINSTYLE_MITER
Constant specifying line-join style where the outer edges of
the lines are projected until they meet.
|
static int |
JOINSTYLE_ROUND
Constant specifying line-join style where the join is rounded
off with an arc whose center is at the point where the lines
meet and the diameter is equal to the width of the line.
|
double |
miterLimit
Ratio of the length of the
miter
and the line width for this
pen.
|
Color |
strokeColor
Color of the strokes made by the pen.
|
double |
width
Width of the strokes made by the pen.
|
public static final double DEFAULT_WIDTH
public static final int DEFAULT_MITERLIMIT
public static final int CAPSTYLE_BUTT
public static final int CAPSTYLE_ROUND
public static final int CAPSTYLE_PROJECTING_SQUARE
public static final int JOINSTYLE_MITER
or @link #JOINSTYLE_ROUND
is recommended.public static final int JOINSTYLE_ROUND
public static final int JOINSTYLE_BEVEL
CAPSTYLE_BUTT
style.public double dashLength
public double dashGap
public float[] dashArray
public double dashPhase
public double width
public int capStyle
public int joinStyle
public double miterLimit
public Color strokeColor
public PdfPen()
public PdfPen(Color strokeColor)