Write the <c:layout> element.
515351
def write_layout(layout = nil, type = nil) # :nodoc:
      tag = 'c:layout'

      if layout
        @writer.tag_elements(tag)  { write_manual_layout(layout, type) }
      else
        @writer.empty_tag(tag)
      end
    end
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);
	}
1137857
private void writeForm(OutputStream out) throws IOException {
		if (CollectionUtil.isNotEmpty(this.form)) {
			StringBuilder builder = StrUtil.builder();
			for (Entry<String, Object> entry : this.form.entrySet()) {
				builder.append("--").append(BOUNDARY).append(StrUtil.CRLF);
				builder.append(StrUtil.format(CONTENT_DISPOSITION_TEMPLATE, entry.getKey()));
				builder.append(entry.getValue()).append(StrUtil.CRLF);
			}
			IoUtil.write(out, this.charset, false, builder);
		}
	}
154455
function(layouts) {
      var currentLayout;
      layouts = layouts.slice(0);
      currentLayout = self.compile(str, layoutFile);
      layouts.push(currentLayout);
      if (useCache) {
        self.cache[layoutFile] = layouts.slice(0);
      }
      cb(null, layouts);
    }
218131
private final void writeIndentation() throws IOException {

        // Write indentation only if there is any
        if (_indentation.length() > 0) {
            int count = _elementStackSize - 1;
            for (int i = 0; i < count; i++) {
                _out.write(_indentation);
            }
        }
    }
678665
public void writeBlockElement(String name, Object text)
  {
    startBlockElement(name);
    writeText(text);
    endBlockElement(name);
  }
1289324
def write_elements(elements, mass_erase_used, progress=None):
    

    mem_layout = get_memory_layout(__dev)
    for elem in elements:
        addr = elem['addr']
        size = elem['size']
        data = elem['data']
        elem_size = size
        elem_addr = addr
        if progress:
            progress(elem_addr, 0, elem_size)
        while size > 0:
            write_size = size
            if not mass_erase_used:
                for segment in mem_layout:
                    if addr >= segment['addr'] and \
                       addr <= segment['last_addr']:
                        # We found the page containing the address we want to
                        # write, erase it
                        page_size = segment['page_size']
                        page_addr = addr & ~(page_size - 1)
                        if addr + write_size > page_addr + page_size:
                            write_size = page_addr + page_size - addr
                        page_erase(page_addr)
                        break
            write_memory(addr, data[:write_size], progress,
                         elem_addr, elem_size)
            data = data[write_size:]
            addr += write_size
            size -= write_size
            if progress:
                progress(elem_addr, addr - elem_addr, elem_size)
147422
public void writeLineElement(String name, Object text)
  {
    startLineElement(name);
    writeText(text);
    endLineElement(name);
  }
36086
public void write(int c) {
        if (c != -1) {
            current.append((char)c);
        }
        if (c == '\n') {
            current = new StringBuilder();
            lines.add(current);
        }
    }
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;
        }
    }
591190
public void setLayout(String layout)
    {
        if (layout == null)
        {
            String message = Logging.getMessage("nullValue.StringIsNull");
            Logging.logger().severe(message);
            throw new IllegalArgumentException(message);
        }
        if (!this.layout.equals(layout))
        {
            this.layout = layout;
            clearControls();
        }
    }
1100768
public void writeAttribute(String name, Object value)
  {
    if (!_isElementOpen)
      throw new IllegalStateException("no open element");

    if (value == null)
      return;

    _isElementOpen = false;
    try {
      _strategy.writeAttribute(this, name, value);
    }
    finally {
      _isElementOpen = true;
    }

  }
473184
public void setButtonLayout(final Layout layout) {
		CheckBoxSelectModel model = getOrCreateComponentModel();
		model.layout = layout;
		model.numColumns = 0;
	}
1359972
function () {
        var self = this, style, rect;

        style = self.getEl().style;
        rect = self._layoutRect;

        style.left = rect.x + 'px';
        style.top = rect.y + 'px';
        style.zIndex = 0xFFFF + 0xFFFF;
      }
959286
def add_layout(self, l):
        """"""
        if self.layout():
            self.layout().addLayout(l)
        else:
            layout = QVBoxLayout(self)
            layout.addLayout(l)
