示例#1
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());
 }
 /**
  * Creates a new ZPixmapDataBuffer with a specified width and height.
  *
  * @param d the X display
  * @param w the width
  * @param h the height
  */
 ZPixmapDataBuffer(int w, int h) {
   super(TYPE_BYTE, w * h * 3); // TODO: Support non-24-bit-resolutions.
   GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
   XGraphicsDevice dev = (XGraphicsDevice) env.getDefaultScreenDevice();
   Display d = dev.getDisplay();
   zpixmap = new ZPixmap(d, w, h, d.default_pixmap_format);
 }
示例#3
0
文件: IconIO.java 项目: munix/jdget
  public static BufferedImage convertIconToBufferedImage(final Icon icon) {

    if (icon == null) {
      return null;
    }
    if (icon instanceof ImageIcon) {
      final Image ret = ((ImageIcon) icon).getImage();
      if (ret instanceof BufferedImage) {
        return (BufferedImage) ret;
      }
    }
    final int w = icon.getIconWidth();
    final int h = icon.getIconHeight();
    final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice gd = ge.getDefaultScreenDevice();
    final GraphicsConfiguration gc = gd.getDefaultConfiguration();
    final BufferedImage image = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);

    final Graphics2D g = image.createGraphics();
    g.setRenderingHint(
        RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    // g.setColor(Color.RED);
    // g.fillRect(0, 0, w, h);
    icon.paintIcon(null, g, 0, 0);
    g.dispose();
    return image;
  }
  public void beginExecution() {
    if (cam == null) {

      int numBuffers = 2;

      env = GraphicsEnvironment.getLocalGraphicsEnvironment();
      device = env.getDefaultScreenDevice();
      // MultiBufferTest test = new MultiBufferTest(numBuffers, device);

      try {

        GraphicsConfiguration gc = device.getDefaultConfiguration();
        mainFrame = new Frame(gc);
        mainFrame.setUndecorated(true);
        mainFrame.setIgnoreRepaint(true);
        device.setFullScreenWindow(mainFrame);
        if (device.isDisplayChangeSupported()) {
          chooseBestDisplayMode(device);
        }
        mainFrame.createBufferStrategy(numBuffers);
        bufferStrategy = mainFrame.getBufferStrategy();

      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
示例#5
0
 /**
  * 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);
   }
 }
示例#6
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()]);
  }
示例#7
0
  public MafiaMainClass() {
    setLayout(card); // BorderLayout

    // add("WR",wr);
    add("LOG", login); // window창 위에 penal을 올린다
    setTitle("MAFIA GAME - LOGIN");
    setSize(1280, 985); // window 크기

    /*			// 창을 중앙에 띄운다.
    			Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
    			Dimension ex_size = this.getSize();

    			int xpos=(int)(screen.getWidth()/2 - this.getWidth()/2);
    			int ypos=(int)(screen.getHeight()/2 - this.getHeight()/2);

    			this.setLocation(xpos,ypos);
    */
    // 전체화면
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    setUndecorated(true);
    gd.setFullScreenWindow(this);

    setVisible(true); // window 보이기
    setResizable(false); // 화면크기 고정

    addMouseListener(this); // mouse움직임
  }
示例#8
0
  /**
   * ZombieFrame's constructor.
   *
   * @param contents Optional JPanel(s) to add to content pane. Arguments > 0 are ignored.
   */
  public ZombieFrame(JPanel... contents) {
    super("ZombieHouse");

    // Request keyboard focus for the frame.
    setFocusable(true);
    requestFocusInWindow();
    requestFocus();

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setUndecorated(true);
    setResizable(false);
    setBackground(Color.BLACK);

    // The content pane. An optional JPanel may be passed into the
    // constructor. It creates an empty pane with a black background if
    // one isn't provided.
    pane = getContentPane();
    pane.setBackground(Color.BLACK);
    pane.setFocusable(false);
    pane.setVisible(true);
    if (contents.length > 0) {
      pane.add(contents[0]);
    }

    keys = new ZombieKeyBinds((JComponent) pane);

    // Get the graphics device information.
    GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice graphics = environment.getDefaultScreenDevice();

    pack();

    // Go full screen, if supported.
    if (graphics.isFullScreenSupported()) {
      try {
        graphics.setFullScreenWindow(this);
        // Having gone full screen, retrieve the display size.
        // size = Toolkit.getDefaultToolkit().getScreenSize();

        // This double-switching of setVisible is to fix a bug with
        // full-screen-exclusive mode on OS X. Versions 10.8 and later
        // don't send keyboard events properly without it.
        if (System.getProperty("os.name").contains("OS X")) {
          setVisible(false);
        }
      } catch (HeadlessException ex) {
        System.err.println(
            "Error: primary display not set or found. "
                + "Your experience of life may be suboptimal.");
        ex.printStackTrace();
      }
    } else {
      // If full-screen-exclusive mode isn't supported, switch to
      // maximized window mode.
      System.err.println("Full-screen-exclusive mode not supported.");
      setExtendedState(Frame.MAXIMIZED_BOTH);
    }
    setVisible(true);
  }
示例#9
0
文件: IconIO.java 项目: munix/jdget
  public static BufferedImage createEmptyImage(final int w, final int h) {

    final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice gd = ge.getDefaultScreenDevice();
    final GraphicsConfiguration gc = gd.getDefaultConfiguration();
    final BufferedImage image = gc.createCompatibleImage(w, h, Transparency.BITMASK);
    return image;
  }
示例#10
0
  /**
   * Creates a device compatible BufferedImage
   *
   * @param width the width in pixels
   * @param height the height in pixels
   */
  public static BufferedImage getDeviceCompatibleImage(int width, int height) {

    GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice screenDevice = graphicsEnvironment.getDefaultScreenDevice();
    GraphicsConfiguration graphicConfiguration = screenDevice.getDefaultConfiguration();
    BufferedImage image = graphicConfiguration.createCompatibleImage(width, height);

    return image;
  }
  // TODO not used
  private void showNotification() {
    final WebDialog dialog = new WebDialog();
    dialog.setUndecorated(true);
    dialog.setBackground(Color.BLACK);
    dialog.setBackground(StyleConstants.transparent);

    WebNotificationPopup popup = new WebNotificationPopup(PopupStyle.dark);
    popup.setIcon(Utils.getIcon("kontalk_small.png"));
    popup.setMargin(View.MARGIN_DEFAULT);
    popup.setDisplayTime(6000);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {}

          @Override
          public void accepted() {}

          @Override
          public void closed() {
            dialog.dispose();
          }
        });

    // content
    WebPanel panel = new WebPanel();
    panel.setMargin(View.MARGIN_DEFAULT);
    panel.setOpaque(false);
    WebLabel title = new WebLabel("A new Message!");
    title.setFontSize(View.FONT_SIZE_BIG);
    title.setForeground(Color.WHITE);
    panel.add(title, BorderLayout.NORTH);
    String text = "this is some message, and some longer text was added";
    WebLabel message = new WebLabel(text);
    message.setForeground(Color.WHITE);
    panel.add(message, BorderLayout.CENTER);
    popup.setContent(panel);

    // popup.packPopup();
    dialog.setSize(popup.getPreferredSize());

    // set position on screen
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    Rectangle screenBounds = gc.getBounds();
    // get height of the task bar
    // doesn't work on all environments
    // Insets toolHeight = toolkit.getScreenInsets(popup.getGraphicsConfiguration());
    int toolHeight = 40;
    dialog.setLocation(
        screenBounds.width - dialog.getWidth() - 10,
        screenBounds.height - toolHeight - dialog.getHeight());

    dialog.setVisible(true);
    NotificationManager.showNotification(dialog, popup);
  }
 /**
  * Retrieves transparent image of specified dimension.
  *
  * @param width Image width.
  * @param height Image height.
  * @return Transparent image of specified dimension.
  */
 public static BufferedImage getBlankImage(int width, int height) {
   if (UIUtil.isRetina()) {
     return new JBHiDPIScaledImage(width, height, BufferedImage.TYPE_INT_ARGB);
   } else {
     GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
     GraphicsDevice d = e.getDefaultScreenDevice();
     GraphicsConfiguration c = d.getDefaultConfiguration();
     return c.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
   }
 }
