Package org.apache.fop.render.java2d
Class Java2DGraphicsState
java.lang.Object
org.apache.fop.render.java2d.Java2DGraphicsState
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
ConstructorDescriptionJava2DGraphicsState
(Graphics2D graphics, FontInfo fontInfo, AffineTransform at) State for storing graphics state.Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Frees resources allocated by the current Graphics2D instance.getColor()
getFont()
getGraph()
Get the current transform.toString()
void
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.
-
Constructor Details
-
Java2DGraphicsState
State for storing graphics state.- Parameters:
graphics
- the graphics associated with the BufferedImagefontInfo
- the FontInfo from the rendererat
- the initial AffineTransform containing the scale transformation
-
Java2DGraphicsState
Copy constructor.- Parameters:
org
- the instance to copy
-
-
Method Details
-
getGraph
- Returns:
- the currently valid state
-
dispose
public void dispose()Frees resources allocated by the current Graphics2D instance. -
updateColor
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
- Returns:
- the current java.awt.Color
-
updateFont
Set the current font name. Check if the font name will change and then set the new name.- Parameters:
name
- the new font namesize
- the font size- Returns:
- true if the new Font changes the current 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 widthstyle
- the constant for the style of the line as an int- Returns:
- true if the new Stroke changes the current Stroke
-
getStroke
- Returns:
- the currently active Stroke
-
updatePaint
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
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
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:
-
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
-