View Javadoc

1   /* -------------------------------------------------------------------
2    * Java source file for the class StandingWaveBeanInfo
3    * 
4    * Copyright (c), 2004, Masahiro Takatsuka
5    * All Rights Researved.
6    * 
7    * Original Author: Masahiro Takatsuka
8    * $Author: takatsukam $
9    * 
10   * $Date: 2004/11/23 21:46:47 $
11   * 
12   * $Id: StandingWaveBeanInfo.java,v 1.1 2004/11/23 21:46:47 takatsukam Exp $
13   * 
14   * Reference:		Document no:
15   * ___				___
16   * 
17   * To Do:
18   * ___
19   * 
20  ------------------------------------------------------------------- */
21  
22  /* --------------------------- Package ---------------------------- */
23  package net.jbeans.physics.model.standingwave;
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 StandingWaveBeanInfo             
36  ====================================================================*/
37  /***
38   * generally describe StandingWaveBeanInfo in here
39   * 
40   * @version $Revision: 1.1 $
41   * @author Masahiro Takatsuka (masa@takatsuka.org)
42   * @see JBeanBeanInfo
43   */
44  
45  public class StandingWaveBeanInfo extends JBeansBeanInfo {
46      private final static Class beanClass = StandingWave.class;
47  
48      private static String iconColor16x16Filename = "resources/StandingWave/IconColor16.gif";
49      private static String iconColor32x32Filename = "resources/StandingWave/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 StandingWave 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 component that creates a standing wave of a thing drum surface."
90          });
91          bd.setValue("helpSetName", "net/jbeans/physics/model/standingwave/resources/StandingWave/jhelpset.hs");
92  		return bd;
93      }
94  
95  	/***
96  	 * Returns PropertyDescriptors associated with a StandingWave bean.
97  	 * <PRE>
98  	 * </PRE>
99  	 * 
100 	 * @return PropertyDescriptor[]
101 	 */
102   	public PropertyDescriptor[] getPropertyDescriptors() {
103 		return (new PropertyDescriptor[] {
104 			createPropertyDescriptor("x", new Object[] {
105 				"bound", Boolean.TRUE, "preferred", Boolean.TRUE, "visualUpdate", Boolean.TRUE, "shortDescription", "Set the size of data along the X axis."}),
106 			createPropertyDescriptor("y", new Object[] {
107 				"bound", Boolean.TRUE, "preferred", Boolean.TRUE, "visualUpdate", Boolean.TRUE, "shortDescription", "Set the size of data along the Y axis."})
108 		});
109   	}
110 
111 	/***
112 	 * Returns EventSetDescriptors associated with a StandingWave bean.
113 	 * <PRE>
114 	 * </PRE>
115 	 * 
116 	 * @return EventSetDescriptor[]
117 	 */
118 	public EventSetDescriptor[] getEventSetDescriptors() {
119 		try {
120   			String[] methodname = {"stateChanged"};
121 			EventSetDescriptor modelChange = new EventSetDescriptor(
122 									StandingWave.class, // sourceClass
123 									"Wave", // eventSetName
124 									ChangeListener.class, 
125 									methodname, // listenerMethodNames
126 									"addSurfaceListener",
127 									"removeSurfaceListener");
128 			EventSetDescriptor dimChange = new EventSetDescriptor(
129 									StandingWave.class, // sourceClass
130 									"Dimension", // eventSetName
131 									ChangeListener.class, 
132 									methodname, // listenerMethodNames
133 									"addSurfaceDimensionListener",
134 									"removeSurfaceDimensionListener");
135 			EventSetDescriptor[] rv = {modelChange, dimChange};
136 			return rv;
137 		} catch (IntrospectionException ie) {
138 			ie.printStackTrace();
139 			return null;
140     	}
141 	}
142 }