Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.swt.printing
Class Printer  view Printer download Printer.java

java.lang.Object
  extended byorg.eclipse.swt.graphics.Device
      extended byorg.eclipse.swt.printing.Printer
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public final class Printer
extends org.eclipse.swt.graphics.Device

Instances of this class are used to print to a printer. Applications create a GC on a printer using new GC(printer) and then draw on the printer GC using the usual graphics calls.

A Printer object may be constructed by providing a PrinterData object which identifies the printer. A PrintDialog presents a print dialog to the user and returns an initialized instance of PrinterData. Alternatively, calling new Printer() will construct a printer object for the user's default printer.

Application code must explicitly invoke the Printer.dispose() method to release the operating system resources managed by each instance when those instances are no longer required.


Field Summary
(package private)  PrinterData data
           
 
Fields inherited from class org.eclipse.swt.graphics.Device
CurrentDevice, DEBUG, DeviceFinder
 
Constructor Summary
Printer()
          Constructs a new printer representing the default printer.
Printer(PrinterData data)
          Constructs a new printer given a PrinterData object representing the desired printer.
 
Method Summary
 void cancelJob()
          Cancels a print job in progress.
 org.eclipse.swt.graphics.Rectangle computeTrim(int x, int y, int width, int height)
          Given a desired client area for the receiver (as described by the arguments), returns the bounding rectangle which would be required to produce that client area.
 void endJob()
          Ends the current print job.
 void endPage()
          Ends the current page.
 org.eclipse.swt.graphics.Rectangle getBounds()
          Returns a rectangle describing the receiver's size and location.
 org.eclipse.swt.graphics.Rectangle getClientArea()
          Returns a rectangle which describes the area of the receiver which is capable of displaying data.
static PrinterData getDefaultPrinterData()
          Returns a PrinterData object representing the default printer or null if there is no printer available on the System.
 org.eclipse.swt.graphics.Point getDPI()
          Returns a point whose x coordinate is the horizontal dots per inch of the printer, and whose y coordinate is the vertical dots per inch of the printer.
 PrinterData getPrinterData()
          Returns a PrinterData object representing the target printer for this print job.
static PrinterData[] getPrinterList()
          Returns an array of PrinterData objects representing all available printers.
 void internal_dispose_GC(long xGC, org.eclipse.swt.graphics.GCData data)
          Invokes platform specific functionality to dispose a GC handle.
 long internal_new_GC(org.eclipse.swt.graphics.GCData data)
          Invokes platform specific functionality to allocate a new GC handle.
 boolean startJob(java.lang.String jobName)
          Starts a print job and returns true if the job started successfully and false otherwise.
 boolean startPage()
          Starts a page and returns true if the page started successfully and false otherwise.
 
Methods inherited from class org.eclipse.swt.graphics.Device
checkDevice, create, destroy, dispose, getDepth, getDeviceData, getFontList, getSystemColor, getSystemFont, getWarnings, init, isDisposed, release, setWarnings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

PrinterData data
Constructor Detail

Printer

public Printer()
Constructs a new printer representing the default printer.

You must dispose the printer when it is no longer required.


Printer

public Printer(PrinterData data)
Constructs a new printer given a PrinterData object representing the desired printer.

You must dispose the printer when it is no longer required.

Method Detail

getPrinterList

public static PrinterData[] getPrinterList()
Returns an array of PrinterData objects representing all available printers.


getDefaultPrinterData

public static PrinterData getDefaultPrinterData()
Returns a PrinterData object representing the default printer or null if there is no printer available on the System.

Since:
2.1

internal_new_GC

public long internal_new_GC(org.eclipse.swt.graphics.GCData data)
Invokes platform specific functionality to allocate a new GC handle.

IMPORTANT: This method is not part of the public API for Printer. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.


internal_dispose_GC

public void internal_dispose_GC(long xGC,
                                org.eclipse.swt.graphics.GCData data)
Invokes platform specific functionality to dispose a GC handle.

IMPORTANT: This method is not part of the public API for Printer. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.


startJob

public boolean startJob(java.lang.String jobName)
Starts a print job and returns true if the job started successfully and false otherwise.

This must be the first method called to initiate a print job, followed by any number of startPage/endPage calls, followed by endJob. Calling startPage, endPage, or endJob before startJob will result in undefined behavior.


endJob

public void endJob()
Ends the current print job.


cancelJob

public void cancelJob()
Cancels a print job in progress.


startPage

public boolean startPage()
Starts a page and returns true if the page started successfully and false otherwise.

After calling startJob, this method may be called any number of times along with a matching endPage.


endPage

public void endPage()
Ends the current page.


getDPI

public org.eclipse.swt.graphics.Point getDPI()
Returns a point whose x coordinate is the horizontal dots per inch of the printer, and whose y coordinate is the vertical dots per inch of the printer.


getBounds

public org.eclipse.swt.graphics.Rectangle getBounds()
Returns a rectangle describing the receiver's size and location. For a printer, this is the size of a page, in pixels.


getClientArea

public org.eclipse.swt.graphics.Rectangle getClientArea()
Returns a rectangle which describes the area of the receiver which is capable of displaying data. For a printer, this is the size of the printable area of a page, in pixels.


computeTrim

public org.eclipse.swt.graphics.Rectangle computeTrim(int x,
                                                      int y,
                                                      int width,
                                                      int height)
Given a desired client area for the receiver (as described by the arguments), returns the bounding rectangle which would be required to produce that client area.

In other words, it returns a rectangle such that, if the receiver's bounds were set to that rectangle, the area of the receiver which is capable of displaying data (that is, not covered by the "trimmings") would be the rectangle described by the arguments (relative to the receiver's parent).

Note that there is no setBounds for a printer. This method is usually used by passing in the client area (the 'printable area') of the printer. It can also be useful to pass in 0, 0, 0, 0.


getPrinterData

public PrinterData getPrinterData()
Returns a PrinterData object representing the target printer for this print job.