com.eliad.swing
Class JSmartGrid

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.eliad.swing.JSmartGrid
Direct Known Subclasses:
JSmartGridHeader

public class JSmartGrid
extends javax.swing.JComponent
implements javax.swing.Scrollable, GridModelListener, SpanModelListener, StyleModelListener, GridSelectionListener, RulerModelListener, javax.swing.event.CellEditorListener, java.beans.PropertyChangeListener, java.awt.event.HierarchyListener, RulerConstants, GridSelectionConstants, javax.accessibility.Accessible

The JSmartGrid is a JComponent where grid-oriented data can be displayed.

The data is represented by several models:

This is exemplified by the following diagram:


Those models work both by push and by pull, meaning that they can be both queried by the grid and notify the grids of changes. A grid may be active, or passive, for each of the two orientations. If it is passive, it depends on some other grid for its ruler model along that orientation.

Version:
1.0 00/03/26
Author:
Patrick Mérissert-Coffinières
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
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
 
Constructor Summary
JSmartGrid()
          Constructs a default JSmartGrid of size 10x10, using a GenericGridModel.
JSmartGrid(GridModel model)
          Constructs a JSmartGrid with a given GridModel, a null SpanModel, and a default StyleModel.
JSmartGrid(GridModel model, SpanModel spanModel)
          Constructs a JSmartGrid with a given GridModel, a given SpanModel, and a default StyleModel.
JSmartGrid(GridModel model, SpanModel spanModel, StyleModel styleModel)
          Constructs a JSmartGrid with a given GridModel, a given SpanModel, and a given StyleModel.
JSmartGrid(int rowCount, int columnCount)
          Constructs a JSmartGrid of a given size, using a GenericGridModel.
 
Method Summary
 void addGridEditingListener(GridEditingListener l)
          Adds a listener to the list that is notified each time an editing event occurs.
 void addGridListener(GridListener l)
          Adds a listener to the list that is notified each time a cell event occurs.
 void addNotify()
          Calls the configureEnclosingScrollPane method.
 void addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
          Adds an item to the vetoable property change listeners list.
 void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Adds an item to the vetoable property change listeners list.
 void anchorChanged(GridSelectionEvent event)
           
 void beforeItemsMoved(RulerModelEvent e)
          Received a prenotification that ruler items are to be moved.
 void changeSelection(int row, int column, boolean toggle, boolean extend)
          Updates the selection models of the grid, depending on the state of the two flags: toggle and extend.
 void clearSelection()
          Unselects all selected cells.
protected  java.awt.AWTEvent coalesceEvents(java.awt.AWTEvent existingEvent, java.awt.AWTEvent newEvent)
          Potentially coalesce an event being posted with an existing event.
 int columnAtPoint(java.awt.Point point)
          Returns the index of the column that point lies in.
 int columnAtX(int x)
          Returns the index of the column that x lies in.
protected  void columnsResized(int resizingItem)
          Call-back for column resizing.
protected  void configureEnclosingScrollPane()
          If this JSmartGrid is the viewportView of an enclosing JScrollPane (as is usually the case), configure this ScrollPane by installing the grid's gridHeaders as the HeaderViews of the scroll pane.
protected  RulerModel createDefaultColumnModel()
          Creates a default column model for an autonomous grid, based on the grid model dimension.
protected  RulerModel createDefaultRowModel()
          Creates a default row model for an autonomous grid, based on the grid model dimension.
protected  javax.swing.JComponent createHeader(int orientation)
          Creates a default header for this JSmartGrid object.
protected static javax.swing.JComponent createHeader(JSmartGrid mainGrid, int orientation)
          Creates the preferred header for a JSmartGrid with a DefaultHeaderModel and DefaultHeaderStyleModel.
protected static javax.swing.JComponent createHeader(JSmartGrid mainGrid, int orientation, GridModel gm, SpanModel sm, StyleModel uim)
          Creates the preferred header for a JSmartGrid with specific GridModel, SpanModel and StyleModel.
protected  javax.swing.CellRendererPane createRendererPane()
          Factory method to create the cellRendererPane used to render the cells.
protected  javax.swing.JComponent createTopLeft(JSmartGrid rowHeader, RulerModel rowHeaderHorizontalRuler, GridModel rhm, JSmartGrid columnHeader, RulerModel columnHeaderVerticalRuler, GridModel chm)
          Creates a default top left corner component for this grid.
protected  void doEnsurePreferredSizeAt(int orientation, int index)
          Computes automatically a "best"size for a given item on a given orientation, based on the renderers preferred sizes.
protected  void doEnsurePreferredSizeAt(int orientation, int index, boolean abovePref)
          Computes automatically a "best"size for a given item on a given orientation, based on the renderers preferred sizes.
 boolean editCellAt(int row, int column)
          Starts editing the cell at row and column, if the cell is editable.
 boolean editCellAt(int row, int column, java.util.EventObject e)
          Starts editing the cell at row and column, if the cell is editable.
 void editingCanceled(javax.swing.event.ChangeEvent e)
          Invoked when editing is canceled.
 void editingStopped(javax.swing.event.ChangeEvent e)
          Invoked when editing is finished.
 void ensureCellInVisibleRect(int row, int column, boolean isSpanSensitive)
          Ensures that a given cell is in the visible rectangle, scrolling the view if necessary.
protected  boolean ensureNarrowSizes()
          Computes automatic "best" sizes for the orientation on which the grid is dependent, unless it is fully dependent.
 void ensurePreferredSizeAt(int orientation, int index)
          Auto resize a column (resp. row).
protected  void fireEditingCanceled(int row, int column)
          Notifies registered listeners that editing was canceled in a given cell
protected  void fireEditingStarted(int row, int column)
          Notifies registered listeners that editing has started in a given cell
protected  void fireEditingStopped(int row, int column)
          Notifies registered listeners that editing is completed in a given cell
protected  void fireFocusGained(java.awt.event.InputEvent ie, int row, int column, int rowCount, int columnCount)
          Notifies registered listeners that the mouse exited a cell
protected  void fireFocusLost(java.awt.event.InputEvent ie, int row, int column, int rowCount, int columnCount)
          Notifies registered listeners that the mouse entered a cell
protected  void fireGridClicked(java.awt.event.MouseEvent me, int row, int column, int rowCount, int columnCount)
          Notifies registered listeners that a click occurred in a cell
protected  void fireGridDragged(java.awt.event.MouseEvent me, int row, int column, int rowCount, int columnCount)
          Notifies registered listeners that the mouse was dragged over a cell
protected  void fireGridEntered(java.awt.event.MouseEvent me, int row, int column, int rowCount, int columnCount)
          Notifies registered listeners that the mouse entered a cell
protected  void fireGridExited(java.awt.event.MouseEvent me, int row, int column, int rowCount, int columnCount)
          Notifies registered listeners that the mouse exited a cell
protected  void fireGridMoved(java.awt.event.MouseEvent me, int row, int column, int rowCount, int columnCount)
          Notifies registered listeners that the mouse was moved over a cell
protected  void fireGridPressed(java.awt.event.MouseEvent me, int row, int column, int rowCount, int columnCount)
          Notifies registered listeners that the mouse was pressed over a cell
protected  void fireGridReleased(java.awt.event.MouseEvent me, int row, int column, int rowCount, int columnCount)
          Notifies registered listeners that the mouse was released over a cell
 void flushToolTipCache()
          Invoked whenever the tooltips associated with cells components have changed, without the grid or style models having changed themselves.
 javax.accessibility.AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this JSmartGrid.
 JSmartGrid getActiveGrid(int orientation)
          Returns the grid on which this grid is dependent for the given orientation, null if none.
 javax.swing.border.Border getCellBorder()
          Returns the cell border for cells.
 java.awt.Rectangle getCellBounds(int row, int column, boolean isSpanSensitive, boolean includeSpacing, java.awt.Rectangle r)
          Returns a rectangle for the cell that lies logically at the intersection of row and column, covering any overspanned cells.
 java.awt.Dimension getCellMaximumSize(int row, int column)
          Returns the maximum size of a physical cell.
 java.awt.Dimension getCellMaximumSize(int row, int column, boolean isSpanSensitive)
          Returns the maximum size of a cell.
 java.awt.Dimension getCellMinimumSize(int row, int column)
          Returns the minimum size of a physical cell.
 java.awt.Dimension getCellMinimumSize(int row, int column, boolean isSpanSensitive)
          Returns the minimum size of a cell.
 java.awt.Dimension getCellPreferredSize(int row, int column)
          Returns the preferred size of a physical cell.
 java.awt.Dimension getCellPreferredSize(int row, int column, boolean isSpanSensitive)
          Returns the preferred size of a cell.
protected  GridCellRenderer getCellRenderer(int row, int column, int height, int width, java.lang.Object id)
          Returns an appropriate renderer for the cell specified by this row and column.
 JSmartGrid getColumnActiveGrid()
          Returns the grid on which this grid is dependent for the horizontal orientation, null if none.
 int getColumnAutoResizeMode()
          Returns the column auto resize mode of the grid.
 int getColumnCount()
           
 java.awt.Component getColumnHeader()
          Returns the component that serves as the horizontal header for this JSmartGrid, if any.
 int getColumnMargin()
          Gets the amount of empty space (in pixels) between cells.
 RulerModel getColumnModel()
          Returns the horizontal ruler model associated with this JSmartGrid.
 int getColumnPosition(int column)
          Returns the leftmost horizontal coordinate (in pixels) of the cells in column.
 int getColumnWidth(int column)
          Returns the width (in pixels) of the cells in column.
 GridCellEditor getCurrentCellEditor()
          Returns the cell editor.
 int getDraggingDistance(int orientation)
          Returns the dragging distance along the given orientation.
protected  java.awt.Component getEditorComponent()
          Returns the component that is handling the editing session.
 java.awt.Rectangle getEnclosure(int row0, int column0, int row1, int column1)
          Computes the smallest rectangle enclosing two given cells and that fully contains any span that it crosses.
 int getFirstDraggingItem(int orientation)
          Returns the index of the first item currently being dragged along the given orientation.
 int getFirstSelectedColumn()
           
 int getFirstSelectedRow()
           
 java.awt.Color getFocusBackgroundColor()
          Returns the background color for the cells that have the focus.
 java.awt.Color getFocusForegroundColor()
          Returns the foreground color for the cells that have the focus.
 javax.swing.border.Border getFocusHighlightBorder()
          Returns the highlight border for the cells that have the focus.
 java.awt.Color getGridColor()
          Returns the color used to draw grid lines.
 java.awt.Dimension getIntercellSpacing()
          Returns the horizontal and vertical space between cells.
 int getLastDraggingItem(int orientation)
          Returns the index of the last item currently being dragged along the given orientation.
 int getLastSelectedColumn()
           
 int getLastSelectedRow()
           
