build widget to be used as "connector" bit between the vertical bar
        between siblings and their respective horizontal bars leading to the
        arrow tip
161732
def _construct_connector(self, pos):
        
        # connector symbol, either L or |- shaped.
        connectorw = None
        connector = None
        if self._tree.next_sibling_position(pos) is not None:  # |- shaped
            if self._arrow_connector_tchar is not None:
                connectorw = urwid.Text(self._arrow_connector_tchar)
        else:  # L shaped
            if self._arrow_connector_lchar is not None:
                connectorw = urwid.Text(self._arrow_connector_lchar)
        if connectorw is not None:
            att = self._arrow_connector_att or self._arrow_att
            connector = urwid.AttrMap(connectorw, att)
        return connector
1156233
function( p, dir, desired, s, best ) {
        var result, r, diff, desiredForArrow = {}, tip = {};

        // If the arrow has no wiggle room along the edge of the popup, it cannot
        // be displayed along the requested edge without it sticking out.
        if ( s.arFull[ p.dimKey ] > s.guideDims[ p.dimKey ] ) {
            return best;
        }

        desiredForArrow[ p.fst ] = desired[ p.fst ] +
            ( s.arHalf[ p.oDimKey ] + s.menuHalf[ p.oDimKey ] ) * p.offsetFactor -
            s.contentBox[ p.fst ] + ( s.clampInfo.menuSize[ p.oDimKey ] - s.contentBox[ p.oDimKey ] ) * p.arrowOffsetFactor;
        desiredForArrow[ p.snd ] = desired[ p.snd ];

        result = s.result || this._calculateFinalLocation( desiredForArrow, s.clampInfo );
        r = { x: result.left, y: result.top };

        tip[ p.fst ] = r[ p.fst ] + s.contentBox[ p.fst ] + p.tipOffset;
        tip[ p.snd ] = Math.max( result[ p.prop ] + s.guideOffset[ p.prop ] + s.arHalf[ p.dimKey ],
            Math.min( result[ p.prop ] + s.guideOffset[ p.prop ] + s.guideDims[ p.dimKey ] - s.arHalf[ p.dimKey ],
                desired[ p.snd ] ) );

        diff = Math.abs( desired.x - tip.x ) + Math.abs( desired.y - tip.y );
        if ( !best || diff < best.diff ) {
            // Convert tip offset to coordinates inside the popup
            tip[ p.snd ] -= s.arHalf[ p.dimKey ] + result[ p.prop ] + s.contentBox[ p.snd ];
            best = { dir: dir, diff: diff, result: result, posProp: p.prop, posVal: tip[ p.snd ] };
        }

        return best;
    }
1281316
def add_frame_widget(self, ref, left=1, top=1, right=20, bottom=1, width=20, height=4, direction="h", speed=1):
        

        if ref not in self.widgets:
            widget = widgets.FrameWidget(
                screen=self, ref=ref, left=left, top=top, right=right, bottom=bottom, width=width, height=height,
                direction=direction, speed=speed,
            )
            self.widgets[ref] = widget
            return self.widgets[ref]
1350121
function () {
            this.$Container.initWidget.apply(this, arguments);
            var getChild = ariaUtilsDom.getDomElementChild;
            var parentContainer = getChild(getChild(this.getDom(), 0), 0);
            this._splitPanel1 = getChild(parentContainer, 0);
            this._splitBar = getChild(parentContainer, 1);
            this._splitBarProxy = getChild(parentContainer, 2);
            this._splitPanel2 = getChild(parentContainer, 3);

            this._splitBarProxyClass = new ariaUtilsClassList(this._splitBarProxy);
            var handleBarElem = "splitBarProxy_" + this._domId;
            var cursor = this._orientation ? "n-resize" : "e-resize";
            this._draggable = new ariaUtilsDragdropDrag(handleBarElem, {
                handle : handleBarElem,
                cursor : cursor,
                proxy : null,
                constrainTo : parentContainer
            });

            this._draggable.$on({
                "dragstart" : {
                    fn : this._onDragStart,
                    scope : this
                },

                "dragend" : {
                    fn : this._onDragEnd,
                    scope : this
                }
            });

        }
294870
def create_toolbutton(parent, text=None, shortcut=None, icon=None, tip=None,
                      toggled=None, triggered=None,
                      autoraise=True, text_beside_icon=False):
    """"""
    button = QToolButton(parent)
    if text is not None:
        button.setText(text)
    if icon is not None:
        if is_text_string(icon):
            icon = get_icon(icon)
        button.setIcon(icon)
    if text is not None or tip is not None:
        button.setToolTip(text if tip is None else tip)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    button.setAutoRaise(autoraise)
    if triggered is not None:
        button.clicked.connect(triggered)
    if toggled is not None:
        button.toggled.connect(toggled)
        button.setCheckable(True)
    if shortcut is not None:
        button.setShortcut(shortcut)
    return button
