Examples of OrientationRequested


Examples of javax.print.attribute.standard.OrientationRequested

  public static PageFormat extractPageFormat(final PrintRequestAttributeSet attributeSet)
  {
    final Media media = (Media) attributeSet.get(Media.class);
    final MediaPrintableArea printableArea =
        (MediaPrintableArea) attributeSet.get(MediaPrintableArea.class);
    final OrientationRequested orientationRequested =
        (OrientationRequested) attributeSet.get(OrientationRequested.class);

    final MediaSize mediaSize = lookupMediaSize(media);
    if (mediaSize == null)
    {
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

        }

        Media media = (Media)attributes.get(Media.class);
        MediaPrintableArea mpa =
            (MediaPrintableArea)attributes.get(MediaPrintableArea.class);
        OrientationRequested orientReq =
           (OrientationRequested)attributes.get(OrientationRequested.class);

        if (media == null && mpa == null && orientReq == null) {
           return pf;
        }
        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, attributes);
      if (mpaVals instanceof MediaPrintableArea[] &&
    ((MediaPrintableArea[])mpaVals).length > 0) {
    mpa = ((MediaPrintableArea[])mpaVals)[0];
      }
  }

        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);
        }
    }
            }
        }

        if (mpa != null &&
      service.isAttributeValueSupported(mpa, null, attributes)) {
            float [] printableArea =
                mpa.getPrintableArea(MediaPrintableArea.INCH);
            for (int i=0; i < printableArea.length; i++) {
                printableArea[i] = printableArea[i]*72.0f;
            }
            paper.setImageableArea(printableArea[0], printableArea[1],
                                   printableArea[2], printableArea[3]);
        }

        if (orientReq != null &&
            service.isAttributeValueSupported(orientReq, null, attributes)) {
            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

        );
    }

    if (!printRequestAttributeSet.containsKey(OrientationRequested.class))
    {
      OrientationRequested orientation;
      switch (jPrint.getOrientationValue())
      {
        case LANDSCAPE:
          orientation = OrientationRequested.LANDSCAPE;
          break;
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

  public static PageFormat extractPageFormat(final PrintRequestAttributeSet attributeSet)
  {
    final Media media = (Media) attributeSet.get(Media.class);
    final MediaPrintableArea printableArea =
        (MediaPrintableArea) attributeSet.get(MediaPrintableArea.class);
    final OrientationRequested orientationRequested =
        (OrientationRequested) attributeSet.get(OrientationRequested.class);

    final MediaSize mediaSize = lookupMediaSize(media);
    if (mediaSize == 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

        }

        Media media = (Media)attributes.get(Media.class);
        MediaPrintableArea mpa =
            (MediaPrintableArea)attributes.get(MediaPrintableArea.class);
        OrientationRequested orientReq =
           (OrientationRequested)attributes.get(OrientationRequested.class);

        if (media == null && mpa == null && orientReq == null) {
           return pf;
        }
        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, attributes);
            if (mpaVals instanceof MediaPrintableArea[] &&
                ((MediaPrintableArea[])mpaVals).length > 0) {
                mpa = ((MediaPrintableArea[])mpaVals)[0];
            }
        }

        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);
                    }
                }
            }
        }

        if (mpa != null &&
            service.isAttributeValueSupported(mpa, null, attributes)) {
            float [] printableArea =
                mpa.getPrintableArea(MediaPrintableArea.INCH);
            for (int i=0; i < printableArea.length; i++) {
                printableArea[i] = printableArea[i]*72.0f;
            }
            paper.setImageableArea(printableArea[0], printableArea[1],
                                   printableArea[2], printableArea[3]);
        }

        if (orientReq != null &&
            service.isAttributeValueSupported(orientReq, null, attributes)) {
            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

        return answer;
    }

    public OrientationRequested assignOrientation(final String orientation) {
        OrientationRequested answer;

        if (orientation == null) {
            // default to portrait
            answer = OrientationRequested.PORTRAIT;
        } else if (orientation.equalsIgnoreCase("portrait")) {
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

                p.setImageableArea(0.0,0.0,p.getWidth(),p.getHeight());
            }

            pageFormat.setPaper(p);

            OrientationRequested orient =
               (OrientationRequested)attributes.get(OrientationRequested.class);
            if (orient!= null &&
                orient == OrientationRequested.REVERSE_LANDSCAPE) {
                pageFormat.setOrientation(PageFormat.REVERSE_LANDSCAPE);
            } else if (orient == OrientationRequested.LANDSCAPE) {
View Full Code Here

Examples of javax.print.attribute.standard.OrientationRequested

            pageAttributes.setColor(ColorType.COLOR);
        } else {
            pageAttributes.setColor(ColorType.MONOCHROME);
        }

        OrientationRequested orient =
            (OrientationRequested)attributes.get(OrientationRequested.class);
        if (orient == OrientationRequested.LANDSCAPE) {
            pageAttributes.setOrientationRequested(
                                       OrientationRequestedType.LANDSCAPE);
        } else {
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.