de.jaret.util.ui.timebars.swt
Class TimeBarPrinter

java.lang.Object
  extended by de.jaret.util.ui.timebars.swt.TimeBarPrinter

public class TimeBarPrinter
extends java.lang.Object

Utility class for printing a time bar chart. All renderers used have to support the creation of a print renderer.

Version:
$Id: TimeBarPrinter.java 1083 2011-07-01 20:29:16Z kliem $
Author:
Peter Kliem

Field Summary
protected  TimeBarViewerDelegate _delegate
          timebarviewerdelegate works for the printer.
protected  double _footerHeight
          height of the footer in cm.
protected  TimeBarGapRenderer _gapRenderer
          gap raenderer.
protected  GlobalAssistantRenderer _globalAssistantRenderer
          global assistance renderer.
protected  GridRenderer _gridRenderer
          grid renderer.
protected  HeaderRenderer _headerRenderer
          header renderer.
protected  HierarchyRenderer _hierarchyRenderer
          hierarchy renderer.
protected  double _marginBottom
          bottom margin in cm.
protected  double _marginLeft
          left margin in cm.
protected  double _marginRight
          right margin in cm.
protected  double _marginTop
          top margin in cm.
protected  TimeBarMarkerRenderer _markerRenderer
          marker renderer.
protected  org.eclipse.swt.printing.Printer _printer
          printer device.
protected  java.util.Map<java.lang.Class<? extends de.jaret.util.date.Interval>,TimeBarRenderer> _printerRendererMap
          mapping between interval classes and renderers (printer).
protected  IRelationRenderer _relationRenderer
          relation renderer.
protected  TimeBarRenderer _renderer
          time bar renderer.
protected  double _scaleX
          scale factor horizontal.
protected  double _scaleY
          scale factor vertical.
protected  TimeScaleRenderer _timeScaleRenderer
          time scale renderer.
protected  TitleRenderer _titleRenderer
          title renderer.
 
Constructor Summary
TimeBarPrinter(org.eclipse.swt.printing.Printer printer)
          Construct a timebar printer.
 
Method Summary
 void dispose()
          Dispose whatever needs disposal.
 TimeBarViewerDelegate getDelegate()
          Access to the delegate.
 double getFooterHeight()
           
 double getMarginBottom()
          Retrieve the bottom margin (cm).
 double getMarginLeft()
          Retrieve the left margin (cm).
 double getMarginRight()
          Retrieve the right margin (cm).
 double getMarginTop()
          Retrieve the top margin (cm).
 org.eclipse.swt.printing.Printer getPrinter()
          Retrieve the printer device.
protected  TimeBarRenderer getRenderer(java.lang.Class<? extends de.jaret.util.date.Interval> clazz)
          Retrieve a renderer for a given class.
 double getScaleX()
          Retrieve the scale factor for the x axis.
 double getScaleY()
          Retrieve the scale factor for the y axis.
 void init(TimeBarViewer tbv)
          Init the timebarprinter with the appropriate rendereres and settings from the timebarviewer.
protected  int pixelForCmX(double cm)
          Convert a value in cm to a number of printer pixels (x axis).
protected  int pixelForCmY(double cm)
          Convert a value in cm to a number of printer pixels (y axis).
 void print(ViewConfiguration vc)
          Do the printing.
 int scaleX(int in)
          Scale a pixel value to printer coordinates (x axis).
 int scaleY(int in)
          Scale a pixel value to printer coordinates (y axis).
 void setFooterHeight(double footerHeight)
           
 void setMarginBottom(double marginBottom)
          Set the bottom margin (cm).
 void setMarginLeft(double marginLeft)
          Set the left margin (cm).
 void setMarginRight(double marginRight)
          Set the right margin (cm).
 void setMarginTop(double marginTop)
          Set the top margin (cm).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_printer

protected org.eclipse.swt.printing.Printer _printer
printer device.


_scaleX

protected double _scaleX
scale factor horizontal.


_scaleY

protected double _scaleY
scale factor vertical.


_timeScaleRenderer

protected TimeScaleRenderer _timeScaleRenderer
time scale renderer.


_headerRenderer

protected HeaderRenderer _headerRenderer
header renderer.


_renderer

protected TimeBarRenderer _renderer
time bar renderer.


_hierarchyRenderer

protected HierarchyRenderer _hierarchyRenderer
hierarchy renderer.


_gridRenderer

