Exemplo n.º 1
0
  private static void exportScreenshotEpsGraphics(
      Component target, File selectedFile, boolean paintOffscreen) throws IOException {

    if (!SnapshotUtilities.canExportScreenshotEps()) {
      String msg =
          "ERROR: EPS output requires EPSGraphics library. See https://www.broadinstitute.org/software/igv/third_party_tools#epsgraphics";
      log.error(msg);
      return;
    }

    Graphics2D g = null;
    FileOutputStream fos = null;
    try {
      Class colorModeClass = RuntimeUtils.loadClassForName(EPSColorModeClassName, null);
      Class graphicsClass = RuntimeUtils.loadClassForName(EPSClassName, null);

      Constructor constructor =
          graphicsClass.getConstructor(
              String.class,
              OutputStream.class,
              int.class,
              int.class,
              int.class,
              int.class,
              colorModeClass);

      Object colorModeValue = Enum.valueOf(colorModeClass, "COLOR_RGB");

      // EpsGraphics stores directly in a file
      fos = new FileOutputStream(selectedFile);
      g =
          (Graphics2D)
              constructor.newInstance(
                  "eps", fos, 0, 0, target.getWidth(), target.getHeight(), colorModeValue);

      choosePaint(target, g, paintOffscreen);

      graphicsClass.getMethod("close").invoke(g);

    } catch (Exception e) {
      log.error(e.getMessage(), e);
    } finally {
      if (fos != null) {
        fos.flush();
        fos.close();
      }
    }
  }
Exemplo n.º 2
0
 private static String writeFileBytes(String path, byte[] data) {
   try {
     if (data.length>=524288 && !path.endsWith("JmolApplet.jar") ){ //gzip it
       path += ".gz";
       GZIPOutputStream gzFile = new GZIPOutputStream(new FileOutputStream(path));
       gzFile.write(data);
       LogPanel.log("      ..." + GT._("compressing large data file to") + "\n");
       gzFile.flush();
       gzFile.close();
     } else {
       FileOutputStream os = new FileOutputStream(path);
       os.write(data);
       os.flush();
       os.close();
     }
   } catch (IOException e) {
     LogPanel.log(e.getMessage());
   }
   return path;
 }