Main Page | Namespace List | Class Hierarchy | Class List | Class Members | Related Pages

gnu::jpdf::PDFGraphics Class Reference

Inheritance diagram for gnu::jpdf::PDFGraphics:

Inheritance graph
[legend]
Collaboration diagram for gnu::jpdf::PDFGraphics:

Collaboration graph
[legend]
List of all members.

Public Member Functions

PrintWriter getWriter ()
PDFPage getPage ()
Graphics create ()
void dispose ()
void clearRect (int x, int y, int w, int h)
void drawRect (int x, int y, int w, int h)
void draw3DRect (int x, int y, int width, int height, boolean raised)
void fill3DRect (int x, int y, int width, int height, boolean raised)
void fillRect (int x, int y, int w, int h)
void fillRoundRect (int x, int y, int w, int h, int aw, int ah)
void drawRoundRect (int x, int y, int w, int h, int aw, int ah)
void drawOval (int x, int y, int w, int h)
void fillOval (int x, int y, int w, int h)
void drawPolygon (int[] xp, int[] yp, int np)
void drawPolyline (int[] xp, int[] yp, int np)
void fillPolygon (int[] xp, int[] yp, int np)
boolean drawImage (Image img, int x, int y, ImageObserver obs)
boolean drawImage (Image img, int x, int y, int w, int h, ImageObserver obs)
boolean drawImage (Image img, int x, int y, Color bgcolor, ImageObserver obs)
boolean drawImage (Image img, int x, int y, int w, int h, Color bgcolor, ImageObserver obs)
boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver obs)
boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver obs)
void clipRect (int x, int y, int w, int h)
void setClip (int x, int y, int w, int h)
void setClip (Shape s)
void clipPolygon (Polygon p)
Rectangle getClipBounds ()
Color getColor ()
void setColor (Color c)
void setPaintMode ()
void setXORMode (Color c1)
FontMetrics getFontMetrics (Font font)
Font getFont ()
void setFont (Font f)
void drawString (String s, int x, int y)
void drawBytes (byte[] data, int offset, int length, int x, int y)
void copyArea (int x, int y, int w, int h, int dx, int dy)
void drawLine (int x1, int y1, int x2, int y2)
void translate (int x, int y)
void drawArc (int x, int y, int w, int h, int sa, int aa)
void fillArc (int x, int y, int w, int h, int sa, int aa)
void moveto (int x, int y)
void moveto (double x, double y)
void lineto (int x, int y)
void lineto (double x, double y)
void setLineWidth (double w)
void setDefaultLineWidth ()
void polygon (int[] xp, int[] yp, int np)
void curveto (int x1, int y1, int x2, int y2, int x3, int y3)
void curveto (double x1, double y1, double x2, double y2, double x3, double y3)
void curveto (int x1, int y1, int x2, int y2)
void curveto (double x1, double y1, double x2, double y2)
void curveto2 (int x1, int y1, int x2, int y2)
void curveto2 (double x1, double y1, double x2, double y2)
void arc (double axc, double ayc, double width, double height, double ang1, double ang2, boolean clockwise)
void setOrientation ()
Shape getClip ()
void drawString (java.text.AttributedCharacterIterator aci, int x, int y)

Protected Member Functions

PDFGraphics createGraphic (PDFPage page, PrintWriter pw)
void init (PDFPage page)
void init (PDFPage page, PrintWriter pw)

Protected Attributes

Rectangle media
int trax
int tray
Rectangle clipRectangle

Package Functions

void closeBlock ()
void closeBlock (String code)
void newPath ()
void newTextBlock (int x, int y)

Detailed Description

This class is our implementation of AWT's Graphics class. It provides a

Java standard way of rendering into a PDF Document's Page.

Author:
Peter T Mount, http://www.retep.org.uk/pdf/

Eric Z. Beard, ericzbeard@hotmail.com

Author
ezb
Version:
Revision
1.2
,
Date
2001/11/16 15:26:04
See also:
gnu.jpdf.PDFGraphics


