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); }
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; }
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; }
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; }
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; }
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());
private static Point getLocPopAt() { Rectangle screen0 = Do.getDevice().getMonitor(); if (null == screen0) { return null; } return new Point((int) screen0.getCenterX(), (int) screen0.getCenterY()); }
/** * 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; }
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);
@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()))); }
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); }
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()); }
private static Point getLocPopAt() { Rectangle screen0 = rt.getMonitor(0); if (null == screen0) { return null; } return new Point((int) screen0.getCenterX(), (int) screen0.getCenterY()); }
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); }
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); }
/** 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); }
/** 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); }
public Point getVisibleCenterMatrixPos() { Rectangle rect = this.getVisibleRect(); Point centerPanePos = new Point((int)rect.getCenterX(),(int)rect.getCenterY()); Point centerMatrixPos = paneCoordToMatrixCoord(centerPanePos); return centerMatrixPos; }
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); }
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); }