org.apache.fop.render.java2d

Class Java2DGraphicsState


public class Java2DGraphicsState
extends java.lang.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

Java2DGraphicsState(Graphics2D graphics, FontInfo fontInfo, AffineTransform at)
State for storing graphics state.
Java2DGraphicsState(Java2DGraphicsState org)
Copy constructor.

Method Summary

void
dispose()
Frees resources allocated by the current Graphics2D instance.
Color
getColor()
java.awt.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.

Constructor Details

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 Details

dispose

public void dispose()
Frees resources allocated by the current Graphics2D instance.

getColor

public Color getColor()
Returns:
the current java.awt.Color

getFont

public java.awt.Font getFont()
Returns:
the current java.awt.Font

getGraph

public Graphics2D getGraph()
Returns:
the currently valid state

getStroke

public BasicStroke getStroke()
Returns:
the currently active Stroke

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()
See Also:
java.lang.Object.toString()

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 concatonate to the current level transform
See Also:
.

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

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

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

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

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

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