/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* BasicTableHeaderUI implementation
*
* @author Alan Chung
* @author Philip Milne
*/
//
// Instance Variables
//
/** The JTableHeader that is delegating the painting to this UI. */
// Listeners that are attached to the JTable
// The column header over which the mouse currently is.
// The column that should be highlighted when the table header has the focus.
public void focusGained(FocusEvent e) {
repaintHeader(e.getSource());
}
public void focusLost(FocusEvent e) {
repaintHeader(e.getSource());
}
if (source instanceof JTableHeader) {
BasicTableHeaderUI.class);
return;
}
}
}
};
/**
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of {@code BasicTableHeaderUI}.
*/
private int mouseXOffset;
return;
}
if (columnIndex != -1) {
}
}
}
}
}
if (column == -1) {
return null;
}
if (r.contains(p)) {
return null;
}
int columnIndex;
} else {
}
if (columnIndex == -1) {
return null;
}
}
return;
}
// First find which header cell was hit
if (index != -1) {
// The last 3 pixels + 3 pixels of next column are for resizing
} else {
}
}
else if (header.getReorderingAllowed()) {
mouseXOffset = p.x;
}
}
if (header.getReorderingAllowed()) {
int oldRolloverColumn = rolloverColumn;
rolloverColumn = -1;
}
}
private void swapCursor() {
otherCursor = tmp;
}
return;
}
swapCursor();
}
}
return;
}
if (resizingColumn != null) {
int newWidth;
if (headerLeftToRight) {
} else {
}
}
else if (draggedColumn != null) {
//Cache the selected column.
int selectedIndex =
//Now do the move.
//Update the selected index.
false);
return;
}
}
}
}
return;
}
}
return;
}
}
return;
}
int oldRolloverColumn = rolloverColumn;
rolloverColumn = -1;
}
//
// Protected & Private Methods
//
if (column != -1) {
}
}
}
//
// Factory methods for the Listeners
//
/**
* Creates the mouse listener for the JTableHeader.
*/
return new MouseInputHandler();
}
//
// The installation/uninstall procedures and support
//
return new BasicTableHeaderUI();
}
// Installation
header = (JTableHeader)c;
rendererPane = new CellRendererPane();
}
/**
* Initializes JTableHeader properties such as font, foreground, and background.
* The font, foreground, and background properties are only set if their
* current value is either null or a UIResource, other properties are set
* if the current value is null.
*
* @see #installUI
*/
protected void installDefaults() {
"TableHeader.foreground", "TableHeader.font");
}
/**
* Attaches listeners to the JTableHeader.
*/
protected void installListeners() {
}
/**
* Register all keyboard actions on the JTableHeader.
*/
protected void installKeyboardActions() {
"TableHeader.ancestorInputMap");
"TableHeader.actionMap");
}
// Uninstall methods
rendererPane = null;
}
protected void uninstallDefaults() {}
protected void uninstallListeners() {
}
/**
* Unregisters default key actions.
*/
protected void uninstallKeyboardActions() {
}
/**
* Populates TableHeader's actions.
*/
}
//
// Support for mouse rollover
//
/**
* Returns the index of the column header over which the mouse
* currently is. When the mouse is not over the table header,
* -1 is returned.
*
* @see #rolloverColumnUpdated(int, int)
* @return the index of the current rollover column
* @since 1.6
*/
protected int getRolloverColumn() {
return rolloverColumn;
}
/**
* This method gets called every time when a rollover column in the table
* header is updated. Every look and feel that supports a rollover effect
* in a table header should override this method and repaint the header.
*
* @param oldColumn the index of the previous rollover column or -1 if the
* mouse was not over a column
* @param newColumn the index of the new rollover column or -1 if the mouse
* is not over a column
* @see #getRolloverColumn()
* @see JTableHeader#getHeaderRect(int)
* @since 1.6
*/
}
if (col != rolloverColumn) {
int oldRolloverColumn = rolloverColumn;
}
}
}
//
// Support for keyboard and mouse access
//
int newIndex = getSelectedColumnIndex();
newIndex++;
if (doIt) {
}
}
return newIndex;
}
int newIndex = getSelectedColumnIndex();
if (newIndex > 0) {
newIndex--;
if (doIt) {
}
}
return newIndex;
}
/**
* Selects the specified column in the table header. Repaints the
* affected header cells and makes sure the newly selected one is visible.
*/
selectColumn(newColIndex, true);
}
if (doScroll) {
}
return;
}
/**
* Used by selectColumn to scroll horizontally, if necessary,
* to ensure that the newly selected column is visible.
*/
//Test whether the header is in a scroll pane and has a table.
!(container instanceof JScrollPane) ||
return;
}
//Now scroll, if necessary.
vis.x = cellBounds.x;
}
private int getSelectedColumnIndex() {
}
return selectedColumnIndex;
}
&& column.getResizable();
}
!(container instanceof JScrollPane) ||
return 0;
}
/* Resize a table */
/* If this table is in AUTO_RESIZE_OFF mode and
* has a horizontal scrollbar, we need to update
* a view's position.
*/
if ((newHeaderWidth >= viewportWidth) &&
p.x + diff));
return diff;
}
}
return 0;
}
//
// Baseline
//
/**
* Returns the baseline.
*
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @see javax.swing.JComponent#getBaseline(int, int)
* @since 1.6
*/
int baseline = -1;
column++) {
if (columnBaseline >= 0) {
if (baseline == -1) {
}
else if (baseline != columnBaseline) {
baseline = -1;
break;
}
}
}
return baseline;
}
//
// Paint Methods and support
//
return;
}
// This should never happen.
if (cMin == -1) {
cMin = 0;
}
// If the table does not have enough columns to fill the view we'll get -1.
// Replace this with the index of the last column.
if (cMax == -1) {
}
int columnWidth;
if (ltr) {
if (aColumn != draggedColumn) {
}
cellRect.x += columnWidth;
}
} else {
if (aColumn != draggedColumn) {
}
cellRect.x += columnWidth;
}
}
// Paint the dragged column if we are dragging.
if (draggedColumn != null) {
// Draw a gray well in place of the moving column.
// Fill the background.
}
// Remove all components in the rendererPane.
}
}
&& (columnIndex == getSelectedColumnIndex())
false, hasFocus,
-1, columnIndex);
}
}
return column;
}
}
return -1;
}
//
// Size Methods
//
private int getHeaderHeight() {
int height = 0;
boolean accomodatedDefault = false;
if (!isDefault || !accomodatedDefault) {
// Configuring the header renderer to calculate its preferred size
// is expensive. Optimise this by assuming the default renderer
// always has the same height as the first non-zero height that
if (headerValue != null) {
accomodatedDefault = true;
}
}
}
}
}
return height;
}
// None of the callers include the intercell spacing, do it here.
}
}
/**
* Return the minimum size of the header. The minimum width is the sum
* of the minimum widths of each column (plus inter-cell spacing).
*/
long width = 0;
while (enumeration.hasMoreElements()) {
}
return createHeaderSize(width);
}
/**
* Return the preferred size of the header. The preferred height is the
* maximum of the preferred heights of all of the components provided
* by the header renderers. The preferred width is the sum of the
* preferred widths of each column (plus inter-cell spacing).
*/
long width = 0;
while (enumeration.hasMoreElements()) {
}
return createHeaderSize(width);
}
/**
* Return the maximum size of the header. The maximum width is the sum
* of the maximum widths of each column (plus inter-cell spacing).
*/
long width = 0;
while (enumeration.hasMoreElements()) {
}
return createHeaderSize(width);
}
"toggleSortOrder";
"selectColumnToLeft";
"selectColumnToRight";
"moveColumnLeft";
"moveColumnRight";
"resizeLeft";
"resizeRight";
"focusTable";
super(name);
}
if (sender instanceof JTableHeader) {
return false;
}
BasicTableHeaderUI.class);
if (key == MOVE_COLUMN_LEFT) {
return th.getReorderingAllowed()
} else if (key == MOVE_COLUMN_RIGHT) {
return th.getReorderingAllowed()
} else if (key == RESIZE_LEFT ||
key == RESIZE_RIGHT) {
} else if (key == FOCUS_TABLE) {
}
}
}
return true;
}
BasicTableHeaderUI.class);
return;
}
if (TOGGLE_SORT_ORDER == name) {
}
} else if (SELECT_COLUMN_TO_LEFT == name) {
ui.selectPreviousColumn(true);
} else {
ui.selectNextColumn(true);
}
} else if (SELECT_COLUMN_TO_RIGHT == name) {
ui.selectNextColumn(true);
} else {
ui.selectPreviousColumn(true);
}
} else if (MOVE_COLUMN_LEFT == name) {
} else if (MOVE_COLUMN_RIGHT == name) {
} else if (RESIZE_LEFT == name) {
} else if (RESIZE_RIGHT == name) {
} else if (FOCUS_TABLE == name) {
}
}
}
}
int newIndex;
} else {
}
if (doIt) {
} else {
return true; // we'd do the move if asked
}
}
return false;
}
} else {
}
}
}
} // End of Class BasicTableHeaderUI