当前位置: 首页>>代码示例>>Java>>正文


Java Sides类代码示例

本文整理汇总了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);
	}
	
}
 
开发者ID:CoffeeCodeSwitzerland,项目名称:Lernkartei_2017,代码行数:16,代码来源:Printer.java

示例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()]);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:Win32PrintService.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:PrinterConfiguration.java

示例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());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:PrinterPrintTest.java

示例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());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:PrinterPrintTest.java

示例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);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:DevmodeStructWrapper.java

示例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)));
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:ServiceUIDialog.java

示例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);
            }
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:ServiceUIDialog.java

示例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;
	}
}
 
开发者ID:Ayutac,项目名称:toolkit,代码行数:24,代码来源:PageSetupPanel.java

示例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());
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:23,代码来源:PrinterIntegrationTest.java

示例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()]);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:Win32PrintService.java

示例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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:WPrinterJob.java

示例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);
	}
}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:12,代码来源:PrintSidesSubJPanel.java

示例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()]);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:Win32PrintService.java

示例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;
}
 
开发者ID:accountingSoftwareCSE343Group4,项目名称:accounting_Soft,代码行数:43,代码来源:Printer.java


注:本文中的javax.print.attribute.standard.Sides类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。