Convert the coordinates of an DOM Event from screen into element
coordinates.

@param doc Document context
@param tag Element containing the coordinate system
@param evt Event to interpret
@return coordinates
345367
public static SVGPoint elementCoordinatesFromEvent(Document doc, Element tag, Event evt) {
    try {
      DOMMouseEvent gnme = (DOMMouseEvent) evt;
      SVGMatrix mat = ((SVGLocatable) tag).getScreenCTM();
      SVGMatrix imat = mat.inverse();
      SVGPoint cPt = ((SVGDocument) doc).getRootElement().createSVGPoint();
      cPt.setX(gnme.getClientX());
      cPt.setY(gnme.getClientY());
      return cPt.matrixTransform(imat);
    }
    catch(Exception e) {
      LoggingUtil.warning("Error getting coordinates from SVG event.", e);
      return null;
    }
  }
439451
private TagElement setTagValues(TagElement tag, TagKind tagKind, DocTree javadocNode,
      DocTree body) {
    tag.setTagKind(tagKind);
    setPos(javadocNode, tag);
    scan(body, tag);
    return tag;
  }
357899
public void go(DocListener document, InputSource is, String tagmap) {
        try {
            parser.parse(is, new SAXmyHandler(document, new TagMap(tagmap)));
        }
        catch(SAXException se) {
            throw new ExceptionConverter(se);
        }
        catch(IOException ioe) {
            throw new ExceptionConverter(ioe);
        }
    }
1319787
function(node) {
            /**
             * Three coordinate variations to consider:
             * 1) <gml:pos>x y z</gml:pos>
             * 2) <gml:coordinates>x, y, z</gml:coordinates>
             * 3) <gml:coord><gml:X>x</gml:X><gml:Y>y</gml:Y></gml:coord>
             */
            var nodeList, coordString;
            var coords = [];

            // look for <gml:pos>
            var nodeList = this.getElementsByTagNameNS(node, this.gmlns, "pos");
            if(nodeList.length > 0) {
                coordString = nodeList[0].firstChild.nodeValue;
                coordString = coordString.replace(this.regExes.trimSpace, "");
                coords = coordString.split(this.regExes.splitSpace);
            }

            // look for <gml:coordinates>
            if(coords.length == 0) {
                nodeList = this.getElementsByTagNameNS(node, this.gmlns,
                                                       "coordinates");
                if(nodeList.length > 0) {
                    coordString = nodeList[0].firstChild.nodeValue;
                    coordString = coordString.replace(this.regExes.removeSpace,
                                                      "");
                    coords = coordString.split(",");
                }
            }

            // look for <gml:coord>
            if(coords.length == 0) {
                nodeList = this.getElementsByTagNameNS(node, this.gmlns,
                                                       "coord");
                if(nodeList.length > 0) {
                    var xList = this.getElementsByTagNameNS(nodeList[0],
                                                            this.gmlns, "X");
                    var yList = this.getElementsByTagNameNS(nodeList[0],
                                                            this.gmlns, "Y");
                    if(xList.length > 0 && yList.length > 0) {
                        coords = [xList[0].firstChild.nodeValue,
                                  yList[0].firstChild.nodeValue];
                    }
                }
            }
                
            // preserve third dimension
            if(coords.length == 2) {
                coords[2] = null;
            }
            
            if (this.xy) {
                return new OpenLayers.Geometry.Point(coords[0], coords[1],
                                                 coords[2]);
            }
            else{
                return new OpenLayers.Geometry.Point(coords[1], coords[0],
                                                 coords[2]);
            }
        }
