/*
Method: layoutRow

Performs the layout of an array of nodes.

Parameters:

ch - An array of nodes.
w - A fixed dimension where nodes will be laid out.
coord - A coordinates object specifying width, height, left and top style properties.
14012
function(ch, w, coord, prop) {
     if(this.layout.horizontal()) {
       return this.layoutH(ch, w, coord, prop);
     } else {
       return this.layoutV(ch, w, coord, prop);
     }
    }
179420
private void addAntiPatternExamples() {
		add(new WHeading(HeadingLevel.H2, "WLabel anti-patterns"));
		add(new ExplanatoryText("These are here for testing purposes and must not be used as examples to follow.\n"
						+ "Turn on debugging (bordertech.wcomponents.debug.enabled=true) to get much more information."));
		add(new WHeading(HeadingLevel.H3, "Poor but not erroneous uses of WLabel"));
		WPanel errorLayoutPanel = new WPanel();
		errorLayoutPanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.LARGE));
		add(errorLayoutPanel);
		//label not for anything should not be a WLabel
		errorLayoutPanel.add(new WLabel("I am not 'for' anything"));
		//WLabel for something which is not labellable
		errorLayoutPanel.add(new WLabel("I am for a component which should not be labelled", errorLayoutPanel));
		// If the WLabel is 'for' something that is not in the tree it becomes 'for' the WApplication. This is not necessarily a good thing!!!
		WCheckBox notHere = new WCheckBox();
		errorLayoutPanel.add(new WLabel("My component wasn't added", notHere));

		/*
		 * The examples which follow MUST NEVER BE USED! They cause ERRORS.
		 * They are here purely for framework testing.
		 */
		add(new WHeading(HeadingLevel.H3, "Very bad uses of WLabel"));
		errorLayoutPanel = new WPanel();
		errorLayoutPanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.LARGE));
		add(errorLayoutPanel);

		/*
		 * Nested WLabels: very bad
		 */
		errorLayoutPanel.add(new ExplanatoryText(
				"This example shows nested WLabels. This is a contravention of the HTML specification."));

		WPanel nestingErrorPanel = new WPanel();
		nestingErrorPanel.setLayout(new ColumnLayout(new int[]{50, 50}, Size.LARGE, Size.MEDIUM));
		errorLayoutPanel.add(nestingErrorPanel);
		WTextField outerField = new WTextField();
		WLabel outerLabel = new WLabel("I am an outer label", outerField);
		nestingErrorPanel.add(outerLabel);

		WTextField innerField = new WTextField();
		WLabel innerLabel = new WLabel("Inner label", innerField);
		//add the inner label to the outer label: this is the ERROR
		outerLabel.add(innerLabel);
		nestingErrorPanel.add(innerField);
		nestingErrorPanel.add(outerField);

		/*
		 * It is permissible to place certain simple form control components into
		 * a WLabel under the following conditions:
		 * there must be no more than one such component in the WLabel;
		 * the component MUST be one which outputs a simple HTML form control
		 * (and I am not going to tell you which they are);
		 * The WLabel must be 'for' the nested component or not 'for' anything.
		 */
		errorLayoutPanel.add(new ExplanatoryText("This example shows a WLabel with a nested simple form control WTextField but the WLabel is not "
				+ "'for' the WTextField. This is a contravention of the HTML specification."));

		WTextField notMyField = new WTextField();
		notMyField.setToolTip("This field should not be in the label it is in");

		WTextField myField = new WTextField();
		WLabel myFieldLabel = new WLabel("I am not the label for my nested text field", myField);
		nestingErrorPanel = new WPanel();
		nestingErrorPanel.setLayout(new ColumnLayout(new int[]{50, 50}, 12, 6));
		errorLayoutPanel.add(nestingErrorPanel);
		nestingErrorPanel.add(myFieldLabel);
		nestingErrorPanel.add(myField);

		//adding the 'wrong' WTextField to a WLabel is what causes this error
		myFieldLabel.add(notMyField);

		add(new ExplanatoryText("The next field has a label explicitly set to only white space."));
		WTextField emptyLabelTextField = new WTextField();
		WLabel emptyLabel = new WLabel(" ", emptyLabelTextField);
		add(emptyLabel);
		add(emptyLabelTextField);

		add(new WHeading(HeadingLevel.H2, "Unlabelled controls"));
		add(new ExplanatoryText("These controls must be labelled but are not."));
		WFieldLayout fieldsFlat = new WFieldLayout();
		add(fieldsFlat);
		fieldsFlat.addField((WLabel) null, new WTextField());
		fieldsFlat.addField((WLabel) null, new WTextArea());
		fieldsFlat.addField((WLabel) null, new WDateField());
		fieldsFlat.addField((WLabel) null, new WCheckBox());
		fieldsFlat.addField((WLabel) null, new WCheckBoxSelect(
				new String[]{"Apple", "Cherry", "Orange", "Pineapple"}));
	}
