Class PdfGraphics2D
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
org.openpdf.text.pdf.PdfGraphics2D
- Direct Known Subclasses:
PdfPrinterGraphics2D
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classWrapper class that helps to draw string with sun.font.CompositeFont (Windows logical fonts).private static classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprivate floatprivate Colorprivate BaseFontStorage for BaseFont objects created.private static final Stringprivate static final Stringprivate PdfContentByteprivate Areaprivate static final intprivate Compositeprivate final PdfGraphics2D.CompositeFontDrawerprivate booleanprotected intprotected intprivate Graphics2Dprivate booleanprivate static final intprotected PdfGState[]private Fontprivate FontMapperprivate floatprivate floatprivate static final AffineTransformprivate booleanprivate floatprivate booleanprivate MediaTrackerprivate Strokeprivate booleanprivate Strokeprivate Paintprivate Paintprivate Paintprivate Paintprivate final RenderingHintsprivate Strokeprivate static final intprotected PdfGState[]private BasicStrokeprivate AffineTransformprotected booleanprivate float -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePdfGraphics2D(PdfContentByte cb, float width, float height) Shortcut constructor for PDFGraphics2D.PdfGraphics2D(PdfContentByte cb, float width, float height, FontMapper fontMapper, boolean onlyShapes, boolean convertImagesToJPEG, float quality) Constructor for PDFGraphics2D.protectedPdfGraphics2D(PdfGraphics2D parent) Copy constructor for child PdfGraphics2D objects. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRenderingHints(Map hints) static doubleasPoints(double d, int i) Calculates position and/or stroke thickness depending on the font sizeprivate booleancheckNewPaint(Paint oldPaint) voidclearRect(int x, int y, int width, int height) voidvoidclipRect(int x, int y, int width, int height) voidcopyArea(int x, int y, int width, int height, int dx, int dy) create()protected PdfGraphics2Dvoiddispose()protected voidThis routine goes through the attributes and sets the font before calling the actual string drawing routinevoidvoiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle) voiddrawGlyphVector(GlyphVector g, float x, float y) voiddrawImage(BufferedImage img, BufferedImageOp op, int x, int y) booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) booleandrawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) booleandrawImage(Image img, int x, int y, int width, int height, ImageObserver observer) booleandrawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) booleandrawImage(Image img, int x, int y, ImageObserver observer) booleandrawImage(Image img, AffineTransform xform, ImageObserver obs) private booleandrawImage(Image img, Image mask, AffineTransform xform, Color bgColor, ImageObserver obs) voiddrawLine(int x1, int y1, int x2, int y2) voiddrawOval(int x, int y, int width, int height) voiddrawPolygon(int[] xPoints, int[] yPoints, int nPoints) voiddrawPolyline(int[] x, int[] y, int nPoints) voiddrawRect(int x, int y, int width, int height) voiddrawRenderableImage(RenderableImage img, AffineTransform xform) voiddrawRenderedImage(RenderedImage img, AffineTransform xform) voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) voiddrawString(String s, float x, float y) voiddrawString(String s, int x, int y) private doubledrawString(String s, BaseFont baseFont, double x, double y) voiddrawString(AttributedCharacterIterator iter, float x, float y) voiddrawString(AttributedCharacterIterator iterator, int x, int y) voidvoidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle) voidfillOval(int x, int y, int width, int height) voidfillPolygon(int[] xPoints, int[] yPoints, int nPoints) voidfillRect(int x, int y, int width, int height) voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) private voidfollowPath(Shape s, int drawType) private BaseFontgetClip()getColor()getFont()getPaint()Method contributed by Alexej Suchovbooleanprivate voidprivate AffineTransformprivate floatnormalizeY(float y) private voidnormalizeY(float[] coords) voidrotate(double theta) voidrotate(double theta, double x, double y) voidscale(double sx, double sy) voidsetBackground(Color color) voidsetClip(int x, int y, int width, int height) voidvoidvoidsetComposite(Composite comp) Method contributed by Alexej SuchovvoidsetCompositeFontDrawerEnabled(boolean compositeFontDrawerEnabled) Enables/Disables the composite font drawer due to issues with custom font mappers that do not always default to one specific font but allow custom fonts.private voidvoidSets the current font.private voidsetPaint(boolean invert, double xoffset, double yoffset, boolean fill) voidMethod contributed by Alexej SuchovvoidvoidsetRenderingHint(RenderingHints.Key arg0, Object arg1) Sets a rendering hintvoidsetRenderingHints(Map hints) voidprivate voidsetStrokeDiff(Stroke newStroke, Stroke oldStroke) private voidvoidvoidsetXORMode(Color c1) voidshear(double shx, double shy) Split the given string into substrings depending on if all characters of substring can be displayed with the defined font or not.voidprivate StroketransformStroke(Stroke stroke) voidtranslate(double tx, double ty) voidtranslate(int x, int y) private voidwaitForImage(Image image) Methods inherited from class Graphics2D
draw3DRect, fill3DRectMethods inherited from class Graphics
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
-
Field Details
-
AFM_DIVISOR
public static final int AFM_DIVISOR- See Also:
-
FILL
private static final int FILL- See Also:
-
STROKE
private static final int STROKE- See Also:
-
CLIP
private static final int CLIP- See Also:
-
IDENTITY
-
LOGICAL_FONT_NAMES
-
BOLD_FONT_FACE_NAME_SUFFIX
- See Also:
-
BOLD_ITALIC_FONT_FACE_NAME_SUFFIX
- See Also:
-
compositeFontDrawer
-
underline
protected boolean underline -
fillGState
-
strokeGState
-
currentFillGState
protected int currentFillGState -
currentStrokeGState
protected int currentStrokeGState -
strokeOne
-
font
-
baseFont
-
fontSize
private float fontSize -
transform
-
paint
-
background
-
width
private float width -
height
private float height -
clip
-
rhints
-
stroke
-
originalStroke
-
cb
-
baseFonts
-
disposeCalled
private boolean disposeCalled -
fontMapper
-
kids
-
kid
private boolean kid -
dg2
-
onlyShapes
private boolean onlyShapes -
oldStroke
-
paintFill
-
paintStroke
-
mediaTracker
-
convertImagesToJPEG
private boolean convertImagesToJPEG -
jpegQuality
private float jpegQuality -
alpha
private float alpha -
composite
-
realPaint
-
isCompositeFontDrawerEnabled
private boolean isCompositeFontDrawerEnabled
-
-
Constructor Details
-
PdfGraphics2D
private PdfGraphics2D() -
PdfGraphics2D
Copy constructor for child PdfGraphics2D objects.- Parameters:
parent- the parent PdfGraphics2D- See Also:
-
PdfGraphics2D
Shortcut constructor for PDFGraphics2D.- Parameters:
cb- the PdfContentBytewidth- the widthheight- the height
-
PdfGraphics2D
public PdfGraphics2D(PdfContentByte cb, float width, float height, FontMapper fontMapper, boolean onlyShapes, boolean convertImagesToJPEG, float quality) Constructor for PDFGraphics2D.- Parameters:
cb- The PdfContentBytewidth- The widthheight- The heightfontMapper- The fonts to put in the BaseFont MaponlyShapes- True if there are only shapes, false otherwiseconvertImagesToJPEG- True to convert to JPEG, false otherwisequality- The JPEG quality
-
-
Method Details
-
asPoints
public static double asPoints(double d, int i) Calculates position and/or stroke thickness depending on the font size- Parameters:
d- value to be convertedi- font size- Returns:
- position and/or stroke thickness depending on the font size
-
draw
- Specified by:
drawin classGraphics2D- See Also:
-
drawImage
- Specified by:
drawImagein classGraphics2D- See Also:
-
drawImage
- Specified by:
drawImagein classGraphics2D- See Also:
-
drawRenderedImage
- Specified by:
drawRenderedImagein classGraphics2D- See Also:
-
drawRenderableImage
- Specified by:
drawRenderableImagein classGraphics2D- See Also:
-
drawString
- Specified by:
drawStringin classGraphics2D- See Also:
-
doAttributes
This routine goes through the attributes and sets the font before calling the actual string drawing routine- Parameters:
iter- the AttributedCharacterIterator
-
drawString
- Specified by:
drawStringin classGraphics2D- See Also:
-
drawString
-
drawString
- Specified by:
drawStringin classGraphics2D- See Also:
-
drawString
- Specified by:
drawStringin classGraphics2D- See Also:
-
drawGlyphVector
- Specified by:
drawGlyphVectorin classGraphics2D- See Also:
-
fill
- Specified by:
fillin classGraphics2D- See Also:
-
hit
- Specified by:
hitin classGraphics2D- See Also:
-
getDeviceConfiguration
- Specified by:
getDeviceConfigurationin classGraphics2D- See Also:
-
transformStroke
-
setStrokeDiff
-
setRenderingHint
Sets a rendering hint- Specified by:
setRenderingHintin classGraphics2D- Parameters:
arg0- the Keyarg1- the Object to associate to it
-
getRenderingHint
- Specified by:
getRenderingHintin classGraphics2D- Parameters:
arg0- a key- Returns:
- the rendering hint
-
addRenderingHints
- Specified by:
addRenderingHintsin classGraphics2D- See Also:
-
getRenderingHints
- Specified by:
getRenderingHintsin classGraphics2D- See Also:
-
setRenderingHints
- Specified by:
setRenderingHintsin classGraphics2D- See Also:
-
translate
public void translate(int x, int y) - Specified by:
translatein classGraphics2D- See Also:
-
translate
public void translate(double tx, double ty) - Specified by:
translatein classGraphics2D- See Also:
-
rotate
public void rotate(double theta) - Specified by:
rotatein classGraphics2D- See Also:
-
rotate
public void rotate(double theta, double x, double y) - Specified by:
rotatein classGraphics2D- See Also:
-
scale
public void scale(double sx, double sy) - Specified by:
scalein classGraphics2D- See Also:
-
shear
public void shear(double shx, double shy) - Specified by:
shearin classGraphics2D- See Also:
-
transform
- Specified by:
transformin classGraphics2D- See Also:
-
getTransform
- Specified by:
getTransformin classGraphics2D- See Also:
-
setTransform
- Specified by:
setTransformin classGraphics2D- See Also:
-
getPaint
Method contributed by Alexej Suchov- Specified by:
getPaintin classGraphics2D- See Also:
-
setPaint
Method contributed by Alexej Suchov- Specified by:
setPaintin classGraphics2D- See Also:
-
getComposite
- Specified by:
getCompositein classGraphics2D- See Also:
-
setComposite
Method contributed by Alexej Suchov- Specified by:
setCompositein classGraphics2D- See Also:
-
getBackground
- Specified by:
getBackgroundin classGraphics2D- See Also:
-
setBackground
- Specified by:
setBackgroundin classGraphics2D- See Also:
-
getStroke
- Specified by:
getStrokein classGraphics2D- See Also:
-
setStroke
- Specified by:
setStrokein classGraphics2D- See Also:
-
getFontRenderContext
- Specified by:
getFontRenderContextin classGraphics2D- See Also:
-
create
-
createChild
-
getContent
-
getColor
-
setColor
-
setPaintMode
public void setPaintMode()- Specified by:
setPaintModein classGraphics- See Also:
-
setXORMode
- Specified by:
setXORModein classGraphics- See Also:
-
getFont
-
setFont
-
getCachedBaseFont
-
getFontMetrics
- Specified by:
getFontMetricsin classGraphics- See Also:
-
getClipBounds
- Specified by:
getClipBoundsin classGraphics- See Also:
-
clipRect
-
setClip
-
clip
- Specified by:
clipin classGraphics2D- See Also:
-
getClip
-
setClip
-
copyArea
-
drawLine
-
drawRect
-
fillRect
-
clearRect
-
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Specified by:
drawRoundRectin classGraphics- See Also:
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Specified by:
fillRoundRectin classGraphics- See Also:
-
drawOval
-
fillOval
-
drawArc
-
fillArc
-
drawPolyline
public void drawPolyline(int[] x, int[] y, int nPoints) - Specified by:
drawPolylinein classGraphics- See Also:
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
drawPolygonin classGraphics- See Also:
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
fillPolygonin classGraphics- See Also:
-
drawImage
-
drawImage
-
drawImage
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) -
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) -
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) -
dispose
-
internalDispose
-
setCompositeFontDrawerEnabled
public void setCompositeFontDrawerEnabled(boolean compositeFontDrawerEnabled) Enables/Disables the composite font drawer due to issues with custom font mappers that do not always default to one specific font but allow custom fonts.- Parameters:
compositeFontDrawerEnabled- true if the composite font drawer should be used else false.
-
followPath
-
normalizeY
private float normalizeY(float y) -
normalizeY
private void normalizeY(float[] coords) -
normalizeMatrix
-
drawImage
private boolean drawImage(Image img, Image mask, AffineTransform xform, Color bgColor, ImageObserver obs) -
checkNewPaint
-
setFillPaint
private void setFillPaint() -
setStrokePaint
private void setStrokePaint() -
setPaint
private void setPaint(boolean invert, double xoffset, double yoffset, boolean fill) -
waitForImage
-
splitIntoSubstringsByVisibility
Split the given string into substrings depending on if all characters of substring can be displayed with the defined font or not.- Parameters:
s- given string- Returns:
- list of substrings that can be displayed by with the defined font or not.
-