Member Function Documentation

void gnu::jpdf::PDFGraphics::arc double  axc,
double  ayc,
double  width,
double  height,
double  ang1,
double  ang2,
boolean  clockwise
[inline]
 

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 centre
ayc Y coordinate of arc centre
width of bounding rectangle
height of bounding rectangle
ang1 Start angle
ang2 End angle
clockwise true to draw clockwise, false anti-clockwise

void gnu::jpdf::PDFGraphics::clearRect int  x,
int  y,
int  w,
int  h
[inline]
 

This simply draws a White Rectangle to clear the area

Parameters:
x coord
y coord
w width
h height

void gnu::jpdf::PDFGraphics::clipPolygon Polygon  p  )  [inline]
 

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

void gnu::jpdf::PDFGraphics::clipRect int  x,
int  y,
int  w,
int  h
[inline]
 

Clips to a set of coordinates

Parameters:
x coord
y coord
w width
h height

void gnu::jpdf::PDFGraphics::closeBlock String  code  )  [inline, package]
 

This is used by code that use the path in any way other than Stroke

(like Fill, close path & Stroke etc). Usually this is used internally.

Parameters:
code PDF operators that will close the path

void gnu::jpdf::PDFGraphics::closeBlock  )  [inline, package]
 

All functions should call this to close any existing optimised blocks.

void gnu::jpdf::PDFGraphics::copyArea int  x,
int  y,
int  w,
int  h,
int  dx,
int  dy
[inline]
 

This is unsupported - how do you do this with Vector graphics?

Parameters:
x coord
y coord
w width
h height
dx coord
dy coord

Graphics gnu::jpdf::PDFGraphics::create  )  [inline]
 

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.

Returns:
Graphics object to render onto the page

Reimplemented in gnu::jpdf::PDFJob::graphic.

PDFGraphics gnu::jpdf::PDFGraphics::createGraphic PDFPage  page,
PrintWriter  pw
[inline, protected]
 

This method creates a new instance of the class based on the page

and a print writer.

Parameters:
page the page to attach to
pw the PrintWriter to attach to.

void gnu::jpdf::PDFGraphics::curveto double  x1,
double  y1,
double  x2,
double  y2
[inline]
 

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 point
y1 Second control point
x2 Destination point
y2 Destination point

void gnu::jpdf::PDFGraphics::curveto int  x1,
int  y1,
int  x2,
int  y2
[inline]
 

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 point
y1 Second control point
x2 Destination point
y2 Destination point

void gnu::jpdf::PDFGraphics::curveto double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3
[inline]
 

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 point
y1 First control point
x2 Second control point
y2 Second control point
x3 Destination point
y3 Destination point

void gnu::jpdf::PDFGraphics::curveto int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3
[inline]
 

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 point
y1 First control point
x2 Second control point
y2 Second control point
x3 Destination point
y3 Destination point

void gnu::jpdf::PDFGraphics::curveto2 double  x1,
double  y1,
double  x2,
double  y2
[inline]
 

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 point
y1 Second control point
x2 Destination point
y2 Destination point

void gnu::jpdf::PDFGraphics::curveto2 int  x1,
int  y1,
int  x2,
int  y2
[inline]
 

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 point
y1 Second control point
x2 Destination point
y2 Destination point

void gnu::jpdf::PDFGraphics::dispose  )  [inline]
 

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.

void gnu::jpdf::PDFGraphics::draw3DRect int  x,
int  y,
int  width,
int  height,
boolean  raised
[inline]
 

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.

Parameters:
x an int value
y an int value
width an int value
height an int value
raised a boolean value

void gnu::jpdf::PDFGraphics::drawArc int  x,
int  y,
int  w,
int  h,
int  sa,
int  aa
[inline]
 

Draws an arc

Parameters:
x coord
y coord
w width
h height
sa Start angle
aa End angle

void gnu::jpdf::PDFGraphics::drawBytes byte[]  data,
int  offset,
int  length,
int  x,
int  y
[inline]
 

