本文整理汇总了Java中org.eclipse.swt.printing.Printer类的典型用法代码示例。如果您正苦于以下问题:Java Printer类的具体用法?Java Printer怎么用?Java Printer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Printer类属于org.eclipse.swt.printing包,在下文中一共展示了Printer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: print
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
/**
* Print the file listing for this disk.
*/
protected void print() {
PrintDialog printDialog = new PrintDialog(shell);
PrinterData printerData = printDialog.open();
if (printerData == null) {
// cancelled
return;
}
final Printer printer = new Printer(printerData);
new Thread() {
public void run() {
new Printing(printer).run();
printer.dispose();
}
}.start();
}
示例2: print
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
public void print() {
final Printer printer = SwtUtil.showPrintDialog(styledText);
if (printer == null) return; // Print was cancelled
StyledTextPrintOptions options = new StyledTextPrintOptions();
options.jobName = printJobName;
options.printLineBackground = true;
options.printTextBackground = true;
options.printTextFontStyle = true;
options.printTextForeground = true;
options.footer = "\t<page>"; //$NON-NLS-1$ (for StyledText widget!)
options.header = "\t" + printJobName; //$NON-NLS-1$
final Runnable runnable = styledText.print(printer, options);
new Thread(new Runnable() {
public void run() {
runnable.run();
printer.dispose();
}
}).start();
}
示例3: print
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
public void print() {
final Printer printer = SwtUtil.showPrintDialog(imageCanvas);
if (printer == null) return; // Print was cancelled
new Thread(new Runnable() {
public void run() {
printer.startJob(getPrintJobName());
printer.startPage();
Point dpi = printer.getDPI();
Image image = getImageCanvas().getImage();
int imageWidth = image.getImageData().width;
int imageHeight = image.getImageData().height;
int printedWidth = imageWidth * (dpi.x / 96);
int printedHeight = imageHeight * (dpi.y / 96);
GC gc = new GC(printer);
gc.drawImage(image,
0, 0, imageWidth, imageHeight,
0, 0, printedWidth, printedHeight);
printer.endPage();
printer.endJob();
gc.dispose();
printer.dispose();
}
}).start();
}
示例4: showPrintDialog
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
/**
* Display the Print dialog helper method.
*/
public static Printer showPrintDialog(Control control) {
PrintDialog dialog = new PrintDialog(control.getShell());
PrinterData printerData = dialog.open();
if (printerData == null) return null;
return new Printer(printerData);
}
示例5: 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();
}
}
示例6: getPrintableArea
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
/**
* @param printer
* @param safetyBorder
* @return the rectangle in pixels to print on (and which is also supported
* by the printer hardware)
*/
private Rectangle getPrintableArea(Printer printer, double safetyBorder) {
int safetyBorderWidth = (int) (safetyBorder * printer.getDPI().x);
int safetyBorderHeight = (int) (safetyBorder * printer.getDPI().y);
Rectangle trim = printer.computeTrim(0, 0, 0, 0);
int trimLeft = -trim.x;
int trimTop = -trim.y;
int trimRight = trim.x + trim.width;
int trimBottom = trim.y + trim.height;
int marginLeft = Math.max(trimLeft, safetyBorderWidth);
int marginRight = Math.max(trimRight, safetyBorderWidth);
int marginTop = Math.max(trimTop, safetyBorderHeight);
int marginBottom = Math.max(trimBottom, safetyBorderHeight);
int availWidth = printer.getClientArea().width - marginLeft
- marginRight;
int availHeight = printer.getClientArea().height - marginTop
- marginBottom;
return new Rectangle(marginLeft, marginTop, availWidth, availHeight);
}
示例7: 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();
}
}
示例8: processAction
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
protected void processAction(TGActionContext context){
PrintStyles styles = context.getAttribute(ATTRIBUTE_STYLES);
if( styles == null ) {
this.configureStyles(context);
return;
}
PrinterData printerData = context.getAttribute(ATTRIBUTE_DATA);
if( printerData == null ) {
this.configurePrinterData(context);
return;
}
TGSongManager manager = new TGSongManager(new TGFactoryImpl());
TGSong sourceSong = context.getAttribute(TGDocumentContextAttributes.ATTRIBUTE_SONG);
TGSong targetSong = sourceSong.clone(manager.getFactory());
Printer printer = new Printer(printerData);
PrintController controller = new PrintController(targetSong, manager, new TGResourceFactoryImpl(printer));
PrintLayout printLayout = new PrintLayout(controller, styles);
printLayout.loadStyles(getPrinterScale(printer), 1f);
printLayout.updateSong();
printLayout.makeDocument(new PrintDocumentImpl(printLayout, printer, printerData, getPrinterArea(printer, 0.5f)));
printLayout.getResourceBuffer().disposeAllResources();
}
示例9: run
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void run() {
GraphicalViewer viewer;
viewer = getWorkbenchPart().getAdapter(GraphicalViewer.class);
final PrintDialog dialog = new PrintDialog(viewer.getControl().getShell(), SWT.NULL);
final PrinterData data = dialog.open();
if (data != null) {
final Printer printer = new Printer(data);
final PrintGraphicalViewerOperation op = new PrintERDiagramOperation(printer, viewer);
op.run(getWorkbenchPart().getTitle());
}
}
示例10: 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();
}
示例11: RiskRenderer
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
public RiskRenderer(Printer printer) {
super(printer);
if (printer != null) {
_yellow = printer.getSystemColor(SWT.COLOR_YELLOW);
_green = printer.getSystemColor(SWT.COLOR_GREEN);
_red = printer.getSystemColor(SWT.COLOR_RED);
_black = printer.getSystemColor(SWT.COLOR_BLACK);
_redInactive = new Color(printer, INACTIVE_RED);
_yellowInactive = new Color(printer, INACTIVE_YELLOW);
_greenInactive = new Color(printer, INACTIVE_GREEN);
}
Color[][] inactiveColors = { { _yellowInactive, _redInactive, _redInactive },
{ _greenInactive, _yellowInactive, _redInactive }, { _greenInactive, _greenInactive, _yellowInactive } };
_inactiveColors = inactiveColors;
Color[][] colors = { { _yellow, _red, _red }, { _green, _yellow, _red }, { _green, _green, _yellow } };
_colors = colors;
}
示例12: printJobFile
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
private void printJobFile(JobMeta jobMeta) {
JobGraph jobGraph = getActiveJobGraph();
if (jobGraph == null)
return;
PrintSpool ps = new PrintSpool();
Printer printer = ps.getPrinter(shell);
// Create an image of the screen
Point max = jobMeta.getMaximum();
Image img = jobGraph.getJobImage(printer, max.x, max.y, 1.0f);
ps.printImage(shell, img);
img.dispose();
ps.dispose();
}
示例13: 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);
}
示例14: printTransFile
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
private void printTransFile(TransMeta transMeta) {
TransGraph transGraph = getActiveTransGraph();
if (transGraph == null)
return;
PrintSpool ps = new PrintSpool();
Printer printer = ps.getPrinter(shell);
// Create an image of the screen
Point max = transMeta.getMaximum();
Image img = transGraph.getTransformationImage(printer, max.x, max.y, 1.0f);
ps.printImage(shell, img);
img.dispose();
ps.dispose();
}
示例15: run
import org.eclipse.swt.printing.Printer; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void run() {
GraphicalViewer viewer;
viewer = (GraphicalViewer) getWorkbenchPart().getAdapter(
GraphicalViewer.class);
PrintDialog dialog = new PrintDialog(viewer.getControl().getShell(),
SWT.NULL);
PrinterData data = dialog.open();
if (data != null) {
Printer printer = new Printer(data);
PrintGraphicalViewerOperation op = new PrintERDiagramOperation(
printer, viewer);
op.run(getWorkbenchPart().getTitle());
}
}