722179
function (cb, data, layout) {
            var self = this;

            Y.prepare([DEFAULT_THEME, themeDir], self.getProjectMeta(), function (err, opts) {
                if (err) {
                    console.log(err);
                }
                if (!data.name) {
                    return;
                }

                opts.meta = Y.merge(opts.meta, data);

                opts.meta.title = self.data.project.name;
                opts.meta.moduleName = data.name;
                opts.meta.projectRoot = '../';
                opts.meta.projectAssets = '../assets';
                opts.meta.projectLogo = self._resolveUrl(self.data.project.logo, opts);

                opts = self.populateClasses(opts);
                opts = self.populateModules(opts);
                opts = self.populateFiles(opts);

                opts.meta.fileName = data.name;
                fs.readFile(opts.meta.fileName, Y.charset, Y.rbind(function (err, str, opts, data) {
                    if (err) {
                        Y.log(err, 'error', 'builder');
                        cb(err);
                        return;
                    }

                    if (typeof self.options.tabspace === 'string') {
                        str = str.replace(/\t/g, self.options.tabspace);
                    }

                    opts.meta.fileData = str;
                    var view = new Y.DocView(opts.meta, 'index');
                    var mainLayout = opts.layouts[layout];
                    self.render('{{>files}}', view, mainLayout, opts.partials, function (err, html) {
                        self.files++;
                        cb(html, view, data);
                    });

                }, this, opts, data));
            });

        }
900070
def circular_layout(nodes):
    
    N = len(nodes)
    if not N:
        return ([], [], [])
    circ = np.pi/N*np.arange(N)*2
    x = np.cos(circ)
    y = np.sin(circ)
    return (x, y, nodes)
