Class PDFPaintingState

java.lang.Object
org.apache.fop.util.AbstractPaintingState
org.apache.fop.pdf.PDFPaintingState
All Implemented Interfaces:
Serializable, Cloneable

public class PDFPaintingState extends AbstractPaintingState
This keeps information about the current painting 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.
See Also:
  • Constructor Details

    • PDFPaintingState

      public PDFPaintingState()
      PDF State for storing graphics state.
  • Method Details

    • setPaint

      public boolean setPaint(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(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(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
    • setCharacterSpacing

      public boolean setCharacterSpacing(float value)
      Sets the character spacing (Tc).
      Parameters:
      value - the new value
      Returns:
      true if the value was changed with respect to the previous value
    • getCharacterSpacing

      public float getCharacterSpacing()
      Returns the current character spacing (Tc) value.
      Returns:
      the Tc value
    • getStackLevel

      public int getStackLevel()
      Get the current stack level.
      Returns:
      the current stack level
    • 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.
      Returns:
      the calculated ExtGState in the current context
    • setLayer

      public void setLayer(String layer)
    • getLayer

      public String getLayer()
    • getLayerChanged

      public boolean getLayerChanged()
    • instantiateData

      protected AbstractPaintingState.AbstractData instantiateData()
      Instantiates a new state data object
      Specified by:
      instantiateData in class AbstractPaintingState
      Returns:
      a new state data object
    • instantiate

      protected AbstractPaintingState instantiate()
      Instantiates a new state object
      Specified by:
      instantiate in class AbstractPaintingState
      Returns:
      a new state object
    • save

      public void save()
      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.
      Overrides:
      save in class AbstractPaintingState