Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
  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;
  }
Ejemplo n.º 4
0
  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;
  }
Ejemplo n.º 5
0
 /*
  * Since JobSettings are mutable, this always returns
  * a new instance.
  */
 public JobSettings getDefaultJobSettings() {
   return PrintHelper.createJobSettings(fxPrinter);
 }