|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.icepdf.core.pobjects.graphics.GraphicsState
public class GraphicsState
The PDF viewer application maintains an internal data structure called the graphics state that holds current graphics control parameters. These parameters define the global framework within which the graphics operators execute.
The graphics state is initialized at the beginning of each page, using the default values specified in Tables 4.2 and 4.3. Table 4.2 lists those graphics state parameters that are device-independent and are appropriate to specify in page descriptions. The parameters listed in Table 4.3 control details of the rendering (scan conversion) process and are device-dependent; a page description that is intended to be device-independent should not modify these parameters.
A well-structured PDF document typically contains many graphical elements that are essentially independent of each other and sometimes nested to multiple levels. The graphics state stack allows these elements to make local changes to the graphics state without disturbing the graphics state of the surrounding environment. The stack is a LIFO (last in, first out) data structure in which the contents of the graphics state can be saved and later restored using the following operators:
The q operator pushes a copy of the entire graphics state onto the stack. This is handled by the save() method in this class
The Q operator restores the entire graphics state to its former value by popping it from the stack. This is handled by the restore() method in this class
When a graphics state is saved a new GraphicsState object is created and a pointer is set to the origional graphics state. This creates a linked list of graphics states that can be easily restored when needed (LIFO staack)
The graphics state also manipulates the Shapes stack that contains all of the rendering components dealing with graphics states. As the content parser encounters different graphic state manipulators they are added to the stack and then when the page is rendered the stack (actually a vector) is read in a FIFO to generate the drawing commands.
| Paramater | Type | Value |
| CTM | array | The current transformation matrix, which maps positions from user coordinates to device coordinates. This matrix is modified by each application of the coordinate transformation operator, cm. Initial value: a matrix that transforms default user coordinates to device coordinates. |
| clipping path | (internal) | The current clipping path, which defines the boundary against which all output is to be cropped. Initial value: the boundary of the entire imageable portion of the output page. |
| color space | name or array | The current color space in which color values are to be interpreted. There are two separate color space parameters: one for stroking and one for all other painting operations. Initial value: DeviceGray. |
| color | (various | The current color to be used during painting operations. The type and interpretation of this parameter depend on the current color space; for most color spaces, a color value consists of one to four numbers. There are two separate color parameters: one for stroking and one for all other painting operations. Initial value: black. |
| text state | (various) | A set of nine graphics state parameters that pertain only to the painting of text. These include parameters that select the font, scale the glyphs to an appropriate size, and accomplish other effects. The text state parameters are described in Section 5.2, "Text State Parameters and Operators." |
| line width | number | The thickness, in user space units, of paths to be stroked. |
| line cap | integer | A code specifying the shape of the endpoints for any open path that is stroked (see "Line Cap Style" on page 186). Initial value: 0, for square butt caps. |
| line join | integer | A code specifying the shape of joints between connected segments of a stroked path. Initial value: 0, for mitered joins. |
| miter limit | number | The maximum length of mitered line joins for stroked paths. This parameter limits the length of "spikes" produced when line segments join at sharp angles. Initial value: 10.0, for a miter cutoff below approximately 11.5 degrees. |
| dash pattern | array and number | A description of the dash pattern to be used when paths are stroked. Initial value: a solid line. |
| rendering intent (Not supported) | name | The rendering intent to be used when converting CIE-based colors to device colors. Default value: RelativeColorimetric. |
| stroke adjustment (Not supported) | boolean | (PDF 1.2) A flag specifying whether to compensate for possible rasterization effects when stroking a path with a line width that is small relative to the pixel resolution of the output device.. Note that this is considered a device-independent parameter, even though the details of its effects are device-dependent. Initial value: false. |
| blend mode (Not supported) | name or array | (PDF 1.4) The current blend mode to be used in the transparent imaging model. This parameter is implicitly reset to its initial value at the beginning of execution of a transparency group XObject. Initial value: Normal. |
| soft mask (Not supported) | dictionary or name | (PDF 1.4) A soft-mask dictionary specifying the mask shape or mask opacity values to be used in the transparent imaging model, or the name None if no such mask is specified. This parameter is implicitly reset to its initial value at the beginning of execution of a transparency group XObject. Initial value: None. |
| alpha constant | number | (PDF 1.4) The constant shape or constant opacity value to be used in the transparent imaging model. There are two separate alpha constant parameters: one for stroking and one for all other painting operations. This parameter is implicitly reset to its initial value at the beginning of execution of a transparency group XObject. Initial value: 1.0. |
| alpha source | boolean | (PDF 1.4) A flag specifying whether the current soft mask and alpha constant parameters are to be interpreted as shape values (true) or opacity values (false). This flag also governs the interpretation of the SMask entry, if any, in an image dictionary. Initial value: false. |
Currently Not supported
| Field Summary | |
|---|---|
static Name |
CA_NON_STROKING_KEY
|
static Name |
CA_STROKING_KEY
|
| Constructor Summary | |
|---|---|
GraphicsState(GraphicsState parentGraphicsState)
Constructs a new GraphicsState that is a copy of
the specified GraphicsState object. |
|
GraphicsState(Shapes shapes)
Constructs a new GraphicsState which will have default
values and shapes specified by the shapes stack. |
|
| Method Summary | |
|---|---|
void |
concatenate(ExtGState extGState)
Concatenate the specified ExtGState to the current graphics state. |
int |
getAlphaRule()
|
java.awt.geom.Area |
getClip()
|
java.awt.geom.AffineTransform |
getCTM()
|
float[] |
getDashArray()
|
float |
getDashPhase()
|
float |
getFillAlpha()
|
java.awt.Color |
getFillColor()
|
PColorSpace |
getFillColorSpace()
|
int |
getLineCap()
|
int |
getLineJoin()
|
float |
getLineWidth()
|
float |
getMiterLimit()
|
int |
getOverprintMode()
|
SoftMask |
getSoftMask()
|
float |
getStrokeAlpha()
|
java.awt.Color |
getStrokeColor()
|
PColorSpace |
getStrokeColorSpace()
|
TextState |
getTextState()
|
boolean |
isIsolated()
|
boolean |
isKnockOut()
|
boolean |
isOverprintOther()
|
boolean |
isOverprintStroking()
|
boolean |
isTransparencyGroup()
|
GraphicsState |
restore()
Restores the previously saved graphic state. |
GraphicsState |
save()
Saves the current graphics state. |
void |
scale(double x,
double y)
Concatenates this transform with a scaling transformation specified by the graphics state current CTM. |
void |
set(java.awt.geom.AffineTransform af)
Sets the graphics state CTM to a new transform, the old CTM transform is lost. |
void |
setAlphaRule(int alphaRule)
|
void |
setClip(java.awt.Shape newClip)
Set the graphics state clipping area. |
void |
setCTM(java.awt.geom.AffineTransform ctm)
|
void |
setDashArray(float[] dashArray)
|
void |
setDashPhase(float dashPhase)
|
void |
setFillAlpha(float alpha)
|
void |
setFillColor(java.awt.Color fillColor)
|
void |
setFillColorSpace(PColorSpace fillColorSpace)
|
void |
setIsolated(boolean isolated)
|
void |
setKnockOut(boolean knockOut)
|
void |
setLineCap(int lineCap)
|
void |
setLineJoin(int lineJoin)
|
void |
setLineWidth(float lineWidth)
|
void |
setMiterLimit(float miterLimit)
|
void |
setOverprintMode(int overprintMode)
|
void |
setOverprintOther(boolean overprintOther)
|
void |
setOverprintStroking(boolean overprintStroking)
|
void |
setShapes(Shapes shapes)
Sets the Shapes vector. |
void |
setSoftMask(SoftMask softMask)
|
void |
setStrokeAlpha(float alpha)
|
void |
setStrokeColor(java.awt.Color strokeColor)
|
void |
setStrokeColorSpace(PColorSpace strokeColorSpace)
|
void |
setTextState(TextState textState)
|
void |
setTransparencyGroup(boolean transparencyGroup)
|
void |
translate(double x,
double y)
Concatenates this transform with a translation transformation specified by the graphics state current CTM. |
void |
updateClipCM(java.awt.geom.AffineTransform af)
Updates the clip every time the tranformation matrix is updated. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Name CA_STROKING_KEY
public static final Name CA_NON_STROKING_KEY
| Constructor Detail |
|---|
public GraphicsState(Shapes shapes)
GraphicsState which will have default
values and shapes specified by the shapes stack.
shapes - stack containing pages graphical elements.public GraphicsState(GraphicsState parentGraphicsState)
GraphicsState that is a copy of
the specified GraphicsState object.
parentGraphicsState - the GraphicsState object to copy| Method Detail |
|---|
public void setShapes(Shapes shapes)
shapes - shapes for a given content stream.
public void translate(double x,
double y)
x - the distance by which coordinates are translated in the
X axis directiony - the distance by which coordinates are translated in the
Y axis direction
public void scale(double x,
double y)
x - the factor by which coordinates are scaled along the
X axis directiony - the factor by which coordinates are scaled along the
Y axis directionpublic void set(java.awt.geom.AffineTransform af)
af - the AffineTranform object to set the CTM to.public GraphicsState save()
restore()public void concatenate(ExtGState extGState)
extGState - external graphics state.ExtGStatepublic GraphicsState restore()
save()public void updateClipCM(java.awt.geom.AffineTransform af)
af - transform to be applied to the clip.public void setClip(java.awt.Shape newClip)
newClip - new clip for graphic state.public java.awt.geom.Area getClip()
public java.awt.geom.AffineTransform getCTM()
public void setCTM(java.awt.geom.AffineTransform ctm)
public int getLineCap()
public void setLineCap(int lineCap)
public float getLineWidth()
public void setLineWidth(float lineWidth)
public int getLineJoin()
public void setLineJoin(int lineJoin)
public float[] getDashArray()
public void setDashArray(float[] dashArray)
public float getDashPhase()
public void setDashPhase(float dashPhase)
public float getMiterLimit()
public void setMiterLimit(float miterLimit)
public java.awt.Color getFillColor()
public void setFillColor(java.awt.Color fillColor)
public java.awt.Color getStrokeColor()
public void setStrokeAlpha(float alpha)
public float getStrokeAlpha()
public void setFillAlpha(float alpha)
public float getFillAlpha()
public void setStrokeColor(java.awt.Color strokeColor)
public PColorSpace getFillColorSpace()
public void setFillColorSpace(PColorSpace fillColorSpace)
public PColorSpace getStrokeColorSpace()
public void setStrokeColorSpace(PColorSpace strokeColorSpace)
public TextState getTextState()
public void setTextState(TextState textState)
public int getOverprintMode()
public boolean isOverprintStroking()
public boolean isOverprintOther()
public void setOverprintMode(int overprintMode)
public void setOverprintStroking(boolean overprintStroking)
public void setOverprintOther(boolean overprintOther)
public int getAlphaRule()
public void setAlphaRule(int alphaRule)
public boolean isTransparencyGroup()
public void setTransparencyGroup(boolean transparencyGroup)
public boolean isIsolated()
public void setIsolated(boolean isolated)
public boolean isKnockOut()
public void setKnockOut(boolean knockOut)
public SoftMask getSoftMask()
public void setSoftMask(SoftMask softMask)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||