Not implemented

Parameters:
data a byte[] value
offset an int value
length an int value
x an int value
y an int value

boolean gnu::jpdf::PDFGraphics::drawImage Image  img,
int  dx1,
int  dy1,
int  dx2,
int  dy2,
int  sx1,
int  sy1,
int  sx2,
int  sy2,
Color  bgcolor,
ImageObserver  obs
[inline]
 

Draw's an image onto the page, with scaling

This is not yet supported.

Parameters:
img The java.awt.Image
dx1 coordinate on page
dy1 coordinate on page
dx2 coordinate on page
dy2 coordinate on page
sx1 coordinate on image
sy1 coordinate on image
sx2 coordinate on image
sy2 coordinate on image
bgcolor Background colour
obs ImageObserver
Returns:
true if drawn

boolean gnu::jpdf::PDFGraphics::drawImage Image  img,
int  dx1,
int  dy1,
int  dx2,
int  dy2,
int  sx1,
int  sy1,
int  sx2,
int  sy2,
ImageObserver  obs
[inline]
 

Draw's an image onto the page, with scaling

This is not yet supported.

Parameters:
img The java.awt.Image
dx1 coordinate on page
dy1 coordinate on page
dx2 coordinate on page
dy2 coordinate on page
sx1 coordinate on image
sy1 coordinate on image
sx2 coordinate on image
sy2 coordinate on image
obs ImageObserver
Returns:
true if drawn

boolean gnu::jpdf::PDFGraphics::drawImage Image  img,
int  x,
int  y,
int  w,
int  h,
Color  bgcolor,
ImageObserver  obs
[inline]
 

Draw's an image onto the page, with a backing colour.

Parameters:
img The java.awt.Image
x coordinate on page
y coordinate on page
w Width on page
h height on page
bgcolor Background colour
obs ImageObserver
Returns:
true if drawn

boolean gnu::jpdf::PDFGraphics::drawImage Image  img,
int  x,
int  y,
Color  bgcolor,
ImageObserver  obs
[inline]
 

Draw's an image onto the page, with a backing colour.

Parameters:
img The java.awt.Image
x coordinate on page
y coordinate on page
bgcolor Background colour
obs ImageObserver
Returns:
true if drawn

boolean gnu::jpdf::PDFGraphics::drawImage Image  img,
int  x,
int  y,
int  w,
int  h,
ImageObserver  obs
[inline]
 

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 obviusly needs some

improvement, but it works well for small images

Parameters:
img The java.awt.Image
x coordinate on page
y coordinate on page
w Width on page
h height on page
obs ImageObserver
Returns:
true if drawn

boolean gnu::jpdf::PDFGraphics::drawImage Image  img,
int  x,
int  y,
ImageObserver  obs
[inline]
 

Draw's an image onto the page

Parameters:
img The java.awt.Image
x coordinate on page
y coordinate on page
obs ImageObserver
Returns:
true if drawn

void gnu::jpdf::PDFGraphics::drawLine int  x1,
int  y1,
int  x2,
int  y2
[inline]
 

Draws a line between two coordinates.

If the first coordinate is the same as the last one drawn

(ie a previous drawLine, moveto, etc) it is ignored.

Parameters:
x1 coord
y1 coord
x2 coord
y2 coord

void gnu::jpdf::PDFGraphics::drawOval int  x,
int  y,
int  w,
int  h
[inline]
 

Draws an oval

Parameters:
x coord
y coord
w width
h height

void gnu::jpdf::PDFGraphics::drawPolygon int[]  xp,
int[]  yp,
int  np
[inline]
 

Draws a polygon, linking the first and last coordinates.

Parameters:
xp Array of x coordinates
yp Array of y coordinates
np number of points in polygon

void gnu::jpdf::PDFGraphics::drawPolyline int[]  xp,
int[]  yp,
int  np
[inline]
 

Draws a polyline. The first and last coordinates are not linked.

