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


Java XLinkSupport类代码示例

本文整理汇总了Java中org.apache.batik.dom.util.XLinkSupport的典型用法代码示例。如果您正苦于以下问题:Java XLinkSupport类的具体用法?Java XLinkSupport怎么用?Java XLinkSupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XLinkSupport类属于org.apache.batik.dom.util包,在下文中一共展示了XLinkSupport类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: relativizeElement

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
protected static void relativizeElement(Element e) {
    // work from leaves to root in each subtree
    final NodeList children = e.getChildNodes();
    for (int i = 0; i < children.getLength(); ++i) {
      final Node n = children.item(i);
      if (n.getNodeType() == Node.ELEMENT_NODE)
        relativizeElement((Element) n);
    }

    // relativize the xlink:href attribute if there is one
    if (e.hasAttributeNS(XLinkSupport.XLINK_NAMESPACE_URI, "href")) {
      try {
        final URL url = new URL(new URL(e.getBaseURI()),
                                XLinkSupport.getXLinkHref(e));
        final String anchor = url.getRef();
        final String name = new File(url.getPath()).getName();
        XLinkSupport.setXLinkHref(e, name + '#' + anchor);
      }
      // FIXME: review error message
      catch (MalformedURLException ex) {
//        ErrorLog.warn(ex);
      }
    }

    // remove xml:base attribute if there is one
    e.removeAttributeNS(XMLSupport.XML_NAMESPACE_URI, "base");
  }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:28,代码来源:SVGImageUtils.java

示例2: extractPatternContent

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
/**
 * Returns the content of the specified pattern element. The
 * content of the pattern can be specified as children of the
 * patternElement or children of one of its 'ancestor' (linked with
 * the xlink:href attribute).
 *
 * @param patternElement the gradient element
 * @param ctx the bridge context to use
 */
