本文整理汇总了Java中org.newdawn.slick.svg.ParsingException类的典型用法代码示例。如果您正苦于以下问题:Java ParsingException类的具体用法?Java ParsingException怎么用?Java ParsingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParsingException类属于org.newdawn.slick.svg包,在下文中一共展示了ParsingException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: process
import org.newdawn.slick.svg.ParsingException; //导入依赖的package包/类
/**
* @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
*/
public void process(Loader loader, Element element, Diagram diagram,
Transform transform) throws ParsingException {
String ref = element.getAttributeNS("http://www.w3.org/1999/xlink", "href");
String href = Util.getAsReference(ref);
Figure referenced = diagram.getFigureByID(href);
if (referenced == null) {
throw new ParsingException(element, "Unable to locate referenced element: "+href);
}
Transform local = Util.getTransform(element);
Transform trans = local.concatenate(referenced.getTransform());
NonGeometricData data = Util.getNonGeometricData(element);
Shape shape = referenced.getShape().transform(trans);
data.addAttribute(NonGeometricData.FILL, referenced.getData().getAttribute(NonGeometricData.FILL));
data.addAttribute(NonGeometricData.STROKE, referenced.getData().getAttribute(NonGeometricData.STROKE));
data.addAttribute(NonGeometricData.OPACITY, referenced.getData().getAttribute(NonGeometricData.OPACITY));
data.addAttribute(NonGeometricData.STROKE_WIDTH, referenced.getData().getAttribute(NonGeometricData.STROKE_WIDTH));
Figure figure = new Figure(referenced.getType(), shape, data, trans);
diagram.addFigure(figure);
}
开发者ID:j-dong,项目名称:trashjam2017,代码行数:28,代码来源:UseProcessor.java
示例2: processPoly
import org.newdawn.slick.svg.ParsingException; //导入依赖的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;
while (tokens.hasMoreTokens()) {
String nextToken = tokens.nextToken();
if (nextToken.equals("L")) {
continue;
}
if (nextToken.equals("z")) {
break;
}
if (nextToken.equals("M")) {
continue;
}
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);
}
}
return count;
}
开发者ID:j-dong,项目名称:trashjam2017,代码行数:44,代码来源:LineProcessor.java
示例3: getFloatAttribute
import org.newdawn.slick.svg.ParsingException; //导入依赖的package包/类
/**
* Get a floating point attribute that may appear in either the default or
* SODIPODI namespace
*
* @param element The element from which the attribute should be read
* @param attr The attribute to be read
* @return The value from the given attribute
* @throws ParsingException Indicates the value in the attribute was not a float
*/
static float getFloatAttribute(Element element, String attr) throws ParsingException {
String cx = element.getAttribute(attr);
if ((cx == null) || (cx.equals(""))) {
cx = element.getAttributeNS(SODIPODI, attr);
}
try {
return Float.parseFloat(cx);
} catch (NumberFormatException e) {
throw new ParsingException(element, "Invalid value for: "+attr, e);
}
}
开发者ID:j-dong,项目名称:trashjam2017,代码行数:22,代码来源:Util.java
示例4: processPoly
import org.newdawn.slick.svg.ParsingException; //导入依赖的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;
}
开发者ID:j-dong,项目名称:trashjam2017,代码行数:55,代码来源:PolygonProcessor.java
示例5: process
import org.newdawn.slick.svg.ParsingException; //导入依赖的package包/类
/**
* Process a document extracting all the elements that the processor is
* interested in and producing appropriate diagram components for the
* element.
*
* @param loader The loader/context of the parsing
* @param element The element to be processed
* @param diagram The diagram to be built
* @param transform The transform to apply to all elements at this level
* @throws ParsingException Indicates an invalid content to an element
*/
public void process(Loader loader, Element element, Diagram diagram, Transform transform) throws ParsingException;
开发者ID:j-dong,项目名称:trashjam2017,代码行数:13,代码来源:ElementProcessor.java
注:本文中的org.newdawn.slick.svg.ParsingException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论