1305909
public void layout(float layoutX, float layoutY, float layoutWidth, float layoutHeight) {
        if (sizeInvalid)
            computeSize();

        float hpadding = w(padLeft) + w(padRight);
        float vpadding = h(padTop) + h(padBottom);

        float totalExpandWidth = 0, totalExpandHeight = 0;
        for (int i = 0; i < columns; i++)
            totalExpandWidth += expandWidth[i];
        for (int i = 0; i < rows; i++)
            totalExpandHeight += expandHeight[i];

        // Size columns and rows between min and pref size using (preferred -
        // min) size to weight distribution of extra space.
        float[] localColumnWeightedWidth;
        float totalGrowWidth = tablePrefWidth - tableMinWidth;
        if (totalGrowWidth == 0)
            localColumnWeightedWidth = columnMinWidth;
        else {
            float extraWidth = Math.min(totalGrowWidth, Math.max(0, layoutWidth - tableMinWidth));
            localColumnWeightedWidth = this.columnWeightedWidth = ensureSize(this.columnWeightedWidth, columns);
            for (int i = 0; i < columns; i++) {
                float growWidth = columnPrefWidth[i] - columnMinWidth[i];
                float growRatio = growWidth / (float) totalGrowWidth;
                localColumnWeightedWidth[i] = columnMinWidth[i] + extraWidth * growRatio;
            }
        }

        float[] localRowWeightedHeight;
        float totalGrowHeight = tablePrefHeight - tableMinHeight;
        if (totalGrowHeight == 0)
            localRowWeightedHeight = rowMinHeight;
        else {
            localRowWeightedHeight = this.rowWeightedHeight = ensureSize(this.rowWeightedHeight, rows);
            float extraHeight = Math.min(totalGrowHeight, Math.max(0, layoutHeight - tableMinHeight));
            for (int i = 0; i < rows; i++) {
                float growHeight = rowPrefHeight[i] - rowMinHeight[i];
                float growRatio = growHeight / (float) totalGrowHeight;
                localRowWeightedHeight[i] = rowMinHeight[i] + extraHeight * growRatio;
            }
        }

        // Determine widget and cell sizes (before expand or fill).
        for (int i = 0, n = cells.size(); i < n; i++) {
            Cell<C, T> c = cells.get(i);
            if (c.ignore)
                continue;

            float spannedWeightedWidth = 0;
            for (int column = c.column, nn = column + c.colspan; column < nn; column++)
                spannedWeightedWidth += localColumnWeightedWidth[column];
            float weightedHeight = localRowWeightedHeight[c.row];

            float prefWidth = w(c.prefWidth, c);
            float prefHeight = h(c.prefHeight, c);
            float minWidth = w(c.minWidth, c);
            float minHeight = h(c.minHeight, c);
            float maxWidth = w(c.maxWidth, c);
            float maxHeight = h(c.maxHeight, c);
            if (prefWidth < minWidth)
                prefWidth = minWidth;
            if (prefHeight < minHeight)
                prefHeight = minHeight;
            if (maxWidth > 0 && prefWidth > maxWidth)
                prefWidth = maxWidth;
            if (maxHeight > 0 && prefHeight > maxHeight)
                prefHeight = maxHeight;

            c.widgetWidth = Math.min(spannedWeightedWidth - c.computedPadLeft - c.computedPadRight, prefWidth);
            c.widgetHeight = Math.min(weightedHeight - c.computedPadTop - c.computedPadBottom, prefHeight);

            if (c.colspan == 1)
                columnWidth[c.column] = Math.max(columnWidth[c.column], spannedWeightedWidth);
            rowHeight[c.row] = Math.max(rowHeight[c.row], weightedHeight);
        }

        // Distribute remaining space to any expanding columns/rows.
        if (totalExpandWidth > 0) {
            float extra = layoutWidth - hpadding;
            for (int i = 0; i < columns; i++)
                extra -= columnWidth[i];
            float used = 0;
            int lastIndex = 0;
            for (int i = 0; i < columns; i++) {
                if (expandWidth[i] == 0)
                    continue;
                float amount = extra * expandWidth[i] / totalExpandWidth;
                columnWidth[i] += amount;
                used += amount;
                lastIndex = i;
            }
            columnWidth[lastIndex] += extra - used;
        }
        if (totalExpandHeight > 0) {
            float extra = layoutHeight - vpadding;
            for (int i = 0; i < rows; i++)
                extra -= rowHeight[i];
            float used = 0;
            int lastIndex = 0;
            for (int i = 0; i < rows; i++) {
                if (expandHeight[i] == 0)
                    continue;
                float amount = extra * expandHeight[i] / totalExpandHeight;
                rowHeight[i] += amount;
                used += amount;
                lastIndex = i;
            }
            rowHeight[lastIndex] += extra - used;
        }

        // Distribute any additional width added by colspanned cells to the
        // columns spanned.
        for (int i = 0, n = cells.size(); i < n; i++) {
            Cell<C, T> c = cells.get(i);
            if (c.ignore)
                continue;
            if (c.colspan == 1)
                continue;

            float extraWidth = 0;
            for (int column = c.column, nn = column + c.colspan; column < nn; column++)
                extraWidth += localColumnWeightedWidth[column] - columnWidth[column];
            extraWidth -= Math.max(0, c.computedPadLeft + c.computedPadRight);

            extraWidth /= c.colspan;
            if (extraWidth > 0) {
                for (int column = c.column, nn = column + c.colspan; column < nn; column++)
                    columnWidth[column] += extraWidth;
            }
        }

        // Determine table size.
        float tableWidth = hpadding, tableHeight = vpadding;
        for (int i = 0; i < columns; i++)
            tableWidth += columnWidth[i];
        for (int i = 0; i < rows; i++)
            tableHeight += rowHeight[i];

        // Position table within the container.
        float x = layoutX + w(padLeft);
        if ((align & RIGHT) != 0)
            x += layoutWidth - tableWidth;
        else if ((align & LEFT) == 0) // Center
            x += (layoutWidth - tableWidth) / 2;

        float y = layoutY + w(padTop);
        if ((align & BOTTOM) != 0)
            y += layoutHeight - tableHeight;
        else if ((align & TOP) == 0) // Center
            y += (layoutHeight - tableHeight) / 2;

        // Position widgets within cells.
        float currentX = x, currentY = y;
        for (int i = 0, n = cells.size(); i < n; i++) {
            Cell<C, T> c = cells.get(i);
            if (c.ignore)
                continue;

            float spannedCellWidth = 0;
            for (int column = c.column, nn = column + c.colspan; column < nn; column++)
                spannedCellWidth += columnWidth[column];
            spannedCellWidth -= c.computedPadLeft + c.computedPadRight;

            currentX += c.computedPadLeft;

            if (c.fillX > 0) {
                c.widgetWidth = spannedCellWidth * c.fillX;
                float maxWidth = w(c.maxWidth, c);
                if (maxWidth > 0)
                    c.widgetWidth = Math.min(c.widgetWidth, maxWidth);
            }
            if (c.fillY > 0) {
                c.widgetHeight = rowHeight[c.row] * c.fillY - c.computedPadTop - c.computedPadBottom;
                float maxHeight = h(c.maxHeight, c);
                if (maxHeight > 0)
                    c.widgetHeight = Math.min(c.widgetHeight, maxHeight);
            }

            if ((c.align & LEFT) != 0)
                c.widgetX = currentX;
            else if ((c.align & RIGHT) != 0)
                c.widgetX = currentX + spannedCellWidth - c.widgetWidth;
            else
                c.widgetX = currentX + (spannedCellWidth - c.widgetWidth) / 2;

            if ((c.align & TOP) != 0)
                c.widgetY = currentY + c.computedPadTop;
            else if ((c.align & BOTTOM) != 0)
                c.widgetY = currentY + rowHeight[c.row] - c.widgetHeight - c.computedPadBottom;
            else
                c.widgetY = currentY + (rowHeight[c.row] - c.widgetHeight + c.computedPadTop - c.computedPadBottom) / 2;

            if (c.endRow) {
                currentX = x;
                currentY += rowHeight[c.row];
            } else
                currentX += spannedCellWidth + c.computedPadRight;
        }

        // Draw debug widgets and bounds.
        if (debug == Debug.none)
            return;
        toolkit.clearDebugRectangles(this);
        currentX = x;
        currentY = y;
        if (debug == Debug.table || debug == Debug.all) {
            toolkit.addDebugRectangle(this, Debug.table, layoutX, layoutY, layoutWidth, layoutHeight);
            toolkit.addDebugRectangle(this, Debug.table, x, y, tableWidth - hpadding, tableHeight - vpadding);
        }
        for (int i = 0, n = cells.size(); i < n; i++) {
            Cell<C, T> c = cells.get(i);
            if (c.ignore)
                continue;

            // Widget bounds.
            if (debug == Debug.widget || debug == Debug.all)
                toolkit.addDebugRectangle(this, Debug.widget, c.widgetX, c.widgetY, c.widgetWidth, c.widgetHeight);

            // Cell bounds.
            float spannedCellWidth = 0;
            for (int column = c.column, nn = column + c.colspan; column < nn; column++)
                spannedCellWidth += columnWidth[column];
            spannedCellWidth -= c.computedPadLeft + c.computedPadRight;
            currentX += c.computedPadLeft;
            if (debug == Debug.cell || debug == Debug.all) {
                toolkit.addDebugRectangle(this, Debug.cell, currentX, currentY + c.computedPadTop, spannedCellWidth, rowHeight[c.row] - c.computedPadTop - c.computedPadBottom);
            }

            if (c.endRow) {
                currentX = x;
                currentY += rowHeight[c.row];
            } else
                currentX += spannedCellWidth + c.computedPadRight;
        }
    }
