Class DefaultGridCellRenderer

java.lang.Object
com.codename1.ui.table.DefaultGridCellRenderer
All Implemented Interfaces:
GridCellRenderer

public class DefaultGridCellRenderer extends Object implements GridCellRenderer

The renderer a DataGrid uses for a column that has none: text aligned by kind, a check box for a boolean, and an image scaled to the row.

Subclass it to change one thing, such as the colour of a value, without repainting the rest.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Font
    font(GridCell cell)
    The font of a cell's text; by default the row style's.
    int
    The width, in pixels, the cell's content needs, for a column that sizes itself to what it shows.
    protected static int
    mirror(int align, boolean rtl)
    align as it reads in the grid's direction: right to left, LEFT is the right edge and RIGHT the left one, so text starts and numbers end where the language puts them.
    void
    paint(Graphics g, GridCell cell, int x, int y, int width, int height)
    Paints a cell into the rectangle x, y, width, height.
    protected void
    paintCheck(Graphics g, GridCell cell, int x, int y, int size, boolean on)
    Paints a check box of side size at x, y.
    protected static int
    place(int align, int x, int avail, int w)
    Where something w wide starts in a span from x, avail wide.
    protected String
    text(GridCell cell)
    The text a cell shows; by default its column's format of the value.
    protected int
    textColor(GridCell cell, int defaultColor)
    The colour of a cell's text, given the row style's.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultGridCellRenderer

      public DefaultGridCellRenderer()
  • Method Details

    • paint

      public void paint(Graphics g, GridCell cell, int x, int y, int width, int height)
      Description copied from interface: GridCellRenderer
      Paints a cell into the rectangle x, y, width, height. The graphics is clipped to it.
      Specified by:
      paint in interface GridCellRenderer
    • getPreferredWidth

      public int getPreferredWidth(GridCell cell)
      Description copied from interface: GridCellRenderer
      The width, in pixels, the cell's content needs, for a column that sizes itself to what it shows.
      Specified by:
      getPreferredWidth in interface GridCellRenderer
    • text

      protected String text(GridCell cell)
      The text a cell shows; by default its column's format of the value.
    • textColor

      protected int textColor(GridCell cell, int defaultColor)
      The colour of a cell's text, given the row style's.
    • font

      protected Font font(GridCell cell)
      The font of a cell's text; by default the row style's.
    • paintCheck

      protected void paintCheck(Graphics g, GridCell cell, int x, int y, int size, boolean on)
      Paints a check box of side size at x, y.
    • mirror

      protected static int mirror(int align, boolean rtl)
      align as it reads in the grid's direction: right to left, LEFT is the right edge and RIGHT the left one, so text starts and numbers end where the language puts them.
    • place

      protected static int place(int align, int x, int avail, int w)
      Where something w wide starts in a span from x, avail wide.