/** * Sets the document this bridge context is dedicated to, to the * specified document. * @param document the document */ protected void setDocument(Document document) { if (this.document != document){ fontFamilyMap = null; } this.document = document; this.isSVG12 = ((SVGOMDocument) document).isSVG12(); registerSVGBridges(); }
/** * Returns the value corresponding to the default font. */ public Value getDefaultFontFamily() { // No cache needed since the default font family is asked only // one time on the root element (only if it does not have its // own font-family). SVGOMDocument doc = (SVGOMDocument)document; SVGStylableElement root = (SVGStylableElement)doc.getRootElement(); String str = userAgent.getDefaultFontFamily(); return doc.getCSSEngine().parsePropertyValue (root,SVGConstants.CSS_FONT_FAMILY_PROPERTY, str); }
attrModified }); addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeInserted", nodeInserted, false, null); addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved", nodeRemoved, false, null); addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMSubtreeModified", subtreeModified, false, null); addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMCharacterDataModified", cdataModified, false, null); addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified", attrModified, false, null);
try { context.dispose(); document.setURLObject(new URL(transcoderInput.getURI())); transcode(document, transcoderInput.getURI(), null); SVGSVGElement root = document.getRootElement();
/** * <b>DOM</b>: Implements {@link * DOMImplementation#createDocument(String,String,DocumentType)}. */ public Document createDocument(String namespaceURI, String qualifiedName, DocumentType doctype) throws DOMException { SVGOMDocument result = new SVG12OMDocument(doctype, this); result.setIsSVG12(true); // BUG 32108: return empty document if qualifiedName is null. if (qualifiedName != null) result.appendChild(result.createElementNS(namespaceURI, qualifiedName)); return result; }
/** * Removes event listeners from the DOM and CSS engine. */ protected void removeDOMListeners() { SVGOMDocument doc = (SVGOMDocument)document; doc.removeEventListenerNS (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified", domAttrModifiedEventListener, true); doc.removeEventListenerNS (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeInserted", domNodeInsertedEventListener, true); doc.removeEventListenerNS (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved", domNodeRemovedEventListener, true); doc.removeEventListenerNS (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMCharacterDataModified", domCharacterDataModifiedEventListener, true); doc.removeAnimatedAttributeListener(animatedAttributeListener); CSSEngine cssEngine = doc.getCSSEngine(); if (cssEngine != null) { cssEngine.removeCSSEngineListener (cssPropertiesChangedListener); cssEngine.dispose(); doc.setCSSEngine(null); } }
public void run() { userAgent.setSVGCursor(holder.getCursor()); String href = elt.getHref().getAnimVal(); ParsedURL purl = new ParsedURL(elt.getBaseURI(), href); SVGOMDocument doc = (SVGOMDocument) elt.getOwnerDocument(); ParsedURL durl = doc.getParsedURL(); if (purl.sameFile(durl)) { String frag = purl.getRef(); if (frag != null && frag.length() != 0) { Element refElt = doc.getElementById(frag); if (refElt instanceof SVGOMAnimationElement) { SVGOMAnimationElement aelt = (SVGOMAnimationElement) refElt; float t = aelt.getHyperlinkBeginTime(); if (Float.isNaN(t)) { aelt.beginElement(); } else { doc.getRootElement().setCurrentTime(t); } return; } } } userAgent.openLink(elt); } }
/** * Creates a new SVGAnimationEngine. */ public SVGAnimationEngine(Document doc, BridgeContext ctx) { super(doc); this.ctx = ctx; SVGOMDocument d = (SVGOMDocument) doc; cssEngine = d.getCSSEngine(); dummyStyleMap = new StyleMap(cssEngine.getNumberOfProperties()); isSVG12 = d.isSVG12(); }
/** * Initializes the given document. */ protected void initializeDocument(Document document) { SVGOMDocument doc = (SVGOMDocument)document; CSSEngine eng = doc.getCSSEngine(); if (eng == null) { SVGDOMImplementation impl; impl = (SVGDOMImplementation)doc.getImplementation(); eng = impl.createCSSEngine(doc, this); eng.setCSSEngineUserAgent(new CSSEngineUserAgentWrapper(userAgent)); doc.setCSSEngine(eng); eng.setMedia(userAgent.getMedia()); String uri = userAgent.getUserStyleSheetURI(); if (uri != null) { try { ParsedURL url = new ParsedURL(uri); eng.setUserAgentStyleSheet (eng.parseStyleSheet(url, "all")); } catch (Exception e) { userAgent.displayError(e); } } eng.setAlternateStyleSheet(userAgent.getAlternateStyleSheet()); } }
doc.addEventListenerNS (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified", doc.addEventListenerNS (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeInserted", doc.addEventListenerNS (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved", doc.addEventListenerNS (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMCharacterDataModified", doc.addAnimatedAttributeListener(animatedAttributeListener); CSSEngine cssEngine = doc.getCSSEngine(); cssPropertiesChangedListener = new CSSPropertiesChangedListener(); cssEngine.addCSSEngineListener(cssPropertiesChangedListener);
subCtx = null; if (!isLocal) { subCtx = (BridgeContext)refDocument.getCSSEngine().getCSSContext(); theCtx = subCtx; localRefElement = (Element)document.importNode(refElement, true, true); Element svgElement = document.createElementNS(SVG_NAMESPACE_URI, SVG_SVG_TAG);
localFontElement = (Element)document.importNode (refGlyphElement.getParentNode(), true); String base = AbstractNode.getBaseURI(altGlyphElement); Element g = document.createElementNS(SVG_NAMESPACE_URI, SVG_G_TAG); g.appendChild(localFontElement); g.setAttributeNS(XMLConstants.XML_NAMESPACE_URI,
URL url = null; try { url = new URL(svgDoc.getDocumentURI()); } catch (MalformedURLException e) { interpreter = factory.createInterpreter(url, svgDoc.isSVG12(), imports);
/** * Returns CSSEngine associated to the specified element. * @param e the element */ public static CSSEngine getCSSEngine(Element e) { return ((SVGOMDocument)e.getOwnerDocument()).getCSSEngine(); }
/** * Returns the associated style-sheet. */ public StyleSheet getCSSStyleSheet() { if (styleSheet == null) { HashMap<String, String> attrs = getPseudoAttributes(); String type = attrs.get("type"); if ("text/css".equals(type)) { String title = attrs.get("title"); String media = attrs.get("media"); String href = attrs.get("href"); String alternate = attrs.get("alternate"); SVGOMDocument doc = (SVGOMDocument)getOwnerDocument(); ParsedURL durl = doc.getParsedURL(); ParsedURL burl = new ParsedURL(durl, href); CSSEngine e = doc.getCSSEngine(); styleSheet = e.parseStyleSheet(burl, media); styleSheet.setAlternate("yes".equals(alternate)); styleSheet.setTitle(title); } } return styleSheet; }
/** * Creates an appropriate ScriptingEnvironment and XBL manager for * the given document. */ protected ScriptingEnvironment initializeScriptingEnvironment (BridgeContext ctx) { SVGOMDocument d = (SVGOMDocument) ctx.getDocument(); ScriptingEnvironment se; if (d.isSVG12()) { se = new SVG12ScriptingEnvironment(ctx); ctx.xblManager = new DefaultXBLManager(d, ctx); d.setXBLManager(ctx.xblManager); } else { se = new ScriptingEnvironment(ctx); } return se; }
if (uri != null) { ParsedURL url = new ParsedURL(uri); ((SVGOMDocument)document).setParsedURL(url); SVGSVGElement root = svgDoc.getRootElement(); ctx = createBridgeContext(svgDoc);
URL urlObj = null; if (doc instanceof SVGOMDocument) { urlObj = ((SVGOMDocument) doc).getURLObject();
/** * Returns the URI of the referenced stylesheet. */ public String getStyleSheetURI() { SVGOMDocument svgDoc = (SVGOMDocument) getOwnerDocument(); ParsedURL url = svgDoc.getParsedURL(); String href = getPseudoAttributes().get("href"); if (url != null) { return new ParsedURL(url, href).toString(); } return href; }
public List getBridgeExtensions(Document doc) { Element root = ((SVGOMDocument)doc).getRootElement(); String ver = root.getAttributeNS (null, SVGConstants.SVG_VERSION_ATTRIBUTE); BridgeExtension svgBE; if ((ver.length()==0) || ver.equals("1.0") || ver.equals("1.1")) svgBE = new SVGBridgeExtension(); else svgBE = new SVG12BridgeExtension(); float priority = svgBE.getPriority(); extensions = new LinkedList(getGlobalBridgeExtensions()); ListIterator li = extensions.listIterator(); for (;;) { if (!li.hasNext()) { li.add(svgBE); break; } BridgeExtension lbe = (BridgeExtension)li.next(); if (lbe.getPriority() > priority) { li.previous(); li.add(svgBE); break; } } return extensions; }