001 /** 002 * This library is free software; you can redistribute it and/or modify it 003 * under the terms of the GNU Lesser General Public License (LGPL) as 004 * published by the Free Software Foundation; either version 3.0 of the 005 * License, or (at your option) any later version. 006 * 007 * This library is distributed in the hope that it will be useful, but 008 * WITHOUT ANY WARRANTY; without even the implied warranty of 009 * MERCHANTABILITY of FITNESS FOR A PARTICULAR PURPOSE. See the GNU 010 * Lesser General Public License for more details. 011 */ 012 013 /** 014 * Title: JBarcodeBean 015 * Description: Barcode JavaBeans Component 016 * Copyright: Copyright (C) 2004 017 * Company: Dafydd Walters 018 */ 019 package net.sourceforge.jbarcodebean; 020 021 import java.beans.BeanDescriptor; 022 import java.beans.BeanInfo; 023 import java.beans.IntrospectionException; 024 import java.beans.PropertyDescriptor; 025 import java.beans.SimpleBeanInfo; 026 import java.net.URL; 027 028 import javax.swing.ImageIcon; 029 030 /** 031 * This class is an implementation of the <tt><b>java.beans.BeanInfo</b></tt> 032 * interface, that provides GUI Builders with information about 033 * {@link JBarcodeBean}. 034 */ 035 public class JBarcodeBeanBeanInfo extends SimpleBeanInfo { 036 037 public BeanDescriptor getBeanDescriptor() { 038 BeanDescriptor bd = new BeanDescriptor(beanClass); 039 bd.setName("jbarcodebean.JBarcodeBean"); 040 bd.setDisplayName("JBarcodeBean "+JBarcodeBean.getVersion()); 041 bd.setShortDescription("JBarcodeBean is a JFC Swing-compatible JavaBeans component that lets you barcode-enable Java 2 enterprise applications."); 042 return bd; 043 } 044 045 public java.awt.Image getIcon(int iconKind) { 046 String iconName=null; 047 switch (iconKind) { 048 case BeanInfo.ICON_MONO_16x16: 049 iconName="jbarcodebean_bw16.gif"; 050 break; 051 case BeanInfo.ICON_COLOR_16x16: 052 iconName="jbarcodebean_c16.gif"; 053 break; 054 case BeanInfo.ICON_MONO_32x32: 055 iconName="jbarcodebean_bw32.gif"; 056 break; 057 case BeanInfo.ICON_COLOR_32x32: 058 iconName="jbarcodebean_c32.gif"; 059 break; 060 } 061 if(iconName!=null){ 062 URL url=beanClass.getResource(iconName); 063 if(url!=null){ 064 return new ImageIcon(url).getImage(); 065 } else{ 066 return null; 067 } 068 } 069 return null; 070 } 071 072 public PropertyDescriptor[] getPropertyDescriptors() { 073 try { 074 PropertyDescriptor code = new PropertyDescriptor("code", beanClass); 075 code.setBound(true); 076 PropertyDescriptor narrowestBarWidth = new PropertyDescriptor("narrowestBarWidth", beanClass); 077 narrowestBarWidth.setBound(true); 078 PropertyDescriptor checkDigit = new PropertyDescriptor("checkDigit", beanClass); 079 checkDigit.setBound(true); 080 PropertyDescriptor codeType = new PropertyDescriptor("codeType", beanClass); 081 codeType.setBound(true); 082 codeType.setPropertyEditorClass(BarcodeStrategyEditor.class); 083 PropertyDescriptor font = new PropertyDescriptor("font", beanClass); 084 font.setBound(true); 085 PropertyDescriptor border = new PropertyDescriptor("border", beanClass); 086 border.setBound(true); 087 PropertyDescriptor background = new PropertyDescriptor("background", beanClass); 088 background.setBound(true); 089 PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass); 090 foreground.setBound(true); 091 PropertyDescriptor barcodeBackground = new PropertyDescriptor("barcodeBackground", beanClass); 092 barcodeBackground.setBound(true); 093 PropertyDescriptor barcodeHeight = new PropertyDescriptor("barcodeHeight", beanClass); 094 barcodeHeight.setBound(true); 095 PropertyDescriptor showText = new PropertyDescriptor("showText", beanClass); 096 showText.setBound(true); 097 PropertyDescriptor angleDegrees = new PropertyDescriptor("angleDegrees", beanClass); 098 angleDegrees.setBound(true); 099 100 PropertyDescriptor rv[] = {code, narrowestBarWidth, checkDigit, codeType, 101 font, border, background, foreground, barcodeBackground, 102 barcodeHeight, showText, angleDegrees}; 103 return rv; 104 } catch( IntrospectionException e) { 105 throw new Error(e.toString()); 106 } 107 } 108 109 public int getDefaultPropertyIndex() { 110 // the index for the code property. 111 return 0; 112 } 113 114 private final static Class beanClass = JBarcodeBean.class; 115 }