View Javadoc

1   /* -------------------------------------------------------------------
2    * Java source file for the class Shape3DBeanInfo
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: Shape3DBeanInfo.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.scenegraph;
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  import javax.swing.event.*;
30  
31  import net.jbeans.bean.*;
32  import net.jbeans.j3d.event.*;
33  
34  /*====================================================================
35                 Implementation of class Shape3DBeanInfo                
36  ====================================================================*/
37  /***
38   * generally describe Shape3DBeanInfo in here
39   * 
40   * @version $Revision: 1.3 $
41   * @author Masahiro Takatsuka (masa@jbeans.net)
42   * @see JBeansBeanInfo
43   */
44  
45  public final class Shape3DBeanInfo extends JBeansBeanInfo {
46      private final static Class beanClass = Shape3D.class;
47  	
48  	private static String iconColor16x16Filename = "resources/Shape3D/IconColor16.gif";
49  	private static String iconColor32x32Filename = "resources/Shape3D/IconColor32.gif";
50  	private static String iconMono16x16Filename;
51  	private static String iconMono32x32Filename;
52  	
53  	/***
54  	* Returns a icons of the specified size.
55  	* <PRE>
56  	* </PRE>
57  	* 
58  	* @param iconKind an ID (ICON_COLOR_16x16 or ICON_COLOR_32x32)
59  	* indicating the size of the icon.
60  	* @return Image
61  	*/
62  	public Image getIcon(int iconKind) {
63  		switch (iconKind) {
64  			case BeanInfo.ICON_COLOR_16x16:
65  			  return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null;
66  			case BeanInfo.ICON_COLOR_32x32:
67  			  return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null;
68  			case BeanInfo.ICON_MONO_16x16:
69  			  return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null;
70  			case BeanInfo.ICON_MONO_32x32:
71  			  return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null;
72  		}
73  		return null;
74  	}
75  
76      protected PropertyDescriptor createPropertyDescriptor(String s, Object aobj[]) {
77          return super.createPropertyDescriptor(beanClass, s, aobj);
78      }
79  
80  	/***
81  	* Returns a BeanDescriptor for Shape3D bean.
82  	* <PRE>
83  	* </PRE>
84  	* 
85  	* @return BeanDescriptor
86  	*/
87      public BeanDescriptor getBeanDescriptor() {
88          BeanDescriptor bd = createBeanDescriptor(beanClass, new Object[] {
89              "preferred", Boolean.TRUE, "isContainer", Boolean.FALSE, "shortDescription", "A shape3d component."
90          });
91  		//bd.setValue("hidden-state", Boolean.TRUE);
92          bd.setValue("helpSetName", "net/jbeans/j3d/scenegraph/resources/Shape3D/jhelpset.hs");
93  		return bd;
94      }
95  	
96  	/***
97  	 * Returns PropertyDescriptors associated with a Shape3D bean.
98  	 * <PRE>
99  	 * </PRE>
100 	 * 
101 	 * @return PropertyDescriptor[]
102 	 */
103    	public PropertyDescriptor[] getPropertyDescriptors() {
104   		return (new PropertyDescriptor[] {});
105   	}
106 
107 	/***
108 	 * Returns EventSetDescriptors associated with a Shape3D bean.
109 	 * <PRE>
110 	 * </PRE>
111 	 * 
112 	 * @return EventSetDescriptor[]
113 	 */
114   	public EventSetDescriptor[] getEventSetDescriptors() {
115 		try {
116   			String[] lmnames = {"objectChanged"};
117 			EventSetDescriptor objectChanged = new EventSetDescriptor(
118 									beanClass, // sourceClass
119 									"SceneGraphObject", // eventSetName
120 									SceneGraphObjectListener.class, 
121 									lmnames, // listenerMethodNames
122 									"addSceneGraphObjectListener",
123 									"removeSceneGraphObjectListener");
124 			EventSetDescriptor[] rv = {objectChanged};
125 			return rv;
126 		} catch (IntrospectionException ie) {
127 			ie.printStackTrace();
128 			return null;
129 		}
130   	}
131 }