Java Code Examples for java.awt.Rectangle.getCenterY()

The following are Jave code examples for showing how to use getCenterY() of the java.awt.Rectangle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: UnixMultiResolutionSplashTest.java   View Source Code Vote up 8 votes
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
Project: openjdk-jdk10   File: MultiResolutionSplashTest.java   View Source Code Vote up 6 votes
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 3
Project: incubator-netbeans   File: CenteredZoomAnimator.java   View Source Code Vote up 5 votes
@Override public void tick(double progress) {
    double nextZoom = progress >= 1.0 ? targetZoom :
        (sourceZoom + progress * (targetZoom - sourceZoom));

    Scene scene = getScene();
    JComponent view = scene.getView ();

    if (view != null) {
        Point viewLocation = view.getVisibleRect ().getLocation();
        Dimension viewSize = view.getVisibleRect ().getSize();
        Point oldCenter = scene.convertSceneToView (center);

        ((DependencyGraphScene)scene).setMyZoomFactor (nextZoom);
        scene.validate (); // HINT - forcing to change preferred size of the JComponent view

        Point newCenter = scene.convertSceneToView (center);
        Rectangle viewBounds = view.getVisibleRect();
        Point visibleCenter = new Point((int)viewBounds.getCenterX(), (int)viewBounds.getCenterY());
        newCenter.x += Math.round((newCenter.x - visibleCenter.x) * progress);
        newCenter.y += Math.round((newCenter.y - visibleCenter.y) * progress);

        view.scrollRectToVisible (new Rectangle (
                newCenter.x - oldCenter.x + viewLocation.x,
                newCenter.y - oldCenter.y + viewLocation.y,
                viewSize.width,
                viewSize.height
        ));
    } else {
        ((DependencyGraphScene)scene).setMyZoomFactor (nextZoom);
    }
}
 
Example 4
Project: incubator-netbeans   File: FruchtermanReingoldLayout.java   View Source Code Vote up 5 votes
private void init() {
    int nds = scene.getNodes().size();
    bounds = new Rectangle(magicSizeConstant  + (magicSizeMultiplier * nds), 
                           magicSizeConstant  + (magicSizeMultiplier * nds)); //g.getMaximumBounds();
    temp = bounds.getWidth() / 10;
    forceConstant = 0.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds);
    
    GraphNode<I> rn = scene.getRootGraphNode();
    NodeWidget rw = getWidget(rn);
    rw.locX = bounds.getCenterX();
    rw.locY = bounds.getCenterY();
    rw.setFixed(true);
    layoutCirculary(scene.getNodes(), rn);
}
 
Example 5
Project: What-Happened-to-Station-7   File: TileDamage.java   View Source Code Vote up 5 votes
@Override
public void drawOverEntities(Graphics2D g, int s)
{
	float time = Math.max(T(), getLength());
	Shape bound = pos.getBorder(s);
	Rectangle border = bound.getBounds();
	Point2D.Double f = new Point2D.Double(border.getCenterX(), border.getCenterY());
	Paint grad = new RadialGradientPaint(f, s / 3, new float[] {0, .7f, 1}, new Color[]{
			new Color(1, 0, 0, 0), 
			new Color(1, 0, 0, .2f * (1 - time / getLength())), 
			new Color(1, 0, 0, .8f * (1 - time / getLength()))});
	g.setPaint(grad);
	g.fill(bound);
}
 
Example 6
Project: jdk8u-jdk   File: MultiResolutionSplashTest.java   View Source Code Vote up 5 votes
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
Project: Equella   File: TaskRenderer.java   View Source Code Vote up 4 votes
@Override
public void draw(Graphics g, Rectangle bounds)
{
	// Make a few coordinate calculations
	Dimension totalTextSize = getTextArea(g);

	int maxTextStartX = (int) (bounds.getCenterX() - (totalTextSize.getWidth() / 2));
	int maxTextStartY = (int) (bounds.getCenterY() + (totalTextSize.getHeight() / 2));

	int boxStartY = maxTextStartY - (int) totalTextSize.getHeight() - PADDING_SIZE;
	int boxStartX = maxTextStartX - PADDING_SIZE;
	int boxWidth = (int) totalTextSize.getWidth() + (PADDING_SIZE * 2);
	int boxHeight = (int) totalTextSize.getHeight() + (PADDING_SIZE * 2);

	// Draw the box
	if( getHilight() != null )
	{
		g.setColor(getHilight());
		g.fillRect(boxStartX, boxStartY, boxWidth, boxHeight);
	}
	g.setColor(Color.BLACK);
	g.drawRect(boxStartX, boxStartY, boxWidth, boxHeight);

	// Draw the text
	Dimension textSize = getTextArea(g, displayName);
	int textX = (int) (bounds.getCenterX() - (textSize.getWidth() / 2));
	int textY = boxStartY + PADDING_SIZE + (int) textSize.getHeight();

	g.setFont(DEFAULT_FONT);
	g.drawString(displayName, textX, textY - 2);

	if( getMessage() != null )
	{
		textSize = getTextArea(g, getMessage());
		textX = (int) (bounds.getCenterX() - (textSize.getWidth() / 2));
		textY += NOTE_PADDING + (int) textSize.getHeight();

		g.setFont(NOTE_FONT);
		g.drawString(getMessage(), textX, textY - 2);
	}

	// Draw leading arrow
	drawLeadingInArrow(g, (int) bounds.getCenterX(), bounds.y, boxStartY - bounds.y);

	// Draw trailing arrow
	int arrowX = (int) bounds.getCenterX();
	int arrowY = boxStartY + boxHeight;
	int arrowLength = (bounds.y + bounds.height) - (boxStartY + boxHeight);
	drawLeadingOutArrow(g, arrowX, arrowY, arrowLength);
}