|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
com.jidesoft.grid.JideTable
com.jidesoft.grid.ContextSensitiveTable
com.jidesoft.grid.NavigableTable
com.jidesoft.grid.CellStyleTable
public class CellStyleTable
CellStyleTable
introduces cell styles to table. As long as the table model implements StyleModel
and its StyleModel.isCellStyleOn()
returns true, CellStyleTable
will use the
CellStyle
that is returned from StyleModel.getCellStyleAt(int, int)
to customize the cell
renderer to reflect the cell style as much as possible.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.jidesoft.grid.JideTable |
---|
JideTable.NonContiguousTransferHandler |
Nested classes/interfaces inherited from class javax.swing.JTable |
---|
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected List<CellStyle> |
_cellStyleList
|
static String |
PROPERTY_FILLS_SELECTION
|
static String |
PROPERTY_FILLS_VIEWPORT_WITH_STRIPE
|
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 | |
---|---|
CellStyleTable()
|
|
CellStyleTable(int numRows,
int numColumns)
|
|
CellStyleTable(Object[][] rowData,
Object[] columnNames)
|
|
CellStyleTable(TableModel dm)
|
|
CellStyleTable(TableModel dm,
TableColumnModel cm)
|
|
CellStyleTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
|
|
CellStyleTable(Vector<?> rowData,
Vector<?> columnNames)
|
Method Summary | |
---|---|
void |
addCellStyleCustomizer(CellStyleCustomizer customizer)
Adds a new CellStyleCustomizer. |
void |
clearCellStyleCustomizers()
Clears all the CellStyleCustomizers. |
protected void |
collectCellStyles(int row,
int column)
Collects the cell style of the cell and put into a sorted ArrayList which is a field called _cellStyleList. |
protected Component |
configureEditorComponent(int row,
int column,
Component component)
Changes the style of editor component using the CellStyle object from StyleModel. |
protected Component |
configureRendererComponent(int row,
int column,
Component component)
Changes the style of renderer component using the CellStyle object from StyleModel. |
protected void |
customizeEditorComponent(int row,
int column,
Component component,
CellStyle cellStyle)
Changes the style of editor component using the CellStyle object from StyleModel the CellStyle of the corresponding cell is not null. |
protected void |
customizeRendererComponent(int row,
int column,
Component component,
CellStyle cellStyle)
Changes the style of renderer component using the CellStyle object from StyleModel when CellStyle of corresponding cell is not null. |
CellStyle |
getCellStyleAt(int row,
int column)
Get the merged cell style for the cell from all its underlying StyleModel. |
CellStyleCustomizer[] |
getCellStyleCustomizers()
Gets all the CellStyleCustomizers. |
CellStyleProvider |
getCellStyleProvider()
Gets the CellStyleProvider for the table. |
CellStyle[] |
getCellStyles(int row,
int column)
Gets all cell styles associated with the cell. |
CellStyle |
getFocusCellStyle()
Gets the cell style for the focus cell. |
TableModel |
getNextStyleModel(TableModel model)
Gets the next style model of the specified model. |
TableModel |
getStyleModel()
Gets style model. |
TableStyleProvider |
getTableStyleProvider()
Gets the TableStyleProvider for the table. |
boolean |
isFillsSelection()
Gets the flag indicating if the selection should be filled if JTable.getAutoResizeMode()
returns JideTable.AUTO_RESIZE_FILL . |
boolean |
isFillsViewportWithStripe()
Get the flag indicating if the viewport will be filled with stripe if possible. |
protected void |
mergeCellStyle(CellStyle mergedCellStyle,
CellStyle originalCellStyle)
Merges the styles from the originalCellStyle to mergedCellStyle only if the mergedCellStyle doesn't have the particular style set before. |
protected CellStyle |
mergeCellStyles(List<CellStyle> cellStyles)
Merges the cell styles in the list into one CellStyle. |
protected boolean |
needPaintStripedBackground()
Checks if the striped background of non-table area should be painted. |
void |
paintCellOverlay(Graphics g,
Component component,
int row,
int column,
Rectangle cellRect)
Overrides this method to paint the overlayBorder and the overlayCellPainter from the CellStyle. |
void |
paintCellUnderlay(Graphics g,
Component component,
int row,
int column,
Rectangle cellRect)
Overrides this method to paint the underlayCellPainter from the CellStyle. |
protected void |
paintComponent(Graphics g)
|
Component |
prepareEditor(TableCellEditor editor,
int row,
int column)
Override this method to get the style from CellStyle defined by StyleModel and set it to component return from super.prepareEditor(). |
Component |
prepareRenderer(TableCellRenderer renderer,
int row,
int column)
Override this method to get the style from CellStyle defined by StyleModel and set it to component return from super.prepareRenderer(). |
void |
releaseRendererComponent(TableCellRenderer renderer,
int row,
int column,
Component component)
|
void |
removeCellStyleCustomizer(CellStyleCustomizer customizer)
Removes an existing CellStyleCustomizer. |
void |
setCellStyleProvider(CellStyleProvider cellStyleProvider)
Sets the CellStyleProvider for the table. |
void |
setFillsSelection(boolean fillsSelection)
Sets the flag indicating if the selection should be filled if JTable.getAutoResizeMode()
returns JideTable.AUTO_RESIZE_FILL . |
void |
setFillsViewportWithStripe(boolean fillsViewportWithStripe)
Set the flag indicating if the viewport will be filled with stripe if possible. |
void |
setFocusCellStyle(CellStyle focusCellStyle)
Sets the cell style for the focus cell. |
void |
setTableStyleProvider(TableStyleProvider styleProvider)
Sets the TableStyleProvider for the table. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.jidesoft.grid.TableAdapter |
---|
getCellSelectionEnabled, getColumnClass, getColumnCount, getColumnName, getColumnSelectionAllowed, getRowCount, getRowSelectionAllowed, isCellEditable, setCellSelectionEnabled, setValueAt |
Field Detail |
---|
public static final String PROPERTY_FILLS_VIEWPORT_WITH_STRIPE
public static final String PROPERTY_FILLS_SELECTION
protected final List<CellStyle> _cellStyleList
Constructor Detail |
---|
public CellStyleTable()
public CellStyleTable(int numRows, int numColumns)
public CellStyleTable(TableModel dm)
public CellStyleTable(Object[][] rowData, Object[] columnNames)
public CellStyleTable(Vector<?> rowData, Vector<?> columnNames)
public CellStyleTable(TableModel dm, TableColumnModel cm)
public CellStyleTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Method Detail |
---|
public TableModel getStyleModel()
TableModelWrapperUtils.getActualTableModel(javax.swing.table.TableModel, Class)
to find an
instance of StyleModel. If it can finds one, it will return null.
public TableModel getNextStyleModel(TableModel model)
model
- the model.
public void paintCellUnderlay(Graphics g, Component component, int row, int column, Rectangle cellRect)
paintCellUnderlay
in class JideTable
g
- the Graphicscomponent
- the componentrow
- the row indexcolumn
- the column indexcellRect
- the cell rectangle of the cell at the specified row index and column index.public void releaseRendererComponent(TableCellRenderer renderer, int row, int column, Component component)
releaseRendererComponent
in class JideTable
public void paintCellOverlay(Graphics g, Component component, int row, int column, Rectangle cellRect)
paintCellOverlay
in class JideTable
g
- the Graphicscomponent
- the componentrow
- the row indexcolumn
- the column indexcellRect
- the cell rectangle of the cell at the specified row index and column index.public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
prepareRenderer
in class JideTable
renderer
- the renderer at the specified cell.row
- the row index.column
- the column index.
public Component prepareEditor(TableCellEditor editor, int row, int column)
prepareEditor
in class ContextSensitiveTable
editor
- the cell editor.row
- the row index.column
- the column index.
protected Component configureRendererComponent(int row, int column, Component component)
row
- the row index.column
- the column index.component
- the renderer component
protected CellStyle mergeCellStyles(List<CellStyle> cellStyles)
cellStyles
- the list of CellStyles. The CellStyle priority is from the highest to the lowest in this list.
protected void mergeCellStyle(CellStyle mergedCellStyle, CellStyle originalCellStyle)
mergedCellStyle
- the cell style to merge tooriginalCellStyle
- the cell style to merge frompublic void addCellStyleCustomizer(CellStyleCustomizer customizer)
customizeRendererComponent(int, int, java.awt.Component, CellStyle)
or
customizeEditorComponent(int, int, java.awt.Component, CellStyle)
methods.
customizer
- a new CellStyleCustomizer.public void removeCellStyleCustomizer(CellStyleCustomizer customizer)
customizer
- the CellStyleCustomizer to be removedpublic CellStyleCustomizer[] getCellStyleCustomizers()
public void clearCellStyleCustomizers()
protected void customizeRendererComponent(int row, int column, Component component, CellStyle cellStyle)
row
- the row index.column
- the column index.component
- the component.cellStyle
- the cell style.protected Component configureEditorComponent(int row, int column, Component component)
row
- the row index.column
- the column index.component
- the editor component
public CellStyle getCellStyleAt(int row, int column)
row
- the row indexcolumn
- the column index
public CellStyle[] getCellStyles(int row, int column)
row
- the row indexcolumn
- the column index
protected void collectCellStyles(int row, int column)
row
- the row index.column
- the column index.protected void customizeEditorComponent(int row, int column, Component component, CellStyle cellStyle)
row
- the row index.column
- the column index.component
- the component.cellStyle
- the cell style.public CellStyleProvider getCellStyleProvider()
CellStyleProvider
for the table. It is null by default. But you can use setCellStyleProvider(CellStyleProvider)
to change it.
We probably shouldn't create this method but just let people using getTableStyleProvider instead. However we
leave this method there just for backward compatibility.
public void setCellStyleProvider(CellStyleProvider cellStyleProvider)
CellStyleProvider
for the table. StyleModel
is usually defined if the style
depends on the data in the table model. However there are cases style depending on the view only such as row
stripes. In older releases, you will have to subclass SortableTableModel or whatever the outer-most table model
which is not very convenience. That's why we introduce CellStyleProvider
at CellStyleTable
. You can simply use a setter to define rows stripes instead of subclass a table model.
The cell style returned from CellStyleProvider
has the least priority except that of the
TableStyleProvider. In the other word, if you use any cell style in the inner table model, those cell styles will
be used first. For example, if you have a cell style that says using red background if the value in the cell is
negative. You of course want the background to be red even though it has row stripes defined in this
CellStyleProvider.
There are RowStripeTableStyleProvider
and ColumnStripeTableStyleProvider
which provide row stripes and column stripes respectively.
We probably shouldn't create this method but just let people using setTableStyleProvider instead. However we
leave this method there just for backward compatibility. The only difference between CellStyleProvider and
TableStyleProvider is CellStyleProvider's getCellStyleAt takes a model v.s. TableStyleProvider's getCellStyleAt
takes a JTable as parameter. Since the first parameter of CellStyleProvider's getCellStyleAt is a model, so the
row and column index parameters are the indices as in the model. In TableStyleProvider, the two indices are view
indices.
This method will repaint the table.
cellStyleProvider
- a new CellStyleProvider.setTableStyleProvider(TableStyleProvider)
public TableStyleProvider getTableStyleProvider()
TableStyleProvider
for the table. It is null by default. But you can use setTableStyleProvider(TableStyleProvider)
to change it.
public void setTableStyleProvider(TableStyleProvider styleProvider)
TableStyleProvider
for the table. StyleModel
is usually defined if the style
depends on the data in the table model. However there are cases style depending on the view only such as row
stripes. In older releases, you will have to subclass SortableTableModel or whatever the outer-most table model
which is not very convenience. That's why we introduce TableStyleProvider
at CellStyleTable
. You can simply use a setter to define rows stripes instead of subclass a table model.
The cell style returned from TableStyleProvider
has the least priority. In the other word, if you
use any cell style in the inner table model, those cell styles will be used first. For example, if you have a
cell style that says using red background if the value in the cell is negative. You of course want the background
to be red even though it has row stripes defined in this TableCellStyleProvider.
There are RowStripeTableStyleProvider
and ColumnStripeTableStyleProvider
which provide row stripes and column stripes respectively.
This method will repaint the table.
styleProvider
- a new TableStyleProvider.public CellStyle getFocusCellStyle()
public void setFocusCellStyle(CellStyle focusCellStyle)
CellStyle.setSelectionBackground(java.awt.Color)
and CellStyle.setSelectionForeground(java.awt.Color)
instead of setBackground or setForeground.
focusCellStyle
- the CellStyle for the leading selection cell.public boolean isFillsViewportWithStripe()
setFillsViewportWithStripe(boolean)
public void setFillsViewportWithStripe(boolean fillsViewportWithStripe)
fillsViewportWithStripe
- the flagprotected void paintComponent(Graphics g)
paintComponent
in class JComponent
protected boolean needPaintStripedBackground()
public boolean isFillsSelection()
JTable.getAutoResizeMode()
returns JideTable.AUTO_RESIZE_FILL
.
setFillsSelection(boolean)
public void setFillsSelection(boolean fillsSelection)
JTable.getAutoResizeMode()
returns JideTable.AUTO_RESIZE_FILL
.
By default, this flag is true. However, some customers think the row might be too real to be confused. In that
case, you might want to set this flag to false.
fillsSelection
- the flag
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |