Package javax.print.attribute.standard

Examples of javax.print.attribute.standard.Destination


                }

                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++) {
View Full Code Here


        }

        private String getDestinationPath(final PrintRequestAttributeSet attrs)
                        throws PrintException {
            if (attrs != null) {
                final Destination dest = (Destination) attrs
                                .get(Destination.class);
                return dest != null ? new File(dest.getURI()).getAbsolutePath()
                                : null;
            }
            return null;
        }
View Full Code Here

     * Remove Destination attribute otherwise.
    */
    private void updatePrintToFile() {
        if (toFileBox.isEnabled() && toFileBox.isSelected()) {     
           
            Destination dest = (Destination)
                        (newAttrs.containsKey(Destination.class)
                    ? newAttrs.get(Destination.class)    
                    : myService.getDefaultAttributeValue(Destination.class));
            File file = null;
            DestinationChooser chooser = new DestinationChooser();
   
            if (dest == null) {
                dest = new Destination((new File("out.prn")).toURI());
                /* Default file name for the output file is "out.prn" */
            }
           
            try {
                file = new File(dest.getURI());
            } catch (Exception e) {
                file = new File("out.prn");
           
           
            chooser.setSelectedFile(file);
            chooser.setDialogTitle("Print to file");
            int chooserResult = chooser.showDialog(printDialog, "OK");
            if (chooserResult == JFileChooser.APPROVE_OPTION) {
                try {
                    URI selectedFile = chooser.getSelectedFile().toURI();
                    newAttrs.add(new Destination(selectedFile));
                } catch (Exception e) {
                    removeAttribute(Destination.class);
                }
            }
        } else {
View Full Code Here

            return new RequestingUserName(System.getProperty("user.name"),
                    Locale.US);
        } else if (category.equals(Destination.class)) {
            File file = new File(System.getProperty("user.dir") +
                    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);
        }
View Full Code Here

        Class category = attribute.getCategory();
        if (category.equals(JobName.class) ||
            category.equals(RequestingUserName.class)) {
            return true;
        } else  if (category.equals(Destination.class)) {
            Destination destination = (Destination)attribute;
            if (destination.getURI().getScheme().equals("file")) {
                return true;
            }
        }
        if (flavor != null) {
            if (flavor.equals(DocFlavor.INPUT_STREAM.AUTOSENSE) ||
View Full Code Here

   
    String getDestination(PrintRequestAttributeSet attrs)
            throws PrintException {
        if (attrs != null) {
            if (attrs.containsKey(Destination.class)) {
                Destination destination =
                    (Destination)attrs.get(Destination.class);
                if (!destination.getURI().getScheme().equals("file")) {
                    throw new PrintException(
                            "Only files supported as destinations.");
                }
                String file = destination.getURI().getPath();
                if (file.startsWith("/")) {
                    file = file.substring(1);
                }
                return file;
            }
View Full Code Here

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

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

            if (dest != null) {
                try {
                    mDestType = RasterPrinterJob.FILE;
                    mDestination = (new File(dest.getURI())).getPath();
                } catch (Exception e) {
                    mDestination = "out.prn";
                }
            } else {
                mDestType = RasterPrinterJob.PRINTER;
View Full Code Here

            copiesAttr = copies.getValue();
        } else {
            copiesAttr = getCopies();
        }

        Destination destination =
            (Destination)attributes.get(Destination.class);
        if (isSupportedValue(destination,  attributes)) {
            destinationAttr = "out.prn";
            try {
                destinationAttr = (new File(destination.getURI())).getPath();
            } catch (Exception e) {
            }
        }

        JobSheets jobSheets = (JobSheets)attributes.get(JobSheets.class);
View Full Code Here

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

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

            if (dest != null) {
                try {
                    mDestType = RasterPrinterJob.FILE;
                    mDestination = (new File(dest.getURI())).getPath();
                } catch (Exception e) {
                    mDestination = "out.ps";
                }
            } else {
                mDestType = RasterPrinterJob.PRINTER;
View Full Code Here

            String fileName = jobAttributes.getFileName();
            if (fileName == null) {
                fileName = "out.prn";
            }
            URI uri = (new File(fileName)).toURI();
            attributes.add(new Destination(uri));
        }
        JobAttributes.SidesType sType = jobAttributes.getSides();
        if (sType == JobAttributes.SidesType.TWO_SIDED_LONG_EDGE) {
            attributes.add(Sides.TWO_SIDED_LONG_EDGE);
        } else if (sType == JobAttributes.SidesType.TWO_SIDED_SHORT_EDGE) {
View Full Code Here

TOP

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

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.