org.apache.fop.render.java2d

## Class Java2DGraphicsState

- java.lang.Object
- - org.apache.fop.render.java2d.Java2DGraphicsState

-     public class Java2DGraphicsState
      extends Object

  Keeps information about the current state of the Graphics2D currentGraphics. It is also used as a stack to hold a graphics context.

  The graphics context is updated with the updateXXX() methods.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Java2DGraphicsState(Graphics2D graphics, FontInfo fontInfo, AffineTransform at)` State for storing graphics state.
    `Java2DGraphicsState(Java2DGraphicsState org)` Copy constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `dispose()` Frees resources allocated by the current Graphics2D instance.
    `Color` | `getColor()`
    `Font` | `getFont()`
    `Graphics2D` | `getGraph()`
    `BasicStroke` | `getStroke()`
    `AffineTransform` | `getTransform()` Get the current transform.
    `String` | `toString()`
    `void` | `transform(AffineTransform tf)` Composes an AffineTransform object with the Transform in this Graphics2D according to the rule last-specified-first-applied.
    `boolean` | `updateClip(Shape cl)` Set the current clip.
    `boolean` | `updateColor(Color col)` Set the current background color.
    `boolean` | `updateFont(String name, int size)` Set the current font name.
    `boolean` | `updatePaint(Paint p)` Set the current paint.
    `boolean` | `updateStroke(float width, int style)` Sets the current Stroke.

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

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

- - ### Constructor Detail

    - #### Java2DGraphicsState

          public Java2DGraphicsState(Graphics2D graphics,
                                     FontInfo fontInfo,
                                     AffineTransform at)

      State for storing graphics state.
      Parameters:
        `graphics` - the graphics associated with the BufferedImage
        `fontInfo` - the FontInfo from the renderer
        `at` - the initial AffineTransform containing the scale transformation

    - #### Java2DGraphicsState

          public Java2DGraphicsState(Java2DGraphicsState org)

      Copy constructor.
      Parameters:
        `org` - the instance to copy

  - ### Method Detail

    - #### getGraph

          public Graphics2D getGraph()

      Returns:
        the currently valid state

    - #### dispose

          public void dispose()

      Frees resources allocated by the current Graphics2D instance.

    - #### updateColor

          public boolean updateColor(Color col)

      Set the current background color. Check if the background color will change and then set the new color.
      Parameters:
        `col` - the new color as a java.awt.Color
      Returns:
        true if the background color has changed

    - #### getColor

          public Color getColor()

      Returns:
        the current java.awt.Color

    - #### updateFont

          public boolean updateFont(String name,
                                    int size)

      Set the current font name. Check if the font name will change and then set the new name.
      Parameters:
        `name` - the new font name
        `size` - the font size
      Returns:
        true if the new Font changes the current Font

    - #### getFont

          public Font getFont()

      Returns:
        the current java.awt.Font

    - #### updateStroke

          public boolean updateStroke(float width,
                                      int style)

      Sets the current Stroke. The line width should be set with updateLineWidth() before calling this method
      Parameters:
        `width` - the line width
        `style` - the constant for the style of the line as an int
      Returns:
        true if the new Stroke changes the current Stroke

    - #### getStroke

          public BasicStroke getStroke()

      Returns:
        the currently active Stroke

    - #### updatePaint

          public boolean updatePaint(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

    - #### updateClip

          public boolean updateClip(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
      Returns:
        true if the clip shape needed to be updated

    - #### transform

          public void transform(AffineTransform tf)

      Composes an AffineTransform object with the Transform in this Graphics2D according to the rule last-specified-first-applied.
      Parameters:
        `tf` - the transform to concatenate to the current level transform
      See Also:
        `Graphics2D.transform(AffineTransform)`

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

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2023 Apache Software Foundation. All rights reserved.