private double getWeight(final GridConstraints constraints, final boolean horizontal) {
    int policy = horizontal ? constraints.getHSizePolicy() : constraints.getVSizePolicy();
    if ((policy & GridConstraints.SIZEPOLICY_WANT_GROW) != 0) {
      return 1.0;
    }
    boolean canGrow = ((policy & GridConstraints.SIZEPOLICY_CAN_GROW) != 0);
    for (GridConstraints otherConstraints : myConstraints) {
      if (!constraintsIntersect(horizontal, constraints, otherConstraints)) {
        int otherPolicy = horizontal ? otherConstraints.getHSizePolicy() : otherConstraints.getVSizePolicy();
        if ((otherPolicy & GridConstraints.SIZEPOLICY_WANT_GROW) != 0) {
          return 0.0;
        }
        if (!canGrow && ((otherPolicy & GridConstraints.SIZEPOLICY_CAN_GROW) != 0)) {
          return 0.0;
        }
      }
    }
    return 1.0;
  }
private double getWeight(final GridConstraints constraints, final boolean horizontal)