home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 February / VPR9802A.ISO / APP_DEMO / VC / SOURCE.BIN / ImagePanelBeanInfo.java < prev    next >
Text File  |  1997-10-27  |  7KB  |  211 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5.  
  6. //  08/25/97    LAB    Added IMAGE_NORMAL to Style popup (Addresses Mac Bug #7255).  Added
  7. //                    connections for image style constants.
  8.  
  9. /**
  10.  * BeanInfo for ImagePanel.
  11.  *
  12.  */
  13.  
  14. public class ImagePanelBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a ImagePanelBeanInfo object.
  18.      */
  19.     public ImagePanelBeanInfo() {
  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.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  42.         bd.setFolder("パネル");
  43.         bd.setToolbar("パネル");
  44. //        bd.setFolder("Panels");
  45. //        bd.setToolbar("Panels");
  46.         bd.setWinHelp("0x123B9");
  47.  
  48.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  49.                                                 "%name%.IMAGE_TILED",
  50.                                                 "並べて表示"));
  51. //                                                "IMAGE_TILED"));
  52.  
  53.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  54.                                                 "%name%.IMAGE_CENTERED",
  55.                                                 "中央"));
  56. //                                                "IMAGE_CENTERED"));
  57.  
  58.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  59.                                                 "%name%.IMAGE_SCALED_TO_FIT",
  60.                                                 "枠に合わせて伸長"));
  61. //                                                "IMAGE_SCALED_TO_FIT"));
  62.  
  63.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  64.                                                 "%name%.IMAGE_NORMAL",
  65.                                                 "デフォルト(左上)"));
  66. //                                                "IMAGE_NORMAL"));
  67.         return (BeanDescriptor) bd;
  68.     }
  69.  
  70.     /**
  71.      * Gets an image that may be used to visually represent this bean
  72.      * (in the toolbar, on a form, etc).
  73.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  74.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  75.      * @return an image for this bean, always color even if requested monochrome
  76.      * @see BeanInfo#ICON_MONO_16x16
  77.      * @see BeanInfo#ICON_COLOR_16x16
  78.      * @see BeanInfo#ICON_MONO_32x32
  79.      * @see BeanInfo#ICON_COLOR_32x32
  80.      */
  81.     public java.awt.Image getIcon(int iconKind) {
  82.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  83.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  84.             java.awt.Image img = loadImage("ImagePanelC16.gif");
  85.             return img;
  86.         }
  87.  
  88.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  89.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  90.             java.awt.Image img = loadImage("ImagePanelC32.gif");
  91.             return img;
  92.         }
  93.  
  94.         return null;
  95.     }
  96.  
  97.     /**
  98.      * Gets an array of descriptions of the methods used for "connections" by
  99.      * Visual Caf's Interaction Wizard.
  100.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  101.      * @return method descriptions for this bean
  102.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  103.      */
  104.     public MethodDescriptor[] getMethodDescriptors() {
  105.         Class[] args;
  106.         ConnectionDescriptor connection;
  107.         java.util.Vector connections;
  108.         java.util.Vector md = new java.util.Vector();
  109.  
  110.         try{
  111.             args = new Class[1];
  112.             args[0] = java.lang.Integer.TYPE ;
  113.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setStyle", args));
  114.  
  115.             connections = new java.util.Vector();
  116.             connection = new ConnectionDescriptor("input", "int", "",
  117.                                     "%name%.setStyle(%arg%);",
  118.                                     "イメージ形式を設定する");
  119. //                                    "Set the style of the panel image");
  120.             connections.addElement(connection);
  121.  
  122.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  123.             md.addElement(setStyle);
  124.         } catch (Exception e) { throw new Error("setStyle:: " + e.toString()); }
  125.  
  126.         try{
  127.             args = null;
  128.             MethodDescriptor getStyle = new MethodDescriptor(beanClass.getMethod("getStyle", args));
  129.  
  130.             connections = new java.util.Vector();
  131.             connection = new ConnectionDescriptor("output", "int", "",
  132.                                     "%name%.getStyle()",
  133.                                     "イメージ形式を取得する");
  134. //                                    "Get the style of the panel image");
  135.             connections.addElement(connection);
  136.  
  137.             getStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  138.             md.addElement(getStyle);
  139.         } catch (Exception e) { throw new Error("getStyle:: " + e.toString()); }
  140.  
  141.         try{
  142.             args = null;
  143.             MethodDescriptor getImageURL = new MethodDescriptor(beanClass.getMethod("getImageURL", args));
  144.  
  145.             connections = new java.util.Vector();
  146.             connection = new ConnectionDescriptor("output", "URL", "",
  147.                                     "%name%.getImageURL()",
  148.                                     "パネルのイメージを URL で取得する");
  149. //                                    "Get the image URL of the panel");
  150.             connections.addElement(connection);
  151.  
  152.             getImageURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  153.             md.addElement(getImageURL);
  154.         } catch (Exception e) { throw new Error("getImageURL:: " + e.toString()); }
  155.  
  156.         try{
  157.             args = new Class[1];
  158.             args[0] = java.net.URL.class ;
  159.             MethodDescriptor setImageURL = new MethodDescriptor(beanClass.getMethod("setImageURL", args));
  160.  
  161.             connections = new java.util.Vector();
  162.             connection = new ConnectionDescriptor("input", "URL", "",
  163.                                     "%name%.setImageURL(%arg%);",
  164.                                     "パネルに表示するイメージを URL で設定する");
  165. //                                    "Set the image to be displayed on the panel");
  166.             connections.addElement(connection);
  167.  
  168.             connection = new ConnectionDescriptor("input", "RelativeURL", "",
  169.                                     "%name%.setImageURL(symantec.itools.net.RelativeURL.getURL(%arg%));",
  170.                                     "パネルに表示するイメージを 相対URL で設定する");
  171. //                                    "Set the relative image to be displayed on the panel");
  172.             connections.addElement(connection);
  173.  
  174.             setImageURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  175.             md.addElement(setImageURL);
  176.         } catch (Exception e) { throw new Error("setImageURL:: " + e.toString()); }
  177.  
  178.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  179.         md.copyInto(rv);
  180.  
  181.         return rv;
  182.     }
  183.  
  184.     /**
  185.      * Returns desecriptions of this bean's properties.
  186.      */
  187.     public PropertyDescriptor[] getPropertyDescriptors() {
  188.         try{
  189.         PropertyDescriptor imageURL = new PropertyDescriptor("imageURL", beanClass);
  190.         imageURL.setBound(true);
  191.         imageURL.setConstrained(true);
  192.         imageURL.setDisplayName("URL");
  193.         imageURL.setValue("URLFILTER", "Imageファイル (*.jpg;*.gif)");
  194.  
  195.         PropertyDescriptor style = new PropertyDescriptor("style", beanClass);
  196.         style.setBound(true);
  197.         style.setConstrained(true);
  198.         style.setDisplayName("イメージ形式");
  199. //        style.setDisplayName("Image Style");
  200.         style.setValue("ENUMERATION", "IMAGE_TILED=0, IMAGE_CENTERED=1, IMAGE_SCALED_TO_FIT=2, IMAGE_NORMAL=3");
  201.  
  202.         PropertyDescriptor[] rv = {
  203.             imageURL,
  204.             style};
  205.         return rv;
  206.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  207.     }
  208.  
  209.     private final static Class beanClass = ImagePanel.class;
  210.  
  211.     }    //  end of class ImagePanelBeanInfo