public void add(String label, Point2D point) { Rectangle2D.Double bounds = new Rectangle2D.Double(point.getX(), point.getY(), 0.0, 0.0); this.childMap.put(label, bounds); if (this.root == null) { this.root = new Rectangle2D.Double(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()); } else { this.root.add(point); } }
private void clearPathGraphics(Rectangle2D.Double bounds, Graphics2D gfx) throws IOException { Color transparent = new Color(255, 255, 255, 0); gfx.setColor(transparent); gfx.fillRect(0, 0, (int) bounds.getWidth() * 2, (int) bounds.getHeight() * 2); Color fill = pdfColorToColor(state.getNonStrokingColor()); Color stroke = pdfColorToColor(state.getStrokingColor()); // crop off rendered path whitespace gfx.translate(-bounds.getX(), -bounds.getY()); gfx.setPaint(stroke); gfx.setColor(fill); }
@Override public synchronized Rectangle2D cellRectangle(Graphics2D gs, CellContext context) { if( gs==null )throw new IllegalArgumentException("gs == null"); if( context==null )throw new IllegalArgumentException("context == null"); FlatBlock tb = prepare(gs, context); Pair<Double,Double> pos = evalPosition(context, tb); Rectangle2D.Double rect = tb.getBounds(); double x = pos.A()+paddingLeft; double y = pos.B()+paddingTop; rect = new Rectangle2D.Double(x-paddingLeft, y-paddingTop, rect.getWidth()+paddingLeft+paddingRight, rect.getHeight()+paddingTop+paddingBottom); return rect; }
private Set<Node> getNodesInTravelZone(final Network network) { double minX = travelZone.getX(); double maxX = travelZone.getWidth() + minX; double minY = travelZone.getY(); double maxY = travelZone.getHeight() + minY; // largen the zone... maxX += (maxX - minX) * ZONE_EXPANSION; minX -= (maxX - minX) * ZONE_EXPANSION; maxY += (maxY - minY) * ZONE_EXPANSION; minY -= (maxY - minY) * ZONE_EXPANSION; Set<Node> resultNodes = new TreeSet<Node>(); for (Node n : network.getNodes().values()) { if (n.getCoord().getX() <= maxX && n.getCoord().getX() >= minX && n.getCoord().getY() <= maxY && n.getCoord().getY() >= minY) { resultNodes.add(n); } } return resultNodes; }
public MArea preprocessing(MArea piece, Rectangle2D.Double container) throws Exception { Rectangle2D.Double bbox = piece.getBoundingBox2D(); if (bbox.getWidth() > container.getWidth()) { piece.rotate(90); bbox = piece.getBoundingBox2D(); if (bbox.getWidth() > container.getWidth() || bbox.getHeight() > container.getHeight()) throw new Exception("The piece dimensions seem to be bigger than the container's"); return piece; } if (bbox.getHeight() > container.getHeight()) { piece.rotate(90); bbox = piece.getBoundingBox2D(); if (bbox.getWidth() > container.getWidth() || bbox.getHeight() > container.getHeight()) throw new Exception("The piece dimensions seem to be bigger than the container's"); return piece; } return piece; }
@Override public void updateOverlay(final EllipseFigure figure, final OverlayView view) { super.updateOverlay(figure, view); final EllipseOverlay overlay = downcastOverlay(view.getData()); final Rectangle2D.Double bounds = figure.getBounds(); final double x = bounds.getMinX(); final double y = bounds.getMinY(); final double w = bounds.getWidth(); final double h = bounds.getHeight(); overlay.setOrigin(x + w / 2, 0); overlay.setOrigin(y + h / 2, 1); overlay.setRadius(w / 2, 0); overlay.setRadius(h / 2, 1); overlay.update(); toolService.reportRectangle(x, y, w, h); }
@Override public void updateOverlay(final RectangleFigure figure, final OverlayView view) { super.updateOverlay(figure, view); final RectangleOverlay overlay = downcastOverlay(view.getData()); final Rectangle2D.Double bounds = figure.getBounds(); final double x = bounds.getMinX(); final double y = bounds.getMinY(); final double w = bounds.getWidth(); final double h = bounds.getHeight(); overlay.setOrigin(x, 0); overlay.setOrigin(y, 1); overlay.setExtent(w, 0); overlay.setExtent(h, 1); overlay.update(); toolService.reportRectangle(x, y, w, h); }
/** * @return Text bounds as a path in local coordinates, which is useful * if you need to transform to global coordinates */ public Path2D.Double getBoundsAsPath() { Rectangle2D.Double rect = getTextBounds(); double w = rect.getWidth(); double h = rect.getHeight(); Path2D.Double bounds = new Path2D.Double(); bounds.moveTo(0, 0); bounds.lineTo(w, 0); bounds.lineTo(w, h); bounds.lineTo(0, h); bounds.lineTo(0, 0); return bounds; }
/** * Creates an MArea based on a double precision Rectangle previously * constructed * * @param rectangle from which we are going to construct this MArea * @param ID identification for this MArea * @see Rectangle2D.Double */ public MArea(Rectangle2D.Double rectangle, int ID) { super(rectangle); this.area = rectangle.getWidth() * rectangle.getHeight(); this.ID = ID; rotation = 0; }
private Rectangle2D.Double createRectangle(Rectangle2D.Double rectangularShape) { return new Rectangle2D.Double(rectangularShape.getX(), rectangularShape.getY(), rectangularShape.getWidth(), rectangularShape.getHeight()); }
private Rectangle2D.Double createRectangle(Rectangle2D.Double rectangularShape) { return new Rectangle2D.Double(rectangularShape.getX(), rectangularShape.getY(), rectangularShape.getWidth(), rectangularShape.getHeight()); }
public final void insert(final Rectangle2D.Double rect, final T sampled) { samplesRTree.insert(new float[]{(float) rect.getX(), (float) rect.getY()}, new float[]{(float) rect.getWidth(), (float) rect.getHeight()}, sampled); }
@Test public void testCorrectBoundsIfNecessary_correction_negative_x() { final Rectangle2D.Double toCorrect = new Rectangle2D.Double(-185.499991, -90.0, 360.0, 180.0); RegionSelectableWorldMapPane.correctBoundsIfNecessary(toCorrect); assertEquals(-180.0, toCorrect.getMinX(), 1e-8); assertEquals(174.50000899999895, toCorrect.getMaxX(), 1e-8); assertEquals(-90.0, toCorrect.getMinY(), 1e-8); assertEquals(90.0, toCorrect.getMaxY(), 1e-8); assertTrue(toCorrect.getMinX() + toCorrect.getWidth() <= 180.0); assertTrue(toCorrect.getMinY() + toCorrect.getHeight() <= 90.0); } }
double aspect(java.awt.geom.Rectangle2D.Double r) { return (r.getWidth() == 0 ? 1 : r.getHeight() / r.getWidth()); }
@Test public void testCorrectBoundsIfNecessary_correction_positive_x() { final Rectangle2D.Double toCorrect = new Rectangle2D.Double(-175.499991, -90.0, 360.0, 180.0); RegionSelectableWorldMapPane.correctBoundsIfNecessary(toCorrect); assertEquals(-175.499991, toCorrect.getMinX(), 1e-8); assertEquals(180.0, toCorrect.getMaxX(), 1e-8); assertEquals(-90.0, toCorrect.getMinY(), 1e-8); assertEquals(90.0, toCorrect.getMaxY(), 1e-8); assertTrue(toCorrect.getMinX() + toCorrect.getWidth() <= 180.0); assertTrue(toCorrect.getMinY() + toCorrect.getHeight() <= 90.0); }
public double getSurf() { if (max == null) { return 0; } return max.getWidth() * max.getHeight(); }
public void run(final Network network) { Collection<? extends Node> nodes; if (this.travelZone.getHeight() == 0 || this.travelZone.getWidth() == 0) { nodes = network.getNodes().values(); } else { nodes = getNodesInTravelZone(network); } run(nodes); }
/** * @return Text bounds as a path in local coordinates, which is useful * if you need to transform to global coordinates */ public Path2D.Double getBoundsAsPath() { Rectangle2D.Double rect = getTextBounds(); double w = rect.getWidth(); double h = rect.getHeight(); Path2D.Double bounds = new Path2D.Double(); bounds.moveTo(0, 0); bounds.lineTo(w, 0); bounds.lineTo(w, h); bounds.lineTo(0, h); bounds.lineTo(0, 0); return bounds; }
public double getSurf() { if (max == null) { return 0; } return max.getWidth() * max.getHeight(); }