|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--net.sf.jeppers.grid.JGrid
The JGrid is used to display and edit regular two-dimensional grid of cells. Unlike JTable which is fundamentally vertical in that the structure is determined in the columns, while the rows contain the data. JGrid is symmetrical with respect to the vertical and the horizontal orientations. JGrid also allows for cells to be merged into bigger rectangular arrays, called spans.
Field Summary | |
protected GridCellEditor |
cellEditor
The object that overwrites the screen real estate occupied by the current cell and allows the user to change its contents. |
protected RulerModel |
columnModel
|
protected static int |
DEFAULT_COLUMN_WIDTH
|
protected static int |
DEFAULT_ROW_HEIGHT
|
protected int |
editingColumn
Identifies the column of the cell being edited. |
protected int |
editingRow
Identifies the row of the cell being edited. |
protected Component |
editorComp
If editing, the Component that is handling the editing. |
protected GridModel |
gridModel
|
protected Dimension |
preferredViewportSize
Used by the Scrollable interface to determine the initial visible area. |
protected GridRepaintManager |
repaintMgr
|
protected RulerModel |
rowModel
|
protected SelectionModel |
selectionModel
|
protected SpanModel |
spanModel
|
protected StyleModel |
styleModel
|
Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
JGrid()
|
|
JGrid(GridModel gridModel,
SpanModel spanModel,
StyleModel styleModel)
|
|
JGrid(int rows,
int columns)
|
Method Summary | |
void |
changeSelection(int row,
int column,
boolean toggle,
boolean extend)
|
int |
columnAtPoint(Point point)
Return the column at the specified point |
protected void |
create(GridModel gridModel,
SpanModel spanModel,
StyleModel styleModel,
RulerModel rowModel,
RulerModel columnModel,
SelectionModel selectionModel)
|
boolean |
editCellAt(int row,
int column)
|
boolean |
editCellAt(int row,
int column,
EventObject e)
Programmatically starts editing the cell at row and
column , if the cell is editable. |
void |
editingCanceled(ChangeEvent e)
Invoked when editing is canceled. |
void |
editingStopped(ChangeEvent e)
Invoked when editing is finished. |
void |
ensureCellInVisibleRect(int row,
int column)
|
Rectangle |
getCellBounds(int row,
int column)
Get cell bounds of (row, column) |
GridCellEditor |
getCellEditor(int row,
int column)
|
GridCellRenderer |
getCellRenderer(int row,
int column)
|
int |
getColumnCount()
Returns the number of columns in this grid's model. |
RulerModel |
getColumnModel()
|
int |
getColumnPosition(int column)
Return the left horizontal coordinate (in pixels) of column |
int |
getColumnWidth(int column)
Returns the width (in pixels) of column . |
GridCellEditor |
getCurrentCellEditor()
Return the current cell editor |
int |
getEditingColumn()
Returns the index of the column that contains the cell currently being edited. |
int |
getEditingRow()
Returns the index of the row that contains the cell currently being edited. |
Component |
getEditorComponent()
Returns the component that is handling the editing session. |
Color |
getFocusBackgroundColor()
Returns the background color for cells with focus. |
Color |
getFocusForegroundColor()
Returns the foreground color for cells with focus. |
Color |
getGridColor()
Returns the color used to draw grid lines. |
GridModel |
getGridModel()
|
Dimension |
getPreferredScrollableViewportSize()
Returns the preferred size of the viewport for this table. |
int |
getRowCount()
Returns the number of rows in this grid's model. |
int |
getRowHeight(int row)
Returns the height (in pixels) of row . |
RulerModel |
getRowModel()
|
int |
getRowPosition(int row)
Return the top vertical coordinate (in pixels) of row |
int |
getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction)
Returns visibleRect.height or
visibleRect.width ,
depending on this spreadsheet's orientation. |
boolean |
getScrollableTracksViewportHeight()
Returns false to indicate that the height of the viewport does not determine the height of the spreadsheet. |
boolean |
getScrollableTracksViewportWidth()
Returns false to indicate that the width of the viewport does not determine the width of the spreadsheet. |
int |
getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)
Returns the scroll increment (in pixels) that completely exposes one new row or column (depending on the orientation). |
Color |
getSelectionBackgroundColor()
Returns the background color for selected cells. |
Color |
getSelectionForegroundColor()
Returns the foreground color for selected cells. |
SelectionModel |
getSelectionModel()
|
boolean |
getShowGrid()
Returns true if the grid draws grid lines. |
SpanModel |
getSpanModel()
|
StyleModel |
getStyleModel()
|
GridUI |
getUI()
Returns the L&F object that renders this component. |
String |
getUIClassID()
Returns a string that specifies the name of the l&f class that renders this component. |
Object |
getValueAt(int row,
int column)
|
void |
gridChanged(GridModelEvent event)
Sync row and column sizes between models |
boolean |
isCellSpan(int row,
int column)
|
boolean |
isEditing()
Returns true if a cell is being edited. |
boolean |
isSelected(int row,
int column)
|
Component |
prepareEditor(GridCellEditor editor,
int row,
int column)
Prepares the editor for cell(row, column) |
Component |
prepareRenderer(GridCellRenderer renderer,
int row,
int column)
Prepares the renderer for painting cell(row,column) |
protected boolean |
processKeyBinding(KeyStroke keyStroke,
KeyEvent keyEvent,
int condition,
boolean pressed)
|
void |
removeEditor()
Discards the editor object and frees the real estate it used for cell rendering. |
void |
resizeAndRepaint()
|
int |
rowAtPoint(Point point)
Return the row at the specified point |
void |
setColumnWidth(int column,
int width)
Sets the width for column to width . |
void |
setEditingColumn(int aColumn)
Sets the editingColumn variable. |
void |
setEditingRow(int aRow)
Sets the editingRow variable. |
void |
setFocusBackgroundColor(Color focusBackgroundColor)
Sets the background color for cells with focus. |
void |
setFocusForegroundColor(Color focusForegroundColor)
Sets the foreground color for cells with focus. |
void |
setGridColor(Color gridColor)
Sets the color used to draw grid lines. |
void |
setGridModel(GridModel model)
|
void |
setPreferredScrollableViewportSize(Dimension size)
Sets the preferred size of the viewport for this table. |
void |
setRowHeight(int row,
int height)
Sets the height for row to height . |
void |
setSelectionBackgroundColor(Color selectionBackgroundColor)
Sets the background color for selected cells. |
void |
setSelectionForegroundColor(Color selectionForegroundColor)
Sets the foreground color for selected cells. |
void |
setSelectionModel(SelectionModel model)
|
void |
setShowGrid(boolean show)
Sets wether grid lines should be drawn. |
void |
setSpanModel(SpanModel model)
|
void |
setStyleModel(StyleModel model)
|
void |
setUI(GridUI ui)
Sets the L&F object that renders this component. |
void |
setValueAt(Object value,
int row,
int column)
|
protected void |
updateRepaintManager()
|
void |
updateUI()
Notification from the UIFactory that the L&F has changed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final int DEFAULT_ROW_HEIGHT
protected static final int DEFAULT_COLUMN_WIDTH
protected RulerModel rowModel
protected RulerModel columnModel
protected GridModel gridModel
protected SelectionModel selectionModel
protected SpanModel spanModel
protected StyleModel styleModel
protected GridRepaintManager repaintMgr
protected Dimension preferredViewportSize
Scrollable
interface to determine the initial visible area.
protected Component editorComp
Component
that is handling the editing.
protected GridCellEditor cellEditor
protected int editingColumn
protected int editingRow
Constructor Detail |
public JGrid()
public JGrid(int rows, int columns)
public JGrid(GridModel gridModel, SpanModel spanModel, StyleModel styleModel)
Method Detail |
protected void create(GridModel gridModel, SpanModel spanModel, StyleModel styleModel, RulerModel rowModel, RulerModel columnModel, SelectionModel selectionModel)
protected void updateRepaintManager()
public Color getFocusForegroundColor()
Color
used for the foreground of focused cellspublic void setFocusForegroundColor(Color focusForegroundColor)
focusForegroundColor
- the Color
to use for foreground of
focused cellspublic Color getFocusBackgroundColor()
Color
used for the background of focused cellspublic void setFocusBackgroundColor(Color focusBackgroundColor)
focusBackgroundColor
- the Color
to use for background of
focused cellspublic Color getSelectionForegroundColor()
Color
used for the foreground of selected cells.public void setSelectionForegroundColor(Color selectionForegroundColor)
selectionForegroundColor
- the Color
used for the foreground
of selected cellspublic Color getSelectionBackgroundColor()
Color
used for the background of selected cells.public void setSelectionBackgroundColor(Color selectionBackgroundColor)
selectionBackgroundColor
- the Color
used for the background
of selected cellspublic Color getGridColor()
Color
used to draw grid linespublic void setGridColor(Color gridColor)
gridColor
- the new Color
of the grid linespublic boolean getShowGrid()
public void setShowGrid(boolean show)
public int getRowCount()
public int getColumnCount()
public int getRowHeight(int row)
row
.
row
- the row whose height is to be returned
row
public int getColumnWidth(int column)
column
.
column
- the column whose width is to be returned
column
public void setRowHeight(int row, int height)
row
to height
.
row
- the row whose height is to be changedheight
- new row height (in pixels)public void setColumnWidth(int column, int width)
column
to width
.
column
- the column whose width is to be changedwidth
- new column width (in pixels)public int getRowPosition(int row)
public int getColumnPosition(int column)
public Rectangle getCellBounds(int row, int column)
public int rowAtPoint(Point point)
public int columnAtPoint(Point point)
public boolean isCellSpan(int row, int column)
public GridCellRenderer getCellRenderer(int row, int column)
public GridCellEditor getCellEditor(int row, int column)
public Component prepareRenderer(GridCellRenderer renderer, int row, int column)
public Component prepareEditor(GridCellEditor editor, int row, int column)
public boolean isSelected(int row, int column)
public void ensureCellInVisibleRect(int row, int column)
public void changeSelection(int row, int column, boolean toggle, boolean extend)
public GridModel getGridModel()
public void setGridModel(GridModel model)
public SelectionModel getSelectionModel()
public void setSelectionModel(SelectionModel model)
public SpanModel getSpanModel()
public void setSpanModel(SpanModel model)
public StyleModel getStyleModel()
public void setStyleModel(StyleModel model)
public RulerModel getRowModel()
public RulerModel getColumnModel()
public void gridChanged(GridModelEvent event)
gridChanged
in interface GridModelListener
public boolean editCellAt(int row, int column)
public boolean editCellAt(int row, int column, EventObject e)
row
and
column
, if the cell is editable.
row
- the row to be editedcolumn
- the column to be editede
- event to pass into shouldSelectCell
IllegalArgumentException
- If row
or column
is not in the valid rangepublic void removeEditor()
public void setEditingColumn(int aColumn)
editingColumn
variable.
aColumn
- the column of the cell to be editededitingColumn
public void setEditingRow(int aRow)
editingRow
variable.
aRow
- the row of the cell to be editededitingRow
public boolean isEditing()
editingColumn
,
editingRow
public Component getEditorComponent()
public int getEditingColumn()
editingRow
public int getEditingRow()
editingColumn
public GridCellEditor getCurrentCellEditor()
public void editingStopped(ChangeEvent e)
Application code will not use these methods explicitly, they are used internally by JSpread.
editingStopped
in interface CellEditorListener
e
- the event receivedCellEditorListener
public void editingCanceled(ChangeEvent e)
editingCanceled
in interface CellEditorListener
e
- the event receivedCellEditorListener
protected boolean processKeyBinding(KeyStroke keyStroke, KeyEvent keyEvent, int condition, boolean pressed)
processKeyBinding
in class JComponent
public void setPreferredScrollableViewportSize(Dimension size)
size
- a Dimension
object specifying the preferredSize
of a
JViewport
whose view is this spreadsheetScrollable.getPreferredScrollableViewportSize()
public Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
in interface Scrollable
Dimension
object containing the preferredSize
of the JViewport
which displays this tableScrollable.getPreferredScrollableViewportSize()
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface Scrollable
visibleRect
- the view area visible within the viewportorientation
- either SwingConstants.VERTICAL
or SwingConstants.HORIZONTAL
direction
- less than zero to scroll up/left,
greater than zero for down/right
Scrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
visibleRect.height
or
visibleRect.width
,
depending on this spreadsheet's orientation.
getScrollableBlockIncrement
in interface Scrollable
visibleRect.height
or
visibleRect.width
per the orientationScrollable.getScrollableBlockIncrement(java.awt.Rectangle, int, int)
public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface Scrollable
Scrollable.getScrollableTracksViewportWidth()
public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface Scrollable
Scrollable.getScrollableTracksViewportHeight()
public GridUI getUI()
public void setUI(GridUI ui)
ui
- the SpreadsheetUI L&F objectUIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
updateUI
in class JComponent
JComponent.updateUI()
public String getUIClassID()
getUIClassID
in class JComponent
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public void resizeAndRepaint()
public Object getValueAt(int row, int column)
public void setValueAt(Object value, int row, int column)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |