View Javadoc

1   /*
2    *  File: TimeBarRenderer.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.swing.renderer;
21  
22  import java.awt.Rectangle;
23  
24  import javax.swing.JComponent;
25  
26  import de.jaret.util.date.Interval;
27  import de.jaret.util.ui.timebars.TimeBarViewerDelegate;
28  import de.jaret.util.ui.timebars.swing.TimeBarViewer;
29  
30  /**
31   * Interface for supplying a JComponent to render an interval in the <code>TimeBarViewer</code>. The JComponent should
32   * be reused, i.e. there only has to be one JComponent to be set up for drawing.
33   * 
34   * @author Peter Kliem
35   * @version $Id: TimeBarRenderer.java 869 2009-07-07 19:32:45Z kliem $
36   */
37  public interface TimeBarRenderer {
38      /** key for identifying the content rectangle as a client property. */
39      String CONTAINING_RECTANGLE = "contRect";
40  
41      /**
42       * Supply a component to render an interval in the TimeBarViewer. The component may
43       * <ul>
44       * <li>implement contains(x,y) for exact selection and tooltip firing</li>
45       * <li>put the containing rectangle in the client property <code>TimeBarRenderer.CONTAINING_RECTANGLE</code> for
46       * exact selection using the selection rectangle</li>
47       * </ul>
48       * 
49       * @param tbv the asking TimeBarViewer
50       * @param value the interval to render
51       * @param isSelected render marked as selected
52       * @param overlapping true if the interval is one of an overlapping set of intervals
53       * @return a configured JComponent, ready to be painted by <code>paint(Graphics g)</code>
54       */
55      JComponent getTimeBarRendererComponent(TimeBarViewer tbv, Interval value, boolean isSelected, boolean overlapping);
56  
57      /**
58       * Retrieve the preferred drawing bounds for a specific interval. As a default implementation simply return the interval drawing area.
59       * 
60       * @param intervalDrawingArea the rectangle to render the interval in.
61       * @param delegate the viewer delegate
62       * @param interval the interval to be rendered
63       * @param selected true if the interval is selected
64       * @param overlap true if the interval is drawn as one of several intervals that overlap while beeing drawn.
65       * @return the bounding rectangle that the renderer will paint in when rendering
66       */
67      Rectangle getPreferredDrawingBounds(Rectangle intervalDrawingArea, TimeBarViewerDelegate delegate,
68              Interval interval, boolean selected, boolean overlap);
69  
70  
71  
72  }