本文整理了Java中java.awt.Rectangle.getCenterX
方法的一些代码示例,展示了Rectangle.getCenterX
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rectangle.getCenterX
方法的具体详情如下:
包路径:java.awt.Rectangle
类名称:Rectangle
方法名:getCenterX
暂无
代码示例来源:origin: Activiti/Activiti
public void drawCollapsedMarker(int x,
int y,
int width,
int height) {
// rectangle
int rectangleWidth = MARKER_WIDTH;
int rectangleHeight = MARKER_WIDTH;
Rectangle rect = new Rectangle(x + (width - rectangleWidth) / 2,
y + height - rectangleHeight - 3,
rectangleWidth,
rectangleHeight);
g.draw(rect);
// plus inside rectangle
Line2D.Double line = new Line2D.Double(rect.getCenterX(),
rect.getY() + 2,
rect.getCenterX(),
rect.getMaxY() - 2);
g.draw(line);
line = new Line2D.Double(rect.getMinX() + 2,
rect.getCenterY(),
rect.getMaxX() - 2,
rect.getCenterY());
g.draw(line);
}
代码示例来源:origin: plantuml/plantuml
private GeneralPath makeDecisionPath(Diagram diagram) {
if(points.size() != 4) return null;
Rectangle bounds = makeIntoPath().getBounds();
ShapePoint pointMid = new ShapePoint((float)bounds.getCenterX(), (float)bounds.getCenterY());
ShapePoint left = new ShapePoint((float)bounds.getMinX(), (float)pointMid.getY());
ShapePoint right = new ShapePoint((float)bounds.getMaxX(), (float)pointMid.getY());
ShapePoint top = new ShapePoint((float)pointMid.getX(), (float)bounds.getMinY());
ShapePoint bottom = new ShapePoint((float)pointMid.getX(), (float)bounds.getMaxY());
GeneralPath path = new GeneralPath();
path.moveTo(left.x, left.y);
path.lineTo(top.x, top.y);
path.lineTo(right.x, right.y);
path.lineTo(bottom.x, bottom.y);
path.closePath();
return path;
}
代码示例来源:origin: plantuml/plantuml
private GeneralPath makeTrapezoidPath(Diagram diagram, boolean inverted) {
if(points.size() != 4) return null;
Rectangle bounds = makeIntoPath().getBounds();
float offset = 0.7f * diagram.getCellWidth(); // fixed slope
if (inverted) offset = -offset;
ShapePoint ul = new ShapePoint((float)bounds.getMinX() + offset, (float)bounds.getMinY());
ShapePoint ur = new ShapePoint((float)bounds.getMaxX() - offset, (float)bounds.getMinY());
ShapePoint br = new ShapePoint((float)bounds.getMaxX() + offset, (float)bounds.getMaxY());
ShapePoint bl = new ShapePoint((float)bounds.getMinX() - offset, (float)bounds.getMaxY());
ShapePoint pointMid = new ShapePoint((float)bounds.getCenterX(), (float)bounds.getMaxY());
GeneralPath path = new GeneralPath();
path.moveTo(ul.x, ul.y);
path.lineTo(ur.x, ur.y);
path.lineTo(br.x, br.y);
path.lineTo(bl.x, bl.y);
path.closePath();
return path;
}
代码示例来源:origin: plantuml/plantuml
private GeneralPath makeDocumentPath(Diagram diagram) {
if(points.size() != 4) return null;
Rectangle bounds = makeIntoPath().getBounds();
ShapePoint point1 = new ShapePoint((float)bounds.getMinX(), (float)bounds.getMinY());
ShapePoint point2 = new ShapePoint((float)bounds.getMaxX(), (float)bounds.getMinY());
ShapePoint point3 = new ShapePoint((float)bounds.getMaxX(), (float)bounds.getMaxY());
ShapePoint point4 = new ShapePoint((float)bounds.getMinX(), (float)bounds.getMaxY());
ShapePoint pointMid = new ShapePoint((float)bounds.getCenterX(), (float)bounds.getMaxY());
GeneralPath path = new GeneralPath();
path.moveTo(point1.x, point1.y);
path.lineTo(point2.x, point2.y);
path.lineTo(point3.x, point3.y);
//int controlDX = diagram.getCellWidth();
//int controlDY = diagram.getCellHeight() / 2;
int controlDX = bounds.width / 6;
int controlDY = bounds.height / 8;
path.quadTo(pointMid.x + controlDX, pointMid.y - controlDY, pointMid.x, pointMid.y);
path.quadTo(pointMid.x - controlDX, pointMid.y + controlDY, point4.x, point4.y);
path.closePath();
return path;
}
代码示例来源:origin: plantuml/plantuml
private GeneralPath makeEllipsePath(Diagram diagram) {
if(points.size() != 4) return null;
Rectangle bounds = makeIntoPath().getBounds();
float xOff = (float) bounds.getWidth() * 0.5f * KAPPA;
float yOff = (float) bounds.getHeight() * 0.5f * KAPPA;
ShapePoint pointMid = new ShapePoint((float)bounds.getCenterX(), (float)bounds.getCenterY());
ShapePoint left = new ShapePoint((float)bounds.getMinX(), (float)pointMid.getY());
ShapePoint right = new ShapePoint((float)bounds.getMaxX(), (float)pointMid.getY());
ShapePoint top = new ShapePoint((float)pointMid.getX(), (float)bounds.getMinY());
ShapePoint bottom = new ShapePoint((float)pointMid.getX(), (float)bounds.getMaxY());
GeneralPath path = new GeneralPath();
path.moveTo(top.x, top.y);
path.curveTo(top.x + xOff, top.y, right.x, right.y - yOff, right.x, right.y);
path.curveTo(right.x, right.y + yOff, bottom.x + xOff, bottom.y, bottom.x, bottom.y);
path.curveTo(bottom.x - xOff, bottom.y, left.x, left.y + yOff, left.x, left.y);
path.curveTo(left.x, left.y - yOff, top.x - xOff, top.y, top.x, top.y);
path.closePath();
return path;
}
代码示例来源:origin: plantuml/plantuml
ShapePoint point4 = new ShapePoint((float)bounds.getMinX(), (float)bounds.getMaxY());
ShapePoint pointMidTop = new ShapePoint((float)bounds.getCenterX(), (float)bounds.getMinY());
ShapePoint pointMidBottom = new ShapePoint((float)bounds.getCenterX(), (float)bounds.getMaxY());
代码示例来源:origin: RaiMan/SikuliX2
private static Point getLocPopAt() {
Rectangle screen0 = Do.getDevice().getMonitor();
if (null == screen0) {
return null;
}
return new Point((int) screen0.getCenterX(), (int) screen0.getCenterY());
}
代码示例来源:origin: geotools/geotools
/**
* Calculates transforms suitable for aspect ratio matching. The world bounds will be centred in
* the screen area.
*/
private void calculateCenteringTransforms() {
double xscale = screenArea.getWidth() / bounds.getWidth();
double yscale = screenArea.getHeight() / bounds.getHeight();
double scale = Math.min(xscale, yscale);
double xoff = bounds.getMedian(0) * scale - screenArea.getCenterX();
double yoff = bounds.getMedian(1) * scale + screenArea.getCenterY();
worldToScreen = new AffineTransform(scale, 0, 0, -scale, -xoff, yoff);
try {
screenToWorld = worldToScreen.createInverse();
} catch (NoninvertibleTransformException ex) {
throw new RuntimeException("Unable to create coordinate transforms.", ex);
}
hasCenteringTransforms = true;
}
代码示例来源:origin: stackoverflow.com
Rectangle screenBounds = MouseInfo.getPointerInfo().getDevice().getDefaultConfiguration().getBounds();
int x = (int) screenBounds.getCenterX() - (jDialog.getWidth() / 2);
int y = (int) screenBounds.getCenterY() - (jDialog.getHeight() / 2);
jDialog.setLocation(x, y);
jDialog.setVisible(true);
代码示例来源:origin: Audiveris/audiveris
@Override
public Point getCentroid (Rectangle box)
{
if (centroidOffset == null) {
computeCentroidOffset();
}
return new Point(
(int) Math.rint(box.getCenterX() + (box.getWidth() * centroidOffset.getX())),
(int) Math.rint(box.getCenterY() + (box.getHeight() * centroidOffset.getY())));
}
代码示例来源:origin: org.fudaa.framework.fudaa/fudaa-common
private void initTransform(Rectangle _bounds, AffineTransform _transform) {
double centerY = _bounds.getCenterY();
double centerX = _bounds.getCenterX();
_transform.translate(centerX, centerY);
_transform.shear(shearX_, shearY_);
_transform.rotate(rotation_);
_transform.translate(-centerX, -centerY);
}
代码示例来源:origin: Syncleus/aparapi
void flatRender(Graphics2D _g, InstructionView _instructionView) {
_g.setColor(unselectedColor);
_g.fill(_instructionView.shape);
_g.setColor(Color.black);
stroke(_g, outlineStroke, _instructionView.shape);
text(_g, _instructionView.label, _instructionView.shape.getBounds().getCenterX()
- (_instructionView.shape.getBounds().getWidth() / 2), _instructionView.shape.getBounds().getCenterY());
}
代码示例来源:origin: com.sikulix/sikulixapi
private static Point getLocPopAt() {
Rectangle screen0 = rt.getMonitor(0);
if (null == screen0) {
return null;
}
return new Point((int) screen0.getCenterX(), (int) screen0.getCenterY());
}
代码示例来源:origin: com.bbossgroups.activiti/activiti-engine
public void drawCollapsedMarker(int x, int y, int width, int height) {
// rectangle
int rectangleWidth = MARKER_WIDTH;
int rectangleHeight = MARKER_WIDTH;
Rectangle rect = new Rectangle(x + (width - rectangleWidth) / 2, y + height - rectangleHeight - 3, rectangleWidth, rectangleHeight);
g.draw(rect);
// plus inside rectangle
Line2D.Double line = new Line2D.Double(rect.getCenterX(), rect.getY() + 2, rect.getCenterX(), rect.getMaxY() - 2);
g.draw(line);
line = new Line2D.Double(rect.getMinX() + 2, rect.getCenterY(), rect.getMaxX() - 2, rect.getCenterY());
g.draw(line);
}
代码示例来源:origin: chatty/chatty
public static Point getLocation(String setting) {
if (setting == null) {
return null;
}
String[] split = setting.split(";");
if (split.length < 2) {
return null;
}
IntegerPair coords = Helper.getNumbersFromString(split[0]);
IntegerPair size = Helper.getNumbersFromString(split[1]);
Rectangle r = new Rectangle(coords.a, coords.b, size.a, size.b);
return new Point((int)r.getCenterX() - SPLASH_WIDTH/2, (int)r.getCenterY() - SPLASH_HEIGHT/2);
}
代码示例来源:origin: com.clearnlp/clearnlp
/** Called by {@link TRTreePane#getGeometriesEdges(IntArrayList[])}. */
private int getGeometriesEdgesAux(IntArrayList[] groups, int id1, int id2)
{
return (int)(r_forms[id1].getCenterX() - ((double)(groups[id1].size() - 1) / 2 - groups[id1].indexOf(id2)) * GAP_EDGE_W);
}
代码示例来源:origin: com.googlecode.clearnlp/clearnlp
/** Called by {@link TRTreePane#getGeometriesEdges(IntArrayList[])}. */
private int getGeometriesEdgesAux(IntArrayList[] groups, int id1, int id2)
{
return (int)(r_forms[id1].getCenterX() - ((double)(groups[id1].size() - 1) / 2 - groups[id1].indexOf(id2)) * GAP_EDGE_W);
}
代码示例来源:origin: AliView/AliView
public Point getVisibleCenterMatrixPos() {
Rectangle rect = this.getVisibleRect();
Point centerPanePos = new Point((int)rect.getCenterX(),(int)rect.getCenterY());
Point centerMatrixPos = paneCoordToMatrixCoord(centerPanePos);
return centerMatrixPos;
}
代码示例来源:origin: bcdev/beam
private void scrollToCenterPath(final GeneralPath geoBoundaryPath, final JViewport viewport) {
final GeneralPath pixelPath = ProductUtils.convertToPixelPath(geoBoundaryPath, wmPainter.getGeoCoding());
final Rectangle viewRect = viewport.getViewRect();
final Rectangle pathBounds = pixelPath.getBounds();
setCenter(viewRect, new Point((int) pathBounds.getCenterX(), (int) pathBounds.getCenterY()));
final Dimension bounds = new Dimension(scaledImage.getWidth(null), scaledImage.getHeight(null));
ensureRectIsInBounds(viewRect, bounds);
viewport.scrollRectToVisible(viewRect);
}
代码示例来源:origin: bcdev/beam
private static void setCenter(final Rectangle rectangle, final Point center) {
final int diffX = center.x - (int) rectangle.getCenterX();
final int diffY = center.y - (int) rectangle.getCenterY();
final int x = ((int) rectangle.getX()) + diffX;
final int y = (int) (rectangle.getY() + diffY);
rectangle.setLocation(x, y);
}
内容来源于网络,如有侵权,请联系作者删除!