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:  http://www.jfree.org/orson/
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
029package org.jfree.beans;
030
031import java.beans.EventSetDescriptor;
032import java.beans.IntrospectionException;
033import java.beans.PropertyDescriptor;
034import java.beans.SimpleBeanInfo;
035import java.util.List;
036import java.util.ResourceBundle;
037
038import org.jfree.beans.events.CategoryItemClickListener;
039
040/**
041 * A description of the {@link AbstractCategoryChart} class.
042 */
043public class AbstractCategoryChartBeanInfo extends SimpleBeanInfo {
044
045    /** The resourceBundle for the localization. */
046    static ResourceBundle localizationResources = 
047            ResourceBundle.getBundle("org.jfree.beans.LocalizationBundle");
048
049    
050    /**
051     * Returns some property descriptors.
052     * 
053     * @return The property descriptors.
054     */
055    public PropertyDescriptor[] getPropertyDescriptors() {
056
057        // a prefix for the localised string keys
058        final String prefix = "AbstractCategoryChart.";
059        
060        // these regular properties are defined...
061        Object[][] props = new Object[][] { 
062            {"orientation", Boolean.FALSE, "Category.Plot"},
063            {"categoryAxisLocation", Boolean.FALSE, "Category.CategoryAxis"},
064            {"categoryAxisLabel", Boolean.FALSE, "Category.CategoryAxis"},
065            {"categoryAxisLabelFont", Boolean.FALSE, "Category.CategoryAxis"},
066            {"categoryAxisLabelPaint", Boolean.FALSE, "Category.CategoryAxis"},
067            {"categoryAxisLineVisible", Boolean.FALSE, "Category.CategoryAxis"},
068            {"categoryAxisMargin", Boolean.TRUE, "Category.CategoryAxis"},
069            {"categoryAxisLowerMargin", Boolean.FALSE, "Category.CategoryAxis"},
070            {"categoryAxisUpperMargin", Boolean.FALSE, "Category.CategoryAxis"},
071            {"valueAxisLocation", Boolean.FALSE, "Category.ValueAxis"},
072            {"valueAxisLabel", Boolean.FALSE, "Category.ValueAxis"},
073            {"valueAxisLowerMargin", Boolean.FALSE, "Category.ValueAxis"},
074            {"valueAxisUpperMargin", Boolean.FALSE, "Category.ValueAxis"},
075            {"valueAxisLineVisible", Boolean.FALSE, "Category.ValueAxis"},
076            {"valueAxisInverted", Boolean.FALSE, "Category.ValueAxis"},
077            {"valueAxisGridlinesVisible", Boolean.FALSE, "Category.ValueAxis"},
078            {"toolTipFormat", Boolean.FALSE, "Category.ToolTips"}
079        };
080        
081        // create property descriptors for the regular properties...
082        List pds = new java.util.ArrayList();
083        for (int i = 0; i < props.length; i++) {
084            try {
085                String name = (String) props[i][0];
086                PropertyDescriptor pd = new PropertyDescriptor(name, 
087                        AbstractCategoryChart.class);
088                Boolean expert = (Boolean) props[i][1];
089                pd.setExpert(expert.booleanValue());
090                String desc = localizationResources.getString(prefix + name);
091                pd.setShortDescription(desc);
092                pd.setValue("category", localizationResources.getString(
093                        (String) props[i][2]));
094                pds.add(pd);
095            }
096            catch (IntrospectionException e) {
097                // swallow...
098            }
099        }
100
101        // create and return an array of all property descriptors...
102        PropertyDescriptor[] result = new PropertyDescriptor[pds.size()];
103        for (int i = 0; i < pds.size(); i++) {
104            result[i] = (PropertyDescriptor) pds.get(i);
105        }
106        return result;
107    }
108
109    /* (non-Javadoc)
110     * @see java.beans.SimpleBeanInfo#getEventSetDescriptors()
111     */
112    public EventSetDescriptor[] getEventSetDescriptors() {
113        EventSetDescriptor e1 = null;
114        try {
115            e1 = new EventSetDescriptor(AbstractCategoryChart.class, 
116                    "categoryItemClick", CategoryItemClickListener.class, 
117                    "onCategoryItemClick");
118            e1.setInDefaultEventSet(true);
119            e1.setExpert(false);
120            e1.setPreferred(false);
121        }
122        catch (IntrospectionException e) {
123            e.printStackTrace();
124            return super.getEventSetDescriptors();
125        }
126        return new EventSetDescriptor[] {e1};
127    }
128
129}