本文整理汇总了Java中java.awt.geom.Area.isSingular方法的典型用法代码示例。如果您正苦于以下问题:Java Area.isSingular方法的具体用法?Java Area.isSingular怎么用?Java Area.isSingular使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Area
的用法示例。
在下文中一共展示了Area.isSingular方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getShapeROI
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Get a PathShape from an Area.
* This will try to return a PathRectangleROI or PathPolygonROI if possible,
* or PathAreaROI if neither of the other classes can adequately represent the area.
*
* @param area
* @param c
* @param z
* @param t
* @param flatness - can be used to prefer polygons, see Shape.getPathIterator(AffineTransform at, double flatness)
* @return
*/
public static PathShape getShapeROI(Area area, int c, int z, int t, double flatness) {
if (area.isRectangular()) {
Rectangle2D bounds = area.getBounds2D();
return new RectangleROI(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), c, z, t);
}
// else if (area.isPolygonal() && area.isSingular())
else if (area.isSingular() && (area.isPolygonal() || flatness > 0)) {
Path2D path = new Path2D.Float(area);
List<Point2> points = flatness > 0 ? AWTAreaROI.getLinearPathPoints(path, path.getPathIterator(null, flatness)) : AWTAreaROI.getLinearPathPoints(path, path.getPathIterator(null));
return new PolygonROI(points, c, z, t);
// if (area.isPolygonal())
// return new PolygonROI(new Path2D.Float(area), c, z, t);
// else if (flatness > 0) {
// Path2D path = new Path2D.Float();
// path.append(area.getPathIterator(null, flatness), false);
// return new PolygonROI(path, c, z, t);
// }
}
return new AWTAreaROI(area, c, z, t);
}
示例2: getArea
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Returns the area of this room.
*/
public float getArea()
{
if (this.areaCache == null)
{
Area roomArea = new Area(getShape());
if (roomArea.isSingular())
{
this.areaCache = Math.abs(getSignedArea(getPoints()));
}
else
{
// Add the surface of the different polygons of this room
float area = 0;
List<float[]> currentPathPoints = new ArrayList<float[]>();
for (PathIterator it = roomArea.getPathIterator(null); !it.isDone();)
{
float[] roomPoint = new float[2];
switch (it.currentSegment(roomPoint))
{
case PathIterator.SEG_MOVETO:
currentPathPoints.add(roomPoint);
break;
case PathIterator.SEG_LINETO:
currentPathPoints.add(roomPoint);
break;
case PathIterator.SEG_CLOSE:
float[][] pathPoints = currentPathPoints.toArray(new float[currentPathPoints.size()][]);
area += Math.abs(getSignedArea(pathPoints));
currentPathPoints.clear();
break;
}
it.next();
}
this.areaCache = area;
}
}
return this.areaCache;
}