/*
Convert the clipPath child element to a path. Transformed if need be, and clipped also if it has its own clippath.
197462
@TargetApi(Build.VERSION_CODES.KITKAT)
   private Path objectToPath(SvgElement obj, boolean allowUse)
   {
      // Save style state
      stateStack.push(state);
      state = new RendererState(state);

      updateStyleForElement(state, obj);

      if (!display() || !visible()) {
         state = stateStack.pop();
         return null;
      }

      Path  path = null;

      if (obj instanceof SVG.Use)
      {
         if (!allowUse) {
            error("<use> elements inside a <clipPath> cannot reference another <use>");
         }

         // Locate the referenced object
         SVG.Use  useElement = (SVG.Use) obj;
         SVG.SvgObject  ref = obj.document.resolveIRI(useElement.href);
         if (ref == null) {
            error("Use reference '%s' not found", useElement.href);
            state = stateStack.pop();
            return null;
         }
         if (!(ref instanceof SvgElement)) {
            state = stateStack.pop();
            return null;
         }

         path = objectToPath((SvgElement) ref, false);
         if (path == null)
            return null;

         if (useElement.boundingBox == null) {
            useElement.boundingBox = calculatePathBounds(path);
         }

         if (useElement.transform != null)
            path.transform(useElement.transform);
      }
      else if (obj instanceof SVG.GraphicsElement)
      {
         SVG.GraphicsElement  elem = (SVG.GraphicsElement) obj;

         if (obj instanceof SVG.Path)
         {
            SVG.Path  pathElem = (SVG.Path) obj;
            path = (new PathConverter(pathElem.d)).getPath();
            if (obj.boundingBox == null)
               obj.boundingBox = calculatePathBounds(path);
         }
         else if (obj instanceof SVG.Rect)
            path = makePathAndBoundingBox((SVG.Rect) obj);
         else if (obj instanceof SVG.Circle)
            path = makePathAndBoundingBox((SVG.Circle) obj);
         else if (obj instanceof SVG.Ellipse)
            path = makePathAndBoundingBox((SVG.Ellipse) obj);
         else if (obj instanceof SVG.PolyLine)
            path = makePathAndBoundingBox((SVG.PolyLine) obj);

         if (path == null)
            return null;

         if (elem.boundingBox == null) {
            elem.boundingBox = calculatePathBounds(path);
         }

         if (elem.transform != null)
            path.transform(elem.transform);

         path.setFillType(getClipRuleFromState());
      }
      else if (obj instanceof SVG.Text)
      {
         SVG.Text  textElem = (SVG.Text) obj;
         path = makePathAndBoundingBox(textElem);

         if (path == null)
            return null;

         if (textElem.transform != null)
            path.transform(textElem.transform);

         path.setFillType(getClipRuleFromState());
      }
      else {
         error("Invalid %s element found in clipPath definition", obj.getNodeName());
         return null;
      }

      // Does the clippath child element also have a clippath?
      if (state.style.clipPath != null)
      {
         Path  childsClipPath = calculateClipPath(obj, obj.boundingBox);
         if (childsClipPath != null)
            path.op(childsClipPath, Path.Op.INTERSECT);
      }

      // Restore style state
      state = stateStack.pop();

      return path;
   }
869185
function normalizePath(path)
{
    if (path.indexOf("..") === -1 && path.indexOf('.') === -1)
        return path;

    var normalizedSegments = [];
    var segments = path.split("/");
    for (var i = 0; i < segments.length; i++) {
        var segment = segments[i];
        if (segment === ".")
            continue;
        else if (segment === "..")
            normalizedSegments.pop();
        else if (segment)
            normalizedSegments.push(segment);
    }
    var normalizedPath = normalizedSegments.join("/");
    if (normalizedPath[normalizedPath.length - 1] === "/")
        return normalizedPath;
    if (path[0] === "/" && normalizedPath)
        normalizedPath = "/" + normalizedPath;
    if ((path[path.length - 1] === "/") || (segments[segments.length - 1] === ".") || (segments[segments.length - 1] === ".."))
        normalizedPath = normalizedPath + "/";

    return normalizedPath;
}
338831
function fullPath(el){
  var names = [];
  while (el.parentNode){
    if (el.id){
      names.unshift('#'+el.id);
      break;
    }else{
      if (el==el.ownerDocument.documentElement) names.unshift(el.tagName);
      else{
        for (var c=1,e=el;e.previousElementSibling;e=e.previousElementSibling,c++);
        names.unshift(el.tagName+":nth-child("+c+")");
      }
      el=el.parentNode;
    }
  }
  return names.join(" > ");
}
640690
function (from, to) {
            var toFile = xpfile(to);
            return xpfile(from).moveTo(toFile.parent, toFile.leafName);
        }
317875
function(tree, alsoRemovecoplanarFront) {
            alsoRemovecoplanarFront = alsoRemovecoplanarFront ? true : false;
            this.rootnode.clipTo(tree, alsoRemovecoplanarFront);
        }
1029681
function (clipRect) {
		var wrapper = this,
			clipMembers,
			cssRet;

		if (clipRect) {
			clipMembers = clipRect.members;
			erase(clipMembers, wrapper); // Ensure unique list of elements (#1258)
			clipMembers.push(wrapper);
			wrapper.destroyClip = function () {
				erase(clipMembers, wrapper);
			};
			cssRet = clipRect.getCSS(wrapper);

		} else {
			if (wrapper.destroyClip) {
				wrapper.destroyClip();
			}
			cssRet = { clip: docMode8 ? 'inherit' : 'rect(auto)' }; // #1214
		}

		return wrapper.css(cssRet);

	}
511081
function getNodePath(node) {
    var nodePaths = [];
    var nodeParent = node;
    while (nodeParent) {
        switch (nodeParent.nodeType) {
            case NodeType.ELEM:
                nodePaths.unshift(nodeParent.tagName);
                break;

            case NodeType.IF:
                nodePaths.unshift('if');
                break;

            case NodeType.FOR:
                nodePaths.unshift('for[' + nodeParent.anode.directives['for'].raw + ']'); // eslint-disable-line dot-notation
                break;

            case NodeType.SLOT:
                nodePaths.unshift('slot[' + (nodeParent.name || 'default') + ']');
                break;

            case NodeType.TPL:
                nodePaths.unshift('template');
                break;

            case NodeType.CMPT:
                nodePaths.unshift('component[' + (nodeParent.subTag || 'root') + ']');
                break;

            case NodeType.TEXT:
                nodePaths.unshift('text');
                break;
        }

        nodeParent = nodeParent.parent;
    }

    return nodePaths;
}
1308468
def get_rendered_transform_path_relative(self, relative_transform_ref):
        
        path = self.transform_path
        parent = self.parent

        while parent is not None and parent is not relative_transform_ref:
            path = "{0}/{1}".format(parent.transform_path, path)
            parent = parent.parent

        return path
1033534
function (document, path) {
		  	var node = document.documentElement,
		  		i = 0,
		  		index;
		  while ((index = path[++i]) > -1){
			  node = node.childNodes[index];
		  }
		  return node;
		}
384556
def convert_clip(node, **kwargs):
    
    name, input_nodes, attrs = get_inputs(node, kwargs)

    a_min = np.float(attrs.get('a_min', -np.inf))
    a_max = np.float(attrs.get('a_max', np.inf))

    clip_node = onnx.helper.make_node(
        "Clip",
        input_nodes,
        [name],
        name=name,
        min=a_min,
        max=a_max
    )
    return [clip_node]
1060017
function prunning(node, clipRect, viewAbovePath, viewRoot, depth) {
    var nodeLayout = node.getLayout();
    var nodeInViewAbovePath = viewAbovePath[depth];
    var isAboveViewRoot = nodeInViewAbovePath && nodeInViewAbovePath === node;

    if (
        (nodeInViewAbovePath && !isAboveViewRoot)
        || (depth === viewAbovePath.length && node !== viewRoot)
    ) {
        return;
    }

    node.setLayout({
        // isInView means: viewRoot sub tree + viewAbovePath
        isInView: true,
        // invisible only means: outside view clip so that the node can not
        // see but still layout for animation preparation but not render.
        invisible: !isAboveViewRoot && !clipRect.intersect(nodeLayout),
        isAboveViewRoot: isAboveViewRoot
    }, true);

    // Transform to child coordinate.
    var childClipRect = new BoundingRect(
        clipRect.x - nodeLayout.x,
        clipRect.y - nodeLayout.y,
        clipRect.width,
        clipRect.height
    );

    each(node.viewChildren || [], function (child) {
        prunning(child, childClipRect, viewAbovePath, viewRoot, depth + 1);
    });
}
758899
private ElementUI parentFromPath(String path) throws Exception {
        if (TOOLBAR_PATH.equalsIgnoreCase(path)) {
            return getDesktop().getToolbar();
        }
        
        String[] pieces = path.split(delim, 2);
        ElementTabPane tabPane = pieces.length == 0 ? null : findTabPane(pieces[0]);
        ElementUI parent = pieces.length < 2 ? null : getPathResolver().resolvePath(tabPane, pieces[1]);
        return parent == null ? tabPane : parent;
    }
936289
def _nav_to_tree(root):
    
    def expath(e, x):
        return e.xpath(x, namespaces=HTML_DOCUMENT_NAMESPACES)
    for li in expath(root, 'xhtml:ol/xhtml:li'):
        is_subtree = bool([e for e in li.getchildren()
                           if e.tag[e.tag.find('}')+1:] == 'ol'])
        if is_subtree:
            # It's a sub-tree and have a 'span' and 'ol'.
            itemid = li.get('cnx-archive-uri', 'subcol')
            shortid = li.get('cnx-archive-shortid')
            yield {'id': itemid,
                   # Title is wrapped in a span, div or some other element...
                   'title': squash_xml_to_text(expath(li, '*')[0],
                                               remove_namespaces=True),
                   'shortId': shortid,
                   'contents': [x for x in _nav_to_tree(li)],
                   }
        else:
            # It's a node and should only have an li.
            a = li.xpath('xhtml:a', namespaces=HTML_DOCUMENT_NAMESPACES)[0]
            yield {'id': a.get('href'),
                   'shortid': li.get('cnx-archive-shortid'),
                   'title': squash_xml_to_text(a, remove_namespaces=True)}
798104
function getDOMPath(node, dontGoUpTheDom /* = false */ ) {
		var path = [],
			entry = '';

		if (node === window) {
			return 'window';
		}

		while (node instanceof Node) {
			// div
			entry = node.nodeName.toLowerCase();

			// shorten the path a bit
			if (['body', 'head', 'html'].indexOf(entry) > -1) {
				path.push(entry);
				break;
			}

			if (node instanceof DocumentFragment) {
				entry = 'DocumentFragment';
			}

			// div#foo
			if (node.id && node.id !== '') {
				entry += '#' + node.id;
			}
			// div#foo.bar.test
			else if (typeof node.className === 'string' && node.className !== '') {
				entry += '.' + node.className.trim().replace(/\s+/g, '.');
			}
			// div[0] <- index of child node
			else if (node.parentNode instanceof Node) {
				entry += '[' + Math.max(0, Array.prototype.indexOf.call(node.parentNode.children || node.parentNode.childNodes, node)) + ']';
			}

			path.push(entry);

			if (dontGoUpTheDom === true) {
				break;
			}

			// go up the DOM
			node = node && node.parentNode;
		}

		return (path.length > 0) ? path.reverse().join(' > ') : false;
	}
36588
protected void definePath(ZoomableGraphicsContext gc, T element) {
		gc.beginPath();
		final PathIterator2afp<PathElement2d> pathIterator = element.toPath2D().getPathIterator();
		switch (pathIterator.getWindingRule()) {
		case EVEN_ODD:
			gc.setFillRule(FillRule.EVEN_ODD);
			break;
		case NON_ZERO:
			gc.setFillRule(FillRule.NON_ZERO);
			break;
		default:
			throw new IllegalStateException();
		}
		while (pathIterator.hasNext()) {
			final PathElement2d pelement = pathIterator.next();
			switch (pelement.getType()) {
			case LINE_TO:
				gc.lineTo(pelement.getToX(), pelement.getToY());
				break;
			case MOVE_TO:
				gc.moveTo(pelement.getToX(), pelement.getToY());
				break;
			case CLOSE:
				gc.closePath();
				break;
			case CURVE_TO:
				gc.bezierCurveTo(
						pelement.getCtrlX1(), pelement.getCtrlY1(),
						pelement.getCtrlX2(), pelement.getCtrlY2(),
						pelement.getToX(), pelement.getToY());
				break;
			case QUAD_TO:
				gc.quadraticCurveTo(
						pelement.getCtrlX1(), pelement.getCtrlY1(),
						pelement.getToX(), pelement.getToY());
				break;
			case ARC_TO:
				//TODO: implements arcTo
				gc.lineTo(pelement.getToX(), pelement.getToY());
				break;
			default:
				break;
			}
		}
	}
