本文整理汇总了Java中javax.print.attribute.standard.Sides类的典型用法代码示例。如果您正苦于以下问题:Java Sides类的具体用法?Java Sides怎么用?Java Sides使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sides类属于javax.print.attribute.standard包,在下文中一共展示了Sides类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printDocument
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
public static void printDocument() throws IOException, PrinterException
{
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(Sides.TWO_SIDED_SHORT_EDGE);
PDDocument input = PDDocument.load(new File("Karteikarten.pdf"));
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(input));
if (job.printDialog(pras)) {
job.print(pras);
}
}
示例2: getSupportedAttributeCategories
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
@Override
public Class<?>[] getSupportedAttributeCategories(){
ArrayList<Class> categList = new ArrayList<Class>(otherAttrCats.length+3);
for (int i=0; i < otherAttrCats.length; i++) {
categList.add(otherAttrCats[i]);
}
if (settings.get_CanDuplex()) {
categList.add(Sides.class);
}
if (settings.get_PrinterResolutions().get_Count() > 0) {
categList.add(PrinterResolution.class);
}
return categList.toArray(new Class[categList.size()]);
}
示例3: assignSides
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
public Sides assignSides(String sidesString) {
Sides answer;
if (sidesString == null) {
// default to one side if no slides configured
answer = Sides.ONE_SIDED;
} else if (sidesString.equalsIgnoreCase("one-sided")) {
answer = Sides.ONE_SIDED;
} else if (sidesString.equalsIgnoreCase("duplex")) {
answer = Sides.DUPLEX;
} else if (sidesString.equalsIgnoreCase("tumble")) {
answer = Sides.TUMBLE;
} else if (sidesString.equalsIgnoreCase("two-sided-short-edge")) {
answer = Sides.TWO_SIDED_SHORT_EDGE;
} else if (sidesString.equalsIgnoreCase("two-sided-long-edge")) {
answer = Sides.TWO_SIDED_LONG_EDGE;
} else {
answer = Sides.ONE_SIDED;
}
return answer;
}
示例4: printToMiddleTray
import javax.print.attribute.standard.Sides; //导入依赖的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.standard.Sides; //导入依赖的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: setAttribute
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
public void setAttribute(final Attribute attr) {
final Class<? extends Attribute> category = attr.getCategory();
if (OrientationRequested.class.equals(category)) {
setOrientation((OrientationRequested) attr);
} else if (MediaSize.class.equals(category)) {
setPaper((MediaSize) attr);
} else if (Media.class.equals(category)) {
setPaper((MediaSizeName) attr);
} else if (Paper.class.equals(category)) {
setPaper((Paper) attr);
} else if (Copies.class.equals(category)) {
setCopies((Copies) attr);
} else if (PrintQuality.class.equals(category)) {
setPrintQuality((PrintQuality) attr);
} else if (Sides.class.equals(category)) {
setSides((Sides) attr);
} else if (SheetCollate.class.equals(category)) {
setCollate((SheetCollate) attr);
} else if (PrinterResolution.class.equals(category)) {
setPrinterResolution((PrinterResolution) attr);
} else if (Chromaticity.class.equals(category)) {
setChromaticity((Chromaticity) attr);
}
}
示例7: fillSidesFields
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
void fillSidesFields() {
Sides side = (Sides) attrs.get(Sides.class);
if (firstUse) {
selectSidesButton(side);
}
Sides [] aList = (myService.isAttributeCategorySupported(Sides.class)
? (Sides []) (myService.getSupportedAttributeValues(
Sides.class, flavor, attrs))
: null);
enableSidesButtons(aList);
if ((aList != null) && !sideIsEnabled(getSelectedSide())) {
selectSidesButton(sideIsEnabled(side)
? side
: (Sides) (myService.getDefaultAttributeValue(Sides.class)));
}
}
示例8: enableSidesButtons
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
private void enableSidesButtons(Sides [] list) {
oneSideBtn.setEnabled(false);
duplexBtn.setEnabled(false);
tumbleBtn.setEnabled(false);
if (list != null) {
for (int i = 0; i < list.length; i++) {
if (list[i].equals(Sides.ONE_SIDED)) {
oneSideBtn.setEnabled(true);
} else if (list[i].equals(Sides.DUPLEX)
|| list[i].equals(Sides.TWO_SIDED_LONG_EDGE)) {
duplexBtn.setEnabled(true);
} else if (list[i].equals(Sides.TUMBLE)
|| list[i].equals(Sides.TWO_SIDED_SHORT_EDGE)) {
tumbleBtn.setEnabled(true);
}
}
}
}
示例9: createSidesCombo
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
private void createSidesCombo(PrintRequestAttributeSet set) {
Sides[] sides = (Sides[]) mService.getSupportedAttributeValues(Sides.class, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
if (sides != null && sides.length > 0) {
HashSet<Sides> possible = new HashSet<>();
for (Sides one : sides) {
possible.add(one);
}
ArrayList<PageSides> choices = new ArrayList<>();
for (PageSides side : PageSides.values()) {
if (possible.contains(side.getSides())) {
choices.add(side);
}
}
mSides = new JComboBox<>(choices.toArray(new PageSides[0]));
mSides.setSelectedItem(PrintUtilities.getSides(mService, set));
UIUtilities.setOnlySize(mSides, mSides.getPreferredSize());
LinkedLabel label = new LinkedLabel(SIDES, mSides);
add(label, new PrecisionLayoutData().setEndHorizontalAlignment());
add(mSides);
} else {
mSides = null;
}
}
示例10: printsWithLandscapeOrientation
import javax.print.attribute.standard.Sides; //导入依赖的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);
Assert.assertNotNull(attribute);
Assert.assertEquals("reverse-landscape", attribute.toString());
}
示例11: getSupportedAttributeCategories
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
public Class<?>[] getSupportedAttributeCategories() {
ArrayList categList = new ArrayList(otherAttrCats.length+3);
for (int i=0; i < otherAttrCats.length; i++) {
categList.add(otherAttrCats[i]);
}
int caps = getPrinterCapabilities();
if ((caps & DEVCAP_DUPLEX) != 0) {
categList.add(Sides.class);
}
if ((caps & DEVCAP_QUALITY) != 0) {
int[] defaults = getDefaultPrinterSettings();
// Added check: if supported, we should be able to get the default.
if ((defaults[3] >= DMRES_HIGH) && (defaults[3] < 0)) {
categList.add(PrintQuality.class);
}
}
PrinterResolution[] supportedRes = getPrintResolutions();
if ((supportedRes!=null) && (supportedRes.length>0)) {
categList.add(PrinterResolution.class);
}
return (Class[])categList.toArray(new Class[categList.size()]);
}
示例12: setSidesAttrib
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
private void setSidesAttrib(Attribute attr) {
if (attr == Sides.TWO_SIDED_LONG_EDGE) {
mAttSides = 2; // DMDUP_VERTICAL
} else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
mAttSides = 3; // DMDUP_HORIZONTAL
} else { // Sides.ONE_SIDED
mAttSides = 1;
}
}
示例13: actionPerformed
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
@Override final public void actionPerformed(ActionEvent objPactionEvent) {
final Object objLsourceObject = objPactionEvent.getSource();
if (this.objGoneSidePrintIconRadioJButton.isSameAs(objLsourceObject)) {
this.objGprintJDialog.getAttributes().add(Sides.ONE_SIDED);
} else if (this.objGtumblePrintIconRadioJButton.isSameAs(objLsourceObject)) {
this.objGprintJDialog.getAttributes().add(Sides.TUMBLE);
} else if (this.objGduplexPrintIconRadioJButton.isSameAs(objLsourceObject)) {
this.objGprintJDialog.getAttributes().add(Sides.DUPLEX);
}
}
示例14: getSupportedAttributeCategories
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
public Class<?>[] getSupportedAttributeCategories() {
ArrayList<Class<?>> categList = new ArrayList<>(otherAttrCats.length+3);
for (int i=0; i < otherAttrCats.length; i++) {
categList.add(otherAttrCats[i]);
}
int caps = getPrinterCapabilities();
if ((caps & DEVCAP_DUPLEX) != 0) {
categList.add(Sides.class);
}
if ((caps & DEVCAP_QUALITY) != 0) {
int[] defaults = getDefaultPrinterSettings();
// Added check: if supported, we should be able to get the default.
if ((defaults[3] >= DMRES_HIGH) && (defaults[3] < 0)) {
categList.add(PrintQuality.class);
}
}
PrinterResolution[] supportedRes = getPrintResolutions();
if ((supportedRes!=null) && (supportedRes.length>0)) {
categList.add(PrinterResolution.class);
}
return categList.toArray(new Class<?>[categList.size()]);
}
示例15: print
import javax.print.attribute.standard.Sides; //导入依赖的package包/类
/**
*
* @param g Graphic class
* @param pf page format
* @param page page count
* @return 1
* @throws PrinterException
*
* This methos print to pdf
*/
@Override
public int print(Graphics g, PageFormat pf, int page) throws
PrinterException {
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
PrintRequestAttributeSet patts = new HashPrintRequestAttributeSet();
patts.add(Sides.DUPLEX);
PrintService[] ps = PrintServiceLookup.lookupPrintServices(flavor, patts);
if (ps.length == 0) {
//
}
//System.out.println("Available printers: " + Arrays.asList(ps));
PrintService myService = null;
for (PrintService printService : ps) {
if (printService.getName().equals("Your printer name")) {
myService = printService;
break;
}
}
if (myService == null) {
//
}
try (FileInputStream fis = new FileInputStream(file)) {
Doc pdfDoc = new SimpleDoc(fis, DocFlavor.INPUT_STREAM.AUTOSENSE, null);
DocPrintJob printJob = myService.createPrintJob();
printJob.print(pdfDoc, new HashPrintRequestAttributeSet());
} catch (Exception e) {
e.printStackTrace();
throw new PrinterException("File Not Found!");
}
return 1;
}