// TODO: HACK because of Java7 required:
 // replace later with window.setType(Window.Type.POPUP)
 private static void setPopupType(@NotNull Window window) {
   //noinspection ConstantConditions,ConstantAssertCondition
   assert USE_REFLECTION_TO_ACCESS_JDK7;
   try {
     @SuppressWarnings("unchecked")
     Class<? extends Enum> type = (Class<? extends Enum>) Class.forName("java.awt.Window$Type");
     Object value = Enum.valueOf(type, "POPUP");
     Window.class.getMethod("setType", type).invoke(window, value);
   } catch (Exception ignored) {
   }
 }
Exemple #2
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();
      }
    }
  }
 /** Parses the {@link TimeScale} from the query parameter. */
 public static TimeScale parse(String type) {
   if (type == null) return TimeScale.MIN;
   return Enum.valueOf(TimeScale.class, type.toUpperCase(Locale.ENGLISH));
 }