Example #1
0
  public static void _doLayout(EditorCell_Collection editorCells) {
    final int x = editorCells.getX();
    final int y = editorCells.getY();
    int currentLineWidth = 0;
    int totalWidth = 0;
    int totalHeight = 0;
    int currentLineHeight = 0;
    String nextLineForChildren = editorCells.getStyle().get(StyleAttributes.POSITION_CHILDREN);

    for (EditorCell editorCell : editorCells) {
      String nextLine = editorCell.getStyle().get(StyleAttributes.POSITION);
      if (nextLine != null) {
        System.out.println("nextLine = " + nextLine);
      }
      if (INDENTED.equals(nextLine) || (nextLine == null && INDENTED.equals(nextLineForChildren))) {
        currentLineWidth = INDENT;
        totalHeight += currentLineHeight;
        currentLineHeight = 0;
      } else if (NEXT_LINE.equals(nextLine)
          || (nextLine == null && NEXT_LINE.equals(nextLineForChildren))) {
        currentLineWidth = 0;
        totalHeight += currentLineHeight;
        currentLineHeight = 0;
      }
      editorCell.setX(x + currentLineWidth);
      editorCell.setY(y + totalHeight);
      editorCell.relayout();
      //      System.out.println("EditorCell [" +
      // editorCell.getX()+","+editorCell.getY()+","+editorCell.getWidth()+","+editorCell.getHeight()+"] node:"+editorCell.getSNode().getConceptShortName()+" cell:"+ editorCell.toString());
      currentLineHeight = Math.max(currentLineHeight, editorCell.getHeight());
      currentLineWidth += editorCell.getWidth();
      totalWidth = Math.max(totalWidth, currentLineWidth);
    }
    editorCells.setWidth(totalWidth);
    editorCells.setHeight(totalHeight + currentLineHeight);
  }