public abstract class AbstractContentParser extends java.lang.Object implements ContentParser
| Modifier and Type | Field and Description |
|---|---|
protected java.awt.geom.GeneralPath |
geometricPath |
protected float |
glyph2UserSpaceScale |
protected GraphicsState |
graphicState |
protected java.util.concurrent.atomic.AtomicInteger |
imageIndex |
protected boolean |
inTextBlock |
protected Library |
library |
protected java.util.LinkedList<OptionalContents> |
oCGs |
static float |
OVERPAINT_ALPHA |
protected Resources |
resources |
protected Shapes |
shapes |
protected java.util.Stack<java.lang.Object> |
stack |
protected java.awt.geom.AffineTransform |
textBlockBase |
| Constructor and Description |
|---|
AbstractContentParser(Library l,
Resources r) |
| Modifier and Type | Method and Description |
|---|---|
protected static java.awt.geom.AffineTransform |
applyTextScaling(GraphicsState graphicState)
Text scaling must be applied to the main graphic state.
|
protected static void |
commonFill(Shapes shapes,
GraphicsState graphicState,
java.awt.geom.GeneralPath geometricPath)
Common fill operations used by f, F, F*, b, b*, B, B*.
|
protected static float |
commonOverPrintAlpha(float alpha,
PColorSpace colorSpace)
Utility method for fudging overprinting calculation for screen
representation.
|
protected static void |
commonStroke(GraphicsState graphicState,
Shapes shapes,
java.awt.geom.GeneralPath geometricPath)
Common stroke operations used by S and s.
|
protected static java.awt.geom.GeneralPath |
consume_b_star(GraphicsState graphicState,
Shapes shapes,
java.awt.geom.GeneralPath geometricPath) |
protected static java.awt.geom.GeneralPath |
consume_B_star(GraphicsState graphicState,
Shapes shapes,
java.awt.geom.GeneralPath geometricPath) |
protected static java.awt.geom.GeneralPath |
consume_b(GraphicsState graphicState,
Shapes shapes,
java.awt.geom.GeneralPath geometricPath) |
protected static java.awt.geom.GeneralPath |
consume_B(GraphicsState graphicState,
Shapes shapes,
java.awt.geom.GeneralPath geometricPath) |
protected static void |
consume_BDC(java.util.Stack stack,
Shapes shapes,
java.util.LinkedList<OptionalContents> oCGs,
Resources resources) |
protected static void |
consume_BMC(java.util.Stack stack,
Shapes shapes,
java.util.LinkedList<OptionalContents> oCGs,
Resources resources) |
protected static java.awt.geom.GeneralPath |
consume_c(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath) |
protected static void |
consume_cm(GraphicsState graphicState,
java.util.Stack stack,
boolean inTextBlock,
java.awt.geom.AffineTransform textBlockBase) |
protected static void |
consume_cs(GraphicsState graphicState,
java.util.Stack stack,
Resources resources) |
protected static void |
consume_CS(GraphicsState graphicState,
java.util.Stack stack,
Resources resources) |
protected static void |
consume_d(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes) |
protected static GraphicsState |
consume_d0(GraphicsState graphicState,
java.util.Stack stack) |
protected static GraphicsState |
consume_d1(GraphicsState graphicState,
java.util.Stack stack) |
protected static GraphicsState |
consume_Do(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes,
Resources resources,
boolean viewParse,
java.util.concurrent.atomic.AtomicInteger imageIndex,
Page page)
Process the xObject content.
|
protected static void |
consume_double_quote(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes,
TextMetrics textMetrics,
GlyphOutlineClip glyphOutlineClip,
java.util.LinkedList<OptionalContents> oCGs) |
static void |
consume_DP(java.util.Stack stack) |
protected static void |
consume_EMC(Shapes shapes,
java.util.LinkedList<OptionalContents> oCGs) |
protected static java.awt.geom.GeneralPath |
consume_f_star(GraphicsState graphicState,
Shapes shapes,
java.awt.geom.GeneralPath geometricPath) |
protected static java.awt.geom.GeneralPath |
consume_f(GraphicsState graphicState,
Shapes shapes,
java.awt.geom.GeneralPath geometricPath) |
protected static java.awt.geom.GeneralPath |
consume_F(GraphicsState graphicState,
Shapes shapes,
java.awt.geom.GeneralPath geometricPath) |
protected static void |
consume_g(GraphicsState graphicState,
java.util.Stack stack,
Library library) |
protected static void |
consume_G(GraphicsState graphicState,
java.util.Stack stack,
Library library) |
protected static void |
consume_gs(GraphicsState graphicState,
java.util.Stack stack,
Resources resources) |
protected static void |
consume_h(java.awt.geom.GeneralPath geometricPath) |
protected static void |
consume_i(java.util.Stack stack) |
protected static void |
consume_j(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes) |
protected static void |
consume_J(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes) |
protected static void |
consume_k(GraphicsState graphicState,
java.util.Stack stack,
Library library) |
protected static void |
consume_K(GraphicsState graphicState,
java.util.Stack stack,
Library library) |
protected static java.awt.geom.GeneralPath |
consume_L(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath) |
protected static void |
consume_M(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes) |
protected static java.awt.geom.GeneralPath |
consume_m(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath) |
static void |
consume_MP(java.util.Stack stack) |
protected static java.awt.geom.GeneralPath |
consume_n(java.awt.geom.GeneralPath geometricPath) |
protected static GraphicsState |
consume_q(GraphicsState graphicState) |
protected GraphicsState |
consume_Q(GraphicsState graphicState,
Shapes shapes) |
protected static java.awt.geom.GeneralPath |
consume_re(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath) |
protected static void |
consume_rg(GraphicsState graphicState,
java.util.Stack stack,
Library library) |
protected static void |
consume_RG(GraphicsState graphicState,
java.util.Stack stack,
Library library) |
protected static void |
consume_ri(java.util.Stack stack) |
protected static java.awt.geom.GeneralPath |
consume_s(GraphicsState graphicState,
Shapes shapes,
java.awt.geom.GeneralPath geometricPath) |
protected static java.awt.geom.GeneralPath |
consume_S(GraphicsState graphicState,
Shapes shapes,
java.awt.geom.GeneralPath geometricPath) |
protected static void |
consume_sc(GraphicsState graphicState,
java.util.Stack stack,
Library library,
Resources resources,
boolean isTint) |
protected static void |
consume_SC(GraphicsState graphicState,
java.util.Stack stack,
Library library,
Resources resources,
boolean isTint) |
static void |
consume_sh(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes,
Resources resources) |
protected static void |
consume_single_quote(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes,
TextMetrics textMetrics,
GlyphOutlineClip glyphOutlineClip,
java.util.LinkedList<OptionalContents> oCGs) |
protected static void |
consume_T_star(GraphicsState graphicState,
TextMetrics textMetrics,
PageText pageText,
java.util.LinkedList<OptionalContents> oCGs) |
protected static void |
consume_Tc(GraphicsState graphicState,
java.util.Stack stack) |
protected static void |
consume_Td(GraphicsState graphicState,
java.util.Stack stack,
TextMetrics textMetrics,
PageText pageText,
double previousBTStart,
java.util.LinkedList<OptionalContents> oCGs) |
protected static void |
consume_TD(GraphicsState graphicState,
java.util.Stack stack,
TextMetrics textMetrics,
PageText pageText,
java.util.LinkedList<OptionalContents> oCGs) |
protected static void |
consume_Tf(GraphicsState graphicState,
java.util.Stack stack,
Resources resources) |
protected static void |
consume_Tj(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes,
TextMetrics textMetrics,
GlyphOutlineClip glyphOutlineClip,
java.util.LinkedList<OptionalContents> oCGs) |
protected static void |
consume_TJ(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes,
TextMetrics textMetrics,
GlyphOutlineClip glyphOutlineClip,
java.util.LinkedList<OptionalContents> oCGs) |
protected static void |
consume_TL(GraphicsState graphicState,
java.util.Stack stack) |
protected static void |
consume_tm(GraphicsState graphicState,
java.util.Stack stack,
TextMetrics textMetrics,
PageText pageText,
double previousBTStart,
java.awt.geom.AffineTransform textBlockBase,
java.util.LinkedList<OptionalContents> oCGs) |
protected static void |
consume_Tr(GraphicsState graphicState,
java.util.Stack stack) |
protected static void |
consume_Ts(GraphicsState graphicState,
java.util.Stack stack) |
protected static void |
consume_Tw(GraphicsState graphicState,
java.util.Stack stack) |
protected static void |
consume_Tz(GraphicsState graphicState,
java.util.Stack stack) |
protected static void |
consume_v(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath) |
static void |
consume_W_star(GraphicsState graphicState,
java.awt.geom.GeneralPath geometricPath) |
protected static void |
consume_W(GraphicsState graphicState,
java.awt.geom.GeneralPath geometricPath) |
protected static void |
consume_w(GraphicsState graphicState,
java.util.Stack stack,
Shapes shapes,
float glyph2UserSpaceScale) |
protected static void |
consume_y(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath) |
protected static void |
drawModeFill(GraphicsState graphicState,
TextSprite textSprites,
Shapes shapes,
int rmode)
Utility Method for adding a text sprites to the Shapes stack, given the
specified rmode.
|
protected static void |
drawModeFillStroke(GraphicsState graphicState,
TextSprite textSprites,
TextState textState,
Shapes shapes,
int rmode)
Utility Method for adding a text sprites to the Shapes stack, given the
specifed rmode.
|
protected static void |
drawModeStroke(GraphicsState graphicState,
TextSprite textSprites,
TextState textState,
Shapes shapes,
int rmode)
Utility Method for adding a text sprites to the Shapes stack, given the
specifed rmode.
|
protected static void |
drawString(java.lang.StringBuilder displayText,
TextMetrics textMetrics,
TextState textState,
Shapes shapes,
GlyphOutlineClip glyphOutlineClip,
GraphicsState graphicState,
java.util.LinkedList<OptionalContents> oCGs)
Utility method for calculating the advanceX need for the
displayText given the strings parsed textState. |
GraphicsState |
getGraphicsState()
Returns the current graphics state object being used by this content
stream.
|
Shapes |
getShapes()
Returns the Shapes that have accumulated turing multiple calls to
parse().
|
java.util.Stack<java.lang.Object> |
getStack()
Returns the stack of object used to parse content streams.
|
abstract ContentParser |
parse(byte[][] streamBytes,
Page page)
Parse a pages content stream.
|
abstract Shapes |
parseTextBlocks(byte[][] source)
Specialized method for extracting text from documents.
|
protected static void |
setAlpha(Shapes shapes,
int rule,
float alpha)
Adds a new Alpha Composite object ot the shapes stack.
|
void |
setGlyph2UserSpaceScale(float scale)
Sets the scale factor used by some graphic state parameters so that the
to users space CTM scale factor can be applied.
|
void |
setGraphicsState(GraphicsState graphicState)
Sets the graphics state object which will be used for the current content
parsing.
|
protected static void |
setStroke(Shapes shapes,
GraphicsState graphicState)
Sets the state of the BasicStrok with the latest values from the
graphicSate instance value:
graphicState.lineWidth - line width
graphicState.lineCap - line cap type
graphicState.lineJoin - line join type
graphicState.miterLimit - miter limit
|
public static final float OVERPAINT_ALPHA
protected GraphicsState graphicState
protected Library library
protected Resources resources
protected Shapes shapes
protected java.util.LinkedList<OptionalContents> oCGs
protected java.awt.geom.GeneralPath geometricPath
protected boolean inTextBlock
protected java.awt.geom.AffineTransform textBlockBase
protected float glyph2UserSpaceScale
protected java.util.concurrent.atomic.AtomicInteger imageIndex
protected java.util.Stack<java.lang.Object> stack
public Shapes getShapes()
getShapes in interface ContentParserpublic java.util.Stack<java.lang.Object> getStack()
getStack in interface ContentParserpublic GraphicsState getGraphicsState()
getGraphicsState in interface ContentParserpublic void setGraphicsState(GraphicsState graphicState)
setGraphicsState in interface ContentParsergraphicState - graphics state of this content streampublic abstract ContentParser parse(byte[][] streamBytes, Page page) throws java.lang.InterruptedException, java.io.IOException
parse in interface ContentParserstreamBytes - byte stream containing page contentjava.lang.InterruptedException - if current parse thread is interrupted.java.io.IOException - unexpected end of content stream.public abstract Shapes parseTextBlocks(byte[][] source) throws java.io.UnsupportedEncodingException
parseTextBlocks in interface ContentParsersource - content stream source.java.io.UnsupportedEncodingException - encoding error.protected static void consume_G(GraphicsState graphicState, java.util.Stack stack, Library library)
protected static void consume_g(GraphicsState graphicState, java.util.Stack stack, Library library)
protected static void consume_RG(GraphicsState graphicState, java.util.Stack stack, Library library)
protected static void consume_rg(GraphicsState graphicState, java.util.Stack stack, Library library)
protected static void consume_K(GraphicsState graphicState, java.util.Stack stack, Library library)
protected static void consume_k(GraphicsState graphicState, java.util.Stack stack, Library library)
protected static void consume_CS(GraphicsState graphicState, java.util.Stack stack, Resources resources)
protected static void consume_cs(GraphicsState graphicState, java.util.Stack stack, Resources resources)
protected static void consume_ri(java.util.Stack stack)
protected static void consume_SC(GraphicsState graphicState, java.util.Stack stack, Library library, Resources resources, boolean isTint)
protected static void consume_sc(GraphicsState graphicState, java.util.Stack stack, Library library, Resources resources, boolean isTint)
protected static GraphicsState consume_q(GraphicsState graphicState)
protected GraphicsState consume_Q(GraphicsState graphicState, Shapes shapes)
protected static void consume_cm(GraphicsState graphicState, java.util.Stack stack, boolean inTextBlock, java.awt.geom.AffineTransform textBlockBase)
protected static void consume_i(java.util.Stack stack)
protected static void consume_J(GraphicsState graphicState, java.util.Stack stack, Shapes shapes)
protected static GraphicsState consume_Do(GraphicsState graphicState, java.util.Stack stack, Shapes shapes, Resources resources, boolean viewParse, java.util.concurrent.atomic.AtomicInteger imageIndex, Page page)
graphicState - graphic state to appentstack - stack of object being parsed.shapes - shapes object.resources - associated resources.viewParse - true indicates parsing is for a normal view. If false
the consumption of Do will skip Image based xObjects for performance.protected static void consume_d(GraphicsState graphicState, java.util.Stack stack, Shapes shapes)
protected static void consume_j(GraphicsState graphicState, java.util.Stack stack, Shapes shapes)
protected static void consume_w(GraphicsState graphicState, java.util.Stack stack, Shapes shapes, float glyph2UserSpaceScale)
protected static void consume_M(GraphicsState graphicState, java.util.Stack stack, Shapes shapes)
protected static void consume_gs(GraphicsState graphicState, java.util.Stack stack, Resources resources)
protected static void consume_Tf(GraphicsState graphicState, java.util.Stack stack, Resources resources)
protected static void consume_Tc(GraphicsState graphicState, java.util.Stack stack)
protected static void consume_tm(GraphicsState graphicState, java.util.Stack stack, TextMetrics textMetrics, PageText pageText, double previousBTStart, java.awt.geom.AffineTransform textBlockBase, java.util.LinkedList<OptionalContents> oCGs)
protected static void consume_T_star(GraphicsState graphicState, TextMetrics textMetrics, PageText pageText, java.util.LinkedList<OptionalContents> oCGs)
protected static void consume_TD(GraphicsState graphicState, java.util.Stack stack, TextMetrics textMetrics, PageText pageText, java.util.LinkedList<OptionalContents> oCGs)
protected static void consume_double_quote(GraphicsState graphicState, java.util.Stack stack, Shapes shapes, TextMetrics textMetrics, GlyphOutlineClip glyphOutlineClip, java.util.LinkedList<OptionalContents> oCGs)
protected static void consume_single_quote(GraphicsState graphicState, java.util.Stack stack, Shapes shapes, TextMetrics textMetrics, GlyphOutlineClip glyphOutlineClip, java.util.LinkedList<OptionalContents> oCGs)
protected static void consume_Td(GraphicsState graphicState, java.util.Stack stack, TextMetrics textMetrics, PageText pageText, double previousBTStart, java.util.LinkedList<OptionalContents> oCGs)
protected static void consume_Tz(GraphicsState graphicState, java.util.Stack stack)
protected static void consume_Tw(GraphicsState graphicState, java.util.Stack stack)
protected static void consume_Tr(GraphicsState graphicState, java.util.Stack stack)
protected static void consume_TL(GraphicsState graphicState, java.util.Stack stack)
protected static void consume_Ts(GraphicsState graphicState, java.util.Stack stack)
protected static java.awt.geom.GeneralPath consume_L(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath)
protected static java.awt.geom.GeneralPath consume_m(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath)
protected static java.awt.geom.GeneralPath consume_c(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath)
protected static java.awt.geom.GeneralPath consume_S(GraphicsState graphicState, Shapes shapes, java.awt.geom.GeneralPath geometricPath)
protected static java.awt.geom.GeneralPath consume_F(GraphicsState graphicState, Shapes shapes, java.awt.geom.GeneralPath geometricPath) throws java.awt.geom.NoninvertibleTransformException
java.awt.geom.NoninvertibleTransformExceptionprotected static java.awt.geom.GeneralPath consume_f(GraphicsState graphicState, Shapes shapes, java.awt.geom.GeneralPath geometricPath) throws java.awt.geom.NoninvertibleTransformException
java.awt.geom.NoninvertibleTransformExceptionprotected static java.awt.geom.GeneralPath consume_re(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath)
protected static void consume_h(java.awt.geom.GeneralPath geometricPath)
protected static void consume_BDC(java.util.Stack stack,
Shapes shapes,
java.util.LinkedList<OptionalContents> oCGs,
Resources resources)
protected static void consume_EMC(Shapes shapes, java.util.LinkedList<OptionalContents> oCGs)
protected static void consume_BMC(java.util.Stack stack,
Shapes shapes,
java.util.LinkedList<OptionalContents> oCGs,
Resources resources)
protected static java.awt.geom.GeneralPath consume_f_star(GraphicsState graphicState, Shapes shapes, java.awt.geom.GeneralPath geometricPath) throws java.awt.geom.NoninvertibleTransformException
java.awt.geom.NoninvertibleTransformExceptionprotected static java.awt.geom.GeneralPath consume_b(GraphicsState graphicState, Shapes shapes, java.awt.geom.GeneralPath geometricPath) throws java.awt.geom.NoninvertibleTransformException
java.awt.geom.NoninvertibleTransformExceptionprotected static java.awt.geom.GeneralPath consume_n(java.awt.geom.GeneralPath geometricPath)
throws java.awt.geom.NoninvertibleTransformException
java.awt.geom.NoninvertibleTransformExceptionprotected static void consume_W(GraphicsState graphicState, java.awt.geom.GeneralPath geometricPath) throws java.awt.geom.NoninvertibleTransformException
java.awt.geom.NoninvertibleTransformExceptionprotected static void consume_v(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath)
protected static void consume_y(java.util.Stack stack,
java.awt.geom.GeneralPath geometricPath)
protected static java.awt.geom.GeneralPath consume_B(GraphicsState graphicState, Shapes shapes, java.awt.geom.GeneralPath geometricPath) throws java.awt.geom.NoninvertibleTransformException
java.awt.geom.NoninvertibleTransformExceptionprotected static GraphicsState consume_d0(GraphicsState graphicState, java.util.Stack stack)
protected static java.awt.geom.GeneralPath consume_s(GraphicsState graphicState, Shapes shapes, java.awt.geom.GeneralPath geometricPath)
protected static java.awt.geom.GeneralPath consume_b_star(GraphicsState graphicState, Shapes shapes, java.awt.geom.GeneralPath geometricPath) throws java.awt.geom.NoninvertibleTransformException
java.awt.geom.NoninvertibleTransformExceptionprotected static GraphicsState consume_d1(GraphicsState graphicState, java.util.Stack stack)
protected static java.awt.geom.GeneralPath consume_B_star(GraphicsState graphicState, Shapes shapes, java.awt.geom.GeneralPath geometricPath) throws java.awt.geom.NoninvertibleTransformException
java.awt.geom.NoninvertibleTransformExceptionpublic static void consume_W_star(GraphicsState graphicState, java.awt.geom.GeneralPath geometricPath)
public static void consume_DP(java.util.Stack stack)
public static void consume_MP(java.util.Stack stack)
public static void consume_sh(GraphicsState graphicState, java.util.Stack stack, Shapes shapes, Resources resources)
protected static void consume_TJ(GraphicsState graphicState, java.util.Stack stack, Shapes shapes, TextMetrics textMetrics, GlyphOutlineClip glyphOutlineClip, java.util.LinkedList<OptionalContents> oCGs)
protected static void consume_Tj(GraphicsState graphicState, java.util.Stack stack, Shapes shapes, TextMetrics textMetrics, GlyphOutlineClip glyphOutlineClip, java.util.LinkedList<OptionalContents> oCGs)
protected static void drawString(java.lang.StringBuilder displayText,
TextMetrics textMetrics,
TextState textState,
Shapes shapes,
GlyphOutlineClip glyphOutlineClip,
GraphicsState graphicState,
java.util.LinkedList<OptionalContents> oCGs)
displayText given the strings parsed textState. Each of
displayText glyphs and respective, text state is added to
the shapes collection.displayText - text that will be drawn to the screentextMetrics - current advanceX of last drawn string,
last advance of where the string should be drawntextState - formating properties associated with displayTextshapes - collection of all shapes for page content being parsed.protected static void drawModeFill(GraphicsState graphicState, TextSprite textSprites, Shapes shapes, int rmode)
textSprites - text to add to shapes stackshapes - shapes stackrmode - write modeprotected static void drawModeStroke(GraphicsState graphicState, TextSprite textSprites, TextState textState, Shapes shapes, int rmode)
textSprites - text to add to shapes stackshapes - shapes stacktextState - text state used to build new strokermode - write modeprotected static void drawModeFillStroke(GraphicsState graphicState, TextSprite textSprites, TextState textState, Shapes shapes, int rmode)
textSprites - text to add to shapes stacktextState - text state used to build new strokeshapes - shapes stackrmode - write modeprotected static void commonStroke(GraphicsState graphicState, Shapes shapes, java.awt.geom.GeneralPath geometricPath)
shapes - current shapes stackgeometricPath - current path.protected static float commonOverPrintAlpha(float alpha,
PColorSpace colorSpace)
alpha - alph constantprotected static void commonFill(Shapes shapes, GraphicsState graphicState, java.awt.geom.GeneralPath geometricPath) throws java.awt.geom.NoninvertibleTransformException
shapes - current shapes stackgraphicState - current graphics state.geometricPath - current path.java.awt.geom.NoninvertibleTransformExceptionprotected static void setStroke(Shapes shapes, GraphicsState graphicState)
shapes - current Shapes object for the page being parsedgraphicState - graphic state used to build this stroke instance.protected static java.awt.geom.AffineTransform applyTextScaling(GraphicsState graphicState)
graphicState - current graphics state.protected static void setAlpha(Shapes shapes, int rule, float alpha)
shapes - - current shapes vector to add Alpha Composite torule - - rule to apply to the alphaComposite.alpha - - alpha value, opaque = 1.0f.public void setGlyph2UserSpaceScale(float scale)
ContentParsersetGlyph2UserSpaceScale in interface ContentParserscale - scale factor to apply to various graphic state parameters.