home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1999 February / CDW0299.iso / Demos / Cafe / Source.bin / AnimatorBeanInfo.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  11.2 KB  |  320 lines

  1. package symantec.itools.multimedia;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  08/30/97    LAB    Removed extraneous semicolon in getImageList interacion (Addresses Mac Bug #7672).
  8.  
  9. /**
  10.  * BeanInfo for Animator.
  11.  *
  12.  */
  13.  
  14. public class AnimatorBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a AnimatorBeanInfo object.
  18.      */
  19.     public AnimatorBeanInfo() {
  20.     }
  21.  
  22.     /**
  23.      * Gets a BeanInfo for the superclass of this bean.
  24.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  25.      */
  26.     public BeanInfo[] getAdditionalBeanInfo() {
  27.         try {
  28.             BeanInfo[] bi = new BeanInfo[1];
  29.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  30.             return bi;
  31.         }
  32.         catch (IntrospectionException e) { throw new Error(e.toString());}
  33.     }
  34.  
  35.     /**
  36.      * Gets the SymantecBeanDescriptor for this bean.
  37.      * @return an object of type SymantecBeanDescriptor
  38.      * @see symantec.itools.beans.SymantecBeanDescriptor
  39.      */
  40.     public BeanDescriptor getBeanDescriptor() {
  41.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  42.         String s=group.getString("GroupMultimedia"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setFolder(s);
  46.         bd.setToolbar(s);
  47.         bd.setWinHelp("0x1239D");
  48.  
  49.         return (BeanDescriptor) bd;
  50.     }
  51.  
  52.     /**
  53.      * Gets an image that may be used to visually represent this bean
  54.      * (in the toolbar, on a form, etc).
  55.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  56.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  57.      * @return an image for this bean, always color even if requested monochrome
  58.      * @see BeanInfo#ICON_MONO_16x16
  59.      * @see BeanInfo#ICON_COLOR_16x16
  60.      * @see BeanInfo#ICON_MONO_32x32
  61.      * @see BeanInfo#ICON_COLOR_32x32
  62.      */
  63.     public java.awt.Image getIcon(int iconKind) {
  64.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  65.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  66.             java.awt.Image img = loadImage("AnimatorC16.gif");
  67.             return img;
  68.         }
  69.  
  70.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  71.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  72.             java.awt.Image img = loadImage("AnimatorC32.gif");
  73.             return img;
  74.         }
  75.  
  76.         return null;
  77.     }
  78.  
  79.     /**
  80.      * Gets an array of descriptions of the methods used for "connections" by
  81.      * Visual CafΘ's Interaction Wizard.
  82.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  83.      * @return method descriptions for this bean
  84.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  85.      */
  86.     public MethodDescriptor[] getMethodDescriptors() {
  87.         Class[] args;
  88.         ConnectionDescriptor connection;
  89.         java.util.Vector connections;
  90.         java.util.Vector md = new java.util.Vector();
  91.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  92.  
  93.         try{
  94.             args = new Class[1];
  95.             args[0] = java.net.URL.class ;
  96.             MethodDescriptor addImage = new MethodDescriptor(beanClass.getMethod("addImage", args));
  97.  
  98.             connections = new java.util.Vector();
  99.             connection = new ConnectionDescriptor("input", "URL", "",
  100.                                     "%name%.addImage(%arg%);",
  101.                                     conn.getString("addImageURL"));
  102.             connections.addElement(connection);
  103.  
  104.             connection = new ConnectionDescriptor("input", "RelativeURL", "",
  105.                                     "%name%.addImage(symantec.itools.net.RelativeURL.getURL(%arg%));",
  106.                                     conn.getString("addImageName"));
  107.             connections.addElement(connection);
  108.  
  109.             addImage.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  110.             md.addElement(addImage);
  111.         } catch (Exception e) { throw new Error("addImage:: " + e.toString()); }
  112.  
  113.         try{
  114.             args = new Class[1];
  115.             args[0] = java.lang.Boolean.TYPE ;
  116.             MethodDescriptor setClearFrame = new MethodDescriptor(beanClass.getMethod("setClearFrame", args));
  117.  
  118.             connections = new java.util.Vector();
  119.             connection = new ConnectionDescriptor("input", "void", "",
  120.                                     "%name%.setClearFrame(true);",
  121.                                     conn.getString("setClearFrameTrue"));
  122.             connections.addElement(connection);
  123.  
  124.             connection = new ConnectionDescriptor("input", "void", "",
  125.                                     "%name%.setClearFrame(false);",
  126.                                     conn.getString("setClearFrameFalse"));
  127.             connections.addElement(connection);
  128.  
  129.             setClearFrame.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  130.             md.addElement(setClearFrame);
  131.         } catch (Exception e) { throw new Error("setClearFrame:: " + e.toString()); }
  132.  
  133.         try{
  134.             args = null;
  135.             MethodDescriptor getNumLoops = new MethodDescriptor(beanClass.getMethod("getNumLoops", args));
  136.  
  137.             connections = new java.util.Vector();
  138.             connection = new ConnectionDescriptor("output", "int", "",
  139.                                     "%name%.getNumLoops()",
  140.                                     conn.getString("getNumLoops"));
  141.             connections.addElement(connection);
  142.  
  143.             getNumLoops.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  144.             md.addElement(getNumLoops);
  145.         } catch (Exception e) { throw new Error("getNumLoops:: " + e.toString()); }
  146.  
  147.         try{
  148.             args = null;
  149.             MethodDescriptor startAnimation = new MethodDescriptor(beanClass.getMethod("startAnimation", args));
  150.  
  151.             connections = new java.util.Vector();
  152.             connection = new ConnectionDescriptor("input", "void", "",
  153.                                     "%name%.startAnimation();",
  154.                                     conn.getString("startAnimation"));
  155.             connections.addElement(connection);
  156.  
  157.             startAnimation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  158.             md.addElement(startAnimation);
  159.         } catch (Exception e) { throw new Error("startAnimation:: " + e.toString()); }
  160.  
  161.         try{
  162.             args = null;
  163.             MethodDescriptor stopAnimation = new MethodDescriptor(beanClass.getMethod("stopAnimation", args));
  164.  
  165.             connections = new java.util.Vector();
  166.             connection = new ConnectionDescriptor("input", "void", "",
  167.                                     "%name%.stopAnimation();",
  168.                                     conn.getString("stopAnimation"));
  169.             connections.addElement(connection);
  170.  
  171.             stopAnimation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  172.             md.addElement(stopAnimation);
  173.         } catch (Exception e) { throw new Error("stopAnimation:: " + e.toString()); }
  174.  
  175.         try{
  176.             args = new Class[1];
  177.             args[0] = java.lang.Integer.TYPE ;
  178.             MethodDescriptor setDelay = new MethodDescriptor(beanClass.getMethod("setDelay", args));
  179.  
  180.             connections = new java.util.Vector();
  181.             connection = new ConnectionDescriptor("input", "int", "",
  182.                                     "%name%.setDelay(%arg%);",
  183.                                     conn.getString("setDelay"));
  184.             connections.addElement(connection);
  185.  
  186.             setDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  187.             md.addElement(setDelay);
  188.         } catch (Exception e) { throw new Error("setDelay:: " + e.toString()); }
  189.  
  190.         try{
  191.             args = new Class[1];
  192.             args[0] = java.net.URL[].class ;
  193.             MethodDescriptor setImageList = new MethodDescriptor(beanClass.getMethod("setImageList", args));
  194.  
  195.             connections = new java.util.Vector();
  196.             connection = new ConnectionDescriptor("input", "URL[]", "",
  197.                                     "%name%.setImageList(%arg%);",
  198.                                     conn.getString("setImageList"));
  199.             connections.addElement(connection);
  200.  
  201.             setImageList.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  202.             md.addElement(setImageList);
  203.         } catch (Exception e) { throw new Error("setImageList:: " + e.toString()); }
  204.  
  205.         try{
  206.             args = new Class[1];
  207.             args[0] = java.lang.Integer.TYPE ;
  208.             MethodDescriptor setNumLoops = new MethodDescriptor(beanClass.getMethod("setNumLoops", args));
  209.  
  210.             connections = new java.util.Vector();
  211.             connection = new ConnectionDescriptor("input", "int", "",
  212.                                     "%name%.setNumLoops(%arg%);",
  213.                                     conn.getString("setNumLoops"));
  214.             connections.addElement(connection);
  215.  
  216.             setNumLoops.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  217.             md.addElement(setNumLoops);
  218.         } catch (Exception e) { throw new Error("setNumLoops:: " + e.toString()); }
  219.  
  220.         try{
  221.             args = new Class[1];
  222.             args[0] = java.lang.Boolean.TYPE ;
  223.             MethodDescriptor setRepeatMode = new MethodDescriptor(beanClass.getMethod("setRepeatMode", args));
  224.  
  225.             connections = new java.util.Vector();
  226.             connection = new ConnectionDescriptor("input", "boolean", "",
  227.                                     "%name%.setRepeatMode(%arg%);",
  228.                                     conn.getString("setRepeatMode"));
  229.             connections.addElement(connection);
  230.  
  231.             setRepeatMode.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  232.             md.addElement(setRepeatMode);
  233.         } catch (Exception e) { throw new Error("setRepeatMode:: " + e.toString()); }
  234.  
  235.         try{
  236.             args = null;
  237.             MethodDescriptor getDelay = new MethodDescriptor(beanClass.getMethod("getDelay", args));
  238.  
  239.             connections = new java.util.Vector();
  240.             connection = new ConnectionDescriptor("output", "int", "",
  241.                                     "%name%.getDelay()",
  242.                                     conn.getString("getDelay"));
  243.             connections.addElement(connection);
  244.  
  245.             getDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  246.             md.addElement(getDelay);
  247.         } catch (Exception e) { throw new Error("getDelay:: " + e.toString()); }
  248.  
  249.         try{
  250.             args = null;
  251.             MethodDescriptor getImageList = new MethodDescriptor(beanClass.getMethod("getImageList", args));
  252.  
  253.             connections = new java.util.Vector();
  254.             connection = new ConnectionDescriptor("output", "URL[]", "",
  255.                                     "%name%.getImageList()",
  256.                                     conn.getString("getImageList"));
  257.             connections.addElement(connection);
  258.  
  259.             getImageList.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  260.             md.addElement(getImageList);
  261.         } catch (Exception e) { throw new Error("getImageList:: " + e.toString()); }
  262.  
  263.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  264.         md.copyInto(rv);
  265.  
  266.         return rv;
  267.     }
  268.  
  269.     /**
  270.      * Returns descriptions of this bean's properties.
  271.      */
  272.     public PropertyDescriptor[] getPropertyDescriptors() {
  273.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  274.  
  275.         try{
  276.         PropertyDescriptor delay = new PropertyDescriptor("delay", beanClass);
  277.         delay.setBound(true);
  278.         delay.setConstrained(true);
  279.         delay.setDisplayName(prop.getString("delay"));
  280.  
  281.         PropertyDescriptor numLoops = new PropertyDescriptor("numLoops", beanClass);
  282.         numLoops.setBound(true);
  283.         numLoops.setConstrained(true);
  284.         numLoops.setDisplayName(prop.getString("numLoops"));
  285.  
  286.         PropertyDescriptor repeatMode = new PropertyDescriptor("repeatMode", beanClass);
  287.         repeatMode.setBound(true);
  288.         repeatMode.setConstrained(true);
  289.         repeatMode.setDisplayName(prop.getString("repeatMode"));
  290.  
  291.         PropertyDescriptor imageList = new PropertyDescriptor("imageList", beanClass);
  292.         imageList.setBound(true);
  293.         imageList.setConstrained(true);
  294.         imageList.setDisplayName(prop.getString("imageList"));
  295.         imageList.setValue("URLFILTER", prop.getString("imageURLFILTER"));
  296.  
  297.         PropertyDescriptor clearFrame = new PropertyDescriptor("clearFrame", beanClass);
  298.         clearFrame.setBound(true);
  299.         clearFrame.setConstrained(true);
  300.         clearFrame.setDisplayName(prop.getString("clearFrame"));
  301.  
  302.         PropertyDescriptor previewMode = new PropertyDescriptor("previewMode", beanClass);
  303.         previewMode.setBound(true);
  304.         previewMode.setConstrained(false);
  305.         previewMode.setDisplayName(prop.getString("previewMode"));
  306.  
  307.         PropertyDescriptor[] rv = {
  308.             delay,
  309.             numLoops,
  310.             repeatMode,
  311.             imageList,
  312.             clearFrame,
  313.             previewMode};
  314.         return rv;
  315.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  316.     }
  317.  
  318.     private final static Class beanClass = Animator.class;
  319.  
  320.     }    //  end of class AnimatorBeanInfo