本文整理汇总了Java中org.newdawn.slick.geom.Polygon.setClosed方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.setClosed方法的具体用法?Java Polygon.setClosed怎么用?Java Polygon.setClosed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.newdawn.slick.geom.Polygon
的用法示例。
在下文中一共展示了Polygon.setClosed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processPoly
import org.newdawn.slick.geom.Polygon; //导入方法依赖的package包/类
/**
* Process the points in a polygon definition
*
* @param poly The polygon being built
* @param element The XML element being read
* @param tokens The tokens representing the path
* @return The number of points found
* @throws ParsingException Indicates an invalid token in the path
*/
private static int processPoly(Polygon poly, Element element, StringTokenizer tokens) throws ParsingException {
int count = 0;
ArrayList pts = new ArrayList();
boolean moved = false;
boolean closed = false;
while (tokens.hasMoreTokens()) {
String nextToken = tokens.nextToken();
if (nextToken.equals("L")) {
continue;
}
if (nextToken.equals("z")) {
closed = true;
break;
}
if (nextToken.equals("M")) {
if (!moved) {
moved = true;
continue;
}
return 0;
}
if (nextToken.equals("C")) {
return 0;
}
String tokenX = nextToken;
String tokenY = tokens.nextToken();
try {
float x = Float.parseFloat(tokenX);
float y = Float.parseFloat(tokenY);
poly.addPoint(x,y);
count++;
} catch (NumberFormatException e) {
throw new ParsingException(element.getAttribute("id"), "Invalid token in points list", e);
}
}
poly.setClosed(closed);
return count;
}