示例#13
0
 public static WGLGraphicsConfig getGC(WComponentPeer peer) {
   if (peer != null) {
     return (WGLGraphicsConfig) peer.getGraphicsConfiguration();
   } else {
     // REMIND: this should rarely (never?) happen, but what if
     //         default config is not WGL?
     GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
     GraphicsDevice gd = env.getDefaultScreenDevice();
     return (WGLGraphicsConfig) gd.getDefaultConfiguration();
   }
 }
示例#14
0
 private static D3DGraphicsConfig getGC(WComponentPeer peer) {
   GraphicsConfiguration gc;
   if (peer != null) {
     gc = peer.getGraphicsConfiguration();
   } else {
     GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
     GraphicsDevice gd = env.getDefaultScreenDevice();
     gc = gd.getDefaultConfiguration();
   }
   return (gc instanceof D3DGraphicsConfig) ? (D3DGraphicsConfig) gc : null;
 }
示例#15
0
  public static void main(String[] args) {
    GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice displayDevice = environment.getDefaultScreenDevice();

    frame = new Frame(displayDevice.getDefaultConfiguration());
    frame.setBackground(new Color(0xCC, 0xCC, 0xCC));
    frame.setTitle("TestBug735Inv0AppletAWT");

    try {
      Class<?> c =
          Thread.currentThread()
              .getContextClassLoader()
              .loadClass(Bug735Inv0AppletAWT.class.getName());
      applet = (Bug735Inv0AppletAWT) c.newInstance();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    frame.setLayout(null);
    frame.add(applet);
    frame.pack();
    frame.setResizable(false);

    applet.init();

    Insets insets = frame.getInsets();
    int windowW = applet.width + insets.left + insets.right;
    int windowH = applet.height + insets.top + insets.bottom;
    frame.setSize(windowW, windowH);

    Rectangle screenRect = displayDevice.getDefaultConfiguration().getBounds();
    frame.setLocation(
        screenRect.x + (screenRect.width - applet.width) / 2,
        screenRect.y + (screenRect.height - applet.height) / 2);

    int usableWindowH = windowH - insets.top - insets.bottom;
    applet.setBounds(
        (windowW - applet.width) / 2,
        insets.top + (usableWindowH - applet.height) / 2,
        applet.width,
        applet.height);

    // This allows to close the frame.
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    applet.initGL();
    frame.setVisible(true);
    applet.start();
  }
  /**
   * Generate array with all avalaible resolutions.
   *
   * @return array of resolution strings
   */
  private ResolutionString[] generateResolutionStrings() {
    GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
    DisplayMode[] display_mods = g.getDefaultScreenDevice().getDisplayModes();
    ResolutionString[] resolution_strings = new ResolutionString[display_mods.length];

    for (int i = 0; i < display_mods.length; i++) {
      resolution_strings[i] = new ResolutionString(display_mods[i]);
    }

    return resolution_strings;
  }
示例#17
0
 /** Realiza la inicializacion previa del modo pantalla completa. */
 private void init() {
   env = GraphicsEnvironment.getLocalGraphicsEnvironment();
   graphicsDevice = env.getDefaultScreenDevice();
   oldDisplayMode = graphicsDevice.getDisplayMode();
   if (!graphicsDevice.isFullScreenSupported()) {
     System.out.println("Full screen mode failed");
     System.exit(1);
   } else {
     GraphicsConfiguration gc = graphicsDevice.getDefaultConfiguration();
     window = new Frame(gc);
   }
 }
示例#18
0
  // This method returns a buffered image with the contents of an image
  public static BufferedImage toBufferedImage(Image image) {
    if (image instanceof BufferedImage) {
      return (BufferedImage) image;
    }

    // This code ensures that all the pixels in the image are loaded
    image = new ImageIcon(image).getImage();

    // Determine if the image has transparent pixels;
    // for this method's
    // implementation, see Determining If an Image Has
    // Transparent Pixels
    boolean hasAlpha = hasAlpha(image);

    // Create a buffered image with a format that's compatible
    // with the screen
    BufferedImage bimage = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    try {
      // Determine the type of transparency of the new
      //				 buffered image
      int transparency = Transparency.OPAQUE;
      if (hasAlpha) {
        transparency = Transparency.BITMASK;
      }

      // Create the buffered image
      GraphicsDevice gs = ge.getDefaultScreenDevice();
      GraphicsConfiguration gc = gs.getDefaultConfiguration();
      bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency);
    } catch (HeadlessException e) {
      // The system does not have a screen
    }

    if (bimage == null) {
      // Create a buffered image using the default color model
      int type = BufferedImage.TYPE_INT_RGB;
      if (hasAlpha) {
        type = BufferedImage.TYPE_INT_ARGB;
      }
      bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
    }

    // Copy image to buffered image
    Graphics g = bimage.createGraphics();

    // Paint the image onto the buffered image
    g.drawImage(image, 0, 0, null);
    g.dispose();

    return bimage;
  }
  public TransparentSurface(int width, int height) {
    // create the offscreen buffer
    GraphicsEnvironment local = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice screen = local.getDefaultScreenDevice();
    GraphicsConfiguration conf = screen.getDefaultConfiguration();
    surface = conf.createCompatibleImage(width, height, Transparency.TRANSLUCENT);

    // create the graphics interface
    graphics = (Graphics2D) surface.createGraphics();

    // clear it
    clear();
  }
