org.jdesktop.swingx.renderer
Class CellContext

java.lang.Object
  extended by org.jdesktop.swingx.renderer.CellContext
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ListCellContext, TableCellContext, TreeCellContext

public class CellContext
extends java.lang.Object
implements java.io.Serializable

Encapsulates a snapshop of cell content and default display context for usage by a ComponentProvider.

One part is the super-set of properties that's traditionally passed into the core renderers' (Table-, List-, Tree-) getXXCellRendererComponent. Raw properties which define the context are

Similarl to a ComponentAdapter, the properties are a super-set of those for a concrete component type. It's up to sub-classes (once the generics will be removed, until then the DefaultXXRenderers - PENDING JW: undecided - even after the generics removal, the param list in the subclasses are the same) fill any reasonable defaults for those not applicable to the specific component context. With those raw properties given, a CellContext looks up and returns dependent visual properties as appropriate for the concrete component. Typically, they are taken from the component if supported, or requested from the UIManager. Dependent properties are For a backdoor, the cell location (in horizontal and vertical view coordinates) and the originating component is accessible as well. Note that they are not necessarily valid for the "life" component. It's not recommened to actually use them. If needed, that's probably a sign the api is lacking :-)

PENDING JW: the generic parameterization is useful to have a type-safe installContext but introduces a bunch of generic warnings. Not enough reason to go for, so will be removed in future versions (see Issue 1042-swingx)

Author:
Jeanette Winzenburg
See Also:
Serialized Form

Constructor Summary
CellContext()
           
 
Method Summary
 int getColumn()
          Returns the cell's column index in view coordinates as set in the install.
 javax.swing.JComponent getComponent()
          Returns the component the cell resides on, may be null.
 javax.swing.Icon getIcon()
          Returns the icon.
 int getRow()
          Returns the cell's row index in view coordinates as set in the install.
 java.lang.Object getValue()
          Returns the value of the cell as set in the install.
 boolean isEditable()
          Returns the cell's editability.
 boolean isExpanded()
          Returns the expanded state as set in the install.
 boolean isFocused()
          Returns the focused state as set in the install.
 boolean isLeaf()
          Returns the leaf state as set in the install.
 boolean isSelected()
          Returns the selected state as set in the install.
 java.lang.Object replaceValue(java.lang.Object value)
          Replaces the value of this cell context with the given parameter and returns the replaced value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CellContext

public CellContext()
Method Detail

replaceValue

public java.lang.Object replaceValue(java.lang.Object value)
Replaces the value of this cell context with the given parameter and returns the replaced value.

Parameters:
value - the new value of the cell context
Returns:
the replaced value of the cell context

getComponent

public javax.swing.JComponent getComponent()
Returns the component the cell resides on, may be null. Subclasses are expected to override and return the component type they are handling.

Returns:
the component the cell resides on, may be null.

getValue

public java.lang.Object getValue()
Returns the value of the cell as set in the install.

Returns:
the content value of the cell.

getRow

public int getRow()
Returns the cell's row index in view coordinates as set in the install.

Returns:
the cell's row index.

getColumn

public int getColumn()
Returns the cell's column index in view coordinates as set in the install.

Returns:
the cell's column index.

isSelected

public boolean isSelected()
Returns the selected state as set in the install.

Returns:
the cell's selected state.

isFocused

public boolean isFocused()
Returns the focused state as set in the install.

Returns:
the cell's focused state.

isExpanded

public boolean isExpanded()
Returns the expanded state as set in the install.

Returns:
the cell's expanded state.

isLeaf

public boolean isLeaf()
Returns the leaf state as set in the install.

Returns:
the cell's leaf state.

isEditable

public boolean isEditable()
Returns the cell's editability. Subclasses should override to return a reasonable cell-related state.

Here: false.

Returns:
the cell's editable property.

getIcon

public javax.swing.Icon getIcon()
Returns the icon. Subclasses should override to return a reasonable cell-related state.

Here: null.

Returns:
the cell's icon.