1231393
function drawHoverHighlightBars(dataArray) {
		var hoverBar = parent.svgHoverRoot.selectAll('rect.highlightbar').data(dataArray);
		hoverBar.attr('x', valueX)
				.attr('width', xBar.rangeBand());
		hoverBar.enter().append('rect')
				.attr('x', valueX)
				.attr('y', 0)
				.attr('height', parent.height)
				.attr('width', xBar.rangeBand())
				.classed('highlightbar clickable', true);
		hoverBar.exit().remove();
	}
908301
function drawVerticalBars(bars) {
            // Enter + Update
            bars.enter()
              .append('rect')
                .classed('bar', true)
                .attr('x', chartWidth)
                .attr('y', ({value}) => yScale(value))
                .attr('width', xScale.bandwidth())
                .attr('height', ({value}) => chartHeight - yScale(value))
                .on('mouseover', function(d, index, barList) {
                    handleMouseOver(this, d, barList, chartWidth, chartHeight);
                })
                .on('mousemove', function(d) {
                    handleMouseMove(this, d, chartWidth, chartHeight);
                })
                .on('mouseout', function(d, index, barList) {
                    handleMouseOut(this, d, barList, chartWidth, chartHeight);
                })
                .on('click', function(d) {
                    handleClick(this, d, chartWidth, chartHeight);
                })
              .merge(bars)
                .attr('x', ({name}) => xScale(name))
                .attr('y', ({value}) => yScale(value))
                .attr('width', xScale.bandwidth())
                .attr('height', ({value}) => chartHeight - yScale(value))
                .attr('fill', ({name}) => computeColor(name));
        }
1227340
def _bar(self, serie, parent, x, y, i, zero, secondary=False):
        """"""
        if secondary:
            cumulation = (
                self.secondary_negative_cumulation
                if y < self.zero else self.secondary_positive_cumulation
            )
        else:
            cumulation = (
                self.negative_cumulation
                if y < self.zero else self.positive_cumulation
            )
        zero = cumulation[i]
        cumulation[i] = zero + y
        if zero == 0:
            zero = self.zero
            y -= self.zero
        y += zero

        width = (self.view.x(1) - self.view.x(0)) / self._len
        x, y = self.view((x, y))
        y = y or 0
        series_margin = width * self._series_margin
        x += series_margin
        width -= 2 * series_margin
        if self.secondary_series:
            width /= 2
            x += int(secondary) * width
            serie_margin = width * self._serie_margin
            x += serie_margin
            width -= 2 * serie_margin
        height = self.view.y(zero) - y
        r = serie.rounded_bars * 1 if serie.rounded_bars else 0
        self.svg.transposable_node(
            parent,
            'rect',
            x=x,
            y=y,
            rx=r,
            ry=r,
            width=width,
            height=height,
            class_='rect reactive tooltip-trigger'
        )
        return x, y, width, height
71132
def recordWidget(xparent, widget):
        
        # record a splitter
        if isinstance(widget, XSplitter):
            xwidget = ElementTree.SubElement(xparent, 'split')
            if ( widget.orientation() == Qt.Horizontal ):
                xwidget.set('orient', 'horizontal')
            else:
                xwidget.set('orient', 'vertical')
            
            xwidget.set('state', nativestring(widget.saveState().toBase64()))
            
            # record sub-widgets
            for i in range(widget.count()):
                XViewProfile.recordWidget(xwidget, widget.widget(i))
        
        # record a view panel
        elif isinstance(widget, XViewPanel):
            xwidget = ElementTree.SubElement(xparent, 'panel')
            xwidget.set('current', nativestring(widget.currentIndex()))
            xwidget.set('hideTabs', nativestring(widget.hideTabsWhenLocked()))
            for i in range(widget.count()):
                XViewProfile.recordWidget(xwidget, widget.widget(i))
        
        # record a view
        elif widget is not None:
            xwidget = ElementTree.SubElement(xparent, 'view')
            xwidget.set('name',  nativestring(widget.objectName()))
            xwidget.set('title', nativestring(widget.windowTitle()))
            xwidget.set('type',  nativestring(widget.viewTypeName()))
            xwidget.set('group', nativestring(widget.viewingGroup()))
            
            # store that this was the current widget
            if widget.isCurrent():
                xwidget.set('current', 'True')
            
            widget.saveXml(xwidget)
