java.awt.geom.Area#isEmpty ( )源码实例Demo

下面列出了java.awt.geom.Area#isEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: buffer_bci   文件: FXGraphics2D.java
/**
 * Returns {@code true} if the rectangle (in device space) intersects
 * with the shape (the interior, if {@code onStroke} is false, 
 * otherwise the stroked outline of the shape).
 * 
 * @param rect  a rectangle (in device space).
 * @param s the shape.
 * @param onStroke  test the stroked outline only?
 * 
 * @return A boolean. 
 */
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
    Shape ts;
    if (onStroke) {
        ts = this.transform.createTransformedShape(
                this.stroke.createStrokedShape(s));
    } else {
        ts = this.transform.createTransformedShape(s);
    }
    if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
        return false;
    }
    Area a1 = new Area(rect);
    Area a2 = new Area(ts);
    a1.intersect(a2);
    return !a1.isEmpty();
}
 
源代码2 项目: openstock   文件: FXGraphics2D.java
/**
 * Returns {@code true} if the rectangle (in device space) intersects
 * with the shape (the interior, if {@code onStroke} is false, 
 * otherwise the stroked outline of the shape).
 * 
 * @param rect  a rectangle (in device space).
 * @param s the shape.
 * @param onStroke  test the stroked outline only?
 * 
 * @return A boolean. 
 */
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
    Shape ts;
    if (onStroke) {
        ts = this.transform.createTransformedShape(
                this.stroke.createStrokedShape(s));
    } else {
        ts = this.transform.createTransformedShape(s);
    }
    if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
        return false;
    }
    Area a1 = new Area(rect);
    Area a2 = new Area(ts);
    a1.intersect(a2);
    return !a1.isEmpty();
}
 
源代码3 项目: ccu-historian   文件: SWTGraphics2D.java
/**
 * Returns <code>true</code> if the rectangle (in device space) intersects
 * with the shape (the interior, if <code>onStroke</code> is false, 
 * otherwise the stroked outline of the shape).
 * 
 * @param rect  a rectangle (in device space).
 * @param s the shape.
 * @param onStroke  test the stroked outline only?
 * 
 * @return A boolean. 
 */
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
    AffineTransform transform = getTransform();
    Shape ts;
    if (onStroke) {
        Stroke stroke = getStroke();
        ts = transform.createTransformedShape(stroke.createStrokedShape(s));
    } else {
        ts = transform.createTransformedShape(s);
    }
    if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
        return false;
    }
    Area a1 = new Area(rect);
    Area a2 = new Area(ts);
    a1.intersect(a2);
    return !a1.isEmpty();
}
 
源代码4 项目: jfreesvg   文件: SVGGraphics2D.java
/**
 * Returns {@code true} if the rectangle (in device space) intersects
 * with the shape (the interior, if {@code onStroke} is {@code false}, 
 * otherwise the stroked outline of the shape).
 * 
 * @param rect  a rectangle (in device space).
 * @param s the shape.
 * @param onStroke  test the stroked outline only?
 * 
 * @return A boolean. 
 */
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
    Shape ts;
    if (onStroke) {
        ts = this.transform.createTransformedShape(
                this.stroke.createStrokedShape(s));
    } else {
        ts = this.transform.createTransformedShape(s);
    }
    if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
        return false;
    }
    Area a1 = new Area(rect);
    Area a2 = new Area(ts);
    a1.intersect(a2);
    return !a1.isEmpty();
}
 
源代码5 项目: buffer_bci   文件: FXGraphics2D.java
/**
 * Returns {@code true} if the rectangle (in device space) intersects
 * with the shape (the interior, if {@code onStroke} is false, 
 * otherwise the stroked outline of the shape).
 * 
 * @param rect  a rectangle (in device space).
 * @param s the shape.
 * @param onStroke  test the stroked outline only?
 * 
 * @return A boolean. 
 */
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
    Shape ts;
    if (onStroke) {
        ts = this.transform.createTransformedShape(
                this.stroke.createStrokedShape(s));
    } else {
        ts = this.transform.createTransformedShape(s);
    }
    if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
        return false;
    }
    Area a1 = new Area(rect);
    Area a2 = new Area(ts);
    a1.intersect(a2);
    return !a1.isEmpty();
}
 
