コード例 #1
0
  private int checkSetSizesFromParent(Container container, Insets insets) {
    int skipLayout = 0;
    GridLayoutManager parentGridLayout = null;
    GridConstraints parentGridConstraints = null;
    Container parent = container.getParent();
    if (parent != null) {
      if (parent.getLayout() instanceof GridLayoutManager) {
        parentGridLayout = (GridLayoutManager) parent.getLayout();
        parentGridConstraints = parentGridLayout.getConstraintsForComponent(container);
      } else {
        Container col = parent.getParent();
        if (col != null && col.getLayout() instanceof GridLayoutManager) {
          parentGridLayout = (GridLayoutManager) col.getLayout();
          parentGridConstraints = parentGridLayout.getConstraintsForComponent(parent);
        }
      }
    }

    if (parentGridLayout != null && parentGridConstraints.isUseParentLayout()) {
      int i;
      if (this.myRowStretches.length == parentGridConstraints.getRowSpan()) {
        int row = parentGridConstraints.getRow();
        this.myYs[0] = insets.top + this.myMargin.top;
        this.myHeights[0] = parentGridLayout.myHeights[row] - this.myYs[0];

        for (i = 1; i < this.myRowStretches.length; ++i) {
          this.myYs[i] = parentGridLayout.myYs[i + row] - parentGridLayout.myYs[row];
          this.myHeights[i] = parentGridLayout.myHeights[i + row];
        }

        this.myHeights[this.myRowStretches.length - 1] -= insets.bottom + this.myMargin.bottom;
        skipLayout |= 1;
      }

      if (this.myColumnStretches.length == parentGridConstraints.getColSpan()) {
        int column = parentGridConstraints.getColumn();
        this.myXs[0] = insets.left + this.myMargin.left;
        this.myWidths[0] = parentGridLayout.myWidths[column] - this.myXs[0];

        for (i = 1; i < this.myColumnStretches.length; ++i) {
          this.myXs[i] = parentGridLayout.myXs[i + column] - parentGridLayout.myXs[column];
          this.myWidths[i] = parentGridLayout.myWidths[i + column];
        }

        this.myWidths[this.myColumnStretches.length - 1] -= insets.right + this.myMargin.right;
        skipLayout |= 2;
      }
    }

    return skipLayout;
  }
コード例 #2
0
  private static void updateSizesFromChild(
      DimensionInfo info, boolean min, int[] widths, Container container, int childIndex) {
    GridLayoutManager childLayout = (GridLayoutManager) container.getLayout();
    if (info.getSpan(childIndex) == info.getChildLayoutCellCount(childLayout)) {
      childLayout.validateInfos(container);
      DimensionInfo childInfo =
          info instanceof HorizontalInfo
              ? childLayout.myHorizontalInfo
              : childLayout.myVerticalInfo;
      int[] sizes = childLayout.getMinOrPrefSizes(childInfo, min);
      int cell = info.getCell(childIndex);

      for (int j = 0; j < sizes.length; ++j) {
        widths[cell + j] = Math.max(widths[cell + j], sizes[j]);
      }
    }
  }