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; }