1 /*
2 * Scope: a generic MVC framework.
3 * Copyright (c) 2000-2002, The Scope team
4 * All rights reserved.
5 *
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * Neither the name "Scope" nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 *
36 * $Id: BasicBeanInfo.java,v 1.2 2002/09/05 15:41:46 ludovicc Exp $
37 */
38 package org.scopemvc.view.swing.beaninfo;
39
40 import java.awt.Image;
41 import java.beans.*;
42
43 /***
44 * Description of the Class
45 *
46 * @author lclaude
47 * @created May 28, 2002
48 */
49 public class BasicBeanInfo extends SimpleBeanInfo {
50
51 /***
52 * Description of the Field
53 */
54 protected Class beanClass;
55
56 Image iconColor16x16;
57 Image iconColor32x32;
58 Image iconMono16x16;
59 Image iconMono32x32;
60
61 /***
62 * Constructor for the BasicBeanInfo object
63 *
64 * @param beanClass TODO: Describe the Parameter
65 */
66 public BasicBeanInfo(Class beanClass) {
67 this.beanClass = beanClass;
68 }
69
70 /***
71 * Gets the icon
72 *
73 * @param iconKind Description of the Parameter
74 * @return The icon value
75 */
76 public Image getIcon(int iconKind) {
77 Image icon = null;
78 switch (iconKind) {
79 case ICON_COLOR_16x16:
80 icon = iconColor16x16;
81 break;
82 case ICON_COLOR_32x32:
83 icon = iconColor32x32;
84 break;
85 case ICON_MONO_16x16:
86 icon = iconMono16x16;
87 break;
88 case ICON_MONO_32x32:
89 icon = iconMono32x32;
90 break;
91 }
92 if (icon == null && beanClass != null) {
93 String resource = getDefaultIconResource(iconKind);
94 System.out.println("Resource" + resource);
95 icon = loadImage(resource);
96 if (icon != null) {
97 switch (iconKind) {
98 case ICON_COLOR_16x16:
99 iconColor16x16 = icon;
100 break;
101 case ICON_COLOR_32x32:
102 iconColor32x32 = icon;
103 break;
104 case ICON_MONO_16x16:
105 iconMono16x16 = icon;
106 break;
107 case ICON_MONO_32x32:
108 iconMono32x32 = icon;
109 break;
110 }
111 }
112 }
113 return icon;
114 }
115
116 /***
117 * Gets the default icon resource
118 *
119 * @param iconKind Description of the Parameter
120 * @return The defaultIconResource value
121 */
122 protected String getDefaultIconResource(int iconKind) {
123 String resource = "beaninfo/images/".concat(String.valueOf(beanClass.getName().substring(beanClass.getName().lastIndexOf('.') + 1)));
124 switch (iconKind) {
125 case ICON_COLOR_16x16:
126 resource = String.valueOf(resource).concat("Color16");
127 break;
128 case ICON_COLOR_32x32:
129 resource = String.valueOf(resource).concat("Color32");
130 break;
131 case ICON_MONO_16x16:
132 resource = String.valueOf(resource).concat("Mono16");
133 break;
134 case ICON_MONO_32x32:
135 resource = String.valueOf(resource).concat("Mono32");
136 break;
137 }
138 return String.valueOf(resource).concat(".gif");
139 }
140
141 }
This page was automatically generated by Maven