I m 利用Batik与SVG图像合作。 具体地说,我有一幅形形状的景象,我需要能够将每一种形状转换成单独的布赖迪。 为此,我使用以下法典:
SVGDocument document = null;
// Load the document
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
File file = new File(inPath);
try {
document = (SVGDocument) f.createDocument(file.toURL().toString());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// Build the tree and get the document dimensions
UserAgentAdapter userAgentAdapter = new UserAgentAdapter();
BridgeContext bridgeContext = new BridgeContext(userAgentAdapter);
GVTBuilder builder = new GVTBuilder();
GraphicsNode graphicsNode = builder.build(bridgeContext, document);
CanvasGraphicsNode canvasGraphicsNode = (CanvasGraphicsNode)
graphicsNode.getRoot().getChildren().get(0);
if(canvasGraphicsNode.getChildren().get(i) instanceof ShapeNode) {
currentNode = (ShapeNode) canvasGraphicsNode.getChildren().get(i);
convertNodeToImage (currentNode);
}
这是相当的标准。 我向Batik开枪,然后把SSVG的档案整理起来。 在这里,将电线转换成图像功能:
Rectangle2D bounds;
BufferedImage bufferedImage;
Graphics2D g2d;
// This is supposed to get the bounds of the svg node. i.e. the rectangle which would
// fit perfectly around the shape
bounds = sn.getSensitiveBounds();
// Transform the shape so it s in the top left hand corner based on the bounds
sn.setTransform(AffineTransform.getTranslateInstance(-bounds.getX(), -bounds.getY()));
// Create a buffered image of the same size as the svg node
bufferedImage = new BufferedImage((int) bounds.getWidth(), (int) bounds.getHeight(),
BufferedImage.TYPE_INT_ARGB);
// Paint the node to the buffered image and convert the buffered image to an input
// stream
g2d = (Graphics2D) bufferedImage.getGraphics();
sn.paint(g2d);
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(bufferedImage, "png", os);
InputStream is = new ByteArrayInputStream(os.toByteArray());
return is;
这对 rec子和直线形体来说是很有价值的,但它却为间谍工作。 对间谍而言,其约束大于已提供的间谍。 我认为,这是因为从业者的职能是将控制点纳入对口单位的计算。 我需要找到一条线,即,如果该间线被冲撞,我想找到该线的束缚。 我尝试了所有“博恩”职能(植物检疫、造血管......),他们都给我同样的结果。 因此,我想知道我是否错过了东西? 这在Batik是一个 b? 或者是否有工作关系?
我所想的工作是,编制一份形形形的vert子清单,人工计算捆绑。 然而,我无法找到如何获得概要清单。
Any help would be greatly appreciated.