源代码6 项目: SIMVA-SoS   文件: SWTGraphics2D.java
/**
 * Returns <code>true</code> if the rectangle (in device space) intersects
 * with the shape (the interior, if <code>onStroke</code> is false, 
 * otherwise the stroked outline of the shape).
 * 
 * @param rect  a rectangle (in device space).
 * @param s the shape.
 * @param onStroke  test the stroked outline only?
 * 
 * @return A boolean. 
 */
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
    AffineTransform transform = getTransform();
    Shape ts;
    if (onStroke) {
        Stroke stroke = getStroke();
        ts = transform.createTransformedShape(stroke.createStrokedShape(s));
    } else {
        ts = transform.createTransformedShape(s);
    }
    if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
        return false;
    }
    Area a1 = new Area(rect);
    Area a2 = new Area(ts);
    a1.intersect(a2);
    return !a1.isEmpty();
}
 
源代码7 项目: TrakEM2   文件: AreaList.java
@Override
public void exportXML(final StringBuilder sb_body, final String indent, final XMLOptions options) {
	sb_body.append(indent).append("<t2_area_list\n");
	final String in = indent + "\t";
	super.exportXML(sb_body, in, options);
	sb_body.append(in).append("fill_paint=\"").append(fill_paint).append("\"\n");
	final String[] RGB = Utils.getHexRGBColor(color);
	sb_body.append(in).append("style=\"stroke:none;fill-opacity:").append(alpha).append(";fill:#").append(RGB[0]).append(RGB[1]).append(RGB[2]).append(";\"\n");
	sb_body.append(indent).append(">\n");
	for (final Map.Entry<Long,Area> entry : ht_areas.entrySet()) {
		final Area area = entry.getValue();
		if (null == area || area.isEmpty()) continue;
		sb_body.append(in).append("<t2_area layer_id=\"").append(entry.getKey()).append("\">\n");
		exportArea(sb_body, in + "\t", area);
		sb_body.append(in).append("</t2_area>\n");
	}
	super.restXML(sb_body, in, options);
	sb_body.append(indent).append("</t2_area_list>\n");
}
 
源代码8 项目: ECG-Viewer   文件: SWTGraphics2D.java
/**
 * Returns <code>true</code> if the rectangle (in device space) intersects
 * with the shape (the interior, if <code>onStroke</code> is false, 
 * otherwise the stroked outline of the shape).
 * 
 * @param rect  a rectangle (in device space).
 * @param s the shape.
 * @param onStroke  test the stroked outline only?
 * 
 * @return A boolean. 
 */
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
    AffineTransform transform = getTransform();
    Shape ts;
    if (onStroke) {
        Stroke stroke = getStroke();
        ts = transform.createTransformedShape(stroke.createStrokedShape(s));
    } else {
        ts = transform.createTransformedShape(s);
    }
    if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
        return false;
    }
    Area a1 = new Area(rect);
    Area a2 = new Area(ts);
    a1.intersect(a2);
    return !a1.isEmpty();
}
 
源代码9 项目: ECG-Viewer   文件: FXGraphics2D.java
/**
 * Returns {@code true} if the rectangle (in device space) intersects
 * with the shape (the interior, if {@code onStroke} is false, 
 * otherwise the stroked outline of the shape).
 * 
 * @param rect  a rectangle (in device space).
 * @param s the shape.
 * @param onStroke  test the stroked outline only?
 * 
 * @return A boolean. 
 */
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
    Shape ts;
    if (onStroke) {
        ts = this.transform.createTransformedShape(
                this.stroke.createStrokedShape(s));
    } else {
        ts = this.transform.createTransformedShape(s);
    }
    if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
        return false;
    }
    Area a1 = new Area(rect);
    Area a2 = new Area(ts);
    a1.intersect(a2);
    return !a1.isEmpty();
}
 
