当前位置: 首页>>代码示例>>Java>>正文


Java SVGDocument.getRootElement方法代码示例

本文整理汇总了Java中org.w3c.dom.svg.SVGDocument.getRootElement方法的典型用法代码示例。如果您正苦于以下问题:Java SVGDocument.getRootElement方法的具体用法?Java SVGDocument.getRootElement怎么用?Java SVGDocument.getRootElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.svg.SVGDocument的用法示例。


在下文中一共展示了SVGDocument.getRootElement方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:22,代码来源:JSVGScrollPane.java

示例2: setToolTip

import org.w3c.dom.svg.SVGDocument; //导入方法依赖的package包/类
/**
 * Sets the tool tip on the input element.
 */
public void setToolTip(Element elt, String toolTip){
    if (toolTipMap == null) {
        toolTipMap = new WeakHashMap();
    }
    if (toolTipDocs == null) {
        toolTipDocs = new WeakHashMap();
    }
    SVGDocument doc = (SVGDocument)elt.getOwnerDocument();
    if (toolTipDocs.put(doc, MAP_TOKEN) == null) {
        NodeEventTarget root;
        root = (NodeEventTarget)doc.getRootElement();
        // On mouseover, it sets the tooltip to the given value
        root.addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
                                SVGConstants.SVG_EVENT_MOUSEOVER,
                                toolTipListener,
                                false, null);
        // On mouseout, it removes the tooltip
        root.addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
                                SVGConstants.SVG_EVENT_MOUSEOUT,
                                toolTipListener,
                                false, null);
    }

    toolTipMap.put(elt, toolTip);

    if (elt == lastTarget)
        EventQueue.invokeLater(new ToolTipRunnable(toolTip));
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:32,代码来源:JSVGCanvas.java

示例3: SvgWidget

import org.w3c.dom.svg.SVGDocument; //导入方法依赖的package包/类
public SvgWidget(IModelerScene scene, SVGDocument doc, Dimension dimension) {
        super((Scene) scene);

        rootElement = doc.getRootElement();
        width = new Integer(rootElement.getAttribute("width"));
        height = new Integer(rootElement.getAttribute("height"));

        this.preDimension = new Dimension(width, height);
        this.dimension = dimension;
        scaleX = dimension.getWidth() / preDimension.getWidth();
        scaleY = dimension.getHeight() / preDimension.getHeight();
        setSVGDocument(doc);

//        setInitialGraphicsNode(graphicsNode);
    }
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:16,代码来源:SvgWidget.java

示例4: getBaseElement

import org.w3c.dom.svg.SVGDocument; //导入方法依赖的package包/类
/**
 * Default implementation uses the root element of the document
 * associated with BridgeContext.  This is useful for CSS case.
 */
protected Element getBaseElement(BridgeContext ctx) {
    SVGDocument d = (SVGDocument)ctx.getDocument();
    return d.getRootElement();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:9,代码来源:FontFace.java

示例5: checkInteractiveElement

import org.w3c.dom.svg.SVGDocument; //导入方法依赖的package包/类
/**
 * used by isInteractiveDocument to check if document
 * contains any 'interactive' elements.
 */
public boolean checkInteractiveElement(SVGDocument doc,
                                       Element e) {
    String tag = e.getLocalName();

    // Check if it's one of our important element.
    if (SVGConstants.SVG_A_TAG.equals(tag))
        return true;

    // This is a bit of a hack but don't count
    // title and desc as children of root SVG since
    // we don't show tool tips for them anyways.
    if (SVGConstants.SVG_TITLE_TAG.equals(tag)) {
        return (e.getParentNode() != doc.getRootElement());
    }
    if (SVGConstants.SVG_DESC_TAG.equals(tag)) {
        return (e.getParentNode() != doc.getRootElement());
    }
    if (SVGConstants.SVG_CURSOR_TAG.equals(tag))
        return true;

    // I am well aware that this is not 100% accurate but it's
    // the best I can do w/o booting the CSSEngine.
    if (e.getAttribute(CSSConstants.CSS_CURSOR_PROPERTY).length() >0)
        return true;

    /* We would like to do this but the CSS Engine isn't setup when
       we want to do this.

    // Check if cursor property is set to something other than 'auto'.
    Value cursorValue = CSSUtilities.getComputedStyle
        (e, SVGCSSEngine.CURSOR_INDEX);
    if ((cursorValue != null) &&
        (cursorValue.getCssValueType()  == CSSValue.CSS_PRIMITIVE_VALUE) &&
        (cursorValue.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) &&
        (SVGConstants.SVG_AUTO_VALUE.equals(cursorValue.getStringValue())))
        return true;
    */

    // Check all the child elements for any of the above.
    final String svg_ns = SVGConstants.SVG_NAMESPACE_URI;
    for (Node n = e.getFirstChild();
         n != null;
         n = n.getNextSibling()) {
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            Element child = (Element)n;
            if (svg_ns.equals(child.getNamespaceURI()))
                if (checkInteractiveElement(child))
                    return true;
        }
    }
    return false;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:57,代码来源:BridgeContext.java

示例6: updateThumbnailRenderingTransform

import org.w3c.dom.svg.SVGDocument; //导入方法依赖的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.SVGDocument.getRootElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。