本文整理汇总了Java中org.w3c.dom.svg.SVGDocument类的典型用法代码示例。如果您正苦于以下问题:Java SVGDocument类的具体用法?Java SVGDocument怎么用?Java SVGDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SVGDocument类属于org.w3c.dom.svg包,在下文中一共展示了SVGDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createImage
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
private byte[] createImage(ImageTranscoder t) throws Exception {
//*** get the SVG document ***
SVGDocument doc = this.getSvgDoc();
org.w3c.dom.Element root = doc.getDocumentElement();
this.getRoot(root);
//*** set the transcoder input and output ***
TranscoderInput input = new TranscoderInput(doc);
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
TranscoderOutput output = new TranscoderOutput(ostream);
//*** perform the transcoding ***
t.transcode(input, output);
ostream.flush();
ostream.close();
return ostream.toByteArray();
}
示例2: execRowsSelected
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
@Override
protected void execRowsSelected(List<? extends ITableRow> rows) {
clearErrorStatus();
try {
Field field = (Field) rows.get(0).getCell(0).getValue();
String svg = DocumentForm.this.getFieldByClass(SvgSourceField.class).getValue();
SVGDocument doc = parseDocument(svg);
DocumentForm.this.getFieldByClass(DocumentSvgField.class)
.setSvgDocument(transformLeft(doc, field));
DocumentForm.this.getFieldByClass(RightGroupBox.class).execDisplayField(field,
transformRight(doc, field));
} catch (Exception e) {
e.printStackTrace();
addErrorStatus(e.getMessage());
}
}
示例3: execInitField
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
@Override
protected void execInitField() {
setLabelVisible(false);
setMultilineText(true);
setMaxLength(1000000);
clearErrorStatus();
try {
SVGDocument doc = generateDocument();
ByteArrayOutputStream out = new ByteArrayOutputStream();
SVGUtility.writeSVGDocument(doc, out, StandardCharsets.UTF_8.toString());
setValue(prettyPrint(new String(out.toByteArray())));
} catch (Exception e) {
e.printStackTrace();
addErrorStatus(e.getMessage());
}
}
示例4: getSvgDocument
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
@Override
protected SVGDocument getSvgDocument(
JasperReportsContext jasperReportsContext,
SVGDocumentFactory documentFactory
) throws JRException
{
try
{
return
documentFactory.createSVGDocument(
null,
new ByteArrayInputStream(
dataRenderer.getData(jasperReportsContext)
)
);
}
catch (IOException e)
{
throw new JRRuntimeException(e);
}
}
示例5: getSvgInfo
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
*
*/
public SvgInfo getSvgInfo(byte[] data)
{
try
{
SVGDocument document =
documentFactory.createSVGDocument(
null,
new ByteArrayInputStream(data)
);
return new SvgInfo(document.getInputEncoding());
}
catch (IOException e)
{
return null;
}
}
示例6: getSVGDocument
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
public SVGDocument getSVGDocument() {
String xmlParser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory df = new SAXSVGDocumentFactory(xmlParser);
SVGDocument doc = null;
try {
if (this.href != null) {
if (!this.href.substring(0, 4).equalsIgnoreCase("file")) {
URL res = ExternalGraphic.class.getResource(this.href);
if (res != null) {
doc = df.createSVGDocument(
ExternalGraphic.class.getResource(this.href).toString());
}
} else {
doc = df.createSVGDocument(this.href);
}
}
} catch (IOException e) {
e.printStackTrace();
}
return doc;
}
示例7: loadDocument
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
* Returns a document from the specified uri.
* @param uri the uri of the document
* @exception IOException if an I/O error occured while loading
* the document
*/
public Document loadDocument(String uri) throws IOException {
Document ret = checkCache(uri);
if (ret != null)
return ret;
SVGDocument document = documentFactory.createSVGDocument(uri);
DocumentDescriptor desc = documentFactory.getDocumentDescriptor();
DocumentState state = new DocumentState(uri, document, desc);
synchronized (cacheMap) {
cacheMap.put(uri, state);
}
return state.getDocument();
}
示例8: getViewBoxRect
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
protected Rectangle2D getViewBoxRect() {
SVGDocument doc = canvas.getSVGDocument();
if (doc == null) return null;
SVGSVGElement el = doc.getRootElement();
if (el == null) return null;
String viewBoxStr = el.getAttributeNS
(null, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE);
if (viewBoxStr.length() != 0) {
float[] rect = ViewBox.parseViewBoxAttribute(el, viewBoxStr, null);
return new Rectangle2D.Float(rect[0], rect[1],
rect[2], rect[3]);
}
GraphicsNode gn = canvas.getGraphicsNode();
if (gn == null) return null;
Rectangle2D bounds = gn.getBounds();
if (bounds == null) return null;
return (Rectangle2D) bounds.clone();
}
示例9: getBrokenLinkDocument
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
* This Implementation simply forwards the request to the AWT thread.
*
* @param e The <image> element that can't be loaded.
* @param url The resolved url that can't be loaded.
* @param msg As best as can be determined the reason it can't be
* loaded (not available, corrupt, unknown format,...).
*/
public SVGDocument getBrokenLinkDocument(final Element e,
final String url,
final String msg) {
if (EventQueue.isDispatchThread())
return userAgent.getBrokenLinkDocument(e, url, msg);
class Query implements Runnable {
SVGDocument doc;
RuntimeException rex = null;
public void run() {
try {
doc = userAgent.getBrokenLinkDocument(e, url, msg);
} catch (RuntimeException re) { rex = re; }
}
}
Query q = new Query();
invokeAndWait(q);
if (q.rex != null) throw q.rex;
return q.doc;
}
示例10: setSVGDocument
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
public void setSVGDocument(SVGDocument doc) {
svgDocument = doc;
UserAgent userAgent = new UserAgentAdapter();
DocumentLoader loader = new DocumentLoader(userAgent);
ctx = new BridgeContext(userAgent, loader);
ctx.setDynamicState(BridgeContext.DYNAMIC);
GVTBuilder builder = new GVTBuilder();
setGraphicsNode(builder.build(ctx, getSvgDocument()));
outlineElement = doc.getElementById("OUTLINE");
if (outlineElement != null) {
outlineShape = ((org.apache.batik.gvt.ShapeNode) ctx.getGraphicsNode(outlineElement)).getShape();
}
if ("OUTER".equals(doc.getRootElement().getAttribute("resizeType"))) {
setResizeType(ResizeType.OUTER);
}
revalidate();
}
示例11: drawSvgGraphics
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
* Draws the selected component (assumed to be a Component) into the
* provided SVGGraphics2D object.
*
* @param component
* @param bounds
*/
private static SVGGraphics2D drawSvgGraphics(Object component, Rectangle bounds) {
// Get a SVGDOMImplementation and create an XML document
DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
String svgNS = "http://www.w3.org/2000/svg";
SVGDocument svgDocument = (SVGDocument) domImpl.createDocument(svgNS, "svg", null);
// Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(svgDocument);
svgGenerator.setSVGCanvasSize(bounds.getSize());
// draw the panel in the SVG generator
if (component instanceof JFreeChart) {
((JFreeChart) component).draw(svgGenerator, bounds);
} else if (component instanceof JComponent) {
((JComponent) component).paintAll(svgGenerator);
}
return svgGenerator;
}
示例12: elementCoordinatesFromEvent
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
* Convert the coordinates of an DOM Event from screen into element
* coordinates.
*
* @param doc Document context
* @param tag Element containing the coordinate system
* @param evt Event to interpret
* @return coordinates
*/
public static SVGPoint elementCoordinatesFromEvent(Document doc, Element tag, Event evt) {
try {
DOMMouseEvent gnme = (DOMMouseEvent) evt;
SVGMatrix mat = ((SVGLocatable) tag).getScreenCTM();
SVGMatrix imat = mat.inverse();
SVGPoint cPt = ((SVGDocument) doc).getRootElement().createSVGPoint();
cPt.setX(gnme.getClientX());
cPt.setY(gnme.getClientY());
return cPt.matrixTransform(imat);
}
catch(Exception e) {
LoggingUtil.warning("Error getting coordinates from SVG event.", e);
return null;
}
}
示例13: drawSvgGraphics
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
* Draws the selected component (assumed to be a Component) into the provided
* SVGGraphics2D object.
*
* @param component
* @param bounds
*/
private static SVGGraphics2D drawSvgGraphics(Object component, Rectangle bounds) {
// Get a SVGDOMImplementation and create an XML document
DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
String svgNS = "http://www.w3.org/2000/svg";
SVGDocument svgDocument = (SVGDocument) domImpl.createDocument(svgNS, "svg", null);
// Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(svgDocument);
svgGenerator.setSVGCanvasSize(bounds.getSize());
// draw the panel in the SVG generator
if (component instanceof JFreeChart) {
((JFreeChart) component).draw(svgGenerator, bounds);
} else if (component instanceof JComponent) {
((JComponent) component).paintAll(svgGenerator);
}
return svgGenerator;
}
示例14: loadDocument
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
* Returns a document from the specified uri.
* @param uri the uri of the document
* @exception IOException if an I/O error occured while loading
* the document
*/
public Document loadDocument(String uri, InputStream is)
throws IOException {
Document ret = checkCache(uri);
if (ret != null)
return ret;
SVGDocument document = documentFactory.createSVGDocument(uri, is);
DocumentDescriptor desc = documentFactory.getDocumentDescriptor();
DocumentState state = new DocumentState(uri, document, desc);
synchronized (cacheMap) {
cacheMap.put(uri, state);
}
return state.getDocument();
}
示例15: execDisplayField
import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
public void execDisplayField(Field field, SVGDocument svgDocument) {
clearErrorStatus();
try {
FieldForm form = new FieldForm(field, svgDocument);
DocumentForm.this.getFieldByClass(GroupFormField.class).setInnerForm(form);
} catch (Exception e) {
e.printStackTrace();
addErrorStatus(e.getMessage());
}
}