1234472
public void setHTML (int row, int column, String text, int colSpan, String... styles)
    {
        setHTML(row, column, text);
        if (colSpan > 0) {
            getFlexCellFormatter().setColSpan(row, column, colSpan);
        }
        setStyleNames(row, column, styles);
    }
446385
public void layoutParts() {
    StringBuilder styleClass = new StringBuilder("group");

    // if there are no rows yet, getRowCount returns -1, in this case the next row is 0
    int nextRow = PreferencesFxUtils.getRowCount(grid) + 1;

    // Only when the preferencesGroup has a title
    if (preferencesGroup.getTitle() != null) {
      grid.add(titleLabel, 0, nextRow++, 2, 1);
      styleClass.append("-title");
      titleLabel.getStyleClass().add("group-title");
    }

    List<Field> fields = preferencesGroup.getElements().stream()
        .map(Field.class::cast)
        .collect(Collectors.toList());
    styleClass.append("-setting");

    int rowAmount = nextRow;
    for (int i = 0; i < fields.size(); i++) {
      // add to GridPane
      Field field = fields.get(i);
      SimpleControl c = (SimpleControl) field.getRenderer();
      c.setField(field);
      grid.add(c.getFieldLabel(), 0, i + rowAmount, 1, 1);
      grid.add(c.getNode(), 1, i + rowAmount, 1, 1);

      // Styling
      GridPane.setHgrow(c.getNode(), Priority.SOMETIMES);
      GridPane.setValignment(c.getNode(), VPos.CENTER);
      GridPane.setValignment(c.getFieldLabel(), VPos.CENTER);

      // additional styling for the last setting
      if (i == fields.size() - 1) {
        styleClass.append("-last");
        GridPane.setMargin(
            c.getNode(),
            new Insets(0, 0, PreferencesFxFormRenderer.SPACING * 4, 0)
        );
        GridPane.setMargin(
            c.getFieldLabel(),
            new Insets(0, 0, PreferencesFxFormRenderer.SPACING * 4, 0)
        );
      }

      c.getFieldLabel().getStyleClass().add(styleClass.toString() + "-label");
      c.getNode().getStyleClass().add(styleClass.toString() + "-node");
    }
  }
