/*
Adjusts the tree position due to canvas scaling or translation.
556705
function(node, scale) {
        var dim = this.node;
        var w = node.getData('width');
        var h = node.getData('height');
        var s = (this.config.multitree 
        		&& ('$orn' in node.data) 
        		&& node.data.$orn) || this.config.orientation;

        var $C = function(a, b) { 
          return function(){
            return node.pos.add(new Complex(a, b)).$scale(1 - scale);
          }; 
        };
        if(dim.align == "left") {
            return this.dispatch(s, $C(0, h), $C(0, 0),
                                 $C(0, 0), $C(w, 0));
        } else if(dim.align == "center") {
            return this.dispatch(s, $C(0, h / 2), $C(-w / 2, 0),
                                 $C(0, -h / 2),$C(w / 2, 0));
        } else if(dim.align == "right") {
            return this.dispatch(s, $C(0, 0), $C(-w, 0),
                                 $C(0, -h),$C(0, 0));
        } else throw "align: not implemented";
    }
972099
private void adjustTextViewHeight() {
        View view = getView();
        if (view == null) {
            return;
        }

        TextSwitcher textSwitcher = (TextSwitcher) view;
        TextView curr = (TextView) textSwitcher.getCurrentView();
        TextView next = (TextView) textSwitcher.getNextView();
        int currH = curr.getLineCount() * curr.getLineHeight();
        int nextH = next.getLineCount() * next.getLineHeight();
        if (currH != nextH) {
            curr.setHeight(currH);
            next.setHeight(currH);
        }
    }
896408
function(startPoint) {
            var orient = this.Tree().CONFIG.rootOrientation, point = {};

            if ( this.stackParentId ) { // return different end point if node is a stacked child
                if ( orient === 'NORTH' || orient === 'SOUTH' ) {
                    orient = 'WEST';
                }
                else if ( orient === 'EAST' || orient === 'WEST' ) {
                    orient = 'NORTH';
                }
            }

            // if pseudo, a virtual center is used
            if ( orient === 'NORTH' ) {
                point.x = (this.pseudo) ? this.X - this.Tree().CONFIG.subTeeSeparation/2 : this.X + this.width/2;
                point.y = (startPoint) ? this.Y + this.height : this.Y;
            }
            else if (orient === 'SOUTH') {
                point.x = (this.pseudo) ? this.X - this.Tree().CONFIG.subTeeSeparation/2 : this.X + this.width/2;
                point.y = (startPoint) ? this.Y : this.Y + this.height;
            }
            else if (orient === 'EAST') {
                point.x = (startPoint) ? this.X : this.X + this.width;
                point.y = (this.pseudo) ? this.Y - this.Tree().CONFIG.subTeeSeparation/2 : this.Y + this.height/2;
            }
            else if (orient === 'WEST') {
                point.x = (startPoint) ? this.X + this.width : this.X;
                point.y =  (this.pseudo) ? this.Y - this.Tree().CONFIG.subTeeSeparation/2 : this.Y + this.height/2;
            }
            return point;
        }
985171
function calculateDraggerPosition() {
    var sl = $container.scrollLeft() / scale;
    var st = $container.scrollTop() / scale;

    // sl / dox = dl / cw
    // dl = sl * cw / dox
    var left = sl * canvasSize.x / docSize.x;
    var top = st * canvasSize.y / docSize.y;
    view.setDraggerPosition(left, top);
  }
781531
function moveSinksRight(nodes, maxDepth) {
    zrUtil.each(nodes, function (node) {
        if (!isNodeDepth(node) && !node.outEdges.length) {
            node.setLayout({depth: maxDepth}, true);
        }
    });
}
1173
function () {
            var series = this,
              chart = series.chart,
              wasDirtyData = series.isDirtyData, // cache it here as it is set to false in render, but used after
              group = series.group,
              xAxis = series.xAxis,
              yAxis = series.yAxis;

            // reposition on resize
            if (group) {
                if (chart.inverted) {
                    group.attr({
                        width: chart.plotWidth,
                        height: chart.plotHeight
                    });
                }

                group.animate({
                    translateX: pick(xAxis && xAxis.left, chart.plotLeft),
                    translateY: pick(yAxis && yAxis.top, chart.plotTop)
                });
            }

            series.translate();
            if (series.setTooltipPoints) {
                series.setTooltipPoints(true);
            }
            series.render();

            if (wasDirtyData) {
                fireEvent(series, 'updatedData');
            }
        }
176981
function handleDocumentMousemove(e) {
  let svg = overlay.parentNode.querySelector('svg.annotationLayer');
  let rect = svg.getBoundingClientRect();

  if (originX + (e.clientX - originX) < rect.right) {
    overlay.style.width = `${e.clientX - originX}px`;
  }

  if (originY + (e.clientY - originY) < rect.bottom) {
    overlay.style.height = `${e.clientY - originY}px`;
  }
}
1108224
function adjustPanes(x, y, overPreview) {
    var ratio = isLeftRight ?
        (x / $outer.clientWidth) :
        ((overPreview ? y : y - 25) / ($outer.clientHeight - 25));
    var psize = overPreview ? editorSize + ratio * 100 : ratio * 100;
    if (psize >= 0) { resizeEditor(psize); }
  }
1035539
@Override
    public final Scene moveDown(final Layer layer)
    {
        if ((null != layer) && (LienzoCore.IS_CANVAS_SUPPORTED))
        {
            final int size = getElement().getChildCount();

            if (size < 2)
            {
                return this;
            }
            final DivElement element = layer.getElement();

            for (int i = 0; i < size; i++)
            {
                final DivElement look = getElement().getChild(i).cast();

                if (look == element)
                {
                    if (i == 0)
                    {
                        // already at bottom

                        break;
                    }
                    getElement().insertBefore(element, getElement().getChild(i - 1));

                    break;
                }
            }
            final NFastArrayList<Layer> layers = getChildNodes();

            if (null != layers)
            {
                layers.moveDown(layer);
            }
        }
        return this;
    }
144873
private void secondWalk(TreeNode v, double m, int level, double levelStart) {
		// construct the position from the prelim and the level information

		// The rootLocation affects the way how x and y are changed and in what
		// direction.
		double levelChangeSign = getLevelChangeSign();
		boolean levelChangeOnYAxis = isLevelChangeInYAxis();
		double levelSize = getSizeOfLevel(level);

		double x = getPrelim(v) + m;

		double y;
		AlignmentInLevel alignment = configuration.getAlignmentInLevel();
		if (alignment == AlignmentInLevel.Center) {
			y = levelStart + levelChangeSign * (levelSize / 2);
		} else if (alignment == AlignmentInLevel.TowardsRoot) {
			y = levelStart + levelChangeSign * (getNodeThickness(v) / 2);
		} else {
			y = levelStart + levelSize - levelChangeSign
					* (getNodeThickness(v) / 2);
		}

		if (!levelChangeOnYAxis) {
			double t = x;
			x = y;
			y = t;
		}

		positions.put(v, new NormalizedPosition(x, y));

		// update the bounds
		updateBounds(v, x, y);

		// recurse
		if (!tree.isLeaf(v)) {
			double nextLevelStart = levelStart
					+ (levelSize + configuration.getGapBetweenLevels(level + 1))
					* levelChangeSign;
			for (TreeNode w : tree.getChildren(v)) {
				secondWalk(w, m + getMod(v), level + 1, nextLevelStart);
			}
		}
	}
499475
def update_positions(tree, positions):
    """"""

    for step, pos in zip(tree.findall('step'), positions):
        for key in sorted(pos):
            value = pos.get(key)
            if key.endswith("-rel"):
                abs_key = key[:key.index("-rel")]
                if value is not None:
                    els = tree.findall(".//*[@id='" + value + "']")
                    for el in els :
                        pos[abs_key] = num(el.get(abs_key)) + pos.get(abs_key)
                        step.attrib[abs_key] = str(pos.get(abs_key))
            else:
                step.attrib[key] = str(pos[key])

        if 'hovercraft-path' in step.attrib:
            del step.attrib['hovercraft-path']
904248
def canvas_resize(self, scale):
        
        self._top *= scale
        self._bottom *= scale
        self._left *= scale
        self._right *= scale
        self._calibrate_to_rect()
294203
public void initalizeTreeState()
    {
        _lastNodeExpandedImage = IMAGE_NODE_EXPAND_LAST;
        _nodeExpandedImage = IMAGE_NODE_EXPAND;
        _lastNodeCollapsedImage = IMAGE_NODE_COLLAPSE_LAST;
        _nodeCollapsedImage = IMAGE_NODE_COLLAPSE;
        _lastLineJoinImage = IMAGE_LINE_JOIN_LAST;
        _lineJoinImage = IMAGE_LINE_JOIN;
        _verticalLineImage = IMAGE_LINE_VERTICAL;
        _imageSpacer = IMAGE_SPACER;
        _defaultIcon = DEFAULT_ICON;
        _imageRoot = null;

        _selectionAction = null;
        _expansionAction = null;
    }
211506
function(node) {
        // Re-adjust the offset to match the parent container
        // is() fails when checking against window
        if (container[0] !== window) {
            var conOffset = container.offset();

            left -= conOffset.left;
            top -= conOffset.top;
        }
    }
656051
function() {
            var offset = IMSoftcrop.Ratio.getElementPosition(this._canvas);

            this._position.x = offset.x;
            this._position.y = offset.y;
        }
478029
private void resize() {
        width                        = getWidth() - getInsets().getLeft() - getInsets().getRight();
        height                       = getHeight() - getInsets().getTop() - getInsets().getBottom();
        pixelSize                    = (width / cols) < (height / rows) ? (width / cols) : (height / rows);
        pixelWidth                   = (width / cols);
        pixelHeight                  = (height / rows);
        spacer                       = useSpacer ? pixelSize * getSpacerSizeFactor() : 0;
        pixelSizeMinusDoubleSpacer   = pixelSize - spacer * 2;
        pixelWidthMinusDoubleSpacer  = pixelWidth - spacer * 2;
        pixelHeightMinusDoubleSpacer = pixelHeight - spacer * 2;


        if (width > 0 && height > 0) {
            if (squarePixels) {
                pixelWidth                   = pixelSize;
                pixelHeight                  = pixelSize;
                pixelWidthMinusDoubleSpacer  = pixelSizeMinusDoubleSpacer;
                pixelHeightMinusDoubleSpacer = pixelSizeMinusDoubleSpacer;
            }
            canvas.setWidth(cols * pixelWidth);
            canvas.setHeight(rows * pixelHeight);

            canvas.relocate((getWidth() - (cols *pixelWidth)) * 0.5, (getHeight() - (rows * pixelHeight)) * 0.5);

            drawMatrix();
        }
    }
1161491
void move(AbstractTreeMap.Entry x, AbstractTreeMap.Entry y)
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "move",
                       new Object[] { x, y });

        Entry yParent = (Entry) y.getParent();

        // Set x into the position occupied by y.
        x.setParent(yParent);

        if (yParent == null)
            setRoot(x);
        else if (yParent.getRight() == y)
            yParent.setRight(x);
        else
            yParent.setLeft(x);
        x.setLeft(y.getLeft());
        x.setRight(y.getRight());

        // Set the x to be the parent of y's children.
        if (y.getLeft() != null)
            y.getLeft().setParent(x);
        if (y.getRight() != null)
            y.getRight().setParent(x);

        x.setColor(y.getColor());
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "move",
                       new Object[] { x });
    }