605981
private String getSubPath(String[] pathElements, int begin) {

        String result = "";
        for (int i = begin; i < pathElements.length; i++) {
            result += pathElements[i] + "/";
        }
        if (result.length() > 0) {
            result = result.substring(0, result.length() - 1);
        }
        return result;
    }
422667
def copy_path(self, fnames=None, method="absolute"):
        """"""
        cb = QApplication.clipboard()
        explorer_dir = self.fsmodel.rootPath()
        if fnames is None:
            fnames = self.get_selected_filenames()
        if not isinstance(fnames, (tuple, list)):
            fnames = [fnames]
        fnames = [_fn.replace(os.sep, "/") for _fn in fnames]
        if len(fnames) > 1:
            if method == "absolute":
                clipboard_files = ',\n'.join('"' + _fn + '"' for _fn in fnames)
            elif method == "relative":
                clipboard_files = ',\n'.join('"' +
                                             osp.relpath(_fn, explorer_dir).
                                             replace(os.sep, "/") + '"'
                                             for _fn in fnames)
        else:
            if method == "absolute":
                clipboard_files = fnames[0]
            elif method == "relative":
                clipboard_files = (osp.relpath(fnames[0], explorer_dir).
                                   replace(os.sep, "/"))
        copied_from = self.parent_widget.__class__.__name__
        if copied_from == 'ProjectExplorerWidget' and method == 'relative':
            clipboard_files = [path.strip(',"') for path in
                               clipboard_files.splitlines()]
            clipboard_files = ['/'.join(path.strip('/').split('/')[1:]) for
                               path in clipboard_files]
            if len(clipboard_files) > 1:
                clipboard_files = ',\n'.join('"' + _fn + '"' for _fn in
                                             clipboard_files)
            else:
                clipboard_files = clipboard_files[0]
        cb.setText(clipboard_files, mode=cb.Clipboard)