Package javax.print.attribute

Examples of javax.print.attribute.HashAttributeSet


     * Test that MadiaName, MediaSizeName, MediaTray are
     * fall into the Media attribute Category
     */
    public final void testMediaCategory() {

        HashAttributeSet aset = new HashAttributeSet();

        MediaSizeName msn = MediaSizeName.ISO_A3;
        aset.add(msn);
        assertEquals(msn, aset.get(Media.class));
        assertNull(aset.get(MediaSizeName.class));

        MediaTray mt = MediaTray.BOTTOM;
        aset.add(mt);
        assertEquals(mt, aset.get(Media.class));
        assertNull(aset.get(MediaTray.class));

        MediaName mn = MediaName.ISO_A4_WHITE;
        aset.add(mn);
        assertEquals(mn, aset.get(Media.class));
        assertNull(aset.get(MediaName.class));
    }
View Full Code Here


                    throw new PrintException("Doc flavor "
                            + df.getRepresentationClassName()
                            + " is not supported yet");
                }

                HashAttributeSet as = new HashAttributeSet();
                DocAttributeSet das;
                das = doc.getAttributes();

                // construct attributes
                if (das != null) {
                    as.addAll(das);
                }
                if (attributes != null) {
                    as.addAll(attributes);
                }
                as.addAll(attributeset);

                // print
                if (as.containsKey(Destination.class)) {
                    print2destination(doc, (Destination) as
                            .get(Destination.class));
                } else {
                    printsimple(doc, as);
                }
            } catch (PrintException e) {
View Full Code Here

                    throw new PrintException("Doc flavor "
                            + df.getRepresentationClassName()
                            + " is not supported yet");
                }

                HashAttributeSet as = new HashAttributeSet();
                DocAttributeSet das;
                das = doc.getAttributes();

                // construct attributes
                if (das != null) {
                    as.addAll(das);
                }
                if (attributes != null) {
                    as.addAll(attributes);
                }
                as.addAll(attributeset);

                // print
                if (as.containsKey(Destination.class)) {
                    print2destination(doc, (Destination) as
                            .get(Destination.class));
                } else {
                    printsimple(doc, as);
                }
            } catch (PrintException e) {
View Full Code Here

            throw new IllegalArgumentException("Flavor " + flavor.getMimeType()
                    + " is not supported by print service");
        }
       
        Attribute[] attrs = attributes.toArray();
        HashAttributeSet unsupported = new HashAttributeSet();
        for (int i = 0; i < attrs.length; i++) {
            if (!isAttributeValueSupported(attrs[i], flavor, attributes)) {
                unsupported.add(attrs[i]);
            }
        }
        if (unsupported.size() > 0) {
            return unsupported;
        }
        return null;
    }
View Full Code Here

        for (int i = 0, ii = services.length; i < ii; i++) {
            System.out.println("\n----------- " + services[i].getName()
                    + "----------");

            Class[] cats = services[i].getSupportedAttributeCategories();
            HashAttributeSet aset = new HashAttributeSet();
            aset.add(MediaSizeName.ISO_A0);
            aset.add(OrientationRequested.LANDSCAPE);
            aset.add(Finishings.SADDLE_STITCH);

            for (int l = 0, ll = flavors.length; l < ll; l++) {
                if (services[i].isDocFlavorSupported(flavors[l])) {
                    System.out.println("    " + flavors[l]);
View Full Code Here

                    //uri = File.createTempFile("xxx", null).toURI();
                } catch (URISyntaxException e) {
                    fail();
                }

                AttributeSet attrs = new HashAttributeSet();
                attrs.add(Finishings.EDGE_STITCH);
                attrs.add(MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
                attrs.add(new Destination(uri));
                attrs.add(new DocumentName("Doc X", Locale.US));
                attrs.add(new JobName("Job Y", Locale.US));
                attrs.add(new RequestingUserName("User Z", Locale.US));

                for (int j = 0; j < flavors.length; j++) {
                    if (services[i].isDocFlavorSupported(flavors[j])) {
                        AttributeSet aset = services[i]
                                .getUnsupportedAttributes(flavors[j], attrs);
View Full Code Here

            final DocFlavor flavor = doc.getDocFlavor();
            final DevmodeStructWrapper dm = service.getPrinterProps();

            dm.setAttributes(attributes);
            dm.setAttributes(doc.getAttributes());
            notifyAttrListeners(dm.getAttributes(new HashAttributeSet()));

            try {
                if (DocFlavor.SERVICE_FORMATTED.PRINTABLE.equals(flavor)) {
                    printPrintable(doc, attributes);
                } else if (DocFlavor.SERVICE_FORMATTED.PAGEABLE.equals(flavor)) {
View Full Code Here

        if (attributes == null) {
            return null;
        }

        Attribute attr;
        AttributeSet unsupp = new HashAttributeSet();
        Attribute []attrs = attributes.toArray();
        for (int i=0; i<attrs.length; i++) {
            try {
                attr = attrs[i];
                if (!isAttributeCategorySupported(attr.getCategory())) {
                    unsupp.add(attr);
                }
                else if (!isAttributeValueSupported(attr, flavor, attributes)) {
                    unsupp.add(attr);
                }
            } catch (ClassCastException e) {
            }
        }
        if (unsupp.isEmpty()) {
            return null;
        } else {
            return unsupp;
        }
    }
View Full Code Here

        if (attributes == null) {
            return null;
        }

        Attribute attr;
        AttributeSet unsupp = new HashAttributeSet();
        Attribute []attrs = attributes.toArray();
        for (int i=0; i<attrs.length; i++) {
            try {
                attr = attrs[i];
                if (!isAttributeCategorySupported(attr.getCategory())) {
                    unsupp.add(attr);
                } else if (!isAttributeValueSupported(attr, flavor,
                                                      attributes)) {
                    unsupp.add(attr);
                }
            } catch (ClassCastException e) {
            }
        }
        if (unsupp.isEmpty()) {
            return null;
        } else {
            return unsupp;
        }
    }
View Full Code Here

    }
   
    // Localiza todas as impressoras com suporte a impress�o de PDFs e com suporte a cores
    DocFlavor pdfFlavor = DocFlavor.BYTE_ARRAY.PDF;
   
    AttributeSet attributes = new HashAttributeSet();
    attributes.add(Chromaticity.COLOR);

    PrintService[] pdfPrinters = PrintServiceLookup.lookupPrintServices(pdfFlavor, attributes);
    for (int i = 0; i < pdfPrinters.length; i++) {
      System.out.println(pdfPrinters[i].getName());
    }
View Full Code Here

TOP

Related Classes of javax.print.attribute.HashAttributeSet

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.