Ejemplo n.º 1
1
 private static void setDisplayModeAndFullscreenInternal(boolean fullscreen, DisplayMode mode)
     throws LWJGLException {
   synchronized (GlobalLock.lock) {
     if (mode == null) throw new NullPointerException("mode must be non-null");
     DisplayMode old_mode = current_mode;
     current_mode = mode;
     boolean was_fullscreen = isFullscreen();
     Display.fullscreen = fullscreen;
     if (was_fullscreen != isFullscreen() || !mode.equals(old_mode)) {
       if (!isCreated()) return;
       destroyWindow();
       try {
         if (isFullscreen()) {
           switchDisplayMode();
         } else {
           display_impl.resetDisplayMode();
         }
         createWindow();
         makeCurrentAndSetSwapInterval();
       } catch (LWJGLException e) {
         drawable.destroy();
         display_impl.resetDisplayMode();
         throw e;
       }
     }
   }
 }
Ejemplo n.º 2
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.º 3
0
  /**
   * <code>main</code> - pass in JFrame name
   *
   * @param args - <code>String[]</code> -
   */
  public static void main(String[] args) {
    name = "";
    String maxScreenValue = "false";
    for (int argc = 0; argc < args.length; argc++) {
      // System.err.println( "argc " + argc + " " + args[argc]);
      if (argc == 0) {
        name = args[argc];
      } else if (argc == 1) {
        maxScreenValue = args[argc];
      } else {
        System.err.println("argument '" + args[argc] + "' not handled");
        System.exit(-1);
      }
    }
    osType = System.getProperty("os.type");
    // System.err.println( "osType " + osType);
    planWorksRoot = System.getProperty("planworks.root");
    isMaxScreen = false;
    if (maxScreenValue.equals("true")) {
      isMaxScreen = true;
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    for (int i = 0; i < gs.length; i++) {
      DisplayMode dm = gs[i].getDisplayMode();
      System.err.println(dm.getWidth() + " " + dm.getHeight());
    }

    planWorks = new PlanWorks(buildConstantMenus());
  } // end main
Ejemplo n.º 4
0
  /** Initializes the GUI. */
  public void initGUI() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    DisplayMode dm = gs[0].getDisplayMode();
    windowHeight = dm.getHeight() - 50;
    windowWidth = ((windowHeight * Board.WIDTH) / Board.HEIGHT) + MENU_WIDTH;
    this.setTitle("Kriegspiel Board Display");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setMinimumSize(new Dimension(windowWidth, windowHeight));
    this.setResizable(false);

    Container content = this.getContentPane();

    boardPanel = new JPanel();
    boardPanel.setLayout(
        new GridLayout(Board.HEIGHT, Board.WIDTH, windowHeight / 500, windowHeight / 500));
    JPanel menuPanel = new MenuDisplayer(this, controller);
    content.setLayout(new BorderLayout());

    this.add(boardPanel, BorderLayout.CENTER);
    this.add(menuPanel, BorderLayout.EAST);

    boardPanel.setBackground(new Color(0, 0, 0));

    squares = new JPanel[Board.WIDTH][Board.HEIGHT];
  }
 JoglGraphicsConfiguration(GLCapabilities caps, int chosenIndex, GraphicsDevice device) {
   super();
   this.caps = caps;
   this.chosenIndex = chosenIndex;
   this.device = device;
   // FIXME unit id?
   this.awtGraphicsDevice = new AWTGraphicsDevice(this.device, 0);
   DisplayMode m = device.getDisplayMode();
   width = m.getWidth();
   height = m.getHeight();
 }
Ejemplo n.º 6
0
 /** 将鼠标居中 */
 public void mouseCenter() {
   try {
     GraphicsDevice device =
         GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
     DisplayMode mode = device.getDisplayMode();
     this.mouseX = this.lastMouseX = (mode.getWidth() / 2) - 10;
     this.mouseY = this.lastMouseY = (mode.getHeight() / 2) - 10;
     LSystem.RO_BOT.mouseMove(this.mouseX, this.mouseY);
   } catch (Exception e) {
   }
 }
