Package org.w3c.dom.svg

Examples of org.w3c.dom.svg.SVGElement


                    break;
                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);
                setValueInSpecifiedUnits(UnitProcessor.userSpaceToSVG(unitType,
                                                                      value,
                                                                      elt,
View Full Code Here


     * will be added.
     * @param node the <code>GraphicsNode</code>.
     */
    public static void addDOMListener(BridgeContext ctx,
                                      Element eee) {
        SVGElement element = (SVGElement)eee;
        EventTarget target = null;
        try {
            // 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;
        // <!> TODO we need to memo listeners to be able to remove
        // them later when deconnecting the bridge binding...
        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;
                        }
                    }
                    target.
                        addEventListener(EVENT_NAMES[i+FIRST_SVG_EVENT],
                                         new ScriptCaller(ctx.getUserAgent(),
                                                          script, interpret),
                                         false);
                }
            }
            // 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;
                            }
                        }
                        target.
                            addEventListener(EVENT_NAMES[i+
                                                        FIRST_ANIMATION_EVENT],
                                             new ScriptCaller(ctx.getUserAgent(),
                                                              script, interpret),
                                             false);
                    }
                }
                // 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: "+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

   * @param dstMap the dst map
   * @param srcId the src id
   * @param dstId the dst id
   */
  public static void margeMap(SVGDocument srcMap, SVGDocument dstMap, String srcId, String dstId) {
    SVGElement srcMapRoot;
    Element srcElement;
    Element dstElement;
   
    srcMapRoot = srcMap.getRootElement();
    srcElement = ( srcId == null? srcMapRoot: srcMap.getElementById(srcId) );
View Full Code Here

    NodeList nodeList = targetLayer.getChildNodes();
    for(int i = 0; i < nodeList.getLength(); i++){
      Node childNode = (Node)nodeList.item(i);
      if(childNode instanceof Element) {
        SVGElement child = (SVGElement)childNode;

        String childId = child.getId();
        String column_id = childId.replaceAll(datamart.getTargetFeatureName() + "_", "");

        IRecord record = dataStore.getRecordByID( column_id );


        //Map attributes = (Map)datamart.getAttributeseById(column_id);


        String targetColor = null;
        Number kpyValue = null;
        if(record != null) {
          IField field = record.getFieldAt( dataStoreMeta.getFieldIndex(selectedKpiName) )
          String kpyValueAttr = "" + field.getValue();
          //String kpyValueAttr = (String)attributes.get( selectedKpiName ); 
          if(kpyValueAttr == null) {
            targetColor = null_values_color;
          } else {
            kpyValue = Double.parseDouble(kpyValueAttr);

            if(kpyValue.doubleValue() < lb_value.doubleValue()) {
              targetColor = lb_color;
            } else if(kpyValue.doubleValue() > ub_value.doubleValue()) {
              targetColor = ub_color;
            } else if(kpyValue.doubleValue() == ub_value.doubleValue()) {
              targetColor = col_kpi_array[trash_kpi_array.length-2];
            } else  {
              for (int j = 0; j < trash_kpi_array.length-1; j++) {
                if (kpyValue.doubleValue() >= trash_kpi_array[j].doubleValue() && kpyValue.doubleValue() <  trash_kpi_array[j+1].doubleValue()) {
                  targetColor = col_kpi_array[j];
                  break;
                }
              }
            }
          }
        }

        if(targetColor != null) {
          if(child.getNodeName().equals("path")
              || child.getNodeName().equals("polygon")
              || child.getNodeName().equals("ellipse")
              || child.getNodeName().equals("circle")
              || child.getNodeName().equals("rect")
          ) {

            child.setAttribute("fill", targetColor );
          } else if(child.getNodeName().equals("line")
              || child.getNodeName().equals("polyline")
          ) {
            child.setAttribute("stroke", targetColor );
          }

          String opacity = measure.getColurCalculatorParameters().getProperty("opacity");
          if(opacity != null) {
            child.setAttribute("opacity", opacity );
          }


        }
View Full Code Here

    NodeList nodeList = targetLayer.getChildNodes();
    for(int i = 0; i < nodeList.getLength(); i++){
      Node childNode = (Node)nodeList.item(i);
      if(childNode instanceof Element) {
        SVGElement child = (SVGElement)childNode;
        String childId = child.getId();
        String column_id = childId.replaceAll(datamart.getTargetFeatureName() + "_", "");


        IRecord record = dataStore.getRecordByID( column_id );
        if(record == null) {
          logger.warn("No data available for feature [" + column_id +"]");
          continue;
        }
        List fields = record.getFields();
        for(int j = 0; j < fields.size(); j++) {
          if(j == dataStore.getMetaData().getIdFieldIndex() ) {
            continue;
          }
          IField field = (IField)fields.get(j);
          child.setAttribute("attrib:" + dataStore.getMetaData().getFieldName(j), "" + field.getValue());
        }
        child.setAttribute("attrib:nome", child.getAttribute("id"));

      }
    }
  }
View Full Code Here

    List lstLink = new ArrayList();
    for(int i = 0; i < nodeList.getLength(); i++){
      Node childNode= (Node)nodeList.item(i);
      try{
        if(childNode instanceof Element) {
          SVGElement childOrig =(SVGElement)childNode;         
          String childId = childOrig.getId();
          String column_id = childId.replaceAll(datamart.getTargetFeatureName() + "_", "");         

          IRecord record = dataStore.getRecordByID( column_id );
          if(record == null) {
            logger.warn("No data available for feature [" + column_id + "]");
            continue;
          }

          IField filed = record.getFieldAt( dataStoreMeta.getFieldIndex( filedMeta.getName()) );

          String link = "" + filed.getValue();

          if (link != null) {
            mapLink = new HashMap();
            mapLink.put("column_id",column_id);
            mapLink.put("path", childOrig);
            mapLink.put("link", link);             
            lstLink.add(mapLink);             
          }
        }
      }catch (Exception e){
        e.printStackTrace();
      }
    }

    //adds href links     
    for (int j=0; j<lstLink.size(); j++){ 
      Map tmpMap = (Map)lstLink.get(j);
      Element linkElement = map.createElement("a");
      String pippo = (String)tmpMap.get("link");
      linkElement.setAttribute("xlink:href", (String)tmpMap.get("link"));
      linkElement.setAttribute("target", "_parent");
      linkElement.appendChild((Element)tmpMap.get("path"));
      targetLayer.appendChild(linkElement);
      Node lf = map.createTextNode("\n");
      targetLayer.appendChild(lf);       
    }     

    //deletes duplicate path
    boolean isNew = false;
    for(int i = 0; i < nodeList.getLength(); i++){
      Node childNode= (Node)nodeList.item(i)
      SVGElement childOrig = null;
      if(childNode instanceof SVGElement) {
        try{
          childOrig = (SVGElement)childNode;
        }catch(ClassCastException e){

          logger.debug("DynamicMapRenderer :: addLinK : Element Generic", e);

        }
        String childId = "";
        String column_id = "";
        if (childOrig != null){
          childId = childOrig.getId();         
          column_id = childId.replaceAll(datamart.getTargetFeatureName() + "_", "");
        }
        Iterator it = lstLink.iterator();
        isNew = false;
        while(it.hasNext()) {
View Full Code Here

            final RasterReference rasterReference, final Double rotation,
            final Color backgroundColor, final File workingDir,
            final MfClientHttpRequestFactory clientHttpRequestFactory)
            throws IOException {
        // load SVG graphic
        final SVGElement svgRoot = parseSvg(rasterReference.inputStream);

        // create a new SVG graphic in which the existing graphic is embedded (scaled and rotated)
        DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
        Document newDocument = impl.createDocument(SVG_NS, "svg", null);
        SVGElement newSvgRoot = (SVGElement) newDocument.getDocumentElement();
        newSvgRoot.setAttributeNS(null, "width", Integer.toString(targetSize.width));
        newSvgRoot.setAttributeNS(null, "height", Integer.toString(targetSize.height));

        setSvgBackground(backgroundColor, targetSize, newDocument, newSvgRoot);
        embedSvgGraphic(svgRoot, newSvgRoot, newDocument, targetSize, rotation);
        File path = writeSvgToFile(newDocument, workingDir);
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

     * 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;
        // <!> TODO we need to memo listeners to be able to remove
        // them later when deconnecting the bridge binding...
        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;
                        }
                    }
                    target.
                        addEventListener(EVENT_NAMES[i+FIRST_SVG_EVENT],
                                         new ScriptCaller(ctx.getUserAgent(),
                                                          script, interpret),
                                         false);
                }
            }
            // 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;
                            }
                        }
                        target.
                            addEventListener(EVENT_NAMES[i+
                                                        FIRST_ANIMATION_EVENT],
                                             new ScriptCaller(ctx.getUserAgent(),
                                                              script, interpret),
                                             false);
                    }
                }
                // 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: "+language));
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.