View Javadoc
1   package org.opentrafficsim.swing.gui;
2   
3   /**
4    * This interface allows on screen items to <b>not</b> obtain colors and/or the font from an {@code Appearance}. This can be
5    * useful for items where considering only a background and a foreground color is not sufficient, possibly creating unreadable
6    * or otherwise unpleasant on screen items.<br>
7    * <br>
8    * The default implementation of the methods in this interface return {@code false}, meaning the {@code Appearance} is
9    * completely ignored. In order to ignore it only partially, some methods should be overridden to return true. An example of
10   * this is given below, which will only allow the font of the {@code Appearance}. It also shows a convenient way to implement
11   * this interface when using default on screen items using a local class.
12   * 
13   * <pre>
14   * class AppearanceControlComboBox&lt;T&gt; extends JComboBox&lt;T&gt; implements AppearanceControl
15   * {
16   *     public boolean isFont()
17   *     {
18   *         return true;
19   *     }
20   * }
21   * 
22   * JComboBox&lt;String&gt; comboBox = new AppearanceControlComboBox&lt;&gt;();
23   * </pre>
24   * 
25   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
26   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
27   * <p>
28   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 6 feb. 2018 <br>
29   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
30   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
31   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
32   */
33  public interface AppearanceControl
34  {
35  
36      /**
37       * Returns whether this item has a controllable background.
38       * @return whether this item has a controllable background
39       */
40      default boolean isBackground()
41      {
42          return false;
43      }
44  
45      /**
46       * Returns whether this item has a controllable foreground.
47       * @return whether this item has a controllable foreground
48       */
49      default boolean isForeground()
50      {
51          return false;
52      }
53  
54      /**
55       * Returns whether this item has a controllable font.
56       * @return whether this item has a controllable font
57       */
58      default boolean isFont()
59      {
60          return false;
61      }
62  
63  }