Ejemplo n.º 7
0
 private static int getWindowY() {
   if (!isFullscreen() && parent == null) {
     // if no display location set, center window
     if (y == -1) {
       return Math.max(0, (initial_mode.getHeight() - current_mode.getHeight()) / 2);
     } else {
       return y;
     }
   } else {
     return 0;
   }
 }
Ejemplo n.º 8
0
  public static DisplayDeviceArea[] getPresentationAndImageDeviceAreas() {
    DisplayDeviceArea[] displayDeviceAreas = null;
    GraphicsDevice[] gs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
    if (gs.length == 1) {
      DisplayMode dm = gs[0].getDisplayMode();
      int width = dm.getWidth();
      int height = dm.getHeight();
      float presentationAspectRatio = 5f / 4; // usual screen for presentations
      float imageAspectRatio = 3f / 4 * 2; // pair of portrait monitors

      float presentationHorizontalProportion = 0.33f;

      int presentationWidth = (int) (width * presentationHorizontalProportion);

      int presentationHeight = (int) (presentationWidth / presentationAspectRatio);
      if (presentationHeight > height) {
        presentationHeight = height;
      }
      int presentationX = 0;
      int presentationY = height - presentationHeight;

      int imageWidth = width - presentationWidth;
      int imageHeight = (int) (imageWidth / imageAspectRatio);
      if (imageHeight > height) {
        imageHeight = height;
      }
      int imageX = presentationWidth;
      int imageY = height - imageHeight;

      displayDeviceAreas = new DisplayDeviceArea[2];
      displayDeviceAreas[0] =
          new DisplayDeviceArea(
              gs[0], presentationX, presentationY, presentationWidth, presentationHeight);
      displayDeviceAreas[1] = new DisplayDeviceArea(gs[0], imageX, imageY, imageWidth, imageHeight);
    } else if (gs.length == 2) {
      DisplayMode dm1 = gs[0].getDisplayMode();
      DisplayMode dm2 = gs[1].getDisplayMode();
      int width1 = dm1.getWidth();
      int width2 = dm2.getWidth();
      int height1 = dm1.getHeight();
      int height2 = dm2.getHeight();
      GraphicsDevice presentationDevice;
      GraphicsDevice imageDevice;
      if (width1 * height1 > width2 * height2) {
        presentationDevice = gs[1];
        imageDevice = gs[0];
      } else {
        presentationDevice = gs[0];
        imageDevice = gs[1];
      }
      displayDeviceAreas = new DisplayDeviceArea[2];
      displayDeviceAreas[0] = new DisplayDeviceArea(presentationDevice);
      displayDeviceAreas[1] = new DisplayDeviceArea(imageDevice);
    }
    return displayDeviceAreas;
  }
Ejemplo n.º 9
0
 private static void switchDisplayMode() throws LWJGLException {
   if (!current_mode.isFullscreenCapable()) {
     throw new IllegalStateException(
         "Only modes acquired from getAvailableDisplayModes() can be used for fullscreen display");
   }
   display_impl.switchDisplayMode(current_mode);
 }
Ejemplo n.º 10
0
  public MainFrame(Coord isz) {
    super("Haven and Hearth");
    version = "1.6 (12.22.2015)";
    Coord sz;
    if (isz == null) {
      sz = Utils.getprefc("wndsz", new Coord(800, 600));
      if (sz.x < 640) sz.x = 640;
      if (sz.y < 480) sz.y = 480;
    } else {
      sz = isz;
    }
    this.g = new ThreadGroup(HackThread.tg(), "Haven client");
    this.mt = new HackThread(this.g, this, "Haven main thread");
    p = new HavenPanel(sz.x, sz.y);
    if (fsmode == null) {
      Coord pfm = Utils.getprefc("fsmode", null);
      if (pfm != null) fsmode = findmode(pfm.x, pfm.y);
    }
    if (fsmode == null) {
      DisplayMode cm = getGraphicsConfiguration().getDevice().getDisplayMode();
      fsmode = findmode(cm.getWidth(), cm.getHeight());
    }
    if (fsmode == null) fsmode = findmode(800, 600);
    add(p);
    pack();
    setResizable(!Utils.getprefb("wndlock", false));
    p.requestFocusInWindow();
    seticon();
    setVisible(true);
    p.init();
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            g.interrupt();
          }

          public void windowActivated(WindowEvent e) {
            p.bgmode = false;
          }

          public void windowDeactivated(WindowEvent e) {
            p.bgmode = true;
          }
        });
    if ((isz == null) && Utils.getprefb("wndmax", false))
      setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
  }
