Class PDFGraphics2D
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
com.orsonpdf.PDFGraphics2D
A
Graphics2D implementation that writes to PDF format. For
typical usage, see the documentation for the PDFDocument class.
For some demos of the use of this class, please check out the JFree Demos project at GitHub (https://github.com/jfree/jfree-demos).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Arc2DAn instance that is lazily instantiated in draw/fillArc and then subsequently reused to avoid creating a lot of garbage.private Colorprivate ShapeThe user clip (can be null).private Colorprivate Compositeprivate GraphicsConfigurationprivate Fontprivate final FontRenderContextThe font render context.private GraphicsStreamThe content created by the Graphics2D instance.(package private) intprivate RenderingHintsRendering hints (all ignored).private final BufferedImageA hidden image used for font metrics.private Line2DAn instance that is lazily instantiated in drawLine and then subsequently reused to avoid creating a lot of garbage.(package private) AffineTransformWhen an instance is created via thecreate()method, a copy of the transform in effect is retained so it can be restored once the child instance is disposed.private Ellipse2DAn instance that is lazily instantiated in draw/fillOval and then subsequently reused to avoid creating a lot of garbage.private Paint(package private) Rectangle2DAn instance that is lazily instantiated in fillRect and then subsequently reused to avoid creating a lot of garbage.private RoundRectangle2DAn instance that is lazily instantiated in draw/fillRoundRect and then subsequently reused to avoid creating a lot of garbage.private Strokeprivate AffineTransform(package private) int -
Constructor Summary
ConstructorsConstructorDescriptionPDFGraphics2D(GraphicsStream gs, int width, int height) Creates a new instance ofPDFGraphics2D.PDFGraphics2D(GraphicsStream gs, int width, int height, boolean skipJava2DTransform) Creates a new instance ofPDFGraphics2D. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRenderingHints(Map<?, ?> hints) Adds all the supplied rendering hints.voidclearRect(int x, int y, int width, int height) Clears the specified rectangle by filling it with the current background color.voidClips to the intersection of the current clipping region and the specified shape.voidclipRect(int x, int y, int width, int height) Clips to the intersection of the current clipping region and the specified rectangle.voidcopyArea(int x, int y, int width, int height, int dx, int dy) This method does nothing.create()Returns a newPDFGraphics2Dinstance that is a copy of this instance.voiddispose()Performs any actions required when the graphics instance is finished with.voidDraws the specified shape with the currentpaintandstroke.voiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle) Draws an arc contained within the rectangle(x, y, width, height), starting atstartAngleand continuing througharcAngledegrees using the currentpaintandstroke.voiddrawGlyphVector(GlyphVector g, float x, float y) Draws the specified glyph vector at the location(x, y).voiddrawImage(BufferedImage img, BufferedImageOp op, int x, int y) Draws the image resulting from applying theBufferedImageOpto the specified image at the location(x, y).booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) Draws part of an image (defined by the source rectangle(sx1, sy1, sx2, sy2)) into the destination rectangle(dx1, dy1, dx2, dy2).booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) Draws part of an image (defined by the source rectangle(sx1, sy1, sx2, sy2)) into the destination rectangle(dx1, dy1, dx2, dy2).booleandrawImage(Image img, int x, int y, int w, int h, Color bgcolor, ImageObserver observer) Draws an image to the rectangle(x, y, w, h)(scaling it if required), first filling the background with the specified color.booleandrawImage(Image img, int x, int y, int w, int h, ImageObserver observer) Draws the image into the rectangle defined by(x, y, w, h).booleandrawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) Draws an image at the location(x, y).booleandrawImage(Image img, int x, int y, ImageObserver observer) Draws an image at the location(x, y).booleandrawImage(Image img, AffineTransform xform, ImageObserver observer) Draws an image with the specified transform.voiddrawLine(int x1, int y1, int x2, int y2) Draws a line from(x1, y1)to(x2, y2)using the currentpaintandstroke.voiddrawOval(int x, int y, int width, int height) Draws an oval framed by the rectangle(x, y, width, height)using the currentpaintandstroke.voiddrawPolygon(int[] xPoints, int[] yPoints, int nPoints) Draws the specified polygon using the currentpaintandstroke.voiddrawPolyline(int[] xPoints, int[] yPoints, int nPoints) Draws the specified multi-segment line using the currentpaintandstroke.voiddrawRenderableImage(RenderableImage img, AffineTransform xform) Draws the renderable image.voiddrawRenderedImage(RenderedImage img, AffineTransform xform) Draws the rendered image.voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) Draws a rectangle with rounded corners using the currentpaintandstroke.voiddrawString(String str, float x, float y) Draws a string at(x, y).voiddrawString(String str, int x, int y) Draws a string at(x, y).voiddrawString(AttributedCharacterIterator iterator, float x, float y) Draws a string of attributed characters at(x, y).voiddrawString(AttributedCharacterIterator iterator, int x, int y) Draws a string of attributed characters at(x, y).voidFills the specified shape with the currentpaint.voidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle) Fills an arc contained within the rectangle(x, y, width, height), starting atstartAngleand continuing througharcAngledegrees, using the currentpaintvoidfillOval(int x, int y, int width, int height) Fills an oval framed by the rectangle(x, y, width, height).voidfillPolygon(int[] xPoints, int[] yPoints, int nPoints) Fills the specified polygon using the currentpaint.voidfillRect(int x, int y, int width, int height) Fills the specified rectangle with the currentpaint.voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) Fills a rectangle with rounded corners.Returns the background color.getClip()Returns the user clipping region.Returns the bounds of the user clipping region.getColor()Returns the foreground color.Returns the current composite.Returns the device configuration associated with thisGraphics2D.getFont()Returns the current font used for drawing text.Returns the font metrics for the specified font.Returns the font render context.getPaint()Returns the paint used to draw or fill shapes (or text).getRenderingHint(RenderingHints.Key hintKey) Returns the current value for the specified hint.Returns a copy of the rendering hints.Returns the current stroke (used when drawing shapes).Returns a copy of the current transform.booleanReturnstrueif the rectangle (in device space) intersects with the shape (the interior, ifonStrokeis false, otherwise the stroked outline of the shape).private ShapeinvTransformedClip(Shape clip) voidrotate(double theta) Applies a rotation (anti-clockwise) about(0, 0).voidrotate(double theta, double x, double y) Applies a rotation (anti-clockwise) about(x, y).voidscale(double sx, double sy) Applies a scale transformation.private voidsetArc(int x, int y, int width, int height, int startAngle, int arcAngle) Sets the attributes of the reusableArc2Dobject that is used bydrawArc(int, int, int, int, int, int)andfillArc(int, int, int, int, int, int)methods.voidsetBackground(Color color) Sets the background color.voidsetClip(int x, int y, int width, int height) Sets the user clipping region to the specified rectangle.voidSets the user clipping region.voidSets the foreground color.voidsetComposite(Composite comp) Sets the composite (onlyAlphaCompositeis handled).voidSets the font to be used for drawing text.private voidsetOval(int x, int y, int width, int height) Sets the attributes of the reusableEllipse2Dobject that is used by thedrawOval(int, int, int, int)andfillOval(int, int, int, int)methods.voidSets the paint used to draw or fill shapes (or text).voidDoes nothing in thisPDFGraphics2Dimplementation.private voidsetRect(int x, int y, int width, int height) Sets the attributes of the reusableRectangle2Dobject that is used by theGraphics.drawRect(int, int, int, int)andfillRect(int, int, int, int)methods.voidsetRenderingHint(RenderingHints.Key hintKey, Object hintValue) Sets the value for a hint.voidsetRenderingHints(Map<?, ?> hints) Sets the rendering hints to the specified collection.private voidsetRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) Sets the attributes of the reusableRoundRectangle2Dobject that is used by thedrawRoundRect(int, int, int, int, int, int)andfillRoundRect(int, int, int, int, int, int)methods.voidSets the stroke that will be used to draw shapes.voidSets the transform.voidsetXORMode(Color c) Does nothing in thisPDFGraphics2Dimplementation.voidshear(double shx, double shy) Applies a shear transformation.voidApplies this transform to the existing transform by concatenating it.voidtranslate(double tx, double ty) Applies the translation(tx, ty).voidtranslate(int tx, int ty) Applies the translation(tx, ty).Methods inherited from class Graphics2D
draw3DRect, fill3DRectMethods inherited from class Graphics
create, drawBytes, drawChars, drawPolygon, drawRect, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
-
Field Details
-
width
int width -
height
int height -
hints
Rendering hints (all ignored). -
paint
-
color
-
background
-
composite
-
stroke
-
transform
-
clip
The user clip (can be null). -
font
-
image
A hidden image used for font metrics. -
line
An instance that is lazily instantiated in drawLine and then subsequently reused to avoid creating a lot of garbage. -
rect
Rectangle2D rectAn instance that is lazily instantiated in fillRect and then subsequently reused to avoid creating a lot of garbage. -
roundRect
An instance that is lazily instantiated in draw/fillRoundRect and then subsequently reused to avoid creating a lot of garbage. -
oval
An instance that is lazily instantiated in draw/fillOval and then subsequently reused to avoid creating a lot of garbage. -
arc
An instance that is lazily instantiated in draw/fillArc and then subsequently reused to avoid creating a lot of garbage. -
gs
The content created by the Graphics2D instance. -
deviceConfiguration
-
fontRenderContext
The font render context. The fractional metrics flag solves the glyph positioning issue identified by Christoph Nahr: http://news.kynosarges.org/2014/06/28/glyph-positioning-in-jfreesvg-orsonpdf/ -
originalTransform
AffineTransform originalTransformWhen an instance is created via thecreate()method, a copy of the transform in effect is retained so it can be restored once the child instance is disposed. See issue #4 at GitHub.
-
-
Constructor Details
-
PDFGraphics2D
Creates a new instance ofPDFGraphics2D. You won't normally create this directly, instead you will call thePage.getGraphics2D()method.- Parameters:
gs- the graphics stream (nullnot permitted).width- the width.height- the height.
-
PDFGraphics2D
Creates a new instance ofPDFGraphics2D. You won't normally create this directly, instead you will call thePage.getGraphics2D()method.- Parameters:
gs- the graphics stream (nullnot permitted).width- the width.height- the height.skipJava2DTransform- a flag that allows the PDF to Java2D transform to be skipped (used for watermarks which are appended to an existing stream that already has the transform).
-
-
Method Details
-
create
-
getPaint
Returns the paint used to draw or fill shapes (or text). The default value isColor.WHITE.- Specified by:
getPaintin classGraphics2D- Returns:
- The paint (never
null). - See Also:
-
setPaint
Sets the paint used to draw or fill shapes (or text). Ifpaintis an instance ofColor, this method will also update the current color attribute (seegetColor()). If you passnullto this method, it does nothing (in accordance with the JDK specification).- Specified by:
setPaintin classGraphics2D- Parameters:
paint- the paint (nullis permitted but ignored).- See Also:
-
getColor
Returns the foreground color. This method exists for backwards compatibility in AWT, you should normally use thegetPaint()method instead. -
setColor
Sets the foreground color. This method exists for backwards compatibility in AWT, you should normally use thesetPaint(java.awt.Paint)method. -
getBackground
Returns the background color. The default value isColor.BLACK. This is used by theclearRect(int, int, int, int)method.- Specified by:
getBackgroundin classGraphics2D- Returns:
- The background color (possibly
null). - See Also:
-
setBackground
Sets the background color. This is used by theclearRect(int, int, int, int)method. The reference implementation allowsnullfor the background color so we allow that too (but for that case, theclearRect()method will do nothing).- Specified by:
setBackgroundin classGraphics2D- Parameters:
color- the color (nullpermitted).- See Also:
-
getComposite
Returns the current composite.- Specified by:
getCompositein classGraphics2D- Returns:
- The current composite (never
null). - See Also:
-
setComposite
Sets the composite (onlyAlphaCompositeis handled).- Specified by:
setCompositein classGraphics2D- Parameters:
comp- the composite (nullnot permitted).- See Also:
-
getStroke
Returns the current stroke (used when drawing shapes).- Specified by:
getStrokein classGraphics2D- Returns:
- The current stroke (never
null). - See Also:
-
setStroke
Sets the stroke that will be used to draw shapes. OnlyBasicStrokeis supported.- Specified by:
setStrokein classGraphics2D- Parameters:
s- the stroke (nullnot permitted).- See Also:
-
getRenderingHint
Returns the current value for the specified hint. See thePDFHintsclass for details of the supported hints.- Specified by:
getRenderingHintin classGraphics2D- Parameters:
hintKey- the hint key (nullpermitted, but the result will benullalso).- Returns:
- The current value for the specified hint (possibly
null). - See Also:
-
setRenderingHint
Sets the value for a hint. See thePDFHintsclass for details of the supported hints.- Specified by:
setRenderingHintin classGraphics2D- Parameters:
hintKey- the hint key.hintValue- the hint value.- See Also:
-
getRenderingHints
Returns a copy of the rendering hints. Modifying the returned copy will have no impact on the state of thisGraphics2Dinstance.- Specified by:
getRenderingHintsin classGraphics2D- Returns:
- The rendering hints (never
null). - See Also:
-
setRenderingHints
Sets the rendering hints to the specified collection.- Specified by:
setRenderingHintsin classGraphics2D- Parameters:
hints- the new set of hints (nullnot permitted).- See Also:
-
addRenderingHints
Adds all the supplied rendering hints.- Specified by:
addRenderingHintsin classGraphics2D- Parameters:
hints- the hints (nullnot permitted).
-
invTransformedClip
-
draw
Draws the specified shape with the currentpaintandstroke. There is direct handling forLine2DandPath2Dinstances. All other shapes are mapped to aGeneralPathand then drawn (effectively asPath2Dobjects).- Specified by:
drawin classGraphics2D- Parameters:
s- the shape (nullnot permitted).- See Also:
-
fill
Fills the specified shape with the currentpaint. There is direct handling forPath2Dinstances. All other shapes are mapped to aGeneralPathand then filled.- Specified by:
fillin classGraphics2D- Parameters:
s- the shape (nullnot permitted).- See Also:
-
getFont
-
setFont
-
getFontMetrics
Returns the font metrics for the specified font.- Specified by:
getFontMetricsin classGraphics- Parameters:
f- the font.- Returns:
- The font metrics.
-
getFontRenderContext
Returns the font render context. The implementation here returns theFontRenderContextfor an image that is maintained internally (as forgetFontMetrics(Font)).- Specified by:
getFontRenderContextin classGraphics2D- Returns:
- The font render context.
-
drawString
Draws a string at(x, y). The start of the text at the baseline level will be aligned with the(x, y)point.- Specified by:
drawStringin classGraphics2D- Parameters:
str- the string (nullnot permitted).x- the x-coordinate.y- the y-coordinate.- See Also:
-
drawString
Draws a string at(x, y). The start of the text at the baseline level will be aligned with the(x, y)point.- Specified by:
drawStringin classGraphics2D- Parameters:
str- the string (nullnot permitted).x- the x-coordinate.y- the y-coordinate.
-
drawString
Draws a string of attributed characters at(x, y). The call is delegated todrawString(java.text.AttributedCharacterIterator, float, float).- Specified by:
drawStringin classGraphics2D- Parameters:
iterator- an iterator for the characters.x- the x-coordinate.y- the x-coordinate.
-
drawString
Draws a string of attributed characters at(x, y).LIMITATION: in the current implementation, the string is drawn using the current font and the formatting is ignored.
- Specified by:
drawStringin classGraphics2D- Parameters:
iterator- an iterator over the characters (nullnot permitted).x- the x-coordinate.y- the y-coordinate.
-
drawGlyphVector
Draws the specified glyph vector at the location(x, y).- Specified by:
drawGlyphVectorin classGraphics2D- Parameters:
g- the glyph vector (nullnot permitted).x- the x-coordinate.y- the y-coordinate.
-
translate
public void translate(int tx, int ty) Applies the translation(tx, ty). This call is delegated totranslate(double, double).- Specified by:
translatein classGraphics2D- Parameters:
tx- the x-translation.ty- the y-translation.- See Also:
-
translate
public void translate(double tx, double ty) Applies the translation(tx, ty).- Specified by:
translatein classGraphics2D- Parameters:
tx- the x-translation.ty- the y-translation.
-
rotate
public void rotate(double theta) Applies a rotation (anti-clockwise) about(0, 0).- Specified by:
rotatein classGraphics2D- Parameters:
theta- the rotation angle (in radians).
-
rotate
public void rotate(double theta, double x, double y) Applies a rotation (anti-clockwise) about(x, y).- Specified by:
rotatein classGraphics2D- Parameters:
theta- the rotation angle (in radians).x- the x-coordinate.y- the y-coordinate.
-
scale
public void scale(double sx, double sy) Applies a scale transformation.- Specified by:
scalein classGraphics2D- Parameters:
sx- the x-scaling factor.sy- the y-scaling factor.
-
shear
public void shear(double shx, double shy) Applies a shear transformation. This is equivalent to the following call to thetransformmethod:-
transform(AffineTransform.getShearInstance(shx, shy));
- Specified by:
shearin classGraphics2D- Parameters:
shx- the x-shear factor.shy- the y-shear factor.
-
-
transform
Applies this transform to the existing transform by concatenating it.- Specified by:
transformin classGraphics2D- Parameters:
t- the transform (nullnot permitted).
-
getTransform
Returns a copy of the current transform.- Specified by:
getTransformin classGraphics2D- Returns:
- A copy of the current transform (never
null). - See Also:
-
setTransform
Sets the transform.- Specified by:
setTransformin classGraphics2D- Parameters:
t- the new transform (nullpermitted, resets to the identity transform).- See Also:
-
hit
Returnstrueif the rectangle (in device space) intersects with the shape (the interior, ifonStrokeis false, otherwise the stroked outline of the shape).- Specified by:
hitin classGraphics2D- Parameters:
rect- a rectangle (in device space).s- the shape.onStroke- test the stroked outline only?- Returns:
- A boolean.
-
getDeviceConfiguration
Returns the device configuration associated with thisGraphics2D.- Specified by:
getDeviceConfigurationin classGraphics2D- Returns:
- The graphics configuration.
-
setPaintMode
public void setPaintMode()Does nothing in thisPDFGraphics2Dimplementation.- Specified by:
setPaintModein classGraphics
-
setXORMode
Does nothing in thisPDFGraphics2Dimplementation.- Specified by:
setXORModein classGraphics- Parameters:
c- ignored
-
getClip
-
setClip
-
getClipBounds
Returns the bounds of the user clipping region. If the user clipping region isnull, this method will returnnull.- Specified by:
getClipBoundsin classGraphics- Returns:
- The clip bounds (possibly
null). - See Also:
-
clip
Clips to the intersection of the current clipping region and the specified shape.According to the Oracle API specification, this method will accept a
nullargument, but there is an open bug report (since 2004) that suggests this is wrong:- Specified by:
clipin classGraphics2D- Parameters:
s- the clip shape (nullnot permitted).
-
clipRect
-
setClip
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2) Draws a line from(x1, y1)to(x2, y2)using the currentpaintandstroke. -
fillRect
-
clearRect
public void clearRect(int x, int y, int width, int height) Clears the specified rectangle by filling it with the current background color. If the background color isnull, this method will do nothing. -
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) Draws a rectangle with rounded corners using the currentpaintandstroke.- Specified by:
drawRoundRectin classGraphics- Parameters:
x- the x-coordinate.y- the y-coordinate.width- the width.height- the height.arcWidth- the arc-width.arcHeight- the arc-height.- See Also:
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) Fills a rectangle with rounded corners.- Specified by:
fillRoundRectin classGraphics- Parameters:
x- the x-coordinate.y- the y-coordinate.width- the width.height- the height.arcWidth- the arc-width.arcHeight- the arc-height.
-
drawOval
public void drawOval(int x, int y, int width, int height) Draws an oval framed by the rectangle(x, y, width, height)using the currentpaintandstroke. -
fillOval
-
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) Draws an arc contained within the rectangle(x, y, width, height), starting atstartAngleand continuing througharcAngledegrees using the currentpaintandstroke. -
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) Fills an arc contained within the rectangle(x, y, width, height), starting atstartAngleand continuing througharcAngledegrees, using the currentpaint -
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) Draws the specified multi-segment line using the currentpaintandstroke.- Specified by:
drawPolylinein classGraphics- Parameters:
xPoints- the x-points.yPoints- the y-points.nPoints- the number of points to use for the polyline.
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) Draws the specified polygon using the currentpaintandstroke.- Specified by:
drawPolygonin classGraphics- Parameters:
xPoints- the x-points.yPoints- the y-points.nPoints- the number of points to use for the polygon.- See Also:
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) Fills the specified polygon using the currentpaint.- Specified by:
fillPolygonin classGraphics- Parameters:
xPoints- the x-points.yPoints- the y-points.nPoints- the number of points to use for the polygon.- See Also:
-
drawImage
Draws an image with the specified transform. Note that theobsis ignored.- Specified by:
drawImagein classGraphics2D- Parameters:
img- the image.xform- the transform (nullpermitted).observer- the image observer (ignored).- Returns:
trueif the image is drawn.
-
drawImage
Draws the image resulting from applying theBufferedImageOpto the specified image at the location(x, y).- Specified by:
drawImagein classGraphics2D- Parameters:
img- the image.op- the operation.x- the x-coordinate.y- the y-coordinate.
-
drawRenderedImage
Draws the rendered image. Whenimgisnullthis method does nothing.- Specified by:
drawRenderedImagein classGraphics2D- Parameters:
img- the image (nullpermitted).xform- the transform.
-
drawRenderableImage
Draws the renderable image.- Specified by:
drawRenderableImagein classGraphics2D- Parameters:
img- the renderable image.xform- the transform.
-
drawImage
Draws an image at the location(x, y). Note that theobserveris ignored. -
drawImage
Draws the image into the rectangle defined by(x, y, w, h). Note that theobserveris ignored (it is not useful in this context). -
drawImage
Draws an image at the location(x, y). Note that theobserveris ignored. -
drawImage
public boolean drawImage(Image img, int x, int y, int w, int h, Color bgcolor, ImageObserver observer) Draws an image to the rectangle(x, y, w, h)(scaling it if required), first filling the background with the specified color. Note that theobserveris ignored. -
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) Draws part of an image (defined by the source rectangle(sx1, sy1, sx2, sy2)) into the destination rectangle(dx1, dy1, dx2, dy2). Note that theobserveris ignored.- Specified by:
drawImagein classGraphics- Parameters:
img- the image.dx1- the x-coordinate for the top left of the destination.dy1- the y-coordinate for the top left of the destination.dx2- the x-coordinate for the bottom right of the destination.dy2- the y-coordinate for the bottom right of the destination.sx1- the x-coordinate for the top left of the source.sy1- the y-coordinate for the top left of the source.sx2- the x-coordinate for the bottom right of the source.sy2- the y-coordinate for the bottom right of the source.- Returns:
trueif the image is drawn.
-
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) Draws part of an image (defined by the source rectangle(sx1, sy1, sx2, sy2)) into the destination rectangle(dx1, dy1, dx2, dy2). The destination rectangle is first cleared by filling it with the specifiedbgcolor. Note that theobserveris ignored.- Specified by:
drawImagein classGraphics- Parameters:
img- the image.dx1- the x-coordinate for the top left of the destination.dy1- the y-coordinate for the top left of the destination.dx2- the x-coordinate for the bottom right of the destination.dy2- the y-coordinate for the bottom right of the destination.sx1- the x-coordinate for the top left of the source.sy1- the y-coordinate for the top left of the source.sx2- the x-coordinate for the bottom right of the source.sy2- the y-coordinate for the bottom right of the source.bgcolor- the background color (nullpermitted).observer- ignored.- Returns:
trueif the image is drawn.
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy) This method does nothing. The operation assumes that the output is in bitmap form, which is not the case for PDF, so we silently ignore this method call. -
dispose
-
setRect
private void setRect(int x, int y, int width, int height) Sets the attributes of the reusableRectangle2Dobject that is used by theGraphics.drawRect(int, int, int, int)andfillRect(int, int, int, int)methods.- Parameters:
x- the x-coordinate.y- the y-coordinate.width- the width.height- the height.
-
setRoundRect
private void setRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) Sets the attributes of the reusableRoundRectangle2Dobject that is used by thedrawRoundRect(int, int, int, int, int, int)andfillRoundRect(int, int, int, int, int, int)methods.- Parameters:
x- the x-coordinate.y- the y-coordinate.width- the width.height- the height.arcWidth- the arc width.arcHeight- the arc height.
-
setOval
private void setOval(int x, int y, int width, int height) Sets the attributes of the reusableEllipse2Dobject that is used by thedrawOval(int, int, int, int)andfillOval(int, int, int, int)methods.- Parameters:
x- the x-coordinate.y- the y-coordinate.width- the width.height- the height.
-
setArc
private void setArc(int x, int y, int width, int height, int startAngle, int arcAngle) Sets the attributes of the reusableArc2Dobject that is used bydrawArc(int, int, int, int, int, int)andfillArc(int, int, int, int, int, int)methods.- Parameters:
x- the x-coordinate.y- the y-coordinate.width- the width.height- the height.startAngle- the start angle in degrees, 0 = 3 o'clock.arcAngle- the angle (anticlockwise) in degrees.
-