コード例 #1
0
  protected void fillSubBranches(
      IBranchPart branch, List<IBranchPart> subBranches, LayoutInfo info) {
    Rectangle area = info.getCheckedClientArea();

    Column2 col = getColumn(branch);
    Chart2 chart = col.getOwnedChart();
    int lineWidth = chart.getLineWidth();
    int cellSpacing = chart.getMinorSpacing();
    int itemSpacing = col.getMinorSpacing();

    IInsertion insertion = getCurrentInsertion(branch);
    RowHead insHead = (RowHead) MindMapUtils.getCache(branch, Spreadsheet.KEY_INSERTION_ROW_HEAD);

    int startX = info.getReference().x - col.getPrefCellWidth() / 2;
    int y = area.y + chart.getColHeadHeight() + cellSpacing / 2 + lineWidth;
    List<Row2> rows = chart.getRows();
    IInsertion rowIns =
        (IInsertion) MindMapUtils.getCache(chart.getTitle(), Spreadsheet.CACHE_ROW_INSERTION);
    for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) {
      if (rowIns != null && rowIns.getIndex() == rowIndex) {
        y += rowIns.getSize().height + chart.getMinorSpacing() + lineWidth;
      }

      Row2 row = rows.get(rowIndex);
      int x = startX;
      boolean insertionInRow = insertion != null && row.getHead().equals(insHead);
      Cell2 cell = col.findCellByRow(row);
      if (cell != null) {
        info.add(new Rectangle(x, y, col.getPrefCellWidth(), cell.getContentHeight()));
        List<Item2> items = cell.getItems();
        int num = items.size();
        int itemY = y;
        for (int i = 0; i < num; i++) {
          Item2 item = items.get(i);
          if (insertionInRow && insertion.getIndex() == i) {
            Rectangle r = insertion.createRectangle(x, y);
            info.add(r);
            itemY += r.height + itemSpacing;
          }
          IBranchPart child = item.getBranch();
          IFigure childFigure = child.getFigure();
          Dimension size = childFigure.getPreferredSize();

          int bh = 0;
          if (!branch.getBoundaries().isEmpty()) {
            for (IBoundaryPart boundary : branch.getBoundaries()) {
              List<IBranchPart> enclosingBranches = boundary.getEnclosingBranches();
              if (child.equals(enclosingBranches.get(0))) {
                bh = boundary.getFigure().getInsets().top;
                if (boundary.getTitle() != null && boundary.getTitle().getFigure() != null) {
                  Dimension s = boundary.getTitle().getFigure().getPreferredSize();
                  bh = Math.max(bh, s.height);
                }
                List<ITopic> topics = boundary.getBoundary().getEnclosingTopics();
                if (topics.size() > 1) {
                  itemY += bh;
                }
                bh = 0;
              }
              if (child.equals(enclosingBranches.get(enclosingBranches.size() - 1))) {
                bh = boundary.getFigure().getInsets().bottom;
              }
            }
          }

          Rectangle childBounds = new Rectangle(x, itemY, size.width, size.height + 10);
          info.put(childFigure, childBounds);
          itemY += size.height + itemSpacing + bh;
        }
        if (insertionInRow && insertion.getIndex() == num) {
          info.add(insertion.createRectangle(x, y));
        }
      } else if (insertionInRow) {
        info.add(insertion.createRectangle(x, y));
      }
      y += row.getPrefCellHeight() + cellSpacing + lineWidth;
    }
    if (rowIns != null && rowIns.getIndex() == rows.size()) {
      info.add(new Rectangle(startX, y, rowIns.getSize().width, 1));
    }
  }