Examples of OrientationRequested


Examples of javax.print.attribute.standard.OrientationRequested

     * OrientationRequested attribute. Only supported by service orientations
     * are enabled.
    */
    void fillOrientationFields() {
       
        OrientationRequested orient =
                (OrientationRequested) attrs.get(OrientationRequested.class);
        boolean isSupported =
                myService.isAttributeCategorySupported(OrientationRequested.class);
   
        OrientationRequested [] supportedList = (isSupported
                ? (OrientationRequested []) myService.getSupportedAttributeValues(
                        OrientationRequested.class, flavor, attrs)
                : null);
       
        enableOrient(supportedList);
         
        /* Select orientation at first time (orientation from attributes set or
           default orientation for this Print Service) */
        if (firstUse) {
            if (orient != null) {
                selectOrient(orient);  
            } else {
                OrientationRequested defaul = (OrientationRequested)
                    myService.getDefaultAttributeValue(OrientationRequested.class);
                selectOrient(isSupported ? defaul : null);
            }
        }
   
        /* Select orientation if previosly selected button is disabled now */
        if (supportedList != null) {
            OrientationRequested oldValue = getOrient();
            if (!orientEnabled(oldValue)) {
                selectOrient(orientEnabled(orient) ? orient : supportedList[0]);
            }
        }
    }
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

     * "Margins" fields should be updated after the orientation is changed.
    */
    class OrientationChangeListener implements ChangeListener {
   
        public void stateChanged(ChangeEvent e) {
            OrientationRequested now = getOrient();
       
            if ((lastOrient != null) && (now != null) && (!lastOrient.equals(now))) {
                /* if orientation was really changed */
               
                String txt = leftTxt.getText();
       
                if ((lastOrient.equals(OrientationRequested.PORTRAIT)
                                && now.equals(OrientationRequested.LANDSCAPE))
                        || (lastOrient.equals(OrientationRequested.LANDSCAPE
                                && now.equals(OrientationRequested.REVERSE_PORTRAIT))
                        || (lastOrient.equals(OrientationRequested.REVERSE_PORTRAIT)
                                && now.equals(OrientationRequested.REVERSE_LANDSCAPE))
                        || (lastOrient.equals(OrientationRequested.REVERSE_LANDSCAPE)
                                && now.equals(OrientationRequested.PORTRAIT))) {
                    leftTxt.setText(bottomTxt.getText());
                    bottomTxt.setText(rightTxt.getText());
                    rightTxt.setText(topTxt.getText());
                    topTxt.setText(txt);
       
                } else if ((lastOrient.equals(OrientationRequested.PORTRAIT)
                                && now.equals(OrientationRequested.REVERSE_PORTRAIT))
                        || (lastOrient.equals(OrientationRequested.LANDSCAPE)
                                && now.equals(OrientationRequested.REVERSE_LANDSCAPE))
                        || (lastOrient.equals(OrientationRequested.REVERSE_PORTRAIT)
                                && now.equals(OrientationRequested.PORTRAIT))
                        || (lastOrient.equals(OrientationRequested.REVERSE_LANDSCAPE)
                                && now.equals(OrientationRequested.LANDSCAPE))) {
                    leftTxt.setText(rightTxt.getText());
                    rightTxt.setText(txt);
                    txt = topTxt.getText();
                    topTxt.setText(bottomTxt.getText());
                    bottomTxt.setText(txt);
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

            PrintRequestAttributeSet newattrs) {
       
        PageFormat pf = new PageFormat();
       
        if (newattrs.containsKey(OrientationRequested.class)) {
            OrientationRequested or = (OrientationRequested)
                    newattrs.get(OrientationRequested.class);
            pf.setOrientation(or.equals(OrientationRequested.LANDSCAPE
                    ? PageFormat.LANDSCAPE
                    : (or.equals(OrientationRequested.REVERSE_LANDSCAPE
                            ? PageFormat.REVERSE_LANDSCAPE
                            : PageFormat.PORTRAIT));
        }

        Paper paper = new Paper();
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

            return new PageFormat();
        }

        final PageFormat format = new PageFormat();
        final Paper paper = new Paper();
        final OrientationRequested orient = (OrientationRequested) attributes
                        .get(OrientationRequested.class);
        final MediaSize size = attributes.containsKey(Media.class) ? MediaSize
                        .getMediaSizeForName((MediaSizeName) attributes
                                        .get(Media.class))
                        : (MediaSize) attributes.get(MediaSize.class);
        final MediaPrintableArea area = (MediaPrintableArea) attributes
                        .get(MediaPrintableArea.class);

        if (orient != null) {
            if (orient.equals(OrientationRequested.LANDSCAPE)) {
                format.setOrientation(PageFormat.LANDSCAPE);
            } else if (orient.equals(OrientationRequested.REVERSE_LANDSCAPE)) {
                format.setOrientation(PageFormat.REVERSE_LANDSCAPE);
            }
        }

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

Examples of javax.print.attribute.standard.OrientationRequested

        private PageFormat getPageFormat(final AttributeSet... attrSets) {
            final Paper paper = new Paper();
            final PageFormat format = new PageFormat();
            final DevmodeStructWrapper dm = service.getPrinterProps();
            final OrientationRequested o = dm.getOrientation();
            final MediaPrintableArea area = getAttribute(
                            MediaPrintableArea.class, attrSets);
            DevmodeStructWrapper.Paper p = dm.getPaper();

            if (p == null) {
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

     * OrientationRequested attribute. Only supported by service orientations
     * are enabled.
    */
    void fillOrientationFields() {
       
        OrientationRequested orient =
                (OrientationRequested) attrs.get(OrientationRequested.class);
        boolean isSupported =
                myService.isAttributeCategorySupported(OrientationRequested.class);
   
        OrientationRequested [] supportedList = (isSupported
                ? (OrientationRequested []) myService.getSupportedAttributeValues(
                        OrientationRequested.class, flavor, attrs)
                : null);
       
        enableOrient(supportedList);
         
        /* Select orientation at first time (orientation from attributes set or
           default orientation for this Print Service) */
        if (firstUse) {
            if (orient != null) {
                selectOrient(orient);  
            } else {
                OrientationRequested defaul = (OrientationRequested)
                    myService.getDefaultAttributeValue(OrientationRequested.class);
                selectOrient(isSupported ? defaul : null);
            }
        }
   
        /* Select orientation if previosly selected button is disabled now */
        if (supportedList != null) {
            OrientationRequested oldValue = getOrient();
            if (!orientEnabled(oldValue)) {
                selectOrient(orientEnabled(orient) ? orient : supportedList[0]);
            }
        }
    }
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

     * "Margins" fields should be updated after the orientation is changed.
    */
    class OrientationChangeListener implements ChangeListener {
   
        public void stateChanged(ChangeEvent e) {
            OrientationRequested now = getOrient();
       
            if ((lastOrient != null) && (now != null) && (!lastOrient.equals(now))) {
                /* if orientation was really changed */
               
                String txt = leftTxt.getText();
       
                if ((lastOrient.equals(OrientationRequested.PORTRAIT)
                                && now.equals(OrientationRequested.LANDSCAPE))
                        || (lastOrient.equals(OrientationRequested.LANDSCAPE
                                && now.equals(OrientationRequested.REVERSE_PORTRAIT))
                        || (lastOrient.equals(OrientationRequested.REVERSE_PORTRAIT)
                                && now.equals(OrientationRequested.REVERSE_LANDSCAPE))
                        || (lastOrient.equals(OrientationRequested.REVERSE_LANDSCAPE)
                                && now.equals(OrientationRequested.PORTRAIT))) {
                    leftTxt.setText(bottomTxt.getText());
                    bottomTxt.setText(rightTxt.getText());
                    rightTxt.setText(topTxt.getText());
                    topTxt.setText(txt);
       
                } else if ((lastOrient.equals(OrientationRequested.PORTRAIT)
                                && now.equals(OrientationRequested.REVERSE_PORTRAIT))
                        || (lastOrient.equals(OrientationRequested.LANDSCAPE)
                                && now.equals(OrientationRequested.REVERSE_LANDSCAPE))
                        || (lastOrient.equals(OrientationRequested.REVERSE_PORTRAIT)
                                && now.equals(OrientationRequested.PORTRAIT))
                        || (lastOrient.equals(OrientationRequested.REVERSE_LANDSCAPE)
                                && now.equals(OrientationRequested.LANDSCAPE))) {
                    leftTxt.setText(rightTxt.getText());
                    rightTxt.setText(txt);
                    txt = topTxt.getText();
                    topTxt.setText(bottomTxt.getText());
                    bottomTxt.setText(txt);
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

    private Pageable patchMedia( Pageable pageable ){
      /* OpenBook is used internally only when app uses Printable.
         * This is the case when we use the values from the attribute set.
         */
        Media media = (Media)reqAttrSet.get(Media.class);
        OrientationRequested orientReq = (OrientationRequested)reqAttrSet.get(OrientationRequested.class);
        MediaPrintableArea mpa = (MediaPrintableArea)reqAttrSet.get(MediaPrintableArea.class);

        if ((orientReq != null || media != null || mpa != null) && pageable instanceof OpenBook) {

            /* We could almost(!) use PrinterJob.getPageFormat() except
             * here we need to start with the PageFormat from the OpenBook :
             */
            Printable printable = pageable.getPrintable(0);
            PageFormat pf = (PageFormat)pageable.getPageFormat(0).clone();
            Paper paper = pf.getPaper();

            /* If there's a media but no media printable area, we can try
             * to retrieve the default value for mpa and use that.
             */
            if (mpa == null && media != null && service.isAttributeCategorySupported(MediaPrintableArea.class)) {
                Object mpaVals = service. getSupportedAttributeValues(MediaPrintableArea.class, null, reqAttrSet);
                if (mpaVals instanceof MediaPrintableArea[] && ((MediaPrintableArea[])mpaVals).length > 0) {
                    mpa = ((MediaPrintableArea[])mpaVals)[0];
                }
            }

            if (isSupportedValue(orientReq, reqAttrSet) || (!fidelity && orientReq != null)) {
                int orient;
                if (orientReq.equals(OrientationRequested.REVERSE_LANDSCAPE)) {
                    orient = PageFormat.REVERSE_LANDSCAPE;
                } else if (orientReq.equals(OrientationRequested.LANDSCAPE)) {
                    orient = PageFormat.LANDSCAPE;
                } else {
                    orient = PageFormat.PORTRAIT;
                }
                pf.setOrientation(orient);
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

//    MediaSizeName mediaSizeName=MediaSize.findMedia((float)paper.getWidth(),(float)paper.getHeight(),MediaSize.INCH*72);
//    System.out.println("mediaSizeName="+mediaSizeName);
    attr.add(sizeName);
//    attr.add(new MediaPrintableArea((float)paper.getImageableX(),(float)paper.getImageableY(),(float)paper.getImageableWidth(),(float)paper.getImageableHeight(),MediaSize.INCH*72));
    attr.add(printableArea);
    OrientationRequested orientation;
    switch (getOrientation()) {
    case PageFormat.PORTRAIT: orientation=OrientationRequested.PORTRAIT;
      break;
    case PageFormat.LANDSCAPE: orientation=OrientationRequested.LANDSCAPE;
      break;
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

                         (72.0))/(float)Size2DSyntax.INCH;
        float y = (float)Math.rint(
                         (page.getPaper().getHeight()*Size2DSyntax.INCH)/
                         (72.0))/(float)Size2DSyntax.INCH;

        OrientationRequested orient;
        switch (page.getOrientation()) {
        case PageFormat.LANDSCAPE :
            orient = OrientationRequested.LANDSCAPE;
            break;
        case PageFormat.REVERSE_LANDSCAPE:
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.