fop 0.91beta

org.apache.fop.render.java2d
Class Java2DGraphicsState

java.lang.Object
  |
  +--org.apache.fop.render.java2d.Java2DGraphicsState
All Implemented Interfaces:
Constants, RendererState

public class Java2DGraphicsState
extends java.lang.Object
implements Constants, RendererState

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.


Fields inherited from interface org.apache.fop.fo.Constants
COMPOUND_COUNT, COMPOUND_MASK, COMPOUND_SHIFT, CP_BLOCK_PROGRESSION_DIRECTION, CP_CONDITIONALITY, CP_INLINE_PROGRESSION_DIRECTION, CP_LENGTH, CP_MAXIMUM, CP_MINIMUM, CP_OPTIMUM, CP_PRECEDENCE, CP_WITHIN_COLUMN, CP_WITHIN_LINE, CP_WITHIN_PAGE, EN_100, EN_200, EN_300, EN_400, EN_500, EN_600, EN_700, EN_800, EN_900, EN_ABSOLUTE, EN_ABSOLUTE_COLORMETRIC, EN_AFTER, EN_AFTER_EDGE, EN_ALL, EN_ALPHABETIC, EN_ALWAYS, EN_ANY, EN_AUTO, EN_AUTO_EVEN, EN_AUTO_ODD, EN_BACKSLANT, EN_BASELINE, EN_BEFORE, EN_BEFORE_EDGE, EN_BIDI_OVERRIDE, EN_BLANK, EN_BLINK, EN_BLOCK, EN_BOLDER, EN_BOTH, EN_BOTTOM, EN_BOUNDED_IN_ONE_DIMENSION, EN_CAPITALIZE, EN_CENTER, EN_CENTRAL, EN_CHARACTER_BY_CHARACTER, EN_COLLAPSE, EN_COLLAPSE_WITH_PRECEDENCE, EN_COLUMN, EN_CONDENSED, EN_CONSIDER_SHIFTS, EN_DASHED, EN_DISCARD, EN_DISREGARD_SHIFTS, EN_DOCUMENT, EN_DOTS, EN_DOTTED, EN_DOUBLE, EN_EMBED, EN_END, EN_END_ON_EVEN, EN_END_ON_ODD, EN_ERROR_IF_OVERFLOW, EN_EVEN, EN_EVEN_PAGE, EN_EXPANDED, EN_EXTRA_CONDENSED, EN_EXTRA_EXPANDED, EN_FALSE, EN_FIC, EN_FIRST, EN_FIXED, EN_FONT_HEIGHT, EN_FORCE, EN_FSWP, EN_GROOVE, EN_HANGING, EN_HIDDEN, EN_HIDE, EN_IDEOGRAPHIC, EN_IGNORE, EN_IGNORE_IF_AFTER_LINEFEED, EN_IGNORE_IF_BEFORE_LINEFEED, EN_IGNORE_IF_SURROUNDING_LINEFEED, EN_INDEFINITE, EN_INDENT, EN_INHERIT, EN_INSET, EN_INSIDE, EN_INTEGER_PIXELS, EN_ITALIC, EN_JUSTIFY, EN_LARGER, EN_LAST, EN_LEFT, EN_LEWP, EN_LIGHTER, EN_LINE, EN_LINE_HEIGHT, EN_LINE_THROUGH, EN_LOWERCASE, EN_LR_TB, EN_LSWP, EN_LTR, EN_MATHEMATICAL, EN_MAX_HEIGHT, EN_MIDDLE, EN_NARROWER, EN_NO_BLINK, EN_NO_CHANGE, EN_NO_FORCE, EN_NO_LIMIT, EN_NO_LINE_THROUGH, EN_NO_OVERLINE, EN_NO_UNDERLINE, EN_NO_WRAP, EN_NON_UNIFORM, EN_NONE, EN_NOREPEAT, EN_NORMAL, EN_NOT_BLANK, EN_OBLIQUE, EN_ODD, EN_ODD_PAGE, EN_OUTSET, EN_OUTSIDE, EN_OVERLINE, EN_PAGE, EN_PAGE_SEQUENCE, EN_PAGINATE, EN_PERCEPTUAL, EN_PRESERVE, EN_REFERENCE_AREA, EN_RELATIVE, EN_RELATIVE_COLOMETRIC, EN_REPEAT, EN_REPEATX, EN_REPEATY, EN_RESAMPLE_ANY_METHOD, EN_RESET_SIZE, EN_REST, EN_RETAIN, EN_RIDGE, EN_RIGHT, EN_RL_TB, EN_RTL, EN_RULE, EN_SATURATION, EN_SCALE_TO_FIT, EN_SCROLL, EN_SEMI_CONDENSED, EN_SEMI_EXPANDED, EN_SEPARATE, EN_SHOW, EN_SMALL_CAPS, EN_SMALLER, EN_SOLID, EN_SPACE, EN_START, EN_STATIC, EN_SUB, EN_SUPER, EN_SUPPRESS, EN_TB_RL, EN_TEXT_AFTER_EDGE, EN_TEXT_BEFORE_EDGE, EN_TEXT_BOTTOM, EN_TEXT_TOP, EN_TOP, EN_TRADITIONAL, EN_TREAT_AS_SPACE, EN_TREAT_AS_ZERO_WIDTH_SPACE, EN_TRUE, EN_ULTRA_CONDENSED, EN_ULTRA_EXPANDED, EN_UNBOUNDED, EN_UNDERLINE, EN_UNIFORM, EN_UPPERCASE, EN_USE_FONT_METRICS, EN_USE_SCRIPT, EN_USECONTENT, EN_VISIBLE, EN_WIDER, EN_WRAP, EN_X_DISTRIBUTE, EN_X_FILL, ENUM_COUNT, FO_BASIC_LINK, FO_BIDI_OVERRIDE, FO_BLOCK, FO_BLOCK_CONTAINER, FO_BOOKMARK, FO_BOOKMARK_TITLE, FO_BOOKMARK_TREE, FO_CHARACTER, FO_COLOR_PROFILE, FO_CONDITIONAL_PAGE_MASTER_REFERENCE, FO_DECLARATIONS, FO_EXTERNAL_GRAPHIC, FO_FLOAT, FO_FLOW, FO_FOOTNOTE, FO_FOOTNOTE_BODY, FO_INITIAL_PROPERTY_SET, FO_INLINE, FO_INLINE_CONTAINER, FO_INPUT, FO_INSTREAM_FOREIGN_OBJECT, FO_LAYOUT_MASTER_SET, FO_LEADER, FO_LIST_BLOCK, FO_LIST_ITEM, FO_LIST_ITEM_BODY, FO_LIST_ITEM_LABEL, FO_MARKER, FO_MULTI_CASE, FO_MULTI_PROPERTIES, FO_MULTI_PROPERTY_SET, FO_MULTI_SWITCH, FO_MULTI_TOGGLE, FO_PAGE_NUMBER, FO_PAGE_NUMBER_CITATION, FO_PAGE_SEQUENCE, FO_PAGE_SEQUENCE_MASTER, FO_PAGE_SEQUENCE_WRAPPER, FO_REGION_AFTER, FO_REGION_BEFORE, FO_REGION_BODY, FO_REGION_END, FO_REGION_START, FO_REPEATABLE_PAGE_MASTER_ALTERNATIVES, FO_REPEATABLE_PAGE_MASTER_REFERENCE, FO_RETRIEVE_MARKER, FO_ROOT, FO_SIMPLE_PAGE_MASTER, FO_SINGLE_PAGE_MASTER_REFERENCE, FO_STATIC_CONTENT, FO_TABLE, FO_TABLE_AND_CAPTION, FO_TABLE_BODY, FO_TABLE_CAPTION, FO_TABLE_CELL, FO_TABLE_COLUMN, FO_TABLE_FOOTER, FO_TABLE_HEADER, FO_TABLE_ROW, FO_TITLE, FO_UNKNOWN_NODE, FO_WRAPPER, FRM_OBJ_COUNT, NOT_SET, PR_ABSOLUTE_POSITION, PR_ACTIVE_STATE, PR_ALIGNMENT_ADJUST, PR_ALIGNMENT_BASELINE, PR_AUTO_RESTORE, PR_AZIMUTH, PR_BACKGROUND, PR_BACKGROUND_ATTACHMENT, PR_BACKGROUND_COLOR, PR_BACKGROUND_IMAGE, PR_BACKGROUND_POSITION, PR_BACKGROUND_POSITION_HORIZONTAL, PR_BACKGROUND_POSITION_VERTICAL, PR_BACKGROUND_REPEAT, PR_BASELINE_SHIFT, PR_BLANK_OR_NOT_BLANK, PR_BLOCK_PROGRESSION_DIMENSION, PR_BORDER, PR_BORDER_AFTER_COLOR, PR_BORDER_AFTER_PRECEDENCE, PR_BORDER_AFTER_STYLE, PR_BORDER_AFTER_WIDTH, PR_BORDER_BEFORE_COLOR, PR_BORDER_BEFORE_PRECEDENCE, PR_BORDER_BEFORE_STYLE, PR_BORDER_BEFORE_WIDTH, PR_BORDER_BOTTOM, PR_BORDER_BOTTOM_COLOR, PR_BORDER_BOTTOM_STYLE, PR_BORDER_BOTTOM_WIDTH, PR_BORDER_COLLAPSE, PR_BORDER_COLOR, PR_BORDER_END_COLOR, PR_BORDER_END_PRECEDENCE, PR_BORDER_END_STYLE, PR_BORDER_END_WIDTH, PR_BORDER_LEFT, PR_BORDER_LEFT_COLOR, PR_BORDER_LEFT_STYLE, PR_BORDER_LEFT_WIDTH, PR_BORDER_RIGHT, PR_BORDER_RIGHT_COLOR, PR_BORDER_RIGHT_STYLE, PR_BORDER_RIGHT_WIDTH, PR_BORDER_SEPARATION, PR_BORDER_SPACING, PR_BORDER_START_COLOR, PR_BORDER_START_PRECEDENCE, PR_BORDER_START_STYLE, PR_BORDER_START_WIDTH, PR_BORDER_STYLE, PR_BORDER_TOP, PR_BORDER_TOP_COLOR, PR_BORDER_TOP_STYLE, PR_BORDER_TOP_WIDTH, PR_BORDER_WIDTH, PR_BOTTOM, PR_BREAK_AFTER, PR_BREAK_BEFORE, PR_CAPTION_SIDE, PR_CASE_NAME, PR_CASE_TITLE, PR_CHARACTER, PR_CLEAR, PR_CLIP, PR_COLOR, PR_COLOR_PROFILE_NAME, PR_COLUMN_COUNT, PR_COLUMN_GAP, PR_COLUMN_NUMBER, PR_COLUMN_WIDTH, PR_CONTENT_HEIGHT, PR_CONTENT_TYPE, PR_CONTENT_WIDTH, PR_COUNTRY, PR_CUE, PR_CUE_AFTER, PR_CUE_BEFORE, PR_DESTINATION_PLACEMENT_OFFSET, PR_DIRECTION, PR_DISPLAY_ALIGN, PR_DOMINANT_BASELINE, PR_ELEVATION, PR_EMPTY_CELLS, PR_END_INDENT, PR_ENDS_ROW, PR_EXTENT, PR_EXTERNAL_DESTINATION, PR_FLOAT, PR_FLOW_NAME, PR_FONT, PR_FONT_FAMILY, PR_FONT_SELECTION_STRATEGY, PR_FONT_SIZE, PR_FONT_SIZE_ADJUST, PR_FONT_STRETCH, PR_FONT_STYLE, PR_FONT_VARIANT, PR_FONT_WEIGHT, PR_FORCE_PAGE_COUNT, PR_FORMAT, PR_GLYPH_ORIENTATION_HORIZONTAL, PR_GLYPH_ORIENTATION_VERTICAL, PR_GROUPING_SEPARATOR, PR_GROUPING_SIZE, PR_HEIGHT, PR_HYPHENATE, PR_HYPHENATION_CHARACTER, PR_HYPHENATION_KEEP, PR_HYPHENATION_LADDER_COUNT, PR_HYPHENATION_PUSH_CHARACTER_COUNT, PR_HYPHENATION_REMAIN_CHARACTER_COUNT, PR_ID, PR_INDEX_CLASS, PR_INDEX_KEY, PR_INDICATE_DESTINATION, PR_INITIAL_PAGE_NUMBER, PR_INLINE_PROGRESSION_DIMENSION, PR_INTERNAL_DESTINATION, PR_INTRUSION_DISPLACE, PR_KEEP_TOGETHER, PR_KEEP_WITH_NEXT, PR_KEEP_WITH_PREVIOUS, PR_LANGUAGE, PR_LAST_LINE_END_INDENT, PR_LEADER_ALIGNMENT, PR_LEADER_LENGTH, PR_LEADER_PATTERN, PR_LEADER_PATTERN_WIDTH, PR_LEFT, PR_LETTER_SPACING, PR_LETTER_VALUE, PR_LINE_HEIGHT, PR_LINE_HEIGHT_SHIFT_ADJUSTMENT, PR_LINE_STACKING_STRATEGY, PR_LINEFEED_TREATMENT, PR_MARGIN, PR_MARGIN_BOTTOM, PR_MARGIN_LEFT, PR_MARGIN_RIGHT, PR_MARGIN_TOP, PR_MARKER_CLASS_NAME, PR_MASTER_NAME, PR_MASTER_REFERENCE, PR_MAX_HEIGHT, PR_MAX_WIDTH, PR_MAXIMUM_REPEATS, PR_MEDIA_USAGE, PR_MIN_HEIGHT, PR_MIN_WIDTH, PR_NUMBER_COLUMNS_REPEATED, PR_NUMBER_COLUMNS_SPANNED, PR_NUMBER_ROWS_SPANNED, PR_ODD_OR_EVEN, PR_ORPHANS, PR_OVERFLOW, PR_PADDING, PR_PADDING_AFTER, PR_PADDING_BEFORE, PR_PADDING_BOTTOM, PR_PADDING_END, PR_PADDING_LEFT, PR_PADDING_RIGHT, PR_PADDING_START, PR_PADDING_TOP, PR_PAGE_BREAK_AFTER, PR_PAGE_BREAK_BEFORE, PR_PAGE_BREAK_INSIDE, PR_PAGE_HEIGHT, PR_PAGE_POSITION, PR_PAGE_WIDTH, PR_PAUSE, PR_PAUSE_AFTER, PR_PAUSE_BEFORE, PR_PITCH, PR_PITCH_RANGE, PR_PLAY_DURING, PR_POSITION, PR_PRECEDENCE, PR_PROVISIONAL_DISTANCE_BETWEEN_STARTS, PR_PROVISIONAL_LABEL_SEPARATION, PR_REF_ID, PR_REFERENCE_ORIENTATION, PR_REGION_NAME, PR_RELATIVE_ALIGN, PR_RELATIVE_POSITION, PR_RENDERING_INTENT, PR_RETRIEVE_BOUNDARY, PR_RETRIEVE_CLASS_NAME, PR_RETRIEVE_POSITION, PR_RICHNESS, PR_RIGHT, PR_ROLE, PR_RULE_STYLE, PR_RULE_THICKNESS, PR_SCALING, PR_SCALING_METHOD, PR_SCORE_SPACES, PR_SCRIPT, PR_SHOW_DESTINATION, PR_SIZE, PR_SOURCE_DOCUMENT, PR_SPACE_AFTER, PR_SPACE_BEFORE, PR_SPACE_END, PR_SPACE_START, PR_SPAN, PR_SPEAK, PR_SPEAK_HEADER, PR_SPEAK_NUMERAL, PR_SPEAK_PUNCTUATION, PR_SPEECH_RATE, PR_SRC, PR_START_INDENT, PR_STARTING_STATE, PR_STARTS_ROW, PR_STRESS, PR_SUPPRESS_AT_LINE_BREAK, PR_SWITCH_TO, PR_TABLE_LAYOUT, PR_TABLE_OMIT_FOOTER_AT_BREAK, PR_TABLE_OMIT_HEADER_AT_BREAK, PR_TARGET_PRESENTATION_CONTEXT, PR_TARGET_PROCESSING_CONTEXT, PR_TARGET_STYLESHEET, PR_TEXT_ALIGN, PR_TEXT_ALIGN_LAST, PR_TEXT_ALTITUDE, PR_TEXT_DECORATION, PR_TEXT_DEPTH, PR_TEXT_INDENT, PR_TEXT_SHADOW, PR_TEXT_TRANSFORM, PR_TOP, PR_TREAT_AS_WORD_SPACE, PR_UNICODE_BIDI, PR_VERTICAL_ALIGN, PR_VISIBILITY, PR_VOICE_FAMILY, PR_VOLUME, PR_WHITE_SPACE_COLLAPSE, PR_WHITE_SPACE_TREATMENT, PR_WIDOWS, PR_WIDTH, PR_WORD_SPACING, PR_WRAP_OPTION, PR_WRITING_MODE, PR_X_BLOCK_PROGRESSION_UNIT, PR_XML_LANG, PR_Z_INDEX, PROPERTY_COUNT, PROPERTY_MASK, XSLT_INPUT
 
