static public boolean intersect(Positionable p1, Positionable p2) { return toRectangle(p1).intersects(toRectangle(p2)); }
static public boolean intersect(Positionable big, Positionable small) { final Rectangle2D bigR = convert(big); final Rectangle2D smallR = convert(small); return bigR.intersects(smallR); // final Point2D pt = small.getPosition(); // final Dimension2D dim = small.getSize(); // // if (contains(big, pt)) { // return true; // } // if (contains(big, new Point2D.Double(pt.getX() + dim.getWidth(), // pt.getY()))) { // return true; // } // if (contains(big, new Point2D.Double(pt.getX() + dim.getWidth(), // pt.getY() + dim.getHeight()))) { // return true; // } // if (contains(big, new Point2D.Double(pt.getX(), pt.getY() + // dim.getHeight()))) { // return true; // } // return false; }
public Raster getRaster(int xOffset, int yOffset, int w, int h) { ColorModel cm = getColorModel(); if (raster == null) createRaster(); // TODO: eventually use caching here WritableRaster childRaster = cm.createCompatibleWritableRaster(w, h); Rectangle2D childRect = new Rectangle2D.Double(xOffset, yOffset, w, h); if (!childRect.intersects(deviceBounds)) { // usually doesn't happen ... return childRaster; } Rectangle2D destRect = new Rectangle2D.Double(); Rectangle2D.intersect(childRect, deviceBounds, destRect); int dx = (int)(destRect.getX()-deviceBounds.getX()); int dy = (int)(destRect.getY()-deviceBounds.getY()); int dw = (int)destRect.getWidth(); int dh = (int)destRect.getHeight(); Object data = raster.getDataElements(dx, dy, dw, dh, null); dx = (int)(destRect.getX()-childRect.getX()); dy = (int)(destRect.getY()-childRect.getY()); childRaster.setDataElements(dx, dy, dw, dh, data); return childRaster; }
if(r==null || !r.intersects(area)) { Point2D anchorPoint = RectangleAnchor.coordinates(area, position.getCategoryAnchor());
/** * Returns true if the interior of this node intersects the interior of a * specified Rectangle2D, false otherwise. * * @param r the specified Rectangle2D in the user node space */ public boolean intersects(Rectangle2D r) { Rectangle2D b = getBounds(); if (b == null) return false; return b.intersects(r); }
/** * Returns true if the interior of this node intersects the interior of a * specified Rectangle2D, false otherwise. * * @param r the specified Rectangle2D in the user node space */ public boolean intersects(Rectangle2D r) { Rectangle2D b = getBounds(); if (b == null) return false; return b.intersects(r); }
/** * Returns true if the interior of this node intersects the interior of a * specified Rectangle2D, false otherwise. * * @param r the specified Rectangle2D in the user node space */ public boolean intersects(Rectangle2D r) { Rectangle2D b = getBounds(); if (b == null) return false; return b.intersects(r); }
@Override public boolean intersects(AnchoredText primitive, AttributeSet style, Rectangle2D rect) { Rectangle2D bounds = boundingBox(primitive, style); return bounds != null && bounds.intersects(rect); }
@Override public boolean intersects(AnchoredIcon primitive, AttributeSet style, Rectangle2D rect) { return boundingBox(primitive, style).intersects(rect); }
@Override public boolean intersects(AnchoredImage primitive, AttributeSet style, Rectangle2D rect) { return boundingBox(primitive, style).intersects(rect); }
/** * Returns how many times rectangle stripe cross shape or the are intersect */ public static int intersectShape(Shape s, double x, double y, double w, double h) { if (!s.getBounds2D().intersects(x, y, w, h)) { return 0; } return intersectPath(s.getPathIterator(null), x, y, w, h); }
public Shape getDirtyRegion(int srcIndex, Rectangle2D inputRgn) { if (srcIndex != 0) throw new IndexOutOfBoundsException("Affine only has one input"); inputRgn = (Rectangle2D)inputRgn.clone(); Rectangle2D bounds = getBounds2D(); // Changes in the input region don't propogate outside our // bounds. if ( ! inputRgn.intersects(bounds) ) return new Rectangle2D.Float(); Rectangle2D.intersect(inputRgn, bounds, inputRgn); return inputRgn; }
public Shape getDirtyRegion(int srcIndex, Rectangle2D inputRgn) { if (srcIndex != 0) throw new IndexOutOfBoundsException("Affine only has one input"); inputRgn = (Rectangle2D)inputRgn.clone(); Rectangle2D bounds = getBounds2D(); // Changes in the input region don't propogate outside our // bounds. if ( ! inputRgn.intersects(bounds) ) return new Rectangle2D.Float(); Rectangle2D.intersect(inputRgn, bounds, inputRgn); return inputRgn; }
public Shape getDirtyRegion(int srcIndex, Rectangle2D inputRgn) { if (srcIndex != 0) throw new IndexOutOfBoundsException("Affine only has one input"); inputRgn = (Rectangle2D)inputRgn.clone(); Rectangle2D bounds = getBounds2D(); // Changes in the input region don't propogate outside our // bounds. if ( ! inputRgn.intersects(bounds) ) return new Rectangle2D.Float(); Rectangle2D.intersect(inputRgn, bounds, inputRgn); return inputRgn; }
public boolean isIntersectingNode(double inputX, double inputY, double inputWidth, double inputHeight) { Rectangle2D inputRectangle = new Rectangle2D(inputX, inputY, inputWidth, inputHeight); double newX = 20, newY = 20, newW = 20, newH = 20; Rectangle2D scannedRectangle = new Rectangle2D(newX, newY, newW, newH); return inputRectangle.intersects(scannedRectangle); }
private List<IEntity> getEntitiesInCollisionBox() { final List<IEntity> collEntities = new CopyOnWriteArrayList<>(); for (final ICollisionEntity coll : Game.physics().getCollisionEntities()) { if (coll == this || !this.activators.isEmpty() && !this.activators.contains(coll.getMapId())) { continue; } if (coll.getCollisionBox().intersects(this.getCollisionBox())) { collEntities.add(coll); } } return collEntities; }
public boolean intersects(float x, float y, float w, float h) { if (npoints <= 0 || !getBounds2D().intersects(x, y, w, h)) { return false; } Crossings cross = getCrossings(x, y, x + w, y + h); return (cross == null || !cross.isEmpty()); }
public boolean contains(float x, float y, float w, float h) { if (npoints <= 0 || !getBounds2D().intersects(x, y, w, h)) { return false; } Crossings cross = getCrossings(x, y, x + w, y + h); return (cross != null && cross.covers(y, y + h)); }
@Override public boolean intersects(double x, double y, double w, double h) { if (npoints <= 0 || !getBounds2D().intersects(x, y, w, h)) { return false; } Crossings cross = getCrossings(x, y, x + w, y + h); return (cross == null || !cross.isEmpty()); }
@Override public boolean contains(double x, double y, double w, double h) { if (npoints <= 0 || !getBounds2D().intersects(x, y, w, h)) { return false; } Crossings cross = getCrossings(x, y, x + w, y + h); return (cross != null && cross.covers(y, y + h)); }