Java 类javax.print.attribute.standard.MediaPrintableArea 实例源码

项目:jdk8u-jdk    文件:RasterPrinterJob.java   
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page,
        double w, double h) {
    double ix, iw, iy, ih;
        if (w >= 72.0 * 6.0) {
            ix = 72.0;
            iw = w - 2 * 72.0;
        } else {
            ix = w / 6.0;
            iw = w * 0.75;
        }
        if (h >= 72.0 * 6.0) {
            iy = 72.0;
            ih = h - 2 * 72.0;
        } else {
            iy = h / 6.0;
            ih = h * 0.75;
        }

    return new MediaPrintableArea((float) (ix / DPI), (float) (iy / DPI),
            (float) (iw / DPI), (float) (ih / DPI), MediaPrintableArea.INCH);
}
项目:openjdk-jdk10    文件:RasterPrinterJob.java   
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page,
        double w, double h) {
    double ix, iw, iy, ih;
    if (w >= 72.0 * 6.0) {
        ix = 72.0;
        iw = w - 2 * 72.0;
    } else {
        ix = w / 6.0;
        iw = w * 0.75;
    }
    if (h >= 72.0 * 6.0) {
        iy = 72.0;
        ih = h - 2 * 72.0;
    } else {
        iy = h / 6.0;
        ih = h * 0.75;
    }

    return new MediaPrintableArea((float) (ix / DPI), (float) (iy / DPI),
            (float) (iw / DPI), (float) (ih / DPI), MediaPrintableArea.INCH);
}
项目:OpenJSharp    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:jdk8u-jdk    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:openjdk-jdk10    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:openjdk-jdk10    文件:Win32PrintService.java   
private boolean isSupportedMediaPrintableArea(MediaPrintableArea mpa) {

        getMediaPrintables(null);
        int units = MediaPrintableArea.INCH;

        if (mediaPrintables != null) {
            for (int i=0; i<mediaPrintables.length; i++) {
                if ((mpa.getX(units) >= mediaPrintables[i].getX(units)) &&
                    (mpa.getY(units) >= mediaPrintables[i].getY(units)) &&
                    (mpa.getX(units) + mpa.getWidth(units) <=
                            mediaPrintables[i].getX(units) +
                            mediaPrintables[i].getWidth(units)) &&
                    (mpa.getY(units) + mpa.getHeight(units) <=
                            mediaPrintables[i].getY(units) +
                            mediaPrintables[i].getHeight(units))) {
                    return true;
                }
            }
        }
        return false;
    }
项目:openjdk9    文件:RasterPrinterJob.java   
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page,
        double w, double h) {
    double ix, iw, iy, ih;
    if (w >= 72.0 * 6.0) {
        ix = 72.0;
        iw = w - 2 * 72.0;
    } else {
        ix = w / 6.0;
        iw = w * 0.75;
    }
    if (h >= 72.0 * 6.0) {
        iy = 72.0;
        ih = h - 2 * 72.0;
    } else {
        iy = h / 6.0;
        ih = h * 0.75;
    }

    return new MediaPrintableArea((float) (ix / DPI), (float) (iy / DPI),
            (float) (iw / DPI), (float) (ih / DPI), MediaPrintableArea.INCH);
}
项目:openjdk9    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:jdk8u_jdk    文件:RasterPrinterJob.java   
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page,
        double w, double h) {
    double ix, iw, iy, ih;
        if (w >= 72.0 * 6.0) {
            ix = 72.0;
            iw = w - 2 * 72.0;
        } else {
            ix = w / 6.0;
            iw = w * 0.75;
        }
        if (h >= 72.0 * 6.0) {
            iy = 72.0;
            ih = h - 2 * 72.0;
        } else {
            iy = h / 6.0;
            ih = h * 0.75;
        }

    return new MediaPrintableArea((float) (ix / DPI), (float) (iy / DPI),
            (float) (iw / DPI), (float) (ih / DPI), MediaPrintableArea.INCH);
}
项目:jdk8u_jdk    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:lookaside_java-1.8.0-openjdk    文件:RasterPrinterJob.java   
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page,
        double w, double h) {
    double ix, iw, iy, ih;
        if (w >= 72.0 * 6.0) {
            ix = 72.0;
            iw = w - 2 * 72.0;
        } else {
            ix = w / 6.0;
            iw = w * 0.75;
        }
        if (h >= 72.0 * 6.0) {
            iy = 72.0;
            ih = h - 2 * 72.0;
        } else {
            iy = h / 6.0;
            ih = h * 0.75;
        }

    return new MediaPrintableArea((float) (ix / DPI), (float) (iy / DPI),
            (float) (iw / DPI), (float) (ih / DPI), MediaPrintableArea.INCH);
}
项目:lookaside_java-1.8.0-openjdk    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:javify    文件:PrinterDialog.java   
/**
 * Called to update for new selected
 * print service. Tests if currently
 * selected attributes are supported.
 */