Constructor Summary
Java2DGraphicsState(java.awt.Graphics2D graphics, FontInfo fontInfo, java.awt.geom.AffineTransform at)
          State for storing graphics state.
 
Method Summary
 boolean checkClip(java.awt.Shape cl)
          Check if the clip will change the current state.
 boolean checkTransform(java.awt.geom.AffineTransform tf)
          Check the current transform.
 java.awt.Color getColor()
           
 java.awt.Font getFont()
           
 java.awt.Graphics2D getGraph()
           
 int getStackLevel()
          Get the current stack level.
 java.awt.BasicStroke getStroke()
           
 java.awt.geom.AffineTransform getTransform()
          Get the current transform.
 java.awt.Graphics2D pop()
          Pop the state from the stack and restore the graphics context.
 void push()
          Push the current state onto the stack.
 void setTransform(java.awt.geom.AffineTransform tf)
          Overwrites the Transform in the Graphics2D context.
 java.awt.Color toColor(ColorType col)
          Converts a ColorType to a java.awt.Color (sRGB).
 java.lang.String toString()
          a verbose description of the current state
 void transform(java.awt.geom.AffineTransform tf)
          Composes an AffineTransform object with the Transform in this Graphics2D according to the rule last-specified-first-applied.
 boolean updateClip(java.awt.Shape cl)
          Set the current clip.
 boolean updateColor(java.awt.Color col)
          Set the current background color.
 void updateColor(ColorType col)
          Update the current Color
 boolean updateColor(ColorType col, boolean fill, java.lang.StringBuffer pdf)
          Establishes a new foreground or fill color.
 boolean updateFont(java.lang.String name, int size, java.lang.StringBuffer pdf)
          Set the current font name.
 boolean updatePaint(java.awt.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(java.awt.Graphics2D graphics,
                           FontInfo fontInfo,
                           java.awt.geom.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
Method Detail

getGraph

public java.awt.Graphics2D getGraph()
Returns:
the currently valid state

push

public void push()
Description copied from interface: RendererState
Push the current state onto the stack.
Specified by:
push in interface RendererState
See Also:
RendererState.push()

pop

public java.awt.Graphics2D pop()
Description copied from interface: RendererState
Pop the state from the stack and restore the graphics context.
Specified by:
pop in interface RendererState
See Also:
RendererState.pop()

getStackLevel

public int getStackLevel()
Description copied from interface: RendererState
Get the current stack level.
Specified by:
getStackLevel in interface RendererState
See Also:
RendererState.getStackLevel()

updateColor

public boolean updateColor(java.awt.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

toColor

public java.awt.Color toColor(ColorType col)
Converts a ColorType to a java.awt.Color (sRGB).
Parameters:
col - the color as a org.apache.fop.datatypes.ColorType
Returns:
the converted color as a java.awt.Color

updateColor

public boolean updateColor(ColorType col,
                           boolean fill,
                           java.lang.StringBuffer pdf)
Description copied from interface: RendererState
Establishes a new foreground or fill color.
Specified by:
updateColor in interface RendererState
See Also:
RendererState.updateColor(org.apache.fop.datatypes.ColorType, boolean, java.lang.StringBuffer)

updateColor

public void updateColor(ColorType col)
Update the current Color
Parameters:
col - the ColorType

getColor

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

updateFont

public boolean updateFont(java.lang.String name,
                          int size,
                          java.lang.StringBuffer pdf)
Description copied from interface: RendererState
Set the current font name. Check if the font name will change and then set the new name.
Specified by:
updateFont in interface RendererState
See Also:
RendererState.updateFont(java.lang.String, int, java.lang.StringBuffer)

getFont

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

updateStroke

public boolean updateStroke(float width,
                            int style)
Description copied from interface: RendererState
Sets the current Stroke. The line width should be set with updateLineWidth() before calling this method
Specified by:
updateStroke in interface RendererState
See Also:
RendererState.updateStroke(float, int)

getStroke

public java.awt.BasicStroke getStroke()

updatePaint

public boolean updatePaint(java.awt.Paint p)
Description copied from interface: RendererState
Set the current paint. This checks if the paint will change and then sets the current paint.
Specified by:
updatePaint in interface RendererState
See Also:
RendererState.updatePaint(java.awt.Paint)

checkClip

public boolean checkClip(java.awt.Shape cl)
Description copied from interface: RendererState
Check if the clip will change the current state. A clip is assumed to be used in a situation where it will add to any clip in the current or parent states. A clip cannot be cleared, this can only be achieved by going to a parent level with the correct clip. If the clip is different then it may start a new state so that it can return to the previous clip.
Specified by:
checkClip in interface RendererState
See Also:
RendererState.checkClip(java.awt.Shape)

updateClip

public boolean updateClip(java.awt.Shape cl)
Description copied from interface: RendererState
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.
Specified by:
updateClip in interface RendererState
See Also:
RendererState.updateClip(java.awt.Shape)

checkTransform

public boolean checkTransform(java.awt.geom.AffineTransform tf)
Description copied from interface: RendererState
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.
Specified by:
checkTransform in interface RendererState
See Also:
RendererState.checkTransform(java.awt.geom.AffineTransform)

setTransform

public void setTransform(java.awt.geom.AffineTransform tf)
Description copied from interface: RendererState
Overwrites the Transform in the Graphics2D context. Use transform() if you wish to compose with the current Affinetransform instead.
Specified by:
setTransform in interface RendererState
See Also:
RendererState.setTransform(java.awt.geom.AffineTransform)

transform

public void transform(java.awt.geom.AffineTransform tf)
Description copied from interface: RendererState
Composes an AffineTransform object with the Transform in this Graphics2D according to the rule last-specified-first-applied.
Specified by:
transform in interface RendererState
See Also:
RendererState.transform(java.awt.geom.AffineTransform)

getTransform

public java.awt.geom.AffineTransform getTransform()
Description copied from interface: RendererState
Get the current transform. This gets the combination of all transforms in the current state.
Specified by:
getTransform in interface RendererState
See Also:
RendererState.getTransform()

toString

public java.lang.String toString()
a verbose description of the current state
Overrides:
toString in class java.lang.Object

fop 0.91beta

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