Package java.awt

Examples of java.awt.GraphicsDevice


    }
  }

  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());
  }
View Full Code Here


      mode.getBitDepth());
  }

  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++) {
View Full Code Here

    public BufferedImage getColorBufferedImage(int width, int height,
        boolean hasAlpha)
    {
      GraphicsEnvironment ge = GraphicsEnvironment
          .getLocalGraphicsEnvironment();
      GraphicsDevice gd = ge.getDefaultScreenDevice();
      GraphicsConfiguration gc = gd.getDefaultConfiguration();
      return gc.createCompatibleImage(width, height,
          Transparency.TRANSLUCENT);
    }
View Full Code Here

        if (o != null)
            return (BufferedImage)(((Reference)o).get());

        // Check if this is a BufferedImage G2d if so throw an error...
        GraphicsConfiguration gc = g2d.getDeviceConfiguration();
        GraphicsDevice gd = gc.getDevice();
        if (WARN_DESTINATION &&
            (gd.getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) &&
            (g2d.getRenderingHint(RenderingHintsKeyExt.KEY_TRANSCODING) !=
                RenderingHintsKeyExt.VALUE_TRANSCODING_PRINTING))
            // throw new IllegalArgumentException
            System.err.println
                ("Graphics2D from BufferedImage lacks BUFFERED_IMAGE hint");
View Full Code Here

    public static void setFullScreen(boolean fullScreen) {
        setFullScreen(fullScreen, true);
    }

    private static void setFullScreen(boolean fullScreen, boolean visible) {
        GraphicsDevice graphicsDevice = windowedHostFrame.getGraphicsConfiguration().getDevice();

        if (fullScreen) {
            // Go to full screen mode
            if (windowedHostFrame.isVisible()) {
                windowedHostFrame.remove(primaryDisplayHost);
            }

            windowedHostFrame.setVisible(false);

            // Setting the full screen window now will cause a SplashScreen to
            // be dismissed, so don't do so if the --preserveSplashScreen
            // startup property was true, and a SplashScreen was supplied.
            // When the SplashScreen needs to be dismissed, users can call
            // replaceSplashScreen(Display) which will set the full screen
            // window, if required.
            if (visible) {
                graphicsDevice.setFullScreenWindow(fullScreenHostFrame);
            }

            fullScreenHostFrame.add(primaryDisplayHost);
            fullScreenHostFrame.setTitle(windowedHostFrame.getTitle());
            fullScreenHostFrame.setVisible(visible);
        } else {
            // Go to windowed mode
            if (fullScreenHostFrame.isVisible()) {
                fullScreenHostFrame.remove(primaryDisplayHost);
            }

            fullScreenHostFrame.setVisible(false);

            graphicsDevice.setFullScreenWindow(null);

            windowedHostFrame.add(primaryDisplayHost);
            windowedHostFrame.setTitle(fullScreenHostFrame.getTitle());
            windowedHostFrame.setVisible(visible);
        }
View Full Code Here

     * @param display Display to make visible
     * @see java.awt.SplashScreen
     */
    public static void replaceSplashScreen(Display display) {
        java.awt.Window hostWindow = display.getHostWindow();
        GraphicsDevice device = windowedHostFrame.getGraphicsConfiguration().getDevice();
        if ((hostWindow == fullScreenHostFrame) && (device.getFullScreenWindow() == null)) {
            device.setFullScreenWindow(fullScreenHostFrame);
        }
        hostWindow.setVisible(true);
    }
View Full Code Here

        if (o != null)
            return (BufferedImage)(((Reference)o).get());

        // Check if this is a BufferedImage G2d if so throw an error...
        GraphicsConfiguration gc = g2d.getDeviceConfiguration();
        GraphicsDevice gd = gc.getDevice();
        if (WARN_DESTINATION &&
            (gd.getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) &&
            (g2d.getRenderingHint(RenderingHintsKeyExt.KEY_TRANSCODING) !=
                RenderingHintsKeyExt.VALUE_TRANSCODING_PRINTING))
            // throw new IllegalArgumentException
            System.out.println
                ("Graphics2D from BufferedImage lacks BUFFERED_IMAGE hint");
View Full Code Here

      capabilities = new GLCapabilities();
    }
    if (chooser == null) {
      chooser = new DefaultGLCapabilitiesChooser();
    }
    GraphicsDevice device = null;
    if (absDevice != null &&
        !(absDevice instanceof AWTGraphicsDevice)) {
      throw new IllegalArgumentException("This GLDrawableFactory accepts only AWTGraphicsDevice objects");
    }

    if ((absDevice == null) ||
        (((AWTGraphicsDevice) absDevice).getGraphicsDevice() == null)) {
      device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    } else {
      device = ((AWTGraphicsDevice) absDevice).getGraphicsDevice();
    }

    int screen;
    if (isXineramaEnabled()) {
      screen = 0;
    } else {
      screen = X11SunJDKReflection.graphicsDeviceGetScreen(device);
    }

    // Until we have a rock-solid visual selection algorithm written
    // in pure Java, we're going to provide the underlying window
    // system's selection to the chooser as a hint

    int[] attribs = glCapabilities2AttribList(capabilities, isMultisampleAvailable(), false, 0, 0);
    XVisualInfo[] infos = null;
    GLCapabilities[] caps = null;
    int recommendedIndex = -1;
    lockToolkit();
    try {
      long display = getDisplayConnection();
      XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0);
      if (DEBUG) {
        System.err.print("!!! glXChooseVisual recommended ");
        if (recommendedVis == null) {
          System.err.println("null visual");
        } else {
          System.err.println("visual id 0x" + Long.toHexString(recommendedVis.visualid()));
        }
      }
      int[] count = new int[1];
      XVisualInfo template = XVisualInfo.create();
      template.screen(screen);
      infos = GLX.XGetVisualInfo(display, GLX.VisualScreenMask, template, count, 0);
      if (infos == null) {
        throw new GLException("Error while enumerating available XVisualInfos");
      }
      caps = new GLCapabilities[infos.length];
      for (int i = 0; i < infos.length; i++) {
        caps[i] = xvi2GLCapabilities(display, infos[i]);
        // Attempt to find the visual chosen by glXChooseVisual
        if (recommendedVis != null && recommendedVis.visualid() == infos[i].visualid()) {
          recommendedIndex = i;
        }
      }
    } finally {
      unlockToolkit();
    }
    // Store these away for later
    for (int i = 0; i < infos.length; i++) {
      if (caps[i] != null) {
        visualToGLCapsMap.put(new ScreenAndVisualIDKey(screen, infos[i].visualid()),
                              caps[i].clone());
      }
    }
    int chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
    if (chosen < 0 || chosen >= caps.length) {
      throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
    }
    XVisualInfo vis = infos[chosen];
    if (vis == null) {
      throw new GLException("GLCapabilitiesChooser chose an invalid visual");
    }
    // FIXME: need to look at glue code and see type of this field
    long visualID = vis.visualid();
    // FIXME: the storage for the infos array, as well as that for the
    // recommended visual, is leaked; should free them here with XFree()

    // Now figure out which GraphicsConfiguration corresponds to this
    // visual by matching the visual ID
    GraphicsConfiguration[] configs = device.getConfigurations();
    for (int i = 0; i < configs.length; i++) {
      GraphicsConfiguration config = configs[i];
      if (config != null) {
        if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
          return new AWTGraphicsConfiguration(config);
View Full Code Here

  }
  screen= null;

  GraphicsEnvironment ge=
      GraphicsEnvironment.getLocalGraphicsEnvironment();
  GraphicsDevice screens[]= ge.getScreenDevices();
  if (defaultScreen!=null) {
      for (int i=0; i<screens.length; i++) {
    if (screens[i]== defaultScreen) {
        screen= defaultScreen;
    }
View Full Code Here

    }
  }

  /** Displays this frame in full screen mode. */
  private void showFrameInFullScreen() {
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment()
        .getDefaultScreenDevice();

    // TODO: remove workaround for mac/java7 bug as soon as Oracle fixes issue
    if ((OS.indexOf("mac") >= 0) && JAVA.indexOf("1.7") >= 0) {
      logger.warn("Opening SwingExecutionFrame with workaround for Mac OS X and Java 7 Bug.");
      gd.setFullScreenWindow(this);
      this.setVisible(false);
      this.setVisible(true);
    } else {
      logger.info("Opening SwingExecutionFrame without workaround for Mac OS X and Java 7 Bug.");
      this.setVisible(true);
      gd.setFullScreenWindow(this);
    }
  }
View Full Code Here

TOP

Related Classes of java.awt.GraphicsDevice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.