Ejemplo n.º 11
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.º 12
0
  @Override
  public final synchronized void render() {
    final Graphics graphics = buffer.getDrawGraphics();
    if (smoothScale) {
      ((Graphics2D) graphics)
          .setRenderingHint(
              RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    }
    if (inFullScreen) {
      graphics.setColor(Color.BLACK);
      DisplayMode dm = gd.getDisplayMode();
      int scrnheight = dm.getHeight();
      int scrnwidth = dm.getWidth();
      // don't ask why this needs to be done every frame,
      // but it does b/c the canvas keeps resizing itself
      canvas.setSize(scrnwidth, scrnheight);
      graphics.fillRect(0, 0, scrnwidth, scrnheight);
      if (PrefsSingleton.get().getBoolean("maintainAspect", true)) {
        double scalefactor = getmaxscale(scrnwidth, scrnheight);
        int height = (int) (NES_HEIGHT * scalefactor);
        int width = (int) (256 * scalefactor * 1.1666667);
        graphics.drawImage(
            frame,
            ((scrnwidth / 2) - (width / 2)),
            ((scrnheight / 2) - (height / 2)),
            width,
            height,
            null);
      } else {
        graphics.drawImage(frame, 0, 0, scrnwidth, scrnheight, null);
      }
      graphics.setColor(Color.DARK_GRAY);
      graphics.drawString(this.getTitle(), 16, 16);

    } else {
      graphics.drawImage(
          frame, 0, 0, NES_WIDTH * screenScaleFactor, NES_HEIGHT * screenScaleFactor, null);
    }

    graphics.dispose();
    buffer.show();
  }
  /**
   * Populates user language, color depth, screen resolution, and character encoding. Can't get
   * flash version.
   */
  public void populateFromSystem() {
    encoding = System.getProperty("file.encoding");

    String region = System.getProperty("user.region");
    if (region == null) {
      region = System.getProperty("user.country");
    }
    userLanguage = System.getProperty("user.language") + "-" + region;

    int screenHeight = 0;
    int screenWidth = 0;

    GraphicsEnvironment ge = null;
    GraphicsDevice[] gs = null;

    try {
      ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      gs = ge.getScreenDevices();

      // Get size of each screen
      for (int i = 0; i < gs.length; i++) {
        DisplayMode dm = gs[i].getDisplayMode();
        screenWidth += dm.getWidth();
        screenHeight += dm.getHeight();
      }
      if (screenHeight != 0 && screenWidth != 0) {
        screenResolution = screenWidth + "x" + screenHeight;
      }

      if (gs[0] != null) {
        colorDepth = gs[0].getDisplayMode().getBitDepth() + "";
        for (int i = 1; i < gs.length; i++) {
          colorDepth += ", " + gs[i].getDisplayMode().getBitDepth();
        }
      }
    } catch (HeadlessException e) {
      // report reasonable defaults.
      screenHeight = 1024;
      screenWidth = 768;
      colorDepth = "32";
    }
  }
Ejemplo n.º 14
0
 /** @return whether the Display is in fullscreen mode */
 public static boolean isFullscreen() {
   synchronized (GlobalLock.lock) {
     return fullscreen && current_mode.isFullscreenCapable();
   }
 }
Ejemplo n.º 15
0
  public void createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y)
      throws LWJGLException {
    close_requested = false;
    is_dirty = false;
    isMinimized = false;
    isFocused = false;
    redoMakeContextCurrent = false;
    maximized = false;
    this.parent = parent;
    hasParent = parent != null;
    parent_hwnd = parent != null ? getHwnd(parent) : 0;
    this.hwnd =
        nCreateWindow(
            x,
            y,
            mode.getWidth(),
            mode.getHeight(),
            Display.isFullscreen() || isUndecorated(),
            parent != null,
            parent_hwnd);
    this.resizable = false;
    if (hwnd == 0) {
      throw new LWJGLException("Failed to create window");
    }
    this.hdc = getDC(hwnd);
    if (hdc == 0) {
      nDestroyWindow(hwnd);
      throw new LWJGLException("Failed to get dc");
    }

    try {
      if (drawable instanceof DrawableGL) {
        int format =
            WindowsPeerInfo.choosePixelFormat(
                getHdc(),
                0,
                0,
                (PixelFormat) drawable.getPixelFormat(),
                null,
                true,
                true,
                false,
                true);
        WindowsPeerInfo.setPixelFormat(getHdc(), format);
      } else {
        peer_info = new WindowsDisplayPeerInfo(true);
        ((DrawableGLES) drawable)
            .initialize(
                hwnd,
                hdc,
                EGL.EGL_WINDOW_BIT,
                (org.lwjgl.opengles.PixelFormat) drawable.getPixelFormat());
      }
      peer_info.initDC(getHwnd(), getHdc());
      showWindow(getHwnd(), SW_SHOWDEFAULT);

      updateWidthAndHeight();

      if (parent == null) {
        if (Display.isResizable()) {
          setResizable(true);
        }
        setForegroundWindow(getHwnd());
      } else {
        parent_focused = new AtomicBoolean(false);
        parent.addFocusListener(
            parent_focus_tracker =
                new FocusAdapter() {
                  public void focusGained(FocusEvent e) {
                    parent_focused.set(true);
                    clearAWTFocus();
                  }
                });
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                clearAWTFocus();
              }
            });
      }
      grabFocus();
    } catch (LWJGLException e) {
      nReleaseDC(hwnd, hdc);
      nDestroyWindow(hwnd);
      throw e;
    }
  }