834109
def arrow(self, JOIN, _id):
        """"""
        r = JOIN
        for node in self.lattice.get_elements(JOIN):
            if node.left_hand_side == _id:
                r = r ^ self.lattice.el2bv[node]
        return r
451068
def add_arrow(self, x1, y1, x2, y2, **kws):
        """"""
        self.panel.add_arrow(x1, y1, x2, y2, **kws)
1138098
function drawLinearBarHighlights(context, options) {
    let {isVertical, width, length, barWidth, barOffset, barMargin,
        X, Y, ticksLength, ticksPadding} = context.barDimensions;
    let hlWidth = width * (parseFloat(options.highlightsWidth) || 0) / 100;

    if (!options.highlights || !hlWidth) return ;

    let hasLeft = options.tickSide !== 'right';
    let hasRight = options.tickSide !== 'left';
    let i = 0;
    let s = options.highlights.length;
    let tickOffset = (width - barWidth) / 2;
    let interval = options.maxValue - options.minValue;
    //noinspection JSUnresolvedFunction
    let eX = round(isVertical ? X + tickOffset : X + barMargin + barOffset);
    let eH = hlWidth;
    let eY = isVertical ? Y + length - barMargin - barOffset: Y + tickOffset;
    //noinspection JSUnresolvedFunction
    let hLeft = round((options.ticksWidth / 100 + ticksPadding) * width)
        + (hlWidth - options.ticksWidth / 100 * width);
    //noinspection JSUnresolvedFunction
    let hRight = round(barWidth + ticksPadding * width);

    context.save();

    for (; i < s; i++) {
        let entry = options.highlights[i];
        //noinspection JSUnresolvedFunction
        let eStart = ticksLength * abs(options.minValue - entry.from) /
            interval;
        //noinspection JSUnresolvedFunction
        let eW = ticksLength * abs((entry.to - entry.from) / interval);

        context.beginPath();
        context.fillStyle = entry.color;

        if (isVertical) {
            if (hasLeft)
                context.rect(eX - hLeft, eY - eStart, eH, -eW);

            if (hasRight)
                context.rect(eX + hRight, eY - eStart, eH, -eW);
        }

        else {
            if (hasLeft)
                context.rect(eX + eStart, eY - hLeft, eW, eH);

            if (hasRight)
                context.rect(eX + eStart, eY + hRight, eW, eH);
        }

        context.fill();
        context.closePath();
    }
}
75380
private void buildGui() {
		initWidget(UI_BINDER.createAndBindUi(this));
		getElement().getStyle().setPosition(Position.ABSOLUTE);
		getElement().getStyle().setTop(5, Unit.PX);
		getElement().getStyle().setLeft(5, Unit.PX);

		StopPropagationHandler preventWeirdBehaviourHandler = new StopPropagationHandler();
		addDomHandler(preventWeirdBehaviourHandler, MouseDownEvent.getType());
		addDomHandler(preventWeirdBehaviourHandler, MouseUpEvent.getType());
		addDomHandler(preventWeirdBehaviourHandler, ClickEvent.getType());
		addDomHandler(preventWeirdBehaviourHandler, DoubleClickEvent.getType());

		// Create TOP button:
		topElement.addDomHandler(new ClickHandler() {

			public void onClick(ClickEvent event) {
				Bbox bounds = mapPresenter.getViewPort().getBounds();
				double deltaY = bounds.getHeight() / 5;
				PanAnimation animation = new PanAnimation(mapPresenter.getViewPort());
				animation.panTo(0, deltaY, 300);
				event.stopPropagation();
			}
		}, ClickEvent.getType());

		// Create RIGHT button:
		rightElement.addDomHandler(new ClickHandler() {

			public void onClick(ClickEvent event) {
				Bbox bounds = mapPresenter.getViewPort().getBounds();
				double deltaX = bounds.getWidth() / 5;
				PanAnimation animation = new PanAnimation(mapPresenter.getViewPort());
				animation.panTo(deltaX, 0, 300);
				event.stopPropagation();
			}
		}, ClickEvent.getType());

		// Create BOTTOM button:
		bottomElement.addDomHandler(new ClickHandler() {

			public void onClick(ClickEvent event) {
				Bbox bounds = mapPresenter.getViewPort().getBounds();
				double deltaY = -bounds.getHeight() / 5;
				PanAnimation animation = new PanAnimation(mapPresenter.getViewPort());
				animation.panTo(0, deltaY, 300);
				event.stopPropagation();
			}
		}, ClickEvent.getType());

		// Create LEFT button:
		leftElement.addDomHandler(new ClickHandler() {

			public void onClick(ClickEvent event) {
				Bbox bounds = mapPresenter.getViewPort().getBounds();
				double deltaX = -bounds.getWidth() / 5;
				PanAnimation animation = new PanAnimation(mapPresenter.getViewPort());
				animation.panTo(deltaX, 0, 300);
				event.stopPropagation();
			}
		}, ClickEvent.getType());
	}
