- java.lang.Object
-
- java.awt.Graphics
-
- java.awt.Graphics2D
-
- com.lowagie.text.pdf.PdfGraphics2D
-
- Direct Known Subclasses:
PdfPrinterGraphics2D
public class PdfGraphics2D extends Graphics2D
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPdfGraphics2D.HyperLinkKey
-
Field Summary
Fields Modifier and Type Field Description static intAFM_DIVISORprotected intcurrentFillGStateprotected intcurrentStrokeGStateprotected PdfGState[]fillGStateprotected PdfGState[]strokeGStateprotected booleanunderline
-
Constructor Summary
Constructors Constructor Description 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRenderingHints(Map hints)static doubleasPoints(double d, int i)Calculates position and/or stroke thickness depending on the font sizevoidclearRect(int x, int y, int width, int height)voidclip(Shape s)voidclipRect(int x, int y, int width, int height)voidcopyArea(int x, int y, int width, int height, int dx, int dy)Graphicscreate()voiddispose()protected voiddoAttributes(AttributedCharacterIterator iter)This routine goes through the attributes and sets the font before calling the actual string drawing routinevoiddraw(Shape s)voiddrawArc(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)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)voiddrawString(AttributedCharacterIterator iter, float x, float y)voiddrawString(AttributedCharacterIterator iterator, int x, int y)voidfill(Shape s)voidfillArc(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)ColorgetBackground()ShapegetClip()RectanglegetClipBounds()ColorgetColor()CompositegetComposite()PdfContentBytegetContent()GraphicsConfigurationgetDeviceConfiguration()FontgetFont()FontMetricsgetFontMetrics(Font f)FontRenderContextgetFontRenderContext()PaintgetPaint()Method contributed by Alexej SuchovObjectgetRenderingHint(RenderingHints.Key arg0)RenderingHintsgetRenderingHints()StrokegetStroke()AffineTransformgetTransform()booleanhit(Rectangle rect, Shape s, boolean onStroke)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)voidsetClip(Shape s)voidsetColor(Color color)voidsetComposite(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.voidsetFont(Font f)Sets the current font.voidsetPaint(Paint paint)Method contributed by Alexej SuchovvoidsetPaintMode()voidsetRenderingHint(RenderingHints.Key arg0, Object arg1)Sets a rendering hintvoidsetRenderingHints(Map hints)voidsetStroke(Stroke s)voidsetTransform(AffineTransform t)voidsetXORMode(Color c1)voidshear(double shx, double shy)voidtransform(AffineTransform tx)voidtranslate(double tx, double ty)voidtranslate(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
-
AFM_DIVISOR
public static final int AFM_DIVISOR
- See Also:
- Constant Field Values
-
underline
protected boolean underline
-
fillGState
protected PdfGState[] fillGState
-
strokeGState
protected PdfGState[] strokeGState
-
currentFillGState
protected int currentFillGState
-
currentStrokeGState
protected int currentStrokeGState
-
-
Constructor Detail
-
PdfGraphics2D
public PdfGraphics2D(PdfContentByte cb, float width, float height)
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 Detail
-
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
public void draw(Shape s)
- Specified by:
drawin classGraphics2D- See Also:
Graphics2D.draw(Shape)
-
drawImage
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
- Specified by:
drawImagein classGraphics2D- See Also:
Graphics2D.drawImage(Image, AffineTransform, ImageObserver)
-
drawImage
public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
- Specified by:
drawImagein classGraphics2D- See Also:
Graphics2D.drawImage(BufferedImage, BufferedImageOp, int, int)
-
drawRenderedImage
public void drawRenderedImage(RenderedImage img, AffineTransform xform)
- Specified by:
drawRenderedImagein classGraphics2D- See Also:
Graphics2D.drawRenderedImage(RenderedImage, AffineTransform)
-
drawRenderableImage
public void drawRenderableImage(RenderableImage img, AffineTransform xform)
- Specified by:
drawRenderableImagein classGraphics2D- See Also:
Graphics2D.drawRenderableImage(RenderableImage, AffineTransform)
-
drawString
public void drawString(String s, int x, int y)
- Specified by:
drawStringin classGraphics2D- See Also:
Graphics.drawString(String, int, int)
-
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- the AttributedCharacterIterator
-
drawString
public void drawString(String s, float x, float y)
- Specified by:
drawStringin classGraphics2D- See Also:
Graphics2D.drawString(String, float, float)
-
drawString
public void drawString(AttributedCharacterIterator iterator, int x, int y)
- Specified by:
drawStringin classGraphics2D- See Also:
Graphics.drawString(AttributedCharacterIterator, int, int)
-
drawString
public void drawString(AttributedCharacterIterator iter, float x, float y)
- Specified by:
drawStringin classGraphics2D- See Also:
Graphics2D.drawString(AttributedCharacterIterator, float, float)
-
drawGlyphVector
public void drawGlyphVector(GlyphVector g, float x, float y)
- Specified by:
drawGlyphVectorin classGraphics2D- See Also:
Graphics2D.drawGlyphVector(GlyphVector, float, float)
-
fill
public void fill(Shape s)
- Specified by:
fillin classGraphics2D- See Also:
Graphics2D.fill(Shape)
-
hit
public boolean hit(Rectangle rect, Shape s, boolean onStroke)
- Specified by:
hitin classGraphics2D- See Also:
Graphics2D.hit(Rectangle, Shape, boolean)
-
getDeviceConfiguration
public GraphicsConfiguration getDeviceConfiguration()
- Specified by:
getDeviceConfigurationin classGraphics2D- See Also:
Graphics2D.getDeviceConfiguration()
-
setRenderingHint
public void setRenderingHint(RenderingHints.Key arg0, Object arg1)
Sets a rendering hint- Specified by:
setRenderingHintin classGraphics2D- Parameters:
arg0- the Keyarg1- the Object to associate to it
-
getRenderingHint
public Object getRenderingHint(RenderingHints.Key arg0)
- Specified by:
getRenderingHintin classGraphics2D- Parameters:
arg0- a key- Returns:
- the rendering hint
-
addRenderingHints
public void addRenderingHints(Map hints)
- Specified by:
addRenderingHintsin classGraphics2D- See Also:
Graphics2D.addRenderingHints(Map)
-
getRenderingHints
public RenderingHints getRenderingHints()
- Specified by:
getRenderingHintsin classGraphics2D- See Also:
Graphics2D.getRenderingHints()
-
setRenderingHints
public void setRenderingHints(Map hints)
- Specified by:
setRenderingHintsin classGraphics2D- See Also:
Graphics2D.setRenderingHints(Map)
-
translate
public void translate(int x, int y)- Specified by:
translatein classGraphics2D- See Also:
Graphics.translate(int, int)
-
translate
public void translate(double tx, double ty)- Specified by:
translatein classGraphics2D- See Also:
Graphics2D.translate(double, double)
-
rotate
public void rotate(double theta)
- Specified by:
rotatein classGraphics2D- See Also:
Graphics2D.rotate(double)
-
rotate
public void rotate(double theta, double x, double y)- Specified by:
rotatein classGraphics2D- See Also:
Graphics2D.rotate(double, double, double)
-
scale
public void scale(double sx, double sy)- Specified by:
scalein classGraphics2D- See Also:
Graphics2D.scale(double, double)
-
shear
public void shear(double shx, double shy)- Specified by:
shearin classGraphics2D- See Also:
Graphics2D.shear(double, double)
-
transform
public void transform(AffineTransform tx)
- Specified by:
transformin classGraphics2D- See Also:
Graphics2D.transform(AffineTransform)
-
getTransform
public AffineTransform getTransform()
- Specified by:
getTransformin classGraphics2D- See Also:
Graphics2D.getTransform()
-
setTransform
public void setTransform(AffineTransform t)
- Specified by:
setTransformin classGraphics2D- See Also:
Graphics2D.setTransform(AffineTransform)
-
getPaint
public Paint getPaint()
Method contributed by Alexej Suchov- Specified by:
getPaintin classGraphics2D- See Also:
Graphics2D.getPaint()
-
setPaint
public void setPaint(Paint paint)
Method contributed by Alexej Suchov- Specified by:
setPaintin classGraphics2D- See Also:
Graphics2D.setPaint(Paint)
-
getComposite
public Composite getComposite()
- Specified by:
getCompositein classGraphics2D- See Also:
Graphics2D.getComposite()
-
setComposite
public void setComposite(Composite comp)
Method contributed by Alexej Suchov- Specified by:
setCompositein classGraphics2D- See Also:
Graphics2D.setComposite(Composite)
-
getBackground
public Color getBackground()
- Specified by:
getBackgroundin classGraphics2D- See Also:
Graphics2D.getBackground()
-
setBackground
public void setBackground(Color color)
- Specified by:
setBackgroundin classGraphics2D- See Also:
Graphics2D.setBackground(Color)
-
getStroke
public Stroke getStroke()
- Specified by:
getStrokein classGraphics2D- See Also:
Graphics2D.getStroke()
-
setStroke
public void setStroke(Stroke s)
- Specified by:
setStrokein classGraphics2D- See Also:
Graphics2D.setStroke(Stroke)
-
getFontRenderContext
public FontRenderContext getFontRenderContext()
- Specified by:
getFontRenderContextin classGraphics2D- See Also:
Graphics2D.getFontRenderContext()
-
create
public Graphics create()
- Specified by:
createin classGraphics- See Also:
Graphics.create()
-
getContent
public PdfContentByte getContent()
-
getColor
public Color getColor()
- Specified by:
getColorin classGraphics- See Also:
Graphics.getColor()
-
setColor
public void setColor(Color color)
- Specified by:
setColorin classGraphics- See Also:
Graphics.setColor(Color)
-
setPaintMode
public void setPaintMode()
- Specified by:
setPaintModein classGraphics- See Also:
Graphics.setPaintMode()
-
setXORMode
public void setXORMode(Color c1)
- Specified by:
setXORModein classGraphics- See Also:
Graphics.setXORMode(Color)
-
getFont
public Font getFont()
- Specified by:
getFontin classGraphics- See Also:
Graphics.getFont()
-
getFontMetrics
public FontMetrics getFontMetrics(Font f)
- Specified by:
getFontMetricsin classGraphics- See Also:
Graphics.getFontMetrics(Font)
-
getClipBounds
public Rectangle getClipBounds()
- Specified by:
getClipBoundsin classGraphics- See Also:
Graphics.getClipBounds()
-
clipRect
public void clipRect(int x, int y, int width, int height)- Specified by:
clipRectin classGraphics- See Also:
Graphics.clipRect(int, int, int, int)
-
setClip
public void setClip(int x, int y, int width, int height)- Specified by:
setClipin classGraphics- See Also:
Graphics.setClip(int, int, int, int)
-
clip
public void clip(Shape s)
- Specified by:
clipin classGraphics2D- See Also:
Graphics2D.clip(Shape)
-
getClip
public Shape getClip()
- Specified by:
getClipin classGraphics- See Also:
Graphics.getClip()
-
setClip
public void setClip(Shape s)
- Specified by:
setClipin classGraphics- See Also:
Graphics.setClip(Shape)
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy)- Specified by:
copyAreain 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:
drawLinein classGraphics- See Also:
Graphics.drawLine(int, int, int, int)
-
drawRect
public void drawRect(int x, int y, int width, int height)- Overrides:
drawRectin classGraphics- See Also:
Graphics.fillRect(int, int, int, int)
-
fillRect
public void fillRect(int x, int y, int width, int height)- Specified by:
fillRectin classGraphics- See Also:
Graphics.fillRect(int, int, int, int)
-
clearRect
public void clearRect(int x, int y, int width, int height)- Specified by:
clearRectin 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:
drawRoundRectin 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:
fillRoundRectin 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:
drawOvalin classGraphics- See Also:
Graphics.drawOval(int, int, int, int)
-
fillOval
public void fillOval(int x, int y, int width, int height)- Specified by:
fillOvalin 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:
drawArcin 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:
fillArcin classGraphics- See Also:
Graphics.fillArc(int, int, int, int, int, int)
-
drawPolyline
public void drawPolyline(int[] x, int[] y, int nPoints)- Specified by:
drawPolylinein classGraphics- See Also:
Graphics.drawPolyline(int[], int[], int)
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)- Specified by:
drawPolygonin classGraphics- See Also:
Graphics.drawPolygon(int[], int[], int)
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)- Specified by:
fillPolygonin classGraphics- See Also:
Graphics.fillPolygon(int[], int[], int)
-
drawImage
public boolean drawImage(Image img, int x, int y, ImageObserver observer)
- Specified by:
drawImagein 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:
drawImagein 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:
drawImagein 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:
drawImagein 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:
drawImagein 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:
drawImagein classGraphics- See Also:
Graphics.drawImage(Image, int, int, int, int, int, int, int, int, Color, ImageObserver)
-
dispose
public void dispose()
- Specified by:
disposein classGraphics- See Also:
Graphics.dispose()
-
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.
-
-