Package javax.print.attribute.standard

Examples of javax.print.attribute.standard.Destination


     * 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


            if (ms.equalsIgnoreCase("gif") || ms.equalsIgnoreCase("jpeg")
                    || ms.equalsIgnoreCase("png")
                    || ms.equalsIgnoreCase("postscript")
                    || flavor.getClass() == DocFlavor.SERVICE_FORMATTED.class) {
                try {
                    return new Object[] { new Destination(new URI(
                            "file:///foo/bar")) };
                } catch (URISyntaxException e) {
                    // return empty array - values are not supported
                    return new Object[0];
                }
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

     * 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

            if (ms.equalsIgnoreCase("gif") || ms.equalsIgnoreCase("jpeg")
                    || ms.equalsIgnoreCase("png")
                    || ms.equalsIgnoreCase("postscript")
                    || flavor.getClass() == DocFlavor.SERVICE_FORMATTED.class) {
                try {
                    return new Object[] { new Destination(new URI(
                            "file:///foo/bar")) };
                } catch (URISyntaxException e) {
                    // return empty array - values are not supported
                    return new Object[0];
                }
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

            Attribute[] attrs = { MediaSizeName.ISO_A0,
                    Finishings.NONE,
                    Finishings.EDGE_STITCH,
                    MediaSizeName.ISO_A2,
                    MediaSizeName.ISO_A3,
                    new Destination(uri1),
                    new Destination(uri2),
                    new Destination(uri3),
                    new DocumentName("xyz", Locale.US),
                    new JobName("xyz", Locale.US),
                    new RequestingUserName("xyz", Locale.US),
                    Sides.DUPLEX,
                    Sides.ONE_SIDED,
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.