本文整理汇总了Java中java.awt.geom.Area.intersects方法的典型用法代码示例。如果您正苦于以下问题:Java Area.intersects方法的具体用法?Java Area.intersects怎么用?Java Area.intersects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Area
的用法示例。
在下文中一共展示了Area.intersects方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eraseBorderGlyphs
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* 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;
}
}
}
}
示例2: lookup
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Retrieve the chord(s) embraced by the slur side.
*
* @param slur the provided slur
* @param side desired side
* @return the map of chords found, perhaps empty, with their data
*/
private Map<Inter, ChordLink> lookup (SlurInter slur,
HorizontalSide side)
{
Map<Inter, ChordLink> found = new HashMap<Inter, ChordLink>();
SlurInfo info = slur.getInfo();
Area area = info.getChordArea(side == LEFT);
Point slurTarget = info.getTargetPoint(side == LEFT);
// Look for intersected chords
for (Inter chord : chords.get(side)) {
Rectangle chordBox = chord.getBounds();
if (area.intersects(chordBox)) {
// Check the chord contains at least one suitable head on desired slur side
if (chordHasHead((AbstractChordInter) chord, slur, side)) {
found.put(chord, new ChordLink(slurTarget, (AbstractChordInter) chord));
}
}
}
return found;
}
示例3: erasedInters
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* 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<Inter>();
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;
}
示例4: getSystemsOf
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* 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<SystemInfo>();
}
for (SystemInfo system : systems) {
Area area = system.getArea();
if ((area != null) && area.intersects(rect)) {
found.add(system);
}
}
return found;
}
示例5: getBoundsForActiveGene
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Get the motion bounds for any biomolecule that is going to be associated
* with the currently active gene. This is used to keep the biomolecules
* from wandering outside of the area that the user can see.
*/
public MotionBounds getBoundsForActiveGene() {
// The bottom bounds are intended to be roughly at the bottom of the
// viewport. The value was empirically determined.
double bottomYPos = DnaMolecule.Y_POS - 2000;
// Get the nominal bounds for this gene.
Area bounds = new Area( new Rectangle2D.Double( activeGene.get().getCenterX() - BIOMOLECULE_STAGE_WIDTH / 2,
bottomYPos,
BIOMOLECULE_STAGE_WIDTH,
BIOMOLECULE_STAGE_HEIGHT ) );
// Subtract off any off limits areas.
for ( Shape offLimitMotionSpace : offLimitsMotionSpaces ) {
if ( bounds.intersects( offLimitMotionSpace.getBounds2D() ) ) {
bounds.subtract( new Area( offLimitMotionSpace ) );
}
}
return new MotionBounds( bounds );
}
示例6: hit
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* @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);
}
示例7: intersectedGlyphs
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* 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<Glyph>();
for (Glyph glyph : collection) {
if (area.intersects(glyph.getBounds())) {
set.add(glyph);
}
}
return set;
}
示例8: hit
import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
if(onStroke) {
return hit(rect, getStroke().createStrokedShape(s), false);
}
Area area = new Area(s);
return area.intersects(rect);
}
示例9: intersectedInters
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Lookup the provided list of interpretations for those whose related glyph
* intersect the given area.
*
* @param inters the list of interpretations to search for
* @param order if the list is already sorted by some order, this may speedup the search
* @param area the intersecting area
* @return the intersected interpretations found
*/
public static List<Inter> intersectedInters (List<Inter> inters,
GeoOrder order,
Area area)
{
List<Inter> found = new ArrayList<Inter>();
Rectangle bounds = area.getBounds();
double xMax = bounds.getMaxX();
double yMax = bounds.getMaxY();
for (Inter inter : inters) {
if (inter.isDeleted()) {
continue;
}
Rectangle iBox = inter.getBounds();
if (area.intersects(iBox)) {
found.add(inter);
} else {
switch (order) {
case BY_ABSCISSA:
if (iBox.x > xMax) {
return found;
}
break;
case BY_ORDINATE:
if (iBox.y > yMax) {
return found;
}
break;
case NONE:
}
}
}
return found;
}
示例10: isBirdDied
import java.awt.geom.Area; //导入方法依赖的package包/类
public boolean isBirdDied(Bird bird) {
int[] xpoints1 = {x, x, x + top.getWidth(null), x + top.getWidth(null)};
int[] ypoints1 = {y - top.getHeight(null), y, y, y - top.getHeight(null)};
int[] xpoints2 = {x, x, x + bottom.getWidth(null), x + bottom.getWidth(null)};
int[] ypoints2 = {y + GameFrame.w, y + GameFrame.w + bottom.getHeight(null), y + GameFrame.w + bottom.getHeight(null), y + GameFrame.w };
Polygon p1 = new Polygon(xpoints1, ypoints1, 4);
Polygon p2 = new Polygon(xpoints2, ypoints2, 4);
Area a1 = new Area(p1);
Area a2 = new Area(p2);
return a1.intersects(bird.getX(), bird.getY(), 35, 30) || a2.intersects(bird.getX(), bird.getY(), 35, 35) || bird.getY() > 450 || bird.getY() < 0;
}
示例11: computeTiledROIs
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Create a collection of tiled ROIs corresponding to a specified parentROI if it is larger than sizeMax.
*
* If the parentROI is smaller, it is returned as is.
*
* @param parentROI
* @param sizePreferred
* @param sizeMax
* @param fixedSize
* @param overlap
* @return
*/
public static Collection<? extends ROI> computeTiledROIs(ROI parentROI, ImmutableDimension sizePreferred, ImmutableDimension sizeMax, boolean fixedSize, int overlap) {
PathArea pathArea = parentROI instanceof PathArea ? (PathArea)parentROI : null;
Rectangle2D bounds = AwtTools.getBounds2D(parentROI);
if (pathArea == null || (bounds.getWidth() <= sizeMax.width && bounds.getHeight() <= sizeMax.height)) {
return Collections.singletonList(parentROI);
}
List<ROI> pathROIs = new ArrayList<>();
Area area = getArea(pathArea);
double xMin = bounds.getMinX();
double yMin = bounds.getMinY();
int nx = (int)Math.ceil(bounds.getWidth() / sizePreferred.width);
int ny = (int)Math.ceil(bounds.getHeight() / sizePreferred.height);
double w = fixedSize ? sizePreferred.width : (int)Math.ceil(bounds.getWidth() / nx);
double h = fixedSize ? sizePreferred.height : (int)Math.ceil(bounds.getHeight() / ny);
// Center the tiles
xMin = (int)(bounds.getCenterX() - (nx * w * .5));
yMin = (int)(bounds.getCenterY() - (ny * h * .5));
for (int yi = 0; yi < ny; yi++) {
for (int xi = 0; xi < nx; xi++) {
double x = xMin + xi * w - overlap;
double y = yMin + yi * h - overlap;
Rectangle2D boundsTile = new Rectangle2D.Double(x, y, w + overlap*2, h + overlap*2);
// double x = xMin + xi * w;
// double y = yMin + yi * h;
//
// Rectangle2D boundsTile = new Rectangle2D.Double(x, y, w, h);
// logger.info(boundsTile);
ROI pathROI = null;
Shape shape = getShape(pathArea);
if (shape.contains(boundsTile))
pathROI = new RectangleROI(boundsTile.getX(), boundsTile.getY(), boundsTile.getWidth(), boundsTile.getHeight(), parentROI.getC(), parentROI.getZ(), parentROI.getT());
else if (pathArea instanceof RectangleROI) {
Rectangle2D bounds2 = boundsTile.createIntersection(bounds);
pathROI = new RectangleROI(bounds2.getX(), bounds2.getY(), bounds2.getWidth(), bounds2.getHeight(), parentROI.getC(), parentROI.getZ(), parentROI.getT());
}
else {
if (!area.intersects(boundsTile))
continue;
Area areaTemp = new Area(boundsTile);
areaTemp.intersect(area);
if (!areaTemp.isEmpty())
pathROI = new AWTAreaROI(areaTemp, parentROI.getC(), parentROI.getZ(), parentROI.getT());
}
if (pathROI != null)
pathROIs.add(pathROI);
x += w;
}
}
return pathROIs;
}