protected  int getListenerCount()
          Returns the numbers of listeners of all types (bar the listeners on property change events).
protected  int getListenerCount(java.lang.Class clazz)
          Returns the numbers of listeners of a given type.
 GridModel getModel()
          Returns the data model associated with this JSmartGrid.
 java.awt.Dimension getPreferredScrollableViewportSize()
          Returns the preferred size of the viewport for this table.
protected  GridContext getRendererContext(int row, int column, int height, int width, java.lang.Object identifier)
          Returns the JSmartGrid viewed as a GridContext for a given cell
 java.awt.Component getRenderingComponent(int row, int column)
          Returns the component suitable for a specific cell.
protected  java.awt.Component getRenderingComponent(int row, int column, boolean isSpanSensitive)
          Returns the component suitable for a specific cell.
 int getResizingItem()
          Returns the index of the item currently used to resize cells.
 int getResizingOrientation()
          Returns the orientation of the axis along which cells are currently resized.
 JSmartGrid getRowActiveGrid()
          Returns the grid on which this grid is dependent for the vertical orientation, null if none.
 int getRowAutoResizeMode()
          Returns the row auto resize mode of the grid.
 int getRowCount()
           
 java.awt.Component getRowHeader()
          Returns the component that serves as the vertical header for this JSmartGrid, if any.
 int getRowHeight(int row)
          Returns the height (in pixels) of the cells in row.
 int getRowMargin()
          Gets the amount of empty space (in pixels) between cells.
 RulerModel getRowModel()
          Returns the vertical ruler model associated with this JSmartGrid.
 int getRowPosition(int row)
          Returns the top vertical coordinate (in pixels) of the cells in row.
 RulerModel getRulerModel(int orientation)
          Returns one of the ruler models associated with this JSmartGrid.
 int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Returns the scroll increment (in pixels) that completely exposes one new "page".
 boolean getScrollableTracksViewportHeight()
          Decides whether the height of the viewport determines the height of the grid.
 boolean getScrollableTracksViewportWidth()
          Decides whether the width of the viewport determines the width of the grid.
 int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Returns the scroll increment (in pixels) that completely exposes one new row or column (depending on the orientation).
 java.awt.Rectangle getSelectableEnclosure(int row0, int column0, int row1, int column1)
           
 int getSelectedCellsCount(boolean isSpanSensitive)
          Returns the number of selected cells in the data model.
 int getSelectedColumnCount()
          Returns the number of selected columns.
 int[] getSelectedColumns()
          Returns the selected columns as an array of their indexes.
 int getSelectedRowCount()
          Returns the number of selected rows.
 int[] getSelectedRows()
          Returns the selected rows as an array of their indexes.
 java.awt.Color getSelectionBackgroundColor()
          Returns the background color for selected cells.
 javax.swing.border.Border getSelectionCellBorder()
          Returns the border for selected cells
 java.awt.Color getSelectionForegroundColor()
          Returns the foreground color for selected cells.
 int getSelectionMode()
          Returns the current selection mode.
 GridSelectionModel getSelectionModel()
          Returns the selection model associated with this JSmartGrid.
 int getSelectionPolicy()
          Returns the current selection policy.
 int getSelectionUnit()
          Returns the current selection unit.
 boolean getShowHorizontalLines()
          Returns true if the grid draws horizontal lines between cells, false if it doesn't.
 boolean getShowVerticalLines()
          Returns true if the grid draws vertical lines between cells, false if it doesn't.
 SpanModel getSpanModel()
          Returns the span model associated with this JSmartGrid.
 ExtentCell getSpanOver(int row, int column)
          Obtains the span which contains the cell at row, column.
 StyleModel getStyleModel()
          Returns the style model associated with this JSmartGrid.
 java.lang.String getToolTipText(java.awt.event.MouseEvent event)
          Returns the tooltip string that has been set with setToolTipText().
 GridUI getUI()
          Returns the Look & Feel object that renders this component.
 java.lang.String getUIClassID()
          Returns the suffix used to construct the name of the L&F class used to render this component.
 java.lang.Object getValueAt(int row, int column)
          Returns the cell value at row and column.
protected  javax.swing.JViewport getViewport()
          Returns the viewport containing the grid, when the grid has been embedded in a scroll pane.
 java.awt.Rectangle getVisibleRect()
          Returns the part of the grid that is currently not obscured by ancestors.
 void gridDataChanged(GridModelEvent e)
          Call-back from the GridModel after data was updated in some cells.
 void gridModelChanged(GridModelEvent e)
          Call-back from the GridModel after a global model change.
 void gridStructureChanged(GridModelEvent e)
          Call-back from the GridModel after a continuous block of either rows or columns was either inserted or deleted.
 void hideGrid()
          Supresses all forms of grid separation, both grid lines and intercells margins.
 void hierarchyChanged(java.awt.event.HierarchyEvent e)
          Called when the hierarchy has been changed.
protected  void initializeTransients()
          This is code that needs to be executed both by all constructorrs and by deserialization (readObject).
 boolean isAutoCreateColumnHeader()
          Returns true if a row header will be automatically created if the grid is set inside a javax.swing.JScrollPane.
 boolean isAutoCreateRowHeader()
          Returns true if a row header will be automatically created if the grid is set inside a javax.swing.JScrollPane.
 boolean isCellEditable(int row, int column, boolean isSpanSensitive)
          Returns true if the cell at row and column is editable.
 boolean isCellSelected(int row, int column, boolean isSpanSensitive)
          Returns true if the cell at the specified position is selected.
 boolean isColumnDraggable()
          Returns the draggability of columns in the grid.
 boolean isColumnHeader()
          Returns true if this grid is a column header, such that it is inside a scrollpane in the viewport reserved for column headers.
 boolean isColumnLeader()
          Returns true if this grid is active along the horizontal axis.
 boolean isColumnResizable()
          Returns the resizability of columns in the grid.
 boolean isColumnSelected(int column)
          Returns true if the specified column is selected.
 boolean isColumnVisible(int column)
          Returns the visibility of the column column.
 boolean isCorner()
          Returns true if this grid is a corner grid, such that it is inside a scrollpane in the viewport reserved for corner components.
 boolean isDraggable(int orientation)
          Returns the draggability of the grid for a given orientation.
 boolean isDragging(int orientation)
          Returns true if the grid is being dragged on a ruler chosen by an orientation.
 boolean isEditing()
          Returns true if a cell is being edited.
 boolean isFocusTraversable()
          This method, whose implementation in JComponent returns false, is overloaded to return true.
 boolean isLeader(int orientation)
          Returns true if this grid is active for the given orientation.
 boolean isManagingFocus()
          This method, whose implementation in JComponent returns false, is overloaded to return true.
 boolean isResizable(int orientation)
          Returns the resizability of the grid for a given orientation.
 boolean isResizing()
          Returns true if the grid is being resized along a given orientation.
 boolean isRowDraggable()
          Returns the draggability of rows in the grid.
 boolean isRowHeader()
          Returns true if this grid is a row header, such that it is inside a scrollpane in the viewport reserved for row headers.
 boolean isRowLeader()
          Returns true if this grid is active along the vertical axis.
 boolean isRowResizable()
          Returns the resizability of rows in the grid.
 boolean isRowSelected(int row)
          Returns true if the specified row is selected.
 boolean isRowVisible(int row)
          Returns the visibility, of the row row.
 boolean isSelectionEmpty()
          Returns true if no cells are selected.
 boolean isSpanEmpty()
          Returns true if there is no spanned cell.
protected  void paintComponent(java.awt.Graphics g)
          The JComponent method is overloaded here in order to cleanup the CellRenderPane used to "stencil" the individual cells onto the JSmartGrid background.
protected  java.awt.Component prepareRenderer(GridCellRenderer renderer, int row, int column, int height, int width, java.lang.Object id)
          Prepares a renderer for display of a specific cell, taking into account whether the cell is the current one, whether it is selected, or editable.
protected  boolean processKeyBinding(javax.swing.KeyStroke ks, java.awt.event.KeyEvent e, int condition, boolean pressed)
          Invoked to process the key bindings for ks as the result of the Keystroke e.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          This method is called when a bound property is changed.
 void rangeChanged(GridSelectionEvent event)
          Invoked when the selection changes -- repaints to show the new selection.
protected  void removeEditor(boolean canceled, boolean fireEvents)
          Discards the editor object and frees the real estate it used for cell rendering.
 void removeGridEditingListener(GridEditingListener l)
          Removes a listener from the list that is notified each time an editing event occurs.
 void removeGridListener(GridListener l)
          Removes a listener from the list that is notified each time a a cell event occurs.
 void removeNotify()
          Calls the unconfigureEnclosingScrollPane method.
 void removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
          Removes an item from the vetoable property change listeners list.
 void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Removes an item from the vetoable property change listeners list.
 void resetDragging(int orientation)
          Cancels all resizing along the given orientation
 void resizeAndRepaint()
          Equivalent to revalidate followed by repaint.
 int rowAtPoint(java.awt.Point point)
          Returns the index of the row that point lies in.
 int rowAtY(int y)
          Returns the index of the row that y lies in.
