本文整理汇总了Java中org.w3c.dom.svg.SVGSVGElement类的典型用法代码示例。如果您正苦于以下问题:Java SVGSVGElement类的具体用法?Java SVGSVGElement怎么用?Java SVGSVGElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SVGSVGElement类属于org.w3c.dom.svg包,在下文中一共展示了SVGSVGElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: documentLoadingCompleted
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {
NodeEventTarget root
= (NodeEventTarget) e.getSVGDocument().getRootElement();
root.addEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
SVGConstants.SVG_SVGZOOM_EVENT_TYPE,
new EventListener() {
public void handleEvent(Event evt) {
if (!(evt.getTarget() instanceof SVGSVGElement))
return;
// assert(evt.getType() ==
// SVGConstants.SVG_SVGZOOM_EVENT_TYPE);
SVGSVGElement svg = (SVGSVGElement) evt.getTarget();
scaleChange(svg.getCurrentScale());
} // handleEvent()
}, false, null);
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:18,代码来源:JSVGScrollPane.java
示例2: getViewBoxRect
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的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();
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:22,代码来源:JSVGScrollPane.java
示例3: setGraphicsNode
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
public void setGraphicsNode(GraphicsNode gn, boolean createDispatcher) {
Dimension2D dim = bridgeContext.getDocumentSize();
Dimension mySz = new Dimension((int)dim.getWidth(),
(int)dim.getHeight());
JSVGComponent.this.setMySize(mySz);
SVGSVGElement elt = svgDocument.getRootElement();
prevComponentSize = getSize();
AffineTransform at = calculateViewingTransform
(fragmentIdentifier, elt);
CanvasGraphicsNode cgn = getCanvasGraphicsNode(gn);
if (cgn != null) {
cgn.setViewingTransform(at);
}
viewingTransform = null;
initialTransform = new AffineTransform();
setRenderingTransform(initialTransform, false);
jsvgComponentListener.updateMatrix(initialTransform);
addJGVTComponentListener(jsvgComponentListener);
addComponentListener(jsvgComponentListener);
super.setGraphicsNode(gn, createDispatcher);
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:22,代码来源:JSVGComponent.java
示例4: layoutSVGDocument
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
private void layoutSVGDocument(Rectangle bounds) {
animateBounds = createAnimationElement(this, SVG_ANIMATE_TAG,
SVG_VIEW_BOX_ATTRIBUTE, null);
updateManager = null;
datalinkMap.clear();
Graph graph = getGraph();
if (graph instanceof SVGGraph) {
SVGGraph svgGraph = (SVGGraph) graph;
SVGSVGElement svgElement = getSVGDocument().getRootElement();
SVGElement graphElement = svgGraph.getSVGElement();
svgElement.appendChild(graphElement);
setBounds(layoutGraph(graph, bounds));
edgeLine = EdgeLine.createAndAdd(getSVGDocument(), this);
}
drawingDiagram = true;
}
开发者ID:apache,项目名称:incubator-taverna-workbench,代码行数:20,代码来源:SVGGraphController.java
示例5: setBounds
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
public void setBounds(final Rectangle bounds) {
oldBounds = this.bounds;
this.bounds = bounds;
updateSVGDocument(new Runnable() {
@Override
public void run() {
SVGSVGElement svgElement = getSVGDocument().getRootElement();
if (isAnimatable() && oldBounds != null) {
String from = "0 0 " + oldBounds.width + " "
+ oldBounds.height;
String to = "0 0 " + bounds.width + " " + bounds.height;
animate(animateBounds, svgElement, getAnimationSpeed(),
from, to);
} else if ((svgElement != null) && (bounds != null))
svgElement.setAttribute(SVG_VIEW_BOX_ATTRIBUTE,
"0 0 " + String.valueOf(bounds.width) + " "
+ String.valueOf(bounds.height));
}
});
}
开发者ID:apache,项目名称:incubator-taverna-workbench,代码行数:21,代码来源:SVGGraphController.java
示例6: outputMessage
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
private void outputMessage(final String message) {
SVGSVGElement svgElement = getSVGDocument().getRootElement();
String[] parts = message.split("\n");
int initialPosition = 200;
for (int i = 0; i < parts.length; i++) {
Text errorsText = createText(parts[i]);
SVGOMTextElement error = (SVGOMTextElement) createElement(SVG_TEXT_TAG);
error.setAttribute(SVG_Y_ATTRIBUTE,
Integer.toString(initialPosition + i * 60));
error.setAttribute(SVG_FONT_SIZE_ATTRIBUTE, "20");
error.setAttribute(SVG_FONT_FAMILY_ATTRIBUTE, "sans-serif");
error.setAttribute(SVG_FILL_ATTRIBUTE, "red");
error.appendChild(errorsText);
svgElement.appendChild(error);
}
bounds = new Rectangle(300, parts.length * 60 + 200);
svgCanvas.setDocument(getSVGDocument());
}
开发者ID:apache,项目名称:incubator-taverna-workbench,代码行数:19,代码来源:SVGGraphController.java
示例7: postRenderAction
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
public void postRenderAction(SVGSVGElement root)
{
if (wcFont.isWebSafe())
return;
Document document = root.getOwnerDocument();
Element defs = root.getElementById(SVGSyntax.ID_PREFIX_GENERIC_DEFS);
Element style = document.createElementNS(SVGSyntax.SVG_NAMESPACE_URI, SVGSyntax.SVG_STYLE_TAG);
style.setAttributeNS(null, SVGSyntax.SVG_TYPE_ATTRIBUTE, "text/css");
CDATASection styleSheet = document.createCDATASection("");
Font font = FontUtils.getFont();
styleSheet.setData("@font-face { font-family: '" + font.getFamily() + "'; src: url('static/fonts/" + wcFont.getName() + ".ttf');}");
style.appendChild(styleSheet);
defs.appendChild(style);
}
开发者ID:spupyrev,项目名称:swcv,代码行数:17,代码来源:TextStyleHandler.java
示例8: getInterpreter
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
/**
* Returns the default Interpreter for this document.
*/
public Interpreter getInterpreter() {
if (interpreter != null)
return interpreter;
SVGSVGElement root = (SVGSVGElement)document.getDocumentElement();
String lang = root.getContentScriptType();
return getInterpreter(lang);
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:12,代码来源:BaseScriptingEnvironment.java
示例9: dispatchSVGLoadEvent
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
/**
* Recursively dispatch the SVG 'onload' event.
*/
public void dispatchSVGLoadEvent() {
SVGSVGElement root = (SVGSVGElement)document.getDocumentElement();
String lang = root.getContentScriptType();
long documentStartTime = System.currentTimeMillis();
bridgeContext.getAnimationEngine().start(documentStartTime);
dispatchSVGLoad(root, true, lang);
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:11,代码来源:BaseScriptingEnvironment.java
示例10: dispatchSVGDocEvent
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
protected void dispatchSVGDocEvent(String eventType) {
SVGSVGElement root =
(SVGSVGElement)document.getDocumentElement();
// Event is dispatched on outermost SVG element.
EventTarget t = root;
DocumentEvent de = (DocumentEvent)document;
AbstractEvent ev = (AbstractEvent) de.createEvent("SVGEvents");
ev.initEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
eventType,
false,
false);
t.dispatchEvent(ev);
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:15,代码来源:BaseScriptingEnvironment.java
示例11: getSize
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
protected AffineTransform calculateViewingTransform
(String fragIdent, SVGSVGElement svgElt) {
Dimension d = getSize();
if (d.width < 1) d.width = 1;
if (d.height < 1) d.height = 1;
return ViewBox.getViewTransform
(fragIdent, svgElt, d.width, d.height, bridgeContext);
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:9,代码来源:JSVGComponent.java
示例12: getOwnerSVGElement
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
/**
* <b>DOM</b>: Implements {@link SVGElement#getOwnerSVGElement()}.
*/
public SVGSVGElement getOwnerSVGElement() {
for (Element e = CSSEngine.getParentCSSStylableElement(this);
e != null;
e = CSSEngine.getParentCSSStylableElement(e)) {
if (e instanceof SVGSVGElement) {
return (SVGSVGElement)e;
}
}
return null;
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:14,代码来源:SVGOMElement.java
示例13: runImplBasic
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
public boolean runImplBasic() throws Exception {
Document doc = newSVGDoc();
Element e2 = doc.createElementNS(SVG_NAMESPACE_URI, "g");
boolean pass = e2 instanceof SVGGElement;
e2 = (Element) ((AbstractDocument) doc).renameNode(e2, SVG_NAMESPACE_URI, "svg");
pass = pass && e2 instanceof SVGSVGElement;
Attr a = doc.createAttributeNS(null, "test");
a = (Attr) ((AbstractDocument) doc).renameNode(a, EX_NAMESPACE_URI, "test2");
pass = pass && a.getNamespaceURI().equals(EX_NAMESPACE_URI)
&& a.getLocalName().equals("test2");
return pass;
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:13,代码来源:DocumentRenameNodeTest.java
示例14: calculateDefaultViewbox
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
protected float[] calculateDefaultViewbox(String fragIdent, SVGSVGElement svgElt) {
float[] vb = new float[4];
SVGRect rc = svgElt.getBBox();
vb[0] = rc.getX();
vb[1] = rc.getY();
vb[2] = rc.getWidth();
vb[3] = rc.getHeight();
return vb;
}
开发者ID:petebrew,项目名称:fhaes,代码行数:11,代码来源:JSVGCanvasEx.java
示例15: createSVG
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
public static byte[] createSVG(WordCloudRenderer renderer, SVGTextStyleHandler styleHandler)
{
// Create an instance of org.w3c.dom.Document.
DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
Document document = domImpl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null);
// Configure the SVGGraphics2D
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
ctx.setStyleHandler(styleHandler);
SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);
// rendering the cloud
renderer.render(svgGenerator);
SVGSVGElement root = (SVGSVGElement)svgGenerator.getRoot();
styleHandler.postRenderAction(root);
try
{
Writer writer = new StringWriter();
svgGenerator.stream(root, writer);
writer.close();
return writer.toString().getBytes("UTF-8");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
开发者ID:spupyrev,项目名称:swcv,代码行数:31,代码来源:RenderUtils.java
示例16: handleXML
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
/** {@inheritDoc} */
public void handleXML(RendererContext context,
org.w3c.dom.Document doc, String ns) throws Exception {
if (getNamespace().equals(ns)) {
if (!(doc instanceof SVGDocument)) {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
doc = DOMUtilities.deepCloneDocument(doc, impl);
}
SVGSVGElement svg = ((SVGDocument) doc).getRootElement();
SVGDocument targetDoc = (SVGDocument)context.getProperty(SVG_DOCUMENT);
SVGElement currentPageG = (SVGElement)context.getProperty(SVG_PAGE_G);
Element view = targetDoc.createElementNS(getNamespace(), "svg");
Node newsvg = targetDoc.importNode(svg, true);
//view.setAttributeNS(null, "viewBox", "0 0 ");
int xpos = ((Integer)context.getProperty(XPOS)).intValue();
int ypos = ((Integer)context.getProperty(YPOS)).intValue();
view.setAttributeNS(null, "x", "" + xpos / 1000f);
view.setAttributeNS(null, "y", "" + ypos / 1000f);
// this fixes a problem where the xmlns is repeated sometimes
Element ele = (Element) newsvg;
ele.setAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns",
getNamespace());
if (ele.hasAttributeNS(null, "xmlns")) {
ele.removeAttributeNS(null, "xmlns");
}
view.appendChild(newsvg);
currentPageG.appendChild(view);
}
}
开发者ID:pellcorp,项目名称:fop,代码行数:32,代码来源:SVGSVGHandler.java
示例17: extractSVGBounds
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
/**
* Extract the viewbox of the input SVG
* @return
* @throws MalformedURLException
* @throws IOException
*/
private Rectangle extractSVGBounds(QualifiedSVGResource svg) throws IOException {
// check <svg> attributes first : x, y, width, height
SVGDocument svgDocument = getSVGDocument(svg);
SVGSVGElement svgElement = svgDocument.getRootElement();
if (svgElement.getAttributeNode("width") != null && svgElement.getAttribute("height") != null) {
UserAgent userAgent = new DensityAwareUserAgent(svg.getDensity().getDpi());
UnitProcessor.Context context = org.apache.batik.bridge.UnitProcessor.createContext(
new BridgeContext(userAgent), svgElement);
float width = svgLengthInPixels(svgElement.getWidth().getBaseVal(), context);
float height = svgLengthInPixels(svgElement.getHeight().getBaseVal(), context);
float x = 0;
float y = 0;
// check x and y attributes
if (svgElement.getX() != null && svgElement.getX().getBaseVal() != null) {
x = svgLengthInPixels(svgElement.getX().getBaseVal(), context);
}
if (svgElement.getY() != null && svgElement.getY().getBaseVal() != null) {
y = svgLengthInPixels(svgElement.getY().getBaseVal(), context);
}
return new Rectangle((int) floor(x), (int) floor(y), (int) ceil(width), (int) ceil(height));
}
// use computed bounds
log.warn("Take time to fix desired width and height attributes of the root <svg> node for this file... " +
"ROI will be computed by magic using Batik " + boundsType.name() + " bounds");
return boundsType.getBounds(getGraphicsNode(svgDocument, svg.getDensity().getDpi()));
}
开发者ID:avianey,项目名称:androidsvgdrawable-plugin,代码行数:37,代码来源:QualifiedSVGResourceFactory.java
示例18: rebuildImageNode
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
protected void rebuildImageNode() {
// Reference copy of the imgDocument
if ((imgDocument != null) && (listener != null)) {
NodeEventTarget tgt = (NodeEventTarget)imgDocument.getRootElement();
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_CLICK,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_KEYDOWN,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_KEYPRESS,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_KEYUP,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEDOWN,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEMOVE,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOUT,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOVER,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEUP,
listener, false);
listener = null;
}
if (imgDocument != null) {
SVGSVGElement svgElement = imgDocument.getRootElement();
disposeTree(svgElement);
}
imgDocument = null;
subCtx = null;
//update of the reference of the image.
GraphicsNode inode = buildImageGraphicsNode(ctx,e);
ImageNode imgNode = (ImageNode)node;
imgNode.setImage(inode);
if (inode == null) {
SVGImageElement ie = (SVGImageElement) e;
String uriStr = ie.getHref().getAnimVal();
throw new BridgeException(ctx, e, ERR_URI_IMAGE_INVALID,
new Object[] {uriStr});
}
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:57,代码来源:SVGImageElementBridge.java
示例19: dispose
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
public void dispose() {
if ((imgDocument != null) && (listener != null)) {
NodeEventTarget tgt = (NodeEventTarget)imgDocument.getRootElement();
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_CLICK,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_KEYDOWN,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_KEYPRESS,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_KEYUP,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEDOWN,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEMOVE,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOUT,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOVER,
listener, false);
tgt.removeEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEUP,
listener, false);
listener = null;
}
if (imgDocument != null) {
SVGSVGElement svgElement = imgDocument.getRootElement();
disposeTree(svgElement);
imgDocument = null;
subCtx = null;
}
super.dispose();
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:44,代码来源:SVGImageElementBridge.java
示例20: updateThumbnailRenderingTransform
import org.w3c.dom.svg.SVGSVGElement; //导入依赖的package包/类
/**
* Updates the thumbnail component rendering transform.
*/
protected void updateThumbnailRenderingTransform() {
SVGDocument svgDocument = svgCanvas.getSVGDocument();
if (svgDocument != null) {
SVGSVGElement elt = svgDocument.getRootElement();
Dimension dim = svgThumbnailCanvas.getSize();
// XXX Update this to use the animated values of 'viewBox'
// and 'preserveAspectRatio'.
String viewBox = elt.getAttributeNS
(null, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE);
AffineTransform Tx;
if (viewBox.length() != 0) {
String aspectRatio = elt.getAttributeNS
(null, SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE);
Tx = ViewBox.getPreserveAspectRatioTransform
(elt, viewBox, aspectRatio, dim.width, dim.height, null);
} else {
// no viewBox has been specified, create a scale transform
Dimension2D docSize = svgCanvas.getSVGDocumentSize();
double sx = dim.width / docSize.getWidth();
double sy = dim.height / docSize.getHeight();
double s = Math.min(sx, sy);
Tx = AffineTransform.getScaleInstance(s, s);
}
GraphicsNode gn = svgCanvas.getGraphicsNode();
CanvasGraphicsNode cgn = getCanvasGraphicsNode(gn);
if (cgn != null) {
AffineTransform vTx = cgn.getViewingTransform();
if ((vTx != null) && !vTx.isIdentity()) {
try {
AffineTransform invVTx = vTx.createInverse();
Tx.concatenate(invVTx);
} catch (NoninvertibleTransformException nite) {
/* nothing */
}
}
}
svgThumbnailCanvas.setRenderingTransform(Tx);
overlay.synchronizeAreaOfInterest();
}
}
开发者ID:git-moss,项目名称:Push2Display,代码行数:48,代码来源:ThumbnailDialog.java
注:本文中的org.w3c.dom.svg.SVGSVGElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论