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

java.lang.Object
  extended by de.jaret.util.ui.table.renderer.RendererBase
      extended by de.jaret.util.ui.table.renderer.DefaultTableHeaderRenderer
All Implemented Interfaces:
ITableHeaderRenderer

public class DefaultTableHeaderRenderer
extends RendererBase
implements ITableHeaderRenderer

Default header renderer for the jaret table. The header renderer will render a simple header view. The renderer supports rotating the header text from 0 to 90 degrees anti-clock wise. If a rotation is set, the header is drawn using a white background. Several properties allow changing the drawing (always consider writing a specialized renderer!).

Version:
$Id: DefaultTableHeaderRenderer.java 1077 2010-12-17 12:03:27Z kliem $
Author:
Peter Kliem

Nested Class Summary
static class DefaultTableHeaderRenderer.Alignment
          Alignment enumeration.
 class DefaultTableHeaderRenderer.LocalResourceImageDescriptor
           
 
Field Summary
protected  DefaultTableHeaderRenderer.Alignment _alignment
          Alignment: default left.
protected  org.eclipse.swt.graphics.RGB _backgroundRGB
          background rgb value.
protected  org.eclipse.swt.graphics.Color _bgColor
          allocated background color.
protected  boolean _drawBox
          true if the header box should be drawn.
protected  org.eclipse.swt.graphics.Font _font
          font when aquired.
protected  org.eclipse.swt.graphics.FontData _fontData
          FOntadat of the font to use.
protected  org.eclipse.jface.resource.ImageRegistry _imageRegistry
           
protected  int _rotation
          rotation of the header text.
protected  org.eclipse.swt.graphics.Transform _transform
          Transformations for rotated text.
protected  org.eclipse.swt.graphics.Transform _transformInv
          inverse transformation to reset gc.
protected static java.lang.String DOWN
          key for downwards arrow.
protected static int SORTINGAREAINDICATORWIDTH
          width reserved for the sorting area.
protected static java.lang.String UP
          key for uowards arrow.
 
Fields inherited from class de.jaret.util.ui.table.renderer.RendererBase
_printer, _scaleX, _scaleY, SCREEN_DPI_X, SCREEN_DPI_Y
 
Constructor Summary
DefaultTableHeaderRenderer()
          Construct header renderer for a display.
DefaultTableHeaderRenderer(org.eclipse.swt.printing.Printer printer)
          Construct a header renderer for printing.
 
Method Summary
 boolean disableClipping()
          If this method returns true the gc for drawing will not be limited by a clipping rect.
 void dispose()
          Dispose any resources allocated.
 void draw(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle drawingArea, IColumn column, int sortingOrder, boolean sortDir, boolean printing)
          Draw a table header.
 DefaultTableHeaderRenderer.Alignment getAlignment()
          Retrieve the alignment for the header label (only when not rotated).
 org.eclipse.swt.graphics.RGB getBackgroundRGB()
          Get the background RGB value of the header (non rotated only).
 boolean getDrawBox()
          Retrieve whether the header is drawn boxed.
 org.eclipse.swt.graphics.FontData getFontData()
          Get the fontdata for the font used to render the header label.
 ITableHeaderRenderer getPrintRenderer(org.eclipse.swt.printing.Printer printer)
          Create a table header renderer for printing.
 boolean isSortingClick(org.eclipse.swt.graphics.Rectangle drawingArea, IColumn column, int x, int y)
          Check whether a click hits the area reserved for sorting indication.
 void setAlignment(DefaultTableHeaderRenderer.Alignment alignment)
          Set the alignment for the header label (not used when rotated).
 void setBackgroundRGB(org.eclipse.swt.graphics.RGB backgroundRGB)
          Set the background rgb value.
 void setDrawBox(boolean drawBox)
          Set whether the header should be drawn boxed.
 void setFontData(org.eclipse.swt.graphics.FontData fontData)
          Set the fontdata for the font to render the header.
 void setRotation(int rotation)
          Set the rotation of the header text.
 
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
 

Field Detail

_alignment

protected DefaultTableHeaderRenderer.Alignment _alignment
Alignment: default left.


_drawBox

protected boolean _drawBox
true if the header box should be drawn.


_backgroundRGB

protected org.eclipse.swt.graphics.RGB _backgroundRGB
background rgb value.


_bgColor

protected org.eclipse.swt.graphics.Color _bgColor
allocated background color.


_fontData

protected org.eclipse.swt.graphics.FontData _fontData
FOntadat of the font to use.


_font

protected org.eclipse.swt.graphics.Font _font
font when aquired.


_rotation

