示例#1
0
  /**
   * Repaint the region of change covered by the given document event. Damages the line that begins
   * the range to cover the case when the insert/remove is only on one line. If lines are added or
   * removed, damages the whole view. The longest line is checked to see if it has changed.
   */
  protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f) {
    Component host = getContainer();
    updateMetrics();
    Element elem = getElement();
    DocumentEvent.ElementChange ec = changes.getChange(elem);
    Element[] added = (ec != null) ? ec.getChildrenAdded() : null;
    Element[] removed = (ec != null) ? ec.getChildrenRemoved() : null;
    if (((added != null) && (added.length > 0)) || ((removed != null) && (removed.length > 0))) {
      // lines were added or removed...
      if (added != null) {
        int addedAt = ec.getIndex(); // FIXME: Is this correct?????
        for (int i = 0; i < added.length; i++) possiblyUpdateLongLine(added[i], addedAt + i);
      }
      if (removed != null) {
        for (int i = 0; i < removed.length; i++) {
          if (removed[i] == longLine) {
            longLineWidth = -1; // Must do this!!
            calculateLongestLine();
            break;
          }
        }
      }
      preferenceChanged(null, true, true);
      host.repaint();
    }

    // This occurs when syntax highlighting only changes on lines
    // (i.e. beginning a multiline comment).
    else if (changes.getType() == DocumentEvent.EventType.CHANGE) {
      // System.err.println("Updating the damage due to a CHANGE event...");
      int startLine = changes.getOffset();
      int endLine = changes.getLength();
      damageLineRange(startLine, endLine, a, host);
    } else {
      Element map = getElement();
      int line = map.getElementIndex(changes.getOffset());
      damageLineRange(line, line, a, host);
      if (changes.getType() == DocumentEvent.EventType.INSERT) {
        // check to see if the line is longer than current
        // longest line.
        Element e = map.getElement(line);
        if (e == longLine) {
          // We must recalculate longest line's width here
          // because it has gotten longer.
          longLineWidth = getLineWidth(line);
          preferenceChanged(null, true, false);
        } else {
          // If long line gets updated, update the status bars too.
          if (possiblyUpdateLongLine(e, line)) preferenceChanged(null, true, false);
        }
      } else if (changes.getType() == DocumentEvent.EventType.REMOVE) {
        if (map.getElement(line) == longLine) {
          // removed from longest line... recalc
          longLineWidth = -1; // Must do this!
          calculateLongestLine();
          preferenceChanged(null, true, false);
        }
      }
    }
  }
示例#2
0
    /**
     * Calculates the preferred size dimensions for the specified panal given the components in the
     * specified parent container.
     */
    public Dimension preferredLayoutSize(Container target) {
      synchronized (target.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        int size = actions.size();
        if ((grip != null) && grip.isVisible()) {
          Dimension d = grip.getPreferredSize();
          dim.width += d.width;
          dim.width += hgap;
        }
        for (int i = 0; i < size; i++) {
          Component comp = (Component) actions.elementAt(i);
          if (comp.isVisible()) {
            Dimension d = comp.getPreferredSize();
            dim.width += d.width;
            dim.height = Math.max(dim.height, d.height);
            dim.width += hgap;
          }
        }
        Insets insets = target.getInsets();
        dim.width += insets.left + insets.right;
        dim.height += insets.top + insets.bottom;

        return dim;
      }
    }
示例#3
0
    public void layoutContainer(Container parent) {
      Dimension size = parent.getSize();
      Insets insets = parent.getInsets();
      int itop = insets.top;
      int ileft = insets.left;
      int ibottom = insets.bottom;
      int iright = insets.right;

      int rightWidth = right.getPreferredSize().width;
      int bottomHeight = bottom.getPreferredSize().height;
      int centerWidth = size.width - rightWidth - ileft - iright;
      int centerHeight = size.height - bottomHeight - itop - ibottom;

      center.setBounds(ileft, itop, centerWidth, centerHeight);

      right.setBounds(ileft + centerWidth, itop, rightWidth, centerHeight);

      // Lay out all status components, in order
      Enumeration status = leftOfScrollBar.elements();
      while (status.hasMoreElements()) {
        Component comp = (Component) status.nextElement();
        Dimension dim = comp.getPreferredSize();
        comp.setBounds(ileft, itop + centerHeight, dim.width, bottomHeight);
        ileft += dim.width;
      }

      bottom.setBounds(
          ileft, itop + centerHeight, size.width - rightWidth - ileft - iright, bottomHeight);
    }
