Package org.crsh.text

Examples of org.crsh.text.LineRenderer


      LabelElement bar = new LabelElement("bar").style(Style.style(Decoration.bold_off));
      LabelElement juu = new LabelElement("juu");

      @Override
      public LineRenderer renderer() {
        return new LineRenderer() {
          @Override
          public int getActualWidth() {
            return 9;
          }
          @Override
View Full Code Here


      }

      public void flush() throws IOException {
        // We don't really flush, we just compute renderables from the buffer
        if (buffer.size() > 0) {
          LineRenderer i = renderable.renderer(buffer.iterator());
          buffer.clear();
          renderers.add(i);
        }
      }
View Full Code Here

  @Override
  public int getActualWidth() {
    int actualWidth = 0;
    for (int i = 0;i < cols.size();i++) {
      LineRenderer col = cols.get(i);
      actualWidth += col.getActualWidth();
      actualWidth += leftCellPadding;
      actualWidth += rightCellPadding;
      if (separator != null && i > 0) {
        actualWidth++;
      }
View Full Code Here

  @Override
  public int getMinWidth() {
    int minWidth = 0;
    for (int i = 0;i < cols.size();i++) {
      LineRenderer col = cols.get(i);
      minWidth += col.getMinWidth();
      minWidth += leftCellPadding;
      minWidth += rightCellPadding;
      if (separator != null && i > 0) {
        minWidth++;
      }
View Full Code Here

  // }
  // in relation to widths array that can contain (should?) 0 value
  LineReader renderer(final int[] widths, int height) {
    final LineReader[] readers = new LineReader[widths.length];
    for (int i = 0;i < readers.length;i++) {
      LineRenderer renderer = cols.get(i);
      LineReader reader = renderer.reader(widths[i] - leftCellPadding - rightCellPadding, height);
      readers[i] = reader;
    }

    //
    return new LineReader() {
View Full Code Here

  @Override
  public LineReader reader(int width) {
    int[] widths = new int[cols.size()];
    int[] minWidths = new int[cols.size()];
    for (int i = 0;i < cols.size();i++) {
      LineRenderer renderable = cols.get(i);
      widths[i] = Math.max(widths[i], renderable.getActualWidth());
      minWidths[i] = Math.max(minWidths[i], renderable.getMinWidth());
    }
    widths = Layout.flow().compute(false, width, widths, minWidths);
    if (widths == null) {
      return null;
    } else {
View Full Code Here

  }

  public abstract LineRenderer renderer();

  public void render(RenderAppendable to) {
    LineRenderer renderer = renderer();

    // For now height - 1 because of the char that goes to the line in some impl
    LineReader reader = renderer.reader(to.getWidth(), to.getHeight() - 1);
    if (reader != null) {
      while (reader.hasLine()) {
        reader.renderLine(to);
        to.append('\n');
      }
View Full Code Here

    int[] eltMinWidths = new int[len];

    // Compute each column as is
    for (TableRowLineRenderer row = head;row != null;row = row.next()) {
      for (int i = 0;i < row.getCols().size();i++) {
        LineRenderer renderable = row.getCols().get(i);
        eltWidths[i] = Math.max(eltWidths[i], renderable.getActualWidth() + row.row.leftCellPadding + row.row.rightCellPadding);
        eltMinWidths[i] = Math.max(eltMinWidths[i], renderable.getMinWidth() + row.row.leftCellPadding + row.row.rightCellPadding);
      }
    }

    // Note that we may have a different widths != eltWidths according to the layout algorithm
    final int[] widths = columnLayout.compute(separator != null, width - (border != null ? 2 : 0), eltWidths, eltMinWidths);
View Full Code Here

        actualHeight = 1;
        break;
      case WRAP:
        actualHeight = 0;
        for (int i = 0;i < widths.length;i++) {
          LineRenderer col = row.getCols().get(i);
          actualHeight = Math.max(actualHeight, col.getActualHeight(widths[i]));
        }
        break;
      default:
        throw new AssertionError();
    }
View Full Code Here

        minHeight = 1;
        break;
      case WRAP:
        minHeight = 0;
        for (int i = 0;i < widths.length;i++) {
          LineRenderer col = row.getCols().get(i);
          minHeight = Math.max(minHeight, col.getMinHeight(widths[i]));
        }
        break;
      default:
        throw new AssertionError();
    }
View Full Code Here

TOP

Related Classes of org.crsh.text.LineRenderer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.