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


Java Paper.getImageableWidth方法代碼示例

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


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

示例1: testGetPageFormat

import java.awt.print.Paper; //導入方法依賴的package包/類
public void testGetPageFormat() {
    PrinterJob pj = PrinterJob.getPrinterJob();
    PageFormat expResult = PrintPreferences.getPageFormat(pj);
    PrintPreferences.setPageFormat(expResult);
    PageFormat result = PrintPreferences.getPageFormat(pj);
    assertEquals(expResult.getHeight(), result.getHeight());
    assertEquals(expResult.getWidth(), result.getWidth());
    assertEquals(expResult.getOrientation(), result.getOrientation());
    assertEquals(expResult.getPaper().getHeight(), result.getPaper().getHeight());
    assertEquals(expResult.getPaper().getWidth(), result.getPaper().getWidth());
    assertEquals(expResult.getPaper().getImageableHeight(), result.getPaper().getImageableHeight());
    assertEquals(expResult.getPaper().getImageableWidth(), result.getPaper().getImageableWidth());
    assertEquals(expResult.getPaper().getImageableX(), result.getPaper().getImageableX());
    assertEquals(expResult.getPaper().getImageableY(), result.getPaper().getImageableY());
    
    double w = expResult.getPaper().getWidth() + 10;
    double h = expResult.getPaper().getHeight() + 10;
    Paper p = expResult.getPaper();
    double ix = p.getImageableX() + 10;
    double iy = p.getImageableY() + 10;
    double iw = p.getImageableWidth() + 10;
    double ih = p.getImageableHeight() + 10;
    p.setImageableArea(ix, iy, iw, ih);
    p.setSize(w, h);
    expResult.setPaper(p);
    PrintPreferences.setPageFormat(expResult);
    assertEquals(h, PrintPreferences.getPageFormat(pj).getHeight());
    assertEquals(w, PrintPreferences.getPageFormat(pj).getWidth());
    assertEquals(ix, PrintPreferences.getPageFormat(pj).getPaper().getImageableX());
    assertEquals(iy, PrintPreferences.getPageFormat(pj).getPaper().getImageableY());
    assertEquals(iw, PrintPreferences.getPageFormat(pj).getPaper().getImageableWidth());
    assertEquals(ih, PrintPreferences.getPageFormat(pj).getPaper().getImageableHeight());
    
    expResult.setOrientation(PageFormat.REVERSE_LANDSCAPE);
    PrintPreferences.setPageFormat(expResult);
    assertEquals(PageFormat.REVERSE_LANDSCAPE, PrintPreferences.getPageFormat(pj).getOrientation());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:PrintPreferencesTest.java

示例2: updateController

import java.awt.print.Paper; //導入方法依賴的package包/類
/**
 * Updates controller print attributes.
 */
public void updateController(PageSetupController controller)
{
	// Return an HomePrint instance matching returnedPageFormat
	HomePrint.PaperOrientation paperOrientation;
	switch (this.pageFormat.getOrientation())
	{
		case PageFormat.LANDSCAPE:
			paperOrientation = HomePrint.PaperOrientation.LANDSCAPE;
			break;
		case PageFormat.REVERSE_LANDSCAPE:
			paperOrientation = HomePrint.PaperOrientation.REVERSE_LANDSCAPE;
			break;
		default:
			paperOrientation = HomePrint.PaperOrientation.PORTRAIT;
			break;
	}
	Paper paper = this.pageFormat.getPaper();
	HomePrint homePrint = new HomePrint(paperOrientation, (float) paper.getWidth(), (float) paper.getHeight(),
			(float) paper.getImageableY(), (float) paper.getImageableX(),
			(float) (paper.getHeight() - paper.getImageableHeight() - paper.getImageableY()),
			(float) (paper.getWidth() - paper.getImageableWidth() - paper.getImageableX()),
			this.furniturePrintedCheckBox.isSelected(), this.planPrintedCheckBox.isSelected(),
			this.view3DPrintedCheckBox.isSelected(),
			this.userPlanScaleRadioButton.isSelected() && this.userPlanScaleSpinner.getValue() != null
					? 1f / ((Number) this.userPlanScaleSpinner.getValue()).intValue() : null,
			this.headerFormatTextField.getText().trim(), this.footerFormatTextField.getText().trim());
	controller.setPrint(homePrint);
}
 
開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:32,代碼來源:PageSetupPanel.java

示例3: getPageFormatAsString

import java.awt.print.Paper; //導入方法依賴的package包/類
/**
 * @param pPageFormat
 * @return
 */
public static String getPageFormatAsString(Paper pPaper) {
	return pPaper.getWidth() + ";" + pPaper.getHeight() + ";"
			+ pPaper.getImageableX() + ";" + pPaper.getImageableY() + ";"
			+ pPaper.getImageableWidth() + ";"
			+ pPaper.getImageableHeight();
}
 
開發者ID:iwabuchiken,項目名稱:freemind_1.0.0_20140624_214725,代碼行數:11,代碼來源:Tools.java

示例4: validatePaper

import java.awt.print.Paper; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:50,代碼來源:RasterPrinterJob.java

示例5: getPhysicalPrintableWidth

import java.awt.print.Paper; //導入方法依賴的package包/類
protected double getPhysicalPrintableWidth(Paper p) {
    return p.getImageableWidth();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:PSPrinterJob.java


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