private static @Nullable GraphicsConfiguration getConfiguration(@Nullable Object object) {
    if (object instanceof Project project) {
      object = WindowManager.getInstance().getFrame(project);
      if (object == null) LOG.warn("cannot find a project frame for " + project);
    }
    if (object instanceof Window window) {
      GraphicsConfiguration configuration = window.getGraphicsConfiguration();
      if (configuration != null) return configuration;
      object = ScreenUtil.getScreenDevice(window.getBounds());
      if (object == null) LOG.warn("cannot find a device for " + window);
    }
    if (object instanceof GraphicsDevice device) {
      object = device.getDefaultConfiguration();
      if (object == null) LOG.warn("cannot find a configuration for " + device);
    }
    if (object instanceof GraphicsConfiguration) return (GraphicsConfiguration)object;
    if (object != null) LOG.warn("unexpected object " + object.getClass());
    return null;
  }
private static @Nullable GraphicsConfiguration getConfiguration(@Nullable Object object)