View Javadoc

1   /*
2    *  File: TimeScaleRenderer.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.ui.timebars.swing.TimeBarViewer;
25  
26  /**
27   * Interface for a renderer used to render a time scale in the TimeBarViewer. Care has to be taken not to create a
28   * JComponent for every call of <code>getRendererComponent</code>. The renderer should guard one JComponent to configure
29   * and return on subsequent calls.
30   * 
31   * @author Peter Kliem
32   * @version $Id: TimeScaleRenderer.java 800 2008-12-27 22:27:33Z kliem $
33   */
34  public interface TimeScaleRenderer {
35      /**
36       * Return a JComponent to be used to render the time scale. The component has to be configured properly before
37       * returning it. All needed information about the time scale, major and minor ticks can be obtainend by the
38       * TimeBarViewer.
39       * <p>
40       * The component may implement <code>getToolTipText(MouseEvent evt)</code> to return a proper tooltip for the
41       * location
42       * </p>
43       * 
44       * @param tbv the TimeBarViwer the component is used for
45       * @param top if true the scale is drawn at the top of the diagram
46       * @return a configured JComponent
47       */
48      JComponent getRendererComponent(TimeBarViewer tbv, boolean top);
49  
50      /**
51       * Return the height needed for painting the time scale. The value will be fetched only once when the renderer is
52       * set for the TimeBarViewer for reasons of stability in painting.
53       * 
54       * @return the height of the time scale
55       */
56      int getHeight();
57  }