001    /* ======================================================
002     * Orson : a free chart beans library based on JFreeChart
003     * ======================================================
004     *
005     * (C) Copyright 2007, by Object Refinery Limited.
006     *
007     * Project Info:  not-yet-released
008     *
009     * This library is free software; you can redistribute it and/or modify it 
010     * under the terms of the GNU Lesser General Public License as published by 
011     * the Free Software Foundation; either version 2.1 of the License, or 
012     * (at your option) any later version.
013     *
014     * This library is distributed in the hope that it will be useful, but 
015     * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016     * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017     * License for more details.
018     *
019     * You should have received a copy of the GNU Lesser General Public
020     * License along with this library; if not, write to the Free Software
021     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022     * USA.  
023     *
024     * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025     * in the United States and other countries.]
026     * 
027     */
028    
029    package org.jfree.beans;
030    
031    import java.beans.BeanInfo;
032    import java.beans.IntrospectionException;
033    import java.beans.PropertyDescriptor;
034    import java.beans.SimpleBeanInfo;
035    import java.util.List;
036    import java.util.ResourceBundle;
037    
038    /**
039     * Bean info for the {@link NumericalXYChart} bean.
040     */
041    public class NumericalXYChartBeanInfo extends SimpleBeanInfo {
042    
043        /** The resourceBundle for the localization. */
044        static ResourceBundle localizationResources = 
045                ResourceBundle.getBundle("org.jfree.beans.LocalizationBundle");
046        
047        /**
048         * Returns the bean info from the super classes.
049         * 
050         * @return Additional bean info.
051         */
052        public BeanInfo[] getAdditionalBeanInfo() {
053            return new BeanInfo[] {new AbstractXYChartBeanInfo(), 
054                    new AbstractXYChartBeanInfo()};    
055        }
056        
057        /**
058         * Returns some property descriptors.
059         * 
060         * @return The property descriptors.
061         */
062        public PropertyDescriptor[] getPropertyDescriptors() {
063    
064            // a prefix for the localised string keys
065            final String prefix = "NumericalXYChart.";
066            
067            // these regular properties are defined...
068            Object[][] props = new Object[][] { 
069                {"xAxisAutoRangeIncludesZero", Boolean.FALSE, "Category.XAxis"},
070                {"xAxisScale", Boolean.FALSE, "Category.XAxis"}
071            };
072            
073    
074            // create property descriptors for the regular properties...
075            List pds = new java.util.ArrayList();
076            for (int i = 0; i < props.length; i++) {
077                try {
078                    String name = (String) props[i][0];
079                    PropertyDescriptor pd = new PropertyDescriptor(name, 
080                            NumericalXYChart.class);
081                    Boolean expert = (Boolean) props[i][1];
082                    pd.setExpert(expert.booleanValue());
083                    String desc = localizationResources.getString(prefix + name);
084                    pd.setShortDescription(desc);
085                    pd.setValue("category", localizationResources.getString(
086                            (String) props[i][2]));
087                    pds.add(pd);
088                }
089                catch (IntrospectionException e) {
090                    // swallow...
091                }
092            }
093            
094            // create and return an array of all property descriptors...
095            PropertyDescriptor[] result = new PropertyDescriptor[pds.size()];
096            for (int i = 0; i < pds.size(); i++) {
097                result[i] = (PropertyDescriptor) pds.get(i);
098            }
099            return result;
100        }
101    
102    }