1   /**
2    * Distribution License:
3    * BibleDesktop is free software; you can redistribute it and/or modify it under
4    * the terms of the GNU General Public License, version 2 as published by
5    * the Free Software Foundation. This program is distributed in the hope
6    * that it will be useful, but WITHOUT ANY WARRANTY; without even the
7    * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8    * See the GNU General Public License for more details.
9    *
10   * The License is available on the internet at:
11   *       http://www.gnu.org/copyleft/gpl.html
12   * or by writing to:
13   *      Free Software Foundation, Inc.
14   *      59 Temple Place - Suite 330
15   *      Boston, MA 02111-1307, USA
16   *
17   * Copyright: 2007
18   *     The copyright to this program is held by it's authors.
19   *
20   * ID: $Id: FullHTMLTip.java 2223 2012-01-26 21:28:02Z dmsmith $
21   */
22  package org.crosswire.bibledesktop.display.basic;
23  
24  import java.awt.Dimension;
25  import java.awt.Insets;
26  
27  import javax.swing.JTextPane;
28  import javax.swing.JToolTip;
29  import javax.swing.text.html.HTMLEditorKit;
30  
31  import org.crosswire.common.swing.AntiAliasedTextPane;
32  
33  /**
34   * A specialization of a JToolTip
35   * 
36   * @see gnu.gpl.License for license details.<br>
37   *      The copyright to this program is held by it's authors.
38   * @author Yingjie Lan [lanyjie at yahoo dot com]
39   */
40  class FullHTMLTip extends JToolTip {
41      public FullHTMLTip() {
42          this.setLayout(new java.awt.CardLayout());
43          txtView = new AntiAliasedTextPane();
44          txtView.setEditable(false);
45          txtView.setEditorKit(new HTMLEditorKit());
46          this.add(txtView, "HTMLTip");
47      }
48  
49      @Override
50      public Dimension getPreferredSize() {
51          Insets ist = getBorder().getBorderInsets(txtView);
52          Dimension d = txtView.getPreferredSize();
53          d.width += ist.left + ist.right;
54          d.height += ist.top + ist.bottom;
55          return d;
56      }
57  
58      @Override
59      public void setTipText(String tipText) {
60          txtView.setText(tipText);
61      }
62  
63      /**
64       * @return the text view
65       */
66      public JTextPane getTextView() {
67          return txtView;
68      }
69  
70      private JTextPane txtView;
71  
72      /**
73       * randomly generated sid.
74       */
75      private static final long serialVersionUID = 6364125062683029727L;
76  }
77