示例#4
0
  @Override
  public int getRowHeight() {
    if (myRowHeightIsComputing) {
      return super.getRowHeight();
    }

    if (myRowHeight < 0) {
      try {
        myRowHeightIsComputing = true;
        for (int row = 0; row < getRowCount(); row++) {
          for (int column = 0; column < getColumnCount(); column++) {
            final TableCellRenderer renderer = getCellRenderer(row, column);
            if (renderer != null) {
              final Object value = getValueAt(row, column);
              final Component component =
                  renderer.getTableCellRendererComponent(this, value, true, true, row, column);
              if (component != null) {
                final Dimension size = component.getPreferredSize();
                myRowHeight = Math.max(size.height, myRowHeight);
              }
            }
          }
        }
      } finally {
        myRowHeightIsComputing = false;
      }
    }

    if (myMinRowHeight == null) {
      myMinRowHeight = getFontMetrics(UIManager.getFont("Label.font")).getHeight();
    }

    return Math.max(myRowHeight, myMinRowHeight);
  }
  public boolean editCellAt(int index, EventObject e) {
    if (editor != null && !editor.stopCellEditing()) return false;

    if (index < 0 || index >= getModel().getSize()) return false;

    if (!isCellEditable(index)) return false;

    if (editorRemover == null) {
      KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      editorRemover = new CellEditorRemover(fm);
      fm.addPropertyChangeListener("permanentFocusOwner", editorRemover); // NOI18N
    }

    if (editor != null && editor.isCellEditable(e)) {
      editorComp = prepareEditor(index);
      if (editorComp == null) {
        removeEditor();
        return false;
      }
      editorComp.setBounds(getCellBounds(index, index));
      add(editorComp);
      editorComp.validate();

      editingIndex = index;
      editor.addCellEditorListener(this);

      return true;
    }
    return false;
  }
示例#6
0
  private static Frame getFrame(Component c) {
    Component w = c;

    while (!(w instanceof Frame) && (w != null)) {
      w = w.getParent();
    }
    return (Frame) w;
  }
  /**
   * This method gets the width of a cell, specified by a column and row number.
   *
   * @param row The column number.
   * @param column The row number.
   * @return The width of the cell data.
   */
  private int getCellDataWidth(int row, int column) {
    //  Inovke the renderer for the cell to calculate the preferred width

    TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
    Component c = table.prepareRenderer(cellRenderer, row, column);
    int width = c.getPreferredSize().width + table.getIntercellSpacing().width;

    return width;
  }
 private int calcMaxContentColumnWidth(int columnIndex, int maxRowsToCheck) {
   int maxWidth = 0;
   for (int row = 0; row < maxRowsToCheck && row < getRowCount(); row++) {
     TableCellRenderer renderer = getCellRenderer(row, columnIndex);
     Component comp = prepareRenderer(renderer, row, columnIndex);
     maxWidth = Math.max(comp.getPreferredSize().width, maxWidth);
   }
   return maxWidth + UIUtil.DEFAULT_HGAP;
 }
示例#9
0
 /**
  * Repaint the given line range.
  *
  * @param line0 The starting line number to repaint. This must be a valid line number in the
  *     model.
  * @param line1 The ending line number to repaint. This must be a valid line number in the model.
  * @param a The region allocated for the view to render into.
  * @param host The component hosting the view (used to call repaint).
  */
 protected void damageLineRange(int line0, int line1, Shape a, Component host) {
   if (a != null) {
     Rectangle area0 = lineToRect(a, line0);
     Rectangle area1 = lineToRect(a, line1);
     if ((area0 != null) && (area1 != null)) {
       Rectangle dmg = area0.union(area1); // damage.
       host.repaint(dmg.x, dmg.y, dmg.width, dmg.height);
     } else host.repaint();
   }
 }
 protected void paintEditor(Graphics g) {
   Component component = grid.getEditorComponent();
   if (component == null) {
     return;
   }
   Rectangle cellBounds = grid.getCellBounds(grid.getEditingRow(), grid.getEditingColumn());
   component.setBounds(cellBounds);
   component.validate();
   component.requestFocus();
 }
