|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.grid.CellStyle
public class CellStyle
CellStyle
defines the styles of a table cell. Those styles include the background (include the selection
background), the foreground (include the selection foreground), the font, the horizontal alignment, the vertical
alignment, the text, the toolTipText, the icon and the border. CellStyleTable
and its subclasses will
use the styles defined in CellStyle
and set to cell renderer component. Obviously, not all styles apply
to all types of cell renderer components.
CellStyle
works with StyleModel
which can be used as an interface for TableModel. You can
refer to StyleModel
to see how to use it.
In additional to all the styles that you can set to CellStyle, you can assign a priority to it. This is useful where
there are multiple cell styles for the same cell. Please read javadoc of getPriority()
for more
information.
Field Summary | |
---|---|
static Border |
EMPTY_BORDER
|
static CellPainter |
EMPTY_CELL_PAINTER
|
static Color |
EMPTY_COLOR
|
static Font |
EMPTY_FONT
|
static Icon |
EMPTY_ICON
An empty icon instance. |
static String |
EMPTY_STRING
|
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Constructor Summary | |
---|---|
CellStyle()
|
|
CellStyle(CellStyle style)
Create a copy of the CellStyle; |
Method Summary | |
---|---|
CellStyle |
clone()
|
boolean |
equals(Object obj)
|
boolean |
equalsForExporting(Object obj)
Checks if this CellStyle instance equals to the obj in terms of exporting to excel. |
Color |
getBackground()
|
Border |
getBorder()
|
Font |
getFont()
|
int |
getFontStyle()
|
Color |
getForeground()
|
int |
getHorizontalAlignment()
|
int |
getHorizontalTextPosition()
|
Icon |
getIcon()
|
Border |
getOverlayBorder()
|
CellPainter |
getOverlayCellPainter()
Gets the overlay CellPainter which is used to paint after the cell content is painted. |
int |
getPriority()
Gets the priority of the cell style. |
Color |
getSelectionBackground()
|
Color |
getSelectionForeground()
|
String |
getText()
|
String |
getToolTipText()
|
CellPainter |
getUnderlayCellPainter()
Gets the underlay CellPainter which is used to paint before the cell content is painted. |
int |
getVerticalAlignment()
|
int |
getVerticalTextPosition()
|
boolean |
isShowIconOnly()
Deprecated. replaced by getText() . If it returns an empty string, that means only icon will be shown. |
static void |
mergeCellStyle(CellStyle mergedCellStyle,
CellStyle anotherCellStyle)
Merges the styles from the originalCellStyle to mergedCellStyle only if the mergedCellStyle doesn't have the particular style set before. |
void |
setBackground(Color background)
Sets the background. |
void |
setBorder(Border border)
Sets the border style. |
void |
setFont(Font font)
Sets the font. |
void |
setFontStyle(int fontStyle)
Sets the font style which could be Font.PLAIN, Font.BOLD or Font.ITALIC. |
void |
setForeground(Color foreground)
Sets the foreground color. |
void |
setHorizontalAlignment(int horizontalAlignment)
Sets the horizontal alignment. |
void |
setHorizontalTextPosition(int horizontalTextPosition)
Sets the horizontal text position. |
void |
setIcon(Icon icon)
Sets the icon. |
void |
setOverlayBorder(Border overlayBorder)
Sets the overlay border cell style. |
void |
setOverlayCellPainter(CellPainter overlayCellPainter)
Sets the overlay CellPainter. |
void |
setPriority(int priority)
Sets the priority of the cell style. |
void |
setSelectionBackground(Color selectionBackground)
Sets the selection background. |
void |
setSelectionForeground(Color selectionForeground)
Sets the selection foreground. |
void |
setShowIconOnly(boolean showIconOnly)
Deprecated. replaced by setText(String) |
void |
setText(String text)
Sets the text style. |
void |
setToolTipText(String toolTipText)
Sets the tooltip text style. |
void |
setUnderlayCellPainter(CellPainter underlayCellPainter)
Sets the underlay CellPainter. |
void |
setVerticalAlignment(int verticalAlignment)
Sets the vertical alignment. |
void |
setVerticalTextPosition(int verticalTextPosition)
Sets the vertical text position. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Icon EMPTY_ICON
public static final Color EMPTY_COLOR
public static final Font EMPTY_FONT
public static final Border EMPTY_BORDER
public static final String EMPTY_STRING
public static final CellPainter EMPTY_CELL_PAINTER
Constructor Detail |
---|
public CellStyle()
public CellStyle(CellStyle style)
style
- the existing cell style.Method Detail |
---|
public Border getBorder()
public void setBorder(Border border)
border
- the border.public Color getBackground()
public void setBackground(Color background)
background
- the background color.public Color getForeground()
public void setForeground(Color foreground)
foreground
- the foreground color.public Color getSelectionBackground()
public void setSelectionBackground(Color selectionBackground)
selectionBackground
- the selection background.public Color getSelectionForeground()
public void setSelectionForeground(Color selectionForeground)
selectionForeground
- the selection foreground.public Font getFont()
public void setFont(Font font)
font
- the font in the CellStyle.public int getFontStyle()
public void setFontStyle(int fontStyle)
fontStyle
- the font style in the CellStyle.public Icon getIcon()
public void setIcon(Icon icon)
icon
- the icon.public int getVerticalAlignment()
public void setVerticalAlignment(int verticalAlignment)
verticalAlignment
- One of the following constants defined in SwingConstants
: TOP
,
CENTER
(the default), or BOTTOM
.public int getHorizontalAlignment()
public void setHorizontalAlignment(int horizontalAlignment)
horizontalAlignment
- One of the following constants defined in SwingConstants
:
LEFT
, CENTER
(the default for image-only labels),
RIGHT
, LEADING
(the default for text-only labels) or
TRAILING
.public int getVerticalTextPosition()
public void setVerticalTextPosition(int verticalTextPosition)
verticalTextPosition
- One of the following constants defined in SwingConstants
:
TOP
, CENTER
(the default), or BOTTOM
.public int getHorizontalTextPosition()
public void setHorizontalTextPosition(int horizontalTextPosition)
horizontalTextPosition
- One of the following constants defined in SwingConstants
:
LEFT
, CENTER
(the default for image-only labels),
RIGHT
, LEADING
(the default for text-only labels) or
TRAILING
.public String getText()
public void setText(String text)
text
- the text.public String getToolTipText()
public void setToolTipText(String toolTipText)
toolTipText
- the tooltip text.public Border getOverlayBorder()
public void setOverlayBorder(Border overlayBorder)
overlayBorder
- the overlay border.public CellPainter getOverlayCellPainter()
public void setOverlayCellPainter(CellPainter overlayCellPainter)
overlayCellPainter
- the overlay CellPainter.public CellPainter getUnderlayCellPainter()
public void setUnderlayCellPainter(CellPainter underlayCellPainter)
underlayCellPainter
- the underlay CellPainter.public int getPriority()
TableModelWrapper
which can wrap another table model. So you can end up with
a pipe of TableModelWrapper
s. Any of the table models can implement StyleModel
and each
one can return a different cell style. CellStyleTable
will look at those CellStyle
s and
sort them by the priority. The cell style that has the higher priority will win over any cell styles that have a
lower priority when there are style conflicts (meaning the same style is used in different cell styles).
For example, you have one cell style that implements the row stripes and another cell style that implements cell
update indication. Both use cell background style. Obviously you want the cell update indication has a higher
priority than row stripes. So you just set a higher priority in cell update indication cell style.
If the cell styles have the same priority, the one from inner style table model has a higher priority.
getPriority
in interface Prioritized
public void setPriority(int priority)
priority
- the new prioritypublic boolean equalsForExporting(Object obj)
getBackground()
, getForeground()
, getFont()
, getFontStyle()
, getHorizontalAlignment()
and getVerticalAlignment()
are compared in this method.
obj
- the target object
public boolean equals(Object obj)
equals
in class Object
@Deprecated public boolean isShowIconOnly()
getText()
. If it returns an empty string, that means only icon will be shown.
getIcon()
is a non-null value.
@Deprecated public void setShowIconOnly(boolean showIconOnly)
setText(String)
getIcon()
is a non-null value.
showIconOnly
- the flagpublic CellStyle clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public static void mergeCellStyle(CellStyle mergedCellStyle, CellStyle anotherCellStyle)
mergedCellStyle
- the cell style to merge toanotherCellStyle
- the cell style to merge from
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |