本文整理汇总了Java中javax.print.attribute.standard.Destination类的典型用法代码示例。如果您正苦于以下问题:Java Destination类的具体用法?Java Destination怎么用?Java Destination使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Destination类属于javax.print.attribute.standard包,在下文中一共展示了Destination类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDefaultAttributeValue
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
public Object getDefaultAttributeValue(Class category) {
if (category.equals(JobName.class)) {
return new JobName("Java GDI client print job", Locale.US);
} else if (category.equals(RequestingUserName.class)) {
return new RequestingUserName(System.getProperty("user.name"),
Locale.US);
} else if (category.equals(Destination.class)) {
File file = new File(System.getProperty("user.dir") +
File.separator + "output.prn");
return new Destination(file.toURI());
} else if (category.equals(SheetCollate.class)) {
return SheetCollate.COLLATED;
} else if (category.equals(Copies.class)) {
return new Copies(1);
}
return null;
}
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:GDIClient.java
示例2: getDestination
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
String getDestination(PrintRequestAttributeSet attrs)
throws PrintException {
if (attrs != null) {
if (attrs.containsKey(Destination.class)) {
Destination destination =
(Destination)attrs.get(Destination.class);
if (!destination.getURI().getScheme().equals("file")) {
throw new PrintException(
"Only files supported as destinations.");
}
String file = destination.getURI().getPath();
if (file.startsWith("/")) {
file = file.substring(1);
}
return file;
}
}
return null;
}
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:GDIClient.java
示例3: getDefaultAttributeValueEx
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
private Object[] getDefaultAttributeValueEx(Class category) {
if (Destination.class.isAssignableFrom(category)) {
return new Object[0];
} else if (RequestingUserName.class.isAssignableFrom(category)) {
return new Object[] { new RequestingUserName(
(String) AccessController
.doPrivileged(new PrivilegedAction() {
public Object run() {
return System.getProperty("user.name");
}
}), Locale.US) };
} else if (JobName.class.isAssignableFrom(category)) {
return new Object[] { new JobName("Java print job", Locale.US) };
} else if (DocumentName.class.isAssignableFrom(category)) {
return new Object[] { new DocumentName("Java print document",
Locale.US) };
}
return null;
}
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:CUPSClient.java
示例4: getSupportedAttributeValuesEx
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
private Object[] getSupportedAttributeValuesEx(Class category,
DocFlavor flavor) {
if (Destination.class.isAssignableFrom(category)) {
String ms = flavor.getMediaSubtype();
if (ms.equalsIgnoreCase("gif") || ms.equalsIgnoreCase("jpeg")
|| ms.equalsIgnoreCase("png")
|| ms.equalsIgnoreCase("postscript")
|| flavor.getClass() == DocFlavor.SERVICE_FORMATTED.class) {
try {
return new Object[] { new Destination(new URI(
"file:///foo/bar")) };
} catch (URISyntaxException e) {
// return empty array - values are not supported
return new Object[0];
}
}
} else if (RequestingUserName.class.isAssignableFrom(category)) {
return new Object[] { new RequestingUserName("I.A.Muser", Locale.US) };
} else if (JobName.class.isAssignableFrom(category)) {
return new Object[] { new JobName("Foo print job", Locale.US) };
} else if (DocumentName.class.isAssignableFrom(category)) {
return new Object[] { new DocumentName("Foo document", Locale.US) };
}
return null;
}
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:CUPSClient.java
示例5: main
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
PrinterJob printerJob = PrinterJob.getPrinterJob();
printerJob.setPrintable((graphics, pageFormat, pageIndex) -> {
if (pageIndex != 0) {
return Printable.NO_SUCH_PAGE;
} else {
Shape shape = new Rectangle(110, 110, 10, 10);
Rectangle rect = shape.getBounds();
BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
.getDefaultConfiguration().createCompatibleImage(rect.width, rect.height, Transparency.BITMASK);
graphics.drawImage(image, rect.x, rect.y, rect.width, rect.height, null);
return Printable.PAGE_EXISTS;
}
});
File file = null;
try {
HashPrintRequestAttributeSet hashPrintRequestAttributeSet = new HashPrintRequestAttributeSet();
file = File.createTempFile("out", "ps");
file.deleteOnExit();
Destination destination = new Destination(file.toURI());
hashPrintRequestAttributeSet.add(destination);
printerJob.print(hashPrintRequestAttributeSet);
} finally {
if (file != null) {
file.delete();
}
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:32,代码来源:PrintCrashTest.java
示例6: main
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
/**
* Starts the application.
*/
public static void main(java.lang.String[] args) {
PrintDlgApp pd = new PrintDlgApp();
PrinterJob pj = PrinterJob.getPrinterJob();
System.out.println(pj);
PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet();
pSet.add(new Copies(1));
//PageFormat pf = pj.pageDialog(pSet);
PageFormat pf = new PageFormat();
System.out.println("Setting Printable...pf = "+pf);
if (pf == null) {
return;
}
pj.setPrintable(pd,pf);
//try { pj.setPrintService(services[0]); } catch(Exception e) { e.printStackTrace(); }
pSet.add(new Destination(new java.io.File("./out.prn").toURI()));
System.out.println("open PrintDialog..");
for (int i=0; i<2; i++) {
if (pj.printDialog(pSet)) {
try {
System.out.println("About to print the data ...");
pj.print(pSet);
System.out.println("Printed");
}
catch (PrinterException pe) {
pe.printStackTrace();
}
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:PrintDlgApp.java
示例7: printTest
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
private static void printTest() {
PrintService defService = null, service[] = null;
HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
service = PrintServiceLookup.lookupPrintServices(flavor, null);
defService = PrintServiceLookup.lookupDefaultPrintService();
if ((service == null) || (service.length == 0)) {
throw new RuntimeException("No Printer services found");
}
File f = new File("output.ps");
Destination d = new Destination(f.toURI());
prSet.add(d);
if (defService != null) {
System.out.println("isAttrCategory Supported? " +
defService.isAttributeCategorySupported(Destination.class));
System.out.println("isAttrValue Supported? " +
defService.isAttributeValueSupported(d, flavor, null));
}
defService = ServiceUI.printDialog(null, 100, 100, service, defService,
flavor, prSet);
ServiceUI.printDialog(null, 100, 100, service, defService,
DocFlavor.SERVICE_FORMATTED.PAGEABLE,
new HashPrintRequestAttributeSet());
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:ServiceDialogValidateTest.java
示例8: displayNativeDialog
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
private boolean displayNativeDialog() {
// "attributes" is required for getting the updated attributes
if (attributes == null) {
return false;
}
DialogOwner dlgOwner = (DialogOwner)attributes.get(DialogOwner.class);
Frame ownerFrame = (dlgOwner != null) ? dlgOwner.getOwner() : null;
WPrintDialog dialog = new WPrintDialog(ownerFrame, this);
dialog.setRetVal(false);
dialog.setVisible(true);
boolean prv = dialog.getRetVal();
dialog.dispose();
Destination dest =
(Destination)attributes.get(Destination.class);
if ((dest == null) || !prv){
return prv;
} else {
String title = null;
String strBundle = "sun.print.resources.serviceui";
ResourceBundle rb = ResourceBundle.getBundle(strBundle);
try {
title = rb.getString("dialog.printtofile");
} catch (MissingResourceException e) {
}
FileDialog fileDialog = new FileDialog(ownerFrame, title,
FileDialog.SAVE);
URI destURI = dest.getURI();
// Old code destURI.getPath() would return null for "file:out.prn"
// so we use getSchemeSpecificPart instead.
String pathName = (destURI != null) ?
destURI.getSchemeSpecificPart() : null;
if (pathName != null) {
File file = new File(pathName);
fileDialog.setFile(file.getName());
File parent = file.getParentFile();
if (parent != null) {
fileDialog.setDirectory(parent.getPath());
}
} else {
fileDialog.setFile("out.prn");
}
fileDialog.setVisible(true);
String fileName = fileDialog.getFile();
if (fileName == null) {
fileDialog.dispose();
return false;
}
String fullName = fileDialog.getDirectory() + fileName;
File f = new File(fullName);
File pFile = f.getParentFile();
while ((f.exists() &&
(!f.isFile() || !f.canWrite())) ||
((pFile != null) &&
(!pFile.exists() || (pFile.exists() && !pFile.canWrite())))) {
(new PrintToFileErrorDialog(ownerFrame,
ServiceDialog.getMsg("dialog.owtitle"),
ServiceDialog.getMsg("dialog.writeerror")+" "+fullName,
ServiceDialog.getMsg("button.ok"))).setVisible(true);
fileDialog.setVisible(true);
fileName = fileDialog.getFile();
if (fileName == null) {
fileDialog.dispose();
return false;
}
fullName = fileDialog.getDirectory() + fileName;
f = new File(fullName);
pFile = f.getParentFile();
}
fileDialog.dispose();
attributes.add(new Destination(f.toURI()));
return true;
}
}
开发者ID:campolake,项目名称:openjdk9,代码行数:82,代码来源:WPrinterJob.java
示例9: updateForSelectedService
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
/**
* Called to update for new selected
* print service. Tests if currently
* selected attributes are supported.
*/
void updateForSelectedService()
{
PrinterMakeAndModel att1 =
getSelectedPrintService().getAttribute(PrinterMakeAndModel.class);
typValue.setText(att1 == null ? "" : att1.getValue());
PrinterInfo att2 =
getSelectedPrintService().getAttribute(PrinterInfo.class);
infoValue.setText(att2 == null ? "" : att2.getValue());
PrinterIsAcceptingJobs att3 =
getSelectedPrintService().getAttribute(PrinterIsAcceptingJobs.class);
PrinterState att4 =
getSelectedPrintService().getAttribute(PrinterState.class);
String status = att4.toString();
if (att3 == PrinterIsAcceptingJobs.ACCEPTING_JOBS)
status += " - " + getLocalizedString("lb.acceptingjobs");
else if (att3 == PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS)
status += " - " + getLocalizedString("lb.notacceptingjobs");
statusValue.setText(status);
if (categorySupported(Destination.class))
{
fileRedirection_cb.setEnabled(false);
}
}
开发者ID:vilie,项目名称:javify,代码行数:34,代码来源:PrinterDialog.java
示例10: updateForSelectedService
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
/**
* Called to update for new selected
* print service. Tests if currently
* selected attributes are supported.
*/
void updateForSelectedService()
{
PrinterMakeAndModel att1 =
getSelectedPrintService().getAttribute(PrinterMakeAndModel.class);
typValue.setText(att1 == null ? "" : att1.getValue());
PrinterInfo att2 =
getSelectedPrintService().getAttribute(PrinterInfo.class);
infoValue.setText(att2 == null ? "" : att2.getValue());
PrinterIsAcceptingJobs att3 =
getSelectedPrintService().getAttribute(PrinterIsAcceptingJobs.class);
PrinterState att4 =
getSelectedPrintService().getAttribute(PrinterState.class);
String status = att4.toString();
if (att3 == PrinterIsAcceptingJobs.ACCEPTING_JOBS)
status += " - " + getLocalizedString("lb.acceptingjobs");
else if (att3 == PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS)
status += " - " + getLocalizedString("lb.notacceptingjobs");
statusValue.setText(status);
if (categorySupported(Destination.class))
{
fileRedirection_cb.setEnabled(false);
}
}
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:34,代码来源:PrinterDialog.java
示例11: _printPDF
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
/** If a PDF printer is available print to it.
* @exception PrinterException If a printer with the string "PDF"
* cannot be found or if the job cannot be set to the PDF print
* service or if there is another problem printing.
*/
protected void _printPDF() throws PrinterException {
// Find something that will print to PDF
boolean foundPDFPrinter = false;
PrintService pdfPrintService = null;
PrintService printServices[] = PrinterJob.lookupPrintServices();
for (int i = 0; i < printServices.length; i++) {
if (printServices[i].getName().indexOf("PDF") != -1) {
foundPDFPrinter = true;
pdfPrintService = printServices[i];
}
}
if (pdfPrintService == null) {
throw new PrinterException("Could not find a printer with the "
+ "string \"PDF\" in its name.");
}
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintService(pdfPrintService);
job.setPrintable(plot, job.defaultPage());
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
// This gets ignored, but let's try it anyway
Destination destination = new Destination(new File("plot.pdf").toURI());
aset.add(destination);
job.print(aset);
if (foundPDFPrinter) {
System.out
.println("Plot printed from command line. "
+ "Under MacOSX, look for "
+ "~/Desktop/Java Printing.pdf");
}
}
开发者ID:cmm863,项目名称:HearthAttack,代码行数:41,代码来源:PlotFrame.java
示例12: getDefaultAttributeValue
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
public Object getDefaultAttributeValue(
final Class<? extends Attribute> category) {
checkArgs(category, null);
final DevmodeStructWrapper dm = getDefaultPrinterProps();
if (JobName.class.equals(category)) {
return DEFAULT_JOB_NAME;
} else if (RequestingUserName.class.equals(category)) {
return new RequestingUserName(getSystemProperty("user.name"), //$NON-NLS-1$
null);
} else if (Destination.class.equals(category)) {
File file = new File(getSystemProperty("user.dir") //$NON-NLS-1$
+ File.separator + "output.prn"); //$NON-NLS-1$
return new Destination(file.toURI());
} else if (OrientationRequested.class.equals(category)) {
return dm.getOrientation();
} else if (Paper.class.equals(category)) {
return getDefaultPaper();
} else if (Media.class.equals(category)) {
return getDefaultPaper().getSize().getMediaSizeName();
} else if (MediaSize.class.equals(category)) {
return getDefaultPaper().getSize();
} else if (PrintQuality.class.equals(category)) {
return dm.getPrintQuality();
} else if (Sides.class.equals(category)) {
return dm.getSides();
} else if (Copies.class.equals(category)) {
return dm.getCopies();
} else if (SheetCollate.class.equals(category)) {
return dm.getCollate();
} else if (PrinterResolution.class.equals(category)) {
return dm.getPrinterResolution();
} else if (Chromaticity.class.equals(category)) {
return dm.getChromaticity();
}
return null;
}
开发者ID:shannah,项目名称:cn1,代码行数:40,代码来源:WinPrintService.java
示例13: getDestinationPath
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
private String getDestinationPath(final PrintRequestAttributeSet attrs)
throws PrintException {
if (attrs != null) {
final Destination dest = (Destination) attrs
.get(Destination.class);
return dest != null ? new File(dest.getURI()).getAbsolutePath()
: null;
}
return null;
}
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:WinPrintJob.java
示例14: getSupportedAttributeCategories
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
public Class[] getSupportedAttributeCategories() {
ArrayList supportedCategories = new ArrayList();
if (getCopiesSupported(serviceName) >= 1) {
supportedCategories.add(Copies.class);
}
if (getSidesSupported(serviceName)) {
supportedCategories.add(Sides.class);
}
if (getSupportedMediaSizeNames() != null) {
supportedCategories.add(Media.class);
}
if (getResolutionsSupported(serviceName) != null) {
supportedCategories.add(PrinterResolution.class);
}
if (getOrientationSupported(serviceName)) {
supportedCategories.add(OrientationRequested.class);
}
if (getCollateSupported(serviceName)) {
supportedCategories.add(SheetCollate.class);
}
supportedCategories.add(Chromaticity.class);
supportedCategories.add(JobName.class);
supportedCategories.add(RequestingUserName.class);
supportedCategories.add(Destination.class);
Class[] categories = new Class[supportedCategories.size()];
supportedCategories.toArray(categories);
return categories;
}
开发者ID:shannah,项目名称:cn1,代码行数:30,代码来源:GDIClient.java
示例15: filltoFileBox
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
void filltoFileBox() {
if (firstUse && attrs.containsKey(Destination.class)) {
toFileBox.setSelected(true);
}
toFileBox.setEnabled(checkFilePermission(destPermission)
&& myService.isAttributeCategorySupported(Destination.class));
}
开发者ID:shannah,项目名称:cn1,代码行数:8,代码来源:ServiceUIDialog.java
示例16: getSupportedAttributeCategoriesEx
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
private void getSupportedAttributeCategoriesEx(ArrayList clazz) {
if (!clazz.contains(Destination.class)) {
clazz.add(Destination.class);
}
if (!clazz.contains(RequestingUserName.class)) {
clazz.add(RequestingUserName.class);
}
if (!clazz.contains(JobName.class)) {
clazz.add(JobName.class);
}
if (!clazz.contains(DocumentName.class)) {
clazz.add(DocumentName.class);
}
}
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:CUPSClient.java
示例17: isAttributeValueSupportedEx
import javax.print.attribute.standard.Destination; //导入依赖的package包/类
private boolean[] isAttributeValueSupportedEx(Attribute avalue,
DocFlavor flavor) {
if (Destination.class.isAssignableFrom(avalue.getCategory())) {
String ms = (flavor != null ? flavor.getMediaSubtype() : "");
Class cls = (flavor != null ? flavor.getClass() : null);
if (ms.equalsIgnoreCase("gif") || ms.equalsIgnoreCase("jpeg")
|| ms.equalsIgnoreCase("png")
|| ms.equalsIgnoreCase("postscript") || flavor == null
|| cls == DocFlavor.SERVICE_FORMATTED.class) {
if (!canPrintToFile()) {
return new boolean[] { false };
}
URI uri = ((Destination) avalue).getURI();
try {
File file = new File(uri);
if (file.isFile()) {
if (file.canWrite()) {
return new boolean[] { true };
}
return new boolean[] { false };
}
String path = file.getParent();
File parent = new File(path);
if (parent.isDirectory()) {
if (parent.canWrite()) {
return new boolean[] { true };
}
return new boolean[] { false };
}
} catch (Exception e) {
return new boolean[] { false };
}
}
}
return null;
}
开发者ID:shannah,项目名称:cn1,代码行数:41,代码来源:CUPSClient.java
注:本文中的javax.print.attribute.standard.Destination类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论