示例#11
0
 /**
  * Gives notification from the document that attributes were changed in a location that this
  * view is responsible for.
  *
  * @param fv the <code>FlowView</code> containing the changes
  * @param e the <code>DocumentEvent</code> describing the changes done to the Document
  * @param alloc Bounds of the View
  * @see View#changedUpdate
  */
 public void changedUpdate(FlowView fv, DocumentEvent e, Rectangle alloc) {
   if (alloc != null) {
     Component host = fv.getContainer();
     if (host != null) {
       host.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
     }
   } else {
     fv.layoutChanged(View.X_AXIS);
     fv.layoutChanged(View.Y_AXIS);
   }
 }
 public void internalFrameClosed(InternalFrameEvent e) {
   Component cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     if (!((JInternalFrame) cont).isClosed()) {
       refreshMe();
     }
   }
 }
示例#13
0
  @Override
  public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    final Component result = super.prepareRenderer(renderer, row, column);
    final boolean selected =
        myExpandableItemsHandler.getExpandedItems().contains(new TableCell(row, column));

    // Fix GTK background
    if (UIUtil.isUnderGTKLookAndFeel()) {
      UIUtil.changeBackGround(this, UIUtil.getTreeTextBackground());
    }

    if (isTableDecorationSupported() && isStriped() && result instanceof JComponent) {
      final Color bg = row % 2 == 1 ? getBackground() : DECORATED_ROW_BG_COLOR;
      final JComponent c = (JComponent) result;
      final boolean cellSelected = isCellSelected(row, column);
      if (!cellSelected || (!hasFocus() && !getSelectionBackground().equals(c.getBackground()))) {
        c.setOpaque(true);
        c.setBackground(bg);
        for (Component child : c.getComponents()) {
          child.setBackground(bg);
        }
      }
    }

    if (!selected) return result;

    return new JComponent() {
      {
        add(result);
        setOpaque(false);
        setLayout(
            new AbstractLayoutManager() {
              @Override
              public Dimension preferredLayoutSize(Container parent) {
                return result.getPreferredSize();
              }

              @Override
              public void layoutContainer(Container parent) {
                Dimension size = parent.getSize();
                Insets i = parent.getInsets();
                Dimension pref = result.getPreferredSize();
                result.setBounds(
                    i.left,
                    i.top,
                    Math.max(pref.width, size.width - i.left - i.right),
                    size.height - i.top - i.bottom);
              }
            });
      }
    };
  }
  /**
   * Returns the component in the currently selected path which contains sourcePoint.
   *
   * @param source The component in whose coordinate space sourcePoint is given
   * @param sourcePoint The point which is being tested
   * @return The component in the currently selected path which contains sourcePoint (relative to
   *     the source component's coordinate space. If sourcePoint is not inside a component on the
   *     currently selected path, null is returned.
   */
  public Component componentForPoint(Component source, Point sourcePoint) {
    int screenX, screenY;
    Point p = sourcePoint;
    int i, c, j, d;
    Component mc;
    Rectangle r2;
    int cWidth, cHeight;
    MenuElement menuElement;
    MenuElement subElements[];
    Vector<MenuElement> tmp;
    int selectionSize;

    SwingUtilities.convertPointToScreen(p, source);

    screenX = p.x;
    screenY = p.y;

    tmp = (Vector<MenuElement>) selection.clone();
    selectionSize = tmp.size();
    for (i = selectionSize - 1; i >= 0; i--) {
      menuElement = (MenuElement) tmp.elementAt(i);
      subElements = menuElement.getSubElements();

      for (j = 0, d = subElements.length; j < d; j++) {
        if (subElements[j] == null) continue;
        mc = subElements[j].getComponent();
        if (!mc.isShowing()) continue;
        if (mc instanceof JComponent) {
          cWidth = mc.getWidth();
          cHeight = mc.getHeight();
        } else {
          r2 = mc.getBounds();
          cWidth = r2.width;
          cHeight = r2.height;
        }
        p.x = screenX;
        p.y = screenY;
        SwingUtilities.convertPointFromScreen(p, mc);

        /**
         * Return the deepest component on the selection path in whose bounds the event's point
         * occurs
         */
        if (p.x >= 0 && p.x < cWidth && p.y >= 0 && p.y < cHeight) {
          return mc;
        }
      }
    }
    return null;
  }