Ejemplo n.º 16
0
 /**
  * Set the mode of the context. If no context has been created through create(), the mode will
  * apply when create() is called. If mode.isFullscreenCapable() is true, the context will become a
  * fullscreen context and the display mode is switched to the mode given by getDisplayMode(). If
  * mode.isFullscreenCapable() is false, the context will become a windowed context with the
  * dimensions given in the mode returned by getDisplayMode(). The native cursor position is also
  * reset.
  *
  * @param mode The new display mode to set. Must be non-null.
  * @throws LWJGLException If the mode switch fails.
  */
 public static void setDisplayModeAndFullscreen(DisplayMode mode) throws LWJGLException {
   setDisplayModeAndFullscreenInternal(mode.isFullscreenCapable(), mode);
 }
  private void enterFullscreen() {
    GraphicsDevice device = m_renderTarget.getGraphicsConfiguration().getDevice();

    if (!device.isFullScreenSupported())
      m_logger.error("Cannot enter full-screen. Device does not support full-screen mode");
    else {
      device.setFullScreenWindow(m_renderTarget);

      DisplayMode best = device.getDisplayMode();

      if (!device.isDisplayChangeSupported())
        m_logger.error(
            "Device does not support change of display modes. Using default display mode.");
      else {
        for (DisplayMode d : device.getDisplayModes()) {
          int dDeltaWidth = d.getWidth() - m_canvasRenderWidth;
          int dDeltaHeight = d.getHeight() - m_canvasRenderHeight;
          int dDeltaBitDepth = d.getBitDepth() - PREFERRED_BIT_DEPTH;

          int bestDeltaWidth = best.getWidth() - m_canvasRenderWidth;
          int bestDeltaHeight = best.getHeight() - m_canvasRenderHeight;
          int bestDeltaBitDepth = best.getBitDepth() - PREFERRED_BIT_DEPTH;

          if (dDeltaWidth == bestDeltaWidth && dDeltaHeight == bestDeltaHeight) {
            if (d.getBitDepth() > MIN_BIT_DEPTH
                && (Math.abs(dDeltaBitDepth) < Math.abs(bestDeltaBitDepth))) best = d;
          } else if (dDeltaWidth == 0
              || (dDeltaWidth > 0 && dDeltaWidth < bestDeltaWidth) && dDeltaHeight == 0
              || (dDeltaHeight > 0 && dDeltaHeight < bestDeltaWidth)) {
            best = d;
          }
        }
        device.setDisplayMode(best);
      }

      m_renderTarget.setBounds(
          new Rectangle(
              m_renderTarget.getLocation(), new Dimension(best.getWidth(), best.getHeight())));
    }
  }
