Package com.lowagie.text.pdf
Class PdfGraphics2D
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
com.lowagie.text.pdf.PdfGraphics2D
- Direct Known Subclasses:
PdfPrinterGraphics2D
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Wrapper class that helps to draw string with sun.font.CompositeFont (Windows logical fonts).private static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
private float
private Color
private BaseFont
Storage for BaseFont objects created.private static final String
private static final String
private PdfContentByte
private Area
private static final int
private Composite
private final PdfGraphics2D.CompositeFontDrawer
private boolean
protected int
protected int
private Graphics2D
private boolean
private static final int
protected PdfGState[]
private Font
private FontMapper
private float
private float
private static final AffineTransform
private boolean
private float
private boolean
private MediaTracker
private Stroke
private boolean
private Stroke
private Paint
private Paint
private Paint
private Paint
private final RenderingHints
private Stroke
private static final int
protected PdfGState[]
private BasicStroke
private AffineTransform
protected boolean
private float
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
PdfGraphics2D
(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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRenderingHints
(Map hints) static double
asPoints
(double d, int i) Calculates position and/or stroke thickness depending on the font sizeprivate boolean
checkNewPaint
(Paint oldPaint) void
clearRect
(int x, int y, int width, int height) void
void
clipRect
(int x, int y, int width, int height) void
copyArea
(int x, int y, int width, int height, int dx, int dy) create()
void
dispose()
protected void
This routine goes through the attributes and sets the font before calling the actual string drawing routinevoid
void
drawArc
(int x, int y, int width, int height, int startAngle, int arcAngle) void
drawGlyphVector
(GlyphVector g, float x, float y) void
drawImage
(BufferedImage img, BufferedImageOp op, int x, int y) boolean
drawImage
(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) boolean
drawImage
(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) boolean
drawImage
(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) boolean
drawImage
(Image img, int x, int y, int width, int height, ImageObserver observer) boolean
drawImage
(Image img, int x, int y, Color bgcolor, ImageObserver observer) boolean
drawImage
(Image img, int x, int y, ImageObserver observer) boolean
drawImage
(Image img, AffineTransform xform, ImageObserver obs) private boolean
drawImage
(Image img, Image mask, AffineTransform xform, Color bgColor, ImageObserver obs) void
drawLine
(int x1, int y1, int x2, int y2) void
drawOval
(int x, int y, int width, int height) void
drawPolygon
(int[] xPoints, int[] yPoints, int nPoints) void
drawPolyline
(int[] x, int[] y, int nPoints) void
drawRect
(int x, int y, int width, int height) void
drawRenderableImage
(RenderableImage img, AffineTransform xform) void
drawRenderedImage
(RenderedImage img, AffineTransform xform) void
drawRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) void
drawString
(String s, float x, float y) void
drawString
(String s, int x, int y) private double
drawString
(String s, BaseFont baseFont, double x, double y) void
drawString
(AttributedCharacterIterator iter, float x, float y) void
drawString
(AttributedCharacterIterator iterator, int x, int y) void
void
fillArc
(int x, int y, int width, int height, int startAngle, int arcAngle) void
fillOval
(int x, int y, int width, int height) void
fillPolygon
(int[] xPoints, int[] yPoints, int nPoints) void
fillRect
(int x, int y, int width, int height) void
fillRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) private void
followPath
(Shape s, int drawType) private BaseFont
getClip()
getColor()
getFont()
getPaint()
Method contributed by Alexej Suchovboolean
private void
private AffineTransform
private float
normalizeY
(float y) private void
normalizeY
(float[] coords) void
rotate
(double theta) void
rotate
(double theta, double x, double y) void
scale
(double sx, double sy) void
setBackground
(Color color) void
setClip
(int x, int y, int width, int height) void
void
void
setComposite
(Composite comp) Method contributed by Alexej Suchovvoid
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.private void
void
Sets the current font.private void
setPaint
(boolean invert, double xoffset, double yoffset, boolean fill) void
Method contributed by Alexej Suchovvoid
void
setRenderingHint
(RenderingHints.Key arg0, Object arg1) Sets a rendering hintvoid
setRenderingHints
(Map hints) void
private void
setStrokeDiff
(Stroke newStroke, Stroke oldStroke) private void
void
void
setXORMode
(Color c1) void
shear
(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.void
private Stroke
transformStroke
(Stroke stroke) void
translate
(double tx, double ty) void
translate
(int x, int y) private void
waitForImage
(Image image) Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
Methods inherited from class java.awt.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
Storage for BaseFont objects created. -
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
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:
draw
in classGraphics2D
- See Also:
-
drawImage
- Specified by:
drawImage
in classGraphics2D
- See Also:
-
drawImage
- Specified by:
drawImage
in classGraphics2D
- See Also:
-
drawRenderedImage
- Specified by:
drawRenderedImage
in classGraphics2D
- See Also:
-
drawRenderableImage
- Specified by:
drawRenderableImage
in classGraphics2D
- See Also:
-
drawString
- Specified by:
drawString
in 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:
drawString
in classGraphics2D
- See Also:
-
drawString
-
drawString
- Specified by:
drawString
in classGraphics2D
- See Also:
-
drawString
- Specified by:
drawString
in classGraphics2D
- See Also:
-
drawGlyphVector
- Specified by:
drawGlyphVector
in classGraphics2D
- See Also:
-
fill
- Specified by:
fill
in classGraphics2D
- See Also:
-
hit
- Specified by:
hit
in classGraphics2D
- See Also:
-
getDeviceConfiguration
- Specified by:
getDeviceConfiguration
in classGraphics2D
- See Also:
-
transformStroke
-
setStrokeDiff
-
setRenderingHint
Sets a rendering hint- Specified by:
setRenderingHint
in classGraphics2D
- Parameters:
arg0
- the Keyarg1
- the Object to associate to it
-
getRenderingHint
- Specified by:
getRenderingHint
in classGraphics2D
- Parameters:
arg0
- a key- Returns:
- the rendering hint
-
addRenderingHints
- Specified by:
addRenderingHints
in classGraphics2D
- See Also:
-
getRenderingHints
- Specified by:
getRenderingHints
in classGraphics2D
- See Also:
-
setRenderingHints
- Specified by:
setRenderingHints
in classGraphics2D
- See Also:
-
translate
public void translate(int x, int y) - Specified by:
translate
in classGraphics2D
- See Also:
-
translate
public void translate(double tx, double ty) - Specified by:
translate
in classGraphics2D
- See Also:
-
rotate
public void rotate(double theta) - Specified by:
rotate
in classGraphics2D
- See Also:
-
rotate
public void rotate(double theta, double x, double y) - Specified by:
rotate
in classGraphics2D
- See Also:
-
scale
public void scale(double sx, double sy) - Specified by:
scale
in classGraphics2D
- See Also:
-
shear
public void shear(double shx, double shy) - Specified by:
shear
in classGraphics2D
- See Also:
-
transform
- Specified by:
transform
in classGraphics2D
- See Also:
-
getTransform
- Specified by:
getTransform
in classGraphics2D
- See Also:
-
setTransform
- Specified by:
setTransform
in classGraphics2D
- See Also:
-
getPaint
Method contributed by Alexej Suchov- Specified by:
getPaint
in classGraphics2D
- See Also:
-
setPaint
Method contributed by Alexej Suchov- Specified by:
setPaint
in classGraphics2D
- See Also:
-
getComposite
- Specified by:
getComposite
in classGraphics2D
- See Also:
-
setComposite
Method contributed by Alexej Suchov- Specified by:
setComposite
in classGraphics2D
- See Also:
-
getBackground
- Specified by:
getBackground
in classGraphics2D
- See Also:
-
setBackground
- Specified by:
setBackground
in classGraphics2D
- See Also:
-
getStroke
- Specified by:
getStroke
in classGraphics2D
- See Also:
-
setStroke
- Specified by:
setStroke
in classGraphics2D
- See Also:
-
getFontRenderContext
- Specified by:
getFontRenderContext
in classGraphics2D
- See Also:
-
create
-
getContent
-
getColor
-
setColor
-
setPaintMode
public void setPaintMode()- Specified by:
setPaintMode
in classGraphics
- See Also:
-
setXORMode
- Specified by:
setXORMode
in classGraphics
- See Also:
-
getFont
-
setFont
Sets the current font. -
getCachedBaseFont
-
getFontMetrics
- Specified by:
getFontMetrics
in classGraphics
- See Also:
-
getClipBounds
- Specified by:
getClipBounds
in classGraphics
- See Also:
-
clipRect
public void clipRect(int x, int y, int width, int height) -
setClip
public void setClip(int x, int y, int width, int height) -
clip
- Specified by:
clip
in classGraphics2D
- See Also:
-
getClip
-
setClip
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy) -
drawLine
public void drawLine(int x1, int y1, int x2, int y2) -
drawRect
public void drawRect(int x, int y, int width, int height) -
fillRect
public void fillRect(int x, int y, int width, int height) -
clearRect
public void clearRect(int x, int y, int width, int height) -
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Specified by:
drawRoundRect
in classGraphics
- See Also:
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Specified by:
fillRoundRect
in classGraphics
- See Also:
-
drawOval
public void drawOval(int x, int y, int width, int height) -
fillOval
public void fillOval(int x, int y, int width, int height) -
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) -
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) -
drawPolyline
public void drawPolyline(int[] x, int[] y, int nPoints) - Specified by:
drawPolyline
in classGraphics
- See Also:
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
drawPolygon
in classGraphics
- See Also:
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
fillPolygon
in 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
public void 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.
-