org.apache.pivot.wtk.content
Class TableViewMultiCellRenderer

java.lang.Object
  extended by org.apache.pivot.wtk.content.TableViewMultiCellRenderer
All Implemented Interfaces:
ConstrainedVisual, Renderer, TableView.CellRenderer, Visual

public class TableViewMultiCellRenderer
extends Object
implements TableView.CellRenderer

Table cell renderer that supports dynamic rendering based on the type of content being rendered.


Nested Class Summary
static class TableViewMultiCellRenderer.RendererMapping
          Maps the type of value being rendered (the value class) to a specific cell renderer.
 
Constructor Summary
TableViewMultiCellRenderer()
           
 
Method Summary
 int getBaseline()
          Returns the visual's baseline.
 int getBaseline(int widthArgument, int heightArgument)
          Returns the baseline for a given width and height.
 TableView.CellRenderer getDefaultRenderer()
           
 int getHeight()
          Returns the visual's height.
 int getPreferredHeight(int widthArgument)
          Returns the visual's preferred height given the provided width constraint.
 Dimensions getPreferredSize()
          Returns the visual's unconstrained preferred size.
 int getPreferredWidth(int heightArgument)
          Returns the visual's preferred width given the provided height constraint.
 Sequence<TableViewMultiCellRenderer.RendererMapping> getRendererMappings()
           
 Dictionary<String,Object> getStyles()
          Returns the renderer's style dictionary.
 int getWidth()
          Returns the visual's width.
 void paint(Graphics2D graphics)
          Paints the visual.
 void render(Object row, int rowIndex, int columnIndex, TableView tableView, String columnName, boolean selected, boolean highlighted, boolean disabled)
          Prepares the renderer for layout or paint.
 void setDefaultRenderer(TableView.CellRenderer defaultRenderer)
           
 void setSize(int width, int height)
          Sets the visual's render size.
 String toString(Object row, String columnName)
          Converts table view cell data to a string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableViewMultiCellRenderer

public TableViewMultiCellRenderer()
Method Detail

getWidth

public int getWidth()
Description copied from interface: Visual
Returns the visual's width.

Specified by:
getWidth in interface Visual

getHeight

public int getHeight()
Description copied from interface: Visual
Returns the visual's height.

Specified by:
getHeight in interface Visual

getBaseline

public int getBaseline()
Description copied from interface: Visual
Returns the visual's baseline.

Specified by:
getBaseline in interface Visual
Returns:
The baseline relative to the origin of the visual, or -1 if this visual does not have a baseline.

paint

public void paint(Graphics2D graphics)
Description copied from interface: Visual
Paints the visual.

Specified by:
paint in interface Visual
Parameters:
graphics - The graphics context in which to paint the visual.

setSize

public void setSize(int width,
                    int height)
Description copied from interface: ConstrainedVisual
Sets the visual's render size.

Specified by:
setSize in interface ConstrainedVisual

getPreferredWidth

public int getPreferredWidth(int heightArgument)
Description copied from interface: ConstrainedVisual
Returns the visual's preferred width given the provided height constraint.

Specified by:
getPreferredWidth in interface ConstrainedVisual
Parameters:
heightArgument - The height by which to constrain the preferred width, or -1 for no constraint.

getPreferredHeight

public int getPreferredHeight(int widthArgument)
Description copied from interface: ConstrainedVisual
Returns the visual's preferred height given the provided width constraint.

Specified by:
getPreferredHeight in interface ConstrainedVisual
Parameters:
widthArgument - The width by which to constrain the preferred height, or -1 for no constraint.

getPreferredSize

public Dimensions getPreferredSize()
Description copied from interface: ConstrainedVisual
Returns the visual's unconstrained preferred size.

Specified by:
getPreferredSize in interface ConstrainedVisual

getBaseline

public int getBaseline(int widthArgument,
                       int heightArgument)
Description copied from interface: ConstrainedVisual
Returns the baseline for a given width and height.

Specified by:
getBaseline in interface ConstrainedVisual
Returns:
The baseline relative to the origin of this visual, or -1 if this visual does not have a baseline.

getStyles

public Dictionary<String,Object> getStyles()
Description copied from interface: Renderer
Returns the renderer's style dictionary.

Specified by:
getStyles in interface Renderer

render

public void render(Object row,
                   int rowIndex,
                   int columnIndex,
                   TableView tableView,
                   String columnName,
                   boolean selected,
                   boolean highlighted,
                   boolean disabled)
Description copied from interface: TableView.CellRenderer
Prepares the renderer for layout or paint.

Specified by:
render in interface TableView.CellRenderer
Parameters:
row - The row to render, or null if called to calculate preferred height for skins that assume a fixed renderer height.
rowIndex - The index of the row being rendered, or -1 if value is null.
columnIndex - The index of the column being rendered.
tableView - The host component.
columnName - The name of the column being rendered.
selected - If true, the row is selected.
highlighted - If true, the row is highlighted.
disabled - If true, the row is disabled.

toString

public String toString(Object row,
                       String columnName)
Description copied from interface: TableView.CellRenderer
Converts table view cell data to a string representation.

Specified by:
toString in interface TableView.CellRenderer
Returns:
The cell data's string representation, or null if the data does not have a string representation.

Note that this method may be called often during keyboard navigation, so implementations should avoid unnecessary string allocations.


getDefaultRenderer

public TableView.CellRenderer getDefaultRenderer()

setDefaultRenderer

public void setDefaultRenderer(TableView.CellRenderer defaultRenderer)

getRendererMappings

public Sequence<TableViewMultiCellRenderer.RendererMapping> getRendererMappings()