ewe.fx.print
Class PrintSurfaceObject

java.lang.Object
  extended byewe.fx.print.PrintSurfaceObject
All Implemented Interfaces:
PrintSurface

public abstract class PrintSurfaceObject
extends Object
implements PrintSurface


Field Summary
protected  boolean allocatePageRectScaling
          If this is set true, then you intend to call the getScaledImage() method on PageRect objects that you create during the putPageRect() method.
protected  PageFormat format
           
 
Fields inherited from interface ewe.fx.print.PrintSurface
HINT_DONT_RESIZE, HINT_DONT_RESIZE_HEIGHT, HINT_DONT_RESIZE_WIDTH, HINT_GRAYSCALE_IMAGE, HINT_MONO_IMAGE
 
Constructor Summary
protected PrintSurfaceObject(PageFormat format)
           
 
Method Summary
 void cancelPageRect(PageRect r)
          This frees the resources of the PageRect without sending it to the output device.
protected abstract  Image getImageBuffer(int width, int height)
           
 Dimension getOutputSize(double width, double height, Dimension dest)
          Return the size in pixels on the output device, given a width and height on this PrintSurface.
 double getOutputXDPI()
          By default this will return the xDPI value of the PageFormat supplied to the PrintSurfaceObject.
 double getOutputYDPI()
          By default this will return the yDPI value of the PageFormat supplied to the PrintSurfaceObject.
 PageRect getPageRect(double x, double y, double width, double height, double xdpi, double ydpi, int hints)
          Call this whithin the print() method of the Printable object to get a PageRect for a section of the current page.
static int getWidthHeight(double value, double dpi)
           
 void movePageRect(PageRect pr, double newX, double newY)
          Move the PageRect to a new location relative to the top left corner of the page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 
Methods inherited from interface ewe.fx.print.PrintSurface
putPageRect
 

Field Detail

format

protected PageFormat format

allocatePageRectScaling

protected boolean allocatePageRectScaling
If this is set true, then you intend to call the getScaledImage() method on PageRect objects that you create during the putPageRect() method.

Constructor Detail

PrintSurfaceObject

protected PrintSurfaceObject(PageFormat format)
Method Detail

cancelPageRect

public void cancelPageRect(PageRect r)
Description copied from interface: PrintSurface
This frees the resources of the PageRect without sending it to the output device. You should not use it after this.

Specified by:
cancelPageRect in interface PrintSurface

getOutputXDPI

public double getOutputXDPI()
By default this will return the xDPI value of the PageFormat supplied to the PrintSurfaceObject.

Specified by:
getOutputXDPI in interface PrintSurface

getOutputYDPI

public double getOutputYDPI()
By default this will return the yDPI value of the PageFormat supplied to the PrintSurfaceObject.

Specified by:
getOutputYDPI in interface PrintSurface

getWidthHeight

public static int getWidthHeight(double value,
                                 double dpi)

getOutputSize

public Dimension getOutputSize(double width,
                               double height,
                               Dimension dest)
Return the size in pixels on the output device, given a width and height on this PrintSurface. This would depend on the output X and Y DPI, so if they are not known then this method will return null.


movePageRect

public void movePageRect(PageRect pr,
                         double newX,
                         double newY)
Move the PageRect to a new location relative to the top left corner of the page. This method will erase the image buffer.

Specified by:
movePageRect in interface PrintSurface
Parameters:
pr - the PageRect to move.
newX - the new x location in Points (1/72 of an inch) of the PageRect.
newY - the new y location in Points (1/72 of an inch) of the PageRect.

getPageRect

public PageRect getPageRect(double x,
                            double y,
                            double width,
                            double height,
                            double xdpi,
                            double ydpi,
                            int hints)
Call this whithin the print() method of the Printable object to get a PageRect for a section of the current page. You would then draw onto the Image buffer provided which would then be placed on the paper using putPageRect().

Note that this method may throw an IllegalArgumentException if the rect requested is too big. In which case you should request a smaller size rect or a lower DPI.

Specified by:
getPageRect in interface PrintSurface
Parameters:
x - The x location in Points (1/72 of an inch) of the PageRect, relative to the top left of the page.
y - The y location in Points (1/72 of an inch) of the PageRect, relative to the top left of the page.
width - The width in Points (1/72 of an inch) of the PageRect.
height - The height in Points (1/72 of an inch) of the PageRect.
hints - Hints indicating the kind of drawing that will be done. This should be any of the HINT_XXX values OR'ed together.
xdpi - The requested horizontal DPI of the PageRect. This will affect the number of pixels that are in the image horizontally.
ydpi - The requested horizontal DPI of the PageRect. This will affect the number of pixels that are in the image horizontally.
Returns:
a PageRect that you can draw on for later transfer to the printer, or null if a PageRect of the requested size and DPI could not be created and HINT_DONT_RESIZE was specified.

getImageBuffer

protected abstract Image getImageBuffer(int width,
                                        int height)