1223140
private void createCellhd( int chproj, int chzone, double chn, double chs, double che, double chw, int chcols, int chrows,
            double chnsres, double chewres, int chformat, int chcompressed ) throws Exception {
        StringBuffer data = new StringBuffer(512);
        data.append("proj:   " + chproj + "\n").append("zone:   " + chzone + "\n").append("north:   " + chn + "\n")
                .append("south:   " + chs + "\n").append("east:   " + che + "\n").append("west:   " + chw + "\n")
                .append("cols:   " + chcols + "\n").append("rows:   " + chrows + "\n").append("n-s resol:   " + chnsres + "\n")
                .append("e-w resol:   " + chewres + "\n").append("format:   " + chformat + "\n")
                .append("compressed:   " + chcompressed);
        File ds = new File(mapsetPath + File.separator + GrassLegacyConstans.CELLHD + File.separator + name);
        OutputStreamWriter windFile = new OutputStreamWriter(new FileOutputStream(ds));
        windFile.write(data.toString());
        windFile.close();
    }
562808
private void layoutComponents() {
		GridBagLayout layout = new GridBagLayout();
		layout.rowWeights = new double[]{1.0, 0.0, 0.0};
		layout.columnWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0};
		layout.rowHeights = new int[] {0, 0, 0};
		layout.columnWidths = new int[] {0, 0, 0, 0, 0};
		getContentPane().setLayout(layout);

		GridBagConstraints wizardPageContainerConstraint = new GridBagConstraints();
		wizardPageContainerConstraint.gridwidth = 5;
		wizardPageContainerConstraint.fill = GridBagConstraints.BOTH;
		wizardPageContainerConstraint.gridx = 0;
		wizardPageContainerConstraint.gridy = 0;
		wizardPageContainerConstraint.insets = new Insets(5, 5, 5, 5);
		getContentPane().add(wizardPageContainer, wizardPageContainerConstraint);

		GridBagConstraints separatorConstraints = new GridBagConstraints();
		separatorConstraints.gridwidth = 5;
		separatorConstraints.fill = GridBagConstraints.HORIZONTAL;
		separatorConstraints.gridx = 0;
		separatorConstraints.gridy = 1;
		separatorConstraints.insets = new Insets(5, 5, 5, 5);
		getContentPane().add(new JSeparator(), separatorConstraints);

		GridBagConstraints cancelButtonConstraints = new GridBagConstraints();
		cancelButtonConstraints.gridx = 1;
		cancelButtonConstraints.gridy = 2;
		cancelButtonConstraints.insets = new Insets(5, 5, 5, 0);
		getContentPane().add(cancelButton, cancelButtonConstraints);

		GridBagConstraints previousButtonConstraints = new GridBagConstraints();
		previousButtonConstraints.gridx = 2;
		previousButtonConstraints.gridy = 2;
		previousButtonConstraints.insets = new Insets(5, 5, 5, 0);
		getContentPane().add(previousButton, previousButtonConstraints);

		GridBagConstraints nextButtonConstraints = new GridBagConstraints();
		nextButtonConstraints.gridx = 3;
		nextButtonConstraints.gridy = 2;
		nextButtonConstraints.insets = new Insets(5, 5, 5, 0);
		getContentPane().add(nextButton, nextButtonConstraints);

		GridBagConstraints finishButtonConstraints = new GridBagConstraints();
		finishButtonConstraints.gridx = 4;
		finishButtonConstraints.gridy = 2;
		finishButtonConstraints.insets = new Insets(5, 5, 5, 5);
		getContentPane().add(finishButton, finishButtonConstraints);
	}
