本文整理汇总了Java中javax.print.attribute.standard.MediaSize.MM属性的典型用法代码示例。如果您正苦于以下问题:Java MediaSize.MM属性的具体用法?Java MediaSize.MM怎么用?Java MediaSize.MM使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.print.attribute.standard.MediaSize
的用法示例。
在下文中一共展示了MediaSize.MM属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: savePrinterProperties
/**
* Utility that tries to save the state of the currently set MediaSize.
* The width height and unit values are written to the the propertiesManager.
* When the Viewer RI is exited the properites file is wrtten to disk.
*
* @param printHelper instance of the open documents print helper.
*/
private void savePrinterProperties(PrintHelper printHelper) {
PrintRequestAttributeSet printRequestAttributeSet =
printHelper.getPrintRequestAttributeSet();
Object printAttributeSet = printRequestAttributeSet.get(Media.class);
if (propertiesManager != null &&
printAttributeSet instanceof MediaSizeName) {
MediaSizeName paper = (MediaSizeName) printAttributeSet;
MediaSize mediaSize = MediaSize.getMediaSizeForName(paper);
// write out the new page size property values.
int printMediaUnit = MediaSize.MM;
propertiesManager.set(
PropertiesManager.PROPERTY_PRINT_MEDIA_SIZE_UNIT,
String.valueOf(printMediaUnit));
double printMediaWidth = mediaSize.getX(printMediaUnit);
propertiesManager.set(
PropertiesManager.PROPERTY_PRINT_MEDIA_SIZE_WIDTH,
String.valueOf(printMediaWidth));
double printMediaHeight = mediaSize.getY(printMediaUnit);
propertiesManager.set(
PropertiesManager.PROPERTY_PRINT_MEDIA_SIZE_HEIGHT,
String.valueOf(printMediaHeight));
}
}
示例2: main
public static void main(String args[]) {
MediaSize sizeA = MediaSize.getMediaSizeForName(MediaSizeName.A);
new MediaSize(1.0f, 2.0f, MediaSize.MM, MediaSizeName.A);
if (!sizeA.equals(MediaSize.getMediaSizeForName(MediaSizeName.A))) {
throw new RuntimeException("mapping changed");
}
MediaSize sizeB = MediaSize.getMediaSizeForName(MediaSizeName.B);
new MediaSize(1, 2, MediaSize.MM, MediaSizeName.B);
if (!sizeB.equals(MediaSize.getMediaSizeForName(MediaSizeName.B))) {
throw new RuntimeException("mapping changed");
}
}