示例#20
0
 /** 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;
   // }
 }
示例#21
0
  private static BufferedImage createCompatibleImage(
      final BufferedImage img, final boolean translucent) {
    final GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice d = e.getDefaultScreenDevice();
    final GraphicsConfiguration c = d.getDefaultConfiguration();
    final int t = translucent ? Transparency.TRANSLUCENT : Transparency.BITMASK;

    final BufferedImage ret = c.createCompatibleImage(img.getWidth(), img.getHeight(), t);

    final Graphics2D g = ret.createGraphics();
    g.drawImage(img, 0, 0, null);
    g.dispose();
    return ret;
  }
/**
 * GraphicsManager maintains graphics context information that maybe useful for many aspects of
 * graphics rendering. This means that many of the fields are computer dependent and are placed here
 * so they are only calculated once.
 */
public class GraphicsManager {

  /** get GraphicConfiguration for default screen - this should only be done once at startup * */
  private static GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

  private static GraphicsDevice gs = ge.getDefaultScreenDevice();
  public static GraphicsConfiguration gc = gs.getDefaultConfiguration();

  private static final int MAX_RECYCLED_IMAGES = 50;
  private static int numRecycledImages = 0;
  private static HashMap<Dimension, List<BufferedImage>> recycledImages =
      new HashMap<Dimension, List<BufferedImage>>();
  /**
   * Functionally equivalent to gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT)
   * but allows reusing released images.
   */
  public static BufferedImage getGCCompatibleImage(int width, int height) {
    List<BufferedImage> imgList = recycledImages.get(new Dimension(width, height));
    if (imgList == null || imgList.isEmpty())
      return gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
    numRecycledImages--;
    BufferedImage img = imgList.remove(imgList.size() - 1);
    // Clear the image
    Graphics2D g2D = img.createGraphics();
    g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
    Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, width, height);
    g2D.fill(rect);
    return img;
  }

  /**
   * Add an image to the recycled images list (or if img = null, does nothing). Note: the passed
   * variable should be immediately set to null to avoid aliasing bugs.
   */
  public static void recycleGCCompatibleImage(BufferedImage img) {
    if (img == null) return;
    // Make sure we don't waste too much memory
    if (numRecycledImages >= MAX_RECYCLED_IMAGES) {
      recycledImages.clear();
    }
    Dimension dim = new Dimension(img.getWidth(), img.getHeight());
    List<BufferedImage> imgList = recycledImages.get(dim);
    if (imgList == null) {
      imgList = new ArrayList<BufferedImage>();
      recycledImages.put(dim, imgList);
    }
    imgList.add(img);
  }
}
示例#23
0
 public Image iconToImage(Icon icon) {
   if (icon instanceof ImageIcon) {
     return ((ImageIcon) icon).getImage();
   } else {
     int w = icon.getIconWidth();
     int h = icon.getIconHeight();
     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
     GraphicsDevice gd = ge.getDefaultScreenDevice();
     GraphicsConfiguration gc = gd.getDefaultConfiguration();
     BufferedImage image = gc.createCompatibleImage(w, h);
     Graphics2D g = image.createGraphics();
     icon.paintIcon(null, g, 0, 0);
     g.dispose();
     return image;
   }
 }
  private VolatileImage createVolatileImage(int width, int height, int transparency) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
    VolatileImage image = null;

    image = gc.createCompatibleVolatileImage(width, height, transparency);

    int valid = image.validate(gc);

    if (valid == VolatileImage.IMAGE_INCOMPATIBLE) {
      image = this.createVolatileImage(width, height, transparency);
      return image;
    }

    return image;
  }
 private static void test(BufferedImage bi, int type) throws IOException {
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
   VolatileImage vi = gc.createCompatibleVolatileImage(511, 255, type);
   BufferedImage gold = gc.createCompatibleImage(511, 255, type);
   // draw to compatible Image
   Graphics2D big = gold.createGraphics();
   // force scaled blit
   big.drawImage(bi, 7, 11, 127, 111, 7, 11, 127 * 2, 111, null);
   big.dispose();
   // draw to volatile image
   BufferedImage snapshot;
   while (true) {
     vi.validate(gc);
     if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
       try {
         Thread.sleep(100);
       } catch (final InterruptedException ignored) {
       }
       continue;
     }
     Graphics2D vig = vi.createGraphics();
     // force scaled blit
     vig.drawImage(bi, 7, 11, 127, 111, 7, 11, 127 * 2, 111, null);
     vig.dispose();
     snapshot = vi.getSnapshot();
     if (vi.contentsLost()) {
       try {
         Thread.sleep(100);
       } catch (final InterruptedException ignored) {
       }
       continue;
     }
     break;
   }
   // validate images
   for (int x = 7; x < 127; ++x) {
     for (int y = 11; y < 111; ++y) {
       if (gold.getRGB(x, y) != snapshot.getRGB(x, y)) {
         ImageIO.write(gold, "png", new File("gold.png"));
         ImageIO.write(snapshot, "png", new File("bi.png"));
         throw new RuntimeException("Test failed.");
       }
     }
   }
 }