Ejemplo n.º 18
0
  /** creates the lobby. */
  public ClientLobby(User u) {
    this.user = u;

    /*
     * Get Infos about the screen
     * */
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice screen = ge.getDefaultScreenDevice();
    DisplayMode disp = screen.getDisplayMode();
    screenX = disp.getWidth();
    screenY = disp.getHeight();

    JPanel bg = createBackground();

    /*
     * Set up lobby / inputs
     * */
    lobbyParent = new JFrame("SwissDefcon Lobby");
    lobbyParent.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    lobbyParent.setSize(iLobbyX, iLobbyY);
    lobbyParent.setResizable(false);
    lobbyParent.setLocation(screenX / 2 - iLobbyX / 2, screenY / 2 - iLobbyY / 2);
    lobbyParent.setContentPane(bg);

    s = new SelectServer(user);
    s.addServerSelectedListener(
        new ServerSelectedListener() {
          public void serverSelected(final ServerSelectedEvent ev) {
            ServerAddress server = ev.getServer();
            String desiredNick = ev.getUsername();
            try {
              Log.InformationLog(
                  "-->Connecting to "
                      + ev.getServer().getServerName()
                      + "("
                      + server.getAddress().getHostAddress()
                      + ") as "
                      + ev.getUsername()
                      + "(desired Username)");

              // stop discovery
              s.stopSearch();
              s.setVisible(false);

              // make Connection
              socket = new Clientsocket(server);
              // JOptionPane.showMessageDialog(lobbyParent, "Verbunden mit Server");

              l = new InnerLobby(socket, user);
              lobbyParent.add(l);

              // request nick
              socket.sendData(Protocol.CON_NICK.str() + desiredNick);

              // TODO Game Listener to start game here.

              socket.addInfoEventListener(
                  new InfoEventListener() {
                    @Override
                    public void received(final InfoEvent evt) {
                      if (evt.getId() == -1) {
                        Log.InformationLog("Connection to server broken, starting ServerSelect");
                        JOptionPane.showMessageDialog(
                            lobbyParent,
                            "Verbindungsunterbruch",
                            "Connection Error",
                            JOptionPane.ERROR_MESSAGE);
                        // TODO remove the game if it exists.
                        socket.disconnect();
                        lobbyParent.remove(l);
                        lobbyParent.validate();
                        lobbyParent.repaint();
                        s.setVisible(true);
                        s.startSearch();
                      }
                    }
                  });

            } catch (Exception e) {
              // e.printStackTrace();
              Log.WarningLog("-->connection broken, could not connect");
              JOptionPane.showMessageDialog(
                  lobbyParent,
                  "Konnte nicht mit Server verbinden: ",
                  "Connection Error",
                  JOptionPane.ERROR_MESSAGE);
              if (socket != null) {
                socket.disconnect();
              }
              s.setVisible(true);
              s.startSearch();
            }
          }
        });
    lobbyParent.add(s);
    Log.InformationLog("you can now select a server");

    lobbyParent.setVisible(true);
  }
Ejemplo n.º 19
0
 private static void reshape() {
   DisplayMode mode = getEffectiveMode();
   display_impl.reshape(getWindowX(), getWindowY(), mode.getWidth(), mode.getHeight());
 }
Ejemplo n.º 20
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.º 21
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;
  }
Ejemplo n.º 22
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.º 23
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;
  }