Parameters:
xp Array of x coordinates
yp Array of y coordinates
np number of points in polyline

void gnu::jpdf::PDFGraphics::drawRect int  x,
int  y,
int  w,
int  h
[inline]
 

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.

Parameters:
x coord
y coord
w width
h height

void gnu::jpdf::PDFGraphics::drawRoundRect int  x,
int  y,
int  w,
int  h,
int  aw,
int  ah
[inline]
 

This is not yet implemented

Parameters:
x coord
y coord
w width
h height
aw a-width
ah a-height

void gnu::jpdf::PDFGraphics::drawString java.text.AttributedCharacterIterator  aci,
int  x,
int  y
[inline]
 

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.

void gnu::jpdf::PDFGraphics::drawString String  s,
int  x,
int  y
[inline]
 

This draws a string.

Parameters:
s String to draw
x coord
y coord

void gnu::jpdf::PDFGraphics::fill3DRect int  x,
int  y,
int  width,
int  height,
boolean  raised
[inline]
 

Not implemented

Parameters:
x an int value
y an int value
width an int value
height an int value
raised a boolean value

void gnu::jpdf::PDFGraphics::fillArc int  x,
int  y,
int  w,
int  h,
int  sa,
int  aa
[inline]
 

Fills an arc, joining the start and end coordinates

Parameters:
x coord
y coord
w width
h height
sa Start angle
aa End angle

void gnu::jpdf::PDFGraphics::fillOval int  x,
int  y,
int  w,
int  h
[inline]
 

Draws a filled oval

Parameters:
x coord
y coord
w width
h height

void gnu::jpdf::PDFGraphics::fillPolygon int[]  xp,
int[]  yp,
int  np
[inline]
 

Fills a polygon.

Parameters:
xp Array of x coordinates
yp Array of y coordinates
np number of points in polygon

void gnu::jpdf::PDFGraphics::fillRect int  x,
int  y,
int  w,
int  h
[inline]
 

Fills a rectangle with the current colour

Parameters:
x coord
y coord
w width
h height

void gnu::jpdf::PDFGraphics::fillRoundRect int  x,
int  y,
int  w,
int  h,
int  aw,
int  ah
[inline]
 

This is not yet implemented

Parameters:
x coord
y coord
w width
h height
aw a-width
ah a-height

Shape gnu::jpdf::PDFGraphics::getClip  )  [inline]
 

Returns the Shape of the clipping region

As my JDK docs say, this may break with Java 2D.

Returns:
Shape of the clipping region

Rectangle gnu::jpdf::PDFGraphics::getClipBounds  )  [inline]
 

Returns the Rectangle that fits the current clipping region

Returns:
the Rectangle that fits the current clipping region

Color gnu::jpdf::PDFGraphics::getColor  )  [inline]
 

Returns the current pen Colour

Returns:
the current pen Colour

Font gnu::jpdf::PDFGraphics::getFont  )  [inline]
 

Return's the current font.

Returns:
the current font.

FontMetrics gnu::jpdf::PDFGraphics::getFontMetrics Font  font  )  [inline]
 

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?

Parameters:
font The java.awt.Font to return the metrics for
Returns:
FontMetrics for a font

PDFPage gnu::jpdf::PDFGraphics::getPage  )  [inline]
 

Returns the associated PDFPage for this graphic

Returns:
the associated PDFPage for this graphic

PrintWriter gnu::jpdf::PDFGraphics::getWriter  )  [inline]
 

Returns the PrintWriter handling the underlying stream

Returns:
the PrintWriter handling the underlying stream

void gnu::jpdf::PDFGraphics::init PDFPage  page,
PrintWriter  pw
[inline, protected]
 

This method is used internally by create() and by the PDFJob class

Parameters:
page PDFPage to draw into
pw PrintWriter to use

void gnu::jpdf::PDFGraphics::init PDFPage  page  )  [inline, protected]
 

This is called by PDFPage when creating a Graphcis instance.

Parameters:
page The PDFPage to draw onto.