protected int _rotation
rotation of the header text.


_transform

protected org.eclipse.swt.graphics.Transform _transform
Transformations for rotated text.


_transformInv

protected org.eclipse.swt.graphics.Transform _transformInv
inverse transformation to reset gc.


_imageRegistry

protected org.eclipse.jface.resource.ImageRegistry _imageRegistry

UP

protected static final java.lang.String UP
key for uowards arrow.

See Also:
Constant Field Values

DOWN

protected static final java.lang.String DOWN
key for downwards arrow.

See Also:
Constant Field Values

SORTINGAREAINDICATORWIDTH

protected static final int SORTINGAREAINDICATORWIDTH
width reserved for the sorting area.

See Also:
Constant Field Values
Constructor Detail

DefaultTableHeaderRenderer

public DefaultTableHeaderRenderer(org.eclipse.swt.printing.Printer printer)
Construct a header renderer for printing.

Parameters:
printer - printer device

DefaultTableHeaderRenderer

public DefaultTableHeaderRenderer()
Construct header renderer for a display.

Method Detail

setRotation

public void setRotation(int rotation)
Set the rotation of the header text. Please note that you have to call redraw() on the table yourself if you change the rotation while the table is showing.

Parameters:
rotation - rotation in degrees anti clockwise between 0 and 90 degrees.

draw

public void draw(org.eclipse.swt.graphics.GC gc,
                 org.eclipse.swt.graphics.Rectangle drawingArea,
                 IColumn column,
                 int sortingOrder,
                 boolean sortDir,
                 boolean printing)
Draw a table header.

Specified by:
draw in interface ITableHeaderRenderer
Parameters:
gc - GC to be used
drawingArea - rectangle to draw within
column - the column for which the header is painted.
sortingOrder - if the column is part of the sorting set this indicates the sorting order position. A value of 0 means no sorting.
sortDir - if sorting this indicates the sorting direction. true means ascending.
printing - true if the draw operation is for a printer

disableClipping

public boolean disableClipping()
If this method returns true the gc for drawing will not be limited by a clipping rect. This is useful for slanted header texts but should be used with the appropriate care.

Specified by:
disableClipping in interface ITableHeaderRenderer
Returns:
true if the rendering should not be clipped.

dispose

public void dispose()
Dispose any resources allocated.

Specified by:
dispose in interface ITableHeaderRenderer

isSortingClick

public boolean isSortingClick(org.eclipse.swt.graphics.Rectangle drawingArea,
                              IColumn column,
                              int x,
                              int y)
Check whether a click hits the area reserved for sorting indication.

Specified by:
isSortingClick in interface ITableHeaderRenderer
Parameters:
drawingArea - drawing aea of the header
column - column
x - x coordinat of the click
y - y coordinate of the click
Returns:
true if the click is in the area that should be active for sorting

getPrintRenderer

public ITableHeaderRenderer getPrintRenderer(org.eclipse.swt.printing.Printer printer)
Create a table header renderer for printing.

Specified by:
getPrintRenderer in interface ITableHeaderRenderer
Parameters:
printer - the printer that will be used
Returns:
a configured header renderer for printing.

getAlignment

public DefaultTableHeaderRenderer.Alignment getAlignment()
Retrieve the alignment for the header label (only when not rotated).

Returns:
the alignment

setAlignment

public void setAlignment(DefaultTableHeaderRenderer.Alignment alignment)
Set the alignment for the header label (not used when rotated).

Parameters:
alignment - alignment to be used

getDrawBox

public boolean getDrawBox()
Retrieve whether the header is drawn boxed.

Returns:
true if a box is drawn around the header

setDrawBox

public void setDrawBox(boolean drawBox)
Set whether the header should be drawn boxed.

Parameters:
drawBox - true for boxed drawing

getBackgroundRGB

public org.eclipse.swt.graphics.RGB getBackgroundRGB()
Get the background RGB value of the header (non rotated only).

Returns:
the RGB value for the background

setBackgroundRGB

public void setBackgroundRGB(org.eclipse.swt.graphics.RGB backgroundRGB)
Set the background rgb value. The color will be aquired when used. Will only be used when non rotated.

Parameters:
backgroundRGB - the RGB value

getFontData

public org.eclipse.swt.graphics.FontData getFontData()
Get the fontdata for the font used to render the header label.

Returns:
the fontdata

setFontData

public void setFontData(org.eclipse.swt.graphics.FontData fontData)
Set the fontdata for the font to render the header. The font will be aquired when used.

Parameters:
fontData - fontdat ato use


Copyright © 2012. All Rights Reserved.