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-2024 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://github.com/wjschakel">Wouter Schakel</a>
31   */
32  public interface AppearanceControl extends nl.tudelft.simulation.dsol.swing.gui.appearance.AppearanceControl
33  {
34  
35      /** Default font size. */
36      public static int DEFAULT_FONT_SIZE = 12;
37  
38      /**
39       * Returns the font size. May be {@code null} to ignore font size.
40       * @return Integer; font size, may be {@code null} to ignore font size from appearance.
41       */
42      default Integer getFontSize()
43      {
44          return DEFAULT_FONT_SIZE;
45      }
46  
47  }