void updateForSelectedService()
{
  if (categorySupported(MediaPrintableArea.class))
    {
      left.setEnabled(true);
      right.setEnabled(true);
      top.setEnabled(true);
      bottom.setEnabled(true);
      left_tf.setEnabled(true);
      right_tf.setEnabled(true);
      top_tf.setEnabled(true);
      bottom_tf.setEnabled(true);
    }
  else
    {
      left.setEnabled(false);
      right.setEnabled(false);
      top.setEnabled(false);
      bottom.setEnabled(false);
      left_tf.setEnabled(false);
      right_tf.setEnabled(false);
      top_tf.setEnabled(false);
      bottom_tf.setEnabled(false);
    }
 }
项目:jvm-stm    文件:PrinterDialog.java   
/**
 * Called to update for new selected
 * print service. Tests if currently
 * selected attributes are supported.
 */
void updateForSelectedService()
{
  if (categorySupported(MediaPrintableArea.class))
    {
      left.setEnabled(true);
      right.setEnabled(true);
      top.setEnabled(true);
      bottom.setEnabled(true);
      left_tf.setEnabled(true);
      right_tf.setEnabled(true);
      top_tf.setEnabled(true);
      bottom_tf.setEnabled(true);           
    }
  else
    {
      left.setEnabled(false);
      right.setEnabled(false);
      top.setEnabled(false);
      bottom.setEnabled(false);
      left_tf.setEnabled(false);
      right_tf.setEnabled(false);
      top_tf.setEnabled(false);
      bottom_tf.setEnabled(false); 
    }     
 }
项目:metasfresh    文件:CPaper.java   
/**
 *  Get "nice" String Representation
 *  @param ctx context
 *  @return info
 */
public String toString (Properties ctx)
{
    StringBuffer sb = new StringBuffer();
    //  Print Media size
    //AA Goodwill : Custom Paper Support
    if (m_mediaSize != null){
        sb.append(m_mediaSize.getMediaSizeName());
        //  Print dimension
        String name = m_mediaSize.getMediaSizeName().toString();
        if (!name.startsWith("iso"))
            sb.append(" - ").append(m_mediaSize.toString(MediaSize.INCH,"\""))
                .append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.INCH,"\""));
        if (!name.startsWith("na"))
            sb.append(" - ").append(m_mediaSize.toString(MediaSize.MM,"mm"))
                .append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.MM,"mm"));
        //  Print Orientation
        sb.append(") - ")
            .append(Msg.getMsg(ctx, m_landscape ? "Landscape" : "Portrait"));
    }       
    else sb.append("Custom - ").append(toString());
    //End Of AA Goodwill
    return sb.toString();
}
项目:infobip-open-jdk-8    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:jdk8u-dev-jdk    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:jdk7-jdk    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:openjdk-source-code-learn    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:OLD-OpenJDK8    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:cn1    文件:PSPrinterJob.java   
protected PrintRequestAttributeSet updateMediaAndMarginsIfNeeded(
        PrintRequestAttributeSet newAttrs) {

    /* create copy of this.attrs*/
    PrintRequestAttributeSet sum = 
            new HashPrintRequestAttributeSet(this.attrs);

    /* remove MediaMargins and MediaPrintableArea attributes from the copy
       of job attributes if newAttrs contains  MediaMargins or 
       PrintableArea */
    if (newAttrs.containsKey(MediaPrintableArea.class)
                || attrs.containsKey(MediaMargins.class)) {
        sum.remove(MediaPrintableArea.class);
        sum.remove(MediaMargins.class);
    }

    sum.addAll(newAttrs);
    return sum;
}
项目:JamVM-PH    文件:PrinterDialog.java   
/**
 * Called to update for new selected
 * print service. Tests if currently
 * selected attributes are supported.
 */
void updateForSelectedService()
{
  if (categorySupported(MediaPrintableArea.class))
    {
      left.setEnabled(true);
      right.setEnabled(true);
      top.setEnabled(true);
      bottom.setEnabled(true);
      left_tf.setEnabled(true);
      right_tf.setEnabled(true);
      top_tf.setEnabled(true);
      bottom_tf.setEnabled(true);           
    }
  else
    {
      left.setEnabled(false);
      right.setEnabled(false);
      top.setEnabled(false);
      bottom.setEnabled(false);
      left_tf.setEnabled(false);
      right_tf.setEnabled(false);
      top_tf.setEnabled(false);
      bottom_tf.setEnabled(false); 
    }     
 }
项目:openjdk-jdk7u-jdk    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:classpath    文件:PrinterDialog.java   
/**
 * Called to update for new selected
 * print service. Tests if currently
 * selected attributes are supported.
 */
void updateForSelectedService()
{
  if (categorySupported(MediaPrintableArea.class))
    {
      left.setEnabled(true);
      right.setEnabled(true);
      top.setEnabled(true);
      bottom.setEnabled(true);
      left_tf.setEnabled(true);
      right_tf.setEnabled(true);
      top_tf.setEnabled(true);
      bottom_tf.setEnabled(true);
    }
  else
    {
      left.setEnabled(false);
      right.setEnabled(false);
      top.setEnabled(false);
      bottom.setEnabled(false);
      left_tf.setEnabled(false);
      right_tf.setEnabled(false);
      top_tf.setEnabled(false);
      bottom_tf.setEnabled(false);
    }
 }
项目:freeVM    文件:PSPrinterJob.java   
protected PrintRequestAttributeSet updateMediaAndMarginsIfNeeded(
        PrintRequestAttributeSet newAttrs) {

    /* create copy of this.attrs*/
    PrintRequestAttributeSet sum = 
            new HashPrintRequestAttributeSet(this.attrs);

    /* remove MediaMargins and MediaPrintableArea attributes from the copy
       of job attributes if newAttrs contains  MediaMargins or 
       PrintableArea */
    if (newAttrs.containsKey(MediaPrintableArea.class)
                || attrs.containsKey(MediaMargins.class)) {
        sum.remove(MediaPrintableArea.class);
        sum.remove(MediaMargins.class);
    }

    sum.addAll(newAttrs);
    return sum;
}
项目:freeVM    文件:PSPrinterJob.java   
protected PrintRequestAttributeSet updateMediaAndMarginsIfNeeded(
        PrintRequestAttributeSet newAttrs) {

    /* create copy of this.attrs*/
    PrintRequestAttributeSet sum = 
            new HashPrintRequestAttributeSet(this.attrs);

    /* remove MediaMargins and MediaPrintableArea attributes from the copy
       of job attributes if newAttrs contains  MediaMargins or 
       PrintableArea */
    if (newAttrs.containsKey(MediaPrintableArea.class)
                || attrs.containsKey(MediaMargins.class)) {
        sum.remove(MediaPrintableArea.class);
        sum.remove(MediaMargins.class);
    }

    sum.addAll(newAttrs);
    return sum;
}
项目:openjdk-icedtea7    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:OpenJSharp    文件:Win32PrintService.java   
private boolean isSupportedMediaPrintableArea(MediaPrintableArea mpa) {

        getMediaPrintables(null);

        if (mediaPrintables != null) {
            for (int i=0; i<mediaPrintables.length; i++) {
                if (mpa.equals(mediaPrintables[i])) {
                    return true;
                }
            }
        }
        return false;
    }
项目:jdk8u-jdk    文件:CPrinterJob.java   
@Override
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page, double w, double h) {
    final float dpi = 72.0f;
    Paper paper = page.getPaper();
    return new MediaPrintableArea(
            (float) (paper.getImageableX() / dpi),
            (float) (paper.getImageableY() / dpi),
            (float) (paper.getImageableWidth() / dpi),
            (float) (paper.getImageableHeight() / dpi),
            MediaPrintableArea.INCH);
}
项目:jdk8u-jdk    文件:Win32PrintService.java   
private boolean isSupportedMediaPrintableArea(MediaPrintableArea mpa) {

        getMediaPrintables(null);

        if (mediaPrintables != null) {
            for (int i=0; i<mediaPrintables.length; i++) {
                if (mpa.equals(mediaPrintables[i])) {
                    return true;
                }
            }
        }
        return false;
    }
