java.awt.print.Paper#getWidth ( )源码实例Demo

下面列出了java.awt.print.Paper#getWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pentaho-reporting   文件: PageFormatSerializer.java
/**
 * Resolves a page format, so that the result can be serialized.
 *
 * @param format the page format that should be prepared for serialisation.
 * @return the prepared page format data.
 */
private Object[] resolvePageFormat( final PageFormat format ) {
  final Integer orientation = new Integer( format.getOrientation() );
  final Paper p = format.getPaper();
  final float[] fdim = new float[] { (float) p.getWidth(), (float) p.getHeight() };
  final float[] rect = new float[] { (float) p.getImageableX(),
    (float) p.getImageableY(),
    (float) p.getImageableWidth(),
    (float) p.getImageableHeight() };
  return new Object[] { orientation, fdim, rect };
}
 
源代码2 项目: dragonwell8_jdk   文件: RasterPrinterJob.java
/**
 * updates a Paper object to reflect the current printer's selected
 * paper size and imageable area for that paper size.
 * Default implementation copies settings from the original, applies
 * applies some validity checks, changes them only if they are
 * clearly unreasonable, then sets them into the new Paper.
 * Subclasses are expected to override this method to make more
 * informed decisons.
 */
protected void validatePaper(Paper origPaper, Paper newPaper) {
    if (origPaper == null || newPaper == null) {
        return;
    } else {
        double wid = origPaper.getWidth();
        double hgt = origPaper.getHeight();
        double ix = origPaper.getImageableX();
        double iy = origPaper.getImageableY();
        double iw = origPaper.getImageableWidth();
        double ih = origPaper.getImageableHeight();

        /* Assume any +ve values are legal. Overall paper dimensions
         * take precedence. Make sure imageable area fits on the paper.
         */
        Paper defaultPaper = new Paper();
        wid = ((wid > 0.0) ? wid : defaultPaper.getWidth());
        hgt = ((hgt > 0.0) ? hgt : defaultPaper.getHeight());
        ix = ((ix > 0.0) ? ix : defaultPaper.getImageableX());
        iy = ((iy > 0.0) ? iy : defaultPaper.getImageableY());
        iw = ((iw > 0.0) ? iw : defaultPaper.getImageableWidth());
        ih = ((ih > 0.0) ? ih : defaultPaper.getImageableHeight());
        /* full width/height is not likely to be imageable, but since we
         * don't know the limits we have to allow it
         */
        if (iw > wid) {
            iw = wid;
        }
        if (ih > hgt) {
            ih = hgt;
        }
        if ((ix + iw) > wid) {
            ix = wid - iw;
        }
        if ((iy + ih) > hgt) {
            iy = hgt - ih;
        }
        newPaper.setSize(wid, hgt);
        newPaper.setImageableArea(ix, iy, iw, ih);
    }
}
 
源代码3 项目: dragonwell8_jdk   文件: PSPrinterJob.java
protected double getPhysicalPageWidth(Paper p) {
    return p.getWidth();
}
 
源代码4 项目: openjdk-8   文件: PSPrinterJob.java
protected double getPhysicalPageWidth(Paper p) {
    return p.getWidth();
}
 
源代码5 项目: TencentKona-8   文件: PSPrinterJob.java
protected double getPhysicalPageWidth(Paper p) {
    return p.getWidth();
}
 
源代码6 项目: jdk8u60   文件: RasterPrinterJob.java
/**
 * updates a Paper object to reflect the current printer's selected
 * paper size and imageable area for that paper size.
 * Default implementation copies settings from the original, applies
 * applies some validity checks, changes them only if they are
 * clearly unreasonable, then sets them into the new Paper.
 * Subclasses are expected to override this method to make more
 * informed decisons.
 */
protected void validatePaper(Paper origPaper, Paper newPaper) {
    if (origPaper == null || newPaper == null) {
        return;
    } else {
        double wid = origPaper.getWidth();
        double hgt = origPaper.getHeight();
        double ix = origPaper.getImageableX();
        double iy = origPaper.getImageableY();
        double iw = origPaper.getImageableWidth();
        double ih = origPaper.getImageableHeight();

        /* Assume any +ve values are legal. Overall paper dimensions
         * take precedence. Make sure imageable area fits on the paper.
         */
        Paper defaultPaper = new Paper();
        wid = ((wid > 0.0) ? wid : defaultPaper.getWidth());
        hgt = ((hgt > 0.0) ? hgt : defaultPaper.getHeight());
        ix = ((ix > 0.0) ? ix : defaultPaper.getImageableX());
        iy = ((iy > 0.0) ? iy : defaultPaper.getImageableY());
        iw = ((iw > 0.0) ? iw : defaultPaper.getImageableWidth());
        ih = ((ih > 0.0) ? ih : defaultPaper.getImageableHeight());
        /* full width/height is not likely to be imageable, but since we
         * don't know the limits we have to allow it
         */
        if (iw > wid) {
            iw = wid;
        }
        if (ih > hgt) {
            ih = hgt;
        }
        if ((ix + iw) > wid) {
            ix = wid - iw;
        }
        if ((iy + ih) > hgt) {
            iy = hgt - ih;
        }
        newPaper.setSize(wid, hgt);
        newPaper.setImageableArea(ix, iy, iw, ih);
    }
}
 
源代码7 项目: jdk8u-jdk   文件: PSPrinterJob.java
protected double getPhysicalPageWidth(Paper p) {
    return p.getWidth();
}
 
源代码8 项目: jdk8u-jdk   文件: RasterPrinterJob.java
/**
 * updates a Paper object to reflect the current printer's selected
 * paper size and imageable area for that paper size.
 * Default implementation copies settings from the original, applies
 * applies some validity checks, changes them only if they are
 * clearly unreasonable, then sets them into the new Paper.
 * Subclasses are expected to override this method to make more
 * informed decisons.
 */
protected void validatePaper(Paper origPaper, Paper newPaper) {
    if (origPaper == null || newPaper == null) {
        return;
    } else {
        double wid = origPaper.getWidth();
        double hgt = origPaper.getHeight();
        double ix = origPaper.getImageableX();
        double iy = origPaper.getImageableY();
        double iw = origPaper.getImageableWidth();
        double ih = origPaper.getImageableHeight();

        /* Assume any +ve values are legal. Overall paper dimensions
         * take precedence. Make sure imageable area fits on the paper.
         */
        Paper defaultPaper = new Paper();
        wid = ((wid > 0.0) ? wid : defaultPaper.getWidth());
        hgt = ((hgt > 0.0) ? hgt : defaultPaper.getHeight());
        ix = ((ix > 0.0) ? ix : defaultPaper.getImageableX());
        iy = ((iy > 0.0) ? iy : defaultPaper.getImageableY());
        iw = ((iw > 0.0) ? iw : defaultPaper.getImageableWidth());
        ih = ((ih > 0.0) ? ih : defaultPaper.getImageableHeight());
        /* full width/height is not likely to be imageable, but since we
         * don't know the limits we have to allow it
         */
        if (iw > wid) {
            iw = wid;
        }
        if (ih > hgt) {
            ih = hgt;
        }
        if ((ix + iw) > wid) {
            ix = wid - iw;
        }
        if ((iy + ih) > hgt) {
            iy = hgt - ih;
        }
        newPaper.setSize(wid, hgt);
        newPaper.setImageableArea(ix, iy, iw, ih);
    }
}
 
