Java Code Examples for java.awt.GraphicsDevice#TYPE_RASTER_SCREEN

The following examples show how to use java.awt.GraphicsDevice#TYPE_RASTER_SCREEN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WindowUtils.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Looks for the screen device that contains the largest part of the specified global bounds.
 *
 * @param bounds The global bounds to determine the preferred screen device for.
 * @return The preferred screen device.
 */
public static GraphicsDevice getPreferredScreenDevice(Rectangle bounds) {
    GraphicsEnvironment ge            = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice      best          = ge.getDefaultScreenDevice();
    Rectangle           overlapBounds = Geometry.intersection(bounds, best.getDefaultConfiguration().getBounds());
    int                 bestOverlap   = overlapBounds.width * overlapBounds.height;

    for (GraphicsDevice gd : ge.getScreenDevices()) {
        if (gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
            overlapBounds = Geometry.intersection(bounds, gd.getDefaultConfiguration().getBounds());
            if (overlapBounds.width * overlapBounds.height > bestOverlap) {
                best = gd;
            }
        }
    }
    return best;
}
 
Example 2
Source File: AquaLnFPopupLocationFix.java    From cropplanning with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get the best graphics configuration for the specified point and component.
 */
private GraphicsConfiguration graphicsConfigurationForComponent(Component component) {
    Point point = component.getLocationOnScreen();
    
    // try to find the graphics configuration for our point of interest
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gd = ge.getScreenDevices();
    for(int i = 0; i < gd.length; i++) {
        if(gd[i].getType() != GraphicsDevice.TYPE_RASTER_SCREEN) continue;
        GraphicsConfiguration defaultGraphicsConfiguration = gd[i].getDefaultConfiguration();
        if(!defaultGraphicsConfiguration.getBounds().contains(point)) continue;
        return defaultGraphicsConfiguration;
    }
    
    // we couldn't find a graphics configuration, use the component's
    return component.getGraphicsConfiguration();
}
 
Example 3
Source File: bug8071705.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 4
Source File: bug8071705.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 5
Source File: bug8071705.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 6
Source File: bug8071705.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 7
Source File: bug8071705.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 8
Source File: bug8071705.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 9
Source File: bug8071705.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 10
Source File: bug8071705.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 11
Source File: bug8071705.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 12
Source File: bug8071705.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 13
Source File: bug8071705.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
Example 14
Source File: PersistenceHandler.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * @return False if the given point is not inside any screen device that are currently available.
 */
private static boolean isOutOfScreen( int x, int y ) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    for( int j=0; j<gs.length; j++ ) {
        GraphicsDevice gd = gs[j];
        if( gd.getType() != GraphicsDevice.TYPE_RASTER_SCREEN )
            continue;
        Rectangle bounds = gd.getDefaultConfiguration().getBounds();
        if( bounds.contains( x, y ) )
            return false;
    }
    return true;
}
 
Example 15
Source File: SwingDisplayServer.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public final int getDpiResolution( )
{

	if ( iDpiResolution == 0 )
	{
		switch ( getGraphicsContext( ).getDeviceConfiguration( )
				.getDevice( )
				.getType( ) )
		{
			case GraphicsDevice.TYPE_RASTER_SCREEN :
				// This is the only reliable dpi for the display, the one in
				// g2d.getTransform()
				// will be 72 dpi for the display, even when the OS has a
				// different dpi set.
				iDpiResolution = computeScreenDpi();
				break;
			case GraphicsDevice.TYPE_PRINTER :
				// In that case the g2d already contains a transform with the right dpi of the printer
				// so we set the dpi to 72, since there is no adjustment needed
				iDpiResolution = 72;
				break;
			case GraphicsDevice.TYPE_IMAGE_BUFFER :
				if ( userResolution == 0 )
				{
					// Use value set by user, if none, use screen resolution
					iDpiResolution = computeScreenDpi( );
				}
				else
				{
					iDpiResolution = userResolution;
				}
				break;
		}

		adjustFractionalMetrics( );
	}
	return iDpiResolution;
}
 