示例#15
0
 // Overridden for performance reasons. ---->
 @Override
 public boolean isOpaque() {
   Color back = getBackground();
   Component p = getParent();
   if (Objects.nonNull(p)) {
     p = p.getParent();
   } // p should now be the JTable.
   boolean colorMatch =
       Objects.nonNull(back)
           && Objects.nonNull(p)
           && back.equals(p.getBackground())
           && p.isOpaque();
   return !colorMatch && super.isOpaque();
 }
  /*
   *  Calculated the width based on the column name
   */
  private int getColumnHeaderWidth(int column) {
    if (!isColumnHeaderIncluded) return 0;

    TableColumn tableColumn = table.getColumnModel().getColumn(column);
    Object value = tableColumn.getHeaderValue();
    TableCellRenderer renderer = tableColumn.getHeaderRenderer();

    if (renderer == null) {
      renderer = table.getTableHeader().getDefaultRenderer();
    }

    Component c = renderer.getTableCellRendererComponent(table, value, false, false, -1, column);
    return c.getPreferredSize().width;
  }
示例#17
0
  public CreInvChecker(Component parent) {
    typeButtons = new JCheckBox[CHECKTYPES.length];
    JPanel boxPanel = new JPanel(new GridLayout(0, 1));
    for (int i = 0; i < typeButtons.length; i++) {
      typeButtons[i] = new JCheckBox(CHECKTYPES[i], true);
      boxPanel.add(typeButtons[i]);
    }
    bstart.setMnemonic('s');
    bcancel.setMnemonic('c');
    bstart.addActionListener(this);
    bcancel.addActionListener(this);
    selectframe.getRootPane().setDefaultButton(bstart);
    selectframe.setIconImage(Icons.getIcon("Find16.gif").getImage());
    boxPanel.setBorder(BorderFactory.createTitledBorder("Select test to check:"));

    JPanel bpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    bpanel.add(bstart);
    bpanel.add(bcancel);

    JPanel mainpanel = new JPanel(new BorderLayout());
    mainpanel.add(boxPanel, BorderLayout.CENTER);
    mainpanel.add(bpanel, BorderLayout.SOUTH);
    mainpanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));

    JPanel pane = (JPanel) selectframe.getContentPane();
    pane.setLayout(new BorderLayout());
    pane.add(mainpanel, BorderLayout.CENTER);

    selectframe.pack();
    Center.center(selectframe, parent.getBounds());
    selectframe.setVisible(true);
  }