protected  void rowsResized(int resizingItem)
          Call-back for row resizing.
 void rulerDataChanged(RulerModelEvent e)
          Call-back for whenever the ruler presentation model changes.
 void rulerModelChanged(RulerModelEvent e)
          Call-back for global ruler model change.
 void rulerStructureChanged(RulerModelEvent e)
          Call back for insertions and removals of items.
 void scrollRectToVisible(java.awt.Rectangle contentRect)
           
 void selectAll()
          Selects all the cells in the grid.
 void setActiveGrid(JSmartGrid activeGrid, int orientation)
          Specifies a grid on which this grid will be dependent along the given orientation.
 void setAutoCreateColumnHeader(boolean flag)
          Determines whether a row header will be automatically created if the grid is set inside a javax.swing.JScrollPane.
 void setAutoCreateRowHeader(boolean flag)
          Determines whether a row header will be automatically created if the grid is set inside a javax.swing.JScrollPane.
 void setAutoResizeMode(int mode)
          Sets the grid's auto resize mode for both orientations.
 void setBounds(int x, int y, int width, int height)
          This method is overloaded here in order to enhance performance by communicating the area where efficient computations will be necessary.
 void setCellBorder(javax.swing.border.Border cellBorder)
          Sets the border for cells.
 void setColumnActiveGrid(JSmartGrid activeGrid)
          Specifies a grid on which this grid will be dependent for the horizontal orientation.
 void setColumnAutoResizeMode(int mode)
          Sets the grid's auto resize mode for the horizontal axis.
 void setColumnDraggable(boolean isDraggable)
          Changes the draggability of columns in the grid.
 void setColumnHeader(java.awt.Component c)
          Sets the component that serves as the horizontal header for this JSmartGrid.
 void setColumnMargin(int columnMargin)
          Sets the amount of empty space between cells in adjacent columns.
 void setColumnModel(RulerModel columnModel)
          Sets a ruler presentation model for columns.
 void setColumnResizable(boolean isResizable)
          Changes the resizability of columns in the grid.
 void setColumnVisible(int column, boolean flag)
          Sets the visibility for column.
 void setColumnWidth(int column, int columnWidth)
          Sets the width for column to columnWidth, revalidates, and repaints.
 void setDraggable(int orientation, boolean isDraggable)
          Changes the draggability of the grid for a given orientation.
 void setDraggingDistance(int orientation, int d)
          Changes the dragging distance along the given orientation.
 void setFirstDraggingItem(int orientation, int index)
          Sets the index of the first item currently being dragged along the given orientation.
 void setFocusBackgroundColor(java.awt.Color focusBackgroundColor)
          Sets the background color for the cells that have the focus.
 void setFocusForegroundColor(java.awt.Color focusForegroundColor)
          Sets the foreground color for the cells that have the focus.
 void setFocusHighlightBorder(javax.swing.border.Border focusHighlightBorder)
          Sets the highlight border for cells that have the focus.
 void setGridColor(java.awt.Color gridColor)
          Sets the color used to draw grid lines in gridColor and redisplays.
 void setIntercellSpacing(java.awt.Dimension intercellSpacing)
          Sets the rowMargin and the columnMargin -- the height and width of the space between cells -- to intercellSpacing.
 void setLastDraggingItem(int orientation, int index)
          Sets the index of the first item currently being dragged along the given orientation.
 void setModel(GridModel model)
          Sets the data model associated with this JSmartGrid.
 void setPreferredScrollableViewportSize(java.awt.Dimension size)
          Sets the preferred size of the viewport for this table.
 void setResizable(int orientation, boolean isResizable)
          Changes the resizability of the grid for a given orientation.
 void setResizing(int orientation, int index)
          Sets the resizing index property on a ruler chosen by an orientation.
 void setRowActiveGrid(JSmartGrid activeGrid)
          Specifies a grid on which this grid will be dependent for the vertical orientation.
 void setRowAutoResizeMode(int mode)
          Sets the grid's auto resize mode for the vertical axis.
 void setRowDraggable(boolean isDraggable)
          Changes the draggability of rows in the grid.
 void setRowHeader(java.awt.Component c)
          Sets the component that serves as the vertical header for this JSmartGrid.
 void setRowHeight(int row, int rowHeight)
          Sets the height for row to rowHeight, revalidates, and repaints.
 void setRowMargin(int rowMargin)
          Sets the amount of empty space between cells in adjacent rows.
 void setRowModel(RulerModel rowModel)
          Sets a ruler model for rows.
 void setRowResizable(boolean isResizable)
          Changes the resizability of rows in the grid.
 void setRowVisible(int row, boolean flag)
          Sets the visibility for row.
 void setRulerModel(RulerModel rulerModel)
          Attaches a ruler model.
 void setSelectionBackgroundColor(java.awt.Color selectionBackgroundColor)
          Sets the background color for selected cells.
 void setSelectionCellBorder(javax.swing.border.Border selectionCellBorder)
          Sets the border for selected cells.
 void setSelectionForegroundColor(java.awt.Color selectionForegroundColor)
          Sets the foreground color for selected cells.
 void setSelectionMode(int mode)
          Sets the selection mode.
 void setSelectionModel(GridSelectionModel model)
          Associates a new selection model with this JSmartGrid.
 void setSelectionPolicy(int policy)
          Sets the selection policy.
 void setSelectionUnit(int unit)
          Sets the selection unit.
 void setShowGrid(boolean showGrid)
          Sets whether the grid draws grid lines around cells.
 void setShowHorizontalLines(boolean showHorizontalLines)
          Sets whether the grid draws horizontal lines between cells.
 void setShowVerticalLines(boolean showVerticalLines)
          Sets whether the grid draws vertical lines between cells.
 void setSpanModel(SpanModel spanModel)
          Sets the span model associated with this JSmartGrid.
 void setStyleModel(StyleModel styleModel)
          Sets the style model associated with this JSmartGrid.
 void setUI(GridUI ui)
          Sets the Look & Feel object that renders this component and repaints.
 void setValueAt(java.lang.Object aValue, int row, int column)
          Sets the value for the cell in the grid model at row and column.
 void spanDataChanged(SpanModelEvent e)
          Call-back from the SpanModel after spans are modified, added or removed.
 java.util.Iterator spanIterator(int topRow, int leftColumn, int rowCount, int columnCount, boolean withUnspanned)
          Obtains the spans intersecting a given rectangle (in cell positions).
 void spanModelChanged(SpanModelEvent e)
          Call-back from the SpanModel after all the span information changes.
 void spanStructureChanged(SpanModelEvent e)
          Call-back from the SpanModel after the underlying model shape is changed.
 void styleDataChanged(StyleModelEvent e)
          Tells listeners that the renderer model was changed.
 void styleModelChanged(StyleModelEvent e)
          Tells listeners that the model was changed.
 void styleStructureChanged(StyleModelEvent e)
          Called when new renderer/editors are registered or when renderer/editors are forgotten
 void takeLeadershipOver(JSmartGrid grid, int orientation)
          Makes this grid the active one along the given orientation, making another grid dependent.
protected  void unconfigureEnclosingScrollPane()
          Reverses the effect of configureEnclosingScrollPane by removing the HeaderViews of the enclosing scroll pane.
 void updateUI()
          Notification from the UIManager that the L&F has changed.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JSmartGrid

public JSmartGrid(GridModel model,
                  SpanModel spanModel,
                  StyleModel styleModel)
Constructs a JSmartGrid with a given GridModel, a given SpanModel, and a given StyleModel.

JSmartGrid

public JSmartGrid(GridModel model,
                  SpanModel spanModel)
Constructs a JSmartGrid with a given GridModel, a given SpanModel, and a default StyleModel.

JSmartGrid

public JSmartGrid(GridModel model)
Constructs a JSmartGrid with a given GridModel, a null SpanModel, and a default StyleModel. Default models are generated for spans, selection and ruler.

JSmartGrid

public JSmartGrid(int rowCount,
                  int columnCount)
Constructs a JSmartGrid of a given size, using a GenericGridModel. Default models are generated for span, selection and rulers.

JSmartGrid

public JSmartGrid()
Constructs a default JSmartGrid of size 10x10, using a GenericGridModel. Default models are generated for span, selection and rulers.
Method Detail

initializeTransients

protected final void initializeTransients()
This is code that needs to be executed both by all constructorrs and by deserialization (readObject). It mainly initializes transient attributes to other than default values. Since this method must be called by constructors, it cannot be overloaded.

getModel

public final GridModel getModel()
Returns the data model associated with this JSmartGrid.

setModel

public void setModel(GridModel model)
Sets the data model associated with this JSmartGrid.

getSpanModel

public final SpanModel getSpanModel()
Returns the span model associated with this JSmartGrid.

setSpanModel

public void setSpanModel(SpanModel spanModel)
Sets the span model associated with this JSmartGrid.

getStyleModel

public final StyleModel getStyleModel()
Returns the style model associated with this JSmartGrid.

setStyleModel

public void setStyleModel(StyleModel styleModel)
Sets the style model associated with this JSmartGrid.

getSelectionModel

public final GridSelectionModel getSelectionModel()
Returns the selection model associated with this JSmartGrid.

setSelectionModel

public void setSelectionModel(GridSelectionModel model)
Associates a new selection model with this JSmartGrid.

isRowHeader

public boolean isRowHeader()
Returns true if this grid is a row header, such that it is inside a scrollpane in the viewport reserved for row headers.

isColumnHeader

public boolean isColumnHeader()
Returns true if this grid is a column header, such that it is inside a scrollpane in the viewport reserved for column headers.

isCorner

public boolean isCorner()
Returns true if this grid is a corner grid, such that it is inside a scrollpane in the viewport reserved for corner components.

getActiveGrid

public JSmartGrid getActiveGrid(int orientation)
Returns the grid on which this grid is dependent for the given orientation, null if none.

isLeader

public boolean isLeader(int orientation)
Returns true if this grid is active for the given orientation.

getRowActiveGrid

public JSmartGrid getRowActiveGrid()
Returns the grid on which this grid is dependent for the vertical orientation, null if none.

isRowLeader

public boolean isRowLeader()
Returns true if this grid is active along the vertical axis.

getColumnActiveGrid

public JSmartGrid getColumnActiveGrid()
Returns the grid on which this grid is dependent for the horizontal orientation, null if none.

isColumnLeader

public boolean isColumnLeader()
Returns true if this grid is active along the horizontal axis.

setRowActiveGrid

public void setRowActiveGrid(JSmartGrid activeGrid)
Specifies a grid on which this grid will be dependent for the vertical orientation.

setColumnActiveGrid

public void setColumnActiveGrid(JSmartGrid activeGrid)
Specifies a grid on which this grid will be dependent for the horizontal orientation.

setActiveGrid

public void setActiveGrid(JSmartGrid activeGrid,
                          int orientation)
Specifies a grid on which this grid will be dependent along the given orientation.

takeLeadershipOver

public void takeLeadershipOver(JSmartGrid grid,
                               int orientation)
Makes this grid the active one along the given orientation, making another grid dependent.

createDefaultRowModel

protected RulerModel createDefaultRowModel()
Creates a default row model for an autonomous grid, based on the grid model dimension. The ruler auto resize mode is RulerConstants.AUTO_RESIZE_OFF.

createDefaultColumnModel

protected RulerModel createDefaultColumnModel()
Creates a default column model for an autonomous grid, based on the grid model dimension. The ruler auto resize mode is RulerConstants.AUTO_RESIZE_OFF if the grid is vertically dependent, and RulerConstants.AUTO_RESIZE_SUBSEQUENT if the grid is fully autonomous.

createRendererPane

protected javax.swing.CellRendererPane createRendererPane()
Factory method to create the cellRendererPane used to render the cells.

getRowModel

public final RulerModel getRowModel()
Returns the vertical ruler model associated with this JSmartGrid.

setRulerModel

public void setRulerModel(RulerModel rulerModel)
Attaches a ruler model.
Parameters:
rulerModel - the ruler model to be attached to the grid. It will be attached horizontally or vertically according to its orientation property.

ensureNarrowSizes

protected boolean ensureNarrowSizes()
Computes automatic "best" sizes for the orientation on which the grid is dependent, unless it is fully dependent.

setRowModel

public void setRowModel(RulerModel rowModel)
Sets a ruler model for rows.
Parameters:
rowModel - a vertical ruler model.

getColumnModel

public final RulerModel getColumnModel()
Returns the horizontal ruler model associated with this JSmartGrid.

setColumnModel

