Skip to content

Package: IconProvider$1

IconProvider$1

nameinstructionbranchcomplexitylinemethod
getIcon(int)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
{...}
M: 14 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: * TheseFoolishThings: Miscellaneous utilities
5: * http://tidalwave.it/projects/thesefoolishthings
6: *
7: * Copyright (C) 2009 - 2024 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
12: * the License. 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
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/thesefoolishthings-src
23: * git clone https://github.com/tidalwave-it/thesefoolishthings-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.role.ui;
28:
29: import javax.annotation.Nonnegative;
30: import javax.annotation.Nonnull;
31: import java.awt.image.BufferedImage;
32: import javax.swing.Icon;
33: import javax.swing.ImageIcon;
34:
35: /***********************************************************************************************************************
36: *
37: * The role of an object that can provide an icon for rendering.
38: *
39: * @stereotype Role
40: *
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: *
52: * A default {@code IconProvider} with an empty icon.
53: *
54: ******************************************************************************************************************/
55: public static final IconProvider DEFAULT = new IconProvider()
56: {
57: private final Icon EMPTY_ICON = new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_4BYTE_ABGR));
58:
59: @Override @Nonnull
60: public Icon getIcon (@Nonnegative final int size)
61: {
62: return EMPTY_ICON;
63: }
64: };
65:
66: /*******************************************************************************************************************
67: *
68: * Returns the icon for this object. Note that the {@code size} parameter is just a hint to allow implementations
69: * to pick the correctly sized icon in an optimized fashion. In particular, implementations should try to do their
70: * best for providing an icon whose size is equal or greater than the requested one, but this is not guaranteed.
71: * It's up to the client code to eventually resize the returned icon for its purposes.
72: *
73: * @param requestedSize the requested icon size
74: * @return the icon
75: *
76: ******************************************************************************************************************/
77: @Nonnull
78: public Icon getIcon (@Nonnegative int requestedSize);
79: }