Java Code Examples for java.awt.geom.Rectangle2D#setFrameFromCenter()
The following examples show how to use
java.awt.geom.Rectangle2D#setFrameFromCenter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AgentLayer.java From gama with GNU General Public License v3.0 | 6 votes |
@Override public Set<IAgent> collectAgentsAt(final int x, final int y, final IDisplaySurface g) { try (final Collector.AsSet<IAgent> selectedAgents = Collector.getSet()) { final Rectangle2D selection = new Rectangle2D.Double(); selection.setFrameFromCenter(x, y, x + IDisplaySurface.SELECTION_SIZE / 2, y + IDisplaySurface.SELECTION_SIZE / 2); shapes.forEachPair((a, b) -> { if (b.intersects(selection)) { selectedAgents.add(a); } return true; }); return selectedAgents.items(); } }
Example 2
Source File: DrawTest.java From spring-boot-cookbook with Apache License 2.0 | 5 votes |
@Override public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; double centerX = DEFAULT_W / 2; double centerY = DEFAULT_H / 2; double conerX = centerX + 100; double conerY = centerY + 100; Rectangle2D rect = new Rectangle2D.Double(); rect.setFrameFromCenter(centerX, centerY, conerX, conerY); Ellipse2D ellipse = new Ellipse2D.Double(); ellipse.setFrame(rect); Ellipse2D circle = new Ellipse2D.Double(); double radius = Point2D.distance(centerX, centerY, conerX, conerY); circle.setFrameFromCenter(centerX, centerY, centerX + radius, centerY + radius); Line2D line = new Line2D.Double(conerX, conerY, conerX - 200, conerY - 200); Line2D line2 = new Line2D.Double(conerX - 200, conerY, conerX, conerY - 200); // g2d.draw(rect); g2d.draw(ellipse); g2d.setColor(Color.BLUE); g2d.draw(circle); // g2d.draw(line); // g2d.draw(line2); }