示例#26
0
  static {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

      Enumeration keys = UIManager.getDefaults().keys();
      while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof Font) {
          Font f = (Font) value;
          UIManager.put(key, f.deriveFont(Font.BOLD, f.getSize() * 1.2f));
        }
      }
    } catch (ClassNotFoundException
        | InstantiationException
        | IllegalAccessException
        | UnsupportedLookAndFeelException e) {
      e.printStackTrace();
    }

    localGraphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    defaultScreenDevice = localGraphicsEnvironment.getDefaultScreenDevice();
    displayMode = defaultScreenDevice.getDisplayMode();

    for (GraphicsDevice device : localGraphicsEnvironment.getScreenDevices()) {
      System.out.println(device.toString());
    }

    reloadFonts();
    Config.addConfigChangeListener(
        new String[] {
          "font1_file", "font1_size", "font2_file", "font2_size",
        },
        new ConfigChangeListener() {
          @Override
          public void configChanged(ConfigChangeEvent e) {
            reloadFonts();

            MainFrame.getInstance().repaint();
            ProgramWindow.getInstance().repaint();
          }
        });

    instance = new MainFrame();
  }
示例#27
0
 public static void main(String[] args) {
   try {
     int numBuffers = 2;
     if (args != null && args.length > 0) {
       numBuffers = Integer.parseInt(args[0]);
       if (numBuffers < 2 || numBuffers > COLORS.length) {
         System.err.println("Must specify between 2 and " + COLORS.length + " buffers");
         System.exit(1);
       }
     }
     GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
     GraphicsDevice device = env.getDefaultScreenDevice();
     MultiBufferTest test = new MultiBufferTest(numBuffers, device);
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
   System.exit(0);
 }
示例#28
0
 public static GraphicsConfiguration getTranslucencyCapableGC() {
   GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsConfiguration ret = env.getDefaultScreenDevice().getDefaultConfiguration();
   if (AWTUtilitiesWrapper.isTranslucencyCapable(ret)) {
     return ret;
   } else {
     GraphicsDevice[] devices = env.getScreenDevices();
     for (int i = 0; i < devices.length; i++) {
       GraphicsConfiguration[] configs = devices[i].getConfigurations();
       for (int j = 0; j < configs.length; j++) {
         if (AWTUtilitiesWrapper.isTranslucencyCapable(configs[j])) {
           return configs[j];
         }
       }
     }
     return null;
   }
 }
示例#29
0
  @Override
  public void start() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    gd = ge.getDefaultScreenDevice();

    if (!gd.isFullScreenSupported()) {
      onError("Full-screen exclusive mode not supported");
      System.exit(0);
    }
    // switch on FSEM
    //        gd.setFullScreenWindow(window);

    window.setVisible(true);

    renderThread.start();
    updateThread.start();
    inputThread.start();
  }
示例#30
0
  public kra() throws Exception {
    GraphicsEnvironment var1 = GraphicsEnvironment.getLocalGraphicsEnvironment();
    this.b = var1.getDefaultScreenDevice();
    if (!this.b.isFullScreenSupported()) {
      GraphicsDevice[] var2 = var1.getScreenDevices();
      GraphicsDevice[] var3 = var2;

      for (int var4 = 0; ~var4 > ~var3.length; ++var4) {
        GraphicsDevice var5 = var3[var4];
        if (null != var5 && var5.isFullScreenSupported()) {
          this.b = var5;
          return;
        }
      }

      throw new Exception();
    }
  }