Package javax.print.attribute.standard

Examples of javax.print.attribute.standard.MediaSize


    final MediaPrintableArea printableArea =
        (MediaPrintableArea) attributeSet.get(MediaPrintableArea.class);
    final OrientationRequested orientationRequested =
        (OrientationRequested) attributeSet.get(OrientationRequested.class);

    final MediaSize mediaSize = lookupMediaSize(media);
    if (mediaSize == null)
    {
      logger.warn("Unknown media encountered, unable to compute page sizes.");
    }
View Full Code Here


        if (media != null &&
            service.isAttributeValueSupported(media, null, attributes)) {
            if (media instanceof MediaSizeName) {
                MediaSizeName msn = (MediaSizeName)media;
                MediaSize msz = MediaSize.getMediaSizeForName(msn);
                if (msz != null) {
        double inch = 72.0;
                    double paperWid = msz.getX(MediaSize.INCH) * inch;
                    double paperHgt = msz.getY(MediaSize.INCH) * inch;
                    paper.setSize(paperWid, paperHgt);
        if (mpa == null) {
      paper.setImageableArea(inch, inch,
                 paperWid-2*inch,
                 paperHgt-2*inch);
 
View Full Code Here

                        public void run() {
                            Object selectedItem = myComboMediaSize
                                    .getSelectedItem();
                            if (selectedItem != null) {
                                myMediaSizeName = (MediaSizeName) selectedItem;
                                MediaSize ms = MediaSize
                                        .getMediaSizeForName(myMediaSizeName);
                                Paper p = new Paper();
                                float[] size = ms.getSize(MediaSize.INCH);
                                p.setSize(size[0] * 72, size[1] * 72);
                                p.setImageableArea(72, 72,
                                        p.getWidth() - 72 * 2,
                                        p.getHeight() - 72 * 2);
                                myPageFormat.setPaper(p);
                                changePageOrientation(myOrientation);
                                statusBar.setText1(ms.getX(MediaSize.MM)
                                        + " x " + ms.getY(MediaSize.MM));
                                myPreviewContainer.repaint();
                            }
                        }
                    });
                }
            });
        }

        bPrint.setToolTipText(GanttProject.getToolTip(GanttProject
                .correctLabel(language.getText("printProject"))));
        bPortrait.setToolTipText(GanttProject.getToolTip(GanttProject
                .correctLabel(language.getText("portrait"))));
        bLandscape.setToolTipText(GanttProject.getToolTip(GanttProject
                .correctLabel(language.getText("landscape"))));
        bClose.setToolTipText(GanttProject.getToolTip(GanttProject
                .correctLabel(language.getText("close"))));
        final JButton bZoomOut;
        final JButton bZoomIn;
        if (isDate) {
            myWholeProjectButton.setToolTipText(GanttProject
                    .getToolTip(GanttProject.correctLabel(language
                            .getText("displayWholeProject"))));
            /*
            myStartDateButton.setToolTipText(GanttProject
                    .getToolTip(GanttProject.correctLabel(language
                            .getText("setStartDate"))));
            myEndDateButton.setToolTipText(GanttProject.getToolTip(GanttProject
                    .correctLabel(language.getText("setEndDate"))));
                    */
            //GanttProject gp = Mediator.getGanttProjectSingleton();
            final ZoomManager zoomManager = myUIfacade.getZoomManager();
            final Action zoomOut = new ZoomOutAction(zoomManager, "16");
            final Action zoomIn = new ZoomInAction(zoomManager, "16");
            bZoomOut = new JButton((Icon) zoomOut.getValue(Action.SMALL_ICON));
            bZoomIn = new JButton((Icon) zoomIn.getValue(Action.SMALL_ICON));

            bZoomOut.setHorizontalTextPosition(SwingConstants.RIGHT);
            bZoomOut.setText(language.getText("narrowChart"));
            bZoomOut.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                    run(new Runnable() {
                        public void run() {
                            zoomOut.actionPerformed(null);
                            updateSourceImage();
                            bZoomOut.setEnabled(zoomManager.canZoomOut());
                            bZoomIn.setEnabled(zoomManager.canZoomIn());
                        }
                    });
                }
            });

            bZoomIn.setHorizontalTextPosition(SwingConstants.RIGHT);
            bZoomIn.setText(language.getText("widenChart"));
            bZoomIn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                    run(new Runnable() {
                        public void run() {
                            zoomIn.actionPerformed(null);
                            updateSourceImage();
                            bZoomOut.setEnabled(zoomManager.canZoomOut());
                            bZoomIn.setEnabled(zoomManager.canZoomIn());
                        }
                    });
                }
            });

        } else {
            bZoomOut = null;
            bZoomIn = null;
        }

        tb2.setFloatable(false);
        tb.setFloatable(false);
        tb.add(bClose);
        tb.addSeparator(new Dimension(16, 16));
        tb.add(bPrint);
        tb.addSeparator(new Dimension(16, 16));
        tb.add(bPortrait);
        tb.add(bLandscape);
        tb.addSeparator(new Dimension(16, 16));
        tb.add(new JLabel(language.getText("zoom") + " "));
        tb.add(myComboScale);
        if (vMedia != null && !vMedia.isEmpty()) {
            tb.addSeparator(new Dimension(16, 16));
            tb.add(new JLabel(language.getText("choosePaperFormat") + " "));
            tb.addSeparator(new Dimension(0, 10));
            tb.add(myComboMediaSize);
        }

        if (isDate) {
            tb2.add(bZoomOut);
            tb2.addSeparator(new Dimension(5, 0));
            tb2.add(bZoomIn);
            tb2.addSeparator(new Dimension(20, 0));
            tb2.add(myWholeProjectButton);
            tb2.addSeparator(new Dimension(16, 16));
            OptionsPageBuilder builder = new OptionsPageBuilder();
            builder.setOptionKeyPrefix("");
            tb2.add(builder.createStandaloneOptionPanel(myStart));
            URL iconArrow = this.getClass().getClassLoader().getResource(
                    "icons/fromto.gif");
            tb2.add(new JLabel(new ImageIcon(iconArrow)));
            tb2.add(builder.createStandaloneOptionPanel(myFinish));
        }

        JPanel topPanel = new JPanel(new BorderLayout());
        tb.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
        tb2.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
        topPanel.add(tb, BorderLayout.NORTH);
        topPanel.add(tb2, BorderLayout.SOUTH);

        getContentPane().add(topPanel, BorderLayout.NORTH);

        statusBar = new StatusBar();
        statusBar.setLabel0(language.getText("pageNumber"));
        statusBar.setLabel1(language.getText("paperSize"));
        getContentPane().add(statusBar, BorderLayout.SOUTH);

        myPreviewContainer = new PreviewContainer();

        PrinterJob prnJob = PrinterJob.getPrinterJob();

        // --
        myPageFormat = new PageFormat();
        myPageFormat.setOrientation(myOrientation);

        myMediaSizeName = DEFAULT_MEDIA_SIZE_NAME;
        MediaSize ms = MediaSize.getMediaSizeForName(myMediaSizeName);
        Paper p = new Paper();
        float[] size = ms.getSize(MediaSize.INCH);
        p.setSize(size[0] * 72, size[1] * 72);
        p.setImageableArea(72, 72, p.getWidth() - 72 * 2,
                p.getHeight() - 72 * 2);
        myPageFormat.setPaper(p);
        // --
        statusBar.setText1(ms.getX(MediaSize.MM) + " x "
                + ms.getY(MediaSize.MM));

        if (myPageFormat.getHeight() == 0 || myPageFormat.getWidth() == 0) {
            myUIfacade.showErrorDialog("Unable to determine default page size");
            return;
        }
