本文整理汇总了Java中javax.print.attribute.standard.MediaSize类的典型用法代码示例。如果您正苦于以下问题:Java MediaSize类的具体用法?Java MediaSize怎么用?Java MediaSize使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MediaSize类属于javax.print.attribute.standard包,在下文中一共展示了MediaSize类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findMatchingMediaSizeNameMM
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
public MediaSizeName findMatchingMediaSizeNameMM (float w, float h){
if (predefMedia != null) {
for (int k=0; k<predefMedia.length;k++) {
if (predefMedia[k] == null) {
continue;
}
if (isSameSize(predefMedia[k].getX(MediaSize.MM),
predefMedia[k].getY(MediaSize.MM),
w, h)) {
return predefMedia[k].getMediaSizeName();
}
}
}
return null;
}
示例2: getWin32MediaAttrib
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
/** MediaSizeName / dmPaper */
private final int[] getWin32MediaAttrib() {
int wid_ht[] = {0, 0};
if (attributes != null) {
Media media = (Media)attributes.get(Media.class);
if (media instanceof MediaSizeName) {
MediaSizeName msn = (MediaSizeName)media;
MediaSize ms = MediaSize.getMediaSizeForName(msn);
if (ms != null) {
wid_ht[0] = (int)(ms.getX(MediaSize.INCH) * 72.0);
wid_ht[1] = (int)(ms.getY(MediaSize.INCH) * 72.0);
}
}
}
return wid_ht;
}
示例3: getAllPrintableAreas
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
private MediaPrintableArea[] getAllPrintableAreas() {
if (mpas == null) {
Media[] media = (Media[])getSupportedAttributeValues(Media.class,
null, null);
mpas = new MediaPrintableArea[media.length];
for (int i=0; i< mpas.length; i++) {
if (media[i] instanceof MediaSizeName) {
MediaSizeName msn = (MediaSizeName)media[i];
MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
if (mediaSize == null) {
mpas[i] = (MediaPrintableArea)
getDefaultAttributeValue(MediaPrintableArea.class);
} else {
mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
mediaSize.getX(MediaSize.INCH)-0.5f,
mediaSize.getY(MediaSize.INCH)-0.5f,
MediaSize.INCH);
}
}
}
}
MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
return mpasCopy;
}
示例4: getWin32MediaAttrib
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
/** MediaSizeName / dmPaper */
private int[] getWin32MediaAttrib() {
int wid_ht[] = {0, 0};
if (attributes != null) {
Media media = (Media)attributes.get(Media.class);
if (media instanceof MediaSizeName) {
MediaSizeName msn = (MediaSizeName)media;
MediaSize ms = MediaSize.getMediaSizeForName(msn);
if (ms != null) {
wid_ht[0] = (int)(ms.getX(MediaSize.INCH) * 72.0);
wid_ht[1] = (int)(ms.getY(MediaSize.INCH) * 72.0);
}
}
}
return wid_ht;
}
示例5: doTest
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
private static void doTest() {
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(Chromaticity.MONOCHROME);
MediaSize isoA5Size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A5);
float[] size = isoA5Size.getSize(Size2DSyntax.INCH);
Paper paper = new Paper();
paper.setSize(size[0] * 72.0, size[1] * 72.0);
paper.setImageableArea(0.0, 0.0, size[0] * 72.0, size[1] * 72.0);
PageFormat pf = new PageFormat();
pf.setPaper(paper);
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(new WrongPaperPrintingTest(), job.validatePage(pf));
if (job.printDialog()) {
try {
job.print(aset);
} catch (PrinterException pe) {
throw new RuntimeException(pe);
}
}
}
示例6: CPaper
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
/**
* Constructor.
* Derive Paper from PageForamt
* @param pf PageFormat
*/
public CPaper (PageFormat pf)
{
super();
m_landscape = pf.getOrientation() != PageFormat.PORTRAIT;
// try to find MediaSize
float x = (float)pf.getWidth();
float y = (float)pf.getHeight();
MediaSizeName msn = MediaSize.findMedia (x/72, y/72, MediaSize.INCH);
MediaSize ms = null;
if (msn == null)
msn = MediaSize.findMedia (y/72, x/72, MediaSize.INCH); // flip it
if (msn != null)
ms = MediaSize.getMediaSizeForName(msn);
setMediaSize(ms, m_landscape);
// set size directly
setSize(pf.getWidth(), pf.getHeight());
setImageableArea(pf.getImageableX(), pf.getImageableY(),
pf.getImageableWidth(), pf.getImageableHeight());
}
示例7: toString
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
/**
* Get "nice" String Representation
* @param ctx context
* @return info
*/
public String toString (Properties ctx)
{
StringBuffer sb = new StringBuffer();
// Print Media size
//AA Goodwill : Custom Paper Support
if (m_mediaSize != null){
sb.append(m_mediaSize.getMediaSizeName());
// Print dimension
String name = m_mediaSize.getMediaSizeName().toString();
if (!name.startsWith("iso"))
sb.append(" - ").append(m_mediaSize.toString(MediaSize.INCH,"\""))
.append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.INCH,"\""));
if (!name.startsWith("na"))
sb.append(" - ").append(m_mediaSize.toString(MediaSize.MM,"mm"))
.append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.MM,"mm"));
// Print Orientation
sb.append(") - ")
.append(Msg.getMsg(ctx, m_landscape ? "Landscape" : "Portrait"));
}
else sb.append("Custom - ").append(toString());
//End Of AA Goodwill
return sb.toString();
}
示例8: createPrinterHWCalibration
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
public void createPrinterHWCalibration(final String printerName, final String mediaSizeName, final String trayName, final int calX, final int calY)
{
final I_AD_PrinterHW printer = getCreatePrinterHW(printerName);
final I_AD_PrinterHW_MediaSize mediaSize = printingDAO.newInstance(ctx, I_AD_PrinterHW_MediaSize.class, ITrx.TRXNAME_None);
mediaSize.setName(mediaSizeName);
mediaSize.setAD_PrinterHW(printer);
printingDAO.save(mediaSize);
final I_AD_PrinterHW_MediaTray mediaTray = getCreatePrinterTrayHW(printerName, trayName);
// created by 'getCreatePrinterHW(printerName)'
final I_AD_PrinterHW_MediaSize hwMediaSize = printingDAO.retrieveMediaSize(printer, MediaSize.ISO.A4, true);
final I_AD_PrinterHW_Calibration calibration = printingDAO.newInstance(ctx, I_AD_PrinterHW_Calibration.class, ITrx.TRXNAME_None);
calibration.setAD_PrinterHW(printer);
calibration.setAD_PrinterHW_MediaTray(mediaTray);
calibration.setAD_PrinterHW_MediaSize(hwMediaSize);
calibration.setCalX(calX);
calibration.setCalY(calY);
printingDAO.save(calibration);
}
示例9: getPaper
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
public Paper getPaper() {
final short size = getDmPaperSize(structPtr);
Paper p = StdPaper.getPaper(size);
if (p == null) {
final long fields = getDmFields();
if (((fields & DM_PAPERLENGTH) != 0)
&& ((fields & DM_PAPERWIDTH) != 0)) {
p = new CustomPaper(size, new MediaSize(
getDmPaperWidth(structPtr) / 10,
getDmPaperLength(structPtr) / 10,
Size2DSyntax.MM));
}
}
return p;
}
示例10: setAttribute
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
public void setAttribute(final Attribute attr) {
final Class<? extends Attribute> category = attr.getCategory();
if (OrientationRequested.class.equals(category)) {
setOrientation((OrientationRequested) attr);
} else if (MediaSize.class.equals(category)) {
setPaper((MediaSize) attr);
} else if (Media.class.equals(category)) {
setPaper((MediaSizeName) attr);
} else if (Paper.class.equals(category)) {
setPaper((Paper) attr);
} else if (Copies.class.equals(category)) {
setCopies((Copies) attr);
} else if (PrintQuality.class.equals(category)) {
setPrintQuality((PrintQuality) attr);
} else if (Sides.class.equals(category)) {
setSides((Sides) attr);
} else if (SheetCollate.class.equals(category)) {
setCollate((SheetCollate) attr);
} else if (PrinterResolution.class.equals(category)) {
setPrinterResolution((PrinterResolution) attr);
} else if (Chromaticity.class.equals(category)) {
setChromaticity((Chromaticity) attr);
}
}
示例11: getSupportedMediaSizeNames
import javax.print.attribute.standard.MediaSize; //导入依赖的package包/类
public static MediaSizeName[] getSupportedMediaSizeNames(final long handle)
throws PrintException {
final MediaSizeName[] names;
final int[] sizes = getSupportedPaperSizes(handle);
final Vector<MediaSizeName> v = new Vector<MediaSizeName>(
sizes.length / 2);
for (int i = 0; i < sizes.length; i += 2) {
if ((sizes[i] > 0) && (sizes[i + 1] > 0)) {
final MediaSizeName name = MediaSize.findMedia(sizes[i] / 10,
sizes[i + 1] / 10, Size2DSyntax.MM);
if ((name != null) && !v.contains(name)) {
v.add(name);
}
}
}
names = new MediaSizeName[v.size()];
return v.toArray(names);
}