当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.getCenterX方法代码示例

本文整理汇总了Java中java.awt.Rectangle.getCenterX方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getCenterX方法的具体用法?Java Rectangle.getCenterX怎么用?Java Rectangle.getCenterX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Rectangle的用法示例。


在下文中一共展示了Rectangle.getCenterX方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSplash

import java.awt.Rectangle; //导入方法依赖的package包/类
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!");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:UnixMultiResolutionSplashTest.java

示例2: testSplash

import java.awt.Rectangle; //导入方法依赖的package包/类
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!");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:MultiResolutionSplashTest.java

示例3: tick

import java.awt.Rectangle; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:CenteredZoomAnimator.java

示例4: init

import java.awt.Rectangle; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:FruchtermanReingoldLayout.java

示例5: draw

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void draw(Graphics g, Rectangle bounds)
{
	final int childWidth = bounds.width - (PADDING_SIZE * 2);

	// Start placing children from here...
	int nextY = bounds.y;

	final int childCount = getChildCount();
	for( int i = 0; i < childCount; i++ )
	{
		Renderer child = getChild(i);

		// Determine child boundries
		Rectangle childBound = new Rectangle();
		childBound.x = bounds.x + PADDING_SIZE;
		childBound.y = nextY;
		childBound.width = childWidth;
		childBound.height = child.getSize(g).height;

		// Draw child
		child.draw(g, childBound);

		// Next child Y coordinate.
		nextY += childBound.height;
	}

	int maxY = bounds.y + bounds.height;
	if( nextY < maxY )
	{
		int centreX = (int) bounds.getCenterX();
		g.setColor(ARROW_COLOUR);
		g.drawLine(centreX, nextY, centreX, maxY);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:36,代码来源:SerialRenderer.java

示例6: drawOverEntities

import java.awt.Rectangle; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Chroniaro,项目名称:What-Happened-to-Station-7,代码行数:15,代码来源:TileDamage.java

示例7: testSplash

import java.awt.Rectangle; //导入方法依赖的package包/类
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!");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:MultiResolutionSplashTest.java

示例8: searchNext

import java.awt.Rectangle; //导入方法依赖的package包/类
private int searchNext(JmtCell prev) {
	Rectangle boundspadre = GraphConstants.getBounds((prev).getAttributes()).getBounds();
	Object[] listEdges = null;
	GraphModel graphmodel = graph.getModel();
	List<Object> next = new ArrayList<Object>();

	if (flag1 == false && prev.seen == false) {
		if (!flag2) {
			boundspadre.setLocation(x, y + ((e + 1) * (42 + heightMax)) - (int) (boundspadre.getHeight() / 2) + 30);
		} else {
			boundspadre.setLocation(x - (int) (boundspadre.getWidth() / 2), y + ((e + 1) * (42 + heightMax))
					- (int) (boundspadre.getHeight() / 2) + 30);
		}

		GraphConstants.setBounds(prev.getAttributes(), boundspadre);
		x = (int) boundspadre.getCenterX() + widthMax + 50;
		prev.seen = true;
		flag2 = true;
	}

	listEdges = DefaultGraphModel.getOutgoingEdges(graphmodel, prev);
	Vector<Object> listEdgestmp = new Vector<Object>();
	for (Object listEdge : listEdges) {
		JmtCell qq = (JmtCell) (graphmodel.getParent(graphmodel.getTarget(listEdge)));
		if (!(qq).seen) {
			listEdgestmp.add(listEdge);
		}
	}
	listEdges = listEdgestmp.toArray();

	int numTarget = listEdges.length;
	if (numTarget == 0) {
		return 1;
	}

	for (int k = 0; k < numTarget; k++) {
		next.add((graphmodel.getParent(graphmodel.getTarget(listEdges[k]))));
	}

	int j = 1;
	if (inRepositionSons == false && ((JmtCell) next.get(0)).seen == false) {
		j = searchNext((JmtCell) next.get(0));
	} else if (inRepositionSons == true && ((JmtCell) next.get(0)).seen == false) {
		Rectangle bounds = GraphConstants.getBounds(((JmtCell) next.get(0)).getAttributes()).getBounds();
		bounds.setLocation((int) (boundspadre.getCenterX()) + widthMax + 50 - (int) (bounds.getWidth() / 2),
				(int) boundspadre.getCenterY() - (int) (bounds.getHeight() / 2));
		GraphConstants.setBounds(((JmtCell) next.get(0)).getAttributes(), bounds);

		((JmtCell) next.get(0)).seen = true;
		j = searchNext((JmtCell) next.get(0));
	}

	if (numTarget > 0) {
		if (!flag) {
			repositionSons(prev, next, j - 1, 1);
		} else {
			repositionSons(prev, next, -1, 0);
		}
		flag = false;
	}

	(prev).sons = 0;
	for (int w = 0; w < numTarget; w++) {
		prev.sons += ((JmtCell) next.get(w)).sons;
	}

	return prev.sons;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:69,代码来源:Mediator.java

示例9: searchNext

import java.awt.Rectangle; //导入方法依赖的package包/类
private int searchNext(JmtCell prev) {
	Rectangle boundspadre = GraphConstants.getBounds((prev).getAttributes()).getBounds();
	Object[] listEdges = null;
	GraphModel graphmodel = graph.getModel();
	List<Object> next = new ArrayList<Object>();

	if (flag1 == false && prev.seen == false) {

		// Rectangle bounds =
		// GraphConstants.getBounds(((JmtCell)prev).getAttributes()).getBounds();
		if (!flag2) {
			boundspadre.setLocation(x, y + ((e + 1) * (42 + heightMax)) - (int) (boundspadre.getHeight() / 2) + 30);
		} else {
			boundspadre.setLocation(x - (int) (boundspadre.getWidth() / 2), y + ((e + 1) * (42 + heightMax))
					- (int) (boundspadre.getHeight() / 2) + 30);
		}

		GraphConstants.setBounds(prev.getAttributes(), boundspadre);
		x = (int) boundspadre.getCenterX() + widthMax + 50;
		prev.seen = true;
		flag2 = true;
	}

	// inserisco tutti gli archi uscenti e entranti di min.get(j) in
	// listEdges
	listEdges = DefaultGraphModel.getOutgoingEdges(graphmodel, prev);
	Vector<Object> listEdgestmp = new Vector<Object>();
	for (Object listEdge : listEdges) {
		JmtCell qq = (JmtCell) (graphmodel.getParent(graphmodel.getTarget(listEdge)));
		if (!(qq).seen) {
			listEdgestmp.add(listEdge);
		}
	}
	listEdges = listEdgestmp.toArray();

	int numTarget = listEdges.length;
	if (numTarget == 0) {
		return 1;
	}

	for (int k = 0; k < numTarget; k++) {
		next.add((graphmodel.getParent(graphmodel.getTarget(listEdges[k]))));
	}

	int j = 1;
	if (inRepositionSons == false && ((JmtCell) next.get(0)).seen == false) {
		j = searchNext((JmtCell) next.get(0));
	} else if (inRepositionSons == true && ((JmtCell) next.get(0)).seen == false) {

		Rectangle bounds = GraphConstants.getBounds(((JmtCell) next.get(0)).getAttributes()).getBounds();
		bounds.setLocation((int) (boundspadre.getCenterX()) + widthMax + 50 - (int) (bounds.getWidth() / 2), (int) boundspadre.getCenterY()
				- (int) (bounds.getHeight() / 2));
		GraphConstants.setBounds(((JmtCell) next.get(0)).getAttributes(), bounds);

		((JmtCell) next.get(0)).seen = true;
		j = searchNext((JmtCell) next.get(0));
	}

	if (numTarget > 0) {
		if (!flag) {
			repositionSons(prev, next, j - 1, 1);
		} else {
			repositionSons(prev, next, -1, 0);
		}
		flag = false;
	}

	(prev).sons = 0;
	for (int w = 0; w < numTarget; w++) {
		prev.sons += ((JmtCell) next.get(w)).sons;
	}

	return prev.sons;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:75,代码来源:Mediator.java

示例10: draw

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void draw(Graphics g, Rectangle bounds)
{
	g.setFont(Renderer.DEFAULT_FONT);

	final int centreX = (int) bounds.getCenterX();
	int topY = bounds.y;

	// Draw our start point
	drawCircledText(g, START_TEXT, centreX, topY);
	topY += OVAL_HEIGHT;

	drawLeadingOutArrow(g, centreX, topY, HALF_ARROW_HEIGHT);
	topY += HALF_ARROW_HEIGHT;

	// Get ready to draw our child
	Renderer child = getChild(0);
	Dimension childSize = child.getSize(g);
	Rectangle childBound = new Rectangle();
	childBound.x = centreX - (childSize.width / 2);
	childBound.y = topY;
	childBound.width = childSize.width;
	childBound.height = childSize.height;

	child.draw(g, childBound);
	topY += childSize.height;

	// Draw our end point
	drawLeadingInArrow(g, centreX, topY, HALF_ARROW_HEIGHT);
	topY += HALF_ARROW_HEIGHT;

	drawCircledText(g, END_TEXT, centreX, topY);
	topY += OVAL_HEIGHT;

	// Draw any legend elements
	topY += LEGEND_PADDING;
	g.setFont(Renderer.DEFAULT_FONT);
	int legendX = bounds.x + PADDING_SIZE;
	for( Map.Entry<Color, String> entry : legendText.entrySet() )
	{
		int textHeight = (int) getTextSize(g, entry.getValue()).getHeight();

		g.setColor(entry.getKey());
		g.fillRect(legendX, topY, textHeight, textHeight);
		g.setColor(Color.BLACK);
		g.drawRect(legendX, topY, textHeight, textHeight);

		g.drawString(entry.getValue(), legendX + textHeight + PADDING_SIZE, topY + textHeight);

		topY += textHeight + LEGEND_PADDING;
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:53,代码来源:RootRenderer.java

示例11: draw

import java.awt.Rectangle; //导入方法依赖的package包/类
@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);
}
 
开发者ID:equella,项目名称:Equella,代码行数:51,代码来源:TaskRenderer.java

示例12: draw

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void draw(Graphics g, Rectangle bounds)
{
	final int centreX = (int) bounds.getCenterX();

	// Draw the leading arrow
	drawLeadingInArrow(g, centreX, bounds.y, HALF_ARROW_HEIGHT);

	// Draw the trailing arrow
	drawLeadingOutArrow(g, centreX, bounds.y + bounds.height - HALF_ARROW_HEIGHT, HALF_ARROW_HEIGHT);

	// Get ready to draw our child
	Dimension childSize = super.getSizeWithNoPadding(g);
	Rectangle childBound = new Rectangle();
	childBound.x = centreX - (childSize.width / 2);
	childBound.y = bounds.y + (HALF_ARROW_HEIGHT * 2) + DIAMOND_SIZE;
	childBound.width = childSize.width;
	childBound.height = childSize.height;

	// Draw child
	super.draw(g, childBound);

	// Do some general calculations
	Rectangle2D textSize = g.getFontMetrics().getStringBounds(nodeName, g);

	int diamondTop = bounds.y + HALF_ARROW_HEIGHT;
	int halfDiamondY = DIAMOND_SIZE / 2;
	int halfDiamondX = (int) (textSize.getWidth() / 2) + (PADDING_SIZE * 2);

	int textStartX = centreX - (int) (textSize.getWidth() / 2);
	int textStartY = diamondTop + halfDiamondY + (int) (textSize.getHeight() / 2);

	// Draw the diamond
	int[] pointsX = {centreX, centreX - halfDiamondX, centreX, centreX + halfDiamondX};
	int[] pointsY = {diamondTop, diamondTop + halfDiamondY, diamondTop + DIAMOND_SIZE, diamondTop + halfDiamondY};

	if( getHilight() != null )
	{
		g.setColor(getHilight());
		g.fillPolygon(pointsX, pointsY, pointsX.length);
	}

	g.setColor(Color.BLACK);
	g.drawPolygon(pointsX, pointsY, pointsX.length);

	// Draw the text
	g.setColor(Color.BLACK);
	g.drawString(nodeName, textStartX, textStartY - 3);

	// Draw the arrow leading out from the diamond
	drawLeadingOutArrow(g, centreX, diamondTop + DIAMOND_SIZE, HALF_ARROW_HEIGHT);

	// Draw connecting lines
	int lineX1 = centreX - (childSize.width / 2) - PADDING_SIZE;
	int lineX2 = centreX - halfDiamondX;
	int lineY1 = diamondTop + halfDiamondY;
	int lineY2 = lineY1 + HALF_ARROW_HEIGHT + halfDiamondY + childSize.height;

	lineX1 = Math.min(lineX1, lineX2);

	g.setColor(ARROW_COLOUR);
	g.drawLine(lineX1, lineY1, lineX2, lineY1);
	g.drawLine(lineX1, lineY2, centreX, lineY2);
	g.drawLine(lineX1, lineY1, lineX1, lineY2);

	// Draw sideways pointer on arrow
	g.drawLine(centreX - ARROW_HEAD_HEIGHT, lineY2 - ARROW_HEAD_WIDTH, centreX, lineY2);
	g.drawLine(centreX - ARROW_HEAD_HEIGHT, lineY2 + ARROW_HEAD_WIDTH, centreX, lineY2);
}
 
开发者ID:equella,项目名称:Equella,代码行数:70,代码来源:DecisionRenderer.java


注:本文中的java.awt.Rectangle.getCenterX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。