home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 6.4 KB | 192 lines |
- package symantec.itools.awt.shape;
-
- import java.beans.*;
- import symantec.itools.beans.*;
- import java.util.ResourceBundle;
-
- // 07/31/97 LAB Created and checked in.
- // 09/07/97 LAB Removed background and font as properties (Addresses Mac Bug #7698).
-
- /**
- * BeanInfo for Line.
- *
- */
-
- public class LineBeanInfo extends SimpleBeanInfo {
-
- /**
- * Constructs a LineBeanInfo object.
- */
- public LineBeanInfo() {
- }
-
- /**
- * Gets a BeanInfo for the superclass of this bean.
- * @return BeanInfo[] containing this bean's superclass BeanInfo
- */
- public BeanInfo[] getAdditionalBeanInfo() {
- try {
- BeanInfo[] bi = new BeanInfo[1];
- bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
- return bi;
- }
- catch (IntrospectionException e) { throw new Error(e.toString());}
- }
-
- /**
- * Gets the SymantecBeanDescriptor for this bean.
- * @return an object of type SymantecBeanDescriptor
- * @see symantec.itools.beans.SymantecBeanDescriptor
- */
- public BeanDescriptor getBeanDescriptor() {
- ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
- String s=group.getString("GroupShape");
-
- SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
- bd.setFolder(s);
- bd.setToolbar(s);
-
- return (BeanDescriptor) bd;
- }
-
- /**
- * Gets an image that may be used to visually represent this bean
- * (in the toolbar, on a form, etc).
- * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
- * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
- * @return an image for this bean, always color even if requested monochrome
- * @see BeanInfo#ICON_MONO_16x16
- * @see BeanInfo#ICON_COLOR_16x16
- * @see BeanInfo#ICON_MONO_32x32
- * @see BeanInfo#ICON_COLOR_32x32
- */
- public java.awt.Image getIcon(int iconKind) {
- if (iconKind == BeanInfo.ICON_MONO_16x16 ||
- iconKind == BeanInfo.ICON_COLOR_16x16) {
- java.awt.Image img = loadImage("LineC16.gif");
- return img;
- }
-
- if (iconKind == BeanInfo.ICON_MONO_32x32 ||
- iconKind == BeanInfo.ICON_COLOR_32x32) {
- java.awt.Image img = loadImage("LineC32.gif");
- return img;
- }
-
- return null;
- }
-
- /**
- * Gets an array of descriptions of the methods used for "connections" by
- * Visual CafΘ's Interaction Wizard.
- * Included in each method description is a CONNECTIONS ConnectionDescriptor.
- * @return method descriptions for this bean
- * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
- */
- public MethodDescriptor[] getMethodDescriptors() {
- Class[] args;
- ConnectionDescriptor connection;
- java.util.Vector connections;
- java.util.Vector md = new java.util.Vector();
- ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
-
- try{
- args = new Class[1];
- args[0] = java.lang.Boolean.TYPE ;
- MethodDescriptor setPositiveSlope = new MethodDescriptor(beanClass.getMethod("setPositiveSlope", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "boolean", "",
- "%name%.setPositiveSlope(%arg%);",
- conn.getString("setPositiveSlope"));
- connections.addElement(connection);
-
- setPositiveSlope.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setPositiveSlope);
- } catch (Exception e) { throw new Error("setPositiveSlope:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor isPositiveSlope = new MethodDescriptor(beanClass.getMethod("isPositiveSlope", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "boolean", "",
- "%name%.isPositiveSlope()",
- conn.getString("isPositiveSlope"));
- connections.addElement(connection);
-
- isPositiveSlope.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(isPositiveSlope);
- } catch (Exception e) { throw new Error("isPositiveSlope:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE ;
- MethodDescriptor setLineThickness = new MethodDescriptor(beanClass.getMethod("setLineThickness", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setLineThickness(%arg%);",
- conn.getString("setLineThickness"));
- connections.addElement(connection);
-
- setLineThickness.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setLineThickness);
- } catch (Exception e) { throw new Error("setLineThickness:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getLineThickness = new MethodDescriptor(beanClass.getMethod("getLineThickness", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "int", "",
- "%name%.getLineThickness()",
- conn.getString("getLineThickness"));
- connections.addElement(connection);
-
- getLineThickness.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getLineThickness);
- } catch (Exception e) { throw new Error("getLineThickness:: " + e.toString()); }
-
- MethodDescriptor[] rv = new MethodDescriptor[md.size()];
- md.copyInto(rv);
-
- return rv;
- }
-
- /**
- * Returns descriptions of this bean's properties.
- */
- public PropertyDescriptor[] getPropertyDescriptors() {
- ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
-
- try{
- PropertyDescriptor positiveSlope = new PropertyDescriptor("positiveSlope", beanClass);
- positiveSlope.setBound(true);
- positiveSlope.setConstrained(true);
- positiveSlope.setDisplayName(prop.getString("positiveSlope"));
-
- PropertyDescriptor lineThickness = new PropertyDescriptor("lineThickness", beanClass);
- lineThickness.setBound(true);
- lineThickness.setConstrained(true);
- lineThickness.setDisplayName(prop.getString("lineThickness"));
-
- PropertyDescriptor background = new PropertyDescriptor("background", beanClass);
- background.setHidden(true);
-
- PropertyDescriptor font = new PropertyDescriptor("font", beanClass);
- font.setHidden(true);
-
- PropertyDescriptor[] rv = {
- positiveSlope,
- lineThickness,
- background,
- font};
-
- return rv;
- } catch (IntrospectionException e) { throw new Error(e.toString()); }
- }
-
- private final static Class beanClass = Line.class;
-
- } // end of class LineBeanInfo