Ejemplo n.º 1
0
 /** @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */
 public int compare(DisplayMode a, DisplayMode b) {
   // Width
   if (a.getWidth() != b.getWidth()) return (a.getWidth() > b.getWidth()) ? 1 : -1;
   // Height
   if (a.getHeight() != b.getHeight()) return (a.getHeight() > b.getHeight()) ? 1 : -1;
   // Bit depth
   if (a.getBitDepth() != b.getBitDepth()) return (a.getBitDepth() > b.getBitDepth()) ? 1 : -1;
   // Refresh rate
   if (a.getRefreshRate() != b.getRefreshRate())
     return (a.getRefreshRate() > b.getRefreshRate()) ? 1 : -1;
   // All fields are equal
   return 0;
 }
Ejemplo n.º 2
0
 DisplayMode findmode(int w, int h) {
   GraphicsDevice dev = getGraphicsConfiguration().getDevice();
   if (!dev.isFullScreenSupported()) return (null);
   DisplayMode b = null;
   for (DisplayMode m : dev.getDisplayModes()) {
     int d = m.getBitDepth();
     if ((m.getWidth() == w)
         && (m.getHeight() == h)
         && ((d == 24) || (d == 32) || (d == DisplayMode.BIT_DEPTH_MULTI))) {
       if ((b == null)
           || (d > b.getBitDepth())
           || ((d == b.getBitDepth()) && (m.getRefreshRate() > b.getRefreshRate()))) b = m;
     }
   }
   return (b);
 }
Ejemplo n.º 3
0
  public static DisplayMode[] getDisplayModes() {
    GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = genv.getDefaultScreenDevice();
    java.awt.DisplayMode desktopMode = device.getDisplayMode();
    java.awt.DisplayMode[] displayModes = device.getDisplayModes();
    ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>();
    int idx = 0;
    for (java.awt.DisplayMode mode : displayModes) {
      boolean duplicate = false;
      for (int i = 0; i < modes.size(); i++) {
        if (modes.get(i).width == mode.getWidth()
            && modes.get(i).height == mode.getHeight()
            && modes.get(i).bitsPerPixel == mode.getBitDepth()) {
          duplicate = true;
          break;
        }
      }
      if (duplicate) continue;
      if (mode.getBitDepth() != desktopMode.getBitDepth()) continue;
      modes.add(
          new LwjglApplicationConfigurationDisplayMode(
              mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth()));
    }

    return modes.toArray(new DisplayMode[modes.size()]);
  }
Ejemplo n.º 4
0
 public static DisplayMode getDesktopDisplayMode() {
   GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsDevice device = genv.getDefaultScreenDevice();
   java.awt.DisplayMode mode = device.getDisplayMode();
   return new LwjglApplicationConfigurationDisplayMode(
       mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth());
 }
Ejemplo n.º 5
0
  /**
   * Retorna si 2 modos son iguales.
   *
   * @param mode1
   * @param mode2
   * @return True en caso de que ambos sean iguales.
   */
  private boolean sonIguales(DisplayMode mode1, DisplayMode mode2) {
    if (mode1.getWidth() != mode2.getWidth() || mode1.getHeight() != mode2.getHeight()) {
      return false;
    }

    if (mode1.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI
        && mode2.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI
        && mode1.getBitDepth() != mode2.getBitDepth()) {
      return false;
    }

    if (mode1.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN
        && mode2.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN
        && mode1.getRefreshRate() != mode2.getRefreshRate()) {
      return false;
    }

    return true;
  }
Ejemplo n.º 6
0
  public boolean displayModesMatch(DisplayMode m1, DisplayMode m2) {

    if (m1.getWidth() != m2.getWidth() || m1.getHeight() != m2.getHeight()) {
      return false;
    } else {
    }

    if (m1.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI
        && m2.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI
        && m1.getBitDepth() != m2.getBitDepth()) {
      return false;
    } else {
    }

    if (m1.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN
        && m2.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN
        && m1.getRefreshRate() != m2.getRefreshRate()) {
      return false;
    } else {
    }

    return true;
  }