GraphicsState
Overview
GraphicsState is a class in Aspose.Pdf FOSS for Java.
Inherits from: Cloneable.
Tracks the mutable graphics state during PDF page rendering (ISO 32000-1:2008, §8.4).
Properties
| Name | Type | Access | Description |
|---|---|---|---|
cTM | Matrix | Read | Returns the current transformation matrix. |
fillColor | java.awt.Color | Read | Returns the fill color as an AWT color. |
fillPatternName | String | Read | Returns the current fill Pattern name (or null for solid colour fill). |
strokePatternName | String | Read | Returns the current stroke Pattern name (or null). |
strokeColor | java.awt.Color | Read | Returns the stroke color as an AWT color. |
lineWidth | double | Read | Returns the line width in user units. |
lineCap | int | Read | Returns the line cap style (0=butt, 1=round, 2=square). |
lineJoin | int | Read | Returns the line join style (0=miter, 1=round, 2=bevel). |
miterLimit | double | Read | Returns the miter limit. |
dashArray | float[] | Read | Returns the dash array, or null for solid lines. |
dashPhase | float | Read | Returns the dash phase. |
strokingAlpha | float | Read | Returns the stroking alpha (0..1). |
nonStrokingAlpha | float | Read | Returns the non-stroking (fill) alpha (0..1). |
fontName | String | Read | Returns the current font resource name (e.g., “F1”). |
fontSize | double | Read | Returns the current font size. |
charSpacing | double | Read | Returns the character spacing in text-space units. |
wordSpacing | double | Read | Returns the word spacing in text-space units. |
horizontalScaling | double | Read | Returns the horizontal text scaling (percentage, 100 = normal). |
textLeading | double | Read | Returns the text leading. |
textRenderingMode | int | Read | Returns the text rendering mode (0-7). |
textRise | double | Read | Returns the text rise. |
textMatrix | Matrix | Read | Returns the text matrix (Tm). |
textLineMatrix | Matrix | Read | Returns the text line matrix (Tlm). |
currentPath | GeneralPath | Read | Returns the current path. |
clipPath | GeneralPath | Read | Returns the current clipping path, or null if not set. |
pendingClipEvenOdd | boolean | Read | Returns true if the pending clip uses even-odd rule. |
Methods
| Signature | Description |
|---|---|
GraphicsState() | Creates a new graphics state with PDF default values. |
clone() → GraphicsState | |
getCTM() → Matrix | Returns the current transformation matrix. |
setCTM(ctm: Matrix) | Sets the current transformation matrix. |
concatMatrix(matrix: Matrix) | Concatenates a matrix onto the CTM: ctm = matrix × ctm. |
getFillColor() → java.awt.Color | Returns the fill color as an AWT color. |
getFillPatternName() → String | Returns the current fill Pattern name (or null for solid colour fill). |
setFillPatternName(n: String) | Stores a Pattern resource name as the fill source. |
getStrokePatternName() → String | Returns the current stroke Pattern name (or null). |
setStrokePatternName(n: String) | Stores a Pattern resource name as the stroke source. |
setFillColorRGB(r: double, g: double, b: double) | Sets the fill color from PDF RGB components (0..1). |
setFillColorGray(gray: double) | Sets the fill color from a PDF gray value (0..1). |
setFillColorCMYK(c: double, m: double, y: double, k: double) | Sets the fill color from PDF CMYK components (0..1). |
setFillColor(color: java.awt.Color) | Sets the fill color directly. |
getStrokeColor() → java.awt.Color | Returns the stroke color as an AWT color. |
setStrokeColorRGB(r: double, g: double, b: double) | Sets the stroke color from PDF RGB components (0..1). |
setStrokeColorGray(gray: double) | Sets the stroke color from a PDF gray value (0..1). |
setStrokeColorCMYK(c: double, m: double, y: double, k: double) | Sets the stroke color from PDF CMYK components (0..1). |
setStrokeColor(color: java.awt.Color) | Sets the stroke color directly. |
getLineWidth() → double | Returns the line width in user units. |
setLineWidth(w: double) | Sets the line width. |
getLineCap() → int | Returns the line cap style (0=butt, 1=round, 2=square). |
setLineCap(cap: int) | Sets the line cap style. |
getLineJoin() → int | Returns the line join style (0=miter, 1=round, 2=bevel). |
setLineJoin(join: int) | Sets the line join style. |
getMiterLimit() → double | Returns the miter limit. |
setMiterLimit(limit: double) | Sets the miter limit. |
getDashArray() → float[] | Returns the dash array, or null for solid lines. |
getDashPhase() → float | Returns the dash phase. |
setDash(array: float[], phase: float) | Sets the dash pattern. |
createStroke() → BasicStroke | Creates an AWT BasicStroke from the current line style. |
getStrokingAlpha() → float | Returns the stroking alpha (0..1). |
setStrokingAlpha(alpha: float) | Sets the stroking alpha. |
getNonStrokingAlpha() → float | Returns the non-stroking (fill) alpha (0..1). |
setNonStrokingAlpha(alpha: float) | Sets the non-stroking alpha. |
getFontName() → String | Returns the current font resource name (e.g., “F1”). |
setFont(name: String, size: double) | Sets the current font. |
getFontSize() → double | Returns the current font size. |
getCharSpacing() → double | Returns the character spacing in text-space units. |
setCharSpacing(cs: double) | Sets the character spacing. |
getWordSpacing() → double | Returns the word spacing in text-space units. |
setWordSpacing(ws: double) | Sets the word spacing. |
getHorizontalScaling() → double | Returns the horizontal text scaling (percentage, 100 = normal). |
setHorizontalScaling(hs: double) | Sets the horizontal text scaling. |
getTextLeading() → double | Returns the text leading. |
setTextLeading(tl: double) | Sets the text leading. |
getTextRenderingMode() → int | Returns the text rendering mode (0-7). |
setTextRenderingMode(mode: int) | Sets the text rendering mode. |
getTextRise() → double | Returns the text rise. |
setTextRise(rise: double) | Sets the text rise. |
getTextMatrix() → Matrix | Returns the text matrix (Tm). |
setTextMatrix(tm: Matrix) | Sets the text matrix. |
setTextMatrixDirect(tm: Matrix) | Sets the text matrix without changing the text line matrix (for glyph advance). |
getTextLineMatrix() → Matrix | Returns the text line matrix (Tlm). |
moveTextPosition(tx: double, ty: double) | Moves the text position by (tx, ty) — implements Td operator. |
nextLine() | Moves to the next line — implements T* operator. |
beginText() | Begins a text object (BT) — resets text matrix and text line matrix to identity. |
getCurrentPath() → GeneralPath | Returns the current path. |
moveTo(x: double, y: double) | Begins a new subpath at (x, y). |
lineTo(x: double, y: double) | Appends a line from the current point to (x, y). |
curveTo(x1: double, y1: double, x2: double, y2: double, x3: double, y3: double) | Appends a cubic Bézier curve (c operator). |
curveToV(x2: double, y2: double, x3: double, y3: double) | Appends a cubic Bézier curve with first control point = current point (v operator). |
curveToY(x1: double, y1: double, x3: double, y3: double) | Appends a cubic Bézier curve with final control point = end point (y operator). |
rect(x: double, y: double, w: double, h: double) | Appends a rectangle (re operator). |
closePath() | Closes the current subpath (h operator). |
clearPath() | Clears the current path after painting or no-op. |
getClipPath() → GeneralPath | Returns the current clipping path, or null if not set. |
setClipPath(path: GeneralPath) | Sets the clipping path directly. |
setPendingClip() | Marks a pending non-zero winding clip (W operator). |
setPendingClipEvenOdd() | Marks a pending even-odd clip (W* operator). |
hasPendingClip() → boolean | Returns true if there is a pending clip to apply. |
isPendingClipEvenOdd() → boolean | Returns true if the pending clip uses even-odd rule. |
clearPendingClip() | Clears the pending clip flag (after it has been applied). |