源代码10 项目: render   文件: TileBoundsRTree.java
/**
 * @param  tile               core tile for comparison.
 * @param  intersectingTiles  list of tiles that intersect with the core tile.
 *
 * @return true if the core tile is completely obscured by other tiles; otherwise false.
 *         Assumes tiles with lexicographically greater tileId values are drawn on top.
 */
private static boolean isCompletelyObscured(final TileBounds tile,
                                            final List<TileBounds> intersectingTiles) {
    final String tileId = tile.getTileId();
    final Area tileArea = new Area(new Rectangle2D.Double(tile.getMinX(), tile.getMinY(),
                                                          tile.getDeltaX(), tile.getDeltaY()));

    for (final TileBounds intersectingTile : intersectingTiles) {
        if (tileId.compareTo(intersectingTile.getTileId()) < 0) {
            tileArea.subtract(new Area(
                    new Rectangle2D.Double(
                            intersectingTile.getMinX(), intersectingTile.getMinY(),
                            intersectingTile.getDeltaX(), intersectingTile.getDeltaY())));
        }
    }

    return tileArea.isEmpty();
}
 
private boolean productsIntersect(Product timeSeriesSourceProduct, Product collocationProduct) {
    if (collocationProduct.getGeoCoding() == null) {
        return false;
    }
    final GeoCoding geoCoding = collocationProduct.getGeoCoding();
    if (geoCoding.canGetGeoPos() && geoCoding.canGetPixelPos()
        && ((geoCoding instanceof CrsGeoCoding)||(geoCoding instanceof MapGeoCoding))) {
        final GeneralPath[] sourcePaths = ProductUtils.createGeoBoundaryPaths(timeSeriesSourceProduct);
        final GeneralPath[] collocationPaths = ProductUtils.createGeoBoundaryPaths(collocationProduct);
        for (GeneralPath sourcePath : sourcePaths) {
            for (GeneralPath collocationPath : collocationPaths) {
                final Area sourceArea = new Area(sourcePath);
                final Area collocationArea = new Area(collocationPath);
                collocationArea.intersect(sourceArea);
                if (!collocationArea.isEmpty()) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
源代码12 项目: salty-engine   文件: ShapeCollider.java
@Override
public CollisionDetectionResult checkCollision(final GameObject object1, final GameObject object2) {

    final Collider otherCollider = getOtherCollider(object1.getCollider(), object2.getCollider());
    final GameObject otherGameObject = object1.getCollider() == otherCollider ? object1 : object2;

    final Area collisionArea = new Area(shape);

    switch (otherCollider.getType()) {
        case HITBOX_COLLIDER:
            collisionArea.intersect(new Area(otherGameObject.getHitbox().getTransform().getRect()));
            return new CollisionDetectionResult(!collisionArea.isEmpty(), new Transform(shape.getBounds()).getRelation(otherGameObject.getHitbox().getTransform()));

        case CIRCLE_COLLIDER:
            final CircleCollider collider = (CircleCollider) otherCollider;
            final Transform hitbox = collider.getHitbox();
            collisionArea.intersect(new Area(new Ellipse2D.Float(hitbox.getX(), hitbox.getY(), hitbox.getWidth(), hitbox.getHeight())));
            return new CollisionDetectionResult(!collisionArea.isEmpty(), new Transform(shape.getBounds()).getRelation(otherGameObject.getHitbox().getTransform()));

        case SHAPE_COLLIDER:
            final ShapeCollider shapeCollider = (ShapeCollider) otherCollider;
            collisionArea.intersect(new Area(shapeCollider.shape));
            return new CollisionDetectionResult(!collisionArea.isEmpty(), new Transform(shape.getBounds()).getRelation(new Transform(shapeCollider.shape.getBounds())));
    }

    return new CollisionDetectionResult(false, Directions.Direction.EMPTY);
}
 
源代码13 项目: pumpernickel   文件: AbstractShapeTransition2D.java
/** Determine if a particular scaling ratio works */
private boolean isOK(Area shape, Rectangle2D shapeBounds,
		Rectangle2D bounds, float ratio) {
	Area area = new Area(shape);
	area.transform(AffineTransform.getScaleInstance(ratio, ratio));
	Rectangle2D r = ShapeBounds.getBounds(area);
	area.transform(AffineTransform.getTranslateInstance(-r.getCenterX()
			+ bounds.getCenterX(), -r.getCenterY() + bounds.getCenterY()));

	Area boundsArea = new Area(bounds);
	boundsArea.subtract(area);
	return boundsArea.isEmpty();
}
 
源代码14 项目: flowable-engine   文件: CmmnJsonConverter.java
protected Collection<java.awt.geom.Point2D> getIntersections(java.awt.geom.Line2D line, Area shape) {
    Area intersectionArea = new Area(getLineShape(line));
    intersectionArea.intersect(shape);
    if (!intersectionArea.isEmpty()) {
        Rectangle2D bounds2D = intersectionArea.getBounds2D();
        HashSet<java.awt.geom.Point2D> intersections = new HashSet<>(2);
        intersections.add(new java.awt.geom.Point2D.Double(bounds2D.getX(), bounds2D.getY()));
        return intersections;
    }
    return Collections.EMPTY_SET;
}
 
源代码15 项目: flowable-engine   文件: DmnJsonConverterUtil.java
public static Collection<Point2D> getIntersections(java.awt.geom.Line2D line, Area shape) {
    Area intersectionArea = new Area(getLineShape(line));
    intersectionArea.intersect(shape);
    if (!intersectionArea.isEmpty()) {
        Rectangle2D bounds2D = intersectionArea.getBounds2D();
        HashSet<Point2D> intersections = new HashSet<>(1);
        intersections.add(new java.awt.geom.Point2D.Double(bounds2D.getX(), bounds2D.getY()));
        return intersections;
    }
    return Collections.EMPTY_SET;
}
 
源代码16 项目: pentaho-reporting   文件: ShapeTransform.java
/**
 * Clips the given shape to the given bounds. If the shape is a Line2D, manual clipping is performed, as the built in
 * Area does not handle lines.
 *
 * @param s
 *          the shape to be clipped
 * @param bounds
 *          the bounds to which the shape should be clipped
 * @return the clipped shape.
 */
public static Shape performCliping( final Shape s, final Rectangle2D bounds ) {
  if ( s instanceof Line2D ) {
    final Line2D line = (Line2D) s;
    final Point2D[] clipped =
        getClipped( line.getX1(), line.getY1(), line.getX2(), line.getY2(), -DELTA, DELTA + bounds.getWidth(),
            -DELTA, DELTA + bounds.getHeight() );
    if ( clipped == null ) {
      return new GeneralPath();
    }
    return new Line2D.Float( clipped[0], clipped[1] );
  }

  final Rectangle2D boundsCorrected = bounds.getBounds2D();
  boundsCorrected.setRect( -DELTA, -DELTA, DELTA + boundsCorrected.getWidth(), DELTA + boundsCorrected.getHeight() );
  final Area a = new Area( boundsCorrected );
  if ( a.isEmpty() ) {
    // don't clip ... Area does not like lines
    // operations with lines always result in an empty Bounds:(0,0,0,0) area
    return new GeneralPath();
  }

  final Area clipArea = new Area( s );
  a.intersect( clipArea );
  return a;

}
 
源代码17 项目: mars-sim   文件: LocalAreaUtil.java
/**
 * Checks if two areas collide.
 * 
 * @param area1 the first area.
 * @param area2 the second area.
 * @return true if areas collide.
 */
private static boolean doAreasCollide(Area area1, Area area2) {

	Area collide = new Area(area1);
	collide.intersect(area2);
	return !collide.isEmpty();

}
 
源代码18 项目: NovaGuilds   文件: RegionManager.java
/**
 * Checks WorldGuard validity if possible
 *
 * @param selection region selection
 * @return true if valid
 */
private boolean checkWorldGuardValidity(RegionSelection selection) {
	if(!plugin.getDependencyManager().isEnabled(Dependency.WORLDGUARD)) {
		return true;
	}

	WorldGuardPlugin worldGuard = plugin.getDependencyManager().get(Dependency.WORLDGUARD, WorldGuardPlugin.class);
	Area selectionArea = new Area(new Rectangle(
			selection.getCorner(selection.getCorner(0).getBlockX() < selection.getCorner(1).getBlockX() ? 0 : 1).getBlockX(),
			selection.getCorner(selection.getCorner(0).getBlockZ() < selection.getCorner(1).getBlockZ() ? 0 : 1).getBlockZ(),
			selection.getWidth(),
			selection.getLength())
	);

	for(ProtectedRegion region : worldGuard.getRegionManager(selection.getWorld()).getRegions().values()) {
		if(region.getFlag((Flag) RegionManager.WORLDGUARD_FLAG) == StateFlag.State.ALLOW) {
			continue;
		}

		Area regionArea = RegionUtils.toArea(region);

		regionArea.intersect(selectionArea);
		if(!regionArea.isEmpty()) {
			return false;
		}
	}

	return true;
}
 
源代码19 项目: Pixelitor   文件: AbstractShapeTransition2D.java
/**
 * Determine if a particular scaling ratio works
 */
private static boolean isOK(Area shape, Rectangle2D bounds, float ratio) {
    Area area = new Area(shape);
    area.transform(AffineTransform.getScaleInstance(ratio, ratio));
    Rectangle2D r = ShapeBounds.getBounds(area);
    area.transform(AffineTransform.getTranslateInstance(
            -r.getCenterX() + bounds.getCenterX(),
            -r.getCenterY() + bounds.getCenterY()));

    Area boundsArea = new Area(bounds);
    boundsArea.subtract(area);
    return boundsArea.isEmpty();
}
 
源代码20 项目: snap-desktop   文件: NestWorldMapPane.java
public static GeneralPath[] assemblePathList(GeoPos[] geoPoints) {
    final GeneralPath path = new GeneralPath(GeneralPath.WIND_NON_ZERO, geoPoints.length + 8);
    final ArrayList<GeneralPath> pathList = new ArrayList<>(16);

    if (geoPoints.length > 1) {
        double lon, lat;
        double minLon = 0, maxLon = 0;

        boolean first = true;
        for (GeoPos gp : geoPoints) {
            lon = gp.getLon();
            lat = gp.getLat();
            if (first) {
                minLon = lon;
                maxLon = lon;
                path.moveTo(lon, lat);
                first = false;
            }
            if (lon < minLon) {
                minLon = lon;
            }
            if (lon > maxLon) {
                maxLon = lon;
            }
            path.lineTo(lon, lat);
        }
        //path.closePath();

        int runIndexMin = (int) Math.floor((minLon + 180) / 360);
        int runIndexMax = (int) Math.floor((maxLon + 180) / 360);

        if (runIndexMin == 0 && runIndexMax == 0) {
            // the path is completely within [-180, 180] longitude
            pathList.add(path);
            return pathList.toArray(new GeneralPath[pathList.size()]);
        }

        final Area pathArea = new Area(path);
        final GeneralPath pixelPath = new GeneralPath(GeneralPath.WIND_NON_ZERO);
        for (int k = runIndexMin; k <= runIndexMax; k++) {
            final Area currentArea = new Area(new Rectangle2D.Float(k * 360.0f - 180.0f, -90.0f, 360.0f, 180.0f));
            currentArea.intersect(pathArea);
            if (!currentArea.isEmpty()) {
                pathList.add(areaToPath(currentArea, -k * 360.0, pixelPath));
            }
        }
    }
    return pathList.toArray(new GeneralPath[pathList.size()]);
}