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   * <p>
25   * Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
26   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
27   * </p>
28   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
29   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
30   * @author <a href="https://dittlab.tudelft.nl">Wouter Schakel</a>
31   */
32  public interface AppearanceControl
33  {
34  
35      /**
36       * Returns whether this item has a controllable background.
37       * @return whether this item has a controllable background
38       */
39      default boolean isBackground()
40      {
41          return false;
42      }
43  
44      /**
45       * Returns whether this item has a controllable foreground.
46       * @return whether this item has a controllable foreground
47       */
48      default boolean isForeground()
49      {
50          return false;
51      }
52  
53      /**
54       * Returns whether this item has a controllable font.
55       * @return whether this item has a controllable font
56       */
57      default boolean isFont()
58      {
59          return false;
60      }
61  
62  }