1028578
function (evt) {
            var domEventCopy = (evt.$DomEvent != null);
            // objCopy = true happens when creating a DomEventWrapper from a DomEvent object

            // initialize the object property - cf. eventMap
            if (!domEventCopy && isIE8orLess && Aria.$window.event) {

                evt = Aria.$window.event;
                // create all object properties from the map
                for (var k in eventMap) {
                    if (eventMap.hasOwnProperty(k)) {
                        this[k] = evt[eventMap[k]];
                    }
                }
                if (evt.type == "mouseout") {
                    this.relatedTarget = evt["toElement"];
                } else if (evt.type == "mouseover") {
                    this.relatedTarget = evt["fromElement"];
                }
                // TODO: convert evt.button values (not the same in IE/Safari/FF)
            } else {
                // W3C event - duplicate event values
                for (var k in eventMap) {
                    if (eventMap.hasOwnProperty(k)) {
                        this[k] = evt[k];
                    }
                }
            }

            this.type = getType(evt.type);
            // TODO keyCode / charCode should be homogenized between IE and other browsers
            // What must be implemented: (cf. http://www.quirksmode.org/js/keys.html)
            // keyCode=keyboard key code (e.g. 'A' and 'a' have the same key code: 65)
            // charCode=ASCII value of the resulting character (i.e. 'A'=65 'a'=97
            this.charCode = 0;
            this.keyCode = 0;
            if (this.type == 'keydown' || this.type == 'keyup') {
                this.keyCode = evt.keyCode;
                this.isSpecialKey = this.isSpecialKey(this.keyCode, evt);
            } else if (this.type == 'keypress') {
                // In case of a keypress event the "keycode"
                // is different from the keyup or keydown situation
                // We use keyCode OR charCode to calculate it
                var baseKeyCode = evt.keyCode || evt.charCode;

                /*
                 * We need to calculate the corresponding keycode ... On gecko browsers, charcode is usually used and
                 * has the same value as the non-gecko keycode version For special keys such as TAB, ENTER, DELETE,
                 * BACKSPACE, ARROWS, function keys ... the evt.keycode is valid, should be used, without any offset
                 * applied. So if evt.keyCode is defined on gecko browsers we have to skip applying an offset to the
                 * keycode
                 */
                var skipOffset = isGeckoBefore66 && evt.keyCode;
                this.keyCode = baseKeyCode;

                if (!skipOffset) {

                    // default
                    this.keyCode = baseKeyCode;

                    // before 32 > strange chars
                    // 32 > space, stays the same
                    if (baseKeyCode > 32 && baseKeyCode < 38) {
                        this.keyCode = baseKeyCode + 16;
                    }
                    if (baseKeyCode == 38) {
                        this.keyCode = 55;
                    }
                    if (baseKeyCode == 40) {
                        this.keyCode = 57;
                    }
                    /*
                    *  if (baseKeyCode == 39) { this.keyCode = 56; } if (baseKeyCode == 41) { this.keyCode = 48; }
                    */
                    if (baseKeyCode > 41 && baseKeyCode < 48) {
                        // / to * range
                        this.keyCode = baseKeyCode + 64;
                    }
                    if (baseKeyCode > 47 && baseKeyCode < 58) {
                        // 0 to 9 range
                        this.keyCode = baseKeyCode + 48;
                    } /*
                    * if (baseKeyCode == 58) { this.keyCode = 59; } // 59 > 59 if (baseKeyCode == 60) {
                    * this.keyCode = 188; } if (baseKeyCode == 61) { this.keyCode = 107; } if (baseKeyCode == 62) {
                    * this.keyCode = 190; } if (baseKeyCode == 62) { this.keyCode = 191; } if (baseKeyCode == 64) {
                    * this.keyCode = 50; }
                    */
                    // 65 -> 90 A - Z

                    if (baseKeyCode > 96 && baseKeyCode < 123) {
                        // 'a' to 'z' range - transform to 65-90 range
                        this.keyCode = baseKeyCode - 32;
                    }
                }
                this.charCode = baseKeyCode;

                this.isSpecialKey = this.isSpecialKey(this.keyCode, evt);
            }

            /**
             * Stop propagation for this event. Should not be modified directly (use the stopPropagation method).
             * @type Boolean
             */
            this.hasStopPropagation = false;

            /**
             * Prevent default for this event. Should not be modified directly (use the preventDefault method).
             * @type Boolean
             */
            this.hasPreventDefault = false;

            /**
             * Cancel any default action associated with the event
             * @param {Boolean} stopPropagation tells if event propagation must also be stopped - default: false
             * @method
             */
            this.preventDefault = !evt.preventDefault ? function (stopPropagation) {
                this.hasPreventDefault = true;
                evt.returnValue = false;
                if (stopPropagation === true) {
                    this.stopPropagation();
                }
            } : function (stopPropagation) {
                this.hasPreventDefault = true;
                evt.preventDefault();
                if (stopPropagation === true) {
                    this.stopPropagation();
                }
            };

            /**
             * Prevent the event from bubbling
             * @method
             */
            this.stopPropagation = !evt.stopPropagation ? function () {
                this.hasStopPropagation = true;
                evt.cancelBubble = true;
            } : function () {
                this.hasStopPropagation = true;
                evt.stopPropagation();
            };

            /**
             * Needs to be here in order to access the closure variable 'evt'
             * @private
             */
            this._dispose = function () {
                evt = null;
                this.preventDefault = null;
                this.stopPropagation = null;
            };

        }
