de.jaret.util.ui.timebars.swt.renderer
Class BoxTimeScaleRenderer

java.lang.Object
  extended by de.jaret.util.ui.timebars.swt.renderer.RendererBase
      extended by de.jaret.util.ui.timebars.swt.renderer.BoxTimeScaleRenderer
All Implemented Interfaces:
ITickProvider, TimeScaleRenderer

public class BoxTimeScaleRenderer
extends RendererBase
implements TimeScaleRenderer, ITickProvider

Timescalerenderer rendering strips of boxes for different time intervals using DateIterator instances. A holiday enumerator can be used to display special and holidays in the tooltip. Supports horizontal and vertical operation (vertical might be imperformant since vertical text is used).

Version:
$Id: BoxTimeScaleRenderer.java 1086 2011-07-30 20:28:05Z kliem $
Author:
Peter Kliem

Field Summary
protected  java.util.List<java.lang.Boolean> _enable
          enabled state of the corresponding strip.
protected  java.util.List<de.jaret.util.date.iterator.DateIterator.Format> _formats
          format of the corresponding iterator label.
protected  de.jaret.util.date.holidayenumerator.HolidayEnumerator _holidayEnumerator
          holiday enumerator for tooltips.
protected  java.util.List<de.jaret.util.date.iterator.DateIterator> _iterators
          List of dateiterators for the strips.
protected  java.util.List<de.jaret.util.date.JaretDate> _majorTicks
          major ticks of the last rendering.
protected  java.util.List<de.jaret.util.date.JaretDate> _minorTicks
          minor ticks of the last rendering.
protected  int _numberOfStrips
          actual number of strips to render.
protected  int _textHeight
          local cache for textextent height.
protected static int ADDITIONALGAP
          additional gap between end of label and next line (approx).
protected static int BOXHEIGHT
          height of a box.
protected static int GAP
          gap between line and label.
protected static int SETBONUS
          Bonus rewarded when an Iterator is already enabled for a format.
 
Fields inherited from class de.jaret.util.ui.timebars.swt.renderer.RendererBase
_printer, _scaleX, _scaleY
 
Constructor Summary
BoxTimeScaleRenderer()
          Default constructor.
BoxTimeScaleRenderer(org.eclipse.swt.printing.Printer printer)
          Construct the renderer for a printer device.
 
Method Summary
 TimeScaleRenderer createPrintRenderer(org.eclipse.swt.printing.Printer printer)
          Create a timescale renderer setup for printing.
 void dispose()
          Dispose resources.
 void draw(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle drawingArea, TimeBarViewerDelegate delegate, boolean top, boolean printing)
          Draw the Timescale.
 int getHeight()
          Returns the prferred height for rendering.
 java.util.List<de.jaret.util.date.JaretDate> getMajorTicks(TimeBarViewerDelegate delegate)
          Provide a list of dates used as major ticks.
 java.util.List<de.jaret.util.date.JaretDate> getMinorTicks(TimeBarViewerDelegate delegate)
          Provide a list of dates used as minor ticks.
 int getNumberOfStrips()
          retrieve the number of strips to render.
 java.lang.String getToolTipText(TimeBarViewer tbv, org.eclipse.swt.graphics.Rectangle drawingArea, int x, int y)
          Retrieve the tooltip text for a given locatin in the timescale.
 void setCorrectDST(boolean correctDST)
          Setup the iterators to do a DST correction.
 void setHolidayEnumerator(de.jaret.util.date.holidayenumerator.HolidayEnumerator he)
          Set a holidayenumerator for displaying special days as tooltip.
 void setNumberOfStrips(int numberOfStrips)
          Set the maximum number of strips to render.
 boolean supportsOptimizedScrolling()
          Report whether this renderer can be used with optimized scrolling.
 
Methods inherited from class de.jaret.util.ui.timebars.swt.renderer.RendererBase
drawFocus, getDefaultLineWidth, getPrinter, getScaleX, getScaleY, scaleX, scaleY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOXHEIGHT

protected static final int BOXHEIGHT
height of a box.

See Also:
Constant Field Values

ADDITIONALGAP

protected static final int ADDITIONALGAP
additional gap between end of label and next line (approx).

See Also:
Constant Field Values

GAP

protected static final int GAP
gap between line and label.

See Also:
Constant Field Values

SETBONUS

protected static final int SETBONUS
Bonus rewarded when an Iterator is already enabled for a format.

See Also:
Constant Field Values

_textHeight

protected int _textHeight
local cache for textextent height.


_numberOfStrips

