View Javadoc
1   package org.opentrafficsim.swing.gui;
2   
3   import java.util.OptionalInt;
4   
5   /**
6    * This interface allows on screen items to <b>not</b> obtain colors and/or the font from an {@link Appearance}. This can be
7    * useful for items where considering only a background and a foreground color is not sufficient, possibly creating unreadable
8    * or otherwise unpleasant on screen items.<br>
9    * <br>
10   * The default implementation of the methods in this interface return {@code false}, meaning the {@link Appearance} is
11   * completely ignored. In order to ignore it only partially, some methods should be overridden to return true. An example of
12   * this is given below, which will only allow the font of the {@link Appearance}. It also shows a convenient way to implement
13   * this interface when using default on screen items using a local class.
14   *
15   * <pre>
16   * class AppearanceControlComboBox&lt;T&gt; extends JComboBox&lt;T&gt; implements AppearanceControl
17   * {
18   *     public boolean isFont()
19   *     {
20   *         return true;
21   *     }
22   * }
23   *
24   * JComboBox&lt;String&gt; comboBox = new AppearanceControlComboBox&lt;&gt;();
25   * </pre>
26   * <p>
27   * Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
28   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
29   * </p>
30   * @author Alexander Verbraeck
31   * @author Peter Knoppers
32   * @author Wouter Schakel
33   */
34  public interface AppearanceControl extends nl.tudelft.simulation.dsol.swing.gui.appearance.AppearanceControl
35  {
36  
37      /** Default font size. */
38      OptionalInt DEFAULT_FONT_SIZE = OptionalInt.of(12);
39  
40      /**
41       * Returns the font size. May be {@code null} to ignore font size.
42       * @return font size, may be empty to ignore font size from appearance
43       */
44      default OptionalInt getFontSize()
45      {
46          return DEFAULT_FONT_SIZE;
47      }
48  
49  }