源代码9 项目: openjdk-jdk8u   文件: PSPrinterJob.java
protected double getPhysicalPageWidth(Paper p) {
    return p.getWidth();
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: RasterPrinterJob.java
/**
 * updates a Paper object to reflect the current printer's selected
 * paper size and imageable area for that paper size.
 * Default implementation copies settings from the original, applies
 * applies some validity checks, changes them only if they are
 * clearly unreasonable, then sets them into the new Paper.
 * Subclasses are expected to override this method to make more
 * informed decisons.
 */
protected void validatePaper(Paper origPaper, Paper newPaper) {
    if (origPaper == null || newPaper == null) {
        return;
    } else {
        double wid = origPaper.getWidth();
        double hgt = origPaper.getHeight();
        double ix = origPaper.getImageableX();
        double iy = origPaper.getImageableY();
        double iw = origPaper.getImageableWidth();
        double ih = origPaper.getImageableHeight();

        /* Assume any +ve values are legal. Overall paper dimensions
         * take precedence. Make sure imageable area fits on the paper.
         */
        Paper defaultPaper = new Paper();
        wid = ((wid > 0.0) ? wid : defaultPaper.getWidth());
        hgt = ((hgt > 0.0) ? hgt : defaultPaper.getHeight());
        ix = ((ix > 0.0) ? ix : defaultPaper.getImageableX());
        iy = ((iy > 0.0) ? iy : defaultPaper.getImageableY());
        iw = ((iw > 0.0) ? iw : defaultPaper.getImageableWidth());
        ih = ((ih > 0.0) ? ih : defaultPaper.getImageableHeight());
        /* full width/height is not likely to be imageable, but since we
         * don't know the limits we have to allow it
         */
        if (iw > wid) {
            iw = wid;
        }
        if (ih > hgt) {
            ih = hgt;
        }
        if ((ix + iw) > wid) {
            ix = wid - iw;
        }
        if ((iy + ih) > hgt) {
            iy = hgt - ih;
        }
        newPaper.setSize(wid, hgt);
        newPaper.setImageableArea(ix, iy, iw, ih);
    }
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: PSPrinterJob.java
protected double getPhysicalPageWidth(Paper p) {
    return p.getWidth();
}
 
源代码12 项目: jdk8u-dev-jdk   文件: PSPrinterJob.java
protected double getPhysicalPageWidth(Paper p) {
    return p.getWidth();
}
 
源代码13 项目: Bytecoder   文件: PSPrinterJob.java
protected double getPhysicalPageWidth(Paper p) {
    return p.getWidth();
}
 
源代码14 项目: openjdk-8   文件: RasterPrinterJob.java
/**
 * updates a Paper object to reflect the current printer's selected
 * paper size and imageable area for that paper size.
 * Default implementation copies settings from the original, applies
 * applies some validity checks, changes them only if they are
 * clearly unreasonable, then sets them into the new Paper.
 * Subclasses are expected to override this method to make more
 * informed decisons.
 */
protected void validatePaper(Paper origPaper, Paper newPaper) {
    if (origPaper == null || newPaper == null) {
        return;
    } else {
        double wid = origPaper.getWidth();
        double hgt = origPaper.getHeight();
        double ix = origPaper.getImageableX();
        double iy = origPaper.getImageableY();
        double iw = origPaper.getImageableWidth();
        double ih = origPaper.getImageableHeight();

        /* Assume any +ve values are legal. Overall paper dimensions
         * take precedence. Make sure imageable area fits on the paper.
         */
        Paper defaultPaper = new Paper();
        wid = ((wid > 0.0) ? wid : defaultPaper.getWidth());
        hgt = ((hgt > 0.0) ? hgt : defaultPaper.getHeight());
        ix = ((ix > 0.0) ? ix : defaultPaper.getImageableX());
        iy = ((iy > 0.0) ? iy : defaultPaper.getImageableY());
        iw = ((iw > 0.0) ? iw : defaultPaper.getImageableWidth());
        ih = ((ih > 0.0) ? ih : defaultPaper.getImageableHeight());
        /* full width/height is not likely to be imageable, but since we
         * don't know the limits we have to allow it
         */
        if (iw > wid) {
            iw = wid;
        }
        if (ih > hgt) {
            ih = hgt;
        }
        if ((ix + iw) > wid) {
            ix = wid - iw;
        }
        if ((iy + ih) > hgt) {
            iy = hgt - ih;
        }
        newPaper.setSize(wid, hgt);
        newPaper.setImageableArea(ix, iy, iw, ih);
    }
}
 
源代码15 项目: openjdk-jdk9   文件: PSPrinterJob.java
protected double getPhysicalPageWidth(Paper p) {
    return p.getWidth();
}
 
源代码16 项目: jdk8u-jdk   文件: RasterPrinterJob.java
/**
 * updates a Paper object to reflect the current printer's selected
 * paper size and imageable area for that paper size.
 * Default implementation copies settings from the original, applies
 * applies some validity checks, changes them only if they are
 * clearly unreasonable, then sets them into the new Paper.
 * Subclasses are expected to override this method to make more
 * informed decisons.
 */
protected void validatePaper(Paper origPaper, Paper newPaper) {
    if (origPaper == null || newPaper == null) {
        return;
    } else {
        double wid = origPaper.getWidth();
        double hgt = origPaper.getHeight();
        double ix = origPaper.getImageableX();
        double iy = origPaper.getImageableY();
        double iw = origPaper.getImageableWidth();
        double ih = origPaper.getImageableHeight();

        /* Assume any +ve values are legal. Overall paper dimensions
         * take precedence. Make sure imageable area fits on the paper.
         */
        Paper defaultPaper = new Paper();
        wid = ((wid > 0.0) ? wid : defaultPaper.getWidth());
        hgt = ((hgt > 0.0) ? hgt : defaultPaper.getHeight());
        ix = ((ix > 0.0) ? ix : defaultPaper.getImageableX());
        iy = ((iy > 0.0) ? iy : defaultPaper.getImageableY());
        iw = ((iw > 0.0) ? iw : defaultPaper.getImageableWidth());
        ih = ((ih > 0.0) ? ih : defaultPaper.getImageableHeight());
        /* full width/height is not likely to be imageable, but since we
         * don't know the limits we have to allow it
         */
        if (iw > wid) {
            iw = wid;
        }
        if (ih > hgt) {
            ih = hgt;
        }
        if ((ix + iw) > wid) {
            ix = wid - iw;
        }
        if ((iy + ih) > hgt) {
            iy = hgt - ih;
        }
        newPaper.setSize(wid, hgt);
        newPaper.setImageableArea(ix, iy, iw, ih);
    }
}
 
源代码17 项目: jdk8u-dev-jdk   文件: RasterPrinterJob.java
/**
 * updates a Paper object to reflect the current printer's selected
 * paper size and imageable area for that paper size.
 * Default implementation copies settings from the original, applies
 * applies some validity checks, changes them only if they are
 * clearly unreasonable, then sets them into the new Paper.
 * Subclasses are expected to override this method to make more
 * informed decisons.
 */
protected void validatePaper(Paper origPaper, Paper newPaper) {
    if (origPaper == null || newPaper == null) {
        return;
    } else {
        double wid = origPaper.getWidth();
        double hgt = origPaper.getHeight();
        double ix = origPaper.getImageableX();
        double iy = origPaper.getImageableY();
        double iw = origPaper.getImageableWidth();
        double ih = origPaper.getImageableHeight();

        /* Assume any +ve values are legal. Overall paper dimensions
         * take precedence. Make sure imageable area fits on the paper.
         */
        Paper defaultPaper = new Paper();
        wid = ((wid > 0.0) ? wid : defaultPaper.getWidth());
        hgt = ((hgt > 0.0) ? hgt : defaultPaper.getHeight());
        ix = ((ix > 0.0) ? ix : defaultPaper.getImageableX());
        iy = ((iy > 0.0) ? iy : defaultPaper.getImageableY());
        iw = ((iw > 0.0) ? iw : defaultPaper.getImageableWidth());
        ih = ((ih > 0.0) ? ih : defaultPaper.getImageableHeight());
        /* full width/height is not likely to be imageable, but since we
         * don't know the limits we have to allow it
         */
        if (iw > wid) {
            iw = wid;
        }
        if (ih > hgt) {
            ih = hgt;
        }
        if ((ix + iw) > wid) {
            ix = wid - iw;
        }
        if ((iy + ih) > hgt) {
            iy = hgt - ih;
        }
        newPaper.setSize(wid, hgt);
        newPaper.setImageableArea(ix, iy, iw, ih);
    }
}
 
源代码18 项目: pentaho-reporting   文件: StyleFileWriter.java
/**
 * Compiles a collection of page format properties.
 *
 * @param fmt
 *          the pageformat
 * @param retval
 *          the attribute list
 * @return The properties.
 */
private static AttributeList buildPageFormatProperties( final PageFormat fmt, final AttributeList retval ) {
  if ( fmt == null ) {
    throw new NullPointerException();
  }
  if ( retval == null ) {
    throw new NullPointerException();
  }

  final Paper paper = fmt.getPaper();
  final int w = (int) paper.getWidth();
  final int h = (int) paper.getHeight();

  final String pageDefinition = PageFormatFactory.getInstance().getPageFormatName( w, h );
  if ( pageDefinition != null ) {
    retval.setAttribute( BundleNamespaces.STYLE, "pageformat", pageDefinition );
  } else {
    retval.setAttribute( BundleNamespaces.STYLE, "width", String.valueOf( w ) );
    retval.setAttribute( BundleNamespaces.STYLE, "height", String.valueOf( h ) );
  }

  final Insets borders = getBorders( paper );

  if ( fmt.getOrientation() == PageFormat.REVERSE_LANDSCAPE ) {
    retval.setAttribute( BundleNamespaces.STYLE, "orientation", "reverse-landscape" );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-top", String.valueOf( borders.right ) );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-left", String.valueOf( borders.top ) );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-bottom", String.valueOf( borders.left ) );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-right", String.valueOf( borders.bottom ) );
  } else if ( fmt.getOrientation() == PageFormat.PORTRAIT ) {
    retval.setAttribute( BundleNamespaces.STYLE, "orientation", "portrait" );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-top", String.valueOf( borders.top ) );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-left", String.valueOf( borders.left ) );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-bottom", String.valueOf( borders.bottom ) );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-right", String.valueOf( borders.right ) );
  } else {
    retval.setAttribute( BundleNamespaces.STYLE, "orientation", "landscape" );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-top", String.valueOf( borders.left ) );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-left", String.valueOf( borders.bottom ) );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-bottom", String.valueOf( borders.right ) );
    retval.setAttribute( BundleNamespaces.STYLE, "margin-right", String.valueOf( borders.top ) );
  }

  return retval;
}
 
