Ejemplo n.º 1
0
  /**
   * Lays out the children. If the span along the flow axis has changed, layout is marked as invalid
   * which which will cause the superclass behavior to recalculate the layout along the box axis.
   * The FlowStrategy.layout method will be called to rebuild the flow rows as appropriate. If the
   * height of this view changes (determined by the perferred size along the box axis), a
   * preferenceChanged is called. Following all of that, the normal box layout of the superclass is
   * performed.
   *
   * @param width the width to lay out against >= 0. This is the width inside of the inset area.
   * @param height the height to lay out against >= 0 This is the height inside of the inset area.
   */
  protected void layout(int width, int height) {
    final int faxis = getFlowAxis();
    int newSpan;
    if (faxis == X_AXIS) {
      newSpan = (int) width;
    } else {
      newSpan = (int) height;
    }
    if (layoutSpan != newSpan) {
      layoutChanged(faxis);
      layoutChanged(getAxis());
      layoutSpan = newSpan;
    }

    // repair the flow if necessary
    if (!isLayoutValid(faxis)) {
      final int heightAxis = getAxis();
      int oldFlowHeight = (int) ((heightAxis == X_AXIS) ? getWidth() : getHeight());
      strategy.layout(this);
      int newFlowHeight = (int) getPreferredSpan(heightAxis);
      if (oldFlowHeight != newFlowHeight) {
        View p = getParent();
        if (p != null) {
          p.preferenceChanged(this, (heightAxis == X_AXIS), (heightAxis == Y_AXIS));
        }

        // PENDING(shannonh)
        // Temporary fix for 4250847
        // Can be removed when TraversalContext is added
        Component host = getContainer();
        if (host != null) {
          // nb idk 12/12/2001 host should not be equal to null. We need to add assertion here
          host.repaint();
        }
      }
    }

    super.layout(width, height);
  }
Ejemplo n.º 2
0
 /**
  * Child views can call this on the parent to indicate that the preference has changed and should
  * be reconsidered for layout. By default this just propagates upward to the next parent. The root
  * view will call <code>revalidate</code> on the associated text component.
  *
  * @param child the child view
  * @param width true if the width preference has changed
  * @param height true if the height preference has changed
  * @see javax.swing.JComponent#revalidate
  */
 public void preferenceChanged(View child, boolean width, boolean height) {
   View parent = getParent();
   if (parent != null) {
     parent.preferenceChanged(this, width, height);
   }
 }