Package com.itextpdf.awt
Class PdfGraphics2D
- java.lang.Object
-
- java.awt.Graphics
-
- java.awt.Graphics2D
-
- com.itextpdf.awt.PdfGraphics2D
-
- Direct Known Subclasses:
PdfPrinterGraphics2D
public class PdfGraphics2D extends Graphics2D
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PdfGraphics2D.HyperLinkKey
-
Field Summary
Fields Modifier and Type Field Description static int
AFM_DIVISOR
protected Color
background
protected BaseFont
baseFont
protected HashMap<String,BaseFont>
baseFonts
Storage for BaseFont objects created.protected PdfContentByte
cb
protected Area
clip
protected int
currentFillGState
protected int
currentStrokeGState
protected boolean
disposeCalled
protected PdfGState[]
fillGState
protected Font
font
protected FontMapper
fontMapper
protected float
fontSize
protected float
height
protected Stroke
originalStroke
protected Paint
paint
protected RenderingHints
rhints
protected boolean
strikethrough
protected Stroke
stroke
protected PdfGState[]
strokeGState
protected AffineTransform
transform
protected boolean
underline
protected float
width
-
Constructor Summary
Constructors Constructor Description PdfGraphics2D(PdfContentByte cb, float width, float height)
PdfGraphics2D(PdfContentByte cb, float width, float height, boolean onlyShapes)
PdfGraphics2D(PdfContentByte cb, float width, float height, FontMapper fontMapper)
PdfGraphics2D(PdfContentByte cb, float width, float height, FontMapper fontMapper, boolean onlyShapes, boolean convertImagesToJPEG, float quality)
Constructor for PDFGraphics2D.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRenderingHints(Map<?,?> hints)
static double
asPoints(double d, int i)
Calculates position and/or stroke thickness depending on the font sizevoid
clearRect(int x, int y, int width, int height)
void
clip(Shape s)
void
clipRect(int x, int y, int width, int height)
void
copyArea(int x, int y, int width, int height, int dx, int dy)
Graphics
create()
void
dispose()
protected void
doAttributes(AttributedCharacterIterator iter)
This routine goes through the attributes and sets the font before calling the actual string drawing routinevoid
draw(Shape s)
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)
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)
void
drawString(AttributedCharacterIterator iter, float x, float y)
void
drawString(AttributedCharacterIterator iterator, int x, int y)
void
fill(Shape s)
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)
Color
getBackground()
Shape
getClip()
Rectangle
getClipBounds()
Color
getColor()
Composite
getComposite()
PdfContentByte
getContent()
GraphicsConfiguration
getDeviceConfiguration()
Font
getFont()
FontMetrics
getFontMetrics(Font f)
FontRenderContext
getFontRenderContext()
Paint
getPaint()
Method contributed by Alexej SuchovObject
getRenderingHint(RenderingHints.Key hintKey)
RenderingHints
getRenderingHints()
Stroke
getStroke()
AffineTransform
getTransform()
boolean
hit(Rectangle rect, Shape s, boolean onStroke)
protected AffineTransform
normalizeMatrix()
static BaseColor
prepareColor(Color color)
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
setClip(Shape s)
void
setColor(Color color)
void
setComposite(Composite comp)
Method contributed by Alexej Suchovvoid
setFont(Font f)
Sets the current font.void
setPaint(Paint paint)
Method contributed by Alexej Suchovvoid
setPaintMode()
void
setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
Sets a rendering hintvoid
setRenderingHints(Map<?,?> hints)
void
setStroke(Stroke s)
void
setTransform(AffineTransform t)
void
setXORMode(Color c1)
void
shear(double shx, double shy)
void
transform(AffineTransform tx)
void
translate(double tx, double ty)
void
translate(int x, int y)
-
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 Detail
-
font
protected Font font
-
baseFont
protected BaseFont baseFont
-
fontSize
protected float fontSize
-
transform
protected AffineTransform transform
-
paint
protected Paint paint
-
background
protected Color background
-
width
protected float width
-
height
protected float height
-
clip
protected Area clip
-
rhints
protected RenderingHints rhints
-
stroke
protected Stroke stroke
-
originalStroke
protected Stroke originalStroke
-
cb
protected PdfContentByte cb
-
disposeCalled
protected boolean disposeCalled
-
fontMapper
protected FontMapper fontMapper
-
underline
protected boolean underline
-
strikethrough
protected boolean strikethrough
- Since:
- 5.0.3
-
fillGState
protected PdfGState[] fillGState
-
strokeGState
protected PdfGState[] strokeGState
-
currentFillGState
protected int currentFillGState
-
currentStrokeGState
protected int currentStrokeGState
-
AFM_DIVISOR
public static final int AFM_DIVISOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PdfGraphics2D
public PdfGraphics2D(PdfContentByte cb, float width, float height)
-
PdfGraphics2D
public PdfGraphics2D(PdfContentByte cb, float width, float height, FontMapper fontMapper)
-
PdfGraphics2D
public PdfGraphics2D(PdfContentByte cb, float width, float height, boolean onlyShapes)
-
PdfGraphics2D
public PdfGraphics2D(PdfContentByte cb, float width, float height, FontMapper fontMapper, boolean onlyShapes, boolean convertImagesToJPEG, float quality)
Constructor for PDFGraphics2D.
-
-
Method Detail
-
draw
public void draw(Shape s)
- Specified by:
draw
in classGraphics2D
- See Also:
Graphics2D.draw(Shape)
-
drawImage
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
- Specified by:
drawImage
in classGraphics2D
- See Also:
Graphics2D.drawImage(Image, AffineTransform, ImageObserver)
-
drawImage
public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
- Specified by:
drawImage
in classGraphics2D
- See Also:
Graphics2D.drawImage(BufferedImage, BufferedImageOp, int, int)
-
drawRenderedImage
public void drawRenderedImage(RenderedImage img, AffineTransform xform)
- Specified by:
drawRenderedImage
in classGraphics2D
- See Also:
Graphics2D.drawRenderedImage(RenderedImage, AffineTransform)
-
drawRenderableImage
public void drawRenderableImage(RenderableImage img, AffineTransform xform)
- Specified by:
drawRenderableImage
in classGraphics2D
- See Also:
Graphics2D.drawRenderableImage(RenderableImage, AffineTransform)
-
drawString
public void drawString(String s, int x, int y)
- Specified by:
drawString
in classGraphics2D
- See Also:
Graphics.drawString(String, int, int)
-
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
-
doAttributes
protected void doAttributes(AttributedCharacterIterator iter)
This routine goes through the attributes and sets the font before calling the actual string drawing routine- Parameters:
iter
-
-
drawString
public void drawString(String s, float x, float y)
- Specified by:
drawString
in classGraphics2D
- See Also:
Graphics2D.drawString(String, float, float)
-
drawString
public void drawString(AttributedCharacterIterator iterator, int x, int y)
- Specified by:
drawString
in classGraphics2D
- See Also:
Graphics.drawString(AttributedCharacterIterator, int, int)
-
drawString
public void drawString(AttributedCharacterIterator iter, float x, float y)
- Specified by:
drawString
in classGraphics2D
- See Also:
Graphics2D.drawString(AttributedCharacterIterator, float, float)
-
drawGlyphVector
public void drawGlyphVector(GlyphVector g, float x, float y)
- Specified by:
drawGlyphVector
in classGraphics2D
- See Also:
Graphics2D.drawGlyphVector(GlyphVector, float, float)
-
fill
public void fill(Shape s)
- Specified by:
fill
in classGraphics2D
- See Also:
Graphics2D.fill(Shape)
-
hit
public boolean hit(Rectangle rect, Shape s, boolean onStroke)
- Specified by:
hit
in classGraphics2D
- See Also:
Graphics2D.hit(Rectangle, Shape, boolean)
-
getDeviceConfiguration
public GraphicsConfiguration getDeviceConfiguration()
- Specified by:
getDeviceConfiguration
in classGraphics2D
- See Also:
Graphics2D.getDeviceConfiguration()
-
setComposite
public void setComposite(Composite comp)
Method contributed by Alexej Suchov- Specified by:
setComposite
in classGraphics2D
- See Also:
Graphics2D.setComposite(Composite)
-
setPaint
public void setPaint(Paint paint)
Method contributed by Alexej Suchov- Specified by:
setPaint
in classGraphics2D
- See Also:
Graphics2D.setPaint(Paint)
-
setStroke
public void setStroke(Stroke s)
- Specified by:
setStroke
in classGraphics2D
- See Also:
Graphics2D.setStroke(Stroke)
-
setRenderingHint
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
Sets a rendering hint- Specified by:
setRenderingHint
in classGraphics2D
- Parameters:
hintKey
-hintValue
-
-
getRenderingHint
public Object getRenderingHint(RenderingHints.Key hintKey)
- Specified by:
getRenderingHint
in classGraphics2D
- Parameters:
hintKey
- a key- Returns:
- the rendering hint
-
setRenderingHints
public void setRenderingHints(Map<?,?> hints)
- Specified by:
setRenderingHints
in classGraphics2D
- See Also:
Graphics2D.setRenderingHints(Map)
-
addRenderingHints
public void addRenderingHints(Map<?,?> hints)
- Specified by:
addRenderingHints
in classGraphics2D
- See Also:
Graphics2D.addRenderingHints(Map)
-
getRenderingHints
public RenderingHints getRenderingHints()
- Specified by:
getRenderingHints
in classGraphics2D
- See Also:
Graphics2D.getRenderingHints()
-
translate
public void translate(int x, int y)
- Specified by:
translate
in classGraphics2D
- See Also:
Graphics.translate(int, int)
-
translate
public void translate(double tx, double ty)
- Specified by:
translate
in classGraphics2D
- See Also:
Graphics2D.translate(double, double)
-
rotate
public void rotate(double theta)
- Specified by:
rotate
in classGraphics2D
- See Also:
Graphics2D.rotate(double)
-
rotate
public void rotate(double theta, double x, double y)
- Specified by:
rotate
in classGraphics2D
- See Also:
Graphics2D.rotate(double, double, double)
-
scale
public void scale(double sx, double sy)
- Specified by:
scale
in classGraphics2D
- See Also:
Graphics2D.scale(double, double)
-
shear
public void shear(double shx, double shy)
- Specified by:
shear
in classGraphics2D
- See Also:
Graphics2D.shear(double, double)
-
transform
public void transform(AffineTransform tx)
- Specified by:
transform
in classGraphics2D
- See Also:
Graphics2D.transform(AffineTransform)
-
setTransform
public void setTransform(AffineTransform t)
- Specified by:
setTransform
in classGraphics2D
- See Also:
Graphics2D.setTransform(AffineTransform)
-
getTransform
public AffineTransform getTransform()
- Specified by:
getTransform
in classGraphics2D
- See Also:
Graphics2D.getTransform()
-
getPaint
public Paint getPaint()
Method contributed by Alexej Suchov- Specified by:
getPaint
in classGraphics2D
- See Also:
Graphics2D.getPaint()
-
getComposite
public Composite getComposite()
- Specified by:
getComposite
in classGraphics2D
- See Also:
Graphics2D.getComposite()
-
setBackground
public void setBackground(Color color)
- Specified by:
setBackground
in classGraphics2D
- See Also:
Graphics2D.setBackground(Color)
-
getBackground
public Color getBackground()
- Specified by:
getBackground
in classGraphics2D
- See Also:
Graphics2D.getBackground()
-
getStroke
public Stroke getStroke()
- Specified by:
getStroke
in classGraphics2D
- See Also:
Graphics2D.getStroke()
-
getFontRenderContext
public FontRenderContext getFontRenderContext()
- Specified by:
getFontRenderContext
in classGraphics2D
- See Also:
Graphics2D.getFontRenderContext()
-
create
public Graphics create()
- Specified by:
create
in classGraphics
- See Also:
Graphics.create()
-
getContent
public PdfContentByte getContent()
-
getColor
public Color getColor()
- Specified by:
getColor
in classGraphics
- See Also:
Graphics.getColor()
-
setColor
public void setColor(Color color)
- Specified by:
setColor
in classGraphics
- See Also:
Graphics.setColor(Color)
-
setPaintMode
public void setPaintMode()
- Specified by:
setPaintMode
in classGraphics
- See Also:
Graphics.setPaintMode()
-
setXORMode
public void setXORMode(Color c1)
- Specified by:
setXORMode
in classGraphics
- See Also:
Graphics.setXORMode(Color)
-
getFont
public Font getFont()
- Specified by:
getFont
in classGraphics
- See Also:
Graphics.getFont()
-
getFontMetrics
public FontMetrics getFontMetrics(Font f)
- Specified by:
getFontMetrics
in classGraphics
- See Also:
Graphics.getFontMetrics(Font)
-
getClipBounds
public Rectangle getClipBounds()
- Specified by:
getClipBounds
in classGraphics
- See Also:
Graphics.getClipBounds()
-
clipRect
public void clipRect(int x, int y, int width, int height)
- Specified by:
clipRect
in classGraphics
- See Also:
Graphics.clipRect(int, int, int, int)
-
setClip
public void setClip(int x, int y, int width, int height)
- Specified by:
setClip
in classGraphics
- See Also:
Graphics.setClip(int, int, int, int)
-
clip
public void clip(Shape s)
- Specified by:
clip
in classGraphics2D
- See Also:
Graphics2D.clip(Shape)
-
getClip
public Shape getClip()
- Specified by:
getClip
in classGraphics
- See Also:
Graphics.getClip()
-
setClip
public void setClip(Shape s)
- Specified by:
setClip
in classGraphics
- See Also:
Graphics.setClip(Shape)
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy)
- Specified by:
copyArea
in classGraphics
- See Also:
Graphics.copyArea(int, int, int, int, int, int)
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2)
- Specified by:
drawLine
in classGraphics
- See Also:
Graphics.drawLine(int, int, int, int)
-
drawRect
public void drawRect(int x, int y, int width, int height)
- Overrides:
drawRect
in classGraphics
- See Also:
Graphics.fillRect(int, int, int, int)
-
fillRect
public void fillRect(int x, int y, int width, int height)
- Specified by:
fillRect
in classGraphics
- See Also:
Graphics.fillRect(int, int, int, int)
-
clearRect
public void clearRect(int x, int y, int width, int height)
- Specified by:
clearRect
in classGraphics
- See Also:
Graphics.clearRect(int, int, int, int)
-
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
- Specified by:
drawRoundRect
in classGraphics
- See Also:
Graphics.drawRoundRect(int, int, int, int, int, int)
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
- Specified by:
fillRoundRect
in classGraphics
- See Also:
Graphics.fillRoundRect(int, int, int, int, int, int)
-
drawOval
public void drawOval(int x, int y, int width, int height)
- Specified by:
drawOval
in classGraphics
- See Also:
Graphics.drawOval(int, int, int, int)
-
fillOval
public void fillOval(int x, int y, int width, int height)
- Specified by:
fillOval
in classGraphics
- See Also:
Graphics.fillOval(int, int, int, int)
-
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
- Specified by:
drawArc
in classGraphics
- See Also:
Graphics.drawArc(int, int, int, int, int, int)
-
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
- Specified by:
fillArc
in classGraphics
- See Also:
Graphics.fillArc(int, int, int, int, int, int)
-
drawPolyline
public void drawPolyline(int[] x, int[] y, int nPoints)
- Specified by:
drawPolyline
in classGraphics
- See Also:
Graphics.drawPolyline(int[], int[], int)
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
- Specified by:
drawPolygon
in classGraphics
- See Also:
Graphics.drawPolygon(int[], int[], int)
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
- Specified by:
fillPolygon
in classGraphics
- See Also:
Graphics.fillPolygon(int[], int[], int)
-
drawImage
public boolean drawImage(Image img, int x, int y, ImageObserver observer)
- Specified by:
drawImage
in classGraphics
- See Also:
Graphics.drawImage(Image, int, int, ImageObserver)
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
- Specified by:
drawImage
in classGraphics
- See Also:
Graphics.drawImage(Image, int, int, int, int, ImageObserver)
-
drawImage
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
- Specified by:
drawImage
in classGraphics
- See Also:
Graphics.drawImage(Image, int, int, Color, ImageObserver)
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
- Specified by:
drawImage
in classGraphics
- See Also:
Graphics.drawImage(Image, int, int, int, int, Color, ImageObserver)
-
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
- Specified by:
drawImage
in classGraphics
- See Also:
Graphics.drawImage(Image, int, int, int, int, int, int, int, int, ImageObserver)
-
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)
- Specified by:
drawImage
in classGraphics
- See Also:
Graphics.drawImage(Image, int, int, int, int, int, int, int, int, Color, ImageObserver)
-
dispose
public void dispose()
- Specified by:
dispose
in classGraphics
- See Also:
Graphics.dispose()
-
normalizeMatrix
protected AffineTransform normalizeMatrix()
-
-