org.apache.fop.pdf
Class PDFState
java.lang.Object
org.apache.fop.pdf.PDFState
public class PDFState
extends java.lang.Object
This keeps information about the current state when writing to pdf.
It allows for creating new graphics states with the q operator.
This class is only used to store the information about the state
the caller needs to handle the actual pdf operators.
When setting the state for pdf there are three possible ways of
handling the situation.
The values can be set to override previous or default values.
A new state can be added and then the values set.
The current state can be popped and values will return to a
previous state then the necessary values can be overridden.
The current transform behaves differently to other values as the
matrix is combined with the current resolved value.
It is impossible to optimise the result without analysing the all
the possible combinations after completing.
PDFState() - PDF State for storing graphics state.
|
boolean | checkClip(Shape cl) - Check if the clip will change the current state.
|
boolean | checkTransform(AffineTransform tf) - Check the current transform.
|
void | concatenate(AffineTransform tf) - Concatenates the given AffineTransform to the current one.
|
AffineTransform | getBaseTransform() - Get a copy of the base transform for the page.
|
PDFState.Data | getData()
|
PDFGState | getGState() - Get the graphics state.
|
int | getStackLevel() - Get the current stack level.
|
AffineTransform | getTransform() - Get the current transform.
|
PDFState.Data | pop() - Pop the state from the stack and set current values to popped state.
|
void | push() - Push the current state onto the stack.
|
boolean | setBackColor(Color col) - Set the current background color.
|
void | setClip(Shape cl) - Set the current clip.
|
boolean | setColor(Color col) - Set the current color.
|
boolean | setLineWidth(float width) - Set the current line width.
|
boolean | setPaint(Paint p) - Set the current paint.
|
void | setTransform(AffineTransform tf) - This method name is misleading.
|
PDFState
public PDFState()
PDF State for storing graphics state.
checkClip
public boolean checkClip(Shape cl)
Check if the clip will change the current state.
A clip is assumed to be used in a situation where it will add
to any clip in the current or parent states.
A clip cannot be cleared, this can only be achieved by going to
a parent level with the correct clip.
If the clip is different then it may start a new state so that
it can return to the previous clip.
cl
- the clip shape to check
- true if the clip will change the current clip.
checkTransform
public boolean checkTransform(AffineTransform tf)
Check the current transform.
The transform for the current state is the combination of all
transforms in the current state. The parameter is compared
against this current transform.
tf
- the transform the check against
- true if the new transform is different then the current transform
concatenate
public void concatenate(AffineTransform tf)
Concatenates the given AffineTransform to the current one.
tf
- the transform to concatenate to the current level transform
getBaseTransform
public AffineTransform getBaseTransform()
Get a copy of the base transform for the page. Used to translate
IPP/BPP values into X,Y positions when positioning is "fixed".
- the base transform, or null if the state stack is empty
getGState
public PDFGState getGState()
Get the graphics state.
This gets the combination of all graphic states for
the current context.
This is the graphic state set with the gs operator not
the other graphic state changes.
- the calculated ExtGState in the current context
getStackLevel
public int getStackLevel()
Get the current stack level.
getTransform
public AffineTransform getTransform()
Get the current transform.
This gets the combination of all transforms in the
current state.
- the calculate combined transform for the current state
pop
public PDFState.Data pop()
Pop the state from the stack and set current values to popped state.
This should be called when a Q operator is used so
the state is restored to the correct values.
- the restored state, null if the stack is empty
push
public void push()
Push the current state onto the stack.
This call should be used when the q operator is used
so that the state is known when popped.
setBackColor
public boolean setBackColor(Color col)
Set the current background color.
Check if the background color will change and then set the new color.
col
- the new background color
- true if the background color has changed
setClip
public void setClip(Shape cl)
Set the current clip.
This either sets a new clip or sets the clip to the intersect of
the old clip and the new clip.
cl
- the new clip in the current state
setColor
public boolean setColor(Color col)
Set the current color.
Check if the new color is a change and then set the current color.
- true if the color has changed
setLineWidth
public boolean setLineWidth(float width)
Set the current line width.
width
- the line width in points
- true if the line width has changed
setPaint
public boolean setPaint(Paint p)
Set the current paint.
This checks if the paint will change and then sets the current paint.
- true if the new paint changes the current paint
setTransform
public void setTransform(AffineTransform tf)
This method name is misleading. Use concatenate(AffineTransform) instead!
Set a new transform.
This transform is appended to the transform of
the current graphic state.
tf
- the transform to concatonate to the current level transform
Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.