Package org.apache.fop.util
Class AbstractPaintingState
- java.lang.Object
-
- org.apache.fop.util.AbstractPaintingState
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
AFPPaintingState
,PDFPaintingState
public abstract class AbstractPaintingState extends java.lang.Object implements java.lang.Cloneable, java.io.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 Description class
AbstractPaintingState.AbstractData
A base painting state data holding objectclass
AbstractPaintingState.StateStack<E>
A stack implementation which holds state objects
-
Constructor Summary
Constructors Constructor Description AbstractPaintingState()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
checkTransform(java.awt.geom.AffineTransform tf)
Check the current transform.void
clear()
Clears the state stackvoid
clearTransform()
Clears the current AffineTransform to the Identity AffineTransformjava.lang.Object
clone()
void
concatenate(java.awt.geom.AffineTransform at)
Concatenates the given AffineTransform to the current one.java.awt.Color
getBackColor()
Get the background color.java.awt.geom.AffineTransform
getBaseTransform()
Get a copy of the base transform for the page.java.awt.Color
getColor()
Get the color.AbstractPaintingState.AbstractData
getData()
Returns the currently valid statejava.lang.String
getFontName()
Gets the current font nameint
getFontSize()
Gets the current font sizefloat
getLineWidth()
Returns the current line widthprotected java.util.Stack<AbstractPaintingState.AbstractData>
getStateStack()
Return the state stackjava.awt.geom.AffineTransform
getTransform()
Get the current transform.protected abstract AbstractPaintingState
instantiate()
Instantiates a new state objectprotected abstract AbstractPaintingState.AbstractData
instantiateData()
Instantiates a new state data objectvoid
resetTransform()
Resets the current AffineTransform to the Base AffineTransform.AbstractPaintingState.AbstractData
restore()
Restore the current painting state.java.util.List<AbstractPaintingState.AbstractData>
restoreAll()
Restore all painting state data.void
save()
Save the current painting state.void
saveAll(java.util.List<AbstractPaintingState.AbstractData> dataList)
Save all painting state data.boolean
setBackColor(java.awt.Color col)
Set the current background color.boolean
setColor(java.awt.Color col)
Set the current color.boolean
setDashArray(float[] dash)
Sets the dash array (line type) for the current basic strokeprotected void
setData(AbstractPaintingState.AbstractData data)
Sets the current state databoolean
setFontName(java.lang.String internalFontName)
Set the current font nameboolean
setFontSize(int size)
Set the current font size.boolean
setLineWidth(float width)
Set the current line width.java.lang.String
toString()
-
-
-
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(java.awt.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 java.awt.Color getColor()
Get the color.- Returns:
- the color
-
getBackColor
public java.awt.Color getBackColor()
Get the background color.- Returns:
- the background color
-
setBackColor
public boolean setBackColor(java.awt.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(java.lang.String internalFontName)
Set the current font name- Parameters:
internalFontName
- the internal font name- Returns:
- true if the font name has changed
-
getFontName
public java.lang.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 java.awt.geom.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(java.awt.geom.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 java.awt.geom.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(java.awt.geom.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(java.util.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 java.util.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 java.util.Stack<AbstractPaintingState.AbstractData> getStateStack()
Return the state stack- Returns:
- the state stack
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-