void gnu::jpdf::PDFGraphics::lineto double  x,
double  y
[inline]
 

This adds a line segment to the current path

Parameters:
x coord
y coord

void gnu::jpdf::PDFGraphics::lineto int  x,
int  y
[inline]
 

This adds a line segment to the current path

Parameters:
x coord
y coord

void gnu::jpdf::PDFGraphics::moveto double  x,
double  y
[inline]
 

This moves the current drawing point.

Parameters:
x coord
y coord

void gnu::jpdf::PDFGraphics::moveto int  x,
int  y
[inline]
 

This moves the current drawing point.

Parameters:
x coord
y coord

void gnu::jpdf::PDFGraphics::newPath  )  [inline, package]
 

Functions that draw lines should start by calling this. It starts a

new path unless inStroke is set, in that case it uses the existing path

void gnu::jpdf::PDFGraphics::newTextBlock int  x,
int  y
[inline, package]
 

Functions that draw text should start by calling this. It starts a text

block (accounting for media orientation) unless we are already in a Text

block.

It also handles if the font has been changed since the current text

block was started, so your function will be current.

Parameters:
x x coord in java space
y y coord in java space

void gnu::jpdf::PDFGraphics::polygon int[]  xp,
int[]  yp,
int  np
[inline]
 

This is used to add a polygon to the current path.

Used by drawPolygon(), drawPolyline() and fillPolygon() etal

Parameters:
xp Array of x coordinates
yp Array of y coordinates
np number of points in polygon
See also:
drawPolygon

drawPolyline

fillPolygon

void gnu::jpdf::PDFGraphics::setClip Shape  s  )  [inline]
 

As my JDK docs say, this may break with Java 2D.

Sets the clipping region to that of a Shape.

Parameters:
s Shape to clip to.

void gnu::jpdf::PDFGraphics::setClip int  x,
int  y,
int  w,
int  h
[inline]
 

Clips to a set of coordinates

Parameters:
x coord
y coord
w width
h height

void gnu::jpdf::PDFGraphics::setColor Color  c  )  [inline]
 

Sets the colour for drawing

Parameters:
c Color to use

void gnu::jpdf::PDFGraphics::setDefaultLineWidth  )  [inline]
 

This extension sets the line width to the default of 1mm which is what

Java uses when drawing to a PrintJob.

void gnu::jpdf::PDFGraphics::setFont Font  f  )  [inline]
 

This sets the font.

Parameters:
f java.awt.Font to set to.

void gnu::jpdf::PDFGraphics::setLineWidth double  w  )  [inline]
 

This extension allows the width of the drawn line to be set

Parameters:
w Line width in mm

void gnu::jpdf::PDFGraphics::setOrientation  )  [inline]
 

This sets the media Orientation (0=Portrait, 90=Landscape,

180=Inverse, 270=Seascape).

Normally, this is called when the Graphics instance is created, but

if the media is changed, then this must be called, especially when using

the PDFJob class to create the file.

void gnu::jpdf::PDFGraphics::setPaintMode  )  [inline]
 

Not implemented, as this is not supported in the PDF specification.

void gnu::jpdf::PDFGraphics::setXORMode Color  c1  )  [inline]
 

Not implemented, as this is not supported in the PDF specification.

Parameters:
c1 Color to xor with

void gnu::jpdf::PDFGraphics::translate int  x,
int  y
[inline]
 

Translate the origin.

Parameters:
x coord offset
y coord offset


Member Data Documentation

Rectangle gnu::jpdf::PDFGraphics::clipRectangle [protected]
 

This holds the current clipRectangle

Rectangle gnu::jpdf::PDFGraphics::media [protected]
 

This is the media we are working with

int gnu::jpdf::PDFGraphics::trax [protected]
 

This is used to translate coordinates

int gnu::jpdf::PDFGraphics::tray [protected]
 

This is used to translate coordinates


The documentation for this class was generated from the following file:
Generated on Wed Jan 19 16:58:07 2005 by  doxygen 1.3.9.1