本文整理汇总了Java中org.eclipse.swt.printing.Printer.endJob方法的典型用法代码示例。如果您正苦于以下问题:Java Printer.endJob方法的具体用法?Java Printer.endJob怎么用?Java Printer.endJob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.printing.Printer
的用法示例。
在下文中一共展示了Printer.endJob方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startPrintJob
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
protected void startPrintJob(Composite elementToPrint,
PrinterData printerData) {
Printer printer = new Printer(printerData);
try {
printer.startJob(jobName);
GC gc = new GC(printer);
try {
Rectangle printArea = getPrintableArea(printer, BORDER);
printer.startPage();
printComposite(elementToPrint, gc, printArea);
printer.endPage();
} finally {
gc.dispose();
}
printer.endJob();
} finally {
printer.dispose();
}
}
示例2: printChart
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
private static void printChart( Chart chart, Printer printer ) throws ChartException
{
// create graphics context for printer
GC gc = new GC(printer);
PlatformConfig config = new PlatformConfig( );
config.setProperty( "STANDALONE", "true" ); //$NON-NLS-1$ //$NON-NLS-2$
IDeviceRenderer render = ChartEngine.instance( config ).getRenderer("dv.SWT"); //$NON-NLS-1$
render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gc);
// The input size is in points (1 inch = 72 points)
Bounds bo = BoundsImpl.create(0,0,300,300);
// builds and computes preferred sizes of various chart components
IGenerator generator = ChartEngine.instance().getGenerator();
GeneratedChartState state = generator.build(render.getDisplayServer(), chart, bo, null, null, null);
printer.startJob("BIRT Sample Chart");//$NON-NLS-1$
printer.startPage();
// set render properties
generator.render(render, state);
printer.endPage();
printer.endJob();
}
示例3: print
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
public void print ()
{
if ( Printer.getPrinterList ().length == 0 )
{
MessageDialog.openInformation ( this.shell, "No printer", "No installed printer could be found" );
return;
}
final PrintDialog dlg = new PrintDialog ( this.shell, SWT.APPLICATION_MODAL );
final PrinterData initialPd = Printer.getDefaultPrinterData ();
initialPd.orientation = PrinterData.LANDSCAPE;
dlg.setPrinterData ( initialPd );
final PrinterData pd = dlg.open ();
if ( pd != null )
{
final Printer printer = new Printer ( pd );
final ResourceManager rm = new DeviceResourceManager ( printer );
try
{
printer.startJob ( "Chart" );
printer.startPage ();
final GC gc = new GC ( printer );
try
{
final SWTGraphics g = new SWTGraphics ( gc, rm );
try
{
this.viewer.getChartRenderer ().paint ( g );
}
finally
{
g.dispose ();
}
}
finally
{
gc.dispose ();
}
printer.endPage ();
printer.endJob ();
}
finally
{
rm.dispose ();
printer.dispose ();
}
}
}
示例4: menuPrint
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
void menuPrint() {
if (image == null) {
return;
}
try {
// Ask the user to specify the printer.
PrintDialog dialog = new PrintDialog(getShell(), SWT.NULL);
PrinterData printerData = dialog.open();
if (printerData == null) {
return;
}
Printer printer = new Printer(printerData);
Point screenDPI = display.getDPI();
Point printerDPI = printer.getDPI();
int scaleFactor = printerDPI.x / screenDPI.x;
Rectangle trim = printer.computeTrim(0, 0, 0, 0);
if (printer.startJob(currentName)) {
if (printer.startPage()) {
GC gc = new GC(printer);
int transparentPixel = imageData.transparentPixel;
if ((transparentPixel != -1) && !transparent) {
imageData.transparentPixel = -1;
}
Image printerImage = new Image(printer, imageData);
gc.drawImage(printerImage, 0, 0, imageData.width, imageData.height, -trim.x, -trim.y, scaleFactor
* imageData.width, scaleFactor * imageData.height);
if ((transparentPixel != -1) && !transparent) {
imageData.transparentPixel = transparentPixel;
}
printerImage.dispose();
gc.dispose();
printer.endPage();
}
printer.endJob();
}
printer.dispose();
}
catch (SWTError e) {
MessageBox box = new MessageBox(getShell(), SWT.ICON_ERROR);
box.setMessage(ImageAnalyzer.bundle.getString("Printing_error") + e.getMessage());
box.open();
}
}
示例5: run
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void run()
{
// Get snapshot. Disposed at end of printing
final Image snapshot = media_pool.get(ImageConverter.convertToSWT(graph.getImage()));
if (snapshot == null)
{
Logger.getLogger(getClass().getName()).fine("Cannot obtain image");
return;
}
// Printer GUI
final PrintDialog dlg = new PrintDialog(shell);
PrinterData data = dlg.open();
if (data == null)
{
Logger.getLogger(getClass().getName()).fine("Cannot obtain printer");
snapshot.dispose();
return;
}
// At least on Linux, access to SWT Printer must be on UI thread.
// Printing in other thread can deadlock with UI thread.
final Printer printer = new Printer(data);
try
{
if (!printer.startJob("Data Browser"))
{
Logger.getLogger(getClass().getName()).fine("Cannot start print job");
return;
}
try
{ // Printer page info
final Rectangle area = printer.getClientArea();
final Rectangle trim = printer.computeTrim(0, 0, 0, 0);
final Point dpi = printer.getDPI();
// Compute layout
final Rectangle image_rect = snapshot.getBounds();
// Leave one inch on each border.
// (copied the computeTrim stuff from an SWT example.
// Really no clue...)
final int left_right = dpi.x + trim.x;
final int top_bottom = dpi.y + trim.y;
final int printed_width = area.width - 2*left_right;
// Try to scale height according to on-screen aspect ratio.
final int max_height = area.height - 2*top_bottom;
final int printed_height = Math.min(max_height,
image_rect.height * printed_width / image_rect.width);
// Print one page
printer.startPage();
final GC gc = new GC(printer);
gc.drawImage(snapshot, 0, 0, image_rect.width, image_rect.height,
left_right, top_bottom, printed_width, printed_height);
printer.endPage();
}
finally
{
printer.endJob();
}
}
finally
{
printer.dispose();
snapshot.dispose();
}
}