当前位置: 首页>>代码示例>>Java>>正文


Java Printer.endJob方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:22,代码来源:ChartPrintJob.java

示例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();
}
 
开发者ID:eclipse,项目名称:birt,代码行数:29,代码来源:SwtChartPrinter.java

示例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 ();
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:54,代码来源:AbstractChartView.java

示例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();
	}
}
 
开发者ID:aroog,项目名称:code,代码行数:46,代码来源:ImageAnalyzer.java

示例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();
    }
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:70,代码来源:PrintAction.java


注:本文中的org.eclipse.swt.printing.Printer.endJob方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。