1 /*
2 * File: TimeBarRenderer2.java
3 * Copyright (c) 2004-2007 Peter Kliem (Peter.Kliem@jaret.de)
4 * A commercial license is available, see http://www.jaret.de.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 package de.jaret.util.ui.timebars.swt.renderer;
21
22 import org.eclipse.swt.graphics.GC;
23 import org.eclipse.swt.graphics.Rectangle;
24 import org.eclipse.swt.printing.Printer;
25
26 import de.jaret.util.date.Interval;
27 import de.jaret.util.ui.timebars.TimeBarViewerDelegate;
28
29 /**
30 * FOR FUTURE USE (AND WILL BE REFACTORED AT A LATER TIME!) Renderer for rendering intervals in the time bar viewer.
31 *
32 * @author Peter Kliem
33 * @version $Id: TimeBarRenderer2.java 800 2008-12-27 22:27:33Z kliem $
34 */
35 public interface TimeBarRenderer2 {
36 /**
37 * Render the given interval. Flags show if the rendering is done for printing and whether the interval is alone in
38 * its loation (overlap = false).
39 *
40 * @param gc GC
41 * @param drawingArea the rectangle to render the interval in.
42 * @param delegate the viewer delegate
43 * @param interval the interval to be rendered
44 * @param selected true if the interval is selected
45 * @param printing true if rendering is done for a prinetr
46 * @param overlap true if the interval is drawn as one of several intervals that overlap while beeing drawn.
47 */
48 void draw(GC gc, Rectangle drawingArea, TimeBarViewerDelegate delegate, Interval interval, boolean selected,
49 boolean printing, boolean overlap);
50
51 /**
52 * Retrieve the preferred drawing bounds for a specific interval.
53 *
54 * @param intervalDrawingArea the rectangle to render the interval in.
55 * @param delegate the viewer delegate
56 * @param interval the interval to be rendered
57 * @param selected true if the interval is selected
58 * @param printing true if rendering is done for a prinetr
59 * @param overlap true if the interval is drawn as one of several intervals that overlap while beeing drawn.
60 * @return the bounding rectangle that the renderer will paint in when rendering
61 */
62 Rectangle getPreferredDrawingBounds(Rectangle intervalDrawingArea, TimeBarViewerDelegate delegate,
63 Interval interval, boolean selected, boolean printing, boolean overlap);
64
65 /**
66 * Retrieve the tooltip text for the interval. Coordniates and drwaing area are given, so it is possible to return
67 * different tooltips for different locations on the rendered interval.
68 *
69 * @param delegate timebar viewer delegate
70 * @param interval the interval
71 * @param drawingArea area the interval has been randered in
72 * @param x x coordinate in the drawing area (relative)
73 * @param y y coordniate in the drawing area (relative)
74 * @param overlapping true if the interval is not alone at this location
75 * @return tooltip text or <code>null</code> indicating no tooltip should be displayed
76 */
77 String getToolTipText(TimeBarViewerDelegate delegate, Interval interval, Rectangle drawingArea, int x, int y,
78 boolean overlapping);
79
80 /**
81 * Check whether a given coordinate is contained in the rendered interval. This is used for exact selection.
82 *
83 * @param delegate timebar viewer delegate
84 * @param interval the interval
85 * @param drawingArea area the interval has been randered in
86 * @param x x coordinate in the drawing area
87 * @param y y coordniate in the drawing area
88 * @param overlapping true if overlapping occurred
89 * @return true if the coordinate belongs to the interval representation
90 */
91 boolean contains(TimeBarViewerDelegate delegate, Interval interval, Rectangle drawingArea, int x, int y,
92 boolean overlapping);
93
94 /**
95 * Retrieve the bounding rectangle of the interval rendering.
96 *
97 * @param delegate timebar viewer delegate
98 * @param interval the interval
99 * @param drawingArea area the interval has been randered in
100 * @param overlapping true if overlapping occurred
101 * @return containing rectangle of the interval's representation
102 */
103 Rectangle getContainingRectangle(TimeBarViewerDelegate delegate, Interval interval, Rectangle drawingArea,
104 boolean overlapping);
105
106 /**
107 * Dispose the renderer. Should free up any resources locked.
108 *
109 */
110 void dispose();
111
112 /**
113 * Create a similar renderer for printing. The creation should copy settings made to the producing renderer.
114 *
115 * @param printer Printer device
116 * @return a configured renderer for printing.
117 */
118 TimeBarRenderer createPrintrenderer(Printer printer);
119 }