View Full Code Here

    final MediaPrintableArea printableArea =
        (MediaPrintableArea) attributeSet.get(MediaPrintableArea.class);
    final OrientationRequested orientationRequested =
        (OrientationRequested) attributeSet.get(OrientationRequested.class);

    final MediaSize mediaSize = lookupMediaSize(media);
    if (mediaSize == null)
    {
      logger.warn("Unknown media encountered, unable to compute page sizes.");
    }
View Full Code Here

            float sizeX = mediaSizes[i][0] / 10.0f;
            float sizeY = mediaSizes[i][1] / 10.0f;
            if (sizeX > 0 && sizeY > 0) {
                boolean standardFound = false;
                for (int j = 0; j < mediaNames.length; j++) {
                    MediaSize mediaSize =
                        MediaSize.getMediaSizeForName(mediaNames[j]);
                    if (mediaSize != null &&
                        Math.abs(sizeX - mediaSize.getX(MediaSize.MM)) < 1 &&
                        Math.abs(sizeY - mediaSize.getY(MediaSize.MM)) < 1) {
                        standardFound = true;
                        if (!result.contains(mediaNames[j])) {
                            result.add(mediaNames[j]);
                            medias.put(mediaNames[j], new Integer(ids[i]));
                            /* TODO:
                             * Do we have to do this break? If not,
                             * all names of one size returned.
                             */
                            break;
                        }
                    }
                }
                if (!standardFound) {
                    GDIMediaName name = new GDIMediaName(names[i],
                            NOT_STANDARD_MEDIA + i);
                    MediaSizeName sname = MediaSize.findMedia(sizeX, sizeY,
                            MediaSize.MM);
                    if (sname == null) {
                        MediaSize size = new MediaSize(sizeX, sizeY,
                                MediaSize.MM, name);
                    } else {
                        MediaSize size = MediaSize.getMediaSizeForName(sname);
                        if (size.getX(MediaSize.MM) != sizeX ||
                            size.getY(MediaSize.MM) != sizeY) {
                            MediaSize newSize = new MediaSize(sizeX, sizeY,
                                    MediaSize.MM, name);
                        }
                    }
                    if (!result.contains(name)) {
                        result.add(name);
View Full Code Here

           
            Media selectedMedia = (Media) sizeBox.getSelectedItem();
            boolean isMediaSizeSelected = (selectedMedia == null)
                ? false :
                selectedMedia.getClass().isAssignableFrom(MediaSizeName.class);
            MediaSize selectedSize = isMediaSizeSelected
                ? MediaSize.getMediaSizeForName((MediaSizeName) selectedMedia)
                : null;
           
            if (isMediaSupported
                    && isPaSupported
View Full Code Here

    }

    if (sizeBox.isEnabled()
         && (sizeBox.getSelectedItem() instanceof MediaSizeName)
         && myService.isAttributeCategorySupported(MediaPrintableArea.class)) {
        MediaSize mediaSize = MediaSize.getMediaSizeForName(
                (MediaSizeName) sizeBox.getSelectedItem());
        float paperWidth = mediaSize.getX(Size2DSyntax.MM);
        float paperHeight = mediaSize.getY(Size2DSyntax.MM);
        if ((x1 + x2 >= paperWidth) || (y1 + y2 >= paperHeight)) {
            return false;
        }
        newAttrs.add(new MediaPrintableArea(x1,
                                            y1,
View Full Code Here

        if (x > y) {
            float z = x;
            y = x;
            x = z;
        }
        new MediaSize(x / 72, y / 72, Size2DSyntax.INCH, this);
    }
View Full Code Here

        if (media != null &&
            service.isAttributeValueSupported(media, null, attributes)) {
            if (media instanceof MediaSizeName) {
                MediaSizeName msn = (MediaSizeName)media;
                MediaSize msz = MediaSize.getMediaSizeForName(msn);
                if (msz != null) {
                    double inch = 72.0;
                    double paperWid = msz.getX(MediaSize.INCH) * inch;
                    double paperHgt = msz.getY(MediaSize.INCH) * inch;
                    paper.setSize(paperWid, paperHgt);
                    if (mpa == null) {
                        paper.setImageableArea(inch, inch,
                                               paperWid-2*inch,
                                               paperHgt-2*inch);
 
View Full Code Here

        else
            printDescription=name.toString();


        //Get paper size
        MediaSize size = MediaSize.getMediaSizeForName(name);
        double pX = size.getX(MediaSize.MM);
        double pY = size.getY(MediaSize.MM);


        //Get printable area
        attributes.add(name);
        MediaPrintableArea[] area = (MediaPrintableArea[])printService.getSupportedAttributeValues(MediaPrintableArea.class,null,attributes);
View Full Code Here

TOP

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

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.