public Set<PrintResolution> supportedPrintResolution() { if (resSet != null) { return resSet; } Set<PrintResolution> rSet = new TreeSet<PrintResolution>(PrintResolutionComparator.theComparator); PrinterResolution[] pr = null; try { pr = (PrinterResolution[]) service.getSupportedAttributeValues(PrinterResolution.class, null, null); } catch (Exception e) { } if (pr == null || pr.length == 0) { rSet.add(defaultPrintResolution()); } else { for (int i = 0; i < pr.length; i++) { int cfr = pr[i].getCrossFeedResolution(ResolutionSyntax.DPI); int fr = pr[i].getFeedResolution(ResolutionSyntax.DPI); rSet.add(PrintHelper.createPrintResolution(cfr, fr)); } } resSet = Collections.unmodifiableSet(rSet); return resSet; }
public PrintResolution defaultPrintResolution() { if (defRes != null) { return defRes; } PrinterResolution res = getDefaultPrinterResolution(); int cfr = res.getCrossFeedResolution(ResolutionSyntax.DPI); int fr = res.getFeedResolution(ResolutionSyntax.DPI); defRes = PrintHelper.createPrintResolution(cfr, fr); return defRes; }
private final synchronized PaperSource addPaperSource(MediaTray tray) { PaperSource source = preDefinedTrayMap.get(tray); if (source == null) { source = PrintHelper.createPaperSource(tray.toString()); } if (trayToSourceMap == null) { trayToSourceMap = new HashMap<MediaTray, PaperSource>(); } trayToSourceMap.put(tray, source); if (sourceToTrayMap == null) { sourceToTrayMap = new HashMap<PaperSource, MediaTray>(); } sourceToTrayMap.put(source, tray); return source; }
private final synchronized Paper addPaper(MediaSizeName media) { if (mediaToPaperMap == null) { mediaToPaperMap = new HashMap<MediaSizeName, Paper>(); } Paper paper = predefinedPaperMap.get(media); if (paper == null) { MediaSize sz = MediaSize.getMediaSizeForName(media); if (sz != null) { int mm = (int) ((25400 / 72.0) + 0.5); paper = PrintHelper.createPaper(media.toString(), sz.getX(mm), sz.getY(mm), Units.MM); } } if (paper == null) { paper = Paper.NA_LETTER; } mediaToPaperMap.put(media, paper); return paper; }
/* * Since JobSettings are mutable, this always returns * a new instance. */ public JobSettings getDefaultJobSettings() { return PrintHelper.createJobSettings(fxPrinter); }