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

java.lang.Object
  extended by de.jaret.util.ui.timebars.swt.renderer.RendererBase
      extended by de.jaret.util.ui.timebars.swt.renderer.AbstractTimeBarRenderer
          extended by de.jaret.util.ui.timebars.swt.renderer.DefaultRenderer
All Implemented Interfaces:
TimeBarRenderer, TimeBarRenderer2

public class DefaultRenderer
extends AbstractTimeBarRenderer

DefaultRenderer for the TimeBarViewer widget. It renders intervals as grey/blue bars.

Version:
$Id: DefaultRenderer.java 802 2008-12-28 12:30:41Z kliem $
Author:
Peter Kliem

Field Summary
protected  TimeBarViewerDelegate _delegate
          cache for the delegate supplying the orientation information.
protected static double BORDERFACTOR
          width or height times this factor = perentage used as the non painted border.
 
Fields inherited from class de.jaret.util.ui.timebars.swt.renderer.RendererBase
_printer, _scaleX, _scaleY
 
Constructor Summary
DefaultRenderer()
          Construct renderer for screen use.
DefaultRenderer(org.eclipse.swt.printing.Printer printer)
          Create renderer for printing.
 
Method Summary
 boolean contains(de.jaret.util.date.Interval interval, org.eclipse.swt.graphics.Rectangle drawingArea, int x, int y, boolean overlapping)
          Check whether a given coordinate is contained in the rendered interval.
 boolean contains(TimeBarViewerDelegate delegate, de.jaret.util.date.Interval interval, org.eclipse.swt.graphics.Rectangle drawingArea, int x, int y, boolean overlapping)
          Check whether a given coordinate is contained in the rendered interval.
 TimeBarRenderer createPrintrenderer(org.eclipse.swt.printing.Printer printer)
          Create a similar renderer for printing.
 void dispose()
          Dispose the renderer.
 void draw(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle drawingArea, TimeBarViewerDelegate delegate, de.jaret.util.date.Interval interval, boolean selected, boolean printing, boolean overlap)
          Render the given interval.
 org.eclipse.swt.graphics.Rectangle getContainingRectangle(de.jaret.util.date.Interval interval, org.eclipse.swt.graphics.Rectangle drawingArea, boolean overlapping)
          Retrieve the bounding rectangle of the interval rendering.
 org.eclipse.swt.graphics.Rectangle getContainingRectangle(TimeBarViewerDelegate delegate, de.jaret.util.date.Interval interval, org.eclipse.swt.graphics.Rectangle drawingArea, boolean overlapping)
          Retrieve the bounding rectangle of the interval rendering.
protected  org.eclipse.swt.graphics.Rectangle getIRect(boolean horizontal, org.eclipse.swt.graphics.Rectangle drawingArea, boolean overlap)
          Calculate the actual drawing rectangle for the interval usig the BORDERFACTOR to determine the border.
 java.lang.String getToolTipText(de.jaret.util.date.Interval interval, org.eclipse.swt.graphics.Rectangle drawingArea, int x, int y, boolean overlapping)
          Retrieve the tooltip text for the interval.
 java.lang.String getToolTipText(TimeBarViewerDelegate delegate, de.jaret.util.date.Interval interval, org.eclipse.swt.graphics.Rectangle drawingArea, int x, int y, boolean overlapping)
          Retrieve the tooltip text for the interval.
 
Methods inherited from class de.jaret.util.ui.timebars.swt.renderer.AbstractTimeBarRenderer
getPreferredDrawingBounds
 
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

BORDERFACTOR

protected static final double BORDERFACTOR
width or height times this factor = perentage used as the non painted border.

See Also:
Constant Field Values

_delegate

protected TimeBarViewerDelegate _delegate
cache for the delegate supplying the orientation information.

Constructor Detail

DefaultRenderer

public DefaultRenderer(org.eclipse.swt.printing.Printer printer)
Create renderer for printing.

Parameters:
printer - printer device

DefaultRenderer

public DefaultRenderer()
Construct renderer for screen use.

Method Detail

draw

public void draw(org.eclipse.swt.graphics.GC gc,
                 org.eclipse.swt.graphics.Rectangle drawingArea,
                 TimeBarViewerDelegate delegate,
                 de.jaret.util.date.Interval interval,
                 boolean selected,
                 boolean printing,
                 boolean overlap)
Render the given interval. Flags show if the rendering is done for printing and whether the interval is alone in its loation (overlap = false).

