Package org.w3c.dom.svg

Examples of org.w3c.dom.svg.SVGElement


     * also be an instance of <code>EventTarget</code> otherwise no listener
     * will be added.
     * @param node the <code>GraphicsNode</code>.
     */
    public static void addDOMListener(BridgeContext ctx, Element eee) {
        SVGElement element = null;
        EventTarget target = null;
        try {
            element = (SVGElement)eee;
            // ability for scripts to be called
            target = (EventTarget)element;
        } catch (ClassCastException e) {
            // will not work on this one!
            return;
        }
        SVGSVGElement svgElement = (SVGSVGElement)element.getOwnerSVGElement();
        if (svgElement == null) {
            if (element.getLocalName().equals(SVG_SVG_TAG)) {
                svgElement = (SVGSVGElement)element;
            } else {
                // something goes wrong => disable scripting
                return;
            }
        }
        String language = svgElement.getContentScriptType();
        String script = null;
        if (element.getLocalName().equals(SVG_SVG_TAG)) {
            for (int i = 0; i < EVENT_ATTRIBUTES_SVG.length; i++) {
                if (!(script = element.getAttribute(EVENT_ATTRIBUTES_SVG[i])).
                    equals("")) {
                    // <!> TODO this will stop working if someone change
                    // the content of the event attribute
                    addScriptCaller(target, EVENT_NAMES[i+FIRST_SVG_EVENT],
                                    new ScriptCaller(ctx, script, language));
                }
            }
            // continue
        } else
            if (element.getLocalName().equals("set") ||
                element.getLocalName().startsWith("animate")) {
                for (int i = 0; i < EVENT_ATTRIBUTES_ANIMATION.length; i++) {
                    if (!(script =
                          element.getAttribute(EVENT_ATTRIBUTES_ANIMATION[i])).
                        equals("")) {
                        // <!> TODO this will stop working if someone change
                        // the content of the event attribute
                        addScriptCaller(target, EVENT_NAMES[i+
                                                           FIRST_ANIMATION_EVENT],
                                        new ScriptCaller(ctx, script, language));
                    }
                }
                // not other stuff to do on this kind of events
                return;
            }
        for (int i = 0; i < EVENT_ATTRIBUTES_GRAPHICS.length; i++) {
            if (!(script = element.getAttribute(EVENT_ATTRIBUTES_GRAPHICS[i])).
                equals("")) {
                // <!> TODO this will stop working if someone change
                // the content of the event attribute
                addScriptCaller(target, EVENT_NAMES[i],
                                 new ScriptCaller(ctx, script, language));
View Full Code Here


    if(DEBUG) System.out.println("color code: "+colorCode);
   
    NodeList children = document.getElementsByTagName("*");
    for(int i = 0; i < children.getLength(); i++){
      if(children.item(i) instanceof SVGElement){
        SVGElement element = (SVGElement) children.item(i);
        if(element.getId().matches(idRegex)){
          if(DEBUG) System.out.println("child>>> "+element+", "+element.getId());
          String style = element.getAttributeNS(null, "style");
          style = style.replaceFirst("fill:#[a-zA-z0-9]+", "fill:"+colorCode);
          if(DEBUG) System.out.println(style);
          element.setAttributeNS(null, "style", style);
        }
      }
    }
  }
View Full Code Here

     * will be added.
     * @param node the <code>GraphicsNode</code>.
     */
    public static void addDOMListener(BridgeContext ctx,
                                      Element eee) {
        SVGElement element = null;
        EventTarget target = null;
        try {
            element = (SVGElement)eee;
            // ability for scripts to be called
            target = (EventTarget)element;
        } catch (ClassCastException e) {
            // will not work on this one!
            return;
        }
        SVGSVGElement svgElement = (SVGSVGElement)element.getOwnerSVGElement();
        if (svgElement == null) {
            if (element.getLocalName().equals(SVG_SVG_TAG)) {
                svgElement = (SVGSVGElement)element;
            } else {
                // something goes wrong => disable scripting
                return;
            }
        }
        String language = svgElement.getContentScriptType();
        Interpreter interpret = null;
        String script = null;
        if (element.getLocalName().equals(SVG_SVG_TAG)) {
            for (int i = 0; i < EVENT_ATTRIBUTES_SVG.length; i++) {
                if (!(script = element.getAttribute(EVENT_ATTRIBUTES_SVG[i])).
                    equals("")) {
                    if (interpret == null) {
                        // try to get the intepreter only if we have
                        // a reason to do it!
                        interpret = ctx.getInterpreterPool().
                            getInterpreter(element.getOwnerDocument(), language);
                        // the interpreter is not avaible => stop it now!
                        if (interpret == null) {
                            UserAgent ua = ctx.getUserAgent();
                            if (ua != null)
                                ua.displayError(new Exception("unknow language: "+
                                                              language));
                            break;
                        }
                    }
                    // <!> TODO this will stop working if someone change
                    // the content of the event attribute
                    addScriptCaller(target, EVENT_NAMES[i+FIRST_SVG_EVENT],
                                     new ScriptCaller(ctx.getUserAgent(),
                                                      script, interpret));
                }
            }
            // continue
        } else
            if (element.getLocalName().equals("set") ||
                element.getLocalName().startsWith("animate")) {
                for (int i = 0; i < EVENT_ATTRIBUTES_ANIMATION.length; i++) {
                    if (!(script =
                          element.getAttribute(EVENT_ATTRIBUTES_ANIMATION[i])).
                        equals("")) {
                        if (interpret == null) {
                            // try to get the intepreter only if we have
                            // a reason to do it!
                            interpret = ctx.getInterpreterPool().
                                getInterpreter(element.getOwnerDocument(),
                                               language);
                            // the interpreter is not avaible => stop it now!
                            if (interpret == null) {
                                UserAgent ua = ctx.getUserAgent();
                                if (ua != null)
                                    ua.displayError(new Exception("unknow language: "+
                                                                  language));
                                break;
                            }
                        }
                        // <!> TODO this will stop working if someone change
                        // the content of the event attribute
                        addScriptCaller(target, EVENT_NAMES[i+
                                                           FIRST_ANIMATION_EVENT],
                                        new ScriptCaller(ctx.getUserAgent(),
                                                         script, interpret));
                    }
                }
                // not other stuff to do on this kind of events
                return;
            }
        for (int i = 0; i < EVENT_ATTRIBUTES_GRAPHICS.length; i++) {
            if (!(script = element.getAttribute(EVENT_ATTRIBUTES_GRAPHICS[i])).
                equals("")) {
                if (interpret == null) {
                    // try to get the intepreter only if we have
                    // a reason to do it!
                    interpret = ctx.getInterpreterPool().
                        getInterpreter(element.getOwnerDocument(), language);
                    // the interpreter is not avaible => stop it now!
                    if (interpret == null) {
                        UserAgent ua = ctx.getUserAgent();
                        if (ua != null)
                            ua.displayError(new Exception("unknow language: "+
View Full Code Here

                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);
        }
    }
View Full Code Here

  protected void addChild(FONode child) {
    super.addChild(child);
    if(child instanceof GraphicsCreator) {
      GraphicsCreator gc = (GraphicsCreator)child;
      SVGElement graph = gc.createGraphic();
      if(graph != null) {
          mask.addElement(graph);
//          graph.setParent(mask);
        }
    } else {
View Full Code Here

        int numChildren = this.children.size();
        for (int i = 0; i < numChildren; i++) {
            FONode child = (FONode) children.elementAt(i);
            if (child instanceof GraphicsCreator) {
                SVGElement impl = ((GraphicsCreator) child).createGraphic();
                graphic.appendChild(impl);
            } else if (child instanceof Defs) {
            }
        }
View Full Code Here

    ggraphic.setClassName(new SVGAnimatedStringImpl(this.properties.get("class").getString()));
    int numChildren = this.children.size();
    for (int i = 0; i < numChildren; i++) {
      FONode child = (FONode) children.elementAt(i);
      if(child instanceof GraphicsCreator) {
        SVGElement impl = ((GraphicsCreator)child).createGraphic();
        if(impl != null) {
          if(impl instanceof SVGElementImpl)
            ((SVGElementImpl)impl).setClassName(new SVGAnimatedStringImpl(((FObj)child).getProperty("class").getString()));
          ggraphic.appendChild(impl);
        }
View Full Code Here

    protected void addChild(FONode child) {
        super.addChild(child);
        if (child instanceof GraphicsCreator) {
            GraphicsCreator gc = (GraphicsCreator) child;
            SVGElement graph = gc.createGraphic();
            clippath.addElement(graph);
            //      graph.setParent(clippath);
        } else {
            // error
        }
View Full Code Here

                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);
        }
    }
View Full Code Here

                    return valueInSpecifiedUnits;
                default:
                    throw new RuntimeException("Invalid Unit");
                }
            } else {
                SVGElement elt = (SVGElement)modificationHandler.getObject(null);
                SVGOMDocument doc = (SVGOMDocument)elt.getOwnerDocument();
                UnitProcessor.Context ctx;
                ctx = new DefaultUnitProcessorContext(doc.getSVGContext(), elt);
                return UnitProcessor.svgToUserSpace(unitType,
                                                    valueInSpecifiedUnits,
                                                    elt,
View Full Code Here

TOP

Related Classes of org.w3c.dom.svg.SVGElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.