bugged
stringlengths
6
599k
fixed
stringlengths
6
40.8M
__index_level_0__
int64
0
3.24M
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
1,599
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
1,600
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
1,601
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
1,602
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
1,603
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
1,604
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
public void setSelectedPath(MenuElement[] path) { if (path == null) { clearSelectedPath(); return; } int i; int minSize = path.length; // size of the smaller path. if (path.length > selectedPath.size()) { minSize = selectedPath.size(); // if new selected path contains more elements then current // selection then first add all elements at // the indexes > selectedPath.size for (i = selectedPath.size(); i < path.length; i++) { selectedPath.add(path[i]); path[i].menuSelectionChanged(true); } } else if (path.length < selectedPath.size()) { // if new selected path contains less elements then current // selection then first remove all elements from the selection // at the indexes > path.length for (i = selectedPath.size() - 1; i >= path.length; i--) { ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false); selectedPath.remove(i); } minSize = path.length; } // Now compare elements in new and current selection path at the // same location and adjust selection until // same menu elements will be encountered at the // same index in both current and new selection path. MenuElement oldSelectedItem; for (i = minSize - 1; i >= 0; i--) { oldSelectedItem = (MenuElement) selectedPath.get(i); if (path[i].equals(oldSelectedItem)) break; oldSelectedItem.menuSelectionChanged(false); path[i].menuSelectionChanged(true); selectedPath.setElementAt(path[i], i); } fireStateChanged(); }
1,605
public void setSelected(boolean selected) { // if this menu selection is true, then activate this menu and // display popup associated with this menu if (selected) { super.setArmed(true); super.setSelected(true); // FIXME: The popup menu should be shown on the screen after certain // number of seconds pass. The 'delay' property of this menu indicates // this amount of seconds. 'delay' property is 0 by default. if (this.isShowing()) { fireMenuSelected(); int x = 0; int y = 0; if (menuLocation == null) { // Calculate correct position of the popup. Note that location of the popup // passed to show() should be relative to the popup's invoker if (isTopLevelMenu()) y = this.getHeight(); else x = this.getWidth(); getPopupMenu().show(this, x, y); } else getPopupMenu().show(this, menuLocation.x, menuLocation.y); } } else { super.setSelected(false); super.setArmed(false); fireMenuDeselected(); popupMenu.setVisible(false); } }
public void setSelected(boolean selected) { // if this menu selection is true, then activate this menu and // display popup associated with this menu if (selected && isEnabled()) { super.setArmed(true); super.setSelected(true); // FIXME: The popup menu should be shown on the screen after certain // number of seconds pass. The 'delay' property of this menu indicates // this amount of seconds. 'delay' property is 0 by default. if (this.isShowing()) { fireMenuSelected(); int x = 0; int y = 0; if (menuLocation == null) { // Calculate correct position of the popup. Note that location of the popup // passed to show() should be relative to the popup's invoker if (isTopLevelMenu()) y = this.getHeight(); else x = this.getWidth(); getPopupMenu().show(this, x, y); } else getPopupMenu().show(this, menuLocation.x, menuLocation.y); } } else { super.setSelected(false); super.setArmed(false); fireMenuDeselected(); popupMenu.setVisible(false); } }
1,606
public void setSelected(boolean selected) { // if this menu selection is true, then activate this menu and // display popup associated with this menu if (selected) { super.setArmed(true); super.setSelected(true); // FIXME: The popup menu should be shown on the screen after certain // number of seconds pass. The 'delay' property of this menu indicates // this amount of seconds. 'delay' property is 0 by default. if (this.isShowing()) { fireMenuSelected(); int x = 0; int y = 0; if (menuLocation == null) { // Calculate correct position of the popup. Note that location of the popup // passed to show() should be relative to the popup's invoker if (isTopLevelMenu()) y = this.getHeight(); else x = this.getWidth(); getPopupMenu().show(this, x, y); } else getPopupMenu().show(this, menuLocation.x, menuLocation.y); } } else { super.setSelected(false); super.setArmed(false); fireMenuDeselected(); popupMenu.setVisible(false); } }
public void setSelected(boolean selected) { // if this menu selection is true, then activate this menu and // display popup associated with this menu if (selected) { super.setArmed(true); super.setSelected(true); // FIXME: The popup menu should be shown on the screen after certain // number of seconds pass. The 'delay' property of this menu indicates // this amount of seconds. 'delay' property is 0 by default. if (this.isShowing()) { fireMenuSelected(); int x = 0; int y = 0; if (menuLocation == null) { // Calculate correct position of the popup. Note that location of the popup // passed to show() should be relative to the popup's invoker if (isTopLevelMenu()) y = this.getHeight(); else x = this.getWidth(); getPopupMenu().show(this, x, y); } else getPopupMenu().show(this, menuLocation.x, menuLocation.y); } } else { super.setSelected(false); super.setArmed(false); fireMenuDeselected(); popupMenu.setVisible(false); } }
1,607
public WindowBar() { this.list = new JList(); this.model = new DefaultListModel(); this.wrappers = new HashMap<JInternalFrame, FrameWrapper>(); list.setModel(model); add(list, BorderLayout.CENTER); }
public WindowBar() { this.list = new JList(); this.model = new DefaultListModel(); this.wrappers = new HashMap<JInternalFrame, FrameWrapper>(); list.setModel(model); add(list, BorderLayout.CENTER); }
1,608
public String toString() { if (compiledCode1 instanceof byte[]) { return NumberUtils.hex((byte[])compiledCode1); } else { return super.toString(); } }
public String toString() { if (compiledCode1 instanceof byte[]) { return NumberUtils.hex((byte[])compiledCode1); } else { return super.toString(); } }
1,609
public void addItem(Object element) { if (dataModel instanceof MutableComboBoxModel) ((MutableComboBoxModel) dataModel).addElement(element); else throw new RuntimeException("Unable to add the item because the data " + "model it is not an instance of " + "MutableComboBoxModel."); }
public void addItem(Object element) { if (dataModel instanceof MutableComboBoxModel) ((MutableComboBoxModel) dataModel).addElement(element); else throw new RuntimeException("Unable to add the item because the data " + "model it is not an instance of " + "MutableComboBoxModel."); }
1,610
protected void configurePropertiesFromAction(Action a) { if (a == null) { setEnabled(true); setToolTipText(null); } else { setEnabled(a.isEnabled()); setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION))); } }
protected void configurePropertiesFromAction(Action a) { if (a == null) { setEnabled(true); setToolTipText(null); } else { setEnabled(a.isEnabled()); setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION))); } }
1,611
protected void configurePropertiesFromAction(Action a) { if (a == null) { setEnabled(true); setToolTipText(null); } else { setEnabled(a.isEnabled()); setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION))); } }
protected void configurePropertiesFromAction(Action a) { if (a == null) { setEnabled(true); setToolTipText(null); } else { setEnabled(a.isEnabled()); setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION))); } }
1,612
protected PropertyChangeListener createActionPropertyChangeListener(Action action) { return new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Action act = (Action) (e.getSource()); configurePropertiesFromAction(act); } }; }
protected PropertyChangeListener createActionPropertyChangeListener(Action action) { return new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Action act = (Action) (e.getSource()); configurePropertiesFromAction(act); } }; }
1,613
public void propertyChange(PropertyChangeEvent e) { Action act = (Action) (e.getSource()); configurePropertiesFromAction(act); }
public void propertyChange(PropertyChangeEvent e) { Action act = (Action) (e.getSource()); configurePropertiesFromAction(act); }
1,614
public AccessibleContext getAccessibleContext() { if (accessibleContext == null) accessibleContext = new AccessibleJComboBox(); return accessibleContext; }
public AccessibleContext getAccessibleContext() { if (accessibleContext == null) accessibleContext = new AccessibleJComboBox(); return accessibleContext; }
1,615
public int getSelectedIndex() { Object selectedItem = getSelectedItem(); if (selectedItem != null) { if (dataModel instanceof DefaultComboBoxModel) // Uses special method of DefaultComboBoxModel to retrieve the index. return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); else { // Iterates over all items to retrieve the index. int size = dataModel.getSize(); for (int i = 0; i < size; i++) { Object o = dataModel.getElementAt(i); // XXX: Is special handling of ComparableS neccessary? if ((selectedItem != null) ? selectedItem.equals(o) : o == null) return i; } } } // returns that no item is currently selected return -1; }
public int getSelectedIndex() { Object selectedItem = getSelectedItem(); if (selectedItem != null) { if (dataModel instanceof DefaultComboBoxModel) // Uses special method of DefaultComboBoxModel to retrieve the index. return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); else { // Iterates over all items to retrieve the index. int size = dataModel.getSize(); for (int i = 0; i < size; i++) { Object o = dataModel.getElementAt(i); // XXX: Is special handling of ComparableS neccessary? if ((selectedItem != null) ? selectedItem.equals(o) : o == null) return i; } } } // returns that no item is currently selected return -1; }
1,616
public int getSelectedIndex() { Object selectedItem = getSelectedItem(); if (selectedItem != null) { if (dataModel instanceof DefaultComboBoxModel) // Uses special method of DefaultComboBoxModel to retrieve the index. return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); else { // Iterates over all items to retrieve the index. int size = dataModel.getSize(); for (int i = 0; i < size; i++) { Object o = dataModel.getElementAt(i); // XXX: Is special handling of ComparableS neccessary? if ((selectedItem != null) ? selectedItem.equals(o) : o == null) return i; } } } // returns that no item is currently selected return -1; }
public int getSelectedIndex() { Object selectedItem = getSelectedItem(); if (selectedItem != null) { if (dataModel instanceof DefaultComboBoxModel) // Uses special method of DefaultComboBoxModel to retrieve the index. return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); else { // Iterates over all items to retrieve the index. int size = dataModel.getSize(); for (int i = 0; i < size; i++) { Object o = dataModel.getElementAt(i); // XXX: Is special handling of ComparableS neccessary? if ((selectedItem != null) ? selectedItem.equals(o) : o == null) return i; } } } // returns that no item is currently selected return -1; }
1,617
public int getSelectedIndex() { Object selectedItem = getSelectedItem(); if (selectedItem != null) { if (dataModel instanceof DefaultComboBoxModel) // Uses special method of DefaultComboBoxModel to retrieve the index. return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); else { // Iterates over all items to retrieve the index. int size = dataModel.getSize(); for (int i = 0; i < size; i++) { Object o = dataModel.getElementAt(i); // XXX: Is special handling of ComparableS neccessary? if ((selectedItem != null) ? selectedItem.equals(o) : o == null) return i; } } } // returns that no item is currently selected return -1; }
public int getSelectedIndex() { Object selectedItem = getSelectedItem(); if (selectedItem != null) { if (dataModel instanceof DefaultComboBoxModel) // Uses special method of DefaultComboBoxModel to retrieve the index. return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); else { // Iterates over all items to retrieve the index. int size = dataModel.getSize(); for (int i = 0; i < size; i++) { Object o = dataModel.getElementAt(i); // XXX: Is special handling of ComparableS neccessary? if ((selectedItem != null) ? selectedItem.equals(o) : o == null) return i; } } } // returns that no item is currently selected return -1; }
1,618
public int getSelectedIndex() { Object selectedItem = getSelectedItem(); if (selectedItem != null) { if (dataModel instanceof DefaultComboBoxModel) // Uses special method of DefaultComboBoxModel to retrieve the index. return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); else { // Iterates over all items to retrieve the index. int size = dataModel.getSize(); for (int i = 0; i < size; i++) { Object o = dataModel.getElementAt(i); // XXX: Is special handling of ComparableS neccessary? if ((selectedItem != null) ? selectedItem.equals(o) : o == null) return i; } } } // returns that no item is currently selected return -1; }
public int getSelectedIndex() { Object selectedItem = getSelectedItem(); if (selectedItem != null) { if (dataModel instanceof DefaultComboBoxModel) // Uses special method of DefaultComboBoxModel to retrieve the index. return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); else { // Iterates over all items to retrieve the index. int size = dataModel.getSize(); for (int i = 0; i < size; i++) { Object o = dataModel.getElementAt(i); // XXX: Is special handling of ComparableS neccessary? if ((selectedItem != null) ? selectedItem.equals(o) : o == null) return i; } } } // returns that no item is currently selected return -1; }
1,619
public int getSelectedIndex() { Object selectedItem = getSelectedItem(); if (selectedItem != null) { if (dataModel instanceof DefaultComboBoxModel) // Uses special method of DefaultComboBoxModel to retrieve the index. return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); else { // Iterates over all items to retrieve the index. int size = dataModel.getSize(); for (int i = 0; i < size; i++) { Object o = dataModel.getElementAt(i); // XXX: Is special handling of ComparableS neccessary? if ((selectedItem != null) ? selectedItem.equals(o) : o == null) return i; } } } // returns that no item is currently selected return -1; }
public int getSelectedIndex() { Object selectedItem = getSelectedItem(); if (selectedItem != null) { if (dataModel instanceof DefaultComboBoxModel) // Uses special method of DefaultComboBoxModel to retrieve the index. return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); else { // Iterates over all items to retrieve the index. int size = dataModel.getSize(); for (int i = 0; i < size; i++) { Object o = dataModel.getElementAt(i); // XXX: Is special handling of ComparableS neccessary? if ((selectedItem != null) ? selectedItem.equals(o) : o == null) return i; } } } // returns that no item is currently selected return -1; }
1,620
public ComboBoxUI getUI() { return (ComboBoxUI) ui; }
public ComboBoxUI getUI() { return (ComboBoxUI) ui; }
1,621
public void insertItemAt(Object element, int index) { if (dataModel instanceof MutableComboBoxModel) ((MutableComboBoxModel) dataModel).insertElementAt(element, index); else throw new RuntimeException("Unable to insert the item because the data " + "model it is not an instance of " + "MutableComboBoxModel."); }
public void insertItemAt(Object element, int index) { if (dataModel instanceof MutableComboBoxModel) ((MutableComboBoxModel) dataModel).insertElementAt(element, index); else throw new RuntimeException("Unable to insert the item because the data " + "model it is not an instance of " + "MutableComboBoxModel."); }
1,622
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); else if (dataModel instanceof MutableComboBoxModel) { // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; // We intentionally remove the items backwards to support models which // shift their content to the beginning (e.g. linked lists) for (int i = mcbm.getSize() - 1; i >= 0; i--) mcbm.removeElementAt(i); } else throw new RuntimeException("Unable to remove the items because the data " +"model it is not an instance of " + "MutableComboBoxModel."); }
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); else if (dataModel instanceof MutableComboBoxModel) { // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; // We intentionally remove the items backwards to support models which // shift their content to the beginning (e.g. linked lists) for (int i = mcbm.getSize() - 1; i >= 0; i--) mcbm.removeElementAt(i); } else throw new RuntimeException("Unable to remove the items because the data " +"model it is not an instance of " + "MutableComboBoxModel."); }
1,623
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); else if (dataModel instanceof MutableComboBoxModel) { // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; // We intentionally remove the items backwards to support models which // shift their content to the beginning (e.g. linked lists) for (int i = mcbm.getSize() - 1; i >= 0; i--) mcbm.removeElementAt(i); } else throw new RuntimeException("Unable to remove the items because the data " +"model it is not an instance of " + "MutableComboBoxModel."); }
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); else if (dataModel instanceof MutableComboBoxModel) { // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; // We intentionally remove the items backwards to support models which // shift their content to the beginning (e.g. linked lists) for (int i = mcbm.getSize() - 1; i >= 0; i--) mcbm.removeElementAt(i); } else throw new RuntimeException("Unable to remove the items because the data " +"model it is not an instance of " + "MutableComboBoxModel."); }
1,624
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); else if (dataModel instanceof MutableComboBoxModel) { // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; // We intentionally remove the items backwards to support models which // shift their content to the beginning (e.g. linked lists) for (int i = mcbm.getSize() - 1; i >= 0; i--) mcbm.removeElementAt(i); } else throw new RuntimeException("Unable to remove the items because the data " +"model it is not an instance of " + "MutableComboBoxModel."); }
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); else if (dataModel instanceof MutableComboBoxModel) { // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; // We intentionally remove the items backwards to support models which // shift their content to the beginning (e.g. linked lists) for (int i = mcbm.getSize() - 1; i >= 0; i--) mcbm.removeElementAt(i); } else throw new RuntimeException("Unable to remove the items because the data " +"model it is not an instance of " + "MutableComboBoxModel."); }
1,625
public void removeItem(Object element) { if (dataModel instanceof MutableComboBoxModel) ((MutableComboBoxModel) dataModel).removeElement(element); else throw new RuntimeException("Unable to remove the item because the data " + "model it is not an instance of " + "MutableComboBoxModel."); }
public void removeItem(Object element) { if (dataModel instanceof MutableComboBoxModel) ((MutableComboBoxModel) dataModel).removeElement(element); else throw new RuntimeException("Unable to remove the item because the data " + "model it is not an instance of " + "MutableComboBoxModel."); }
1,626
public void removeItemAt(int index) { if (dataModel instanceof MutableComboBoxModel) ((MutableComboBoxModel) dataModel).removeElementAt(index); else throw new RuntimeException("Unable to remove the item because the data " + "model it is not an instance of " + "MutableComboBoxModel."); }
public void removeItemAt(int index) { if (dataModel instanceof MutableComboBoxModel) ((MutableComboBoxModel) dataModel).removeElementAt(index); else throw new RuntimeException("Unable to remove the item because the data " + "model it is not an instance of " + "MutableComboBoxModel."); }
1,627
public void setEditable(boolean editable) { if (isEditable != editable) { isEditable = editable; firePropertyChange("editable", !isEditable, isEditable); } }
public void setEditable(boolean editable) { if (isEditable != editable) { isEditable = editable; firePropertyChange("editable", !isEditable, isEditable); } }
1,628
public void setEnabled(boolean enabled) { boolean oldEnabled = super.isEnabled(); if (enabled != oldEnabled) { super.setEnabled(enabled); firePropertyChange("enabled", oldEnabled, enabled); } }
public void setEnabled(boolean enabled) { boolean oldEnabled = super.isEnabled(); if (enabled != oldEnabled) { super.setEnabled(enabled); firePropertyChange("enabled", oldEnabled, enabled); } }
1,629
public void setMaximumRowCount(int rowCount) { if (maximumRowCount != rowCount) { int oldMaximumRowCount = maximumRowCount; maximumRowCount = rowCount; firePropertyChange("maximumRowCount", oldMaximumRowCount, maximumRowCount); } }
public void setMaximumRowCount(int rowCount) { if (maximumRowCount != rowCount) { int oldMaximumRowCount = maximumRowCount; maximumRowCount = rowCount; firePropertyChange("maximumRowCount", oldMaximumRowCount, maximumRowCount); } }
1,630
public void setModel(ComboBoxModel newDataModel) { // dataModel is null if it this method is called from inside the constructors. if (dataModel != null) { // Prevents unneccessary updates. if (dataModel == newDataModel) return; // Removes itself (as DataListener) from the to-be-replaced model. dataModel.removeListDataListener(this); } /* Adds itself as a DataListener to the new model. * It is intentioned that this operation will fail with a NullPointerException if the * caller delivered a null argument. */ newDataModel.addListDataListener(this); // Stores old data model for event notification. ComboBoxModel oldDataModel = dataModel; dataModel = newDataModel; // Notifies the listeners of the model change. firePropertyChange("model", oldDataModel, dataModel); }
public void setModel(ComboBoxModel newDataModel) { // dataModel is null if it this method is called from inside the constructors. if (dataModel != null) { // Prevents unneccessary updates. if (dataModel == newDataModel) return; // Removes itself (as DataListener) from the to-be-replaced model. dataModel.removeListDataListener(this); } /* Adds itself as a DataListener to the new model. * It is intentioned that this operation will fail with a NullPointerException if the * caller delivered a null argument. */ newDataModel.addListDataListener(this); // Stores old data model for event notification. ComboBoxModel oldDataModel = dataModel; dataModel = newDataModel; // Notifies the listeners of the model change. firePropertyChange("model", oldDataModel, dataModel); }
1,631
public void setModel(ComboBoxModel newDataModel) { // dataModel is null if it this method is called from inside the constructors. if (dataModel != null) { // Prevents unneccessary updates. if (dataModel == newDataModel) return; // Removes itself (as DataListener) from the to-be-replaced model. dataModel.removeListDataListener(this); } /* Adds itself as a DataListener to the new model. * It is intentioned that this operation will fail with a NullPointerException if the * caller delivered a null argument. */ newDataModel.addListDataListener(this); // Stores old data model for event notification. ComboBoxModel oldDataModel = dataModel; dataModel = newDataModel; // Notifies the listeners of the model change. firePropertyChange("model", oldDataModel, dataModel); }
public void setModel(ComboBoxModel newDataModel) { // dataModel is null if it this method is called from inside the constructors. if (dataModel != null) { // Prevents unneccessary updates. if (dataModel == newDataModel) return; // Removes itself (as DataListener) from the to-be-replaced model. dataModel.removeListDataListener(this); } /* Adds itself as a DataListener to the new model. * It is intentioned that this operation will fail with a NullPointerException if the * caller delivered a null argument. */ newDataModel.addListDataListener(this); // Stores old data model for event notification. ComboBoxModel oldDataModel = dataModel; dataModel = newDataModel; // Notifies the listeners of the model change. firePropertyChange("model", oldDataModel, dataModel); }
1,632
public void setPrototypeDisplayValue(Object newPrototypeDisplayValue) { prototypeDisplayValue = newPrototypeDisplayValue; }
public void setPrototypeDisplayValue(Object value) { prototypeDisplayValue = newPrototypeDisplayValue; }
1,633
public void setPrototypeDisplayValue(Object newPrototypeDisplayValue) { prototypeDisplayValue = newPrototypeDisplayValue; }
public void setPrototypeDisplayValue(Object newPrototypeDisplayValue) { Object oldValue = prototypeDisplayValue; prototypeDisplayValue = value; firePropertyChange("prototypeDisplayValue", oldValue, value); }
1,634
public void setRenderer(ListCellRenderer aRenderer) { if (renderer != aRenderer) { ListCellRenderer oldRenderer = renderer; renderer = aRenderer; firePropertyChange("renderer", oldRenderer, renderer); } }
public void setRenderer(ListCellRenderer aRenderer) { if (renderer != aRenderer) { ListCellRenderer oldRenderer = renderer; renderer = aRenderer; firePropertyChange("renderer", oldRenderer, renderer); } }
1,635
public void setSelectedIndex(int index) { if (index < -1 || index >= dataModel.getSize()) // Fails because index is out of bounds. throw new IllegalArgumentException("illegal index: " + index); else // Selects the item at the given index or clears the selection if the // index value is -1. setSelectedItem((index == -1) ? null : dataModel.getElementAt(index)); }
public void setSelectedIndex(int index) { if (index < -1 || index >= dataModel.getSize()) // Fails because index is out of bounds. throw new IllegalArgumentException("illegal index: " + index); else // Selects the item at the given index or clears the selection if the // index value is -1. setSelectedItem((index == -1) ? null : dataModel.getElementAt(index)); }
1,636
public void setSelectedIndex(int index) { if (index < -1 || index >= dataModel.getSize()) // Fails because index is out of bounds. throw new IllegalArgumentException("illegal index: " + index); else // Selects the item at the given index or clears the selection if the // index value is -1. setSelectedItem((index == -1) ? null : dataModel.getElementAt(index)); }
public void setSelectedIndex(int index) { if (index < -1 || index >= dataModel.getSize()) // Fails because index is out of bounds. throw new IllegalArgumentException("illegal index: " + index); else // Selects the item at the given index or clears the selection if the // index value is -1. setSelectedItem((index == -1) ? null : dataModel.getElementAt(index)); }
1,637
public void setUI(ComboBoxUI ui) { super.setUI(ui); }
public void setUI(ComboBoxUI ui) { super.setUI(ui); }
1,638
public void updateUI() { setUI((ComboBoxUI) UIManager.getUI(this)); invalidate(); }
public void updateUI() { setUI((ComboBoxUI) UIManager.getUI(this)); invalidate(); }
1,639
public DefaultComboBoxModel(Object[] items) { list = new Vector(Arrays.asList(items)); }
public DefaultComboBoxModel() { list = new Vector(Arrays.asList(items)); }
1,640
public DefaultComboBoxModel(Object[] items) { list = new Vector(Arrays.asList(items)); }
public DefaultComboBoxModel(Object[] items) { list = new Vector(); }
1,641
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Boolean(oldValue), new Boolean(newValue)); }
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Boolean(oldValue), new Boolean(newValue)); }
1,642
public SwingPropertyChangeSupport(Object source) { super(source); this.source = source; this.listeners = new EventListenerList(); this.propertyListeners = new Hashtable(); }
public SwingPropertyChangeSupport(Object source) { super(source); this.source = source; this.listeners = new EventListenerList(); this.propertyListeners = new HashMap(); }
1,643
public void setRect(double x, double y, double width, double height) { this.x = (int) x; this.y = (int) y; this.width = (int) width; this.height = (int) height; }
public void setRect(double x, double y, double width, double height) { this.x = (int) x; this.y = (int) y; this.width = (int) width; this.height = (int) height; }
1,644
public PropertyChangeListener[] getPropertyChangeListeners(String property) { return changeSupport == null ? new PropertyChangeListener[0] : changeSupport.getPropertyChangeListeners(property); }
public PropertyChangeListener[] getPropertyChangeListeners() { return changeSupport == null ? new PropertyChangeListener[0] : changeSupport.getPropertyChangeListeners(property); }
1,645
public PropertyChangeListener[] getPropertyChangeListeners(String property) { return changeSupport == null ? new PropertyChangeListener[0] : changeSupport.getPropertyChangeListeners(property); }
public PropertyChangeListener[] getPropertyChangeListeners(String property) { return changeSupport == null ? new PropertyChangeListener[0] : changeSupport.getPropertyChangeListeners(property); }
1,646
public synchronized PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { EventListenerList list = (EventListenerList) propertyListeners.get(propertyName); if (list == null) return getPropertyChangeListeners(); int size = listeners.getListenerCount() + list.getListenerCount(); PropertyChangeListener[] result = new PropertyChangeListener[size]; // copy in the general listeners int index = 0; for (int i = 0; i < listeners.listenerList.length; i += 2) { result[index++] = (PropertyChangeListener) listeners.listenerList[i + 1]; } // copy in the specific listeners Object[] specificListeners = list.getListenerList(); for (int i = 0; i < specificListeners.length; i += 2) { result[index++] = (PropertyChangeListener) specificListeners[i + 1]; } return result; }
public synchronized PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { EventListenerList list = (EventListenerList) propertyListeners.get(propertyName); if (list == null) return getPropertyChangeListeners(); int size = listeners.getListenerCount() + list.getListenerCount(); PropertyChangeListener[] result = new PropertyChangeListener[size]; // copy in the general listeners int index = 0; for (int i = 0; i < listeners.listenerList.length; i += 2) { result[index++] = (PropertyChangeListener) listeners.listenerList[i + 1]; } // copy in the specific listeners Object[] specificListeners = list.getListenerList(); for (int i = 0; i < specificListeners.length; i += 2) { result[index++] = (PropertyChangeListener) specificListeners[i + 1]; } return result; }
1,647
public synchronized PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { EventListenerList list = (EventListenerList) propertyListeners.get(propertyName); if (list == null) return getPropertyChangeListeners(); int size = listeners.getListenerCount() + list.getListenerCount(); PropertyChangeListener[] result = new PropertyChangeListener[size]; // copy in the general listeners int index = 0; for (int i = 0; i < listeners.listenerList.length; i += 2) { result[index++] = (PropertyChangeListener) listeners.listenerList[i + 1]; } // copy in the specific listeners Object[] specificListeners = list.getListenerList(); for (int i = 0; i < specificListeners.length; i += 2) { result[index++] = (PropertyChangeListener) specificListeners[i + 1]; } return result; }
public synchronized PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { EventListenerList list = (EventListenerList) propertyListeners.get(propertyName); if (list == null) return getPropertyChangeListeners(); int size = listeners.getListenerCount() + list.getListenerCount(); PropertyChangeListener[] result = new PropertyChangeListener[size]; // copy in the general listeners int index = 0; for (int i = 0; i < listeners.listenerList.length; i += 2) { result[index++] = (PropertyChangeListener) listeners.listenerList[i + 1]; } // copy in the specific listeners Object[] specificListeners = list.getListenerList(); for (int i = 0; i < specificListeners.length; i += 2) { result[index++] = (PropertyChangeListener) specificListeners[i + 1]; } return result; }
1,648
public synchronized PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { EventListenerList list = (EventListenerList) propertyListeners.get(propertyName); if (list == null) return getPropertyChangeListeners(); int size = listeners.getListenerCount() + list.getListenerCount(); PropertyChangeListener[] result = new PropertyChangeListener[size]; // copy in the general listeners int index = 0; for (int i = 0; i < listeners.listenerList.length; i += 2) { result[index++] = (PropertyChangeListener) listeners.listenerList[i + 1]; } // copy in the specific listeners Object[] specificListeners = list.getListenerList(); for (int i = 0; i < specificListeners.length; i += 2) { result[index++] = (PropertyChangeListener) specificListeners[i + 1]; } return result; }
public synchronized PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { EventListenerList list = (EventListenerList) propertyListeners.get(propertyName); if (list == null) return getPropertyChangeListeners(); int size = listeners.getListenerCount() + list.getListenerCount(); PropertyChangeListener[] result = new PropertyChangeListener[size]; // copy in the general listeners int index = 0; for (int i = 0; i < listeners.listenerList.length; i += 2) { result[index++] = (PropertyChangeListener) listeners.listenerList[i + 1]; } // copy in the specific listeners Object[] specificListeners = list.getListenerList(); for (int i = 0; i < specificListeners.length; i += 2) { result[index++] = (PropertyChangeListener) specificListeners[i + 1]; } return result; }
1,649
public synchronized PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { EventListenerList list = (EventListenerList) propertyListeners.get(propertyName); if (list == null) return getPropertyChangeListeners(); int size = listeners.getListenerCount() + list.getListenerCount(); PropertyChangeListener[] result = new PropertyChangeListener[size]; // copy in the general listeners int index = 0; for (int i = 0; i < listeners.listenerList.length; i += 2) { result[index++] = (PropertyChangeListener) listeners.listenerList[i + 1]; } // copy in the specific listeners Object[] specificListeners = list.getListenerList(); for (int i = 0; i < specificListeners.length; i += 2) { result[index++] = (PropertyChangeListener) specificListeners[i + 1]; } return result; }
public synchronized PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { EventListenerList list = (EventListenerList) propertyListeners.get(propertyName); if (list == null) return getPropertyChangeListeners(); int size = listeners.getListenerCount() + list.getListenerCount(); PropertyChangeListener[] result = new PropertyChangeListener[size]; // copy in the general listeners int index = 0; for (int i = 0; i < listeners.listenerList.length; i += 2) { result[index++] = (PropertyChangeListener) listeners.listenerList[i + 1]; } // copy in the specific listeners Object[] specificListeners = list.getListenerList(); for (int i = 0; i < specificListeners.length; i += 2) { result[index++] = (PropertyChangeListener) specificListeners[i + 1]; } return result; }
1,650
public void update(Graphics g, JComponent c) { if (c.isOpaque()) { g.setColor(c.getBackground()); Rectangle clip = g.getClipBounds(); g.fillRect(clip.x, clip.y, clip.width, clip.height); } paint(g, c); }
public void update(Graphics g, JComponent c) { if (c.isOpaque()) { g.setColor(c.getBackground()); Rectangle clip = g.getClipBounds(); g.fillRect(0, 0, c.getWidth(), c.getHeight()); } paint(g, c); }
1,651
public synchronized void addInvalidComponent(JComponent component) { Component ancestor = component.getParent(); while (ancestor != null && (! (ancestor instanceof JComponent) || ! ((JComponent) ancestor).isValidateRoot() )) ancestor = ancestor.getParent(); if (ancestor != null && ancestor instanceof JComponent && ((JComponent) ancestor).isValidateRoot()) component = (JComponent) ancestor; if (invalidComponents.contains(component)) return; invalidComponents.add(component); if (! repaintWorker.isLive()) { repaintWorker.setLive(true); SwingUtilities.invokeLater(repaintWorker); } }
public synchronized void addInvalidComponent(JComponent component) { Component ancestor = component.getParent(); while (ancestor != null && (! (ancestor instanceof JComponent) || ! ((JComponent) ancestor).isValidateRoot() )) ancestor = ancestor.getParent(); if (ancestor != null && ancestor instanceof JComponent && ((JComponent) ancestor).isValidateRoot()) component = (JComponent) ancestor; if (invalidComponents.contains(component)) return; invalidComponents.add(component); if (! repaintWorker.isLive()) { repaintWorker.setLive(true); SwingUtilities.invokeLater(repaintWorker); } }
1,652
public FileArgument(String name, String description) { super(name, description, SINGLE); }
public FileArgument(String name, String description) { super(name, description, SINGLE); }
1,653
public double getPercentComplete() { if (getMaximum() == getMinimum()) return 1.0; else return (double) (model.getValue() - model.getMinimum()) / (model .getMaximum() - model.getMinimum()); }
public double getPercentComplete() { if (getMaximum() == getMinimum()) return 1.0; else return (double) (model.getValue() - model.getMinimum()) / (model .getMaximum() - model.getMinimum()); }
1,654
protected void paintBorder(Graphics graphics) { Border border = getBorder(); if (paintBorder && border != null) border.paintBorder(this, graphics, 0, 0, getWidth(), getHeight()); }
protected void paintBorder(Graphics graphics) { Border border = getBorder(); if (paintBorder && border != null) border.paintBorder(this, graphics, 0, 0, getWidth(), getHeight()); }
1,655
public void setBorderPainted(boolean painted) { if (painted != paintBorder) { boolean oldPainted = paintBorder; paintBorder = painted; firePropertyChange("borderPainted", oldPainted, paintBorder); } }
public void setBorderPainted(boolean painted) { if (painted != paintBorder) { boolean oldPainted = paintBorder; paintBorder = painted; firePropertyChange("borderPainted", oldPainted, paintBorder); } }
1,656
public void setIndeterminate(boolean newValue) { if (indeterminate != newValue) { boolean olddeter = indeterminate; indeterminate = newValue; firePropertyChange("indeterminate", olddeter, indeterminate); } }
public void setIndeterminate(boolean flag) { if (indeterminate != newValue) { boolean olddeter = indeterminate; indeterminate = newValue; firePropertyChange("indeterminate", olddeter, indeterminate); } }
1,657
public void setIndeterminate(boolean newValue) { if (indeterminate != newValue) { boolean olddeter = indeterminate; indeterminate = newValue; firePropertyChange("indeterminate", olddeter, indeterminate); } }
public void setIndeterminate(boolean newValue) { if (indeterminate != flag) { boolean olddeter = indeterminate; indeterminate = newValue; firePropertyChange("indeterminate", olddeter, indeterminate); } }
1,658
public void setIndeterminate(boolean newValue) { if (indeterminate != newValue) { boolean olddeter = indeterminate; indeterminate = newValue; firePropertyChange("indeterminate", olddeter, indeterminate); } }
public void setIndeterminate(boolean newValue) { if (indeterminate != newValue) { boolean olddeter = indeterminate; indeterminate = newValue; firePropertyChange("indeterminate", olddeter, indeterminate); } }
1,659
public void setOrientation(int orientation) { if (orientation != VERTICAL && orientation != HORIZONTAL) throw new IllegalArgumentException(orientation + " is not a legal orientation"); if (this.orientation != orientation) { int oldOrientation = this.orientation; this.orientation = orientation; firePropertyChange("orientation", oldOrientation, this.orientation); } }
public void setOrientation(int orientation) { if (orientation != VERTICAL && orientation != HORIZONTAL) throw new IllegalArgumentException(orientation + " is not a legal orientation"); if (this.orientation != orientation) { int oldOrientation = this.orientation; this.orientation = orientation; firePropertyChange("orientation", oldOrientation, this.orientation); } }
1,660
public void setStringPainted(boolean painted) { if (paintString != painted) { boolean oldPainted = paintString; paintString = painted; firePropertyChange("stringPainted", oldPainted, paintString); } }
public void setStringPainted(boolean painted) { if (paintString != painted) { boolean oldPainted = paintString; paintString = painted; firePropertyChange("stringPainted", oldPainted, paintString); } }
1,661
public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); int tabCount = tabPane.getTabCount(); if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { if (e.getSource() == incrButton) { if (++currentScrollLocation >= tabCount) currentScrollLocation = tabCount - 1; int width = 0; for (int i = currentScrollLocation - 1; i < tabCount; i++) width += rects[i].width; if (width < viewport.getWidth()) // FIXME: Still getting mouse events after the button is disabled. // incrButton.setEnabled(false); currentScrollLocation--; else if (! decrButton.isEnabled()) decrButton.setEnabled(true); tabPane.revalidate(); tabPane.repaint(); return; } else if (e.getSource() == decrButton) { if (--currentScrollLocation < 0) currentScrollLocation = 0; if (currentScrollLocation == 0) decrButton.setEnabled(false); else if (! incrButton.isEnabled()) incrButton.setEnabled(true); tabPane.revalidate(); tabPane.repaint(); return; } } int index = tabForCoordinate(tabPane, x, y); // We need to check since there are areas where tabs cannot be // e.g. in the inset area. if (index != -1 && tabPane.isEnabledAt(index)) tabPane.setSelectedIndex(index); tabPane.revalidate(); tabPane.repaint(); }
public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); int tabCount = tabPane.getTabCount(); if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { if (e.getSource() == incrButton) { if (++currentScrollLocation >= tabCount) currentScrollLocation = tabCount - 1; int width = 0; for (int i = currentScrollLocation - 1; i < tabCount; i++) width += rects[i].width; if (width < viewport.getWidth()) // FIXME: Still getting mouse events after the button is disabled. // incrButton.setEnabled(false); currentScrollLocation--; else if (! decrButton.isEnabled()) decrButton.setEnabled(true); tabPane.revalidate(); tabPane.repaint(); return; } else if (e.getSource() == decrButton) { if (--currentScrollLocation < 0) currentScrollLocation = 0; if (currentScrollLocation == 0) decrButton.setEnabled(false); else if (! incrButton.isEnabled()) incrButton.setEnabled(true); tabPane.revalidate(); tabPane.repaint(); return; } } int index = tabForCoordinate(tabPane, x, y); // We need to check since there are areas where tabs cannot be // e.g. in the inset area. if (index != -1 && tabPane.isEnabledAt(index)) tabPane.setSelectedIndex(index); tabPane.revalidate(); tabPane.repaint(); }
1,662
public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); int tabCount = tabPane.getTabCount(); if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { if (e.getSource() == incrButton) { if (++currentScrollLocation >= tabCount) currentScrollLocation = tabCount - 1; int width = 0; for (int i = currentScrollLocation - 1; i < tabCount; i++) width += rects[i].width; if (width < viewport.getWidth()) // FIXME: Still getting mouse events after the button is disabled. // incrButton.setEnabled(false); currentScrollLocation--; else if (! decrButton.isEnabled()) decrButton.setEnabled(true); tabPane.revalidate(); tabPane.repaint(); return; } else if (e.getSource() == decrButton) { if (--currentScrollLocation < 0) currentScrollLocation = 0; if (currentScrollLocation == 0) decrButton.setEnabled(false); else if (! incrButton.isEnabled()) incrButton.setEnabled(true); tabPane.revalidate(); tabPane.repaint(); return; } } int index = tabForCoordinate(tabPane, x, y); // We need to check since there are areas where tabs cannot be // e.g. in the inset area. if (index != -1 && tabPane.isEnabledAt(index)) tabPane.setSelectedIndex(index); tabPane.revalidate(); tabPane.repaint(); }
public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); int tabCount = tabPane.getTabCount(); if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { if (e.getSource() == incrButton) { if (++currentScrollLocation >= tabCount) currentScrollLocation = tabCount - 1; int width = 0; for (int i = currentScrollLocation - 1; i < tabCount; i++) width += rects[i].width; if (width < viewport.getWidth()) // FIXME: Still getting mouse events after the button is disabled. // incrButton.setEnabled(false); currentScrollLocation--; else if (! decrButton.isEnabled()) decrButton.setEnabled(true); tabPane.revalidate(); tabPane.repaint(); return; } else if (e.getSource() == decrButton) { if (--currentScrollLocation < 0) currentScrollLocation = 0; if (currentScrollLocation == 0) decrButton.setEnabled(false); else if (! incrButton.isEnabled()) incrButton.setEnabled(true); tabPane.revalidate(); tabPane.repaint(); return; } } int index = tabForCoordinate(tabPane, x, y); // We need to check since there are areas where tabs cannot be // e.g. in the inset area. if (index != -1 && tabPane.isEnabledAt(index)) tabPane.setSelectedIndex(index); tabPane.revalidate(); tabPane.repaint(); }
1,663
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("tabLayoutPolicy")) { layoutManager = createLayoutManager(); tabPane.setLayout(layoutManager); } else if (e.getPropertyName().equals("tabPlacement") && tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { incrButton = createIncreaseButton(); decrButton = createDecreaseButton(); } tabPane.layout(); tabPane.repaint(); }
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("tabLayoutPolicy")) { layoutManager = createLayoutManager(); tabPane.setLayout(layoutManager); } else if (e.getPropertyName().equals("tabPlacement") && tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { incrButton = createIncreaseButton(); decrButton = createDecreaseButton(); } tabPane.layout(); tabPane.repaint(); }
1,664
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("tabLayoutPolicy")) { layoutManager = createLayoutManager(); tabPane.setLayout(layoutManager); } else if (e.getPropertyName().equals("tabPlacement") && tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { incrButton = createIncreaseButton(); decrButton = createDecreaseButton(); } tabPane.layout(); tabPane.repaint(); }
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("tabLayoutPolicy")) { layoutManager = createLayoutManager(); tabPane.setLayout(layoutManager); } else if (e.getPropertyName().equals("tabPlacement") && tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { incrButton = createIncreaseButton(); decrButton = createDecreaseButton(); } tabPane.layout(); tabPane.repaint(); }
1,665
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("tabLayoutPolicy")) { layoutManager = createLayoutManager(); tabPane.setLayout(layoutManager); } else if (e.getPropertyName().equals("tabPlacement") && tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { incrButton = createIncreaseButton(); decrButton = createDecreaseButton(); } tabPane.layout(); tabPane.repaint(); }
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("tabLayoutPolicy")) { layoutManager = createLayoutManager(); tabPane.setLayout(layoutManager); } else if (e.getPropertyName().equals("tabPlacement") && tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { incrButton = createIncreaseButton(); decrButton = createDecreaseButton(); } tabPane.layout(); tabPane.repaint(); }
1,666
public void paint(Graphics g, JComponent c) { paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex()); }
public void paint(Graphics g, JComponent c) { paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex()); }
1,667
public void addLayoutComponent(String name, Component comp) { // Do nothing. }
public void addLayoutComponent(String name, Component comp) { // Do nothing. }
1,668
public void calculateLayoutInfo() { calculateTabRects(tabPane.getTabPlacement(), tabPane.getTabCount()); if (tabPane.getSelectedIndex() != -1) { Component visible = getVisibleComponent(); Insets insets = getContentBorderInsets(tabPane.getTabPlacement()); if (visible != null) visible.setBounds(contentRect.x + insets.left, contentRect.y + insets.top, contentRect.width - insets.left - insets.right, contentRect.height - insets.top - insets.bottom); } }
public void calculateLayoutInfo() { calculateTabRects(tabPane.getTabPlacement(), tabPane.getTabCount()); if (tabPane.getSelectedIndex() != -1) { Component visible = getVisibleComponent(); Insets insets = getContentBorderInsets(tabPane.getTabPlacement()); if (visible != null) visible.setBounds(contentRect.x + insets.left, contentRect.y + insets.top, contentRect.width - insets.left - insets.right, contentRect.height - insets.top - insets.bottom); } }
1,669
public void calculateLayoutInfo() { calculateTabRects(tabPane.getTabPlacement(), tabPane.getTabCount()); if (tabPane.getSelectedIndex() != -1) { Component visible = getVisibleComponent(); Insets insets = getContentBorderInsets(tabPane.getTabPlacement()); if (visible != null) visible.setBounds(contentRect.x + insets.left, contentRect.y + insets.top, contentRect.width - insets.left - insets.right, contentRect.height - insets.top - insets.bottom); } }
public void calculateLayoutInfo() { calculateTabRects(tabPane.getTabPlacement(), tabPane.getTabCount()); if (tabPane.getSelectedIndex() != -1) { Component visible = getVisibleComponent(); Insets insets = getContentBorderInsets(tabPane.getTabPlacement()); if (visible != null) visible.setBounds(contentRect.x + insets.left, contentRect.y + insets.top, contentRect.width - insets.left - insets.right, contentRect.height - insets.top - insets.bottom); } }
1,670
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; int componentHeight = 0; int componentWidth = 0; Component c; Dimension dims; for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; calcRect = c.getBounds(); dims = c.getPreferredSize(); if (dims != null) { componentHeight = Math.max(componentHeight, dims.height); componentWidth = Math.max(componentWidth, dims.width); } } Insets insets = tabPane.getInsets(); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, componentWidth); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width); height = tabAreaHeight + componentHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, componentHeight); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height); width = tabAreaWidth + componentWidth; } return new Dimension(width, height); }
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; int componentHeight = 0; int componentWidth = 0; Component c; Dimension dims; for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; calcRect = c.getBounds(); dims = c.getPreferredSize(); if (dims != null) { componentHeight = Math.max(componentHeight, dims.height); componentWidth = Math.max(componentWidth, dims.width); } } Insets insets = tabPane.getInsets(); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, componentWidth); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width); height = tabAreaHeight + componentHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, componentHeight); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height); width = tabAreaWidth + componentWidth; } return new Dimension(width, height); }
1,671
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; int componentHeight = 0; int componentWidth = 0; Component c; Dimension dims; for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; calcRect = c.getBounds(); dims = c.getPreferredSize(); if (dims != null) { componentHeight = Math.max(componentHeight, dims.height); componentWidth = Math.max(componentWidth, dims.width); } } Insets insets = tabPane.getInsets(); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, componentWidth); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width); height = tabAreaHeight + componentHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, componentHeight); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height); width = tabAreaWidth + componentWidth; } return new Dimension(width, height); }
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; int componentHeight = 0; int componentWidth = 0; Component c; Dimension dims; for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; calcRect = c.getBounds(); dims = c.getPreferredSize(); if (dims != null) { componentHeight = Math.max(componentHeight, dims.height); componentWidth = Math.max(componentWidth, dims.width); } } Insets insets = tabPane.getInsets(); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, componentWidth); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width); height = tabAreaHeight + componentHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, componentHeight); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height); width = tabAreaWidth + componentWidth; } return new Dimension(width, height); }
1,672
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; int componentHeight = 0; int componentWidth = 0; Component c; Dimension dims; for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; calcRect = c.getBounds(); dims = c.getPreferredSize(); if (dims != null) { componentHeight = Math.max(componentHeight, dims.height); componentWidth = Math.max(componentWidth, dims.width); } } Insets insets = tabPane.getInsets(); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, componentWidth); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width); height = tabAreaHeight + componentHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, componentHeight); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height); width = tabAreaWidth + componentWidth; } return new Dimension(width, height); }
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; int componentHeight = 0; int componentWidth = 0; Component c; Dimension dims; for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; calcRect = c.getBounds(); dims = c.getPreferredSize(); if (dims != null) { componentHeight = Math.max(componentHeight, dims.height); componentWidth = Math.max(componentWidth, dims.width); } } Insets insets = tabPane.getInsets(); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, componentWidth); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width); height = tabAreaHeight + componentHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, componentHeight); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height); width = tabAreaWidth + componentWidth; } return new Dimension(width, height); }
1,673
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; int componentHeight = 0; int componentWidth = 0; Component c; Dimension dims; for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; calcRect = c.getBounds(); dims = c.getPreferredSize(); if (dims != null) { componentHeight = Math.max(componentHeight, dims.height); componentWidth = Math.max(componentWidth, dims.width); } } Insets insets = tabPane.getInsets(); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, componentWidth); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width); height = tabAreaHeight + componentHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, componentHeight); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height); width = tabAreaWidth + componentWidth; } return new Dimension(width, height); }
protected Dimension calculateSize(boolean minimum) { int tabPlacement = tabPane.getTabPlacement(); int width = 0; int height = 0; int componentHeight = 0; int componentWidth = 0; Component c; Dimension dims; for (int i = 0; i < tabPane.getTabCount(); i++) { c = tabPane.getComponentAt(i); if (c == null) continue; calcRect = c.getBounds(); dims = c.getPreferredSize(); if (dims != null) { componentHeight = Math.max(componentHeight, dims.height); componentWidth = Math.max(componentWidth, dims.width); } } Insets insets = tabPane.getInsets(); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int min = calculateMaxTabWidth(tabPlacement); width = Math.max(min, componentWidth); int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width); height = tabAreaHeight + componentHeight; } else { int min = calculateMaxTabHeight(tabPlacement); height = Math.max(min, componentHeight); int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height); width = tabAreaWidth + componentWidth; } return new Dimension(width, height); }
1,674
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,675
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,676
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,677
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,678
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,679
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,680
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,681
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,682
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,683
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,684
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,685
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,686
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,687
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,688
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,689
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,690
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,691
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
protected void calculateTabRects(int tabPlacement, int tabCount) { if (tabCount == 0) return; assureRectsCreated(tabCount); FontMetrics fm = getFontMetrics(); SwingUtilities.calculateInnerArea(tabPane, calcRect); Insets tabAreaInsets = getTabAreaInsets(tabPlacement); Insets insets = tabPane.getInsets(); int max = 0; int runs = 0; int start = getTabRunIndent(tabPlacement, 1); if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) { int maxHeight = calculateMaxTabHeight(tabPlacement); calcRect.width -= tabAreaInsets.left + tabAreaInsets.right; max = calcRect.width + tabAreaInsets.left + insets.left; start += tabAreaInsets.left + insets.left; int width = 0; int runWidth = start; for (int i = 0; i < tabCount; i++) { width = calculateTabWidth(tabPlacement, i, fm); if (runWidth + width > max) { runWidth = tabAreaInsets.left + insets.left + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(runWidth, insets.top + tabAreaInsets.top, width, maxHeight); runWidth += width; } } runs++; tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right; tabAreaRect.height = runs * maxTabHeight - (runs - 1) * tabRunOverlay + tabAreaInsets.top + tabAreaInsets.bottom; contentRect.width = tabAreaRect.width; contentRect.height = tabPane.getHeight() - insets.top - insets.bottom - tabAreaRect.height; contentRect.x = insets.left; tabAreaRect.x = insets.left; if (tabPlacement == SwingConstants.BOTTOM) { contentRect.y = insets.top; tabAreaRect.y = contentRect.y + contentRect.height; } else { tabAreaRect.y = insets.top; contentRect.y = tabAreaRect.y + tabAreaRect.height; } } else { int maxWidth = calculateMaxTabWidth(tabPlacement); calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom; max = calcRect.height + tabAreaInsets.top + insets.top; int height = 0; start += tabAreaInsets.top + insets.top; int runHeight = start; int fontHeight = fm.getHeight(); for (int i = 0; i < tabCount; i++) { height = calculateTabHeight(tabPlacement, i, fontHeight); if (runHeight + height > max) { runHeight = tabAreaInsets.top + insets.top + getTabRunIndent(tabPlacement, ++runs); rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; if (runs > tabRuns.length - 1) expandTabRunsArray(); tabRuns[runs] = i; } else { rects[i] = new Rectangle(insets.left + tabAreaInsets.left, runHeight, maxWidth, height); runHeight += height; } } runs++; tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay + tabAreaInsets.left + tabAreaInsets.right; tabAreaRect.height = tabPane.getHeight() - insets.top - insets.bottom; tabAreaRect.y = insets.top; contentRect.width = tabPane.getWidth() - insets.left - insets.right - tabAreaRect.width; contentRect.height = tabAreaRect.height; contentRect.y = insets.top; if (tabPlacement == SwingConstants.LEFT) { tabAreaRect.x = insets.left; contentRect.x = tabAreaRect.x + tabAreaRect.width; } else { contentRect.x = insets.left; tabAreaRect.x = contentRect.x + contentRect.width; } } runCount = runs; tabRuns[0] = 0; normalizeTabRuns(tabPlacement, tabCount, start, max); selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex()); if (shouldRotateTabRuns(tabPlacement)) rotateTabRuns(tabPlacement, selectedRun); // Need to pad the runs and move them to the correct location. for (int i = 0; i < runCount; i++) { int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1; if (first == tabCount) first = 0; int last = lastTabInRun(tabCount, i); if (shouldPadTabRun(tabPlacement, i)) padTabRun(tabPlacement, first, last, max); // Done padding, now need to move it. if (tabPlacement == SwingConstants.TOP && i > 0) { for (int j = first; j <= last; j++) rects[j].y += (runCount - i) * maxTabHeight - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.BOTTOM) { int height = tabPane.getBounds().height - insets.bottom - tabAreaInsets.bottom; int adjustment; if (i == 0) adjustment = height - maxTabHeight; else adjustment = height - (runCount - i + 1) * maxTabHeight - (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].y = adjustment; } if (tabPlacement == SwingConstants.LEFT && i > 0) { for (int j = first; j <= last; j++) rects[j].x += (runCount - i) * maxTabWidth - (runCount - i) * tabRunOverlay; } if (tabPlacement == SwingConstants.RIGHT) { int width = tabPane.getBounds().width - insets.right - tabAreaInsets.right; int adjustment; if (i == 0) adjustment = width - maxTabWidth; else adjustment = width - (runCount - i + 1) * maxTabWidth + (runCount - i) * tabRunOverlay; for (int j = first; j <= last; j++) rects[j].x = adjustment; } } padSelectedTab(tabPlacement, tabPane.getSelectedIndex()); }
1,692
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
1,693
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
1,694
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
1,695
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
1,696
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
1,697
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); if (tabPlacement == SwingUtilities.TOP || tabPlacement == SwingUtilities.BOTTOM) { // We should only do this for runCount - 1, cause we can only shift that many times between // runs. for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.x + currRun.width; int spaceInNext = nextRun.x + nextRun.width; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.width < max) { tabRuns[i]--; spaceInNext += currRun.width; spaceInCurr -= currRun.width; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.width) - (spaceInNext + currRun.width); } // Fix the bounds. int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currX = tabAreaInsets.left; for (int j = first; j <= last; j++) { rects[j].x = currX; currX += rects[j].width; } } } else { for (int i = 1; i < runCount; i++) { Rectangle currRun = rects[lastTabInRun(tabCount, i)]; Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))]; int spaceInCurr = currRun.y + currRun.height; int spaceInNext = nextRun.y + nextRun.height; int diffNow = spaceInCurr - spaceInNext; int diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); while (Math.abs(diffLater) < Math.abs(diffNow) && spaceInNext + currRun.height < max) { tabRuns[i]--; spaceInNext += currRun.height; spaceInCurr -= currRun.height; currRun = rects[lastTabInRun(tabCount, i)]; diffNow = spaceInCurr - spaceInNext; diffLater = (spaceInCurr - currRun.height) - (spaceInNext + currRun.height); } int first = lastTabInRun(tabCount, i) + 1; int last = lastTabInRun(tabCount, getNextTabRun(i)); int currY = tabAreaInsets.top; for (int j = first; j <= last; j++) { rects[j].y = currY; currY += rects[j].height; } } } }
1,698