本文整理汇总了Java中javax.print.attribute.standard.PrinterResolution.DPI属性的典型用法代码示例。如果您正苦于以下问题:Java PrinterResolution.DPI属性的具体用法?Java PrinterResolution.DPI怎么用?Java PrinterResolution.DPI使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.print.attribute.standard.PrinterResolution
的用法示例。
在下文中一共展示了PrinterResolution.DPI属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setResolutionDPI
private final void setResolutionDPI(int xres, int yres) {
if (attributes != null) {
PrinterResolution res =
new PrinterResolution(xres, yres, PrinterResolution.DPI);
attributes.add(res);
}
mAttXRes = xres;
mAttYRes = yres;
}
示例2: setResolutionDPI
private void setResolutionDPI(int xres, int yres) {
if (attributes != null) {
PrinterResolution res =
new PrinterResolution(xres, yres, PrinterResolution.DPI);
attributes.add(res);
}
mAttXRes = xres;
mAttYRes = yres;
}
示例3: getSupportedAttributeValues
public Object getSupportedAttributeValues(Class category, DocFlavor flavor,
AttributeSet attributes) {
if (flavor != null &&
(flavor.equals(DocFlavor.INPUT_STREAM.AUTOSENSE) ||
flavor.equals(DocFlavor.BYTE_ARRAY.AUTOSENSE) ||
flavor.equals(DocFlavor.URL.AUTOSENSE) ||
flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT) ||
flavor.equals(DocFlavor.URL.POSTSCRIPT))) {
return null;
}
if (category.equals(Copies.class)) {
int copies = getCopiesSupported(serviceName);
if (copies == 1) {
return new CopiesSupported(1);
} else if (copies > 1) {
return new CopiesSupported(1, copies);
}
} else if (category.equals(Sides.class)) {
if (getSidesSupported(serviceName)) {
return new Sides[] {Sides.ONE_SIDED,
Sides.TWO_SIDED_SHORT_EDGE,
Sides.TWO_SIDED_LONG_EDGE,
Sides.DUPLEX,
Sides.TUMBLE};
}
} else if (category.equals(Media.class)) {
return getSupportedMediaSizeNames();
} else if (category.equals(MediaSizeName.class)) {
return getSupportedMediaSizeNames();
} else if (category.equals(Chromaticity.class)) {
if (getColorSupported(serviceName)) {
return new Chromaticity[] { Chromaticity.MONOCHROME,
Chromaticity.COLOR };
} else {
return new Chromaticity[] { Chromaticity.MONOCHROME };
}
} else if (category.equals(OrientationRequested.class)) {
if (getOrientationSupported(serviceName)) {
return new OrientationRequested[]
{ OrientationRequested.PORTRAIT,
OrientationRequested.LANDSCAPE };
}
} else if (category.equals(PrinterResolution.class)) {
int[] resolutions = getResolutionsSupported(serviceName);
if (resolutions != null && resolutions.length > 1) {
PrinterResolution[] res =
new PrinterResolution[resolutions.length / 2];
for (int i = 0; i < resolutions.length / 2; i++) {
res[i] = new PrinterResolution(resolutions[i * 2],
resolutions[i * 2 + 1], PrinterResolution.DPI);
}
return res;
}
} else if (category.equals(SheetCollate.class)) {
if (getCollateSupported(serviceName)) {
return new SheetCollate[] { SheetCollate.COLLATED,
SheetCollate.UNCOLLATED };
}
}
return null;
}
示例4: printOnVVPAT
/**
* Prints onto the attached VVPAT printer, if possible.
*
* @param toPrint the Printable to print.
*/
public boolean printOnVVPAT(Printable toPrint){
/* Check in case VVPAT not ready */
if (_constants.getPrinterForVVPAT().equals("")) return false;
PrintService[] printers = PrinterJob.lookupPrintServices();
PrintService vvpat = null;
/* Check the printer list */
for (PrintService printer : printers) {
PrinterName name = printer.getAttribute(PrinterName.class);
/* When the correct printer name is found, set it as the printer */
if(name.getValue().equals(_constants.getPrinterForVVPAT())) {
vvpat = printer;
break;
}
}
/* Error if the printer could not be found/set */
if(vvpat == null){
Bugout.msg("VVPAT is configured, but not detected as ready.");
return false;
}
/* Printer job housekeeping */
PrinterJob job = PrinterJob.getPrinterJob();
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PrinterResolution pr = new PrinterResolution(300, 300, PrinterResolution.DPI);
aset.add(pr);
aset.add(PrintQuality.HIGH);
/* Try to format and print the page */
try {
PageFormat pf = job.getPageFormat(aset);
Paper paper = pf.getPaper();
/* Set the printer for the job */
job.setPrintService(vvpat) ;
/* Send the paper the dimensions */
paper.setSize(_constants.getPaperWidthForVVPAT(), _constants.getPaperHeightForVVPAT());
/* Info for imageable area */
int imageableWidth = _constants.getPrintableWidthForVVPAT();
int imageableHeight = _constants.getPrintableHeightForVVPAT();
int leftInset = (_constants.getPaperWidthForVVPAT() - _constants.getPrintableWidthForVVPAT()) / 2;
int topInset = (_constants.getPaperHeightForVVPAT() - _constants.getPrintableHeightForVVPAT()) / 2;
/* Set the imageable area beased on _constants */
paper.setImageableArea(leftInset, topInset, imageableWidth, imageableHeight);
/* Set the paper for the PageFormat*/
pf.setPaper(paper);
/* Send the printable to print to the paper */
job.setPrintable(toPrint, pf);
/* Print the page */
job.print();
}
catch (PrinterException e) { Bugout.err("VVPAT printing failed: " + e.getMessage()); return false; }
return true;
}