623988
function(doc) {
        if (typeof doc == "string") { 
            doc = OpenLayers.Format.XML.prototype.read.apply(this, [doc]);
        }

        var nodes = this.getNodes(doc);
        var ways = this.getWays(doc);
        
        // Geoms will contain at least ways.length entries.
        var feat_list = new Array(ways.length);
        
        for (var i = 0; i < ways.length; i++) {
            // We know the minimal of this one ahead of time. (Could be -1
            // due to areas/polygons)
            var point_list = new Array(ways[i].nodes.length);
            
            var poly = this.isWayArea(ways[i]) ? 1 : 0; 
            for (var j = 0; j < ways[i].nodes.length; j++) {
               var node = nodes[ways[i].nodes[j]];
               
               var point = new OpenLayers.Geometry.Point(node.lon, node.lat);
               
               // Since OSM is topological, we stash the node ID internally. 
               point.osm_id = parseInt(ways[i].nodes[j]);
               point_list[j] = point;
               
               // We don't display nodes if they're used inside other 
               // elements.
               node.used = true; 
            }
            var geometry = null;
            if (poly) { 
                geometry = new OpenLayers.Geometry.Polygon(
                    new OpenLayers.Geometry.LinearRing(point_list));
            } else {    
                geometry = new OpenLayers.Geometry.LineString(point_list);
            }
            if (this.internalProjection && this.externalProjection) {
                geometry.transform(this.externalProjection, 
                    this.internalProjection);
            }        
            var feat = new OpenLayers.Feature.Vector(geometry,
                ways[i].tags);
            feat.osm_id = parseInt(ways[i].id);
            feat.fid = "way." + feat.osm_id;
            feat_list[i] = feat;
        } 
        for (var node_id in nodes) {
            var node = nodes[node_id];
            if (!node.used || this.checkTags) {
                var tags = null;
                
                if (this.checkTags) {
                    var result = this.getTags(node.node, true);
                    if (node.used && !result[1]) {
                        continue;
                    }
                    tags = result[0];
                } else { 
                    tags = this.getTags(node.node);
                }    
                
                var feat = new OpenLayers.Feature.Vector(
                    new OpenLayers.Geometry.Point(node['lon'], node['lat']),
                    tags);
                if (this.internalProjection && this.externalProjection) {
                    feat.geometry.transform(this.externalProjection, 
                        this.internalProjection);
                }        
                feat.osm_id = parseInt(node_id); 
                feat.fid = "node." + feat.osm_id;
                feat_list.push(feat);
            }   
            // Memory cleanup
            node.node = null;
        }        
        return feat_list;
    }
1228371
private ExtensionsElement readExtensions(Location location, String documentation) {
    int start = reader.readInt(); // Range start.
    int end = start;
    if (reader.peekChar() != ';') {
      if (!"to".equals(reader.readWord())) throw reader.unexpected("expected ';' or 'to'");
      String s = reader.readWord(); // Range end.
      if (s.equals("max")) {
        end = Util.MAX_TAG_VALUE;
      } else {
        end = Integer.parseInt(s);
      }
    }
    reader.require(';');
    return new ExtensionsElement(location, documentation, start, end);
  }
