View Javadoc

1   /*
2    *  File: TimeBarGapRenderer.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 javax.swing.JComponent;
23  
24  import de.jaret.util.date.Interval;
25  import de.jaret.util.ui.timebars.model.TimeBarRow;
26  import de.jaret.util.ui.timebars.swing.TimeBarViewer;
27  
28  /**
29   * Interface for supplying a JComponent for rendering the gaps between two intervals. The supplied JComponent should be
30   * reused and only be set up for rendering a single gap. Setup is done by the <code>TimeBarViewer</code>. Since in some
31   * situations the gap betwwen two intervals is very small (or non-existent) it is possible to enforce a minimum width
32   * for the clipping rect and size for the gap rendering component.
33   * 
34   * @author Peter Kliem
35   * @version $Id: TimeBarGapRenderer.java 800 2008-12-27 22:27:33Z kliem $
36   */
37  public interface TimeBarGapRenderer {
38      /**
39       * 
40       * @param tbv the calling TimeBarViewer
41       * @param row the row the intervals are in
42       * @param interval1 left interval (may be null if the gap is the starting "gap")
43       * @param interval2 right interval (may be <code>null</code> if it is the ending "gap")
44       * @return a configured JComponent for rendering
45       */
46      JComponent getTimeBarGapRendererComponent(TimeBarViewer tbv, TimeBarRow row, Interval interval1, Interval interval2);
47  
48      /**
49       * By returning a non negative value a minimum width will be given to the renderer. The size and clipping rect will
50       * be centered around the middle of the gap between the two intervals.
51       * 
52       * @return minimum width for the rendering component. A negative value indicates no need for a fixed minimum width
53       */
54      int getMinimumWidth();
55  }