public void setColumnModel(RulerModel columnModel)
Sets a ruler presentation model for columns.
Parameters:
columnModel - A horizontal ruler model.

getRulerModel

public final RulerModel getRulerModel(int orientation)
Returns one of the ruler models associated with this JSmartGrid.

getViewport

protected javax.swing.JViewport getViewport()
Returns the viewport containing the grid, when the grid has been embedded in a scroll pane.

getRowHeader

public java.awt.Component getRowHeader()
Returns the component that serves as the vertical header for this JSmartGrid, if any.

getColumnHeader

public java.awt.Component getColumnHeader()
Returns the component that serves as the horizontal header for this JSmartGrid, if any.

setColumnHeader

public void setColumnHeader(java.awt.Component c)
Sets the component that serves as the horizontal header for this JSmartGrid.

setRowHeader

public void setRowHeader(java.awt.Component c)
Sets the component that serves as the vertical header for this JSmartGrid.

getFocusForegroundColor

public java.awt.Color getFocusForegroundColor()
Returns the foreground color for the cells that have the focus.
Returns:
the Color object for the foreground property
See Also:
setFocusForegroundColor(java.awt.Color), getFocusBackgroundColor(), getFocusHighlightBorder(), getSelectionForegroundColor(), getSelectionBackgroundColor(), Component.setForeground(java.awt.Color), Component.setBackground(java.awt.Color), Component.setFont(java.awt.Font)

setFocusForegroundColor

public void setFocusForegroundColor(java.awt.Color focusForegroundColor)
Sets the foreground color for the cells that have the focus. Cell renderers can use this color to render text and graphics for focused cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
focusForegroundColor - the foreground Color used for focused cells
See Also:
getFocusForegroundColor(), getSelectionForegroundColor(), getSelectionBackgroundColor(), Component.setForeground(java.awt.Color), Component.setBackground(java.awt.Color), Component.setFont(java.awt.Font)

getFocusBackgroundColor

public java.awt.Color getFocusBackgroundColor()
Returns the background color for the cells that have the focus.
Returns:
the Color object for the background property
See Also:
setFocusBackgroundColor(java.awt.Color), getFocusForegroundColor(), getFocusHighlightBorder(), getSelectionBackgroundColor(), getSelectionForegroundColor(), Component.setForeground(java.awt.Color), Component.setBackground(java.awt.Color), Component.setFont(java.awt.Font)

setFocusBackgroundColor

public void setFocusBackgroundColor(java.awt.Color focusBackgroundColor)
Sets the background color for the cells that have the focus. Cell renderers can use this color to render text and graphics for focused cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
focusBackgroundColor - the background Color used for focused cells
See Also:
getFocusBackgroundColor(), getFocusHighlightBorder(), setFocusHighlightBorder(javax.swing.border.Border), setFocusForegroundColor(java.awt.Color), getFocusForegroundColor(), getSelectionForegroundColor(), setSelectionBackgroundColor(java.awt.Color), Component.setForeground(java.awt.Color), Component.setBackground(java.awt.Color), Component.setFont(java.awt.Font)

getFocusHighlightBorder

public javax.swing.border.Border getFocusHighlightBorder()
Returns the highlight border for the cells that have the focus.
Returns:
the Border object used for focused cells
See Also:
setFocusHighlightBorder(javax.swing.border.Border)

setFocusHighlightBorder

public void setFocusHighlightBorder(javax.swing.border.Border focusHighlightBorder)
Sets the highlight border for cells that have the focus. Cell renderers can use this border to render text and graphics for focused cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
focusCellHighlightBorder - the Border used for focused cells
See Also:
getFocusHighlightBorder(), getFocusBackgroundColor(), setFocusForegroundColor(java.awt.Color), JComponent.setBorder(javax.swing.border.Border)

getCellBorder

public javax.swing.border.Border getCellBorder()
Returns the cell border for cells.
Returns:
the cell Border object used for cells
See Also:
setCellBorder(javax.swing.border.Border)

setCellBorder

public void setCellBorder(javax.swing.border.Border cellBorder)
Sets the border for cells. Cell renderers can use this border to render text and graphics. cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
cellBorder - the Border used for cells
See Also:
getCellBorder(), getFocusHighlightBorder(), setFocusHighlightBorder(javax.swing.border.Border), JComponent.setBorder(javax.swing.border.Border)

getSelectionCellBorder

public javax.swing.border.Border getSelectionCellBorder()
Returns the border for selected cells
Returns:
the cell Border object used for cells selected
See Also:
setSelectionCellBorder(javax.swing.border.Border)

setSelectionCellBorder

public void setSelectionCellBorder(javax.swing.border.Border selectionCellBorder)
Sets the border for selected cells. Cell renderers can use this border to render text and graphics.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
cellBorder - the Border used for selected cells
See Also:
getSelectionCellBorder(), getFocusHighlightBorder(), setFocusHighlightBorder(javax.swing.border.Border), JComponent.setBorder(javax.swing.border.Border)

getSelectionForegroundColor

public java.awt.Color getSelectionForegroundColor()
Returns the foreground color for selected cells.
Returns:
the Color object for the foreground property
See Also:
setSelectionForegroundColor(java.awt.Color), setSelectionBackgroundColor(java.awt.Color)

setSelectionForegroundColor

public void setSelectionForegroundColor(java.awt.Color selectionForegroundColor)
Sets the foreground color for selected cells. Cell renderers can use this color to render text and graphics for selected cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
selectionForeground - the Color used in the foreground for selected list items
See Also:
getSelectionForegroundColor(), setSelectionBackgroundColor(java.awt.Color), Component.setForeground(java.awt.Color), Component.setBackground(java.awt.Color), Component.setFont(java.awt.Font)

getSelectionBackgroundColor

public java.awt.Color getSelectionBackgroundColor()
Returns the background color for selected cells.
Returns:
the Color used for the background of selected list items
See Also:
setSelectionBackgroundColor(java.awt.Color), setSelectionForegroundColor(java.awt.Color)

setSelectionBackgroundColor

public void setSelectionBackgroundColor(java.awt.Color selectionBackgroundColor)
Sets the background color for selected cells. Cell renderers can use this color to the fill selected cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
selectionBackground - the Color used for the background of selected cells
See Also:
getSelectionBackgroundColor(), setSelectionForegroundColor(java.awt.Color), Component.setForeground(java.awt.Color), Component.setBackground(java.awt.Color), Component.setFont(java.awt.Font)

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
This method is overloaded here in order to enhance performance by communicating the area where efficient computations will be necessary.
Overrides:
setBounds in class java.awt.Component

getVisibleRect

public java.awt.Rectangle getVisibleRect()
Returns the part of the grid that is currently not obscured by ancestors. When the grid has been put inside a javax.swing.JScrollPane, this is the part that the JViewport is displaying.
Overrides:
getVisibleRect in class javax.swing.JComponent

setRowVisible

public void setRowVisible(int row,
                          boolean flag)
Sets the visibility for row.
Parameters:
row - the row whose visibility is being changed
flag - the new row visibility

isRowVisible

public boolean isRowVisible(int row)
Returns the visibility, of the row row.
Parameters:
row - the column whose visibility is to be returned
Returns:
the visibility of the row

setRowHeight

public void setRowHeight(int row,
                         int rowHeight)
Sets the height for row to rowHeight, revalidates, and repaints. The height of the cells in this row will be equal to the row height minus the row margin.
Parameters:
row - the row whose height is being changed
rowHeight - the new row height (in pixels)
Throws:
java.lang.IllegalArgumentException - if rowHeight is less than 1

getRowHeight

public int getRowHeight(int row)
Returns the height (in pixels) of the cells in row.
Parameters:
row - the row whose height is to be returned
Returns:
the height (in pixels) of the cells in the row

getRowPosition

public int getRowPosition(int row)
Returns the top vertical coordinate (in pixels) of the cells in row.
Parameters:
row - the row whose position is to be returned
Returns:
the top position (in pixels) of the cells in the row

setColumnVisible

public void setColumnVisible(int column,
                             boolean flag)
Sets the visibility for column.
Parameters:
column - the column whose visibility is being changed
flag - new column visibility

isColumnVisible

public boolean isColumnVisible(int column)
Returns the visibility of the column column.
Parameters:
column - the column whose visibility is to be returned
Returns:
the visibility of the column

setColumnWidth

public void setColumnWidth(int column,
                           int columnWidth)
Sets the width for column to columnWidth, revalidates, and repaints. The width of the cells in this column will be equal to the column width minus the column margin.
Parameters:
column - the column whose width is being changed
columnWidth - new column width (in pixels)
Throws:
java.lang.IllegalArgumentException - if columnWidth is less than 1

getColumnWidth

public int getColumnWidth(int column)
Returns the width (in pixels) of the cells in column.
Parameters:
column - the column whose width is to be returned
Returns:
the width (in pixels) of the cells in the column

getColumnPosition

public int getColumnPosition(int column)
Returns the leftmost horizontal coordinate (in pixels) of the cells in column.
Parameters:
column - the column whose position is to be returned
Returns:
the leftmost position (in pixels) of the cells in the column

setRowMargin

public void setRowMargin(int rowMargin)
Sets the amount of empty space between cells in adjacent rows.
Parameters:
rowMargin - the number of pixels between cells in a row
See Also:
getRowMargin()

getRowMargin

public int getRowMargin()
Gets the amount of empty space (in pixels) between cells. Equivalent to: getIntercellSpacing().height.
Returns:
the number of pixels between cells in a row
See Also:
setRowMargin(int)

setColumnMargin

public void setColumnMargin(int columnMargin)
Sets the amount of empty space between cells in adjacent columns.
Parameters:
columnMargin - the number of pixels between cells in a column
See Also:
getColumnMargin()

getColumnMargin

public int getColumnMargin()
Gets the amount of empty space (in pixels) between cells. Equivalent to: getIntercellSpacing().width.
Returns:
the number of pixels between cells in a column
See Also:
setColumnMargin(int)

setIntercellSpacing

public void setIntercellSpacing(java.awt.Dimension intercellSpacing)
Sets the rowMargin and the columnMargin -- the height and width of the space between cells -- to intercellSpacing.
Parameters:
intercellSpacing - a Dimension specifying the new width and height between cells
See Also:
getIntercellSpacing()

getIntercellSpacing

public java.awt.Dimension getIntercellSpacing()
Returns the horizontal and vertical space between cells. The default spacing is (1, 1), which provides room to draw the grid.
Returns:
the horizontal and vertical spacing between cells
See Also:
setIntercellSpacing(java.awt.Dimension)

hideGrid

public void hideGrid()
Supresses all forms of grid separation, both grid lines and intercells margins.

setGridColor

public void setGridColor(java.awt.Color gridColor)
Sets the color used to draw grid lines in gridColor and redisplays. The default color is Color.gray.
Parameters:
gridColor - the new color of the grid lines
Throws:
java.lang.IllegalArgumentException - if gridColor is null
See Also:
getGridColor()

