コード例 #1
0
ファイル: JREImage.java プロジェクト: kazuyakuza/wh40kh
 /**
  * Create possibly volatile scratch image for fast painting. A scratch image can become
  * invalidated, when this happens any actions involving it are ignored, and it needs to be
  * recreated. Use isScratchImageValid() to check this.
  */
 public static Image createScratchImage(int width, int height) {
   try {
     Image img =
         (Image)
             tryMethod(
                 output_comp,
                 "createVolatileImage",
                 new Object[] {new Integer(width), new Integer(height)});
     if (img == null) {
       // no such method -> create regular image
       return output_comp.createImage(width, height);
     }
     // if (img.validate(output_comp.getGraphicsConfiguration())
     // == VolatileImage.IMAGE_INCOMPATIBLE) {
     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
     GraphicsDevice gs = ge.getDefaultScreenDevice();
     GraphicsConfiguration gc = gs.getDefaultConfiguration();
     Integer valid = (Integer) tryMethod(img, "validate", new Object[] {gc});
     // output_comp.getGraphicsConfiguration() });
     if (valid.intValue() == 2) { // I checked, IMAGE_INCOMPATIBLE=2
       // Hmm, somehow it didn't work. Create regular image.
       return output_comp.createImage(width, height);
     }
     return img;
   } catch (java.security.AccessControlException e) {
     // we're not allowed to do this (we're probably an applet)
     return output_comp.createImage(width, height);
   }
 }
コード例 #2
0
ファイル: JREImage.java プロジェクト: kazuyakuza/wh40kh
 /** Create empty image with given alpha mode that should be efficient on this display */
 public static BufferedImage createCompatibleImage(int width, int height, int transparency) {
   // try {
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsDevice gs = ge.getDefaultScreenDevice();
   GraphicsConfiguration gc = gs.getDefaultConfiguration();
   // always use bitmask transparency
   BufferedImage bimage = gc.createCompatibleImage(width, height, transparency);
   return bimage;
   // } catch (HeadlessException e) { // this exception is not in 1.2
   // The system does not have a screen
   //	e.printStackTrace();
   //	return null;
   // }
 }
コード例 #3
0
ファイル: MainFrame.java プロジェクト: XaoZloHnH/hafen-client
 public void setwnd() {
   GraphicsDevice dev = getGraphicsConfiguration().getDevice();
   if (prefs == null) return;
   try {
     dev.setDisplayMode(prefs);
     dev.setFullScreenWindow(null);
     setVisible(false);
     dispose();
     setUndecorated(false);
     setVisible(true);
   } catch (Exception e) {
     throw (new RuntimeException(e));
   }
   prefs = null;
 }
コード例 #4
0
ファイル: MainFrame.java プロジェクト: XaoZloHnH/hafen-client
 public void setfs() {
   GraphicsDevice dev = getGraphicsConfiguration().getDevice();
   if (prefs != null) return;
   prefs = dev.getDisplayMode();
   try {
     setVisible(false);
     dispose();
     setUndecorated(true);
     setVisible(true);
     dev.setFullScreenWindow(this);
     dev.setDisplayMode(fsmode);
     pack();
   } catch (Exception e) {
     throw (new RuntimeException(e));
   }
 }
コード例 #5
0
ファイル: MainFrame.java プロジェクト: XaoZloHnH/hafen-client
 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);
 }
コード例 #6
0
  public GraphicsDevice getGraphicsDeviceAt(Point pos) {

    GraphicsDevice device = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice lstGDs[] = ge.getScreenDevices();
    ArrayList<GraphicsDevice> lstDevices = new ArrayList<>(lstGDs.length);

    for (GraphicsDevice gd : lstGDs) {
      GraphicsConfiguration gc = gd.getDefaultConfiguration();
      Rectangle screenBounds = gc.getBounds();
      if (screenBounds.contains(pos)) {
        lstDevices.add(gd);
      }
    }

    if (lstDevices.size() == 1) {
      device = lstDevices.get(0);
    }
    return device;
  }
コード例 #7
0
  public Rectangle getScreenViewableBounds(GraphicsDevice gd) {

    Rectangle bounds = new Rectangle(0, 0, 0, 0);

    if (gd != null) {
      GraphicsConfiguration gc = gd.getDefaultConfiguration();
      bounds = gc.getBounds();
      Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);

      bounds.x += insets.left;
      bounds.y += insets.top;
      bounds.width -= (insets.left + insets.right);
      bounds.height -= (insets.top + insets.bottom);
    }
    return bounds;
  }
コード例 #8
0
 public GraphicsConfiguration getDeviceConfiguration() {
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsDevice gd = ge.getDefaultScreenDevice();
   return (gd.getDefaultConfiguration());
 }