View Javadoc

1   /*
2    * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
3    * 
4    * Based in London, we are world leaders in the design and development 
5    * of bespoke applications for the securities financing markets.
6    * 
7    * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
8    *           ___  _     _           _   _          _
9    *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
10   *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
11   *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
12   *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
13   *                   |__/
14   *
15   *                     www.ObjectLab.co.uk
16   *
17   * $Id: DefaultToolTipBuilder.java 116 2006-12-12 00:10:31Z ekingulen $
18   * 
19   * Copyright 2006 the original author or authors.
20   *
21   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
22   * use this file except in compliance with the License. You may obtain a copy of
23   * the License at
24   *
25   * http://www.apache.org/licenses/LICENSE-2.0
26   *
27   * Unless required by applicable law or agreed to in writing, software
28   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
30   * License for the specific language governing permissions and limitations under
31   * the License.
32   */
33  package net.sf.jtreemap.swing;
34  
35  import java.io.Serializable;
36  
37  import javax.swing.JToolTip;
38  
39  /**
40   * Default class to build the DefaultToolTip displayed by the JTreeMap.<BR>
41   * 
42   * @see net.sf.jtreemap.swing.DefaultToolTip
43   * @author Laurent DUTHEIL
44   * 
45   */
46  public class DefaultToolTipBuilder implements IToolTipBuilder, Serializable {
47      /**
48       * 
49       */
50      private static final long serialVersionUID = -1646772942428571187L;
51  
52      private static JToolTip instance = null;
53  
54      private JTreeMap jTreeMap;
55  
56      private String weightPrefix;
57      
58      private String valuePrefix;
59      
60      private boolean showWeight;
61  
62      /**
63       * Constructor.
64       * 
65       * @param jTreeMap
66       *            the linked JTreeMap
67       */
68      public DefaultToolTipBuilder(final JTreeMap jTreeMap, final String weightPrefix, final String valuePrefix, final boolean showWeight) {
69          this.jTreeMap = jTreeMap;
70          this.weightPrefix = weightPrefix;
71          this.valuePrefix = valuePrefix;
72          this.showWeight = showWeight;
73      }
74  
75      /*
76       * (non-Javadoc)
77       * 
78       * @see net.sf.jtreemap.swing.IToolTipBuilder#getToolTip()
79       */
80      public JToolTip getToolTip() {
81          if (instance == null) {
82              instance = new DefaultToolTip(this.jTreeMap, this.weightPrefix, 
83                      this.valuePrefix, this.showWeight);
84          }
85          return instance;
86      }
87  }
88  /*
89   *                 ObjectLab is supporing JTreeMap
90   * 
91   * Based in London, we are world leaders in the design and development 
92   * of bespoke applications for the securities financing markets.
93   * 
94   * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
95   *           ___  _     _           _   _          _
96   *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
97   *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
98   *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
99   *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
100  *                   |__/
101  *
102  *                     www.ObjectLab.co.uk
103  */