本文整理汇总了Java中javax.print.attribute.standard.Copies类的典型用法代码示例。如果您正苦于以下问题:Java Copies类的具体用法?Java Copies怎么用?Java Copies使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Copies类属于javax.print.attribute.standard包,在下文中一共展示了Copies类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRangeCopiesAttribute
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
private final void setRangeCopiesAttribute(int from, int to,
boolean isRangeSet,
int copies) {
if (attributes != null) {
if (isRangeSet) {
attributes.add(new PageRanges(from, to));
setPageRange(from, to);
}
defaultCopies = false;
attributes.add(new Copies(copies));
/* Since this is called from native to tell Java to sync
* up with native, we don't call this class's own setCopies()
* method which is mainly to send the value down to native
*/
super.setCopies(copies);
mAttCopies = copies;
}
}
示例2: printWithoutPrintDialog
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
private static void printWithoutPrintDialog() {
final JTable table = createAuthorTable(42);
PrintRequestAttributeSet pras
= new HashPrintRequestAttributeSet();
pras.add(new Copies(1));
try {
boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH,
new MessageFormat("Author Table"),
new MessageFormat("Page - {0}"),
false, pras, false);
closeFrame();
if (!printAccepted) {
throw new RuntimeException("User cancels the printer job!");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: setRangeCopiesAttribute
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
private void setRangeCopiesAttribute(int from, int to, boolean isRangeSet,
int copies) {
if (attributes != null) {
if (isRangeSet) {
attributes.add(new PageRanges(from, to));
setPageRange(from, to);
}
defaultCopies = false;
attributes.add(new Copies(copies));
/* Since this is called from native to tell Java to sync
* up with native, we don't call this class's own setCopies()
* method which is mainly to send the value down to native
*/
super.setCopies(copies);
mAttCopies = copies;
}
}
示例4: printWithoutPrintDialog
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
private static void printWithoutPrintDialog() {
final JTable table = createAuthorTable(50);
PrintRequestAttributeSet pras
= new HashPrintRequestAttributeSet();
pras.add(new Copies(1));
try {
boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH,
new MessageFormat("Author Table"),
new MessageFormat("Page - {0}"),
false, pras, false);
closeFrame();
if (!printAccepted) {
throw new RuntimeException("User cancels the printer job!");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例5: actionPerformed
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e)
{
try {
if (selectedDriver == null)
return;
PrintService ps = (PrintService)printers.getSelectedItem();
PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
attr.add(new Copies(1));
attr.add((Media)ps.getDefaultAttributeValue(Media.class)); // set to default paper from printer
attr.add(OrientationRequested.LANDSCAPE);
SimpleDoc doc = new SimpleDoc(activeLabel, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
ps.createPrintJob().print(doc, attr);
} catch (PrintException ex) {
log.log(Level.SEVERE, "\bBarcode print failed: " + ex.getMessage(), ex);
}
}
示例6: imprimir
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
public boolean imprimir(boolean bMonta) {
if (bMonta)
montaG();
boolean bRet = false;
PrinterJob printJob = PrinterJob.getPrinterJob();
PrintRequestAttributeSet aset = Funcoes.getImpAtrib();
if (printJob.printDialog(aset)) {
try {
printJob.setPrintable(this, new PaginaPad(printJob.defaultPage().getPaper()));
printJob.print(aset);
aset.remove(Copies.class);
Funcoes.setImpAtrib(aset);
bRet = true;
}
catch (Exception ex) {
ex.printStackTrace();
}
}
return bRet;
}
示例7: assignPrintAttributes
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
private PrintRequestAttributeSet assignPrintAttributes() throws PrintException {
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
if (config.getCopies() >= 1) {
printRequestAttributeSet.add(new Copies(config.getCopies()));
} else {
throw new PrintException("Number of print copies should be greater than zero");
}
printRequestAttributeSet.add(config.getMediaSizeName());
printRequestAttributeSet.add(config.getInternalSides());
printRequestAttributeSet.add(config.getInternalOrientation());
if (config.getMediaTray() != null) {
MediaTray mediaTray = resolveMediaTray(config.getMediaTray());
if (mediaTray == null) {
throw new PrintException("mediatray not found " + config.getMediaTray());
}
printRequestAttributeSet.add(mediaTray);
}
return printRequestAttributeSet;
}
示例8: print
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
/**
* Print (async)
* @param printerName optional printer name
* @param jobName optional printer job name
* @param pageable pageable
* @param copies number of copies
* @param withDialog if true, shows printer dialog
*/
static public void print (Pageable pageable, String printerName, String jobName,
int copies, boolean withDialog)
{
if (pageable == null)
return;
String name = "Adempiere_";
if (jobName != null)
name += jobName;
//
PrinterJob job = CPrinter.getPrinterJob(printerName);
job.setJobName (name);
job.setPageable (pageable);
// Attributes
HashPrintRequestAttributeSet prats = new HashPrintRequestAttributeSet();
prats.add(new Copies(copies));
// Set Orientation
if (pageable.getPageFormat(0).getOrientation() == PageFormat.PORTRAIT)
prats.add(OrientationRequested.PORTRAIT);
else
prats.add(OrientationRequested.LANDSCAPE);
prats.add(new JobName(name, Language.getLoginLanguage().getLocale()));
prats.add(getJobPriority(pageable.getNumberOfPages(), copies, withDialog));
//
print (job, prats, withDialog, false);
}
示例9: setRangeCopiesAttribute
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
private final void setRangeCopiesAttribute(int from, int to,
boolean isRangeSet,
int copies) {
if (attributes != null) {
if (isRangeSet) {
attributes.add(new PageRanges(from, to));
setPageRange(from, to);
}
attributes.add(new Copies(copies));
/* Since this is called from native to tell Java to sync
* up with native, we don't call this class's own setCopies()
* method which is mainly to send the value down to native
*/
super.setCopies(copies);
mAttCopies = copies;
}
}
示例10: setAttribute
import javax.print.attribute.standard.Copies; //导入依赖的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: getDefaultAttributeValue
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
public Object getDefaultAttributeValue(Class category) {
if (category.equals(JobName.class)) {
return new JobName("Java GDI client print job", Locale.US);
} else if (category.equals(RequestingUserName.class)) {
return new RequestingUserName(System.getProperty("user.name"),
Locale.US);
} else if (category.equals(Destination.class)) {
File file = new File(System.getProperty("user.dir") +
File.separator + "output.prn");
return new Destination(file.toURI());
} else if (category.equals(SheetCollate.class)) {
return SheetCollate.COLLATED;
} else if (category.equals(Copies.class)) {
return new Copies(1);
}
return null;
}
示例12: print
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
public static void print(File file, int copies, PrintService ps) {
logger.debug("print start - " + file);
try {
try (PDDocument document = PDDocument.load(file)) {
MediaSizeName size = getMediaSizeName(document);
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintService(ps);
job.setPageable(new PDFPageable(document));
PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
attr.add(size);
attr.add(new Copies(copies));
attr.add(new JobName(file.getName(), null));
PageFormat pf = job.getPageFormat(attr);
Paper paper = pf.getPaper();
paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
pf.setPaper(paper);
job.print(attr);
}
} catch (IOException | PrinterException ex) {
logger.warn(ex, ex);
}
logger.debug("print end - " + file);
}
示例13: isSupportedCopies
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
private boolean isSupportedCopies(Copies copies) {
synchronized (this) {
if (gotCopies == false) {
nCopies = getCopiesSupported(printer, getPort());
gotCopies = true;
}
}
int numCopies = copies.getValue();
return (numCopies > 0 && numCopies <= nCopies);
}
示例14: isPSDocAttr
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
private boolean isPSDocAttr(Class category) {
if (category == OrientationRequested.class || category == Copies.class) {
return true;
}
else {
return false;
}
}
示例15: pageableJob
import javax.print.attribute.standard.Copies; //导入依赖的package包/类
public void pageableJob(Pageable pageable) throws PrintException {
try {
synchronized(this) {
if (job != null) { // shouldn't happen
throw new PrintException("already printing");
} else {
job = new sun.awt.windows.WPrinterJob();
}
}
PrintService svc = getPrintService();
job.setPrintService(svc);
if (copies == 0) {
Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class);
copies = c.getValue();
}
job.setCopies(copies);
job.setJobName(jobName);
job.setPageable(pageable);
job.print(reqAttrSet);
notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
return;
} catch (PrinterException pe) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(pe);
} finally {
printReturned = true;
notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
}
}