fop 0.93

org.apache.fop.pdf
Class PDFState

java.lang.Object
  extended byorg.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.


Nested Class Summary
 class PDFState.Data
           
 
Constructor Summary
PDFState()
          PDF State for storing graphics state.
 
Method Summary
 boolean checkClip(java.awt.Shape cl)
          Check if the clip will change the current state.
 boolean checkTransform(java.awt.geom.AffineTransform tf)
          Check the current transform.
 void concatenate(java.awt.geom.AffineTransform tf)
          Concatenates the given AffineTransform to the current one.
 PDFState.Data getData()
           
 PDFGState getGState()
          Get the grapics state.
 int getStackLevel()
          Get the current stack level.
 java.awt.geom.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(java.awt.Color col)
          Set the current background color.
 void setClip(java.awt.Shape cl)
          Set the current clip.
 boolean setColor(java.awt.Color col)
          Set the current color.
 boolean setLineWidth(float width)
          Set the current line width.
 boolean setPaint(java.awt.Paint p)
          Set the current paint.
 void setTransform(java.awt.geom.AffineTransform tf)
          Deprecated. This method name is misleading. Use concatenate(AffineTransform) instead!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDFState

public PDFState()
PDF State for storing graphics state.

Method Detail

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.


getData

public PDFState.Data getData()
Returns:
the currently valid 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.

Returns:
the restored state, null if the stack is empty

getStackLevel

public int getStackLevel()
Get the current stack level.

Returns:
the current stack level

setLineWidth

public boolean setLineWidth(float width)
Set the current line width.

Parameters:
width - the line width in points
Returns:
true if the line width has changed

setColor

public boolean setColor(java.awt.Color col)
Set the current color. Check if the new color is a change and then set the current color.

Parameters:
col - the color to set
Returns:
true if the color has changed

setBackColor

public boolean setBackColor(java.awt.Color col)
Set the current background color. Check if the background color will change and then set the new color.

Parameters:
col - the new background color
Returns:
true if the background color has changed

setPaint

public boolean setPaint(java.awt.Paint p)
Set the current paint. This checks if the paint will change and then sets the current paint.

Parameters:
p - the new paint
Returns:
true if the new paint changes the current paint

checkClip

public boolean checkClip(java.awt.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.

Parameters:
cl - the clip shape to check
Returns:
true if the clip will change the current clip.

setClip

public void setClip(java.awt.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.

Parameters:
cl - the new clip in the current state

checkTransform

public boolean checkTransform(java.awt.geom.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.

Parameters:
tf - the transform the check against
Returns:
true if the new transform is different then the current transform

setTransform

public void setTransform(java.awt.geom.AffineTransform tf)
Deprecated. 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.

Parameters:
tf - the transform to concatonate to the current level transform

concatenate

public void concatenate(java.awt.geom.AffineTransform tf)
Concatenates the given AffineTransform to the current one.

Parameters:
tf - the transform to concatenate to the current level transform

getTransform

public java.awt.geom.AffineTransform getTransform()
Get the current transform. This gets the combination of all transforms in the current state.

Returns:
the calculate combined transform for the current state

getGState

public PDFGState getGState()
Get the grapics 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.

Returns:
the calculated ExtGState in the current context

fop 0.93

Copyright 1999-2006 The Apache Software Foundation. All Rights Reserved.