Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.apache.batik.bridge;
import java.awt.Cursor;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import org.apache.batik.anim.dom.AbstractSVGAnimatedLength;
import org.apache.batik.anim.dom.AnimatedLiveAttributeValue;
import org.apache.batik.anim.dom.SVGOMAnimatedLength;
import org.apache.batik.anim.dom.SVGOMDocument;
import org.apache.batik.anim.dom.SVGOMUseElement;
import org.apache.batik.dom.events.NodeEventTarget;
import org.apache.batik.dom.svg.LiveAttributeException;
import org.apache.batik.dom.svg.SVGOMUseShadowRoot;
import org.apache.batik.gvt.CompositeGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.batik.constants.XMLConstants;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.svg.SVGTransformable;
import org.w3c.dom.svg.SVGUseElement;
/**
* Bridge class for the <use> element.
*
* @author Thierry Kormann
* @version $Id: SVGUseElementBridge.java 1851346 2019-01-15 13:41:00Z ssteiner $
*/
public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
/**
* Used to handle mutation of the referenced content. This is
* only used in dynamic context and only for reference to local
* content.
*/
protected ReferencedElementMutationListener l;
/**
* The bridge context for the referenced document.
*/
protected BridgeContext subCtx;
/**
* Constructs a new bridge for the <use> element.
*/
public SVGUseElementBridge() {}
/**
* Returns 'use'.
*/
public String getLocalName() {
return SVG_USE_TAG;
}
/**
* Returns a new instance of this bridge.
*/
public Bridge getInstance(){
return new SVGUseElementBridge();
}
/**
* Creates a GraphicsNode according to the specified parameters.
*
* @param ctx the bridge context to use
* @param e the element that describes the graphics node to build
* @return a graphics node that represents the specified element
*/
public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
// 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent()))
return null;
CompositeGraphicsNode gn = buildCompositeGraphicsNode(ctx, e, null);
associateSVGContext(ctx, e, gn);
return gn;
}
/**
* Creates a GraphicsNode from the input element and
* populates the input CompositeGraphicsNode
*
* @param ctx the bridge context to use
* @param e the element that describes the graphics node to build
* @param gn the CompositeGraphicsNode where the use graphical
* content will be appended. The composite node is emptied
* before appending new content.
*/
public CompositeGraphicsNode buildCompositeGraphicsNode
(BridgeContext ctx, Element e, CompositeGraphicsNode gn) {
// get the referenced element
SVGOMUseElement ue = (SVGOMUseElement) e;
String uri = ue.getHref().getAnimVal();
if (uri.length() == 0) {
throw new BridgeException(ctx, e, ERR_ATTRIBUTE_MISSING,
new Object[] {"xlink:href"});
}
Element refElement = ctx.getReferencedElement(e, uri);
SVGOMDocument document, refDocument;
document = (SVGOMDocument)e.getOwnerDocument();
refDocument = (SVGOMDocument)refElement.getOwnerDocument();
boolean isLocal = (refDocument == document);
BridgeContext theCtx = ctx;
subCtx = null;
if (!isLocal) {
subCtx = (BridgeContext)refDocument.getCSSEngine().getCSSContext();
theCtx = subCtx;
}
// import or clone the referenced element in current document
Element localRefElement;
localRefElement = (Element)document.importNode(refElement, true, true);
if (SVG_SYMBOL_TAG.equals(localRefElement.getLocalName())) {
// The referenced 'symbol' and its contents are deep-cloned into
// the generated tree, with the exception that the 'symbol' is
// replaced by an 'svg'.
Element svgElement = document.createElementNS(SVG_NAMESPACE_URI,
SVG_SVG_TAG);
// move the attributes from to the