Package org.eclipse.draw2d
Class PrintOperation
java.lang.Object
org.eclipse.draw2d.PrintOperation
- Direct Known Subclasses:
- PrintFigureOperation
Implementation of draw2d's printing capabilities.
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a new PrintOperationCreates a new PrintOperation on Printer p
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidcleanup()Disposes the PrinterGraphics and GC objects associated with this PrintOperation.protected GraphicscreateGraphics(SWTGraphics g, Printer p) protected GraphicsReturns a new Graphics setup for the Printer associated with this PrintOperation.protected PrinterGraphicsDeprecated, for removal: This API element is subject to removal in a future version.Returns the printer.Returns a Rectangle that represents the region that can be printed to.protected voidThis method contains all operations performed to sourceFigure prior to being printed.protected abstract voidThis method is responsible for printing pages.protected voidThis method contains all operations performed to sourceFigure after being printed.voidSets the print job into motion.voidsetPrinter(Printer printer) Sets the printer.voidsetPrintMargin(Insets margin) Sets the page margin in pels (logical pixels) to the passed Insets.(72 pels == 1 inch)protected voidManipulates the PrinterGraphics to position it to paint in the desired region of the page.protected voidDeprecated, for removal: This API element is subject to removal in a future version.UsesetupGraphicsForPage(Graphics)instead.
- 
Constructor Details- 
PrintOperationpublic PrintOperation()Creates a new PrintOperation
- 
PrintOperationCreates a new PrintOperation on Printer p- Parameters:
- p- The printer to print on
 
 
- 
- 
Method Details- 
cleanupprotected void cleanup()Disposes the PrinterGraphics and GC objects associated with this PrintOperation.
- 
getFreshPrinterGraphicsDeprecated, for removal: This API element is subject to removal in a future version.UsegetFreshGraphics()instead. This method will be removed after the 2027-06 release.Returns a new PrinterGraphics setup for the Printer associated with this PrintOperation. This method will be removed after the 2027-06 release. Important: This method should not be called ifcreateGraphics(SWTGraphics, Printer)has been subclasses.- Returns:
- PrinterGraphics The new PrinterGraphics
 
- 
getFreshGraphicsReturns a new Graphics setup for the Printer associated with this PrintOperation.- Returns:
- Graphics The new Graphics
- Since:
- 3.20
 
- 
createGraphicsCreates a newPrinterGraphicswith Graphicsg, using Printerp. May be overridden by subclasses if a differentGraphicsobject is required.- Parameters:
- g- Graphics object to draw with
- p- Printer to print to
- Returns:
- A new PrinterGraphicsobject.
- Since:
- 3.20
 
- 
getPrinterReturns the printer.- Returns:
- Printer
 
- 
getPrintRegionReturns a Rectangle that represents the region that can be printed to. The x, y, height, and width values are using the printers coordinates.- Returns:
- the print region
 
- 
preparePrintSourceprotected void preparePrintSource()This method contains all operations performed to sourceFigure prior to being printed.
- 
printPagesprotected abstract void printPages()This method is responsible for printing pages. (A page is printed by calling Printer.startPage(), followed by painting to the PrinterGraphics object, and then calling Printer.endPage()).
- 
restorePrintSourceprotected void restorePrintSource()This method contains all operations performed to sourceFigure after being printed.
- 
runSets the print job into motion.- Parameters:
- jobName- A String representing the name of the print job
 
- 
setPrinterSets the printer.- Parameters:
- printer- The printer to set
 
- 
setPrintMarginSets the page margin in pels (logical pixels) to the passed Insets.(72 pels == 1 inch)- Parameters:
- margin- The margin to set on the page
 
- 
setupGraphicsForPage@Deprecated(forRemoval=true, since="2025-06") protected void setupGraphicsForPage(PrinterGraphics pg) Deprecated, for removal: This API element is subject to removal in a future version.UsesetupGraphicsForPage(Graphics)instead. This method will be removed after the 2027-06 release.Manipulates the PrinterGraphics to position it to paint in the desired region of the page. (Default is the top left corner of the page).- Parameters:
- pg- The PrinterGraphics to setup
 
- 
setupGraphicsForPageManipulates the PrinterGraphics to position it to paint in the desired region of the page. (Default is the top left corner of the page).- Parameters:
- g- The Graphics to setup
- Since:
- 3.20
 
 
- 
getFreshGraphics()instead.