Esempio n. 1
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;
  }
Esempio n. 2
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);
  }
Esempio n. 3
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);
 }