156110
def draw_widget(self, item):
        """"""
        if item:
            self.filter_remove(remember=True)
            selected_id = self.treedata[item]['id']
            item = self.get_toplevel_parent(item)
            widget_id = self.treedata[item]['id']
            wclass = self.treedata[item]['class']
            xmlnode = self.tree_node_to_xml('', item)
            self.previewer.draw(item, widget_id, xmlnode, wclass)
            self.previewer.show_selected(item, selected_id)
            self.filter_restore()
872124
private void buildWidget(VectorLayer layer) {
		mapModel = layer.getMapModel();

		setTitle(I18nProvider.getAttribute().getAttributeWindowTitle(""));
		setCanDragReposition(true);
		setCanDragResize(true);

		attributeTable = new FeatureAttributeEditor(layer, true, factory);

		toolStrip = new ToolStrip();
		toolStrip.setWidth100();
		toolStrip.setPadding(WidgetLayout.marginSmall);

		toolStrip.addMember(new ZoomButton());
		editButton = new EditButton();
		LayoutSpacer spacer = new LayoutSpacer();
		spacer.setWidth(2);
		toolStrip.addMember(spacer);
		if (editingAllowed) {
			toolStrip.addMember(editButton);
		}

		savePanel = new HLayout(WidgetLayout.marginSmall);
		saveButton = new SaveButton();
		IButton resetButton = new ResetButton();
		IButton cancelButton = new CancelButton();
		savePanel.addMember(saveButton);
		savePanel.addMember(resetButton);
		savePanel.addMember(cancelButton);
		savePanel.setVisible(false);
		savePanel.setAlign(Alignment.CENTER);
		savePanel.setPadding(WidgetLayout.marginSmall);

		VLayout layout = new VLayout();
		layout.addMember(toolStrip);
		layout.addMember(attributeTable);
		layout.addMember(savePanel);
		layout.setWidth(WidgetLayout.featureAttributeWindowLayoutWidth);
		addItem(layout);

		// Set the save button as disabled at startup:
		addDrawHandler(new DrawHandler() {

			public void onDraw(DrawEvent event) {
				saveButton.setDisabled(true);
			}
		});
	}
636929
def add_hbar_widget(self, ref, x=1, y=1, length=10):
        

        if ref not in self.widgets:
            widget = widgets.HBarWidget(screen=self, ref=ref, x=x, y=y, length=length)
            self.widgets[ref] = widget
            return self.widgets[ref]
1239602
function createBarEvent(ctx, type = 'mouse') {
  const parent = getRealParent(ctx);
  const moveEventName = type == 'mouse' ? 'mousemove' : 'touchmove';
  const endEventName = type == 'mouse' ? 'mouseup' : 'touchend';

  function mousedown(e) {
    e.stopImmediatePropagation();
    e.preventDefault();

    const event = type == 'mouse' ? e : e.touches[0];

    document.onselectstart = () => false;
    ctx.axisStartPos =
      event[ctx.bar.client] -
      ctx.$refs['thumb'].getBoundingClientRect()[ctx.bar.posName];

    // Tell parent that the mouse has been down.
    ctx.setBarDrag(true);
    eventCenter(document, moveEventName, mousemove);
    eventCenter(document, endEventName, mouseup);
  }

  function mousemove(e) {
    if (!ctx.axisStartPos) {
      return;
    }

    const thubmParent = ctx.$refs.thumb.parentNode;

    const event = type == 'mouse' ? e : e.touches[0];

    let delta =
      event[ctx.bar.client] -
      thubmParent.getBoundingClientRect()[ctx.bar.posName];
    delta = delta / ctx.barRatio;

    const percent = (delta - ctx.axisStartPos) / thubmParent[ctx.bar.offset];
    parent.scrollTo(
      {
        [ctx.bar.axis.toLowerCase()]:
          parent.scrollPanelElm[ctx.bar.scrollSize] * percent
      },
      false
    );
  }

  function mouseup() {
    ctx.setBarDrag(false);
    parent.hideBar();

    document.onselectstart = null;
    ctx.axisStartPos = 0;

    eventCenter(document, moveEventName, mousemove, false, 'off');
    eventCenter(document, endEventName, mouseup, false, 'off');
  }

  return mousedown;
}