protected void applySettings(AppSettings settings){ active.set(true); canvas.addWindowListener(new WindowAdapter() { @Override public void windowDestroyNotify(WindowEvent e) { canvas.setSize(settings.getWidth(), settings.getHeight()); canvas.setUndecorated(settings.isFullscreen()); canvas.setFullscreen(settings.isFullscreen()); Screen screen = canvas.getScreen(); screen.addReference(); if (settings.isFullscreen()) { List<MonitorMode> screenModes = canvas.getMainMonitor().getSupportedModes(); screenModes = MonitorModeUtil.filterByResolution(screenModes, dimension); screenModes = MonitorModeUtil.getHighestAvailableBpp(screenModes); if (settings.getFrequency() > 0) { screenModes = MonitorModeUtil.filterByRate(screenModes, settings.getFrequency()); } else { screenModes = MonitorModeUtil.getHighestAvailableRate(screenModes); canvas.getMainMonitor().setCurrentMode(screenModes.get(0)); MonitorMode currentScreenMode = canvas.getMainMonitor().getCurrentMode(); logger.log(Level.FINE, "Selected display mode: {0}x{1}x{2} @{3}", new Object[]{currentScreenMode.getRotatedWidth(), currentScreenMode.getRotatedHeight(), currentScreenMode.getSurfaceSize().getBitsPerPixel(),
@Override public void setNativeCursor(JmeCursor cursor) { final ByteBuffer pixels = Buffers.copyIntBufferAsByteBuffer(cursor.getImagesData()); final DimensionImmutable size = new Dimension(cursor.getWidth(), cursor.getHeight()); final PixelFormat pixFormat = PixelFormat.RGBA8888; final PixelRectangle.GenericPixelRect rec = new PixelRectangle.GenericPixelRect(pixFormat, size, 0, true, pixels); final PointerIcon joglCursor = component.getScreen().getDisplay().createPointerIcon(rec, cursor.getXHotSpot(), cursor.getHeight() - cursor.getYHotSpot()); component.setPointerIcon(joglCursor); } }
private final int getHashCode() { // 31 * x == (x << 5) - x int hash = 31 + getId(); hash = ((hash << 5) - hash) + sizeAndRRate.hashCode(); hash = ((hash << 5) - hash) + getRotation(); return hash; }
/** * Calculates the union of all monitor's {@link MonitorDevice#getViewport() viewport} in pixel- and window units. * <p> * Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()}, * however, some native toolkits may choose a different virtual screen area. * </p> * @param viewport storage for result in pixel units, maybe null * @param viewportInWindowUnits storage for result in window units, maybe null */ public final void unionOfMonitorViewports(final Rectangle viewport, final Rectangle viewportInWindowUnits) { MonitorDevice.unionOfViewports(viewport, viewportInWindowUnits, getMonitorDevices()); }
public static MonitorMode getByNativeSizeRateIdAndRotation(final List<MonitorMode> monitorModes, final MonitorMode.SizeAndRRate sizeAndRate, final int modeId, final int rotation) { if( null!=monitorModes && monitorModes.size()>0 ) { for (int i=0; i<monitorModes.size(); i++) { final MonitorMode mode = monitorModes.get(i); if( mode.getSizeAndRRate().equals(sizeAndRate) && mode.getId() == modeId && mode.getRotation() == rotation ) { return mode; } } } return null; }
@Override public void run() { if(newtChild.isVisible() != showing) { newtChild.setVisible(showing); } }}); }
/** * * @param type * @param name * @param fromIndex start index, then decreasing until found or end of list. -1 is interpreted as size - 1. * @param shared if true, only shared instances are found, otherwise also exclusive * @return */ public static Display getLastDisplayOf(final String type, final String name, final int fromIndex, final boolean shared) { return getDisplayOfImpl(type, name, fromIndex, -1, shared); }
/** Returns the rotated screen width in pixel units, * derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code> * and <code>getRotation()</code> */ public final int getRotatedWidth() { return getRotatedWH(true); }
/* package */ void configureNewtChild(final boolean attach) { newtChildReady = attach; if( null != newtChild ) { newtChild.setKeyboardFocusHandler(null); if(attach) { newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); } else { newtChild.setFocusAction(null); newtChild.setDefaultCloseOperation(newtChildCloseOp); } } }
/** * Returns <code>true</true> if the {@link MonitorMode} * has been changed programmatic via this API <i>only</i>, otherwise <code>false</code>. * <p> * Note: We cannot guarantee that we won't interfere w/ another running * application's screen mode change or vice versa. * </p> */ public final boolean isModeChangedByUs() { return modeChanged && !isOriginalMode(); }
/** * * @param type * @param name * @param fromIndex start index, then decreasing until found or end of list. -1 is interpreted as size - 1. * @return */ public static Screen getLastScreenOf(final Display display, final int idx, final int fromIndex) { return getScreenOfImpl(display, idx, fromIndex, -1); }
/** WARNING: must be synchronized with ScreenMode.h, native implementation */ private static MonitorMode streamInMonitorMode0(final MonitorMode.SizeAndRRate sizeAndRate, final int[] modeProperties, int offset) { final int id = modeProperties[offset++]; final int rotation = modeProperties[offset++]; return new MonitorMode(id, sizeAndRate, rotation); }
@Override public void run() { if( componentAdded && newtChild != null ) { newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); } } } );
private final int getHashCode() { // 31 * x == (x << 5) - x int hash = 31 + getId(); hash = ((hash << 5) - hash) + sizeAndRRate.hashCode(); hash = ((hash << 5) - hash) + getRotation(); return hash; }
/** * Calculates the union of all monitor's {@link MonitorDevice#getViewport() viewport} in pixel- and window units. * <p> * Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()}, * however, some native toolkits may choose a different virtual screen area. * </p> * @param viewport storage for result in pixel units, maybe null * @param viewportInWindowUnits storage for result in window units, maybe null */ public final void unionOfMonitorViewports(final Rectangle viewport, final Rectangle viewportInWindowUnits) { MonitorDevice.unionOfViewports(viewport, viewportInWindowUnits, getMonitorDevices()); }
/** * * @param type * @param name * @param fromIndex start index, then decreasing until found or end of list. -1 is interpreted as size - 1. * @param shared if true, only shared instances are found, otherwise also exclusive * @return */ public static Display getLastDisplayOf(final String type, final String name, final int fromIndex, final boolean shared) { return getDisplayOfImpl(type, name, fromIndex, -1, shared); }
/** Returns the rotated screen width in pixel units, * derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code> * and <code>getRotation()</code> */ public final int getRotatedWidth() { return getRotatedWH(true); }
/** * * @param type * @param name * @param fromIndex start index, then increasing until found or end of list * @paran shared if true, only shared instances are found, otherwise also exclusive * @return */ public static Display getFirstDisplayOf(final String type, final String name, final int fromIndex, final boolean shared) { return getDisplayOfImpl(type, name, fromIndex, 1, shared); }
/** Returns the rotated screen height in pixel units, * derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code> * and <code>getRotation()</code> */ public final int getRotatedHeight() { return getRotatedWH(false); }
/** * * @param type * @param name * @param fromIndex start index, then increasing until found or end of list * @paran shared if true, only shared instances are found, otherwise also exclusive * @return */ public static Display getFirstDisplayOf(final String type, final String name, final int fromIndex, final boolean shared) { return getDisplayOfImpl(type, name, fromIndex, 1, shared); }