getGridColor

public java.awt.Color getGridColor()
Returns the color used to draw grid lines. The default color is Color.gray.
Returns:
the color used to draw grid lines
See Also:
setGridColor(java.awt.Color)

setShowGrid

public void setShowGrid(boolean showGrid)
Sets whether the grid draws grid lines around cells. If showGrid is true it does; if false, it doesn't. There is no getShowGrid method as this state is held in two variables -- showHorizontalLines and showVerticalLines -- each of which can be queried independently.
Parameters:
showGrid - true if the grid view should draw grid lines
See Also:
setShowVerticalLines(boolean), setShowHorizontalLines(boolean)

setShowHorizontalLines

public void setShowHorizontalLines(boolean showHorizontalLines)
Sets whether the grid draws horizontal lines between cells. If showHorizontalLines is true it does; if false, it doesn't.
Parameters:
showHorizontalLines - true if the grid view should draw horizontal lines
See Also:
getShowHorizontalLines(), setShowGrid(boolean), setShowVerticalLines(boolean)

setShowVerticalLines

public void setShowVerticalLines(boolean showVerticalLines)
Sets whether the grid draws vertical lines between cells. If showVerticalLines is true it does; if it is false it doesn't.
Parameters:
showVerticalLines - true if grid view should draw vertical lines
See Also:
getShowVerticalLines(), setShowGrid(boolean), setShowHorizontalLines(boolean)

getShowHorizontalLines

public boolean getShowHorizontalLines()
Returns true if the grid draws horizontal lines between cells, false if it doesn't. The default is true.
Returns:
true if the grid draws horizontal lines between cells, false if it doesn't
See Also:
setShowHorizontalLines(boolean)

getShowVerticalLines

public boolean getShowVerticalLines()
Returns true if the grid draws vertical lines between cells, false if it doesn't. The default is true.
Returns:
true if the grid draws vertical lines between cells, false if it doesn't
See Also:
setShowVerticalLines(boolean)

isResizable

public boolean isResizable(int orientation)
Returns the resizability of the grid for a given orientation. The default value is false.
Parameters:
orientation - the axis for which the resizable property is queried.
Returns:
the resizability of the grid
Preconditions:
orientation == HORIZONTAL || orientation == VERTICAL
See Also:
setResizable(int, boolean)

setRowResizable

public void setRowResizable(boolean isResizable)
Changes the resizability of rows in the grid. The default value is false.
Parameters:
isResizable - the new value of the resizable property.
See Also:
setColumnResizable(boolean)

setColumnResizable

public void setColumnResizable(boolean isResizable)
Changes the resizability of columns in the grid. The default value is false.
Parameters:
isResizable - the new value of the resizable property.
See Also:
setColumnResizable(boolean)

isRowResizable

public boolean isRowResizable()
Returns the resizability of rows in the grid. The default value is false.
Returns:
the resizability of rows in the grid
See Also:
setRowResizable(boolean)

isColumnResizable

public boolean isColumnResizable()
Returns the resizability of columns in the grid. The default value is false.
Returns:
the resizability of columns in the grid
See Also:
setColumnResizable(boolean)

setResizable

public void setResizable(int orientation,
                         boolean isResizable)
Changes the resizability of the grid for a given orientation. The default value is false.
Parameters:
orientation - the axis for which the resizable property is changed
isResizable - the new value of the resizable property for the orientation
Preconditions:
orientation == HORIZONTAL || orientation == VERTICAL
See Also:
isResizable(int)

isResizing

public boolean isResizing()
Returns true if the grid is being resized along a given orientation.
Returns:
true if the grid is being resized on a ruler chosen by an orientation.
See Also:
setResizing(int, int), getResizingItem(), getResizingOrientation()

setResizing

public void setResizing(int orientation,
                        int index)
                 throws java.beans.PropertyVetoException
Sets the resizing index property on a ruler chosen by an orientation. Note:  If orientation == -1 and index == -1 then we stop resizing.
Parameters:
orientation - the axis on which resizing is being done.
index - the index of the item origin of the resizing.
Preconditions:
orientation == HORIZONTAL || orientation == VERTICAL
See Also:
getResizingItem(), getResizingOrientation()

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds an item to the vetoable property change listeners list.
Overrides:
addVetoableChangeListener in class javax.swing.JComponent

addVetoableChangeListener

public void addVetoableChangeListener(java.lang.String propertyName,
                                      java.beans.VetoableChangeListener listener)
Adds an item to the vetoable property change listeners list.

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes an item from the vetoable property change listeners list.
Overrides:
removeVetoableChangeListener in class javax.swing.JComponent

removeVetoableChangeListener

public void removeVetoableChangeListener(java.lang.String propertyName,
                                         java.beans.VetoableChangeListener listener)
Removes an item from the vetoable property change listeners list.

getResizingOrientation

public int getResizingOrientation()
Returns the orientation of the axis along which cells are currently resized.

getResizingItem

public int getResizingItem()
Returns the index of the item currently used to resize cells.

ensurePreferredSizeAt

public void ensurePreferredSizeAt(int orientation,
                                  int index)
Auto resize a column (resp. row).
Parameters:
mode - One of 5 legal values:
See Also:
setResizable(int,boolean)

doEnsurePreferredSizeAt

protected void doEnsurePreferredSizeAt(int orientation,
                                       int index)
Computes automatically a "best"size for a given item on a given orientation, based on the renderers preferred sizes.

doEnsurePreferredSizeAt

protected void doEnsurePreferredSizeAt(int orientation,
                                       int index,
                                       boolean abovePref)
Computes automatically a "best"size for a given item on a given orientation, based on the renderers preferred sizes. Renderers which are spanned across the given dimension are ignored. abovePref is currently not used

setAutoResizeMode

public void setAutoResizeMode(int mode)
Sets the grid's auto resize mode for both orientations.
Parameters:
mode - One of 5 legal values:
See Also:
getRowAutoResizeMode(), getColumnAutoResizeMode(), RulerModel.sizeToFit(int)

setRowAutoResizeMode

public void setRowAutoResizeMode(int mode)
Sets the grid's auto resize mode for the vertical axis.
Parameters:
mode - One of 5 legal values:
See Also:
getRowAutoResizeMode(), getColumnAutoResizeMode(), RulerModel.sizeToFit(int)

setColumnAutoResizeMode

public void setColumnAutoResizeMode(int mode)
Sets the grid's auto resize mode for the horizontal axis.
Parameters:
mode - One of 5 legal values:
See Also:
getRowAutoResizeMode(), getColumnAutoResizeMode(), RulerModel.sizeToFit(int)

getRowAutoResizeMode

public int getRowAutoResizeMode()
Returns the row auto resize mode of the grid. The default mode is RulerConstants.AUTO_RESIZE_SUBSEQUENT.
Returns:
the rowAutoResizeMode of the grid
See Also:
setRowAutoResizeMode(int), RulerModel.sizeToFit(int)

getColumnAutoResizeMode

public int getColumnAutoResizeMode()
Returns the column auto resize mode of the grid. The default mode is RulerConstants.AUTO_RESIZE_SUBSEQUENT.
Returns:
the columnAutoResizeMode of the grid
See Also:
setColumnAutoResizeMode(int), RulerModel.sizeToFit(int)

isDraggable

public boolean isDraggable(int orientation)
Returns the draggability of the grid for a given orientation. The default value is false.
Parameters:
orientation - the axis for which the draggable property is queried.
Returns:
the draggability of the grid
Preconditions:
orientation == HORIZONTAL || orientation == VERTICAL
See Also:
setDraggable(int, boolean)

setRowDraggable

public void setRowDraggable(boolean isDraggable)
Changes the draggability of rows in the grid. The default value is false.
Parameters:
isDraggable - the new value of the draggable property.
See Also:
setColumnDraggable(boolean)

setColumnDraggable

public void setColumnDraggable(boolean isDraggable)
Changes the draggability of columns in the grid. The default value is false.
Parameters:
isDraggable - the new value of the draggable property.
See Also:
setColumnDraggable(boolean)

isRowDraggable

public boolean isRowDraggable()
Returns the draggability of rows in the grid. The default value is false.
Returns:
the draggability of rows in the grid
See Also:
setRowDraggable(boolean)

isColumnDraggable

public boolean isColumnDraggable()
Returns the draggability of columns in the grid. The default value is false.
Returns:
the draggability of columns in the grid
See Also:
setColumnDraggable(boolean)

setDraggable

public void setDraggable(int orientation,
                         boolean isDraggable)
Changes the draggability of the grid for a given orientation. The default value is false.
Parameters:
orientation - the axis for which the draggable property is changed
isDraggable - the new value of the draggable property for the orientation
Preconditions:
orientation == HORIZONTAL || orientation == VERTICAL
See Also:
isDraggable(int)

isDragging

public boolean isDragging(int orientation)
Returns true if the grid is being dragged on a ruler chosen by an orientation.
Parameters:
orientation - the orientation of the ruler of interest.
Returns:
true if the grid is being dragged on a ruler chosen by an orientation.
See Also:
setFirstDraggingItem(int, int), getFirstDraggingItem(int)

getFirstDraggingItem

public int getFirstDraggingItem(int orientation)
Returns the index of the first item currently being dragged along the given orientation.
Preconditions:
isDragging(orientation)

setFirstDraggingItem

public void setFirstDraggingItem(int orientation,
                                 int index)
Sets the index of the first item currently being dragged along the given orientation.
Preconditions:
isDraggable(orientation)

getLastDraggingItem

public int getLastDraggingItem(int orientation)
Returns the index of the last item currently being dragged along the given orientation.
Preconditions:
isDragging(orientation)

setLastDraggingItem

public void setLastDraggingItem(int orientation,
                                int index)
Sets the index of the first item currently being dragged along the given orientation.
Preconditions:
isDraggable(orientation) && isDragging(orientation)

getDraggingDistance

public int getDraggingDistance(int orientation)
Returns the dragging distance along the given orientation.
Preconditions:
isDragging(orientation)

setDraggingDistance

public void setDraggingDistance(int orientation,
                                int d)
Changes the dragging distance along the given orientation.
Preconditions:
isDraggable(orientation) && isDragging(orientation)

resetDragging

public void resetDragging(int orientation)
Cancels all resizing along the given orientation

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
This method is called when a bound property is changed.
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - a PropertyChangeEvent object describing the event source and the property that has changed.

hierarchyChanged

public void hierarchyChanged(java.awt.event.HierarchyEvent e)
Called when the hierarchy has been changed. To see the actual type of change, call HierarchyEvent.getChangeFlags().

We are mainly interested in the removal of a master grid from the hierarchy.

Specified by:
hierarchyChanged in interface java.awt.event.HierarchyListener
See Also:
HierarchyEvent.getChangeFlags()