示例#18
0
  /**
   * Displays the popup menu at the position x,y in the coordinate space of the component invoker.
   *
   * @param invoker the component in whose space the popup menu is to appear
   * @param x the x coordinate in invoker's coordinate space at which the popup menu is to be
   *     displayed
   * @param y the y coordinate in invoker's coordinate space at which the popup menu is to be
   *     displayed
   */
  public void show(Component invoker, int x, int y) {
    if (DEBUG) {
      System.out.println("in JPopupMenu.show ");
    }
    setInvoker(invoker);
    Frame newFrame = getFrame(invoker);
    if (newFrame != frame) {
      // Use the invoker's frame so that events
      // are propagated properly
      if (newFrame != null) {
        this.frame = newFrame;
        if (popup != null) {
          setVisible(false);
        }
      }
    }
    Point invokerOrigin;
    if (invoker != null) {
      invokerOrigin = invoker.getLocationOnScreen();

      // To avoid integer overflow
      long lx, ly;
      lx = ((long) invokerOrigin.x) + ((long) x);
      ly = ((long) invokerOrigin.y) + ((long) y);
      if (lx > Integer.MAX_VALUE) lx = Integer.MAX_VALUE;
      if (lx < Integer.MIN_VALUE) lx = Integer.MIN_VALUE;
      if (ly > Integer.MAX_VALUE) ly = Integer.MAX_VALUE;
      if (ly < Integer.MIN_VALUE) ly = Integer.MIN_VALUE;

      setLocation((int) lx, (int) ly);
    } else {
      setLocation(x, y);
    }
    setVisible(true);
  }
 /**
  * Iterate over the lines represented by the child elements of the element this view represents,
  * looking for the line that is the longest. The <em>longLine</em> variable is updated to
  * represent the longest line contained. The <em>font</em> variable is updated to indicate the
  * font used to calculate the longest line.
  */
 void calculateLongestLine() {
   Component c = getContainer();
   font = c.getFont();
   metrics = c.getFontMetrics(font);
   tabSize = getTabSize() * metrics.charWidth(' ');
   Element lines = getElement();
   int n = lines.getElementCount();
   for (int i = 0; i < n; i++) {
     Element line = lines.getElement(i);
     float w = getLineWidth(i);
     if (w > longLineWidth) {
       longLineWidth = w;
       longLine = line;
     }
   }
 }
  /*
   *	Tab has changed. Focus on saved component for the given tab.
   *  When there is no saved component, focus on the first component.
   */
  public void stateChanged(ChangeEvent e) {
    Component key = tabbedPane.getComponentAt(tabbedPane.getSelectedIndex());

    if (key == null) return;

    Component value = tabFocus.get(key);

    //  First time selecting this tab or focus policy is RESET_FOCUS

    if (value == null) {
      key.transferFocus();
      tabFocus.put(key, value);
    } else //  Use the saved component for focusing
    {
      value.requestFocusInWindow();
    }
  }
 /* Repost event to dispatchComponent */
 private boolean repostEvent(MouseEvent e) {
   if (dispatchComponent == null) {
     return false;
   }
   MouseEvent editorMouseEvent = SwingUtilities.convertMouseEvent(grid, e, dispatchComponent);
   dispatchComponent.dispatchEvent(editorMouseEvent);
   return true;
 }
 public void actionPerformed(ActionEvent e) {
   JGrid grid = (JGrid) e.getSource();
   if (!grid.hasFocus()) {
     CellEditor cellEditor = grid.getCurrentCellEditor();
     if (cellEditor != null && !cellEditor.stopCellEditing()) {
       return;
     }
     grid.requestFocus();
   }
   SelectionModel selectionModel = grid.getSelectionModel();
   int anchorRow = selectionModel.getAnchorRow();
   int anchorColumn = selectionModel.getAnchorColumn();
   grid.editCellAt(anchorRow, anchorColumn, null);
   Component editorComp = grid.getEditorComponent();
   if (editorComp != null) {
     editorComp.requestFocus();
   }
 }
 public void actionPerformed(ActionEvent e) {
   JListMutable list = (JListMutable) e.getSource();
   if (!list.hasFocus()) {
     CellEditor cellEditor = list.getListCellEditor();
     if (cellEditor != null && !cellEditor.stopCellEditing()) {
       return;
     }
     list.requestFocus();
     return;
   }
   ListSelectionModel rsm = list.getSelectionModel();
   int anchorRow = rsm.getAnchorSelectionIndex();
   list.editCellAt(anchorRow, null);
   Component editorComp = list.getEditorComponent();
   if (editorComp != null) {
     editorComp.requestFocus();
   }
 }
 private boolean repostEvent(MouseEvent e) {
   // Check for isEditing() in case another event has
   // caused the editor to be removed. See bug #4306499.
   if (dispatchComponent == null || !isEditing()) {
     return false;
   }
   MouseEvent e2 = SwingUtilities.convertMouseEvent(JListMutable.this, e, dispatchComponent);
   dispatchComponent.dispatchEvent(e2);
   return true;
 }
