home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 8.9 KB | 254 lines |
- package symantec.itools.multimedia;
-
- import java.beans.*;
- import symantec.itools.beans.*;
- import java.util.ResourceBundle;
-
- // 08/04/97 LAB Removed Centered property. Removed setCentered and getCentered connections.
- // Added Style property. Added setStyle, getStyle and Style constants as connections.
- // 09/11/97 LAB Changed URL property and connections to ImageURL (Addresses Mac Bug #7689).
- // 09/19/97 RKM Fixed bug in Normal style connection
- // Hid the font, foreground, and background properties - they did nothing
-
- /**
- * BeanInfo for ImageViewer.
- *
- */
-
- public class ImageViewerBeanInfo extends SimpleBeanInfo {
-
- /**
- * Constructs a ImageViewerBeanInfo object.
- */
- public ImageViewerBeanInfo() {
- }
-
- /**
- * 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("GroupMultimedia");
-
- SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
- bd.setFolder(s);
- bd.setToolbar(s);
- bd.setWinHelp("0x123CA");
-
- ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.IMAGE_TILED",
- conn.getString("IMAGE_TILED")));
-
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.IMAGE_CENTERED",
- conn.getString("IMAGE_CENTERED")));
-
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.IMAGE_SCALED_TO_FIT",
- conn.getString("IMAGE_SCALED_TO_FIT")));
-
- bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
- "%name%.IMAGE_NORMAL",
- conn.getString("IMAGE_NORMAL")));
-
- 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("ImageViewerC16.gif");
- return img;
- }
-
- if (iconKind == BeanInfo.ICON_MONO_32x32 ||
- iconKind == BeanInfo.ICON_COLOR_32x32) {
- java.awt.Image img = loadImage("ImageViewerC32.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.String.class ;
- MethodDescriptor setFileName = new MethodDescriptor(beanClass.getMethod("setFileName", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "String", "",
- "%name%.setFileName(%arg%);",
- conn.getString("setFileName"));
- connections.addElement(connection);
-
- setFileName.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setFileName);
- } catch (Exception e) { throw new Error("setFileName:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getImageURL = new MethodDescriptor(beanClass.getMethod("getImageURL", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "URL", "",
- "%name%.getImageURL()",
- conn.getString("getImageURLIV"));
- connections.addElement(connection);
-
- getImageURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getImageURL);
- } catch (Exception e) { throw new Error("getImageURL:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.net.URL.class ;
- MethodDescriptor setImageURL = new MethodDescriptor(beanClass.getMethod("setImageURL", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "RelativeURL", "",
- "%name%.setURL(symantec.itools.net.RelativeURL.getURL(%arg%));",
- conn.getString("setURLIV"));
- connections.addElement(connection);
-
- connection = new ConnectionDescriptor("input", "URL", "",
- "%name%.setImageURL(%arg%);",
- conn.getString("setImageURLIV"));
- connections.addElement(connection);
-
- setImageURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setImageURL);
- } catch (Exception e) { throw new Error("setImageURL:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getFileName = new MethodDescriptor(beanClass.getMethod("getFileName", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "String", "",
- "%name%.getFileName()",
- conn.getString("getFileName"));
- connections.addElement(connection);
-
- getFileName.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getFileName);
- } catch (Exception e) { throw new Error("getFileName:: " + e.toString()); }
-
- try{
- args = new Class[1];
- args[0] = java.lang.Integer.TYPE;
- MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setStyle", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("input", "int", "",
- "%name%.setStyle(%arg%);",
- conn.getString("setStyleIV"));
- connections.addElement(connection);
-
- setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(setStyle);
- } catch (Exception e) { throw new Error("setStyle:: " + e.toString()); }
-
- try{
- args = null;
- MethodDescriptor getStyle = new MethodDescriptor(beanClass.getMethod("getStyle", args));
-
- connections = new java.util.Vector();
- connection = new ConnectionDescriptor("output", "String", "",
- "%name%.getStyle()",
- conn.getString("getStyleIV"));
- connections.addElement(connection);
-
- getStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
- md.addElement(getStyle);
- } catch (Exception e) { throw new Error("getStyle:: " + 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 style = new PropertyDescriptor("style", beanClass);
- style.setBound(true);
- style.setConstrained(true);
- style.setDisplayName(prop.getString("imageStyle"));
- style.setValue("ENUMERATION", "IMAGE_TILED=0, IMAGE_CENTERED=1, IMAGE_SCALED_TO_FIT=2, IMAGE_NORMAL=3");
-
- PropertyDescriptor imageURL = new PropertyDescriptor("imageURL", beanClass);
- imageURL.setBound(true);
- imageURL.setConstrained(true);
- imageURL.setDisplayName(prop.getString("imageURL"));
- imageURL.setValue("URLFILTER", prop.getString("imageURLFILTER"));
-
- //Hide the font, background, and foreground properties
- PropertyDescriptor font = new PropertyDescriptor("font", beanClass);
- font.setHidden(true);
-
- PropertyDescriptor background = new PropertyDescriptor("background", beanClass);
- background.setHidden(true);
-
- PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass);
- foreground.setHidden(true);
-
- PropertyDescriptor[] rv = {
- style,
- imageURL,
- font,
- background,
- foreground
- };
- return rv;
- } catch (IntrospectionException e) { throw new Error(e.toString()); }
- }
-
- private final static Class beanClass = ImageViewer.class;
-
- } // end of class ImageViewerBeanInfo