1353001
function recurse(data, depth, nodes) {
    var childs = children.call(hierarchy, data, depth),
        node = d3_layout_hierarchyInline ? data : {data: data};
    node.depth = depth;
    nodes.push(node);
    if (childs && (n = childs.length)) {
      var i = -1,
          n,
          c = node.children = [],
          v = 0,
          j = depth + 1,
          d;
      while (++i < n) {
        d = recurse(childs[i], j, nodes);
        d.parent = node;
        c.push(d);
        v += d.value;
      }
      if (sort) c.sort(sort);
      if (value) node.value = v;
    } else if (value) {
      node.value = +value.call(hierarchy, data, depth) || 0;
    }
    return node;
  }
772945
def pretty_view(graph, oriented=False, construction=False,
                graphviz_prog=DEFAULT_GRAPHVIZ_PROG):
    """"""
    layout = create_layout(graph, graphviz_prog=graphviz_prog)
    matrix_view = defaultdict(lambda: ' ')

    # Add the edge to the view

    # print('GRAPH EDGES:', tuple(graph.edges()))
    # print('LAYOUT:', layout)

    edges = ((layout[source], layout[target])
             for source, target in graph.edges())
    # print('EDGES:', tuple(edges))

    for source, target in edges:
        previous_edge_char = None
        previous_position = source
        while source != target:
            for is_dir, transform, edge_char in DIRECTIONS:
                first_loop = previous_edge_char is None
                if is_dir(source, target):
                    previous_source = source
                    source = transform(source)
                    if not first_loop:  # first loop: no previous char
                        char = CHARACTER[previous_edge_char, edge_char]
                        if not isinstance(char, str):
                            char = char.value
                        matrix_view[previous_source] = char
                        if construction:
                            old = defaultdict(lambda: ' ', matrix_view)
                            yield view.build(matrix_view)
                        assert isinstance(matrix_view[previous_source], str)
                    if source != target:
                        previous_edge_char = edge_char
                    previous_position = previous_source
                    break  # for loop ; don't test the remain directions

        if oriented:
            matrix_view[previous_position] = ORIENTATION[previous_edge_char, edge_char]
        if construction:
            yield view.build(matrix_view)

    # mark the place where nodes labels will be added
    # for node, coords in layout.items():
        # matrix_view[coords] = node[0]
    # Add the node labels to the view
    # matrix_view = view.clean(matrix_view)
    for node, (x, y) in layout.items():
        if len(node) == 1:
            matrix_view[x, y] = node
            continue
        row_min, row_max = (view.previous_unwrittable_on_row(matrix_view, (x, y)),
                            view.next_unwrittable_on_row(matrix_view, (x, y)))
        col_min, col_max = (view.previous_unwrittable_on_col(matrix_view, (x, y)),
                              view.next_unwrittable_on_col(matrix_view, (x, y)))
        # print('NODE ' + node + ':',
              # '→row: [{};{}]'.format(row_min, row_max).ljust(20),
              # '↓col: [{};{}]'.format(col_min, col_max))
        print_coords = [itertools.count(x), itertools.cycle((y,))]
        if row_min is None:  # write left to right, end at (x, y)
            if row_max is None or row_max > (x + len(node) / 2):  # enough space at the right
                factor = 2
            else:
                factor = 1
            print_coords[0] = tuple(
                x - (len(node) // factor) + offset + 1
                for offset in range(len(node))
            )
            # print('DEBUG 1:', y, len(node), print_coords[0])
        elif row_max is None:  # write left to right, beginning at (x, y)
            if row_min < (x - len(node) / 2):  # enough space at the left
                factor = 1
            else:
                factor = 0
            print_coords[0] = tuple(
                x + offset - (len(node) // 2) * factor
                for offset in range(len(node))
            )
            # print('DEBUG 2:', print_coords[0])
        elif (row_max - row_min) > len(node) + 1:  # write left to right, if enough place
            print_coords[0] = tuple(
                x + offset
                for offset in range(len(node))
            )
            # print('DEBUG 3:', print_coords[0])

        elif col_min is None:  # write up to down, end at (x, y)
            if col_max is None or col_max > (x + len(node) / 2):  # enough space at the right
                factor = 2
            else:
                factor = 1
            print_coords = (itertools.cycle((x,)), tuple(
                y - (len(node) // factor) + offset + 1
                for offset in range(len(node))
            ))
            # print('DEBUG 4:', y, len(node), print_coords[1])
        elif col_max is None:  # write up to down, beginning at (x, y)
            if col_min < (x - len(node) / 2):  # enough space at the left
                factor = 1
            else:
                factor = 0
            print_coords = (itertools.cycle((x,)), tuple(
                y + offset - (len(node) // 2) * factor
                for offset in range(len(node))
            ))
            # print('DEBUG 5:', print_coords[1])
        elif (col_max - col_min) > len(node) + 1:  # write up to down, if enough place
            print_coords = (itertools.cycle((x,)), tuple(
                y + offset
                for offset in range(len(node))
            ))
            # print('DEBUG 6:', print_coords[1])
        else:  # not enough space
            if (row_max - row_min) > (col_max - col_min):
                # more space on Y axis
                node = node[:row_max - row_min]  # cut the node
                print_coords = (itertools.cycle((x,)), tuple(
                    x + offset
                    for offset in range(len(node))
                ))
                # print('DEBUG 7:', print_coords[1])
            else:
                # more space on X axis
                node = node[:col_max - col_min]  # cut the node
                print_coords[0] = tuple(
                    x + offset
                    for offset in range(len(node))
                )
                # print('DEBUG 8:', print_coords[0])

        for letter, i, j in zip(node, *print_coords):
            matrix_view[i, j] = letter




    if construction:
        yield view.build(matrix_view)
    else:
        yield from view.build(matrix_view)
1036957
function intoCoordSystem(cm, lineObj, rect, context) {
    if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
      var size = widgetHeight(lineObj.widgets[i]);
      rect.top += size; rect.bottom += size;
    }
    if (context == "line") return rect;
    if (!context) context = "local";
    var yOff = heightAtLine(lineObj);
    if (context == "local") yOff += paddingTop(cm.display);
    else yOff -= cm.display.viewOffset;
    if (context == "page" || context == "window") {
      var lOff = cm.display.lineSpace.getBoundingClientRect();
      yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
      var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
      rect.left += xOff; rect.right += xOff;
    }
    rect.top += yOff; rect.bottom += yOff;
    return rect;
  }
621542
function NodeLabelView() {
        NodeParasiticView.apply(this, arguments);

        /** @member {string} */
        this.underline = false;

        this.enabled = true;
        this.movable = MM_FREE;
        this.sizable = SZ_NONE;
        this.text = "";
        this.horizontalAlignment = Graphics.AL_CENTER;
        this.verticalAlignment = Graphics.AL_MIDDLE;
    }
169188
function updateCSSNode(editor, srcProp, width, height) {
	const rule = srcProp.parent;
	const widthProp = getProperty(rule, 'width');
	const heightProp = getProperty(rule, 'height');

	// Detect formatting
	const separator = srcProp.separator || ': ';
	const before = getBefore(editor, srcProp);
	const insertOpt = { autoIndent: false };

	editor.transact(() => {
		// Apply changes from right to left, first for height, then for width

		if (!heightProp) {
			// no `height` property, add it right after `width` or source property
			editor.setCursorBufferPosition(widthProp ? widthProp.end : srcProp.end);
			editor.insertText(`${before}height${separator}${height}px;`, insertOpt);
		} else {
			editor.setTextInBufferRange(getRange(heightProp.valueToken), `${height}px`);
		}

		if (!widthProp) {
			// no `width` attribute, add it right after `height` or source property
			if (heightProp) {
				editor.setCursorBufferPosition(heightProp.previousSibling
					? heightProp.previousSibling.end
					: rule.contentStart.end);
			} else {
				editor.setCursorBufferPosition(srcProp.end);
			}
			editor.insertText(`${before}width${separator}${width}px;`, insertOpt);
		} else {
			editor.setTextInBufferRange(getRange(widthProp.valueToken), `${width}px`);
		}
	});
}
965541
function tableDoesNotHaveGridLayout(rows) {
        var headerCells = rows[0].children;

        for (var i = 1; i < headerCells.length; i++) {
            if (headerCells[i].tagName != 'TH') {
                return true;
            }
        }

        for (var i = 1; i < rows.length; i++) {
            if (rows[i].children[0].tagName != 'TH') {
                return true;
            }
        }
        return false;
    }
1567
public static HorizontalPanel newRow (String styleName, Widget... contents)
    {
        return newRow(HasAlignment.ALIGN_MIDDLE, styleName, contents);
    }
219843
function transformLayout(statement) {
    // Transform to layout function
    var actions = statement.expression.children;

    var blocks = [];
    var o = t.identifier('o');
    var type = t.memberExpression(o, t.identifier('type'));
    var config = t.memberExpression(o, t.identifier('config'));
    var childrenPush = t.memberExpression(
      t.memberExpression(o, t.identifier('children')),
      t.identifier('push')
    );
    var childrenUnshift = t.memberExpression(
      t.memberExpression(o, t.identifier('children')),
      t.identifier('unshift')
    );
    var element = t.memberExpression(o, t.identifier('element'));
    var stopRender = t.memberExpression(o, t.identifier('stopRender'));

    for (var ii = 0, actionsLength = actions.length; ii < actionsLength; ii++) {
      var action = actions[ii];
      if (!t.isJSXElement(action)) {
        continue;
      }

      // Check if conditions
      var tests = [], configCondition = true, falseCondition = false;
      var conditions = action.openingElement.attributes;
      var children = childrenPush;
      for (var j = 0, conditionsLength = conditions.length; j < conditionsLength; j++) {
        var condition = conditions[j];
        if (condition.name.name === 'type') {
          // Type condition
          if (t.isJSXExpressionContainer(condition.value)) {
            tests.push(t.binaryExpression(
              '===',
              type,
              condition.value.expression
            ));
          } else {
            falseCondition = true;
            break;
          }
        } else if (condition.name.name === '_top') {
          children = childrenUnshift;
        } else {
          if (configCondition) {
            tests.push(config);
            configCondition = false;
          }
          tests.push(t.binaryExpression(
            '===',
            t.memberExpression(config, t.stringLiteral(condition.name.name), true),
            t.isJSXExpressionContainer(condition.value) ?
              condition.value.expression :
              (condition.value === null ? t.booleanLiteral(true) : condition.value)
          ));
        }
      }
      if (falseCondition) {
        continue;
      }

      var statements = [];
      // Transform each action to block
      switch (action.openingElement.name.name) {
        // Transform content
        case 'addChildren':
        case 'update':
          for (var j = 0, childrenLen = action.children.length; j < childrenLen; j++) {
            var child = action.children[j];
            var param = undefined;
            if (t.isJSXElement(child)) {
              // @TODO process 'before' and 'after' element
              if (child.openingElement.name.name === 'props') {
                // Update props
                var attributes = child.openingElement.attributes;
                for (var jj = 0, attsLength = attributes.length; jj < attsLength; jj++) {
                  if (jj === 0) {
                    statements.push(t.assignmentExpression('=', config, t.logicalExpression(
                      '||', config, t.objectExpression([])
                    )));
                  }
                  var att = attributes[jj];
                  var left = t.memberExpression(config, t.stringLiteral(att.name.name), true);
                  var right;
                  if (t.isJSXExpressionContainer(att.value)) {
                    right = att.value.expression;
                  } else if (att.value === null) {
                    right = t.booleanLiteral(true);
                  } else {
                    right = att.value;
                  }
                  statements.push(t.assignmentExpression('=', left, right));
                }
              } else {
                // JSX element
                param = child;
              }
            } else if (t.isJSXExpressionContainer(child)) {
              // JS expression
              param = child.expression;
            } else if (child.value.trim().length > 0) {
              // Text string
              param = t.stringLiteral(child.value);
            }
            if (param !== undefined) {
              statements.push(t.callExpression(children, [param]))
            }
          }
          break;
        case 'replace':
          for (var j = 0, childrenLen = action.children.length; j < childrenLen; j++) {
            var child = action.children[j];
            if (t.isJSXExpressionContainer(child)) {
              statements.push(t.assignmentExpression('=', element, child.expression));
              break;
            } else if (t.isJSXElement(child)) {
              statements.push(t.assignmentExpression('=', element, child));
              break;
            }
          }
          break;
        case 'remove':
          statements.push(t.assignmentExpression('=', stopRender, t.booleanLiteral(true)));
          break;
        default:
          // Do not transform
      }
      if (statements.length === 0) {
        continue;
      }
      statements = statements.map(function(exp) {
        return t.expressionStatement(exp);
      });

      // Append to blocks
      if (tests.length === 0) {
        blocks = blocks.concat(statements);
      } else {
        blocks.push(t.ifStatement(
          tests.reduce(function(l, r) {
            return t.logicalExpression('&&', l, r);
          }),
          t.blockStatement(statements)
        ));
      }
    }

    statement.expression = t.assignmentExpression(
      '=',
      t.memberExpression(t.identifier('module'), t.identifier('exports')),
      t.functionExpression(null, [o], t.blockStatement(blocks))
    );
  }