Java Code Examples for java.awt.SplashScreen#getBounds()

The following examples show how to use java.awt.SplashScreen#getBounds() . 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: MultiResolutionSplashTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 2
Source File: UnixMultiResolutionSplashTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();
    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }
    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();
    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;
    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 3
Source File: MultiResolutionSplashTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 4
Source File: MultiResolutionSplashTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 5
Source File: MultiResolutionSplashTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 6
Source File: MultiResolutionSplashTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    if(splashBounds.width != IMAGE_WIDTH){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if(splashBounds.height != IMAGE_HEIGHT){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 7
Source File: MultiResolutionSplashTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    if(splashBounds.width != IMAGE_WIDTH){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if(splashBounds.height != IMAGE_HEIGHT){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 8
Source File: MultiResolutionSplashTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    if(splashBounds.width != IMAGE_WIDTH){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if(splashBounds.height != IMAGE_HEIGHT){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 9
Source File: MultiResolutionSplashTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    if(splashBounds.width != IMAGE_WIDTH){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if(splashBounds.height != IMAGE_HEIGHT){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 10
Source File: MultiResolutionSplashTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();
    if (splashBounds.width != IMAGE_WIDTH) {
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if (splashBounds.height != IMAGE_HEIGHT) {
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);
    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 11
Source File: MultiResolutionSplashTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    if(splashBounds.width != IMAGE_WIDTH){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if(splashBounds.height != IMAGE_HEIGHT){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 12
Source File: MultiResolutionSplashTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    if(splashBounds.width != IMAGE_WIDTH){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if(splashBounds.height != IMAGE_HEIGHT){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 13
Source File: DBrowser.java    From Rel with Apache License 2.0 4 votes vote down vote up
private static void launch(String[] args) {
	Display.setAppName(Version.getAppName());
	Display.setAppVersion(Version.getVersion());
	final Display display = new Display();
	
	OpenDocumentEventProcessor openDocProcessor = new OpenDocumentEventProcessor();
	display.addListener(SWT.OpenDocument, openDocProcessor);
	
	openDocProcessor.addFilesToOpen(args);		

	if (Util.isMac())
		executeSplashInteractor(() -> {
			try {
				Thread.sleep(300);
			} catch (InterruptedException e1) {
			}
		});

	try {
		Class.forName("org.reldb.rel.Rel");
		localRel = true;
	} catch (ClassNotFoundException cnfe) {
		localRel = false;
	}
	
	OSSpecific.launch(Version.getAppName(),
		event -> quit(),
		event -> new AboutDialog(shell).open(),
		event -> new Preferences(shell).show()
	);

	if (!Util.isMac()) {
		SplashScreen splash = SplashScreen.getSplashScreen();
		if (splash != null && localRel && !Preferences.getPreferenceBoolean(PreferencePageGeneral.SKIP_DEFAULT_DB_LOAD)) {
			Graphics2D gc = splash.createGraphics();
			Rectangle rect = splash.getBounds();
			int barWidth = rect.width - 20;
			int barHeight = 10;
			Rectangle progressBarRect = new Rectangle(10, rect.height - 20, barWidth, barHeight);
			gc.draw3DRect(progressBarRect.x, progressBarRect.y, progressBarRect.width, progressBarRect.height, false);
			gc.setColor(Color.green);
			(new Thread(() -> {
				while (SplashScreen.getSplashScreen() != null) {
					int percent = Loading.getPercentageOfExpectedMessages();
					int drawExtent = Math.min(barWidth * percent / 100, barWidth);
					gc.fillRect(progressBarRect.x, progressBarRect.y, drawExtent, barHeight);
					splash.update();					
					try {
						Thread.sleep(250);
					} catch (InterruptedException e) {
					}
				}							
			})).start();
		}			
	}
	
	shell = createShell();
	shell.setImage(IconLoader.loadIcon("RelIcon"));
	shell.setImages(loadIcons(display));
	shell.setText(Version.getAppID());
	shell.addListener(SWT.Close, e -> {
		shell.dispose();
	});
	shell.addDisposeListener(e -> quit());
	shell.layout();

	Loading.start();
	
	Core.launch(openDocProcessor, shell);
	
	if (!Util.isMac())
		closeSplash();
	
	shell.open();		
	
	while (!display.isDisposed()) {
		try {
			if (!display.readAndDispatch())
				display.sleep();
		} catch (Throwable t) {
			System.out.println("DBrowser: Exception: " + t);
			t.printStackTrace();
		}
	}
}