GATE
Version 3.1-2270

gate.swing
Class XJTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by gate.swing.XJTable
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, TableColumnModelListener, TableModelListener, Scrollable
Direct Known Subclasses:
JTreeTable, ResourceParametersEditor

public class XJTable
extends JTable

A "smarter" JTable. Feaures include:

It uses a custom made model that stands between the table model set by the user and the gui component. This middle model is responsible for sorting the rows.

See Also:
Serialized Form

Nested Class Summary
protected  class XJTable.ColumnData
           
protected  class XJTable.HeaderMouseListener
           
protected  class XJTable.SortingModel
          Handles translations between an indexed data source and a permutation of itself (like the translations between the rows in sorted table and the rows in the actual unsorted model).
 
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.PrintMode
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean ascending
          is the current sort order ascending (or descending)?
protected  List columnData
          A list of XJTable.ColumnData objects.
protected  ObjectComparator defaultComparator
           
protected  boolean sortable
          Should this table be sortable.
protected  int sortedColumn
          The column currently being sorted.
protected  XJTable.SortingModel sortingModel
           
 
Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
XJTable()
           
XJTable(TableModel model)
           
 
Method Summary
 void adjustSizes()
          Sets the preferred widths for the columns and rows based or the preferred sizes of the renderers.
 Dimension getPreferredScrollableViewportSize()
           
 Dimension getPreferredSize()
           
 int getSortedColumn()
           
 int getTableRow(int modelRow)
          Get the row in the table for a row in the model.
 boolean isAscending()
           
 boolean isColumnHidden(int columnIndex)
          Gets the hidden state for a column
 boolean isSortable()
           
protected  void newColumns()
          Called when the columns have changed.
 int rowModelToView(int modelRow)
          Converts a row number from the model co-ordinates system to the view's.
 int rowViewToModel(int viewRow)
          Converts a row number from the view co-ordinates system to the model's.
 void setAscending(boolean ascending)
           
 void setComparator(int column, Comparator comparator)
          Sets the custom comparator to be used for a particular column.
 void setModel(TableModel dataModel)
           
 void setSortable(boolean sortable)
           
 void setSortedColumn(int sortColumn)
           
 void updateUI()
          This is called whenever the UI is initialised or changed
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit, tableChanged, unconfigureEnclosingScrollPane, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sortingModel

protected XJTable.SortingModel sortingModel

defaultComparator

protected ObjectComparator defaultComparator

sortedColumn

protected int sortedColumn
The column currently being sorted.


ascending

protected boolean ascending
is the current sort order ascending (or descending)?


sortable

protected boolean sortable
Should this table be sortable.


columnData

protected List columnData
A list of XJTable.ColumnData objects.

Constructor Detail

XJTable

public XJTable()

XJTable

public XJTable(TableModel model)
Method Detail

setModel

public void setModel(TableModel dataModel)
Overrides:
setModel in class JTable

newColumns

protected void newColumns()
Called when the columns have changed.


updateUI

public void updateUI()
This is called whenever the UI is initialised or changed

Overrides:
updateUI in class JTable

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class JComponent

getPreferredScrollableViewportSize

public Dimension getPreferredScrollableViewportSize()
Specified by:
getPreferredScrollableViewportSize in interface Scrollable
Overrides:
getPreferredScrollableViewportSize in class JTable

adjustSizes

public void adjustSizes()
Sets the preferred widths for the columns and rows based or the preferred sizes of the renderers.


rowModelToView

public int rowModelToView(int modelRow)
Converts a row number from the model co-ordinates system to the view's.

Parameters:
modelRow - the row number in the model
Returns:
the corresponding row number in the view.

isAscending

public boolean isAscending()
Returns:
Returns the ascending.

isColumnHidden

public boolean isColumnHidden(int columnIndex)
Gets the hidden state for a column

Parameters:
columnIndex - the column
Returns:
the hidden state

setAscending

public void setAscending(boolean ascending)
Parameters:
ascending - The ascending to set.

rowViewToModel

public int rowViewToModel(int viewRow)
Converts a row number from the view co-ordinates system to the model's.

Parameters:
viewRow - the row number in the view.
Returns:
the corresponding row number in the model.

setComparator

public void setComparator(int column,
                          Comparator comparator)
Sets the custom comparator to be used for a particular column. Columns that don't have a custom comparator will be sorted using the natural order.

Parameters:
column - the column index.
comparator - the comparator to be used.

isSortable

public boolean isSortable()
Returns:
Returns the sortable.

setSortable

public void setSortable(boolean sortable)
Parameters:
sortable - The sortable to set.

getSortedColumn

public int getSortedColumn()
Returns:
Returns the sortColumn.

setSortedColumn

public void setSortedColumn(int sortColumn)
Parameters:
sortColumn - The sortColumn to set.

getTableRow

public int getTableRow(int modelRow)
Get the row in the table for a row in the model.


GATE
Version 3.1-2270