當前位置: 首頁>>代碼示例>>Java>>正文


Java PageFormat.getHeight方法代碼示例

本文整理匯總了Java中java.awt.print.PageFormat.getHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java PageFormat.getHeight方法的具體用法?Java PageFormat.getHeight怎麽用?Java PageFormat.getHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.print.PageFormat的用法示例。


在下文中一共展示了PageFormat.getHeight方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPageSize

import java.awt.print.PageFormat; //導入方法依賴的package包/類
public Dimension2D getPageSize() {
    int pageCount = printable.getPageCount();
    double pageWidth = 0;
    double pageHeight = 0;
    PageFormat pageFormat = new PageFormat();
    for (int i = 0; i < pageCount; i++) {
        pageFormat = printable.getPageFormat(pageFormat, i);
        double w = pageFormat.getWidth();
        double h = pageFormat.getHeight();

        if (pageWidth < w)
            pageWidth = w;
        if (pageHeight < h)
            pageHeight = h;
    }

    final double fw = pageWidth;
    final double fh = pageHeight;
    return new Dimension2D() {

        @Override
        public void setSize(double width, double height) {
        }

        @Override
        public double getWidth() {
            return fw;
        }

        @Override
        public double getHeight() {
            return fh;
        }
    };
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:36,代碼來源:PrintPreviewComponent.java

示例2: setSize

import java.awt.print.PageFormat; //導入方法依賴的package包/類
private void setSize() {
     int pageCount = printable.getPageCount();
     rowCount = (pageCount - 1) / columnCount + 1;
     pageWidth = 0;
     pageHeight = 0;
     pages = new Page[pageCount];
     PageFormat pageFormat = printable.getPageFormat();
     for (int i = 0; i < pageCount; i++) {
         pageFormat = printable.getPageFormat(pageFormat, i);
         double w = pageFormat.getWidth() + 1;
         double h = pageFormat.getHeight() + 1;
         double iW = pageFormat.getImageableWidth();
         double iH = pageFormat.getImageableHeight();
         double x = pageFormat.getImageableX();
         double y = pageFormat.getImageableY();

         reverce = (pageFormat.getOrientation() == PageFormat.REVERSE_LANDSCAPE);

/*
          * if (pageFormat.getOrientation() == PageFormat.LANDSCAPE) { double
 * t;
 * 
 * t = w; w = h; h = t;
 * 
 * t = iW; iW = iH; iH = t;
 * 
 * t = x; x = y; y = t; }
 */

         Page page = new Page(w, h, x, y, iW, iH);

         if (pageWidth < w)
             pageWidth = w;
         if (pageHeight < h)
             pageHeight = h;
         pages[i] = page;
     }
     width = (columnCount - 1) * (pageWidth + W_SPACE / zoom) + pageWidth;
     height = rowCount * (pageHeight + W_SPACE / zoom);
     Dimension size = new Dimension((int) (width * getZoom()),
             (int) (height * getZoom()));
     this.setSize(size);
     this.setPreferredSize(size);
 }
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:45,代碼來源:PrintPreviewComponent.java


注:本文中的java.awt.print.PageFormat.getHeight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。