源代码19 项目: openjdk-8-source   文件: RasterPrinterJob.java
/**
 * updates a Paper object to reflect the current printer's selected
 * paper size and imageable area for that paper size.
 * Default implementation copies settings from the original, applies
 * applies some validity checks, changes them only if they are
 * clearly unreasonable, then sets them into the new Paper.
 * Subclasses are expected to override this method to make more
 * informed decisons.
 */
protected void validatePaper(Paper origPaper, Paper newPaper) {
    if (origPaper == null || newPaper == null) {
        return;
    } else {
        double wid = origPaper.getWidth();
        double hgt = origPaper.getHeight();
        double ix = origPaper.getImageableX();
        double iy = origPaper.getImageableY();
        double iw = origPaper.getImageableWidth();
        double ih = origPaper.getImageableHeight();

        /* Assume any +ve values are legal. Overall paper dimensions
         * take precedence. Make sure imageable area fits on the paper.
         */
        Paper defaultPaper = new Paper();
        wid = ((wid > 0.0) ? wid : defaultPaper.getWidth());
        hgt = ((hgt > 0.0) ? hgt : defaultPaper.getHeight());
        ix = ((ix > 0.0) ? ix : defaultPaper.getImageableX());
        iy = ((iy > 0.0) ? iy : defaultPaper.getImageableY());
        iw = ((iw > 0.0) ? iw : defaultPaper.getImageableWidth());
        ih = ((ih > 0.0) ? ih : defaultPaper.getImageableHeight());
        /* full width/height is not likely to be imageable, but since we
         * don't know the limits we have to allow it
         */
        if (iw > wid) {
            iw = wid;
        }
        if (ih > hgt) {
            ih = hgt;
        }
        if ((ix + iw) > wid) {
            ix = wid - iw;
        }
        if ((iy + ih) > hgt) {
            iy = hgt - ih;
        }
        newPaper.setSize(wid, hgt);
        newPaper.setImageableArea(ix, iy, iw, ih);
    }
}
 
源代码20 项目: pentaho-reporting   文件: PageFormatFactory.java
/**
 * Defines the imageable area of the given paper by adjusting the border around the imagable area. The bordersizes are
 * given in points.
 *
 * @param paper
 *          the paper that should be modified
 * @param top
 *          the bordersize of the top-border
 * @param left
 *          the border in points in the left
 * @param bottom
 *          the border in points in the bottom
 * @param right
 *          the border in points in the right
 */
public void setBorders( final Paper paper, final double top, final double left, final double bottom,
    final double right ) {
  final double w = paper.getWidth() - ( right + left );
  final double h = paper.getHeight() - ( bottom + top );
  paper.setImageableArea( left, top, w, h );
}