本文整理匯總了Java中javax.print.attribute.PrintRequestAttributeSet.get方法的典型用法代碼示例。如果您正苦於以下問題:Java PrintRequestAttributeSet.get方法的具體用法?Java PrintRequestAttributeSet.get怎麽用?Java PrintRequestAttributeSet.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.print.attribute.PrintRequestAttributeSet
的用法示例。
在下文中一共展示了PrintRequestAttributeSet.get方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setAttributes
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
super.setAttributes(attributes);
if (attributes == null) {
return;
}
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
if (isSupportedValue(pageRangesAttr, attributes)) {
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
// If rangeSelect is not null, we are using AWT's print dialog that has
// All, Selection, and Range radio buttons
if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
int[][] range = pageRangesAttr.getMembers();
// setPageRange will set firstPage and lastPage as called in getFirstPage
// and getLastPage
setPageRange(range[0][0] - 1, range[0][1] - 1);
}
}
}
示例2: setAttributes
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
@Override
protected void setAttributes(PrintRequestAttributeSet attributes)
throws PrinterException {
super.setAttributes(attributes);
if (attributes == null) {
return; // now always use attributes, so this shouldn't happen.
}
Attribute attr = attributes.get(Media.class);
if (attr instanceof CustomMediaTray) {
CustomMediaTray customTray = (CustomMediaTray)attr;
String choice = customTray.getChoiceName();
if (choice != null) {
mOptions = " InputSlot="+ choice;
}
}
}
示例3: setAttributes
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
super.setAttributes(attributes);
if (attributes == null) {
return;
}
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
if (isSupportedValue(pageRangesAttr, attributes)) {
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
// If rangeSelect is not null, we are using AWT's print dialog that has
// All, Selection, and Range radio buttons
if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
int[][] range = pageRangesAttr.getMembers();
// setPageRange will set firstPage and lastPage as called in getFirstPage
// and getLastPage
setPageRange(range[0][0] - 1, range[0][1] - 1);
} else {
// if rangeSelect is SunPageSelection.ALL
// then setPageRange appropriately
setPageRange(-1, -1);
}
}
}
示例4: printToMiddleTray
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
@Test
public void printToMiddleTray() throws Exception {
PrinterEndpoint endpoint = new PrinterEndpoint();
PrinterConfiguration configuration = new PrinterConfiguration();
configuration.setHostname("localhost");
configuration.setPort(631);
configuration.setPrintername("DefaultPrinter");
configuration.setMediaSizeName(MediaSizeName.ISO_A4);
configuration.setInternalSides(Sides.ONE_SIDED);
configuration.setInternalOrientation(OrientationRequested.PORTRAIT);
configuration.setMediaTray("middle");
PrinterProducer producer = new PrinterProducer(endpoint, configuration);
producer.start();
PrinterOperations printerOperations = producer.getPrinterOperations();
PrintRequestAttributeSet attributeSet = printerOperations.getPrintRequestAttributeSet();
Attribute attribute = attributeSet.get(javax.print.attribute.standard.Media.class);
assertNotNull(attribute);
assertTrue(attribute instanceof MediaTray);
MediaTray mediaTray = (MediaTray) attribute;
assertEquals("middle", mediaTray.toString());
}
示例5: printsWithLandscapeOrientation
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
@Test
public void printsWithLandscapeOrientation() throws Exception {
PrinterEndpoint endpoint = new PrinterEndpoint();
PrinterConfiguration configuration = new PrinterConfiguration();
configuration.setHostname("localhost");
configuration.setPort(631);
configuration.setPrintername("DefaultPrinter");
configuration.setMediaSizeName(MediaSizeName.ISO_A4);
configuration.setInternalSides(Sides.ONE_SIDED);
configuration.setInternalOrientation(OrientationRequested.REVERSE_LANDSCAPE);
configuration.setMediaTray("middle");
configuration.setSendToPrinter(false);
PrinterProducer producer = new PrinterProducer(endpoint, configuration);
producer.start();
PrinterOperations printerOperations = producer.getPrinterOperations();
PrintRequestAttributeSet attributeSet = printerOperations.getPrintRequestAttributeSet();
Attribute attribute = attributeSet.get(OrientationRequested.class);
assertNotNull(attribute);
assertEquals("reverse-landscape", attribute.toString());
}
示例6: setAttributes
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
super.setAttributes(attributes);
if (attributes == null) {
return;
}
// See if this has an NSPrintInfo in it.
NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class);
if (nsPrintInfo != null) {
fNSPrintInfo = nsPrintInfo.getValue();
}
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
if (isSupportedValue(pageRangesAttr, attributes)) {
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
// If rangeSelect is not null, we are using AWT's print dialog that has
// All, Selection, and Range radio buttons
if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
int[][] range = pageRangesAttr.getMembers();
// setPageRange will set firstPage and lastPage as called in getFirstPage
// and getLastPage
setPageRange(range[0][0] - 1, range[0][1] - 1);
}
}
}
示例7: setParentWindowID
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
private void setParentWindowID(PrintRequestAttributeSet attrs) {
parentWindowID = 0L;
onTop = (DialogOnTop)attrs.get(DialogOnTop.class);
if (onTop != null) {
parentWindowID = onTop.getID();
}
}
示例8: print
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
@Override
public void print(Doc doc,
PrintRequestAttributeSet printRequestAttributeSet)
throws PrintException {
System.out.println("job name: " + printRequestAttributeSet.get(JobName.class));
System.out.println("copies: " + printRequestAttributeSet.get(Copies.class));
if(printRequestAttributeSet.get(JobName.class) == null ||
printRequestAttributeSet.get(Copies.class) == null) {
throw new RuntimeException("Copies and JobName is not passed correctly");
}
}
示例9: setAttributes
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
super.setAttributes(attributes);
if (attributes == null) {
return;
}
// See if this has an NSPrintInfo in it.
NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class);
if (nsPrintInfo != null) {
fNSPrintInfo = nsPrintInfo.getValue();
}
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
if (isSupportedValue(pageRangesAttr, attributes)) {
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
// If rangeSelect is not null, we are using AWT's print dialog that has
// All, Selection, and Range radio buttons
if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
int[][] range = pageRangesAttr.getMembers();
// setPageRange will set firstPage and lastPage as called in getFirstPage
// and getLastPage
setPageRange(range[0][0] - 1, range[0][1] - 1);
} else {
// if rangeSelect is SunPageSelection.ALL
// then setPageRange appropriately
setPageRange(-1, -1);
}
}
}
示例10: setAttributes
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
/**
* copy the attributes to the native print job
* Note that this method, and hence the re-initialisation
* of the GDI values is done on each entry to the print dialog since
* an app could redisplay the print dialog for the same job and
* 1) the application may have changed attribute settings
* 2) the application may have changed the printer.
* In the event that the user changes the printer using the
dialog, then it is up to GDI to report back all changed values.
*/
@Override
protected void setAttributes(PrintRequestAttributeSet attributes)
throws PrinterException {
// initialize attribute values
initAttributeMembers();
super.setAttributes(attributes);
mAttCopies = getCopiesInt();
mDestination = destinationAttr;
if (attributes == null) {
return; // now always use attributes, so this shouldn't happen.
}
Attribute[] attrs = attributes.toArray();
for (int i=0; i< attrs.length; i++) {
Attribute attr = attrs[i];
try {
if (attr.getCategory() == Sides.class) {
setSidesAttrib(attr);
}
else if (attr.getCategory() == Chromaticity.class) {
setColorAttrib(attr);
}
else if (attr.getCategory() == PrinterResolution.class) {
setResolutionAttrib(attr);
}
else if (attr.getCategory() == PrintQuality.class) {
setQualityAttrib(attr);
}
else if (attr.getCategory() == SheetCollate.class) {
setCollateAttrib(attr);
} else if (attr.getCategory() == Media.class ||
attr.getCategory() == SunAlternateMedia.class) {
/* SunAlternateMedia is used if its a tray, and
* any Media that is specified is not a tray.
*/
if (attr.getCategory() == SunAlternateMedia.class) {
Media media = (Media)attributes.get(Media.class);
if (media == null ||
!(media instanceof MediaTray)) {
attr = ((SunAlternateMedia)attr).getMedia();
}
}
if (attr instanceof MediaSizeName) {
setWin32MediaAttrib(attr);
}
if (attr instanceof MediaTray) {
setMediaTrayAttrib(attr);
}
}
} catch (ClassCastException e) {
}
}
}
示例11: setAttributes
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
/**
* copy the attributes to the native print job
* Note that this method, and hence the re-initialisation
* of the GDI values is done on each entry to the print dialog since
* an app could redisplay the print dialog for the same job and
* 1) the application may have changed attribute settings
* 2) the application may have changed the printer.
* In the event that the user changes the printer using the
dialog, then it is up to GDI to report back all changed values.
*/
@Override
protected void setAttributes(PrintRequestAttributeSet attributes)
throws PrinterException {
// initialize attribute values
initAttributeMembers();
super.setAttributes(attributes);
mAttCopies = getCopiesInt();
mDestination = destinationAttr;
if (attributes == null) {
return; // now always use attributes, so this shouldn't happen.
}
Attribute[] attrs = attributes.toArray();
for (int i=0; i< attrs.length; i++) {
Attribute attr = attrs[i];
try {
if (attr.getCategory() == Sides.class) {
setSidesAttrib(attr);
}
else if (attr.getCategory() == Chromaticity.class) {
setColorAttrib(attr);
}
else if (attr.getCategory() == PrinterResolution.class) {
if (myService.isAttributeValueSupported(attr, null, null)) {
setResolutionAttrib(attr);
}
}
else if (attr.getCategory() == PrintQuality.class) {
setQualityAttrib(attr);
}
else if (attr.getCategory() == SheetCollate.class) {
setCollateAttrib(attr);
} else if (attr.getCategory() == Media.class ||
attr.getCategory() == SunAlternateMedia.class) {
/* SunAlternateMedia is used if its a tray, and
* any Media that is specified is not a tray.
*/
if (attr.getCategory() == SunAlternateMedia.class) {
Media media = (Media)attributes.get(Media.class);
if (media == null ||
!(media instanceof MediaTray)) {
attr = ((SunAlternateMedia)attr).getMedia();
}
}
if (attr instanceof MediaSizeName) {
setWin32MediaAttrib(attr);
}
if (attr instanceof MediaTray) {
setMediaTrayAttrib(attr);
}
}
} catch (ClassCastException e) {
}
}
}
示例12: pageSetupMenuItem_ActionPerformed
import javax.print.attribute.PrintRequestAttributeSet; //導入方法依賴的package包/類
/**
* Comment
* @param actionEvent
*/
public void pageSetupMenuItem_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
// new Thread() {
// public void run()
// {
final GetPrintableInterface pi = (GetPrintableInterface)CommandManager.getInstance().getCommand("GetPrintableInterface");
if(pi == null)
return;
PrintRequestAttributeSet printRequestAttributeSet = Page.getPrintRequestAttributeSet();
PrinterJob printerJob = PrinterJob.getPrinterJob();
PrintService temp = PrinterSelector.getPrinterSelector(this).getPrintService(lastPrintService);
if (temp == null) {
return;
} else {
lastPrintService = temp;
try {
printerJob.setPrintService(lastPrintService);
} catch (PrinterException e) {
handleException(e);
}
}
PageFormat pageFormat = printerJob.pageDialog(printRequestAttributeSet);
if(pageFormat==null)
return;
int pageFormatOrientation = PageFormat.PORTRAIT;
OrientationRequested orientationRequested = (OrientationRequested)
printRequestAttributeSet.get(OrientationRequested.class);
if(orientationRequested != null)
{
if(orientationRequested.equals(OrientationRequested.LANDSCAPE))
pageFormatOrientation = PageFormat.LANDSCAPE;
else if(orientationRequested.equals(OrientationRequested.REVERSE_LANDSCAPE))
pageFormatOrientation = PageFormat.REVERSE_LANDSCAPE;
}
pi.getPageable().getPageFormat(0).setOrientation(pageFormatOrientation);
MediaPrintableArea mediaPrintableArea = (MediaPrintableArea)
printRequestAttributeSet.get(MediaPrintableArea.class);
Paper paper = pi.getPageable().getPageFormat(0).getPaper();
paper.setImageableArea(mediaPrintableArea.getX(MediaPrintableArea.INCH) * 72.0,
mediaPrintableArea.getY(MediaPrintableArea.INCH) * 72.0,
mediaPrintableArea.getWidth(MediaPrintableArea.INCH) * 72,
mediaPrintableArea.getHeight(MediaPrintableArea.INCH) * 72);
pi.getPageable().getPageFormat(0).setPaper(paper);
// store settings
com.cosylab.vdct.graphics.printing.Page.setPageFormat(pageFormat);
Page.setPrintRequestAttributeSet(printRequestAttributeSet);
// }
//}.start();
}