示例#25
0
    /** Lays out the container in the specified panel. */
    public void layoutContainer(Container target) {
      synchronized (target.getTreeLock()) {
        Insets insets = target.getInsets();
        Dimension dim = target.getSize();

        int fullHeight = dim.height;
        int bottom = dim.height - insets.bottom - 1;
        int top = 0 + insets.top;
        int left = insets.left;
        int maxPosition = dim.width - (insets.left + insets.right) - hgap;
        int right = dim.width - insets.right;
        maxPosition = right;
        int height = bottom - top;
        int size = actions.size();
        int w, h;
        if ((grip != null) && grip.isVisible()) {
          Dimension d = grip.getPreferredSize();
          grip.setBounds(left, top + vgap, d.width, bottom - top - 2 * vgap);
          left += d.width;
          left += hgap;
        }
        for (int i = 0; i < size; i++) {
          left += hgap;
          Component comp = (Component) actions.elementAt(i);
          Dimension d;
          Dimension minSize = comp.getMinimumSize();

          if (i == size - 1) d = comp.getMaximumSize();
          else d = comp.getPreferredSize();
          w = d.width;
          h = Math.min(height, d.height);
          if ((left < maxPosition) && (left + w > maxPosition)) {
            if (maxPosition - left >= minSize.width) w = maxPosition - left;
          }

          comp.setBounds(left, (fullHeight - d.height) / 2, w, h);

          //  	  if (i == size - 1)
          //  	    d = comp.getMaximumSize();
          //  	  else
          //  	    d = comp.getPreferredSize();
          //  	  if ((left + d.width) > right)
          //  	    w = right - left;
          //  	  else
          //  	    w = d.width;
          //  	  h = Math.min (height, d.height);
          //  	  comp.setBounds (left, (fullHeight - d.height)/2, w, h);

          left += d.width;
        }
      }
    }
示例#26
0
 /** Adds the specified component with the specified name to the layout. */
 public void addLayoutComponent(String name, Component comp) {
   synchronized (comp.getTreeLock()) {
     if ("Grip".equals(name)) { // NOI18N
       grip = comp;
     } else if ("Action".equals(name)) { // NOI18N
       actions.addElement(comp);
     } else
       throw new IllegalArgumentException(
           "cannot add to layout: unknown constraint: " + name); // NOI18N
   }
 }
示例#27
0
 private void handleDocumentEvent(DocumentEvent e, Shape a, ViewFactory f) {
   int n = calculateLineCount();
   if (this.nlines != n) {
     this.nlines = n;
     WrappedSyntaxView.this.preferenceChanged(this, false, true);
     // have to repaint any views after the receiver.
     RSyntaxTextArea textArea = (RSyntaxTextArea) getContainer();
     textArea.repaint();
     // Must also revalidate container so gutter components, such
     // as line numbers, get updated for this line's new height
     Gutter gutter = RSyntaxUtilities.getGutter(textArea);
     if (gutter != null) {
       gutter.revalidate();
       gutter.repaint();
     }
   } else if (a != null) {
     Component c = getContainer();
     Rectangle alloc = (Rectangle) a;
     c.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
   }
 }
    public void propertyChange(PropertyChangeEvent ev) {
      if (!isEditing() || getClientProperty("terminateEditOnFocusLost") != Boolean.TRUE) { // NOI18N
        return;
      }

      Component c = focusManager.getPermanentFocusOwner();
      while (c != null) {
        if (c == JListMutable.this) {
          // focus remains inside the table
          return;
        } else if ((c instanceof Window) || (c instanceof Applet && c.getParent() == null)) {
          if (c == SwingUtilities.getRoot(JListMutable.this)) {
            if (!getListCellEditor().stopCellEditing()) {
              getListCellEditor().cancelCellEditing();
            }
          }
          break;
        }
        c = c.getParent();
      }
    }
  /**
   * If inputComponent is non-null, the focus is requested on that, otherwise request focus on the
   * default value
   */
  public void selectInitialValue(JOptionPane op) {
    if (inputComponent != null) inputComponent.requestFocus();
    else {
      if (initialFocusComponent != null) initialFocusComponent.requestFocus();

      if (initialFocusComponent instanceof JButton) {
        JRootPane root = SwingUtilities.getRootPane(initialFocusComponent);
        if (root != null) {
          root.setDefaultButton((JButton) initialFocusComponent);
        }
      }
    }
  }
示例#30
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);
  }