Package javax.print.attribute.standard

Examples of javax.print.attribute.standard.Copies


        }

        if (attributes == null) {
            attributes = new HashPrintRequestAttributeSet();
        }
        attributes.add(new Copies(getCopies()));
        attributes.add(new JobName(getJobName(), null));

        boolean doPrint = false;
        DialogTypeSelection dts =
            (DialogTypeSelection)attributes.get(DialogTypeSelection.class);
        if (dts == DialogTypeSelection.NATIVE) {
            // Remove DialogTypeSelection.NATIVE to prevent infinite loop in
            // RasterPrinterJob.
            attributes.remove(DialogTypeSelection.class);
            doPrint = printDialog(attributes);
            // restore attribute
            attributes.add(DialogTypeSelection.NATIVE);
        } else {
            doPrint = printDialog(attributes);
        }

        if (doPrint) {
            JobName jobName = (JobName)attributes.get(JobName.class);
            if (jobName != null) {
                setJobName(jobName.getValue());
            }
            Copies copies = (Copies)attributes.get(Copies.class);
            if (copies != null) {
                setCopies(copies.getValue());
            }

            Destination dest = (Destination)attributes.get(Destination.class);

            if (dest != null) {
View Full Code Here


}

public void testHashPrintRequestAttributeSet() {
    startTest("HashPrintRequestAttributeSet class testing...");

    Copies copies = new Copies(2);
    PrintRequestAttributeSet set1 = new HashPrintRequestAttributeSet();
    PrintRequestAttributeSet set2 = new HashPrintRequestAttributeSet(copies);
    PrintRequestAttributeSet set3 = new HashPrintRequestAttributeSet(set2);
    PrintRequestAttribute [] arr = {copies,
                                    MediaName.NA_LETTER_WHITE};
    PrintRequestAttributeSet set4 = new HashPrintRequestAttributeSet(arr);
    Attribute [] attrArr = set1.toArray();

    assertTrue(set1.isEmpty());
    assertFalse(set2.isEmpty());
    assertTrue(set3.equals(set2));
    assertFalse(set3.equals(set1));
    set3.clear();
    assertEquals(set3, set1);
    set3.add(copies);
    set3.add(MediaName.NA_LETTER_WHITE);
    assertTrue(set3.containsKey(copies.getClass()));
    assertFalse(set2.containsKey(MediaName.NA_LETTER_WHITE.getClass()));
    assertTrue(set3.containsValue(copies));
    assertFalse(set3.containsValue(OrientationRequested.PORTRAIT));
    assertFalse(set3.containsValue(PrintQuality.DRAFT));
    assertEquals(set1.size(), 0);
    assertEquals(set2.size(), 1);
    assertEquals(set3.size(), 2);
    assertTrue(set4.equals(set3));
    assertEquals(set3.get(copies.getClass()), copies);
    set1.addAll(set3);
    assertEquals(set3, set1);
    set1.remove(copies.getClass());
    assertEquals(set1.size(), 1);
    attrArr = set1.toArray();
    assertEquals(attrArr.length, 1);
    assertEquals(attrArr[0], MediaName.NA_LETTER_WHITE);
}
View Full Code Here

        DocAttributeSet dset = new HashDocAttributeSet();
        dset.add(new DocumentName("print doc name", Locale.US));

        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        aset.add(new Copies(3));
        aset.add(MediaName.ISO_A4_WHITE);
        aset.add(new RequestingUserName("ichebyki", Locale.US));

        try {
            PrintService serv = services[0];
View Full Code Here

        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        HashDocAttributeSet daset = new HashDocAttributeSet();
        DocPrintJob pj;
        Doc doc;

        aset.add(new Copies(2));
        aset.add(MediaSizeName.ISO_A4);
        daset.add(MediaName.ISO_A4_WHITE);
        daset.add(Sides.TWO_SIDED_LONG_EDGE);

        services = PrintServiceLookup.lookupMultiDocPrintServices(
View Full Code Here

        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        HashDocAttributeSet daset = new HashDocAttributeSet();
        DocPrintJob pj;
        Doc doc;

        aset.add(new Copies(2));
        aset.add(MediaSizeName.ISO_A4);
        daset.add(MediaName.ISO_A4_WHITE);
        daset.add(Sides.TWO_SIDED_LONG_EDGE);

        service = PrintServiceLookup.lookupDefaultPrintService();
View Full Code Here

                        // IGNORE exception
                        a = null;
                        e.printStackTrace();
                    }
                } else if (atag == IppAttribute.TAG_INTEGER) {
                    a = new Copies(((Integer) avalue.get(i)).intValue());
                }
                if (a != null) {
                    attrx.add(a);
                }
            }
View Full Code Here

            int value = (firstUse && attrs.containsKey(Copies.class
                        ? ((Copies) (attrs.get(Copies.class))).getValue() 
                        : ((Integer) cpSpinner.getValue()).intValue());
            CopiesSupported supported = (CopiesSupported) myService
                    .getSupportedAttributeValues(Copies.class, flavor, attrs);
            Copies defaul = (Copies)
                    myService.getDefaultAttributeValue(Copies.class);
           
            if(supported == null) {
                /*
                 * It is incorrect situation, however it is possible: Copies
                 * category is supported, but there are no supported values. I
                 * suppose that only default Copies value is supported in this
                 * case. If default Copies value is null - I suppose that default
                 * and supported value is 1 Copy only.
                */
                supported = new CopiesSupported( (defaul == null)
                        ? defaul.getValue()
                        : 1);
            }
           
            int [][] range = supported.getMembers();
           
            if (!supported.contains(value)) {
                value = (((defaul == null)
                                || (!supported.contains(defaul.getValue())))
                        ? range[0][0]
                        : defaul.getValue());
            }
           
            cpSpinner.setModel(
                    new SpinnerNumberModel(value, range[0][0], range[0][1], 1));
        }
View Full Code Here

    */
    private void updateCopies() {
        if (cpSpinner.isEnabled()) {
            int copiesValue = ((SpinnerNumberModel)
                    (cpSpinner.getModel())).getNumber().intValue();
            newAttrs.add(new Copies(copiesValue));
        } else {
            removeAttribute(Copies.class);
        }
    }
View Full Code Here

    }   

    private PrintRequestAttributeSet assignPrintAttributes() throws PrintException {
        PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
        if (config.getCopies() >= 1) {
            printRequestAttributeSet.add(new Copies(config.getCopies()));
        } else {
            throw new PrintException("Number of print copies should be greater than zero");
        }
        printRequestAttributeSet.add(config.getMediaSizeName());
        printRequestAttributeSet.add(config.getInternalSides());
View Full Code Here

                    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;
    }
View Full Code Here

TOP

Related Classes of javax.print.attribute.standard.Copies

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.