flushToolTipCache

public void flushToolTipCache()
Invoked whenever the tooltips associated with cells components have changed, without the grid or style models having changed themselves.

columnsResized

protected void columnsResized(int resizingItem)
Call-back for column resizing.

rowsResized

protected void rowsResized(int resizingItem)
Call-back for row resizing.

rulerModelChanged

public void rulerModelChanged(RulerModelEvent e)
Call-back for global ruler model change.
Specified by:
rulerModelChanged in interface RulerModelListener

rulerStructureChanged

public void rulerStructureChanged(RulerModelEvent e)
Call back for insertions and removals of items.
Specified by:
rulerStructureChanged in interface RulerModelListener

rulerDataChanged

public void rulerDataChanged(RulerModelEvent e)
Call-back for whenever the ruler presentation model changes. It is dispatched according to the direction of the ruler
Specified by:
rulerDataChanged in interface RulerModelListener
Parameters:
e - the event that characterizes the change.

beforeItemsMoved

public void beforeItemsMoved(RulerModelEvent e)
                      throws java.beans.PropertyVetoException
Received a prenotification that ruler items are to be moved. The grid propagates a property change, and propagates back a possible veto.
Specified by:
beforeItemsMoved in interface RulerModelListener

isCellEditable

public boolean isCellEditable(int row,
                              int column,
                              boolean isSpanSensitive)
Returns true if the cell at row and column is editable. Otherwise, invoking setValueAt on the cell will have no effect.
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
isSpanSensitive - if true, the row and column actually used are the ones of the spanned cell over the given row and column, if any.
Returns:
true if the cell is editable
See Also:
setValueAt(java.lang.Object, int, int)

getRowCount

public int getRowCount()
Returns:
the number of rows in this grid's model.
See Also:
getColumnCount()

getColumnCount

public int getColumnCount()
Returns:
the number of columns in the grid's model.
See Also:
getRowCount()

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Returns the cell value at row and column.

Note: The row and column actually used are those of the spanned cell over the given row and column, if any.

Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
the Object at the specified cell

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int row,
                       int column)
Sets the value for the cell in the grid model at row and column.

Note: The row and column actually used are those of the spanned cell over the given row and column, if any. aValue is the new value.

Parameters:
aValue - the new value
row - the row of the cell to be changed
column - the column of the cell to be changed
See Also:
getValueAt(int, int)

rowAtY

public int rowAtY(int y)
Returns the index of the row that y lies in.
Parameters:
y - the vertical coordinate of interest.
Returns:
the index of the row that y lies in.
Postconditions:
y < 0 implies return == -1
y >= getRowModel().getTotalSize() implies return == getRowCount()
y >= 0 && y < getRowModel().getTotalSize() implies return >= 0 && return < getRowCount()
See Also:
columnAtX(int)

rowAtPoint

public int rowAtPoint(java.awt.Point point)
Returns the index of the row that point lies in.
Parameters:
point - the location of interest
Returns:
the index of the row that point lies in.
See Also:
rowAtY(int), columnAtPoint(java.awt.Point)

columnAtX

public int columnAtX(int x)
Returns the index of the column that x lies in.
Parameters:
x - the horizontal coordinate of interest.
Returns:
the index of the column that x lies in.
Postconditions:
x < 0 implies return == -1
x >= getColumnModel().getTotalSize() implies return == getColumnCount()
x >= 0 && x < getColumnModel().getTotalSize() implies return >= 0 && return < getColumnCount()
See Also:
rowAtY(int)

columnAtPoint

public int columnAtPoint(java.awt.Point point)
Returns the index of the column that point lies in.
Parameters:
point - the location of interest
Returns:
the index of the column that point lies in.
See Also:
columnAtX(int)

ensureCellInVisibleRect

public void ensureCellInVisibleRect(int row,
                                    int column,
                                    boolean isSpanSensitive)
Ensures that a given cell is in the visible rectangle, scrolling the view if necessary.
Parameters:
row - the row of the cell of interest
column - the column of the cell of interest
isSpanSensitive - if true, and if there is a span over the given cell, we shall try to make all of it visible.

scrollRectToVisible

public void scrollRectToVisible(java.awt.Rectangle contentRect)
Overrides:
scrollRectToVisible in class javax.swing.JComponent

getCellBounds

public java.awt.Rectangle getCellBounds(int row,
                                        int column,
                                        boolean isSpanSensitive,
                                        boolean includeSpacing,
                                        java.awt.Rectangle r)
Returns a rectangle for the cell that lies logically at the intersection of row and column, covering any overspanned cells. If includeSpacing is true then the value returned has the full height and width of the row and column covered. If it is false, the returned rectangle is inset by the intercell spacing to return the true bounds of the rendering or editing component as it will be set during rendering.

If the row index is valid but the column index is less than zero, the method returns a rectangle with the y and height values set appropriately and the x and width values both set to zero. In general, when either the row or column indices indicate a cell outside the appropriate range, the method returns a rectangle depicting the closest edge of the closest cell that is within the table's range. When both row and column indices are out of range, the returned rectangle covers the closest point of the closest cell.

In all cases, calulations that use this method to calculate results along one axis will not fail because of anomalies in calculations along the other axis. When the cell is not valid the includeSpacing parameter is ignored.

Parameters:
isSpanSensitive - if true, the rectangle computed will be the one of the spanned cell over the given row and column, if any.
includeSpacing - if false, return the true cell bounds - computed by subtracting the intercell spacing from the height and width of the column and row models.
Returns:
the rectangle containing the cell at location row, column

getSelectionUnit

public int getSelectionUnit()
Returns the current selection unit.
Returns:
the value of the selectionUnit property.
See Also:
setSelectionUnit(int), GridSelectionModel.getSelectionUnit()

setSelectionUnit

public void setSelectionUnit(int unit)
Sets the selection unit.
See Also:
getSelectionUnit(), GridSelectionModel.getSelectionUnit()

getSelectionPolicy

public int getSelectionPolicy()
Returns the current selection policy.
Returns:
the value of the selectionPolicy property.
See Also:
setSelectionPolicy(int), GridSelectionModel.getSelectionPolicy()

setSelectionPolicy

public void setSelectionPolicy(int policy)
Sets the selection policy.
See Also:
getSelectionPolicy(), GridSelectionModel.getSelectionPolicy()

getSelectionMode

public int getSelectionMode()
Returns the current selection mode.
Returns:
the value of the selectionMode property.
Postconditions:
return == getSelectionPolicy() * getSelectionUnit()
See Also:
setSelectionMode(int)

setSelectionMode

public void setSelectionMode(int mode)
Sets the selection mode.
See Also:
getSelectionMode()

isCellSelected

public boolean isCellSelected(int row,
                              int column,
                              boolean isSpanSensitive)
Returns true if the cell at the specified position is selected.
Parameters:
row - the row being queried
column - the column being queried
isSpanSensitive - if true, the row and column actually used are those of the spanned cell over the given row and column, if any.
Returns:
true if the cell at index (row, column) is selected, where the first row and first column are at index 0
Throws:
java.lang.IllegalArgumentException - if row or column are not in the valid range

isRowSelected

public boolean isRowSelected(int row)
Returns true if the specified row is selected.
Parameters:
row - the row tested
Returns:
false in this implementation.

isColumnSelected

public boolean isColumnSelected(int column)
Returns true if the specified column is selected.
Parameters:
column - the column tested
Returns:
false in this implementation.

isSelectionEmpty

public boolean isSelectionEmpty()
Returns true if no cells are selected.

getFirstSelectedRow

public int getFirstSelectedRow()

getLastSelectedRow

public int getLastSelectedRow()

getFirstSelectedColumn

public int getFirstSelectedColumn()

getLastSelectedColumn

public int getLastSelectedColumn()

getSelectedCellsCount

public int getSelectedCellsCount(boolean isSpanSensitive)
Returns the number of selected cells in the data model.
Parameters:
isSpanSensitive - if true, we do not count physical cells which are overspanned by others.

getSelectedRowCount

public int getSelectedRowCount()
Returns the number of selected rows.
Returns:
0 in this implementation.

getSelectedColumnCount

public int getSelectedColumnCount()
Returns the number of selected columns.
Returns:
0 in this implementation.

getSelectedRows

public int[] getSelectedRows()
Returns the selected rows as an array of their indexes.
Returns:
null in this implementation

getSelectedColumns

public int[] getSelectedColumns()
Returns the selected columns as an array of their indexes.
Returns:
null in this implementation

getEnclosure

public java.awt.Rectangle getEnclosure(int row0,
                                       int column0,
                                       int row1,
                                       int column1)
Computes the smallest rectangle enclosing two given cells and that fully contains any span that it crosses.

getSelectableEnclosure

public java.awt.Rectangle getSelectableEnclosure(int row0,
                                                 int column0,
                                                 int row1,
                                                 int column1)

changeSelection

public void changeSelection(int row,
                            int column,
                            boolean toggle,
                            boolean extend)
Updates the selection models of the grid, depending on the state of the two flags: toggle and extend. All changes to the selection that are the result of keyboard or mouse events received by the UI are channeled through this method so that the behavior may be overridden by a subclass. The behavior defined here is similar to the one in the javax.swing.JTable, but it is truly two-dimensional while the JTable uses a combination of two linear behaviors. Spanned cells are also taken into account.

This implementation uses the following conventions:

Parameters:
row - affects the selection at row.
column - affects the selection at column.
toggle - see description above.
extend - if true, extends the current selection.

selectAll

public void selectAll()
Selects all the cells in the grid.

clearSelection

public void clearSelection()
Unselects all selected cells.

getSpanOver

public ExtentCell getSpanOver(int row,
                              int column)
Obtains the span which contains the cell at row, column. Delegated to the model.
Parameters:
row - the row of a cell.
column - the column a cell.
Returns:
the span containing this cell, null if there is none.

isSpanEmpty

public boolean isSpanEmpty()
Returns true if there is no spanned cell.

spanIterator

public java.util.Iterator spanIterator(int topRow,
                                       int leftColumn,
                                       int rowCount,
                                       int columnCount,
                                       boolean withUnspanned)
Obtains the spans intersecting a given rectangle (in cell positions).
Parameters:
topRow - the top row of the rectangle of interest.
leftColumn - the leftnost column of the rectangle of interest.
rowCount - the height of the rectangle of interest.
columnCount - the width of the rectangle of interest.
withUnspanned - if true, even non-spanned cells will be returned, in the form of trivial spans of (1,1) dimension.
Returns:
an iterator that will loop on all concerned spans.

gridModelChanged

public void gridModelChanged(GridModelEvent e)
Call-back from the GridModel after a global model change.
Specified by:
gridModelChanged in interface GridModelListener

gridStructureChanged

