Skip to content

Package: IconProvider

IconProvider

nameinstructionbranchcomplexitylinemethod
static {...}
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * SteelBlue: DCI User Interfaces
5: * http://tidalwave.it/projects/steelblue
6: *
7: * Copyright (C) 2015 - 2025 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/steelblue-src
22: * git clone https://github.com/tidalwave-it/steelblue-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.ui.core.role;
27:
28: import javax.annotation.Nonnegative;
29: import jakarta.annotation.Nonnull;
30: import java.awt.image.BufferedImage;
31: import javax.swing.Icon;
32: import javax.swing.ImageIcon;
33:
34: /***************************************************************************************************************************************************************
35: *
36: * The role of an object that can provide an icon for rendering.
37: *
38: * @stereotype Role
39: *
40: * @since 2.0-ALPHA-1
41: * @author Fabrizio Giudici
42: * @it.tidalwave.javadoc.draft
43: *
44: **************************************************************************************************************************************************************/
45: @FunctionalInterface
46: public interface IconProvider
47: {
48: public static final Class<IconProvider> _IconProvider_ = IconProvider.class;
49:
50: /***********************************************************************************************************************************************************
51: * A default {@code IconProvider} with an empty icon.
52: **********************************************************************************************************************************************************/
53: public static final IconProvider DEFAULT = new IconProvider()
54: {
55: private final Icon EMPTY_ICON = new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_4BYTE_ABGR));
56:
57: @Override @Nonnull
58: public Icon getIcon (@Nonnegative final int size)
59: {
60: return EMPTY_ICON;
61: }
62: };
63:
64: /***********************************************************************************************************************************************************
65: * Returns the icon for this object. Note that the {@code size} parameter is just a hint to allow implementations
66: * to pick the correctly sized icon in an optimized fashion. In particular, implementations should try to do their
67: * best for providing an icon whose size is equal or greater than the requested one, but this is not guaranteed.
68: * It's up to the client code to eventually resize the returned icon for its purposes.
69: *
70: * @param requestedSize the requested icon size
71: * @return the icon
72: **********************************************************************************************************************************************************/
73: @Nonnull
74: public Icon getIcon (@Nonnegative int requestedSize);
75: }