1171574
public void writeContent(final OutputStream result) throws IOException
    {
    	
        if(this.topLevelElement) {
            result.write(RtfParagraph.PARAGRAPH_DEFAULTS);
            switch(alignment) {
                case Element.ALIGN_LEFT:
                    result.write(RtfParagraphStyle.ALIGN_LEFT);
                    break;
                case Element.ALIGN_RIGHT:
                    result.write(RtfParagraphStyle.ALIGN_RIGHT);
                    break;
                case Element.ALIGN_CENTER:
                    result.write(RtfParagraphStyle.ALIGN_CENTER);
                    break;
                case Element.ALIGN_JUSTIFIED:
                    result.write(RtfParagraphStyle.ALIGN_JUSTIFY);
                    break;
            }
        }
        result.write(OPEN_GROUP);
        result.write(PICTURE_GROUP);
        result.write(OPEN_GROUP);
        result.write(PICTURE);
        switch(imageType) {
        	case Image.ORIGINAL_JPEG:
        	    result.write(PICTURE_JPEG);
        		break;
        	case Image.ORIGINAL_PNG:
            case Image.ORIGINAL_GIF:
        	    result.write(PICTURE_PNG);
        		break;
        	case Image.ORIGINAL_WMF:
        	case Image.ORIGINAL_BMP:
        	    result.write(PICTURE_WMF);
        		break;
        }
        result.write(PICTURE_WIDTH);
        result.write(intToByteArray((int) width));
        result.write(PICTURE_HEIGHT);
        result.write(intToByteArray((int) height));
        if(this.document.getDocumentSettings().isWriteImageScalingInformation()) {
            result.write(PICTURE_SCALE_X);
            result.write(intToByteArray((int)(100 * plainWidth / width)));
            result.write(PICTURE_SCALE_Y);
            result.write(intToByteArray((int)(100 * plainHeight / height)));
        }
        if(this.document.getDocumentSettings().isImagePDFConformance()) {
            result.write(PICTURE_SCALED_WIDTH);
            result.write(intToByteArray((int) (plainWidth * RtfElement.TWIPS_FACTOR)));
            result.write(PICTURE_SCALED_HEIGHT);
            result.write(intToByteArray((int) (plainHeight * RtfElement.TWIPS_FACTOR)));
        } else {
            if(this.width != this.plainWidth || this.imageType == Image.ORIGINAL_BMP) {
                result.write(PICTURE_SCALED_WIDTH);
                result.write(intToByteArray((int) (plainWidth * PIXEL_TWIPS_FACTOR)));
            }
            if(this.height != this.plainHeight || this.imageType == Image.ORIGINAL_BMP) {
                result.write(PICTURE_SCALED_HEIGHT);
                result.write(intToByteArray((int) (plainHeight * PIXEL_TWIPS_FACTOR)));
            }
        }

        if(this.document.getDocumentSettings().isImageWrittenAsBinary()) {
        	//binary
        	result.write('\n');
        	result.write(PICTURE_BINARY_DATA);
        	result.write(intToByteArray(imageDataSize()));
            result.write(DELIMITER);
            if(result instanceof RtfByteArrayBuffer) {
            	((RtfByteArrayBuffer)result).append(imageData);
            } else {
            	for(int k = 0; k < imageData.length; k++) {
					result.write(imageData[k]);
				}
            }
        } else {
        	//hex encoded
            result.write(DELIMITER);
        	result.write('\n');
        	writeImageDataHexEncoded(result);
        }
        
        result.write(CLOSE_GROUP);
        result.write(CLOSE_GROUP);
        if(this.topLevelElement) {
            result.write(RtfParagraph.PARAGRAPH);
            result.write(RtfParagraph.PARAGRAPH);
        }
        result.write('\n');    	
    }
291274
protected
  Layout parseLayout (Element layout_element) {
    String className = subst(layout_element.getAttribute(CLASS_ATTR));
    LogLog.debug("Parsing layout of class: \""+className+"\"");		 
    try {
      Object instance 	= Loader.loadClass(className).newInstance();
      Layout layout   	= (Layout)instance;
      PropertySetter propSetter = new PropertySetter(layout);
      
      NodeList params 	= layout_element.getChildNodes();
      final int length 	= params.getLength();

      for (int loop = 0; loop < length; loop++) {
	Node currentNode = (Node)params.item(loop);
	if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
	  Element currentElement = (Element) currentNode;
	  String tagName = currentElement.getTagName();
	  if(tagName.equals(PARAM_TAG)) {
            setParameter(currentElement, propSetter);
	  } else {
          parseUnrecognizedElement(instance, currentElement, props);
      }
	}
      }
      
      propSetter.activate();
      return layout;
    }
    catch (Exception oops) {
      LogLog.error("Could not create the Layout. Reported error follows.",
		   oops);
      return null;
    }
  }