项目:jdk8u-jdk    文件:ImageableAreaTest.java   
private static void printWithCustomImageareaSize() {
    final JTable table = createAuthorTable(18);
    PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
    printAttributes.add(DialogTypeSelection.NATIVE);
    printAttributes.add(new Copies(1));
    printAttributes.add(new MediaPrintableArea(
            0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH));
    Printable printable = table.getPrintable(
            JTable.PrintMode.NORMAL,
            new MessageFormat("Author Table"),
            new MessageFormat("Page - {0}")
    );

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(printable);

    boolean printAccepted = job.printDialog(printAttributes);
    if (printAccepted) {
        try {
            job.print(printAttributes);
            closeFrame();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else {
        throw new RuntimeException("User cancels the printer job!");
    }
}
项目:openjdk-jdk10    文件:CPrinterJob.java   
@Override
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page, double w, double h) {
    final float dpi = 72.0f;
    Paper paper = page.getPaper();
    return new MediaPrintableArea(
            (float) (paper.getImageableX() / dpi),
            (float) (paper.getImageableY() / dpi),
            (float) (paper.getImageableWidth() / dpi),
            (float) (paper.getImageableHeight() / dpi),
            MediaPrintableArea.INCH);
}
项目:openjdk-jdk10    文件:ImageableAreaTest.java   
private static void printWithCustomImageareaSize() {
    final JTable table = createAuthorTable(18);
    PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
    printAttributes.add(DialogTypeSelection.NATIVE);
    printAttributes.add(new Copies(1));
    printAttributes.add(new MediaPrintableArea(
            0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH));
    Printable printable = table.getPrintable(
            JTable.PrintMode.NORMAL,
            new MessageFormat("Author Table"),
            new MessageFormat("Page - {0}")
    );

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(printable);

    boolean printAccepted = job.printDialog(printAttributes);
    if (printAccepted) {
        try {
            job.print(printAttributes);
            closeFrame();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else {
        throw new RuntimeException("User cancels the printer job!");
    }
}
项目:openjdk-jdk10    文件:PageDialogMarginTest.java   
static double getPrintableXFromASet(PrintRequestAttributeSet aset) {
    try {
        return ((MediaPrintableArea) aset.get(
                MediaPrintableArea.class)).getX(MediaPrintableArea.INCH);
    } catch (Exception e) {
        return -1.0;
    }
}
项目:openjdk-jdk10    文件:PageDialogMarginTest.java   
static double getPrintableYFromASet(PrintRequestAttributeSet aset) {
    try {
        return ((MediaPrintableArea) aset.get(
                MediaPrintableArea.class)).getY(MediaPrintableArea.INCH);
    } catch (Exception e) {
        return -1.0;
    }
}
项目:openjdk-jdk10    文件:TestPgfmtSetMPA.java   
public static void main(String args[]) {
    PrinterJob job;

    job = PrinterJob.getPrinterJob();

    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();

    // Here you could see the PageFormat with an empty PrintRequestAttributeSet
    PageFormat pf2 = job.getPageFormat(pras);
    System.out.println((pf2.getImageableX() / 72f) + " "
            + (pf2.getImageableY() / 72f) + " "
            + (pf2.getImageableWidth() / 72f) + " "
            + (pf2.getImageableHeight() / 72f)
    );

    // Set left margin to 2.0
    pras.add(new MediaPrintableArea(2.0f,
            (float)(pf2.getImageableY() / 72f),
            (float) ((pf2.getImageableWidth() / 72f) - 1.0f),
            (float) (pf2.getImageableHeight() / 72f),
            MediaPrintableArea.INCH));

    pf2 = job.getPageFormat(pras);
    System.out.println((pf2.getImageableX() / 72f) + " "
            + (pf2.getImageableY() / 72f) + " "
            + (pf2.getImageableWidth() / 72f) + " "
            + (pf2.getImageableHeight() / 72f)
    );

    // check if returned left margin of imageable area is 2.0 as set earlier
    if (pf2.getImageableX() / 72f != 2.0f) {
        throw new RuntimeException("getPageFormat doesn't apply specified "
                + "MediaPrintableArea attribute");
    }
}
项目:openjdk9    文件:CPrinterJob.java   
@Override
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page, double w, double h) {
    final float dpi = 72.0f;
    Paper paper = page.getPaper();
    return new MediaPrintableArea(
            (float) (paper.getImageableX() / dpi),
            (float) (paper.getImageableY() / dpi),
            (float) (paper.getImageableWidth() / dpi),
            (float) (paper.getImageableHeight() / dpi),
            MediaPrintableArea.INCH);
}
项目:openjdk9    文件:Win32PrintService.java   
private boolean isSupportedMediaPrintableArea(MediaPrintableArea mpa) {

        getMediaPrintables(null);

        if (mediaPrintables != null) {
            for (int i=0; i<mediaPrintables.length; i++) {
                if (mpa.equals(mediaPrintables[i])) {
                    return true;
                }
            }
        }
        return false;
    }
项目:openjdk9    文件:ImageableAreaTest.java   
private static void printWithCustomImageareaSize() {
    final JTable table = createAuthorTable(18);
    PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
    printAttributes.add(DialogTypeSelection.NATIVE);
    printAttributes.add(new Copies(1));
    printAttributes.add(new MediaPrintableArea(
            0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH));
    Printable printable = table.getPrintable(
            JTable.PrintMode.NORMAL,
            new MessageFormat("Author Table"),
            new MessageFormat("Page - {0}")
    );

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(printable);

    boolean printAccepted = job.printDialog(printAttributes);
    if (printAccepted) {
        try {
            job.print(printAttributes);
            closeFrame();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else {
        throw new RuntimeException("User cancels the printer job!");
    }
}
项目:openjdk9    文件:PageDialogMarginTest.java   
static double getPrintableXFromASet(PrintRequestAttributeSet aset) {
    try {
        return ((MediaPrintableArea) aset.get(
                MediaPrintableArea.class)).getX(MediaPrintableArea.INCH);
    } catch (Exception e) {
        return -1.0;
    }
}