68042
private Vector decodeEvents(final Document document) {
    Vector events = new Vector();

    NodeList eventList = document.getElementsByTagName("record");

    for (int eventIndex = 0; eventIndex < eventList.getLength();
        eventIndex++) {
      Node eventNode = eventList.item(eventIndex);

      Logger logger = null;
    long timeStamp = 0L;
    Level level = null;
    String threadName = null;
    Object message = null;
    String ndc = null;
    String[] exception = null;
    String className = null;
    String methodName = null;
    String fileName = null;
    String lineNumber = null;
    Hashtable properties = new Hashtable();

      //format of date: 2003-05-04T11:04:52
      //ignore date or set as a property? using millis in constructor instead
      NodeList list = eventNode.getChildNodes();
      int listLength = list.getLength();

      if (listLength == 0) {
        continue;
      }

      for (int y = 0; y < listLength; y++) {
        String tagName = list.item(y).getNodeName();

        if (tagName.equalsIgnoreCase("logger")) {
          logger = Logger.getLogger(getCData(list.item(y)));
        }

        if (tagName.equalsIgnoreCase("millis")) {
          timeStamp = Long.parseLong(getCData(list.item(y)));
        }

        if (tagName.equalsIgnoreCase("level")) {
          level = UtilLoggingLevel.toLevel(getCData(list.item(y)));
        }

        if (tagName.equalsIgnoreCase("thread")) {
          threadName = getCData(list.item(y));
        }

        if (tagName.equalsIgnoreCase("sequence")) {
          properties.put("log4jid", getCData(list.item(y)));
        }

        if (tagName.equalsIgnoreCase("message")) {
          message = getCData(list.item(y));
        }

        if (tagName.equalsIgnoreCase("class")) {
          className = getCData(list.item(y));
        }

        if (tagName.equalsIgnoreCase("method")) {
          methodName = getCData(list.item(y));
        }

        if (tagName.equalsIgnoreCase("exception")) {
          ArrayList exceptionList = new ArrayList();
          NodeList exList = list.item(y).getChildNodes();
          int exlistLength = exList.getLength();

          for (int i2 = 0; i2 < exlistLength; i2++) {
            Node exNode = exList.item(i2);
            String exName = exList.item(i2).getNodeName();

            if (exName.equalsIgnoreCase("message")) {
              exceptionList.add(getCData(exList.item(i2)));
            }

            if (exName.equalsIgnoreCase("frame")) {
              NodeList exList2 = exNode.getChildNodes();
              int exlist2Length = exList2.getLength();

              for (int i3 = 0; i3 < exlist2Length; i3++) {
                exceptionList.add(getCData(exList2.item(i3)) + "\n");
              }
            }
          }
          if (exceptionList.size() > 0) {
              exception =
                (String[]) exceptionList.toArray(new String[exceptionList.size()]);
          }
        }
      }

        /**
         * We add all the additional properties to the properties
         * hashtable. Override properties that already exist
         */
        if (additionalProperties.size() > 0) {
            if (properties == null) {
                properties = new Hashtable(additionalProperties);
            }
            Iterator i = additionalProperties.entrySet().iterator();
            while (i.hasNext()) {
                Map.Entry e = (Map.Entry) i.next();
                properties.put(e.getKey(), e.getValue());
            }
        }

      LocationInfo info;
      if ((fileName != null)
              || (className != null)
              || (methodName != null)
              || (lineNumber != null)) {
          info = new LocationInfo(fileName, className, methodName, lineNumber);
      } else {
        info = LocationInfo.NA_LOCATION_INFO;
      }

        ThrowableInformation throwableInfo = null;
        if (exception != null) {
            throwableInfo = new ThrowableInformation(exception);
        }

        LoggingEvent loggingEvent = new LoggingEvent(null,
                logger, timeStamp, level, message,
                threadName,
                throwableInfo,
                ndc,
                info,
                properties);

      events.add(loggingEvent);

    }
    return events;
  }
481069
private long getLongFromDom( Document dom, String tag )
    {
        return Long.parseLong( dom.getElementsByTagName( tag ).item( 0 ).getTextContent() );
    }
