本文整理了Java中java.awt.Rectangle.getCenterY
方法的一些代码示例,展示了Rectangle.getCenterY
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rectangle.getCenterY
方法的具体详情如下:
包路径:java.awt.Rectangle
类名称:Rectangle
方法名:getCenterY
暂无
代码示例来源:origin: plantuml/plantuml
/**
* Puts diagram shapes in pseudo-3d order starting from back to front
*
*/
public int compare(Object object1, Object object2) {
if(!(object1 instanceof DiagramShape)
|| !(object2 instanceof DiagramShape))
throw new RuntimeException("This comparator can only compare DiagramShapeS");
DiagramShape shape1 = (DiagramShape) object1;
DiagramShape shape2 = (DiagramShape) object2;
double y1 = shape1.makeIntoPath().getBounds().getCenterY();
double y2 = shape2.makeIntoPath().getBounds().getCenterY();
if(y1 > y2) return -1;
if(y1 < y2) return 1;
return 0;
}
代码示例来源: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 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: 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: org.cogchar/org.cogchar.lib.freckler.api
public static Point getRectangleCenterPoint(Rectangle r) {
int x = (int) Math.round(r.getCenterX());
int y = (int) Math.round(r.getCenterY());
Point p = new Point(x, y);
return p;
}
public SightPort getViewPort() {
代码示例来源:origin: org.cogchar/org.cogchar.lib.sight.api
public static Point getRectangleCenterPoint(Rectangle r) {
int x = (int) Math.round(r.getCenterX());
int y = (int) Math.round(r.getCenterY());
Point p = new Point(x, y);
return p;
}
public SightPort getViewPort() {
代码示例来源:origin: stackoverflow.com
final int STEPS = 10000; //Number of steps in a full 360 degree rotation
double theta = (2*Math.PI) / STEPS; //Single step "size" in radians
Rectangle bounds = area.getBounds(); //Getting the bounds to find the center of the Area
AffineTransform trans = AffineTransform.getRotateInstance(theta, bounds.getCenterX(), bounds.getCenterY()); //Transformation matrix for theta radians around the center
//Rotate a full 360 degrees in small steps
for(int i = 0; i < STEPS; i++)
{
area.transform(trans);
}
代码示例来源: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: 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: AliView/AliView
private AliCursor createNewAliCursor(){
//alignment.clearSelection();
Point center = alignmentPane.matrixCoordToPaneCoord((new Point((int)alignmentPane.getVisibleRect().getCenterX(), (int)alignmentPane.getVisibleRect().getCenterY())));
AliCursor newAliCursor = new AliCursor(center.x, center.y);
return newAliCursor;
}
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!