Example 16
Source File: BytecoderGraphicsDevice.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@Override
public int getType() {
    return GraphicsDevice.TYPE_RASTER_SCREEN;
}
 
Example 17
Source File: PageDrawer.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void showAnnotation(PDAnnotation annotation) throws IOException
{
    lastClip = null;
    int deviceType = -1;
    if (graphics.getDeviceConfiguration() != null && 
        graphics.getDeviceConfiguration().getDevice() != null)
    {
        deviceType = graphics.getDeviceConfiguration().getDevice().getType();
    }
    if (deviceType == GraphicsDevice.TYPE_PRINTER && !annotation.isPrinted())
    {
        return;
    }
    if (deviceType == GraphicsDevice.TYPE_RASTER_SCREEN && annotation.isNoView())
    {
        return;
    }
    if (annotation.isHidden())
    {
        return;
    }
    if (annotation.isInvisible() && annotation instanceof PDAnnotationUnknown)
    {
        // "If set, do not display the annotation if it does not belong to one
        // of the standard annotation types and no annotation handler is available."
        return;
    }
    //TODO support NoZoom, example can be found in p5 of PDFBOX-2348

    if (isHiddenOCG(annotation.getOptionalContent()))
    {
        return;
    }
   
    PDAppearanceDictionary appearance = annotation.getAppearance();
    if (appearance == null || appearance.getNormalAppearance() == null)
    {
        annotation.constructAppearances(renderer.document);
    }

    if (annotation.isNoRotate() && getCurrentPage().getRotation() != 0)
    {
        PDRectangle rect = annotation.getRectangle();
        AffineTransform savedTransform = graphics.getTransform();
        // "The upper-left corner of the annotation remains at the same point in
        //  default user space; the annotation pivots around that point."
        graphics.rotate(Math.toRadians(getCurrentPage().getRotation()),
                rect.getLowerLeftX(), rect.getUpperRightY());
        super.showAnnotation(annotation);
        graphics.setTransform(savedTransform);
    }
    else
    {
        super.showAnnotation(annotation);
    }
}
 
Example 18
Source File: PageDrawer.java    From sambox with Apache License 2.0 4 votes vote down vote up
@Override
public void showAnnotation(PDAnnotation annotation) throws IOException
{
    lastClip = null;
    int deviceType = -1;
    if (graphics.getDeviceConfiguration() != null
            && graphics.getDeviceConfiguration().getDevice() != null)
    {
        deviceType = graphics.getDeviceConfiguration().getDevice().getType();
    }
    if (deviceType == GraphicsDevice.TYPE_PRINTER && !annotation.isPrinted())
    {
        return;
    }
    if (deviceType == GraphicsDevice.TYPE_RASTER_SCREEN && annotation.isNoView())
    {
        return;
    }
    if (annotation.isHidden())
    {
        return;
    }
    if (annotation.isInvisible() && annotation instanceof PDAnnotationUnknown)
    {
        // "If set, do not display the annotation if it does not belong to one
        // of the standard annotation types and no annotation handler is available."
        return;
    }
    // TODO support NoZoom, example can be found in p5 of PDFBOX-2348

    if (isHiddenOCG(annotation.getOptionalContent()))
    {
        return;
    }

    PDAppearanceDictionary appearance = annotation.getAppearance();
    if (appearance == null || appearance.getNormalAppearance() == null)
    {
        // TODO: Improve memory consumption by passing a ScratchFile
        annotation.constructAppearances();
    }

    if (annotation.isNoRotate() && getCurrentPage().getRotation() != 0)
    {
        PDRectangle rect = annotation.getRectangle();
        AffineTransform savedTransform = graphics.getTransform();
        // "The upper-left corner of the annotation remains at the same point in
        // default user space; the annotation pivots around that point."
        graphics.rotate(Math.toRadians(getCurrentPage().getRotation()), rect.getLowerLeftX(),
                rect.getUpperRightY());
        super.showAnnotation(annotation);
        graphics.setTransform(savedTransform);
    }
    else
    {
        super.showAnnotation(annotation);
    }
}