protected int _numberOfStrips
actual number of strips to render.


_holidayEnumerator

protected de.jaret.util.date.holidayenumerator.HolidayEnumerator _holidayEnumerator
holiday enumerator for tooltips.


_iterators

protected java.util.List<de.jaret.util.date.iterator.DateIterator> _iterators
List of dateiterators for the strips.


_formats

protected java.util.List<de.jaret.util.date.iterator.DateIterator.Format> _formats
format of the corresponding iterator label.


_enable

protected java.util.List<java.lang.Boolean> _enable
enabled state of the corresponding strip.


_majorTicks

protected java.util.List<de.jaret.util.date.JaretDate> _majorTicks
major ticks of the last rendering.


_minorTicks

protected java.util.List<de.jaret.util.date.JaretDate> _minorTicks
minor ticks of the last rendering.

Constructor Detail

BoxTimeScaleRenderer

public BoxTimeScaleRenderer(org.eclipse.swt.printing.Printer printer)
Construct the renderer for a printer device.

Parameters:
printer - printer device

BoxTimeScaleRenderer

public BoxTimeScaleRenderer()
Default constructor.

Method Detail

setHolidayEnumerator

public void setHolidayEnumerator(de.jaret.util.date.holidayenumerator.HolidayEnumerator he)
Set a holidayenumerator for displaying special days as tooltip.

Parameters:
he - holidayenumerator to use

draw

public void draw(org.eclipse.swt.graphics.GC gc,
                 org.eclipse.swt.graphics.Rectangle drawingArea,
                 TimeBarViewerDelegate delegate,
                 boolean top,
                 boolean printing)
Draw the Timescale.

Specified by:
draw in interface TimeScaleRenderer
Parameters:
gc - GraphicsContext to paint with.
drawingArea - Rectangel denoting the area to draw in. The gc is clipped to this area.
delegate - TimeBarViewerDelegate exposed for callbacks
top - if true the tmiescale is in position top, bottom otherwise
printing - flag to indicate printing.

getToolTipText

public java.lang.String getToolTipText(TimeBarViewer tbv,
                                       org.eclipse.swt.graphics.Rectangle drawingArea,
                                       int x,
                                       int y)
Retrieve the tooltip text for a given locatin in the timescale.

Specified by:
getToolTipText in interface TimeScaleRenderer
Parameters:
tbv - TimeBarViewer
drawingArea - area in that the timescale has been painted
x - x coordinate
y - y coordinate
Returns:
tooltip text or null

getHeight

public int getHeight()
Returns the prferred height for rendering.

Specified by:
getHeight in interface TimeScaleRenderer
Returns:
preferred height

dispose

public void dispose()
Dispose resources.

Specified by:
dispose in interface TimeScaleRenderer

createPrintRenderer

public TimeScaleRenderer createPrintRenderer(org.eclipse.swt.printing.Printer printer)
Create a timescale renderer setup for printing.

Specified by:
createPrintRenderer in interface TimeScaleRenderer
Parameters:
printer - Printer device taht will be used.
Returns:
timescale renderer setup for printing.

getNumberOfStrips

public int getNumberOfStrips()
retrieve the number of strips to render.

Returns:
number of strips

setNumberOfStrips

public void setNumberOfStrips(int numberOfStrips)
Set the maximum number of strips to render.

Parameters:
numberOfStrips - maximum number of strips

getMajorTicks

public java.util.List<de.jaret.util.date.JaretDate> getMajorTicks(TimeBarViewerDelegate delegate)
Provide a list of dates used as major ticks.

Specified by:
getMajorTicks in interface ITickProvider
Parameters:
delegate - the delegate the ticks are used with
Returns:
list of dates

getMinorTicks

public java.util.List<de.jaret.util.date.JaretDate> getMinorTicks(TimeBarViewerDelegate delegate)
Provide a list of dates used as minor ticks.

Specified by:
getMinorTicks in interface ITickProvider
Parameters:
delegate - the delegate the ticks are used with
Returns:
list of dates

setCorrectDST

public void setCorrectDST(boolean correctDST)
Setup the iterators to do a DST correction.

Parameters:
correctDST - true if a correction should be done.

supportsOptimizedScrolling

public boolean supportsOptimizedScrolling()
Report whether this renderer can be used with optimized scrolling. This will usually be the case if all elements drawn are positioned by the date.

Specified by:
supportsOptimizedScrolling in interface TimeScaleRenderer
Returns:
true if optimzed drawing can be used.


Copyright © 2012. All Rights Reserved.