protected GridRenderer _gridRenderer
grid renderer.


_gapRenderer

protected TimeBarGapRenderer _gapRenderer
gap raenderer.


_markerRenderer

protected TimeBarMarkerRenderer _markerRenderer
marker renderer.


_titleRenderer

protected TitleRenderer _titleRenderer
title renderer.


_globalAssistantRenderer

protected GlobalAssistantRenderer _globalAssistantRenderer
global assistance renderer.


_relationRenderer

protected IRelationRenderer _relationRenderer
relation renderer.


_printerRendererMap

protected java.util.Map<java.lang.Class<? extends de.jaret.util.date.Interval>,TimeBarRenderer> _printerRendererMap
mapping between interval classes and renderers (printer).


_delegate

protected TimeBarViewerDelegate _delegate
timebarviewerdelegate works for the printer.


_footerHeight

protected double _footerHeight
height of the footer in cm.


_marginTop

protected double _marginTop
top margin in cm.


_marginBottom

protected double _marginBottom
bottom margin in cm.


_marginLeft

protected double _marginLeft
left margin in cm.


_marginRight

protected double _marginRight
right margin in cm.

Constructor Detail

TimeBarPrinter

public TimeBarPrinter(org.eclipse.swt.printing.Printer printer)
Construct a timebar printer.

Parameters:
printer - printer device
Method Detail

scaleX

public int scaleX(int in)
Scale a pixel value to printer coordinates (x axis).

Parameters:
in - value to scale
Returns:
scaled value

getScaleX

public double getScaleX()
Retrieve the scale factor for the x axis.

Returns:
scale factor

scaleY

public int scaleY(int in)
Scale a pixel value to printer coordinates (y axis).

Parameters:
in - value to scale
Returns:
scaled value

getScaleY

public double getScaleY()
Retrieve the scale factor for the y axis.

Returns:
scale factor

pixelForCmX

protected int pixelForCmX(double cm)
Convert a value in cm to a number of printer pixels (x axis).

Parameters:
cm - value to convert
Returns:
converted value in printer pixel

pixelForCmY

protected int pixelForCmY(double cm)
Convert a value in cm to a number of printer pixels (y axis).

Parameters:
cm - value to convert
Returns:
converted value in printer pixel

getPrinter

public org.eclipse.swt.printing.Printer getPrinter()
Retrieve the printer device.

Returns:
the printer device

getDelegate

public TimeBarViewerDelegate getDelegate()
Access to the delegate.

Returns:
the delegate

init

public void init(TimeBarViewer tbv)
Init the timebarprinter with the appropriate rendereres and settings from the timebarviewer.

Parameters:
tbv - timebarviewer giving the settings

getRenderer

protected TimeBarRenderer getRenderer(java.lang.Class<? extends de.jaret.util.date.Interval> clazz)
Retrieve a renderer for a given class. Checks all interfaces and all superclasses.

Parameters:
clazz - class in question
Returns:
renderer or null

print

public void print(ViewConfiguration vc)
Do the printing.

Parameters:
vc - configuration to use for printing.

dispose

public void dispose()
Dispose whatever needs disposal. The method has to be called by the user of the the timebar printer.


getFooterHeight

public double getFooterHeight()
Returns:
footerheigth in cm

setFooterHeight

public void setFooterHeight(double footerHeight)
Parameters:
footerHeight - height of the footer line in cm

getMarginTop

public double getMarginTop()
Retrieve the top margin (cm).

Returns:
margin in cm

setMarginTop

public void setMarginTop(double marginTop)
Set the top margin (cm).

Parameters:
marginTop - margin in cm

getMarginBottom

public double getMarginBottom()
Retrieve the bottom margin (cm).

Returns:
margin in cm

setMarginBottom

public void setMarginBottom(double marginBottom)
Set the bottom margin (cm).

Parameters:
marginBottom - margin in cm

getMarginLeft

public double getMarginLeft()
Retrieve the left margin (cm).

Returns:
margin in cm

setMarginLeft

public void setMarginLeft(double marginLeft)
Set the left margin (cm).

Parameters:
marginLeft - margin in cm

getMarginRight

public double getMarginRight()
Retrieve the right margin (cm).

Returns:
margin in cm

setMarginRight

public void setMarginRight(double marginRight)
Set the right margin (cm).

Parameters:
marginRight - margin in cm


Copyright © 2012. All Rights Reserved.