protected static
    RootGraphicsNode extractPatternContent(Element patternElement,
                                           BridgeContext ctx) {

    List refs = new LinkedList();
    for (;;) {
        RootGraphicsNode content
            = extractLocalPatternContent(patternElement, ctx);
        if (content != null) {
            return content; // pattern content found, exit
        }
        String uri = XLinkSupport.getXLinkHref(patternElement);
        if (uri.length() == 0) {
            return null; // no xlink:href found, exit
        }
        // check if there is circular dependencies
        SVGOMDocument doc =
            (SVGOMDocument)patternElement.getOwnerDocument();
        ParsedURL purl = new ParsedURL(doc.getURL(), uri);
        if (!purl.complete())
            throw new BridgeException(ctx, patternElement,
                                      ERR_URI_MALFORMED,
                                      new Object[] {uri});

        if (contains(refs, purl)) {
            throw new BridgeException(ctx, patternElement,
                                      ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
                                      new Object[] {uri});
        }
        refs.add(purl);
        patternElement = ctx.getReferencedElement(patternElement, uri);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:43,代码来源:SVGPatternElementBridge.java

示例3: extractStop

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
/**
 * Returns the stops elements of the specified gradient
 * element. Stops can be children of the gradients or defined on
 * one of its 'ancestor' (linked with the xlink:href attribute).
 *
 * @param paintElement the gradient element
 * @param opacity the opacity
 * @param ctx the bridge context to use
 */
protected static List extractStop(Element paintElement,
                                  float opacity,
                                  BridgeContext ctx) {

    List refs = new LinkedList();
    for (;;) {
        List stops = extractLocalStop(paintElement, opacity, ctx);
        if (stops != null) {
            return stops; // stop elements found, exit
        }
        String uri = XLinkSupport.getXLinkHref(paintElement);
        if (uri.length() == 0) {
            return null; // no xlink:href found, exit
        }
        // check if there is circular dependencies
        String baseURI = ((AbstractNode) paintElement).getBaseURI();
        ParsedURL purl = new ParsedURL(baseURI, uri);

        if (contains(refs, purl)) {
            throw new BridgeException(ctx, paintElement,
                                      ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
                                      new Object[] {uri});
        }
        refs.add(purl);
        paintElement = ctx.getReferencedElement(paintElement, uri);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:37,代码来源:AbstractSVGGradientElementBridge.java

示例4: buildFilterPrimitives

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
/**
 * Builds the filter primitives of filter chain of the specified
 * filter element and returns the last filter primitive
 * created. Filter primitives can be children of the filter or
 * defined on one of its 'ancestor' (linked with the xlink:href
 * attribute).
 *
 * @param filterElement the filter element
 * @param filterRegion the filter chain region
 * @param filteredElement the filtered element
 * @param filteredNode the filtered node
 * @param in the input Filter
 * @param filterNodeMap the map used by named filter primitives
 * @param ctx the bridge context
 * @return the last filter primitive created
 */
protected static Filter buildFilterPrimitives(Element filterElement,
                                              Rectangle2D filterRegion,
                                              Element filteredElement,
                                              GraphicsNode filteredNode,
                                              Filter in,
                                              Map filterNodeMap,
                                              BridgeContext ctx) {

    List refs = new LinkedList();
    for (;;) {
        Filter newIn = buildLocalFilterPrimitives(filterElement,
                                                  filterRegion,
                                                  filteredElement,
                                                  filteredNode,
                                                  in,
                                                  filterNodeMap,
                                                  ctx);
        if (newIn != in) {
            return newIn; // filter primitives found, exit
        }
        String uri = XLinkSupport.getXLinkHref(filterElement);
        if (uri.length() == 0) {
            return in; // no xlink:href found, exit
        }
        // check if there is circular dependencies
        SVGOMDocument doc = (SVGOMDocument)filterElement.getOwnerDocument();
        ParsedURL url = new ParsedURL(doc.getURLObject(), uri);
        if (refs.contains(url)) {
            throw new BridgeException(ctx, filterElement,
                                      ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
                                      new Object[] {uri});
        }
        refs.add(url);
        filterElement = ctx.getReferencedElement(filterElement, uri);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:53,代码来源:SVGFilterElementBridge.java

示例5: extractOpacity

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
protected static float extractOpacity(Element paintElement,
                                      float opacity,
                                      BridgeContext ctx) {
    Map refs = new HashMap();
    CSSEngine eng = CSSUtilities.getCSSEngine(paintElement);
    int pidx = eng.getPropertyIndex
        (SVG12CSSConstants.CSS_SOLID_OPACITY_PROPERTY);

    for (;;) {
        Value opacityVal =
            CSSUtilities.getComputedStyle(paintElement, pidx);

        // Was solid-opacity explicity set on this element?
        StyleMap sm =
            ((CSSStylableElement)paintElement).getComputedStyleMap(null);
        if (!sm.isNullCascaded(pidx)) {
            // It was explicit...
            float attr = PaintServer.convertOpacity(opacityVal);
            return (opacity * attr);
        }

        String uri = XLinkSupport.getXLinkHref(paintElement);
        if (uri.length() == 0) {
            return opacity; // no xlink:href found, exit
        }

        SVGOMDocument doc = (SVGOMDocument)paintElement.getOwnerDocument();
        ParsedURL purl = new ParsedURL(doc.getURL(), uri);

        // check if there is circular dependencies
        if (refs.containsKey(purl)) {
            throw new BridgeException
                (ctx, paintElement,
                 ErrorConstants.ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
                 new Object[] {uri});
        }
        refs.put(purl, purl);
        paintElement = ctx.getReferencedElement(paintElement, uri);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:41,代码来源:SVGSolidColorElementBridge.java

示例6: initializeAnimation

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
/**
 * Parses the animation element's target attributes and adds it to the
 * document's AnimationEngine.
 */
protected void initializeAnimation() {
    // Determine the target element.
    String uri = XLinkSupport.getXLinkHref(element);
    Node t;
    if (uri.length() == 0) {
        t = element.getParentNode();
    } else {
        t = ctx.getReferencedElement(element, uri);
        if (t.getOwnerDocument() != element.getOwnerDocument()) {
            throw new BridgeException
                (ctx, element, ErrorConstants.ERR_URI_BAD_TARGET,
                 new Object[] { uri });
        }
    }
    animationTarget = null;
    if (t instanceof SVGOMElement) {
        targetElement = (SVGOMElement) t;
        animationTarget = targetElement;
    }
    if (animationTarget == null) {
        throw new BridgeException
            (ctx, element, ErrorConstants.ERR_URI_BAD_TARGET,
             new Object[] { uri });
    }

    // Add the animation.
    timedElement = createTimedElement();
    animation = createAnimation(animationTarget);
    eng.addAnimation(animationTarget, AnimationEngine.ANIM_TYPE_OTHER,
                     attributeNamespaceURI, attributeLocalName, animation);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:36,代码来源:SVGAnimateMotionElementBridge.java

示例7: getChainableAttributeNS

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
/**
 * Returns the value of the specified attribute specified on the
 * specified element or one of its ancestor. Ancestors are found
 * using the xlink:href attribute.
 *
 * @param element the element to start with
 * @param namespaceURI the namespace URI of the attribute to return
 * @param attrName the name of the attribute to search
 * @param ctx the bridge context
 * @return the value of the attribute or an empty string if not defined
 */
public static String getChainableAttributeNS(Element element,
                                             String namespaceURI,
                                             String attrName,
                                             BridgeContext ctx) {

    DocumentLoader loader = ctx.getDocumentLoader();
    Element e = element;
    List refs = new LinkedList();
    for (;;) {
        String v = e.getAttributeNS(namespaceURI, attrName);
        if (v.length() > 0) { // exit if attribute defined
            return v;
        }
        String uriStr = XLinkSupport.getXLinkHref(e);
        if (uriStr.length() == 0) { // exit if no more xlink:href
            return "";
        }
        String baseURI = ((AbstractNode) e).getBaseURI();
        ParsedURL purl = new ParsedURL(baseURI, uriStr);

        Iterator iter = refs.iterator();
        while (iter.hasNext()) {
            if (purl.equals(iter.next()))
                throw new BridgeException
                    (ctx, e, ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
                     new Object[] {uriStr});
        }

        try {
            SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
            URIResolver resolver = ctx.createURIResolver(svgDoc, loader);
            e = resolver.getElement(purl.toString(), e);
            refs.add(purl);
        } catch(IOException ioEx ) {
            throw new BridgeException(ctx, e, ioEx, ERR_URI_IO,
                                      new Object[] {uriStr});
        } catch(SecurityException secEx ) {
            throw new BridgeException(ctx, e, secEx, ERR_URI_UNSECURE,
                                      new Object[] {uriStr});
        }
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:54,代码来源:SVGUtilities.java

示例8: initializeAnimation

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
/**
 * Parses the animation element's target attributes and adds it to the
 * document's AnimationEngine.
 */
protected void initializeAnimation() {
    // Determine the target element.
    String uri = XLinkSupport.getXLinkHref(element);
    Node t;
    if (uri.length() == 0) {
        t = element.getParentNode();
    } else {
        t = ctx.getReferencedElement(element, uri);
        if (t.getOwnerDocument() != element.getOwnerDocument()) {
            throw new BridgeException
                (ctx, element, ErrorConstants.ERR_URI_BAD_TARGET,
                 new Object[] { uri });
        }
    }
    animationTarget = null;
    if (t instanceof SVGOMElement) {
        targetElement = (SVGOMElement) t;
        animationTarget = targetElement;
    }
    if (animationTarget == null) {
        throw new BridgeException
            (ctx, element, ErrorConstants.ERR_URI_BAD_TARGET,
             new Object[] { uri });
    }

    // Get the attribute/property name.
    String an = element.getAttributeNS(null, SVG_ATTRIBUTE_NAME_ATTRIBUTE);
    int ci = an.indexOf(':');
    if (ci == -1) {
        if (element.hasProperty(an)) {
            animationType = AnimationEngine.ANIM_TYPE_CSS;
            attributeLocalName = an;
        } else {
            animationType = AnimationEngine.ANIM_TYPE_XML;
            attributeLocalName = an;
        }
    } else {
        animationType = AnimationEngine.ANIM_TYPE_XML;
        String prefix = an.substring(0, ci);
        attributeNamespaceURI = element.lookupNamespaceURI(prefix);
        attributeLocalName = an.substring(ci + 1);
    }
    if (animationType == AnimationEngine.ANIM_TYPE_CSS
            && !targetElement.isPropertyAnimatable(attributeLocalName)
        || animationType == AnimationEngine.ANIM_TYPE_XML
            && !targetElement.isAttributeAnimatable(attributeNamespaceURI,
                                                    attributeLocalName)) {
        throw new BridgeException
            (ctx, element, "attribute.not.animatable",
             new Object[] { targetElement.getNodeName(), an });
    }

    // Check that the attribute/property is animatable with this
    // animation element.
    int type;
    if (animationType == AnimationEngine.ANIM_TYPE_CSS) {
        type = targetElement.getPropertyType(attributeLocalName);
    } else {
        type = targetElement.getAttributeType(attributeNamespaceURI,
                                              attributeLocalName);
    }
    if (!canAnimateType(type)) {
        throw new BridgeException
            (ctx, element, "type.not.animatable",
             new Object[] { targetElement.getNodeName(), an,
                            element.getNodeName() });
    }

    // Add the animation.
    timedElement = createTimedElement();
    animation = createAnimation(animationTarget);
    eng.addAnimation(animationTarget, animationType, attributeNamespaceURI,
                     attributeLocalName, animation);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:79,代码来源:SVGAnimationElementBridge.java

示例9: extractColor

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
protected static Color extractColor(Element paintElement,
                                    float opacity,
                                    BridgeContext ctx) {
    Map refs = new HashMap();
    CSSEngine eng = CSSUtilities.getCSSEngine(paintElement);
    int pidx = eng.getPropertyIndex
        (SVG12CSSConstants.CSS_SOLID_COLOR_PROPERTY);

    for (;;) {
        Value colorDef =
            CSSUtilities.getComputedStyle(paintElement, pidx);

        // Was solid-color explicity set on this element?
        StyleMap sm =
            ((CSSStylableElement)paintElement).getComputedStyleMap(null);
        if (!sm.isNullCascaded(pidx)) {
            // It was explicit...
            if (colorDef.getCssValueType() ==
                CSSValue.CSS_PRIMITIVE_VALUE) {
                return PaintServer.convertColor(colorDef, opacity);
            } else {
                return PaintServer.convertRGBICCColor
                    (paintElement, colorDef.item(0),
                     colorDef.item(1),
                     opacity, ctx);
            }
        }


        String uri = XLinkSupport.getXLinkHref(paintElement);
        if (uri.length() == 0) {
            // no xlink:href found, exit
            return new Color(0, 0, 0, opacity);
        }

        SVGOMDocument doc = (SVGOMDocument)paintElement.getOwnerDocument();
        ParsedURL purl = new ParsedURL(doc.getURL(), uri);

        // check if there is circular dependencies
        if (refs.containsKey(purl)) {
            throw new BridgeException
                (ctx, paintElement,
                 ErrorConstants.ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
                 new Object[] {uri});
        }
        refs.put(purl, purl);
        paintElement = ctx.getReferencedElement(paintElement, uri);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:50,代码来源:SVGSolidColorElementBridge.java

示例10: getFontFaceSrcs

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
/**
 * the returned list may contain Strings and ParsedURLs
 */
public List getFontFaceSrcs(Element fontFaceElement) {
    // Search for a font-face-src element
    Element ffsrc = null;
    for (Node n = fontFaceElement.getFirstChild();
         n != null;
         n = n.getNextSibling()) {
        if ((n.getNodeType() == Node.ELEMENT_NODE) &&
            n.getNamespaceURI().equals(SVG_NAMESPACE_URI) &&
            n.getLocalName().equals(SVG_FONT_FACE_SRC_TAG)) {
                ffsrc = (Element)n;
                break;
        }
    }
    if (ffsrc == null)
        return null;

    List ret = new LinkedList();

    // Search for a font-face-uri, or font-face-name elements
    for (Node n = ffsrc.getFirstChild();
         n != null;
         n = n.getNextSibling()) {
        if ((n.getNodeType() != Node.ELEMENT_NODE) ||
            !n.getNamespaceURI().equals(SVG_NAMESPACE_URI))
            continue;

        if (n.getLocalName().equals(SVG_FONT_FACE_URI_TAG)) {
            Element ffuri = (Element)n;
            String uri = XLinkSupport.getXLinkHref(ffuri);
            String base = AbstractNode.getBaseURI(ffuri);
            ParsedURL purl;
            if (base != null) purl = new ParsedURL(base, uri);
            else              purl = new ParsedURL(uri);
            ret.add(purl);                                      // here we add a ParsedURL
            continue;
        }
        if (n.getLocalName().equals(SVG_FONT_FACE_NAME_TAG)) {
            Element ffname = (Element)n;
            String s = ffname.getAttribute("name");
            if (s.length() != 0)
                ret.add(s);                                     // here we add a String
        }
    }
    return ret;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:49,代码来源:SVGFontFaceElementBridge.java

示例11: addRefInfo

import org.apache.batik.dom.util.XLinkSupport; //导入依赖的package包/类
protected void addRefInfo(Element e, Collection elems, 
                          Collection minDim, Collection maxDim,
                          Rectangle2D bounds) {
    String uriStr = XLinkSupport.getXLinkHref(e);
    if (uriStr.length() == 0) {
        throw new BridgeException(ctx, e, ERR_ATTRIBUTE_MISSING,
                                  new Object[] {"xlink:href"});
    }
    String baseURI = AbstractNode.getBaseURI(e);
    ParsedURL purl;
    if (baseURI == null) purl = new ParsedURL(uriStr);
    else                 purl = new ParsedURL(baseURI, uriStr);
    Document doc = e.getOwnerDocument();
    Element imgElem = doc.createElementNS(SVG_NAMESPACE_URI, 
                                          SVG_IMAGE_TAG);
    imgElem.setAttributeNS(XLINK_NAMESPACE_URI, 
                           XLINK_HREF_ATTRIBUTE, purl.toString());
    // move the attributes from <subImageRef> to the <image> element
    NamedNodeMap attrs = e.getAttributes();
    int len = attrs.getLength();
    for (int i = 0; i < len; i++) {
        Attr attr = (Attr)attrs.item(i);
        imgElem.setAttributeNS(attr.getNamespaceURI(),
                               attr.getName(),
                               attr.getValue());
    }
    String s;
    s = e.getAttribute("x");
    if (s.length() == 0) imgElem.setAttribute("x", "0");
    s = e.getAttribute("y");
    if (s.length() == 0) imgElem.setAttribute("y", "0");
    s = e.getAttribute("width");
    if (s.length() == 0) imgElem.setAttribute("width", "100%");
    s = e.getAttribute("height");
    if (s.length() == 0) imgElem.setAttribute("height", "100%");
    e.appendChild(imgElem);
    elems.add(imgElem);

    minDim.add(getElementMinPixel(e, bounds));
    maxDim.add(getElementMaxPixel(e, bounds));
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:42,代码来源:SVGMultiImageElementBridge.java


注:本文中的org.apache.batik.dom.util.XLinkSupport类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。