Class PDFGraphics
- java.lang.Object
-
- java.awt.Graphics
-
- java.awt.Graphics2D
-
- pdf.PDFGraphics
-
- All Implemented Interfaces:
java.io.Serializable
public class PDFGraphics extends java.awt.Graphics2D implements java.io.SerializableThis class is our implementation of AWT's Graphics class. It provides a Java standard way of rendering into a PDF Document's Page.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.RectangleclipRectangleThis holds the current clipRectangleprotected floattraxThis is used to translate coordinatesprotected floattrayThis is used to translate coordinates
-
Constructor Summary
Constructors Constructor Description PDFGraphics()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRenderingHints(java.util.Map<?,?> hints)voidarc(double axc, double ayc, double width, double height, double ang1, double ang2, boolean clockwise)This produces an arc by breaking it down into one or more Bezier curves.voidclearRect(int x, int y, int w, int h)This simply draws a White Rectangle to clear the areavoidclip(java.awt.Shape s)voidclipPolygon(java.awt.Polygon p)This extra method allows PDF users to clip to a Polygon.voidclipRect(int x, int y, int w, int h)Clips to a set of coordinatesvoidcopyArea(int x, int y, int w, int h, int dx, int dy)This is unsupported - how do you do this with Vector graphics?java.awt.Graphicscreate()This returns a child instance of this Graphics object.protected PDFGraphicscreateGraphic(PDFPage page, java.io.PrintWriter pw)This method creates a new instance of the class based on the page and a print writer.voidcurveto(double x1, double y1, double x2, double y2)This extension appends a Bezier curve to the path.voidcurveto(double x1, double y1, double x2, double y2, double x3, double y3)This extension appends a Bezier curve to the path.voidcurveto(int x1, int y1, int x2, int y2)This extension appends a Bezier curve to the path.voidcurveto(int x1, int y1, int x2, int y2, int x3, int y3)This extension appends a Bezier curve to the path.voidcurveto2(double x1, double y1, double x2, double y2)This extension appends a Bezier curve to the path.voidcurveto2(int x1, int y1, int x2, int y2)This extension appends a Bezier curve to the path.voiddispose()This releases any resources used by this Graphics object.voiddraw(java.awt.Shape s)voiddraw3DRect(int x, int y, int width, int height, boolean raised)Not implementedvoiddrawArc(int x, int y, int w, int h, int sa, int aa)Draws an arcvoiddrawBytes(byte[] data, int offset, int length, int x, int y)Not implementedvoiddrawGlyphVector(java.awt.font.GlyphVector g, float x, float y)voiddrawImage(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)booleandrawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)Draw's an image onto the page, with scalingbooleandrawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver obs)Draw's an image onto the page, with scalingbooleandrawImage(java.awt.Image img, int x, int y, int w, int h, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)Draw's an image onto the page, with a backing colour.booleandrawImage(java.awt.Image img, int x, int y, int w, int h, java.awt.image.ImageObserver obs)Draws an image onto the page.booleandrawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)Draw's an image onto the page, with a backing colour.booleandrawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver obs)Draw's an image onto the pagebooleandrawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver obs)voiddrawLine(int x1, int y1, int x2, int y2)Draws a line between two coordinates.voiddrawOval(int x, int y, int w, int h)Draws an ovalvoiddrawPolygon(int[] xp, int[] yp, int np)Draws a polygon, linking the first and last coordinates.voiddrawPolyline(int[] xp, int[] yp, int np)Draws a polyline.voiddrawRect(int x, int y, int w, int h)We override Graphics.drawRect as it doesn't join the 4 lines.voiddrawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)voiddrawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)voiddrawRoundRect(int x, int y, int w, int h, int aw, int ah)This is not yet implementedvoiddrawString(java.lang.String s, float x, float y)voiddrawString(java.lang.String s, int x, int y)This draws a string.voiddrawString(java.text.AttributedCharacterIterator aci, float x, float y)Draws a string using a AttributedCharacterIterator.voiddrawString(java.text.AttributedCharacterIterator aci, int x, int y)Draws a string using a AttributedCharacterIterator.voidfill(java.awt.Shape s)voidfill3DRect(int x, int y, int width, int height, boolean raised)Not implementedvoidfillArc(int x, int y, int w, int h, int sa, int aa)Fills an arc, joining the start and end coordinatesvoidfillOval(int x, int y, int w, int h)Draws a filled ovalvoidfillPolygon(int[] xp, int[] yp, int np)Fills a polygon.voidfillRect(int x, int y, int w, int h)Fills a rectangle with the current colourvoidfillRoundRect(int x, int y, int w, int h, int aw, int ah)This is not yet implementedjava.awt.ColorgetBackground()java.awt.ShapegetClip()Returns the Shape of the clipping region As my JDK docs say, this may break with Java 2D.java.awt.RectanglegetClipBounds()Returns the Rectangle that fits the current clipping regionjava.awt.ColorgetColor()Returns the current pen Colourjava.awt.CompositegetComposite()java.awt.GraphicsConfigurationgetDeviceConfiguration()java.awt.FontgetFont()Return's the current font.java.awt.FontMetricsgetFontMetrics(java.awt.Font font)Returns the FontMetrics for a font.java.awt.font.FontRenderContextgetFontRenderContext()PDFPagegetPage()Returns the associated PDFPage for this graphicjava.awt.PaintgetPaint()Returns the current pen Colourjava.lang.ObjectgetRenderingHint(java.awt.RenderingHints.Key arg0)java.awt.RenderingHintsgetRenderingHints()java.awt.StrokegetStroke()java.awt.geom.AffineTransformgetTransform()java.io.PrintWritergetWriter()Returns the PrintWriter handling the underlying streambooleanhit(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke)protected voidinit(PDFPage page)This is called by PDFPage when creating a Graphcis instance.protected voidinit(PDFPage page, java.io.PrintWriter pw)This method is used internally by create() and by the PDFJob classvoidlineto(double x, double y)This adds a line segment to the current pathvoidlineto(int x, int y)This adds a line segment to the current pathvoidmoveto(double x, double y)This moves the current drawing point.voidmoveto(int x, int y)This moves the current drawing point.voidpolygon(int[] xp, int[] yp, int np)This is used to add a polygon to the current path.voidrotate(double theta)voidrotate(double theta, double x, double y)voidscale(double sx, double sy)voidsetBackground(java.awt.Color color)voidsetClip(int x, int y, int w, int h)Clips to a set of coordinatesvoidsetClip(java.awt.Shape s)As my JDK docs say, this may break with Java 2D.voidsetColor(java.awt.Color c)Sets the color for drawingvoidsetComposite(java.awt.Composite comp)voidsetDefaultLineWidth()This extension sets the line width to the default of 1mm which is what Java uses when drawing to a PrintJob.voidsetFont(java.awt.Font f)This sets the font.voidsetLineWidth(float width)This extension allows the width of the drawn line to be setvoidsetPaint(java.awt.Paint paint)Sets the paint for drawingvoidsetPaintMode()Not implemented, as this is not supported in the PDF specification.voidsetRenderingHint(java.awt.RenderingHints.Key arg0, java.lang.Object arg1)Sets a rendering hintvoidsetRenderingHints(java.util.Map<?,?> hints)voidsetStroke(java.awt.Stroke s)voidsetTransform(java.awt.geom.AffineTransform t)voidsetXORMode(java.awt.Color c1)Not implemented, as this is not supported in the PDF specification.voidshear(double shx, double shy)voidtransform(java.awt.geom.AffineTransform tx)voidtranslate(double tx, double ty)voidtranslate(int x, int y)
-
-
-
Method Detail
-
addRenderingHints
public void addRenderingHints(java.util.Map<?,?> hints)
- Specified by:
addRenderingHintsin classjava.awt.Graphics2D- See Also:
Graphics2D.addRenderingHints(Map)
-
arc
public void arc(double axc, double ayc, double width, double height, double ang1, double ang2, boolean clockwise)This produces an arc by breaking it down into one or more Bezier curves. It is used internally to implement the drawArc and fillArc methods.- Parameters:
axc- X coordinate of arc centreayc- Y coordinate of arc centrewidth- of bounding rectangleheight- of bounding rectangleang1- Start angleang2- End angleclockwise- true to draw clockwise, false anti-clockwise
-
clearRect
public void clearRect(int x, int y, int w, int h)This simply draws a White Rectangle to clear the area- Specified by:
clearRectin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- height
-
clip
public void clip(java.awt.Shape s)
- Specified by:
clipin classjava.awt.Graphics2D- See Also:
Graphics2D.clip(Shape)
-
clipPolygon
public void clipPolygon(java.awt.Polygon p)
This extra method allows PDF users to clip to a Polygon.In theory you could use setClip(), except that java.awt.Graphics only supports Rectangle with that method, so we will have an extra method.
- Parameters:
p- Polygon to clip to
-
clipRect
public void clipRect(int x, int y, int w, int h)Clips to a set of coordinates- Specified by:
clipRectin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- height
-
copyArea
public void copyArea(int x, int y, int w, int h, int dx, int dy)This is unsupported - how do you do this with Vector graphics?- Specified by:
copyAreain classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- heightdx- coordinatedy- coordinate
-
create
public java.awt.Graphics create()
This returns a child instance of this Graphics object. As with AWT, the affects of using the parent instance while the child exists, is not determined.
Once complete, the child should be released with it's dispose() method which will restore the graphics state to it's parent.
- Specified by:
createin classjava.awt.Graphics- Returns:
- Graphics object to render onto the page
-
createGraphic
protected PDFGraphics createGraphic(PDFPage page, java.io.PrintWriter pw)
This method creates a new instance of the class based on the page and a print writer.- Parameters:
page- the page to attach topw- thePrintWriterto attach to.
-
curveto
public void curveto(double x1, double y1, double x2, double y2)This extension appends a Bezier curve to the path. The curve extends from the current point to (x2,y2) using the current point and (x1,y1) as the Bezier control points.The new current point is (x2,y2)
- Parameters:
x1- Second control pointy1- Second control pointx2- Destination pointy2- Destination point
-
curveto
public void curveto(double x1, double y1, double x2, double y2, double x3, double y3)This extension appends a Bezier curve to the path. The curve extends from the current point to (x3,y3) using (x1,y1) and (x2,y2) as the Bezier control points.The new current point is (x3,y3)
- Parameters:
x1- First control pointy1- First control pointx2- Second control pointy2- Second control pointx3- Destination pointy3- Destination point
-
curveto
public void curveto(int x1, int y1, int x2, int y2)This extension appends a Bezier curve to the path. The curve extends from the current point to (x2,y2) using the current point and (x1,y1) as the Bezier control points.The new current point is (x2,y2)
- Parameters:
x1- Second control pointy1- Second control pointx2- Destination pointy2- Destination point
-
curveto
public void curveto(int x1, int y1, int x2, int y2, int x3, int y3)This extension appends a Bezier curve to the path. The curve extends from the current point to (x3,y3) using (x1,y1) and (x2,y2) as the Bezier control points.The new current point is (x3,y3)
- Parameters:
x1- First control pointy1- First control pointx2- Second control pointy2- Second control pointx3- Destination pointy3- Destination point
-
curveto2
public void curveto2(double x1, double y1, double x2, double y2)This extension appends a Bezier curve to the path. The curve extends from the current point to (x2,y2) using (x1,y1) and the end point as the Bezier control points.The new current point is (x2,y2)
- Parameters:
x1- Second control pointy1- Second control pointx2- Destination pointy2- Destination point
-
curveto2
public void curveto2(int x1, int y1, int x2, int y2)This extension appends a Bezier curve to the path. The curve extends from the current point to (x2,y2) using (x1,y1) and the end point as the Bezier control points.The new current point is (x2,y2)
- Parameters:
x1- Second control pointy1- Second control pointx2- Destination pointy2- Destination point
-
dispose
public void dispose()
This releases any resources used by this Graphics object. You must use this method once finished with it. Leaving it open will leave the PDF stream in an inconsistent state, and will produce errors.
If this was created with Graphics.create() then the parent instance can be used again. If not, then this closes the graphics operations for this page when used with PDFJob.
When using PDFPage, you can create another fresh Graphics instance, which will draw over this one.
- Specified by:
disposein classjava.awt.Graphics
-
draw
public void draw(java.awt.Shape s)
- Specified by:
drawin classjava.awt.Graphics2D- See Also:
Graphics2D.draw(Shape)
-
draw3DRect
public void draw3DRect(int x, int y, int width, int height, boolean raised)Not implemented
Draws a 3-D highlighted outline of the specified rectangle. The edges of the rectangle are highlighted so that they appear to be beveled and lit from the upper left corner. The colors used for the highlighting effect are determined based on the current color. The resulting rectangle covers an area that is width + 1 pixels wide by height + 1 pixels tall.
- Overrides:
draw3DRectin classjava.awt.Graphics2D- Parameters:
x- anintvaluey- anintvaluewidth- anintvalueheight- anintvalueraised- abooleanvalue
-
drawArc
public void drawArc(int x, int y, int w, int h, int sa, int aa)Draws an arc- Specified by:
drawArcin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- heightsa- Start angleaa- End angle
-
drawBytes
public void drawBytes(byte[] data, int offset, int length, int x, int y)Not implemented
- Overrides:
drawBytesin classjava.awt.Graphics- Parameters:
data- abyte[]valueoffset- anintvaluelength- anintvaluex- anintvaluey- anintvalue
-
drawGlyphVector
public void drawGlyphVector(java.awt.font.GlyphVector g, float x, float y)- Specified by:
drawGlyphVectorin classjava.awt.Graphics2D- See Also:
Graphics2D.drawGlyphVector(GlyphVector, float, float)
-
drawImage
public void drawImage(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)- Specified by:
drawImagein classjava.awt.Graphics2D- See Also:
Graphics2D.drawImage(BufferedImage, BufferedImageOp, int, int)
-
drawImage
public boolean drawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver obs)- Specified by:
drawImagein classjava.awt.Graphics2D- See Also:
Graphics2D.drawImage(Image, AffineTransform, ImageObserver)
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)Draw's an image onto the page, with a backing colour.
- Specified by:
drawImagein classjava.awt.Graphics- Parameters:
img- The java.awt.Imagex- coordinate on pagey- coordinate on pagebgcolor- Background colourobs- ImageObserver- Returns:
- true if drawn
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver obs)Draw's an image onto the page- Specified by:
drawImagein classjava.awt.Graphics- Parameters:
img- The java.awt.Imagex- coordinate on pagey- coordinate on pageobs- ImageObserver- Returns:
- true if drawn
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, int w, int h, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)Draw's an image onto the page, with a backing colour.
- Specified by:
drawImagein classjava.awt.Graphics- Parameters:
img- The java.awt.Imagex- coordinate on pagey- coordinate on pagew- Width on pageh- height on pagebgcolor- Background colourobs- ImageObserver- Returns:
- true if drawn
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, int w, int h, java.awt.image.ImageObserver obs)Draws an image onto the page.
This method is implemented with ASCIIbase85 encoding and the zip stream deflater. It results in a stream that is anywhere from 3 to 10 times as big as the image. This obviously needs some improvement, but it works well for small images
- Specified by:
drawImagein classjava.awt.Graphics- Parameters:
img- The java.awt.Imagex- coordinate on pagey- coordinate on pagew- Width on pageh- height on pageobs- ImageObserver- Returns:
- true if drawn
-
drawImage
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)Draw's an image onto the page, with scalingThis is not yet supported.
- Specified by:
drawImagein classjava.awt.Graphics- Parameters:
img- The java.awt.Imagedx1- coordinate on pagedy1- coordinate on pagedx2- coordinate on pagedy2- coordinate on pagesx1- coordinate on imagesy1- coordinate on imagesx2- coordinate on imagesy2- coordinate on imagebgcolor- Background colourobs- ImageObserver- Returns:
- true if drawn
-
drawImage
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver obs)Draw's an image onto the page, with scalingThis is not yet supported.
- Specified by:
drawImagein classjava.awt.Graphics- Parameters:
img- The java.awt.Imagedx1- coordinate on pagedy1- coordinate on pagedx2- coordinate on pagedy2- coordinate on pagesx1- coordinate on imagesy1- coordinate on imagesx2- coordinate on imagesy2- coordinate on imageobs- ImageObserver- Returns:
- true if drawn
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2)Draws a line between two coordinates. If the first coordinate is the same as the last one drawn (i.e. a previous drawLine, moveto, etc) it is ignored.- Specified by:
drawLinein classjava.awt.Graphics- Parameters:
x1- coordinatey1- coordinatex2- coordinatey2- coordinate
-
drawOval
public void drawOval(int x, int y, int w, int h)Draws an oval
- Specified by:
drawOvalin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- height
-
drawPolygon
public void drawPolygon(int[] xp, int[] yp, int np)Draws a polygon, linking the first and last coordinates.- Specified by:
drawPolygonin classjava.awt.Graphics- Parameters:
xp- Array of x coordinatesyp- Array of y coordinatesnp- number of points in polygon
-
drawPolyline
public void drawPolyline(int[] xp, int[] yp, int np)Draws a polyline. The first and last coordinates are not linked.- Specified by:
drawPolylinein classjava.awt.Graphics- Parameters:
xp- Array of x coordinatesyp- Array of y coordinatesnp- number of points in polyline
-
drawRect
public void drawRect(int x, int y, int w, int h)We override Graphics.drawRect as it doesn't join the 4 lines. Also, PDF provides us with a Rectangle operator, so we will use that.- Overrides:
drawRectin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- height
-
drawRenderableImage
public void drawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)- Specified by:
drawRenderableImagein classjava.awt.Graphics2D- See Also:
Graphics2D.drawRenderableImage(RenderableImage, AffineTransform)
-
drawRenderedImage
public void drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)- Specified by:
drawRenderedImagein classjava.awt.Graphics2D- See Also:
Graphics2D.drawRenderedImage(RenderedImage, AffineTransform)
-
drawRoundRect
public void drawRoundRect(int x, int y, int w, int h, int aw, int ah)This is not yet implemented- Specified by:
drawRoundRectin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- heightaw- a-widthah- a-height
-
drawString
public void drawString(java.text.AttributedCharacterIterator aci, float x, float y)Draws a string using a AttributedCharacterIterator.This is not supported yet, as I have no idea what an AttributedCharacterIterator is.
This method is new to the Java2 API.
- Specified by:
drawStringin classjava.awt.Graphics2D
-
drawString
public void drawString(java.text.AttributedCharacterIterator aci, int x, int y)Draws a string using a AttributedCharacterIterator.This is not supported yet, as I have no idea what an AttributedCharacterIterator is.
This method is new to the Java2 API.
- Specified by:
drawStringin classjava.awt.Graphics2D
-
drawString
public void drawString(java.lang.String s, float x, float y)- Specified by:
drawStringin classjava.awt.Graphics2D
-
drawString
public void drawString(java.lang.String s, int x, int y)This draws a string.- Specified by:
drawStringin classjava.awt.Graphics2D- Parameters:
s- String to drawx- coordinatey- coordinate
-
fill
public void fill(java.awt.Shape s)
- Specified by:
fillin classjava.awt.Graphics2D- See Also:
Graphics2D.fill(Shape)
-
fill3DRect
public void fill3DRect(int x, int y, int width, int height, boolean raised)Not implemented
- Overrides:
fill3DRectin classjava.awt.Graphics2D- Parameters:
x- anintvaluey- anintvaluewidth- anintvalueheight- anintvalueraised- abooleanvalue
-
fillArc
public void fillArc(int x, int y, int w, int h, int sa, int aa)Fills an arc, joining the start and end coordinates- Specified by:
fillArcin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- heightsa- Start angleaa- End angle
-
fillOval
public void fillOval(int x, int y, int w, int h)Draws a filled oval
- Specified by:
fillOvalin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- height
-
fillPolygon
public void fillPolygon(int[] xp, int[] yp, int np)Fills a polygon.- Specified by:
fillPolygonin classjava.awt.Graphics- Parameters:
xp- Array of x coordinatesyp- Array of y coordinatesnp- number of points in polygon
-
fillRect
public void fillRect(int x, int y, int w, int h)Fills a rectangle with the current colour- Specified by:
fillRectin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- height
-
fillRoundRect
public void fillRoundRect(int x, int y, int w, int h, int aw, int ah)This is not yet implemented- Specified by:
fillRoundRectin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- heightaw- a-widthah- a-height
-
getBackground
public java.awt.Color getBackground()
- Specified by:
getBackgroundin classjava.awt.Graphics2D- See Also:
Graphics2D.getBackground()
-
getClip
public java.awt.Shape getClip()
Returns the Shape of the clipping region As my JDK docs say, this may break with Java 2D.- Specified by:
getClipin classjava.awt.Graphics- Returns:
- Shape of the clipping region
-
getClipBounds
public java.awt.Rectangle getClipBounds()
Returns the Rectangle that fits the current clipping region- Specified by:
getClipBoundsin classjava.awt.Graphics- Returns:
- the Rectangle that fits the current clipping region
-
getColor
public java.awt.Color getColor()
Returns the current pen Colour- Specified by:
getColorin classjava.awt.Graphics- Returns:
- the current pen Colour
-
getComposite
public java.awt.Composite getComposite()
- Specified by:
getCompositein classjava.awt.Graphics2D- See Also:
Graphics2D.getComposite()
-
getDeviceConfiguration
public java.awt.GraphicsConfiguration getDeviceConfiguration()
- Specified by:
getDeviceConfigurationin classjava.awt.Graphics2D- See Also:
Graphics2D.getDeviceConfiguration()
-
getFont
public java.awt.Font getFont()
Return's the current font.- Specified by:
getFontin classjava.awt.Graphics- Returns:
- the current font.
-
getFontMetrics
public java.awt.FontMetrics getFontMetrics(java.awt.Font font)
Returns the FontMetrics for a font.This doesn't work correctly. Perhaps having some way of mapping the base 14 fonts to our own FontMetrics implementation?
- Specified by:
getFontMetricsin classjava.awt.Graphics- Parameters:
font- The java.awt.Font to return the metrics for- Returns:
- FontMetrics for a font
-
getFontRenderContext
public java.awt.font.FontRenderContext getFontRenderContext()
- Specified by:
getFontRenderContextin classjava.awt.Graphics2D- See Also:
Graphics2D.getFontRenderContext()
-
getPage
public PDFPage getPage()
Returns the associated PDFPage for this graphic- Returns:
- the associated PDFPage for this graphic
-
getPaint
public java.awt.Paint getPaint()
Returns the current pen Colour- Specified by:
getPaintin classjava.awt.Graphics2D- Returns:
- the current pen Colour
-
getRenderingHint
public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key arg0)
- Specified by:
getRenderingHintin classjava.awt.Graphics2D- Parameters:
arg0- a key- Returns:
- the rendering hint
-
getRenderingHints
public java.awt.RenderingHints getRenderingHints()
- Specified by:
getRenderingHintsin classjava.awt.Graphics2D- See Also:
Graphics2D.getRenderingHints()
-
getStroke
public java.awt.Stroke getStroke()
- Specified by:
getStrokein classjava.awt.Graphics2D- See Also:
Graphics2D.getStroke()
-
getTransform
public java.awt.geom.AffineTransform getTransform()
- Specified by:
getTransformin classjava.awt.Graphics2D- See Also:
Graphics2D.getTransform()
-
getWriter
public java.io.PrintWriter getWriter()
Returns the PrintWriter handling the underlying stream- Returns:
- the PrintWriter handling the underlying stream
-
hit
public boolean hit(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke)- Specified by:
hitin classjava.awt.Graphics2D- See Also:
Graphics2D.hit(Rectangle, Shape, boolean)
-
init
protected void init(PDFPage page)
This is called by PDFPage when creating a Graphcis instance.- Parameters:
page- The PDFPage to draw onto.
-
init
protected void init(PDFPage page, java.io.PrintWriter pw)
This method is used internally by create() and by the PDFJob class- Parameters:
page- PDFPage to draw intopw- PrintWriter to use
-
lineto
public void lineto(double x, double y)This adds a line segment to the current path- Parameters:
x- coordinatey- coordinate
-
lineto
public void lineto(int x, int y)This adds a line segment to the current path- Parameters:
x- coordinatey- coordinate
-
moveto
public void moveto(double x, double y)This moves the current drawing point.- Parameters:
x- coordinatey- coordinate
-
moveto
public void moveto(int x, int y)This moves the current drawing point.- Parameters:
x- coordinatey- coordinate
-
polygon
public void polygon(int[] xp, int[] yp, int np)This is used to add a polygon to the current path. Used by drawPolygon(), drawPolyline() and fillPolygon() etal- Parameters:
xp- Array of x coordinatesyp- Array of y coordinatesnp- number of points in polygon- See Also:
drawPolygon(int[], int[], int),drawPolyline(int[], int[], int),fillPolygon(int[], int[], int)
-
rotate
public void rotate(double theta)
- Specified by:
rotatein classjava.awt.Graphics2D- See Also:
Graphics2D.rotate(double)
-
rotate
public void rotate(double theta, double x, double y)- Specified by:
rotatein classjava.awt.Graphics2D- See Also:
Graphics2D.rotate(double, double, double)
-
scale
public void scale(double sx, double sy)- Specified by:
scalein classjava.awt.Graphics2D- See Also:
Graphics2D.scale(double, double)
-
setBackground
public void setBackground(java.awt.Color color)
- Specified by:
setBackgroundin classjava.awt.Graphics2D- See Also:
Graphics2D.setBackground(Color)
-
setClip
public void setClip(int x, int y, int w, int h)Clips to a set of coordinates- Specified by:
setClipin classjava.awt.Graphics- Parameters:
x- coordinatey- coordinatew- widthh- height
-
setClip
public void setClip(java.awt.Shape s)
As my JDK docs say, this may break with Java 2D.Sets the clipping region to that of a Shape.
- Specified by:
setClipin classjava.awt.Graphics- Parameters:
s- Shape to clip to.
-
setColor
public void setColor(java.awt.Color c)
Sets the color for drawing- Specified by:
setColorin classjava.awt.Graphics- Parameters:
c- Color to use
-
setComposite
public void setComposite(java.awt.Composite comp)
- Specified by:
setCompositein classjava.awt.Graphics2D- See Also:
Graphics2D.setComposite(Composite)
-
setDefaultLineWidth
public void setDefaultLineWidth()
This extension sets the line width to the default of 1mm which is what Java uses when drawing to a PrintJob.
-
setFont
public void setFont(java.awt.Font f)
This sets the font.- Specified by:
setFontin classjava.awt.Graphics- Parameters:
f- java.awt.Font to set to.
-
setLineWidth
public void setLineWidth(float width)
This extension allows the width of the drawn line to be set- Parameters:
width- Line width in pdf graphic units (points)
-
setPaint
public void setPaint(java.awt.Paint paint)
Sets the paint for drawing- Specified by:
setPaintin classjava.awt.Graphics2D- Parameters:
paint- Paint to use
-
setPaintMode
public void setPaintMode()
Not implemented, as this is not supported in the PDF specification.- Specified by:
setPaintModein classjava.awt.Graphics
-
setRenderingHint
public void setRenderingHint(java.awt.RenderingHints.Key arg0, java.lang.Object arg1)Sets a rendering hint- Specified by:
setRenderingHintin classjava.awt.Graphics2D- Parameters:
arg0-arg1-
-
setRenderingHints
public void setRenderingHints(java.util.Map<?,?> hints)
- Specified by:
setRenderingHintsin classjava.awt.Graphics2D- See Also:
Graphics2D.setRenderingHints(Map)
-
setStroke
public void setStroke(java.awt.Stroke s)
- Specified by:
setStrokein classjava.awt.Graphics2D- See Also:
Graphics2D.setStroke(Stroke)
-
setTransform
public void setTransform(java.awt.geom.AffineTransform t)
- Specified by:
setTransformin classjava.awt.Graphics2D- See Also:
Graphics2D.setTransform(AffineTransform)
-
setXORMode
public void setXORMode(java.awt.Color c1)
Not implemented, as this is not supported in the PDF specification.- Specified by:
setXORModein classjava.awt.Graphics- Parameters:
c1- Color to xor with
-
shear
public void shear(double shx, double shy)- Specified by:
shearin classjava.awt.Graphics2D- See Also:
Graphics2D.shear(double, double)
-
transform
public void transform(java.awt.geom.AffineTransform tx)
- Specified by:
transformin classjava.awt.Graphics2D- See Also:
Graphics2D.transform(AffineTransform)
-
translate
public void translate(double tx, double ty)- Specified by:
translatein classjava.awt.Graphics2D- See Also:
Graphics2D.translate(double, double)
-
translate
public void translate(int x, int y)- Specified by:
translatein classjava.awt.Graphics2D- See Also:
Graphics.translate(int, int)
-
-