public void gridStructureChanged(GridModelEvent e)
Call-back from the GridModel after a continuous block of either rows or columns was either inserted or deleted.
Specified by:
gridStructureChanged in interface GridModelListener

gridDataChanged

public void gridDataChanged(GridModelEvent e)
Call-back from the GridModel after data was updated in some cells.
Specified by:
gridDataChanged in interface GridModelListener

spanStructureChanged

public void spanStructureChanged(SpanModelEvent e)
Call-back from the SpanModel after the underlying model shape is changed.
Specified by:
spanStructureChanged in interface SpanModelListener

spanDataChanged

public void spanDataChanged(SpanModelEvent e)
Call-back from the SpanModel after spans are modified, added or removed.
Specified by:
spanDataChanged in interface SpanModelListener

spanModelChanged

public void spanModelChanged(SpanModelEvent e)
Call-back from the SpanModel after all the span information changes.
Specified by:
spanModelChanged in interface SpanModelListener

styleModelChanged

public void styleModelChanged(StyleModelEvent e)
Tells listeners that the model was changed. That means all renderers and editors were changed.
Specified by:
styleModelChanged in interface StyleModelListener

styleStructureChanged

public void styleStructureChanged(StyleModelEvent e)
Called when new renderer/editors are registered or when renderer/editors are forgotten
Specified by:
styleStructureChanged in interface StyleModelListener

styleDataChanged

public void styleDataChanged(StyleModelEvent e)
Tells listeners that the renderer model was changed. That means all renderers were changed to the StyleModel.
Specified by:
styleDataChanged in interface StyleModelListener

rangeChanged

public void rangeChanged(GridSelectionEvent event)
Invoked when the selection changes -- repaints to show the new selection.

Application code will not use these methods explicitly, they are used internally by JSmartGrid.

Specified by:
rangeChanged in interface GridSelectionListener
Parameters:
e - the event received
See Also:
GridSelectionListener

anchorChanged

public void anchorChanged(GridSelectionEvent event)
Specified by:
anchorChanged in interface GridSelectionListener

coalesceEvents

protected java.awt.AWTEvent coalesceEvents(java.awt.AWTEvent existingEvent,
                                           java.awt.AWTEvent newEvent)
Potentially coalesce an event being posted with an existing event. This method is called by EventQueue.postEvent if an event with the same ID as the event to be posted is found in the queue (both events must have this component as their source). This method either returns a coalesced event which replaces the existing event (and the new event is then discarded), or null to indicate that no combining should be done (add the second event to the end of the queue). Either event parameter may be modified and returned as the other one is discarded unless null is returned.

This implementation of coalesceEvents coalesces only paint events.

Parameters:
existingEvent - the event already on the EventQueue.
newEvent - the event being posted to the EventQueue.
Returns:
a coalesced event, or null indicating that no coalescing was done.
Overrides:
coalesceEvents in class java.awt.Component

resizeAndRepaint

public void resizeAndRepaint()
Equivalent to revalidate followed by repaint.

addNotify

public void addNotify()
Calls the configureEnclosingScrollPane method.
Overrides:
addNotify in class javax.swing.JComponent
See Also:
configureEnclosingScrollPane()

createTopLeft

protected javax.swing.JComponent createTopLeft(JSmartGrid rowHeader,
                                               RulerModel rowHeaderHorizontalRuler,
                                               GridModel rhm,
                                               JSmartGrid columnHeader,
                                               RulerModel columnHeaderVerticalRuler,
                                               GridModel chm)
Creates a default top left corner component for this grid. This component will be automatically installed only if both headers are automatically created and installed.
Returns:
null, the grid has by default no top left corner.

createHeader

protected static javax.swing.JComponent createHeader(JSmartGrid mainGrid,
                                                     int orientation)
Creates the preferred header for a JSmartGrid with a DefaultHeaderModel and DefaultHeaderStyleModel.

createHeader

protected static javax.swing.JComponent createHeader(JSmartGrid mainGrid,
                                                     int orientation,
                                                     GridModel gm,
                                                     SpanModel sm,
                                                     StyleModel uim)
Creates the preferred header for a JSmartGrid with specific GridModel, SpanModel and StyleModel.

createHeader

protected javax.swing.JComponent createHeader(int orientation)
Creates a default header for this JSmartGrid object.

isAutoCreateRowHeader

public boolean isAutoCreateRowHeader()
Returns true if a row header will be automatically created if the grid is set inside a javax.swing.JScrollPane.

setAutoCreateRowHeader

public void setAutoCreateRowHeader(boolean flag)
Determines whether a row header will be automatically created if the grid is set inside a javax.swing.JScrollPane.

isAutoCreateColumnHeader

public boolean isAutoCreateColumnHeader()
Returns true if a row header will be automatically created if the grid is set inside a javax.swing.JScrollPane.

setAutoCreateColumnHeader

public void setAutoCreateColumnHeader(boolean flag)
Determines whether a row header will be automatically created if the grid is set inside a javax.swing.JScrollPane.

configureEnclosingScrollPane

protected void configureEnclosingScrollPane()
If this JSmartGrid is the viewportView of an enclosing JScrollPane (as is usually the case), configure this ScrollPane by installing the grid's gridHeaders as the HeaderViews of the scroll pane. When a JSmartGrid is added to a JScrollPane by using new JScrollPane(myGrid), addNotify is called in the JSmartGrid (when the table is added to the viewport). JSmartGrid's addNotify method in turn calls this method, which is protected so that this default installation procedure can be overridden by a subclass.
See Also:
addNotify()

removeNotify

public void removeNotify()
Calls the unconfigureEnclosingScrollPane method.
Overrides:
removeNotify in class javax.swing.JComponent
See Also:
unconfigureEnclosingScrollPane()

unconfigureEnclosingScrollPane

protected void unconfigureEnclosingScrollPane()
Reverses the effect of configureEnclosingScrollPane by removing the HeaderViews of the enclosing scroll pane. JSmartGrid's removeNotify method calls this method, which is protected so that this default uninstallation procedure can be overridden by a subclass.
See Also:
removeNotify(), configureEnclosingScrollPane()

getUI

public GridUI getUI()
Returns the Look & Feel object that renders this component.
Returns:
the GridUI object that renders this component

setUI

public void setUI(GridUI ui)
Sets the Look & Feel object that renders this component and repaints.
Parameters:
ui - the GridUI L&F object
See Also:
UIDefaults.getUI(javax.swing.JComponent)

updateUI

public void updateUI()
Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.
Overrides:
updateUI in class javax.swing.JComponent
See Also:
JComponent.updateUI()

getUIClassID

public java.lang.String getUIClassID()
Returns the suffix used to construct the name of the L&F class used to render this component.
Returns:
the string "GridUI"
Overrides:
getUIClassID in class javax.swing.JComponent
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

getRendererContext

protected GridContext getRendererContext(int row,
                                         int column,
                                         int height,
                                         int width,
                                         java.lang.Object identifier)
Returns the JSmartGrid viewed as a GridContext for a given cell
Parameters:
row - the topmost row occupied by the cell
column - the leftmost row occupied by the cell
height - the number of rows occupied by the cell
width - the number of column occupied by the cell
See Also:
GridContext, GridCellRenderer, GridCellEditor

editingStopped

public void editingStopped(javax.swing.event.ChangeEvent e)
Invoked when editing is finished. The changes are saved and the editor is discarded.

Application code will not use these methods explicitly, they are used internally by JSmartGrid.

Specified by:
editingStopped in interface javax.swing.event.CellEditorListener
Parameters:
e - the event received
See Also:
CellEditorListener

editingCanceled

public void editingCanceled(javax.swing.event.ChangeEvent e)
Invoked when editing is canceled. The editor object is discarded and the cell is rendered once again.

Application code will not use these methods explicitly, they are used internally by JSmartGrid.

Specified by:
editingCanceled in interface javax.swing.event.CellEditorListener
Parameters:
e - the event received
See Also:
CellEditorListener

getCurrentCellEditor

public GridCellEditor getCurrentCellEditor()
Returns the cell editor.
Returns:
the GridCellEditor that does the editing

removeEditor

protected void removeEditor(boolean canceled,
                            boolean fireEvents)
Discards the editor object and frees the real estate it used for cell rendering.

editCellAt

public boolean editCellAt(int row,
                          int column)
Starts editing the cell at row and column, if the cell is editable.
Parameters:
row - the row to be edited
column - the column to be edited
Returns:
false if for any reason the cell cannot be edited
Throws:
java.lang.IllegalArgumentException - If row or column is not in the valid range

editCellAt

public boolean editCellAt(int row,
                          int column,
                          java.util.EventObject e)
Starts editing the cell at row and column, if the cell is editable. To prevent the JSmartGrid from editing a particular grid, column or cell value, return false from the isCellEditable method in the GridModel interface.
Parameters:
row - the row to be edited
column - the column to be edited
e - event to pass into shouldSelectCell
Returns:
false if for any reason the cell cannot be edited
Throws:
java.lang.IllegalArgumentException - if row or column is not in the valid range

isEditing

public boolean isEditing()
Returns true if a cell is being edited.
Returns:
true if the grid is editing a cell

getEditorComponent

protected java.awt.Component getEditorComponent()
Returns the component that is handling the editing session. If nothing is being edited, returns null.
Returns:
component handling editing session

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Decides whether the width of the viewport determines the width of the grid.
Specified by:
getScrollableTracksViewportWidth in interface javax.swing.Scrollable
Returns:
true if the column auto resize feature is automatically adjusted.
See Also:
Scrollable.getScrollableTracksViewportWidth()

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Decides whether the height of the viewport determines the height of the grid.
Specified by:
getScrollableTracksViewportHeight in interface javax.swing.Scrollable
Returns:
true if the row auto resize feature is automatically adjusted.
See Also:
Scrollable.getScrollableTracksViewportHeight()

getScrollableUnitIncrement

public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Returns the scroll increment (in pixels) that completely exposes one new row or column (depending on the orientation). This method is called each time the user requests a unit scroll.

Delegated to the RulerModel.

Specified by:
getScrollableUnitIncrement in interface javax.swing.Scrollable
Parameters:
visibleRect - the view area visible within the viewport
orientation - either VERTICAL or HORIZONTAL
direction - less than zero to scroll up/left, greater than zero for down/right
Returns:
the "unit" increment for scrolling in the specified direction
See Also:
Scrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)

getScrollableBlockIncrement

public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Returns the scroll increment (in pixels) that completely exposes one new "page". This method is called each time the user requests a page scroll.

Delegated to the RulerModel.

Specified by:
getScrollableBlockIncrement in interface javax.swing.Scrollable
See Also:
Scrollable.getScrollableBlockIncrement(java.awt.Rectangle, int, int)

setPreferredScrollableViewportSize

public void setPreferredScrollableViewportSize(java.awt.Dimension size)
Sets the preferred size of the viewport for this table.
Parameters:
size - a Dimension object specifying the preferredSize of a JViewport whose view is this table
See Also:
Scrollable.getPreferredScrollableViewportSize()

