View Javadoc

1   /* -------------------------------------------------------------------
2    * Java source file for the class GlyphModelerBeanInfo
3    * 
4    * Copyright (c), 2003, Masahiro Takatsuka.
5    * All Rights Researved.
6    * 
7    * Original Author: Masahiro Takatsuka (masa@jbeans.net)
8    * $Author: takatsukam $
9    * 
10   * $Date: 2004/03/03 11:53:06 $
11   * 
12   * $Id: GlyphModelerBeanInfo.java,v 1.3 2004/03/03 11:53:06 takatsukam Exp $
13   * 
14   * Reference:		Document no:
15   * ___				___
16   * 
17   * To Do:
18   * ___
19   * 
20  ------------------------------------------------------------------- */
21  
22  /* --------------------------- Package ---------------------------- */
23  package net.jbeans.j3d.modeler.scene;
24  
25  /* ------------------ Import classes (packages) ------------------- *//package-summary/html">class="comment"> ------------------ Import classes (packages) ------------------- *//package-summary.html">class="comment">/* ------------------ Import classes (packages) ------------------- *//package-summary.html">class="comment"> ------------------ Import classes (packages) ------------------- */
26  import java.awt.*;
27  import java.awt.event.*;
28  import java.beans.*;
29  
30  import javax.media.j3d.*;
31  
32  import net.jbeans.bean.*;
33  import net.jbeans.j3d.event.*;
34  
35  /*====================================================================
36               Implementation of class GlyphModelerBeanInfo             
37  ====================================================================*/
38  /***
39   * generally describe GlyphModelerBeanInfo in here
40   * 
41   * @version $Revision: 1.3 $
42   * @author Masahiro Takatsuka (masa@jbeans.net)
43   * @see JBeansBeanInfo
44   */
45  
46  public class GlyphModelerBeanInfo extends JBeansBeanInfo {
47      private final static Class beanClass = GlyphModeler.class;
48  
49      private static String iconColor16x16Filename = "resources/GlyphModeler/IconColor16.gif";
50      private static String iconColor32x32Filename = "resources/GlyphModeler/IconColor32.gif";
51      private static String iconMono16x16Filename;
52      private static String iconMono32x32Filename;
53      
54      /***
55  	* Returns a icons of the specified size.
56  	* <PRE>
57  	* </PRE>
58  	* 
59  	* @param iconKind an ID (ICON_COLOR_16x16 or ICON_COLOR_32x32)
60  	* indicating the size of the icon.
61  	* @return Image
62  	*/
63      public Image getIcon(int iconKind) {
64  		switch (iconKind) {
65  		case BeanInfo.ICON_COLOR_16x16:
66  			return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null;
67  		case BeanInfo.ICON_COLOR_32x32:
68  			return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null;
69  		case BeanInfo.ICON_MONO_16x16:
70  			return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null;
71  		case BeanInfo.ICON_MONO_32x32:
72  			return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null;
73  		}
74  		return null;
75      }
76  	
77      protected PropertyDescriptor createPropertyDescriptor(String s, Object aobj[]) {
78          return super.createPropertyDescriptor(beanClass, s, aobj);
79      }
80  
81      /***
82       * Returns a BeanDescriptor for Glyphmodeler bean.
83       * <PRE>
84       * </PRE>
85       * 
86       * @return BeanDescriptor
87       */
88      public BeanDescriptor getBeanDescriptor() {
89  		BeanDescriptor bd = createBeanDescriptor(beanClass, new Object[] {
90              "preferred", Boolean.TRUE, "isContainer", Boolean.FALSE, "shortDescription", "A component that creates 3D model."
91          });
92  		bd.setValue("hidden-state", Boolean.TRUE);
93          bd.setValue("helpSetName", "net/jbeans/j3d/modeler/scene/resources/GlyphModeler/jhelpset.hs");
94  		return bd;
95      }	
96  
97      /***
98  	 * Returns PropertyDescriptors associated with a DEM bean.
99  	 * <PRE>
100 	 * </PRE>
101 	 * 
102 	 * @return PropertyDescriptor[]
103 	 */
104     public PropertyDescriptor[] getPropertyDescriptors() {
105   		Object aobj[] = {
106 			"FASTEST", new Integer(TransparencyAttributes.FASTEST), "TransparencyAttributes.FASTEST",
107 			"NICEST", new Integer(TransparencyAttributes.NICEST), "TransparencyAttributes.NICEST",
108 			"BLENDED", new Integer(TransparencyAttributes.BLENDED), "TransparencyAttributes.BLENDED",
109 			"SCREEN_DOOR", new Integer(TransparencyAttributes.SCREEN_DOOR), "TransparencyAttributes.SCREEN_DOOR",
110 			"NONE", new Integer(TransparencyAttributes.NONE), "TransparencyAttributes.NONE"
111   		};
112   		Object bobj[] = {
113 			"FASTEST", new Integer(ColoringAttributes.FASTEST), "ColoringAttributes.FASTEST",
114 			"NICEST", new Integer(ColoringAttributes.NICEST), "ColoringAttributes.NICEST",
115 			"SHADE_FLAT", new Integer(ColoringAttributes.SHADE_FLAT), "ColoringAttributes.SHADE_FLAT",
116 			"SHADE_GOURAUD", new Integer(ColoringAttributes.SHADE_GOURAUD), "ColoringAttributes.SHADE_GOURAUD"
117   		};
118 
119   		return (new PropertyDescriptor[] {
120   			createPropertyDescriptor("defaultColor", new Object[] {
121   				"bound", Boolean.TRUE, "preferred", Boolean.TRUE, "visualUpdate", Boolean.TRUE, "shortDescription", "Set the default color."}),
122   			createPropertyDescriptor("defaultScale", new Object[] {
123   				"bound", Boolean.TRUE, "preferred", Boolean.TRUE, "visualUpdate", Boolean.TRUE, "shortDescription", "Set the default scale."}),
124   			createPropertyDescriptor("transparencyMode", new Object[] {
125   				"bound", Boolean.TRUE, "enumerationValues", aobj, "preferred", Boolean.TRUE, "visualUpdate", Boolean.TRUE, "shortDescription", "Set the mode of transparency."}),
126   			createPropertyDescriptor("shadeModel", new Object[] {
127   				"bound", Boolean.TRUE, "enumerationValues", bobj, "preferred", Boolean.TRUE, "visualUpdate", Boolean.TRUE, "shortDescription", "Set the shading model."}),
128   			createPropertyDescriptor("lightingEnable", new Object[] {
129   				"bound", Boolean.TRUE, "preferred", Boolean.TRUE, "visualUpdate", Boolean.TRUE, "shortDescription", "Turn on/off the lighting."})
130   		});
131     }
132 
133     /***
134 	 * Returns EventSetDescriptors associated with a GlyphModeler bean.
135 	 * <PRE>
136 	 * </PRE>
137 	 * 
138 	 * @return EventSetDescriptor[]
139 	 */
140     public EventSetDescriptor[] getEventSetDescriptors() {
141 		try {
142 			String[] gc = {"objectCreated"};
143 			EventSetDescriptor sceneCreated = new EventSetDescriptor(
144 								    SceneModeler.class, // sourceClass
145 								    "Scene", // eventSetName
146 								    SceneGraphObjectListener.class, 
147 								    gc, // listenerMethodNames
148 								    "addSceneListener",
149 								    "removeSceneListener");
150 			EventSetDescriptor[] rv = {sceneCreated};
151 			return rv;
152 		} catch (IntrospectionException ie) {
153 			ie.printStackTrace();
154 			return null;
155 		}
156     }
157 }