|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbe.ugent.caagt.swirl.lists.DefaultCellListCellRenderer
public class DefaultCellListCellRenderer
Default implementation of CellListCellRenderer
. Renders a
cell to look like a horizontally
centered label, with caption below the icon, except
that the selection background and focus indicator are restricted to
the text part of the label.
Works best with list whose elements implement the interface
CellListCellValue
.
Extension classes override method prepare
to
determine what text and what icon should be displayed.
Constructor Summary | |
---|---|
DefaultCellListCellRenderer()
Default constructor. |
Method Summary | |
---|---|
java.awt.Color |
getBorderSelectionColor()
Return the color which is used to draw the focus indicator. |
java.awt.Font |
getFont()
Return the font used for the caption. |
java.awt.Color |
getForeground()
The color which is used to display the caption. |
javax.swing.Icon |
getIcon()
Icon to be displayed. |
java.awt.Color |
getIconBackground()
Return the background color for icons. |
int |
getIconTextGap()
Return the gap between text and icon |
java.awt.Insets |
getInsets()
Return the insets of this cell. |
java.awt.Color |
getSelectionBackground()
Return the background color for selections. |
java.awt.Color |
getSelectionForeground()
Return the text color for selections. |
java.lang.String |
getText()
Return the caption to be displayed. |
java.lang.String |
getToolTipText(CellList list,
java.lang.Object value,
int index)
Return the tool tip text for the given element. |
void |
paintElement(java.awt.Graphics2D g2,
CellList list,
java.lang.Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
Paint the given element at the 0,0-position on the given graphics context. |
protected void |
prepare(CellList list,
java.lang.Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
Prepare the renderer so that the given element can be displayed. |
void |
setBorderSelectionColor(java.awt.Color borderSelectionColor)
Set the color which is used to draw the focus indicator. |
void |
setFont(java.awt.Font font)
Set the font used for the caption. |
void |
setForeground(java.awt.Color foreground)
Set the color to be used for the caption. |
void |
setIcon(javax.swing.Icon icon)
Set the icon to be displayed. |
void |
setIconBackground(java.awt.Color iconBackground)
Set the background color for icons. |
void |
setIconTextGap(int iconTextGap)
Set the gap between text and icon |
void |
setInsets(java.awt.Insets insets)
Set the insets of this cell. |
void |
setSelectionBackground(java.awt.Color selectionBackground)
Set the background color for selections. |
void |
setSelectionForeground(java.awt.Color selectionForeground)
Set the text color for selections. |
void |
setText(java.lang.String text)
Set the caption to be displayed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultCellListCellRenderer()
Method Detail |
---|
public java.lang.String getToolTipText(CellList list, java.lang.Object value, int index)
If value
is of type CellListCellValue
, this
implementation returns the tool tip text provided by that interface.
Otherwise it returns null
.
getToolTipText
in interface CellListCellRenderer
list
- The cell list to which the element belongsvalue
- The corresponding value returned from the modelindex
- The index of the cell in the list
null
if no tool tip needs to be dipslayedpublic java.lang.String getText()
public void setText(java.lang.String text)
public java.awt.Color getForeground()
public final void setForeground(java.awt.Color foreground)
foreground
- New value of property foreGround.public java.awt.Font getFont()
public final void setFont(java.awt.Font font)
public javax.swing.Icon getIcon()
public void setIcon(javax.swing.Icon icon)
icon
- New value of property icon.public int getIconTextGap()
public void setIconTextGap(int iconTextGap)
public java.awt.Insets getInsets()
public final void setInsets(java.awt.Insets insets)
public java.awt.Color getSelectionForeground()
public final void setSelectionForeground(java.awt.Color selectionForeground)
selectionForeground
- New value of property selectionForeground.public java.awt.Color getSelectionBackground()
public final void setSelectionBackground(java.awt.Color selectionBackground)
selectionBackground
- New value of property selectionBackground.public java.awt.Color getIconBackground()
public final void setIconBackground(java.awt.Color iconBackground)
iconBackground
- New value of property iconBackground.public java.awt.Color getBorderSelectionColor()
public final void setBorderSelectionColor(java.awt.Color borderSelectionColor)
protected void prepare(CellList list, java.lang.Object value, int index, boolean isSelected, boolean cellHasFocus)
paintElement
)
to set the correct text and icon.
This implementation distinguishes three cases:
value
is of type CellListCellValue
,
icon and text
are set according to the information provided by that interface.
value
is of type Icon
, that
icon is used, without text caption.
list
- The cell list to which the element belongsvalue
- The corresponding value returned from the modelindex
- The index of the cell in the listisSelected
- True if the specified cell was selected.cellHasFocus
- True if the specified cell has the focus.public void paintElement(java.awt.Graphics2D g2, CellList list, java.lang.Object value, int index, boolean isSelected, boolean cellHasFocus)
This implementation first calls prepare
to initialize
the text and icon property from the value parameter. Extensions
of this class are advised to override prepare
instead of this method.
paintElement
in interface CellListCellRenderer
g2
- Graphics context onto which the cell must be paintedlist
- The cell list to which the element belongsvalue
- The corresponding value returned from the modelindex
- The index of the cell in the listisSelected
- True if the specified cell was selected.cellHasFocus
- True if the specified cell has the focus.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |