@Override public boolean equals(final Object obj) { if(this == obj) { return true; } if(!(obj instanceof CapabilitiesImmutable)) { return false; } final CapabilitiesImmutable other = (CapabilitiesImmutable)obj; boolean res = other.getRedBits()==redBits && other.getGreenBits()==greenBits && other.getBlueBits()==blueBits && other.getAlphaBits()==alphaBits && other.isBackgroundOpaque()==backgroundOpaque && other.isOnscreen()==onscreen && other.isBitmap()==isBitmap; if(res && !backgroundOpaque) { res = other.getTransparentRedValue()==transparentValueRed && other.getTransparentGreenValue()==transparentValueGreen && other.getTransparentBlueValue()==transparentValueBlue && other.getTransparentAlphaValue()==transparentValueAlpha; } return res; }
/** * Comparing RGBA values only **/ @Override public int compareTo(final CapabilitiesImmutable caps) { /** if ( ! ( o instanceof CapabilitiesImmutable ) ) { Class<?> c = (null != o) ? o.getClass() : null ; throw new ClassCastException("Not a CapabilitiesImmutable object, but " + c); } final CapabilitiesImmutable caps = (CapabilitiesImmutable) o; */ final int rgba = redBits * greenBits * blueBits * ( alphaBits + 1 ); final int xrgba = caps.getRedBits() * caps.getGreenBits() * caps.getBlueBits() * ( caps.getAlphaBits() + 1 ); if(rgba > xrgba) { return 1; } else if(rgba < xrgba) { return -1; } return 0; // they are equal: RGBA }
public static WindowImpl create(final NativeWindow parentWindow, final long parentWindowHandle, final Screen screen, final CapabilitiesImmutable caps) { try { Class<?> windowClass; if(caps.isOnscreen()) { windowClass = getWindowClass(screen.getDisplay().getType()); } else { windowClass = OffscreenWindow.class; } final WindowImpl window = (WindowImpl) windowClass.newInstance(); window.parentWindow = parentWindow; window.parentWindowHandle = parentWindowHandle; window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); window.instantiationFinished(); addWindow2List(window); return window; } catch (final Throwable t) { t.printStackTrace(); throw new NativeWindowException(t); } }
final Capabilities capabilities = (Capabilities) capabilitiesIn.cloneMutable();
System.err.println("Created Config (n): HAVE CF "+awtConfig); System.err.println("Created Config (n): Choosen CF "+config); System.err.println("Created Config (n): EQUALS CAPS "+config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities())); if( !config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities())) { displayConfigChanged=true;
continue; if (desired.isOnscreen() && !cur.isOnscreen()) { continue; // requested onscreen, but n/a ((cur.getRedBits() + cur.getGreenBits() + cur.getBlueBits() + cur.getAlphaBits()) - (desired.getRedBits() + desired.getGreenBits() + desired.getBlueBits() + desired.getAlphaBits()))); scores[i] = score;
public static WindowImpl create(final Object[] cstrArguments, final Screen screen, final CapabilitiesImmutable caps) { try { final Class<?> windowClass = getWindowClass(screen.getDisplay().getType()); final Class<?>[] cstrArgumentTypes = getCustomConstructorArgumentTypes(windowClass); if(null==cstrArgumentTypes) { throw new NativeWindowException("WindowClass "+windowClass+" doesn't support custom arguments in constructor"); } final int argsChecked = verifyConstructorArgumentTypes(cstrArgumentTypes, cstrArguments); if ( argsChecked < cstrArguments.length ) { throw new NativeWindowException("WindowClass "+windowClass+" constructor mismatch at argument #"+argsChecked+"; Constructor: "+getTypeStrList(cstrArgumentTypes)+", arguments: "+getArgsStrList(cstrArguments)); } final WindowImpl window = (WindowImpl) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ; window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); window.instantiationFinished(); addWindow2List(window); return window; } catch (final Throwable t) { throw new NativeWindowException(t); } }
chooser, gc.getDevice()); final GraphicsConfiguration compatible = config.getAWTGraphicsConfiguration(); final boolean equalCaps = config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities()); if(DEBUG) { System.err.println(getThreadName()+": Info:");
/** * Copies all {@link Capabilities} values * from <code>source</code> into this instance. * @return this instance */ public Capabilities copyFrom(final CapabilitiesImmutable other) { redBits = other.getRedBits(); greenBits = other.getGreenBits(); blueBits = other.getBlueBits(); alphaBits = other.getAlphaBits(); backgroundOpaque = other.isBackgroundOpaque(); onscreen = other.isOnscreen(); isBitmap = other.isBitmap(); transparentValueRed = other.getTransparentRedValue(); transparentValueGreen = other.getTransparentGreenValue(); transparentValueBlue = other.getTransparentBlueValue(); transparentValueAlpha = other.getTransparentAlphaValue(); return this; }
private static XVisualInfo getXVisualInfoImpl(final AbstractGraphicsScreen screen, final CapabilitiesImmutable capabilities, final int c_class) { XVisualInfo ret = null; final int[] num = { -1 }; final XVisualInfo vinfo_template = XVisualInfo.create(); vinfo_template.setScreen(screen.getIndex()); vinfo_template.setC_class(c_class); final long display = screen.getDevice().getHandle(); final XVisualInfo[] vinfos = X11Lib.XGetVisualInfo(display, X11Lib.VisualScreenMask, vinfo_template, num, 0); XVisualInfo best=null; final int rdepth = capabilities.getRedBits() + capabilities.getGreenBits() + capabilities.getBlueBits() + capabilities.getAlphaBits(); for (int i = 0; vinfos!=null && i < num[0]; i++) { if ( best == null || best.getDepth() < vinfos[i].getDepth() ) { best = vinfos[i]; if(rdepth <= best.getDepth()) break; } } if ( null!=best && ( rdepth <= best.getDepth() || 24 == best.getDepth()) ) { ret = XVisualInfo.create(best); } best = null; return ret; } }
final Capabilities caps = (Capabilities) getGraphicsConfiguration().getChosenCapabilities().cloneMutable(); caps.setOnscreen(false); setChosenCapabilities(caps);