/** * Finds and returns the boundaries of the screen in which <code>x/y</code> are. * @param x some x coordinate * @param y some y coordinate * @return the boundaries of the nearest screen containing <code>x/y</code> or <code>null</code> */ protected Rectangle findDevice( int x, int y ){ GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); GraphicsDevice best = null; int bestDist = 0; for( GraphicsDevice device : devices ){ Rectangle bounds = device.getDefaultConfiguration().getBounds(); int dist = dist( bounds.x, bounds.width, x ) + dist( bounds.y, bounds.height, y ); if( best == null || dist < bestDist ){ best = device; bestDist = dist; } } if( best == null ){ return null; } return best.getDefaultConfiguration().getBounds(); }
Rectangle screen = findDevice( search.x + target.x, search.y + target.y ); if( screen == null ){ return null; original = findDevice( center.x + target.x, center.y + target.y ); Dimension minimum = getMinimumSize( window );
@Override public Rectangle checkSize( ScreenDockWindow window, Rectangle target ){ Point center = window.getTitleCenter(); Point search; if( center == null ){ center = new Point( target.width/2, target.height/2 ); search = center; } else{ Rectangle bounds = window.getWindowBounds(); search = new Point( center ); search.x += target.x - bounds.x; search.y += target.y - bounds.y; } return validate( window, target, center, search ); }
Rectangle screen = findDevice( search.x + target.x, search.y + target.y ); if( screen == null ){ return null; original = findDevice( center.x + target.x, center.y + target.y );
@Override public Rectangle checkSize( ScreenDockWindow window, Rectangle target ){ Point center = window.getTitleCenter(); Point search; if( center == null ){ center = new Point( target.width/2, target.height/2 ); search = center; } else{ Rectangle bounds = window.getWindowBounds(); search = new Point( center ); search.x += target.x - bounds.x; search.y += target.y - bounds.y; } return validate( window, target, center, search ); }
@Override public Rectangle checkSize( ScreenDockWindow window ){ Point center = window.getTitleCenter(); if( center == null ){ Rectangle target = window.getWindowBounds(); center = new Point( target.width/2, target.height/2 ); } return validate( window, window.getWindowBounds(), center, center ); }
/** * Finds and returns the boundaries of the screen in which <code>x/y</code> are. * @param x some x coordinate * @param y some y coordinate * @return the boundaries of the nearest screen containing <code>x/y</code> or <code>null</code> */ protected Rectangle findDevice( int x, int y ){ GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); GraphicsDevice best = null; int bestDist = 0; for( GraphicsDevice device : devices ){ Rectangle bounds = device.getDefaultConfiguration().getBounds(); int dist = dist( bounds.x, bounds.width, x ) + dist( bounds.y, bounds.height, y ); if( best == null || dist < bestDist ){ best = device; bestDist = dist; } } if( best == null ){ return null; } return best.getDefaultConfiguration().getBounds(); }
@Override public Rectangle checkSize( ScreenDockWindow window ){ Point center = window.getTitleCenter(); if( center == null ){ Rectangle target = window.getWindowBounds(); center = new Point( target.width/2, target.height/2 ); } return validate( window, window.getWindowBounds(), center, center ); }