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 {@code 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 {@code 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 {@code 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<T> extends JComboBox<T> implements AppearanceControl
17 * {
18 * public boolean isFont()
19 * {
20 * return true;
21 * }
22 * }
23 *
24 * JComboBox<String> comboBox = new AppearanceControlComboBox<>();
25 * </pre>
26 * <p>
27 * Copyright (c) 2013-2024 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 <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
31 * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
32 * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
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 }