Parameters:
gc - GC
drawingArea - the rectangle to render the interval in.
delegate - the viewer delegate
interval - the interval to be rendered
selected - true if the interval is selected
printing - true if rendering is done for a prinetr
overlap - true if the interval is drawn as one of several intervals that overlap while beeing drawn.

getToolTipText

public java.lang.String getToolTipText(de.jaret.util.date.Interval interval,
                                       org.eclipse.swt.graphics.Rectangle drawingArea,
                                       int x,
                                       int y,
                                       boolean overlapping)
Retrieve the tooltip text for the interval. Coordniates and drwaing area are given, so it is possible to return different tooltips for different locations on the rendered interval.

Parameters:
interval - the interval
drawingArea - area the interval has been randered in
x - x coordinate in the drawing area (relative)
y - y coordniate in the drawing area (relative)
overlapping - true if the interval is not alone at this location
Returns:
tooltip text or null indicating no tooltip should be displayed

contains

public boolean contains(de.jaret.util.date.Interval interval,
                        org.eclipse.swt.graphics.Rectangle drawingArea,
                        int x,
                        int y,
                        boolean overlapping)
Check whether a given coordinate is contained in the rendered interval. This is used for exact selection.

Parameters:
interval - the interval
drawingArea - area the interval has been randered in
x - x coordinate in the drawing area
y - y coordniate in the drawing area
overlapping - true if overlapping occurred
Returns:
true if the coordinate belongs to the interval representation

getContainingRectangle

public org.eclipse.swt.graphics.Rectangle getContainingRectangle(de.jaret.util.date.Interval interval,
                                                                 org.eclipse.swt.graphics.Rectangle drawingArea,
                                                                 boolean overlapping)
Retrieve the bounding rectangle of the interval rendering.

Parameters:
interval - the interval
drawingArea - area the interval has been randered in
overlapping - true if overlapping occurred
Returns:
containing rectangle of the interval's representation

createPrintrenderer

public TimeBarRenderer createPrintrenderer(org.eclipse.swt.printing.Printer printer)
Create a similar renderer for printing. The creation should copy settings made to the producing renderer.. Will create print renderes for all registered renderers.

Parameters:
printer - Printer device
Returns:
a configured renderer for printing.

dispose

public void dispose()
Dispose the renderer. Should free up any resources locked.


getToolTipText

public java.lang.String getToolTipText(TimeBarViewerDelegate delegate,
                                       de.jaret.util.date.Interval interval,
                                       org.eclipse.swt.graphics.Rectangle drawingArea,
                                       int x,
                                       int y,
                                       boolean overlapping)
Retrieve the tooltip text for the interval. Coordniates and drwaing area are given, so it is possible to return different tooltips for different locations on the rendered interval.

Parameters:
delegate - timebar viewer delegate
interval - the interval
drawingArea - area the interval has been randered in
x - x coordinate in the drawing area (relative)
y - y coordniate in the drawing area (relative)
overlapping - true if the interval is not alone at this location
Returns:
tooltip text or null indicating no tooltip should be displayed

contains

public boolean contains(TimeBarViewerDelegate delegate,
                        de.jaret.util.date.Interval interval,
                        org.eclipse.swt.graphics.Rectangle drawingArea,
                        int x,
                        int y,
                        boolean overlapping)
Check whether a given coordinate is contained in the rendered interval. This is used for exact selection.

Parameters:
delegate - timebar viewer delegate
interval - the interval
drawingArea - area the interval has been randered in
x - x coordinate in the drawing area
y - y coordniate in the drawing area
overlapping - true if overlapping occurred
Returns:
true if the coordinate belongs to the interval representation

getContainingRectangle

public org.eclipse.swt.graphics.Rectangle getContainingRectangle(TimeBarViewerDelegate delegate,
                                                                 de.jaret.util.date.Interval interval,
                                                                 org.eclipse.swt.graphics.Rectangle drawingArea,
                                                                 boolean overlapping)
Retrieve the bounding rectangle of the interval rendering.

Parameters:
delegate - timebar viewer delegate
interval - the interval
drawingArea - area the interval has been randered in
overlapping - true if overlapping occurred
Returns:
containing rectangle of the interval's representation

getIRect

protected org.eclipse.swt.graphics.Rectangle getIRect(boolean horizontal,
                                                      org.eclipse.swt.graphics.Rectangle drawingArea,
                                                      boolean overlap)
Calculate the actual drawing rectangle for the interval usig the BORDERFACTOR to determine the border.

Parameters:
horizontal - true for horizontal false for vertical
drawingArea - drawingArea
overlap - true if it is an overlapping interval
Returns:
the actual drawing rectangle


Copyright © 2012. All Rights Reserved.