Exemple #1
0
  // {{{ getPrintJob() method
  private static PrinterJob getPrintJob(String jobName) {
    job = PrinterJob.getPrinterJob();

    format = new HashPrintRequestAttributeSet();

    String settings = jEdit.getSettingsDirectory();
    if (settings != null) {
      String printSpecPath = MiscUtilities.constructPath(settings, "printspec");
      File filePrintSpec = new File(printSpecPath);

      if (filePrintSpec.exists()) {
        try {
          FileInputStream fileIn = new FileInputStream(filePrintSpec);
          ObjectInputStream obIn = new ObjectInputStream(fileIn);
          format = (HashPrintRequestAttributeSet) obIn.readObject();
        } catch (Exception e) {
          Log.log(Log.ERROR, BufferPrinter1_4.class, e);
        }
        // for backwards compatibility, the color variable is stored also as a property
        if (jEdit.getBooleanProperty("print.color")) format.add(Chromaticity.COLOR);
        else format.add(Chromaticity.MONOCHROME);

        // no need to always keep the same job name for every printout.
        format.add(new JobName(jobName, null));
      }
    }

    return job;
  } // }}}
Exemple #2
0
  // {{{ savePrintSpec() method
  private static void savePrintSpec() {
    String settings = jEdit.getSettingsDirectory();
    if (settings == null) return;

    String printSpecPath = MiscUtilities.constructPath(settings, "printspec");
    File filePrintSpec = new File(printSpecPath);

    try {
      FileOutputStream fileOut = new FileOutputStream(filePrintSpec);
      ObjectOutputStream obOut = new ObjectOutputStream(fileOut);
      obOut.writeObject(format);
      // for backwards compatibility, the color variable is stored also as a property
      Chromaticity cc = (Chromaticity) format.get(Chromaticity.class);
      if (cc != null)
        jEdit.setBooleanProperty("print.color", cc.getValue() == Chromaticity.COLOR.getValue());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }