public AbstractGraphicsConfiguration chooseGraphicsConfiguration(
      Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
    GraphicsDevice device = null;
    if (absScreen != null && !(absScreen instanceof AWTGraphicsScreen)) {
      throw new IllegalArgumentException(
          "This GraphicsConfigurationFactory accepts only AWTGraphicsScreen objects");
    }

    if (null == absScreen) {
      absScreen = AWTGraphicsScreen.createScreenDevice(-1);
    }
    AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen;
    device = ((AWTGraphicsDevice) awtScreen.getDevice()).getGraphicsDevice();

    if (capabilities != null && !(capabilities instanceof GLCapabilities)) {
      throw new IllegalArgumentException(
          "This GraphicsConfigurationFactory accepts only GLCapabilities objects");
    }

    if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) {
      throw new IllegalArgumentException(
          "This GraphicsConfigurationFactory accepts only GLCapabilitiesChooser objects");
    }

    if (DEBUG) {
      System.err.println("MacOSXAWTCGLGraphicsConfigurationFactory: got " + absScreen);
    }

    long displayHandle = 0;

    MacOSXGraphicsDevice macDevice = new MacOSXGraphicsDevice();
    DefaultGraphicsScreen macScreen = new DefaultGraphicsScreen(macDevice, awtScreen.getIndex());
    if (DEBUG) {
      System.err.println("MacOSXAWTCGLGraphicsConfigurationFactory: made " + macScreen);
    }

    GraphicsConfiguration gc = device.getDefaultConfiguration();
    AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc);
    if (DEBUG) {
      System.err.println("AWT Colormodel compatible: " + capabilities);
    }

    MacOSXCGLGraphicsConfiguration macConfig =
        (MacOSXCGLGraphicsConfiguration)
            GraphicsConfigurationFactory.getFactory(macDevice)
                .chooseGraphicsConfiguration(capabilities, chooser, macScreen);

    if (macConfig == null) {
      throw new GLException(
          "Unable to choose a GraphicsConfiguration: "
              + capabilities
              + ",\n\t"
              + chooser
              + "\n\t"
              + macScreen);
    }

    // FIXME: we have nothing to match .. so choose the default
    return new AWTGraphicsConfiguration(
        awtScreen,
        macConfig.getChosenCapabilities(),
        macConfig.getRequestedCapabilities(),
        gc,
        macConfig);
  }
  protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
      CapabilitiesImmutable capsChosen,
      CapabilitiesImmutable capsRequested,
      CapabilitiesChooser chooser,
      AbstractGraphicsScreen absScreen) {
    GraphicsDevice device = null;
    if (absScreen != null && !(absScreen instanceof AWTGraphicsScreen)) {
      throw new IllegalArgumentException(
          "This GraphicsConfigurationFactory accepts only AWTGraphicsScreen objects");
    }

    if (null == absScreen) {
      absScreen = AWTGraphicsScreen.createScreenDevice(-1, AbstractGraphicsDevice.DEFAULT_UNIT);
    }
    AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen;
    device = ((AWTGraphicsDevice) awtScreen.getDevice()).getGraphicsDevice();

    if (!(capsChosen instanceof GLCapabilitiesImmutable)) {
      throw new IllegalArgumentException(
          "This GraphicsConfigurationFactory accepts only GLCapabilities objects - chosen");
    }

    if (!(capsRequested instanceof GLCapabilitiesImmutable)) {
      throw new IllegalArgumentException(
          "This GraphicsConfigurationFactory accepts only GLCapabilities objects - requested");
    }

    if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) {
      throw new IllegalArgumentException(
          "This GraphicsConfigurationFactory accepts only GLCapabilitiesChooser objects");
    }

    if (DEBUG) {
      System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: got " + absScreen);
    }
    GraphicsConfiguration gc = device.getDefaultConfiguration();
    WindowsGraphicsDevice winDevice =
        new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
    DefaultGraphicsScreen winScreen = new DefaultGraphicsScreen(winDevice, awtScreen.getIndex());
    if (DEBUG) {
      System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: made " + winScreen);
    }

    WindowsWGLGraphicsConfiguration winConfig =
        (WindowsWGLGraphicsConfiguration)
            GraphicsConfigurationFactory.getFactory(winDevice)
                .chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, winScreen);

    if (winConfig == null) {
      throw new GLException(
          "Unable to choose a GraphicsConfiguration: "
              + capsChosen
              + ",\n\t"
              + chooser
              + "\n\t"
              + winScreen);
    }

    if (DEBUG) {
      System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: chosen " + winConfig);
    }

    // We have nothing to match .. so choose the default
    return new AWTGraphicsConfiguration(
        awtScreen,
        winConfig.getChosenCapabilities(),
        winConfig.getRequestedCapabilities(),
        gc,
        winConfig);
  }