org.apache.fop.util

## Class AbstractPaintingState

- java.lang.Object
- - org.apache.fop.util.AbstractPaintingState

- All Implemented Interfaces:
    Serializable, Cloneable
  Direct Known Subclasses:
    AFPPaintingState, PDFPaintingState

      public abstract class AbstractPaintingState
      extends Object
      implements Cloneable, Serializable

  A base class which holds information about the current painting state.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `AbstractPaintingState.AbstractData` A base painting state data holding object
    `class` | `AbstractPaintingState.StateStack<E>` A stack implementation which holds state objects

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractPaintingState()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `checkTransform(AffineTransform tf)` Check the current transform.
    `void` | `clear()` Clears the state stack
    `void` | `clearTransform()` Clears the current AffineTransform to the Identity AffineTransform
    `Object` | `clone()`
    `void` | `concatenate(AffineTransform at)` Concatenates the given AffineTransform to the current one.
    `Color` | `getBackColor()` Get the background color.
    `AffineTransform` | `getBaseTransform()` Get a copy of the base transform for the page.
    `Color` | `getColor()` Get the color.
    `AbstractPaintingState.AbstractData` | `getData()` Returns the currently valid state
    `String` | `getFontName()` Gets the current font name
    `int` | `getFontSize()` Gets the current font size
    `float` | `getLineWidth()` Returns the current line width
    `protected Stack<AbstractPaintingState.AbstractData>` | `getStateStack()` Return the state stack
    `AffineTransform` | `getTransform()` Get the current transform.
    `protected abstract AbstractPaintingState` | `instantiate()` Instantiates a new state object
    `protected abstract AbstractPaintingState.AbstractData` | `instantiateData()` Instantiates a new state data object
    `void` | `resetTransform()` Resets the current AffineTransform to the Base AffineTransform.
    `AbstractPaintingState.AbstractData` | `restore()` Restore the current painting state.
    `List<AbstractPaintingState.AbstractData>` | `restoreAll()` Restore all painting state data.
    `void` | `save()` Save the current painting state.
    `void` | `saveAll(List<AbstractPaintingState.AbstractData> dataList)` Save all painting state data.
    `boolean` | `setBackColor(Color col)` Set the current background color.
    `boolean` | `setColor(Color col)` Set the current color.
    `boolean` | `setDashArray(float[] dash)` Sets the dash array (line type) for the current basic stroke
    `protected void` | `setData(AbstractPaintingState.AbstractData data)` Sets the current state data
    `boolean` | `setFontName(String internalFontName)` Set the current font name
    `boolean` | `setFontSize(int size)` Set the current font size.
    `boolean` | `setLineWidth(float width)` Set the current line width.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractPaintingState

          public AbstractPaintingState()

  - ### Method Detail

    - #### instantiateData

          protected abstract AbstractPaintingState.AbstractData instantiateData()

      Instantiates a new state data object
      Returns:
        a new state data object

    - #### instantiate

          protected abstract AbstractPaintingState instantiate()

      Instantiates a new state object
      Returns:
        a new state object

    - #### getData

          public AbstractPaintingState.AbstractData getData()

      Returns the currently valid state
      Returns:
        the currently valid 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.
      Parameters:
        `col` - the color to set
      Returns:
        true if the color has changed

    - #### getColor

          public Color getColor()

      Get the color.
      Returns:
        the color

    - #### getBackColor

          public Color getBackColor()

      Get the background color.
      Returns:
        the background color

    - #### setBackColor

          public boolean setBackColor(Color col)

      Set the current background color. Check if the new background color is a change and then set the current background color.
      Parameters:
        `col` - the background color to set
      Returns:
        true if the color has changed

    - #### setFontName

          public boolean setFontName(String internalFontName)

      Set the current font name
      Parameters:
        `internalFontName` - the internal font name
      Returns:
        true if the font name has changed

    - #### getFontName

          public String getFontName()

      Gets the current font name
      Returns:
        the current font name

    - #### getFontSize

          public int getFontSize()

      Gets the current font size
      Returns:
        the current font size

    - #### setFontSize

          public boolean setFontSize(int size)

      Set the current font size. Check if the font size is a change and then set the current font size.
      Parameters:
        `size` - the font size to set
      Returns:
        true if the font size has changed

    - #### 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

    - #### getLineWidth

          public float getLineWidth()

      Returns the current line width
      Returns:
        the current line width

    - #### setDashArray

          public boolean setDashArray(float[] dash)

      Sets the dash array (line type) for the current basic stroke
      Parameters:
        `dash` - the line dash array
      Returns:
        true if the dash array has changed

    - #### getTransform

          public 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

    - #### 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.
      Parameters:
        `tf` - the transform the check against
      Returns:
        true if the new transform is different then the current 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".
      Returns:
        the base transform, or null if the state stack is empty

    - #### concatenate

          public void concatenate(AffineTransform at)

      Concatenates the given AffineTransform to the current one.
      Parameters:
        `at` - the transform to concatenate to the current level transform

    - #### resetTransform

          public void resetTransform()

      Resets the current AffineTransform to the Base AffineTransform.

    - #### clearTransform

          public void clearTransform()

      Clears the current AffineTransform to the Identity AffineTransform

    - #### save

          public void save()

      Save the current painting state. This pushes the current painting state onto the stack. This call should be used when the Q operator is used so that the state is known when popped.

    - #### restore

          public AbstractPaintingState.AbstractData restore()

      Restore the current painting state. This pops the painting state from the stack and sets current values to popped state.
      Returns:
        the restored state, null if the stack is empty

    - #### saveAll

          public void saveAll(List<AbstractPaintingState.AbstractData> dataList)

      Save all painting state data. This pushes all painting state data in the given list to the stack
      Parameters:
        `dataList` - a state data list

    - #### restoreAll

          public List<AbstractPaintingState.AbstractData> restoreAll()

      Restore all painting state data. This pops all painting state data from the stack
      Returns:
        a list of state data popped from the stack

    - #### setData

          protected void setData(AbstractPaintingState.AbstractData data)

      Sets the current state data
      Parameters:
        `data` - the state data

    - #### clear

          public void clear()

      Clears the state stack

    - #### getStateStack

          protected Stack<AbstractPaintingState.AbstractData> getStateStack()

      Return the state stack
      Returns:
        the state stack

    - #### clone

          public Object clone()

      Overrides:
        `clone` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2023 Apache Software Foundation. All rights reserved.