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 package org.jfree.beans.editors;
029
030 import java.awt.Component;
031 import java.awt.FlowLayout;
032 import java.beans.PropertyEditorSupport;
033
034 import javax.swing.JButton;
035 import javax.swing.JPanel;
036
037 import org.jfree.util.Rotation;
038
039 /**
040 * A JavaBeans property editor for the {@link Rotation} class.
041 */
042 public class StrokeEditor extends PropertyEditorSupport {
043
044 // /**
045 // * Returns a string representing the current value. This will be one of
046 // * <code>Rotation.CLOCKWISE</code> and <code>Rotation.ANTICLOCKWISE</code>.
047 // *
048 // * @return A string representing the current value.
049 // */
050 // public String getAsText() {
051 // return "STROKE1";
052 // }
053 //
054 // /**
055 // * Sets the current value by parsing the supplied string.
056 // *
057 // * @param text the string value.
058 // *
059 // * @throws IllegalArgumentException if <code>text</code> is not one of
060 // * the values listed in {@link #getAsText()}.
061 // */
062 // public void setAsText(String text) throws IllegalArgumentException {
063 // if ("STROKE1".equals(text)) {
064 // setValue(new BasicStroke(1.0f));
065 // }
066 // else if ("STROKE2".equals(text)) {
067 // setValue(new BasicStroke(2.0f));
068 // }
069 // else {
070 // throw new IllegalArgumentException("Unrecognised 'text' argument.");
071 // }
072 // }
073 //
074 // /**
075 // * Returns the valid string values for this property.
076 // *
077 // * @return The valid string values for this property.
078 // */
079 // public String[] getTags() {
080 // return new String[] {"STROKE1", "STROKE2"};
081 // }
082
083 /**
084 * Returns a string for the property value.
085 *
086 * @return A string for the property value.
087 */
088 public String getJavaInitializationString() {
089 return "new BasicStroke(2.0f);";
090 }
091
092 /* (non-Javadoc)
093 * @see java.beans.PropertyEditorSupport#getCustomEditor()
094 */
095 public Component getCustomEditor() {
096 System.out.println("getCustomEditor()");
097 JPanel editor = new JPanel(new FlowLayout());
098 editor.add(new JButton("Button 1"));
099 editor.add(new JButton("Button 2"));
100 return editor;
101 }
102
103 /* (non-Javadoc)
104 * @see java.beans.PropertyEditorSupport#supportsCustomEditor()
105 */
106 public boolean supportsCustomEditor() {
107 System.out.println("supportsCustomEditor()");
108 return true;
109 }
110
111 }