getPreferredScrollableViewportSize

public java.awt.Dimension getPreferredScrollableViewportSize()
Returns the preferred size of the viewport for this table.
Specified by:
getPreferredScrollableViewportSize in interface javax.swing.Scrollable
Returns:
a Dimension object containing the preferredSize of the JViewport which displays this table
See Also:
Scrollable.getPreferredScrollableViewportSize()

getCellMinimumSize

public java.awt.Dimension getCellMinimumSize(int row,
                                             int column,
                                             boolean isSpanSensitive)
Returns the minimum size of a cell.
Parameters:
row - a row identifying the cell whose minimum size is queried.
column - a column identifying the cell whose minimum size is queried.
isSpanSensitive - if true, the dimension computed will be that of the spanned cell over the given row and column, if any.

getCellMinimumSize

public java.awt.Dimension getCellMinimumSize(int row,
                                             int column)
Returns the minimum size of a physical cell.
Postconditions:
return == getCellMinimumSize(row,column,false);

getCellPreferredSize

public java.awt.Dimension getCellPreferredSize(int row,
                                               int column,
                                               boolean isSpanSensitive)
Returns the preferred size of a cell.
Parameters:
row - a row identifying the cell whose preferred size is queried.
column - a column identifying the cell whose preferred size is queried.
isSpanSensitive - if true, the dimension computed will be that of the spanned cell over the given row and column, if any.

getCellPreferredSize

public java.awt.Dimension getCellPreferredSize(int row,
                                               int column)
Returns the preferred size of a physical cell.
Postconditions:
return == getCellPreferredSize(row,column,false);

getCellMaximumSize

public java.awt.Dimension getCellMaximumSize(int row,
                                             int column,
                                             boolean isSpanSensitive)
Returns the maximum size of a cell.
Parameters:
row - a row identifying the cell whose maximum size is queried.
column - a column identifying the cell whose maximum size is queried.
isSpanSensitive - if true, the dimension computed will be that of the spanned cell over the given row and column, if any.

getCellMaximumSize

public java.awt.Dimension getCellMaximumSize(int row,
                                             int column)
Returns the maximum size of a physical cell.
Postconditions:
return == getCellMaximumSize(row,column,false);

getCellRenderer

protected GridCellRenderer getCellRenderer(int row,
                                           int column,
                                           int height,
                                           int width,
                                           java.lang.Object id)
Returns an appropriate renderer for the cell specified by this row and column. Finds the class of the data in the cell (using the value) and returns the default renderer for this type of data.

Note: Throughout the grid package, the internal implementations always use this method to provide renderers so that this default behavior can be safely overridden by a subclass.

Parameters:
row - the row of the cell to render, where 0 is the first row
column - the column of the cell to render, where 0 is the first column
Returns:
the assigned renderer; if null, returns the default renderer for this type of object

prepareRenderer

protected java.awt.Component prepareRenderer(GridCellRenderer renderer,
                                             int row,
                                             int column,
                                             int height,
                                             int width,
                                             java.lang.Object id)
Prepares a renderer for display of a specific cell, taking into account whether the cell is the current one, whether it is selected, or editable. Span computations have already been done.

Note: Throughout the grid package, the internal implementations always use this method to prepare renderers so that this default behavior can be safely overridden by a subclass.

Parameters:
renderer - a renderer obtained from a call to getCellRenderer(int, int, int, int, java.lang.Object).
row - the row of the cell to render, where 0 is the first row.
column - the column of the cell to render, where 0 is the first column.
height - the height of the cell to render, may be > 1 if the cell is spanned.
width - the width of the cell to render, may be > 1 if the cell is spanned.
Returns:
the awt component ready for display.

getRenderingComponent

protected java.awt.Component getRenderingComponent(int row,
                                                   int column,
                                                   boolean isSpanSensitive)
Returns the component suitable for a specific cell. The caller of the method is usually interested by geometrical attributes, such as the preferred size.
Parameters:
row - the row of the cell to render, where 0 is the first row.
column - the column of the cell to render, where 0 is the first column.
isSpanSensitive - if true, the row and column actually used are the ones of the spanned cell over the given row and column, if any.
Returns:
the awt component ready for display.

getRenderingComponent

public java.awt.Component getRenderingComponent(int row,
                                                int column)
Returns the component suitable for a specific cell. It this component is not intended for display, purely visual attributes are ignored. The caller of the method is usually interested by geometrical attributes, such as the preferred size. Spans are automatically taken into account.
Parameters:
row - the row of the cell to render, where 0 is the first row.
column - the column of the cell to render, where 0 is the first column.
Returns:
the awt component ready for display.

paintComponent

protected void paintComponent(java.awt.Graphics g)
The JComponent method is overloaded here in order to cleanup the CellRenderPane used to "stencil" the individual cells onto the JSmartGrid background.
Overrides:
paintComponent in class javax.swing.JComponent

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
Returns the tooltip string that has been set with setToolTipText().
Overrides:
getToolTipText in class javax.swing.JComponent

isManagingFocus

public boolean isManagingFocus()
This method, whose implementation in JComponent returns false, is overloaded to return true. This allows us to give a special meaning to TAB and SHIFT-TAB in the JSmartGrid.
Returns:
true
Overrides:
isManagingFocus in class javax.swing.JComponent

isFocusTraversable

public boolean isFocusTraversable()
This method, whose implementation in JComponent returns false, is overloaded to return true. This indicates that the JSmartGrid is a component that should be part of a tabbing focus cycle by default.
Returns:
true
Overrides:
isFocusTraversable in class javax.swing.JComponent

processKeyBinding

protected boolean processKeyBinding(javax.swing.KeyStroke ks,
                                    java.awt.event.KeyEvent e,
                                    int condition,
                                    boolean pressed)
Invoked to process the key bindings for ks as the result of the Keystroke e. This contains the appropriate InputMap, gets the binding, gets the action from the ActionMap, and then (if the action is found and the receiver is enabled) invokes NotifyAction to notify the action.
Returns:
true if there was a binding to an action, and the action was enabled.
Overrides:
processKeyBinding in class javax.swing.JComponent

getListenerCount

protected int getListenerCount()
Returns the numbers of listeners of all types (bar the listeners on property change events).

getListenerCount

protected int getListenerCount(java.lang.Class clazz)
Returns the numbers of listeners of a given type.
Parameters:
clazz - a class potentially used for registering listeners, usually a listener interface. A listener actually registered on clazz should be an instance of some class that implements clazz (or is a subclass of clazz if it is not an interface).

addGridEditingListener

public void addGridEditingListener(GridEditingListener l)
Adds a listener to the list that is notified each time an editing event occurs.
Parameters:
l - the GridEditingListener

removeGridEditingListener

public void removeGridEditingListener(GridEditingListener l)
Removes a listener from the list that is notified each time an editing event occurs.
Parameters:
l - the GridEditingListener

fireEditingStarted

protected void fireEditingStarted(int row,
                                  int column)
Notifies registered listeners that editing has started in a given cell
Parameters:
row - the row of the cell where editing has started
column - the column of the cell where editing has started

fireEditingStopped

protected void fireEditingStopped(int row,
                                  int column)
Notifies registered listeners that editing is completed in a given cell
Parameters:
row - the row of the cell where editing was completed
column - the column of the cell where editing was completed

fireEditingCanceled

protected void fireEditingCanceled(int row,
                                   int column)
Notifies registered listeners that editing was canceled in a given cell
Parameters:
row - the row of the cell where editing was canceled
column - the column of the cell where editing was canceled

addGridListener

public void addGridListener(GridListener l)
Adds a listener to the list that is notified each time a cell event occurs.
Parameters:
l - the GridListener

removeGridListener

public void removeGridListener(GridListener l)
Removes a listener from the list that is notified each time a a cell event occurs.
Parameters:
l - the GridListener

fireGridClicked

protected void fireGridClicked(java.awt.event.MouseEvent me,
                               int row,
                               int column,
                               int rowCount,
                               int columnCount)
Notifies registered listeners that a click occurred in a cell
Parameters:
row - the row of the cell where the click occurred
column - the column of the cell where the click occurred

fireGridPressed

protected void fireGridPressed(java.awt.event.MouseEvent me,
                               int row,
                               int column,
                               int rowCount,
                               int columnCount)
Notifies registered listeners that the mouse was pressed over a cell
Parameters:
row - the row of the cell where the press occurred
column - the column of the cell where the press occurred

fireGridDragged

protected void fireGridDragged(java.awt.event.MouseEvent me,
                               int row,
                               int column,
                               int rowCount,
                               int columnCount)
Notifies registered listeners that the mouse was dragged over a cell
Parameters:
row - the row of the cell where the drag occurred
column - the column of the cell where the drag occurred

fireGridMoved

protected void fireGridMoved(java.awt.event.MouseEvent me,
                             int row,
                             int column,
                             int rowCount,
                             int columnCount)
Notifies registered listeners that the mouse was moved over a cell
Parameters:
row - the row of the cell where the move occurred
column - the column of the cell where the move occurred

fireGridReleased

protected void fireGridReleased(java.awt.event.MouseEvent me,
                                int row,
                                int column,
                                int rowCount,
                                int columnCount)
Notifies registered listeners that the mouse was released over a cell
Parameters:
row - the row of the cell where the release occurred
column - the column of the cell where release click occurred

fireGridEntered

protected void fireGridEntered(java.awt.event.MouseEvent me,
                               int row,
                               int column,
                               int rowCount,
                               int columnCount)
Notifies registered listeners that the mouse entered a cell
Parameters:
row - the row of the cell that was entered
column - the column of the cell that was entered

fireGridExited

protected void fireGridExited(java.awt.event.MouseEvent me,
                              int row,
                              int column,
                              int rowCount,
                              int columnCount)
Notifies registered listeners that the mouse exited a cell
Parameters:
row - the row of the cell that was exited
column - the column of the cell that was exited

fireFocusLost

protected void fireFocusLost(java.awt.event.InputEvent ie,
                             int row,
                             int column,
                             int rowCount,
                             int columnCount)
Notifies registered listeners that the mouse entered a cell
Parameters:
row - the row of the cell that was entered
column - the column of the cell that was entered

fireFocusGained

protected void fireFocusGained(java.awt.event.InputEvent ie,
                               int row,
                               int column,
                               int rowCount,
                               int columnCount)
Notifies registered listeners that the mouse exited a cell
Parameters:
row - the row of the cell that was exited
column - the column of the cell that was exited

getAccessibleContext

public javax.accessibility.AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JSmartGrid.
Specified by:
getAccessibleContext in interface javax.accessibility.Accessible
Returns:
the AccessibleContext of this JSmartGrid
Overrides:
getAccessibleContext in class javax.swing.JComponent