本文整理汇总了Java中java.awt.print.Paper.getImageableX方法的典型用法代码示例。如果您正苦于以下问题:Java Paper.getImageableX方法的具体用法?Java Paper.getImageableX怎么用?Java Paper.getImageableX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.print.Paper
的用法示例。
在下文中一共展示了Paper.getImageableX方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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);
}
示例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();
}
示例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);
}
}