voji.utils
Class PageGraphics

java.lang.Object
  |
  +--java.awt.Graphics
        |
        +--voji.utils.CopyGraphics
              |
              +--voji.utils.PageGraphics

public class PageGraphics
extends CopyGraphics

This class coveres another Graphics object giving page dimensions, a resolution and a page number to it. The page number is counted automatically.


Constructor Summary
PageGraphics()
          Creates a new empty PageGraphics instance
PageGraphics(java.awt.Graphics graphics, java.awt.Dimension dimension, int dpi)
          Creates a new PageGraphics instance using the Graphics object, page dimensions and page resolution
PageGraphics(java.awt.PrintJob printJob)
          Creates a new PageGraphics instance using a PrintJob
 
Method Summary
 java.awt.Graphics create()
          Creates a new PageGraphics instance as a copy of the current object
 java.awt.Dimension getPageDimension()
          Returns the current page dimensions
 int getPageNumber()
          Returns the current page number
 int getPageResolution()
          Returns the current page resolution
 void setAll(java.awt.Graphics graphics, java.awt.Dimension dimension, int dpi)
          Sets all necessary parameters at once
 void setAll(java.awt.PrintJob printJob)
          Sets all necessary parameters at once
 void setGraphics(java.awt.Graphics graphics)
          Sets the current sub Graphics object.
 void setPageDimension(java.awt.Dimension dimension)
          Sets the current page dimensions
 void setPageNumber(int number)
          Sets the current page number.
 void setPageResolution(int dpi)
          Sets the current page resolution
 int toPixels(double length)
          Returns the number of pixels of the given length
 java.lang.String toString()
          Returns a String object representing this object's value
 
Methods inherited from class voji.utils.CopyGraphics
addGraphics, addGraphics, clearRect, clipRect, copyArea, dispose, drawArc, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRoundRect, drawString, drawString, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, finalize, getClip, getClipBounds, getColor, getFont, getFontMetrics, removeGraphics, setClip, setClip, setColor, setFont, setPaintMode, setXORMode, translate
 
Methods inherited from class java.awt.Graphics
create, draw3DRect, drawBytes, drawChars, drawPolygon, drawRect, fill3DRect, fillPolygon, getClipBounds, getClipRect, getFontMetrics, hitClip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PageGraphics

public PageGraphics()
Creates a new empty PageGraphics instance


PageGraphics

public PageGraphics(java.awt.Graphics graphics,
                    java.awt.Dimension dimension,
                    int dpi)
Creates a new PageGraphics instance using the Graphics object, page dimensions and page resolution

Parameters:
graphics - the Graphics object to cover
dimension - the new page dimensions (in pixels)
dpi - the new page resolution in pixels per inch (DPI)
See Also:
setAll(Graphics,Dimension,int)

PageGraphics

public PageGraphics(java.awt.PrintJob printJob)
Creates a new PageGraphics instance using a PrintJob

Parameters:
printJob - the PrintJob where to take the Graphics object, page dimensions and page resolution from
See Also:
setAll(PrintJob)
Method Detail

create

public java.awt.Graphics create()
Creates a new PageGraphics instance as a copy of the current object

Overrides:
create in class CopyGraphics

toString

public java.lang.String toString()
Returns a String object representing this object's value

Overrides:
toString in class CopyGraphics
Returns:
a string representation of this graphics context

setAll

public void setAll(java.awt.Graphics graphics,
                   java.awt.Dimension dimension,
                   int dpi)
Sets all necessary parameters at once

Parameters:
graphics - the new Graphics object to cover
dimension - the new page dimensions (in pixels)
dpi - the new page resolution in pixels per inch (DPI)

setAll

public void setAll(java.awt.PrintJob printJob)
Sets all necessary parameters at once

Parameters:
printJob - the PrintJob where to take the Graphics object, page dimensions and page resolution from

getPageDimension

public java.awt.Dimension getPageDimension()
Returns the current page dimensions

Returns:
the current page dimensions (in pixels)

setPageDimension

public void setPageDimension(java.awt.Dimension dimension)
Sets the current page dimensions


getPageResolution

public int getPageResolution()
Returns the current page resolution

Returns:
the current page resolution in pixels per inch (DPI)

setPageResolution

public void setPageResolution(int dpi)
Sets the current page resolution

Parameters:
dpi - the new page resolution in pixels per inch (DPI)

toPixels

public int toPixels(double length)
Returns the number of pixels of the given length

Parameters:
length - the length using the current page resolutions
Returns:
the number of pixels that are used by length

getPageNumber

public int getPageNumber()
Returns the current page number

Returns:
the current page number

setPageNumber

public void setPageNumber(int number)
Sets the current page number. You normally don't need to call this function directly.

Parameters:
number - the new page number
See Also:
setGraphics(Graphics)

setGraphics

public void setGraphics(java.awt.Graphics graphics)
Sets the current sub Graphics object. Each direct or indirect call to this function increases the current page number.

Overrides:
setGraphics in class CopyGraphics
Parameters:
graphics - the new sub Graphics object