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.EventSetDescriptor; 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 import org.jfree.beans.events.XYItemClickListener; 039 040 /** 041 * A description of the {@link AbstractXYChart} class. 042 */ 043 public class AbstractXYChartBeanInfo 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 = "AbstractXYChart."; 059 060 // these regular properties are defined... 061 Object[][] props = new Object[][] { 062 {"orientation", Boolean.FALSE, "Category.Plot"}, 063 {"toolTipFormat", Boolean.FALSE, "Category.ToolTips"}, 064 {"xAxisLocation", Boolean.FALSE, "Category.XAxis"}, 065 {"yAxisLocation", Boolean.FALSE, "Category.YAxis"}, 066 {"xAxisLabel", Boolean.FALSE, "Category.XAxis"}, 067 {"xAxisLabelFont", Boolean.FALSE, "Category.XAxis"}, 068 {"xAxisLabelPaint", Boolean.TRUE, "Category.XAxis"}, 069 {"xAxisInverted", Boolean.FALSE, "Category.XAxis"}, 070 {"xAxisLowerMargin", Boolean.TRUE, "Category.XAxis"}, 071 {"xAxisUpperMargin", Boolean.TRUE, "Category.XAxis"}, 072 {"xAxisGridlinesVisible", Boolean.FALSE, "Category.Gridlines"}, 073 {"xAxisGridlinePaint", Boolean.FALSE, "Category.Gridlines"}, 074 {"xAxisTickLabelFont", Boolean.FALSE, "Category.XAxis"}, 075 {"xAxisTickLabelPaint", Boolean.TRUE, "Category.XAxis"}, 076 {"xAxisNegativeArrowVisible", Boolean.TRUE, "Category.XAxis"}, 077 {"xAxisPositiveArrowVisible", Boolean.TRUE, "Category.XAxis"}, 078 {"yAxisLabel", Boolean.FALSE, "Category.YAxis"}, 079 {"yAxisLabelFont", Boolean.FALSE, "Category.YAxis"}, 080 {"yAxisLabelPaint", Boolean.TRUE, "Category.YAxis"}, 081 {"yAxisInverted", Boolean.FALSE, "Category.YAxis"}, 082 {"yAxisScale", Boolean.FALSE, "Category.YAxis"}, 083 {"yAxisAutoRangeIncludesZero", Boolean.FALSE, "Category.YAxis"}, 084 {"yAxisLowerMargin", Boolean.TRUE, "Category.YAxis"}, 085 {"yAxisUpperMargin", Boolean.TRUE, "Category.YAxis"}, 086 {"yAxisGridlinesVisible", Boolean.FALSE, "Category.Gridlines"}, 087 {"yAxisGridlinePaint", Boolean.FALSE, "Category.Gridlines"}, 088 {"yAxisTickLabelFont", Boolean.FALSE, "Category.YAxis"}, 089 {"yAxisTickLabelPaint", Boolean.TRUE, "Category.YAxis"}, 090 {"yAxisNegativeArrowVisible", Boolean.TRUE, "Category.YAxis"}, 091 {"yAxisPositiveArrowVisible", Boolean.TRUE, "Category.YAxis"} 092 }; 093 094 // create property descriptors for the regular properties... 095 List pds = new java.util.ArrayList(); 096 for (int i = 0; i < props.length; i++) { 097 try { 098 String name = (String) props[i][0]; 099 PropertyDescriptor pd = new PropertyDescriptor(name, 100 AbstractXYChart.class); 101 Boolean expert = (Boolean) props[i][1]; 102 pd.setExpert(expert.booleanValue()); 103 String desc = localizationResources.getString(prefix + name); 104 pd.setShortDescription(desc); 105 pd.setValue("category", localizationResources.getString( 106 (String) props[i][2])); 107 pds.add(pd); 108 } 109 catch (IntrospectionException e) { 110 // swallow... 111 } 112 } 113 114 // create and return an array of all property descriptors... 115 PropertyDescriptor[] result = new PropertyDescriptor[pds.size()]; 116 for (int i = 0; i < pds.size(); i++) { 117 result[i] = (PropertyDescriptor) pds.get(i); 118 } 119 return result; 120 } 121 122 /* (non-Javadoc) 123 * @see java.beans.SimpleBeanInfo#getEventSetDescriptors() 124 */ 125 public EventSetDescriptor[] getEventSetDescriptors() { 126 EventSetDescriptor e1 = null; 127 try { 128 e1 = new EventSetDescriptor(AbstractXYChart.class, 129 "xYItemClick", XYItemClickListener.class, 130 "onXYItemClick"); 131 e1.setInDefaultEventSet(true); 132 e1.setExpert(false); 133 e1.setPreferred(false); 134 } 135 catch (IntrospectionException e) { 136 e.printStackTrace(); 137 return super.getEventSetDescriptors(); 138 } 139 return new EventSetDescriptor[] {e1}; 140 } 141 142 }