de.jaret.util.ui.table.renderer
Class TextCellRenderer

java.lang.Object
  extended by de.jaret.util.ui.table.renderer.RendererBase
      extended by de.jaret.util.ui.table.renderer.CellRendererBase
          extended by de.jaret.util.ui.table.renderer.TextCellRenderer
All Implemented Interfaces:
ICellRenderer
Direct Known Subclasses:
DateCellRenderer, DoubleCellRenderer, LabelProviderRenderer

public class TextCellRenderer
extends CellRendererBase
implements ICellRenderer

TextCellRenderer for the jaret table. Features an integrated comment marker (tooltip), Override getComment() to use this. This CellRenderer may be used as the basis for a lot of toText-CellRenderers (see the DateCellRenderer)

Version:
$Id: TextCellRenderer.java 385 2007-04-29 20:31:49Z olk $
Author:
Peter Kliem

Field Summary
protected  org.eclipse.swt.graphics.Color _commentColor
          color of the comment marker.
 
Fields inherited from class de.jaret.util.ui.table.renderer.CellRendererBase
_inset, BLACKRGB, FOCUSINSETS, SELECTIONCOLOR, WHITERGB
 
Fields inherited from class de.jaret.util.ui.table.renderer.RendererBase
_printer, _scaleX, _scaleY, SCREEN_DPI_X, SCREEN_DPI_Y
 
Constructor Summary
TextCellRenderer()
          Create a text cell renderer for display.
TextCellRenderer(org.eclipse.swt.printing.Printer printer)
          Create a text cell renderer for printing.
 
Method Summary
protected  java.lang.String convertValue(IRow row, IColumn column)
          Convert the value specified by row, column to a string.
 ICellRenderer createPrintRenderer(org.eclipse.swt.printing.Printer printer)
          Create a renderer connfigured for printing.
 void dispose()
          If there are resources to free - this is the place.
 void draw(org.eclipse.swt.graphics.GC gc, JaretTable jaretTable, ICellStyle cellStyle, org.eclipse.swt.graphics.Rectangle drawingArea, IRow row, IColumn column, boolean drawFocus, boolean selected, boolean printing)
          Draw a single cell.
protected  java.lang.String getComment(IRow row, IColumn column)
          Override for using content marker and tooltip.
 int getPreferredHeight(org.eclipse.swt.graphics.GC gc, ICellStyle cellStyle, int width, IRow row, IColumn column)
          Calculate the preferred height of a specific cell.
 java.lang.String getTooltip(JaretTable jaretTable, org.eclipse.swt.graphics.Rectangle drawingArea, IRow row, IColumn column, int x, int y)
          Provide a tooltip text for display.
 
Methods inherited from class de.jaret.util.ui.table.renderer.CellRendererBase
applyInsets, drawBackground, drawBorder, drawCommentMarker, drawFocus, drawSelection, getBackgroundColor, getBorderColor, getFont, getForegroundColor, getInnerWidth, getPreferredWidth, getVerticalSpacesSum, isInCommentMarkerArea
 
Methods inherited from class de.jaret.util.ui.table.renderer.RendererBase
getPrinter, getScaleX, getScaleY, restoreGCAttributes, saveGCAttributes, scaleX, scaleY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jaret.util.ui.table.renderer.ICellRenderer
getPreferredWidth
 

Field Detail

_commentColor

protected org.eclipse.swt.graphics.Color _commentColor
color of the comment marker.

Constructor Detail

TextCellRenderer

public TextCellRenderer(org.eclipse.swt.printing.Printer printer)
Create a text cell renderer for printing.

Parameters:
printer - printer device

TextCellRenderer

public TextCellRenderer()
Create a text cell renderer for display.

Method Detail

getTooltip

public java.lang.String getTooltip(JaretTable jaretTable,
                                   org.eclipse.swt.graphics.Rectangle drawingArea,
                                   IRow row,
                                   IColumn column,
                                   int x,
                                   int y)
Provide a tooltip text for display. Default: no tooltip.

Specified by:
getTooltip in interface ICellRenderer
Overrides:
getTooltip in class CellRendererBase
Parameters:
jaretTable - table that is asking
drawingArea - area of the cell rendering
row - row
column - column
x - mouse x coordinate (absolute within drawing area)
y - mouse y coordinate (abs within drawing area)
Returns:
tootip text or null if no tooltip is to be shown

convertValue

protected java.lang.String convertValue(IRow row,
                                        IColumn column)
Convert the value specified by row, column to a string. This method is ideally suited to be overidden by extensions of the textcellrenderer.

Parameters:
row - row of the cell
column - column of the cell
Returns:
String for the value

getComment

protected java.lang.String getComment(IRow row,
                                      IColumn column)
Override for using content marker and tooltip.

Parameters:
row - row of the cell
column - column of the cell
Returns:
comment as String or null

draw

public void draw(org.eclipse.swt.graphics.GC gc,
                 JaretTable jaretTable,
                 ICellStyle cellStyle,
                 org.eclipse.swt.graphics.Rectangle drawingArea,
                 IRow row,
                 IColumn column,
                 boolean drawFocus,
                 boolean selected,
                 boolean printing)
Draw a single cell. The draw method should be null safe (handling null as the cell value).

Specified by:
draw in interface ICellRenderer
Parameters:
gc - GC to paint on
jaretTable - table the rendering is for
cellStyle - style of the cell
drawingArea - rectangle to draw within
row - row of the cell to paint
column - column of the cell to paint
drawFocus - true if a focus mark should be drawn
selected - true if the cell is currently selected
printing - true if the render operation is for a printer

getPreferredHeight

public int getPreferredHeight(org.eclipse.swt.graphics.GC gc,
                              ICellStyle cellStyle,
                              int width,
                              IRow row,
                              IColumn column)
Calculate the preferred height of a specific cell. Default implementation returning: no information.

Specified by:
getPreferredHeight in interface ICellRenderer
Overrides:
getPreferredHeight in class CellRendererBase
Parameters:
gc - GC that will used
cellStyle - cell style of the cell
width - width of the column (thus of the cell)
row - row
column - column
Returns:
the preferred height or -1 for no special preferred height

dispose

public void dispose()
If there are resources to free - this is the place.

Specified by:
dispose in interface ICellRenderer

createPrintRenderer

public ICellRenderer createPrintRenderer(org.eclipse.swt.printing.Printer printer)
Create a renderer connfigured for printing.

Specified by:
createPrintRenderer in interface ICellRenderer
Parameters:
printer - printer to use
Returns:
a configured renderer for printing


Copyright © 2012. All Rights Reserved.