/** * Check whether the provided rectangle would intersect area of frozen * barline/connector. * * @param rect provided rectangle * @return true if area hit */ private boolean barInvolved (Rectangle rect) { for (Area a : barAreas) { if (a.intersects(rect)) { return true; } } return false; }
/** Expects Rectangle in world coords. */ @Override public boolean intersects(final Layer layer, final Rectangle r) { final Polygon[] pol = getSubPerimeters(layer); // transformed if (null == pol) return false; for (final Polygon p : pol) if (new Area(p).intersects(r.x, r.y, r.width, r.height)) return true; return false; } /** Expects Area in world coords. */
/** * Build the list of areas around connectors and frozen barlines. * * @return the bar-centered areas */ private List<Area> getBarAreas (Area area) { List<Area> kept = new ArrayList<>(); for (Area r : systemBarAreas) { if (area.intersects(r.getBounds())) { kept.add(r); } } return kept; }
/** * Look up in a collection of glyph instances for <b>all</b> glyph * instances intersected by a provided area. * * @param collection the collection of glyph instances to be browsed * @param area the intersecting area * @return the glyph instances found, which may be an empty list */ public static Set<Glyph> intersectedGlyphs (Collection<? extends Glyph> collection, Area area) { Set<Glyph> set = new LinkedHashSet<>(); for (Glyph glyph : collection) { if (area.intersects(glyph.getBounds())) { set.add(glyph); } } return set; }
/** * @see Graphics2D#hit(Rectangle, Shape, boolean) */ public boolean hit(Rectangle rect, Shape s, boolean onStroke) { if (onStroke) { s = stroke.createStrokedShape(s); } s = transform.createTransformedShape(s); Area area = new Area(s); if (clip != null) area.intersect(clip); return area.intersects(rect.x, rect.y, rect.width, rect.height); }
/** * @see Graphics2D#hit(Rectangle, Shape, boolean) */ public boolean hit(Rectangle rect, Shape s, boolean onStroke) { if (onStroke) { s = stroke.createStrokedShape(s); } s = transform.createTransformedShape(s); Area area = new Area(s); if (clip != null) area.intersect(clip); return area.intersects(rect.x, rect.y, rect.width, rect.height); }
/** * Report the systems that intersect the provided rectangle * * @param rect the provided rectangle * @param found (output) list to be populated (allocated if null) * @return the containing systems info, perhaps empty but not null */ public List<SystemInfo> getSystemsOf (Rectangle2D rect, List<SystemInfo> found) { if (found != null) { found.clear(); } else { found = new ArrayList<>(); } for (SystemInfo system : systems) { Area area = system.getArea(); if ((area != null) && area.intersects(rect)) { found.add(system); } } return found; }
/** * @see Graphics2D#hit(Rectangle, Shape, boolean) */ @Override public boolean hit(Rectangle rect, Shape s, boolean onStroke) { if (onStroke) { s = stroke.createStrokedShape(s); } s = transform.createTransformedShape(s); Area area = new Area(s); if (clip != null) area.intersect(clip); return area.intersects(rect.x, rect.y, rect.width, rect.height); }
private final void putIn(final int stack_index, final Displayable d, final Area a, final HashMap<Displayable,HashSet<Bucket>> db_map) { if (!a.intersects(x, y, w, h)) return; // there will be at least one now this.empty = false; if (null != children) { for (final Bucket bu : children) bu.putIn(stack_index, d, a, db_map); } else if (null != map) { map.put(stack_index, d); putToBucketMap(d, db_map); // the db_map } }
/** * @see Graphics2D#hit(Rectangle, Shape, boolean) */ @Override public boolean hit( final Rectangle rect, Shape s, final boolean onStroke ) { if ( onStroke ) { s = stroke.createStrokedShape( s ); } s = transform.createTransformedShape( s ); final Area area = new Area( s ); if ( clip != null ) { area.intersect( clip ); } return area.intersects( rect.x, rect.y, rect.width, rect.height ); }
public boolean intersects(JLabel testa, JLabel testb){ Area areaA = new Area(testa.getBounds()); Area areaB = new Area(testb.getBounds()); return areaA.intersects(areaB.getBounds2D()); }
/** Remove from wherever it is, then test if it's in that bucket, otherwise re-add. */ synchronized final void updatePosition(final Displayable d, final Layer layer, final HashMap<Displayable,HashSet<Bucket>> db_map) { final HashSet<Bucket> hs = db_map.get(d); final Area a = d.getAreaForBucket(layer); final int stack_index = d.getBucketable().getDisplayableList().indexOf(d); if (null != hs) { for (final Iterator<Bucket> it = hs.iterator(); it.hasNext(); ) { final Bucket bu = it.next(); if (null != a && a.intersects(bu.x, bu.y, bu.w, bu.h)) continue; // bu.intersects(box)) continue; // no change of bucket: lower-right corner still within the bucket // else, remove bu.map.remove(stack_index); it.remove(); } } // insert wherever appropriate, if not there if (null != a) this.put(stack_index, d, layer, a, db_map); }
if (areaA.intersects(areaB.getBounds())) { System.out.println("Collision!");
/** * Report all erased inters in provided system that intersect the provided box. * * @param system the system being processed * @param box the box to be intersected * @param crossable true for crossable, false for non-crossable * @return the collection of erased inter instances with proper crossable characteristic */ private Set<Inter> erasedInters (SystemInfo system, Rectangle box, boolean crossable) { Set<Inter> found = new LinkedHashSet<>(); List<Inter> inters = skeleton.getErasedInters(crossable).get(system); for (Inter inter : inters) { if (inter.getBounds().intersects(box)) { Area area = inter.getArea(); if ((area == null) || area.intersects(box)) { found.add(inter); } } } return found; }
@Override public boolean intersects(final Layer layer, final Rectangle r) { Object ob = ht_areas.get(layer.getId()); if (null == ob) return false; if (AreaList.UNLOADED == ob) { ob = loadLayer(layer.getId()); if (null == ob) return false; } final Area a = ((Area)ob).createTransformedArea(this.at); return a.intersects(r.x, r.y, r.width, r.height); }
/** * Check whether the provided box overlaps one of the competitors. * * @param box template box * @param competitors sequence of competitors, sorted by abscissa * @return true if overlap was detected */ private boolean overlap (Rectangle2D box, List<Inter> competitors) { final double xMax = box.getMaxX(); for (Inter comp : competitors) { if (comp instanceof HeadInter) { continue; } if (comp.getArea() != null) { if (comp.getArea().intersects(box)) { return true; } } else { Rectangle cBox = comp.getBounds(); if (cBox.intersects(box)) { return true; } else if (cBox.x > xMax) { break; } } } return false; }
@Override public boolean hit(Rectangle rect, Shape s, boolean onStroke) { if (onStroke && getStroke() != null) { s = getStroke().createStrokedShape(s); } if (getTransform() != null) { s = getTransform().createTransformedShape(s); } Area area = new Area(s); if (getClip() != null) { area.intersect(new Area(getClip())); } return area.intersects(rect); }
/** * Checks whether or not the specified <code>Shape</code> intersects * the specified {@link Rectangle}, which is in device * space. * * @param rect the area in device space to check for a hit * @param s the <code>Shape</code> to check for a hit * @param onStroke flag used to choose between testing the stroked or the filled shape. * @see java.awt.Graphics2D#hit(Rectangle, Shape, boolean) */ public boolean hit(Rectangle rect, Shape s, boolean onStroke) { if (onStroke && getStroke() != null) { s = getStroke().createStrokedShape(s); } if (getTransform() != null) { s = getTransform().createTransformedShape(s); } Area area = new Area(s); if (getClip() != null) { area.intersect(new Area(getClip())); } return area.intersects(rect); } }
/** * Erase from text image the glyphs that intersect or touch a staff core area. * <p> * (We also tried to remove too small glyphs, but this led to poor recognition by OCR) * * @param glyphs all the glyph instances in image * @param cores all staves cores */ private void eraseBorderGlyphs (List<Glyph> glyphs, List<Area> cores) { for (Glyph glyph : glyphs) { // Check position WRT staves cores Rectangle glyphBox = glyph.getBounds(); glyphBox.grow(1, 1); // To catch touching glyphs (on top of intersecting ones) for (Area core : cores) { if (core.intersects(glyphBox)) { glyph.getRunTable().render(g, glyph.getTopLeft()); break; } } } }
@Override public boolean intersects(double x, double y, double width, double height) { boolean intersects = false; if (this.shape != null) { intersects = this.shape.intersects(x, y, width, height); } if (this.textArea != null && !intersects && !this.clearText && this.drawText && ( (this.element.isNode() && this.element.getGraph().getShowNodeLabels()) || (this.element.isEdge() && this.element.getGraph().getShowEdgeLabels()) || (this.element.isSubgraph() && this.element.getGraph().getShowSubgraphLabels()) )) { intersects = this.textArea.intersects(x, y, width, height); } return (intersects); }