726938
function sh_insertTags(tags, text) {
  var doc = document;

  var result = document.createDocumentFragment();
  var tagIndex = 0;
  var numTags = tags.length;
  var textPos = 0;
  var textLength = text.length;
  var currentNode = result;

  // output one tag or text node every iteration
  while (textPos < textLength || tagIndex < numTags) {
    var tag;
    var tagPos;
    if (tagIndex < numTags) {
      tag = tags[tagIndex];
      tagPos = tag.pos;
    }
    else {
      tagPos = textLength;
    }

    if (tagPos <= textPos) {
      // output the tag
      if (tag.node) {
        // start tag
        var newNode = tag.node;
        currentNode.appendChild(newNode);
        currentNode = newNode;
      }
      else {
        // end tag
        currentNode = currentNode.parentNode;
      }
      tagIndex++;
    }
    else {
      // output text
      currentNode.appendChild(doc.createTextNode(text.substring(textPos, tagPos)));
      textPos = tagPos;
    }
  }

  return result;
}
460805
private Tag setupDocument(final HttpServletRequest request, final Document doc) {

		final Tag head = doc.block("head");

		head.block("title").text(TITLE);
		head.empty("meta").attr(new Attr("http-equiv", "Content-Type"), new Attr("content", "text/html;charset=utf-8"));
		head.empty("meta").attr(new Name("viewport"), new Attr("content", "width=1024, user-scalable=yes"));
		head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/lib/jquery-ui-1.10.3.custom.min.css"));
		head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/main.css"));
		head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/sprites.css"));
		head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/config.css"));
		head.empty("link").attr(new Rel("icon"), new Href("favicon.ico"), new Type("image/x-icon"));
		head.block("script").attr(new Src("/structr/js/lib/jquery-3.3.1.min.js"));
		head.block("script").attr(new Src("/structr/js/icons.js"));
		head.block("script").attr(new Src("/structr/js/config.js"));

		final Tag body = doc.block("body");
		final Tag header = body.block("div").id("header");

		header.block("i").css("logo sprite sprite-structr-logo");
		final Tag links = header.block("div").id("menu").css("menu").block("ul");

		if (isAuthenticated(request)) {

			final Tag form = links.block("li").block("form").attr(new Attr("action", ConfigUrl), new Attr("method", "post"), new Style("display: none")).id("logout-form");

			form.empty("input").attr(new Type("hidden"), new Name("action"), new Value("logout"));
			links.block("a").text("Logout").attr(new Style("cursor: pointer"), new OnClick("$('#logout-form').submit();"));
		}

		return body;
	}
1286366
function joinTag(editor, node, syntax) {
	// Remove everything between the end of opening tag and the end of closing tag
	const open = getText(editor, node.open);
	const m = open.match(/\s*>$/);
	const start = node.open.end.translate([0, m ? -m[0].length : 0]);
	editor.setTextInBufferRange(new Range(start, node.end),
		selfClosingStyle[syntax] || selfClosingStyle.xhtml);
}
752172
public static String convertDOMToXML(Node doc)
    {
        StringWriter out = new StringWriter();
        Util.convertDOMToXML(doc, out);
        return out.toString();
    }
880954
function( doc, text, textFormat ){
		   var node = modules.domUtils.createNodeWithText( 'div', text );
		   return this.parse( doc, node, textFormat );
		}
1275795
function(doc) {
        var node_list = doc.getElementsByTagName("node");
        var nodes = {};
        for (var i = 0; i < node_list.length; i++) {
            var node = node_list[i];
            var id = node.getAttribute("id");
            nodes[id] = {
                'lat': node.getAttribute("lat"),
                'lon': node.getAttribute("lon"),
                'node': node
            };
        }
        return nodes;
    }
261029
function(evt) {
        var pos = OpenLayers.Util.pagePosition(this.map.viewPortDiv);
        evt.xy.x -= pos[0];
        evt.xy.y -= pos[1];
    }
1352290
function(doc, node, textFormat){
			var out;
			this.textFormat = (textFormat)? textFormat : this.textFormat;
			if(this.textFormat === 'normalised'){
				out = this.walkTreeForText( node );
				if(out !== undefined){
					return this.normalise( doc, out );
				}else{
					return '';
				}
			}else{
				var clonedNode = modules.domUtils.clone(node);
				var trimmedNode = modules.domUtils.removeDescendantsByTagName( clonedNode, this.excludeTags );

			   return this.formatText( doc, modules.domUtils.textContent(trimmedNode), this.textFormat );
			}
		}