本文整理汇总了Java中org.eclipse.swt.printing.Printer.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java Printer.dispose方法的具体用法?Java Printer.dispose怎么用?Java Printer.dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.printing.Printer
的用法示例。
在下文中一共展示了Printer.dispose方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: print
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
void print( Shell shell){
PrintDialog printDialog = new PrintDialog(shell, SWT.NONE);
printDialog.setText("Print Http Packets");
PrinterData printerData = printDialog.open();
if (!(printerData == null)) {
final Printer printer = new Printer(printerData);
Thread printingThread = new Thread("Printing") {
public void run(){
try {
new PrinterFacade(getTextToPrint(), printer).print();
} catch (Exception e) {
ExceptionHandler.handle(e);
} finally {
printer.dispose();
}
}
};
printingThread.start();
}
}
示例3: onPrint
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
private void onPrint() {
PrintDialog printDialog = new PrintDialog(shell);
PrinterData printerData = printDialog.open();
if (printerData == null) {
return;
}
Printer printer = new Printer(printerData);
editText.print(printer).run();
printer.dispose();
}
示例4: print
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
public void print() {
JaretTablePrinter jtp = new JaretTablePrinter(null, _table);
JaretTablePrintDialog pDialog = new JaretTablePrintDialog(Display.getCurrent().getActiveShell(), null, jtp,
null);
pDialog.open();
if (pDialog.getReturnCode() == Dialog.OK) {
PrinterData pdata = pDialog.getPrinterData();
JaretTablePrintConfiguration conf = pDialog.getConfiguration();
Printer printer = new Printer(pdata);
jtp.setPrinter(printer);
jtp.print(conf);
printer.dispose();
}
jtp.dispose();
}
示例5: setupPrinter
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
private Printer setupPrinter(final Shell shell) {
Printer defaultPrinter = new Printer();
Point pageCount = getPageCount(defaultPrinter);
defaultPrinter.dispose();
final PrintDialog printDialog = new PrintDialog(shell);
printDialog.setStartPage(1);
printDialog.setEndPage(pageCount.x * pageCount.y);
printDialog.setScope(PrinterData.ALL_PAGES);
PrinterData printerData = printDialog.open();
if(printerData == null){
return null;
}
return new Printer(printerData);
}
示例6: printQuery
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
private void printQuery ( final AbstractQueryBuffer query )
{
final List<ValueInformation> vis = query.getValueInformation ();
final Map<String, List<Double>> values = query.getValues ();
final PrintDialog dlg = new PrintDialog ( getWorkbenchWindow ().getShell () );
final PrinterData printerData = dlg.open ();
if ( printerData == null )
{
return;
}
printerData.orientation = PrinterData.LANDSCAPE;
final Printer printer = new Printer ( printerData );
try
{
final PrintProcessor processor = new PrintProcessor ( vis, values );
processor.print ( printer );
}
finally
{
printer.dispose ();
}
}
示例7: updateConf
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
private void updateConf() {
_configuration.setRepeatHeader(_repeatHeader.getSelection());
Printer printer = new Printer(_printerData);
_tablePrinter.setPrinter(printer);
Point pages = _tablePrinter.calculatePageCount(_configuration);
printer.dispose();
_pagesLabel.setText(getPagesText(pages));
}
示例8: 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 ();
}
}
}
示例9: 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();
}
}
示例10: 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();
}
}
示例11: createParameterArea
import org.eclipse.swt.printing.Printer; //导入方法依赖的package包/类
protected void createParameterArea(Composite parent) {
GridLayout gl = new GridLayout();
gl.numColumns = 2;
parent.setLayout(gl);
_repeatHeader = new Button(parent, SWT.CHECK);
_repeatHeader.setSelection(_configuration.getRepeatHeader());
_repeatHeader.setText("Repeat header");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
_repeatHeader.setLayoutData(gd);
final Label scaleText = new Label(parent, SWT.RIGHT);
scaleText.setText(getScaleText());
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
scaleText.setLayoutData(gd);
final Scale scale = new Scale(parent, SWT.HORIZONTAL);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
scale.setLayoutData(gd);
scale.setMaximum(1000);
scale.setMinimum(10);
scale.setSelection((int) (_configuration.getScale() * 100));
scale.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent ev) {
int val = scale.getSelection();
double s = (double) val / 100.0;
_configuration.setScale(s);
scaleText.setText(getScaleText());
updateConf();
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
_pagesLabel = new Label(parent, SWT.RIGHT);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
_pagesLabel.setLayoutData(gd);
_printerData = _pdatas[_printerCombo.getSelectionIndex()];
Printer printer = new Printer(_printerData);
_tablePrinter.setPrinter(printer);
Point pages = _tablePrinter.calculatePageCount(_configuration);
printer.dispose();
_pagesLabel.setText(getPagesText(pages));
}