Source Code Cross Referenced for DefaultColorBarEditor.java in  » Chart » jfreechart » org » jfree » chart » editor » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Chart » jfreechart » org.jfree.chart.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ===========================================================
002:         * JFreeChart : a free chart library for the Java(tm) platform
003:         * ===========================================================
004:         *
005:         * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006:         *
007:         * Project Info:  http://www.jfree.org/jfreechart/index.html
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:         * DefaultColorBarEditor.java
029:         * --------------------------
030:         * (C) Copyright 2002-2007, by David M. O'Donnell and Contributors.
031:         *
032:         * Original Author:  David M. O'Donnell;
033:         * Contributor(s):   David Gilbert (for Object Refinery Limited);
034:         *                   Arnaud Lelievre;
035:         *
036:         * $Id: DefaultColorBarEditor.java,v 1.1.2.2 2007/02/02 14:33:12 mungady Exp $
037:         *
038:         * Changes
039:         * -------
040:         * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG);
041:         * 08-Sep-2003 : Added internationalization via use of properties 
042:         *               resourceBundle (RFE 690236) (AL); 
043:         * 24-Nov-2005 : Moved and renamed: org.jfree.chart.ui.ColorBarPropertyEditPanel
044:         *               --> DefaultColorBarEditor (DG);
045:         * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG);
046:         *
047:         */
048:
049:        package org.jfree.chart.editor;
050:
051:        import java.awt.event.ActionEvent;
052:        import java.util.ResourceBundle;
053:
054:        import javax.swing.BorderFactory;
055:        import javax.swing.JButton;
056:        import javax.swing.JCheckBox;
057:        import javax.swing.JLabel;
058:        import javax.swing.JOptionPane;
059:        import javax.swing.JPanel;
060:        import javax.swing.JTabbedPane;
061:
062:        import org.jfree.chart.axis.ColorBar;
063:        import org.jfree.chart.axis.NumberAxis;
064:        import org.jfree.chart.plot.GreyPalette;
065:        import org.jfree.chart.plot.RainbowPalette;
066:        import org.jfree.layout.LCBLayout;
067:
068:        /**
069:         * A DefaultColorBarEditor.  Extends DefaultNumberAxisEditor to allow 
070:         * change general axis type parameters.
071:         */
072:        class DefaultColorBarEditor extends DefaultNumberAxisEditor {
073:
074:            /** 
075:             * A checkbox that indicates whether or not the color indices should run 
076:             * high to low. 
077:             */
078:            private JCheckBox invertPaletteCheckBox;
079:
080:            /** Flag set by invertPaletteCheckBox. */
081:            private boolean invertPalette = false;
082:
083:            /** A checkbox that indicates whether the palette is stepped. */
084:            private JCheckBox stepPaletteCheckBox;
085:
086:            /** Flag set by stepPaletteCheckBox. */
087:            private boolean stepPalette = false;
088:
089:            /** The Palette Sample displaying the current Palette. */
090:            private PaletteSample currentPalette;
091:
092:            /** An array of availiable sample palettes. */
093:            private PaletteSample[] availablePaletteSamples;
094:
095:            /** The resourceBundle for the localization. */
096:            protected static ResourceBundle localizationResources = ResourceBundle
097:                    .getBundle("org.jfree.chart.editor.LocalizationBundle");
098:
099:            /**
100:             * Creates a new edit panel for a color bar.
101:             * 
102:             * @param colorBar  the color bar.
103:             */
104:            public DefaultColorBarEditor(ColorBar colorBar) {
105:                super ((NumberAxis) colorBar.getAxis());
106:                this .invertPalette = colorBar.getColorPalette().isInverse();
107:                this .stepPalette = colorBar.getColorPalette().isStepped();
108:                this .currentPalette = new PaletteSample(colorBar
109:                        .getColorPalette());
110:                this .availablePaletteSamples = new PaletteSample[2];
111:                this .availablePaletteSamples[0] = new PaletteSample(
112:                        new RainbowPalette());
113:                this .availablePaletteSamples[1] = new PaletteSample(
114:                        new GreyPalette());
115:
116:                JTabbedPane other = getOtherTabs();
117:
118:                JPanel palettePanel = new JPanel(new LCBLayout(4));
119:                palettePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4,
120:                        4));
121:
122:                palettePanel.add(new JPanel());
123:                this .invertPaletteCheckBox = new JCheckBox(
124:                        localizationResources.getString("Invert_Palette"),
125:                        this .invertPalette);
126:                this .invertPaletteCheckBox.setActionCommand("invertPalette");
127:                this .invertPaletteCheckBox.addActionListener(this );
128:                palettePanel.add(this .invertPaletteCheckBox);
129:                palettePanel.add(new JPanel());
130:
131:                palettePanel.add(new JPanel());
132:                this .stepPaletteCheckBox = new JCheckBox(localizationResources
133:                        .getString("Step_Palette"), this .stepPalette);
134:                this .stepPaletteCheckBox.setActionCommand("stepPalette");
135:                this .stepPaletteCheckBox.addActionListener(this );
136:                palettePanel.add(this .stepPaletteCheckBox);
137:                palettePanel.add(new JPanel());
138:
139:                palettePanel.add(new JLabel(localizationResources
140:                        .getString("Palette")));
141:                JButton button = new JButton(localizationResources
142:                        .getString("Set_palette..."));
143:                button.setActionCommand("PaletteChoice");
144:                button.addActionListener(this );
145:                palettePanel.add(this .currentPalette);
146:                palettePanel.add(button);
147:
148:                other.add(localizationResources.getString("Palette"),
149:                        palettePanel);
150:
151:            }
152:
153:            /**
154:             * Handles actions from within the property panel.
155:             *
156:             * @param event  the event.
157:             */
158:            public void actionPerformed(ActionEvent event) {
159:                String command = event.getActionCommand();
160:                if (command.equals("PaletteChoice")) {
161:                    attemptPaletteSelection();
162:                } else if (command.equals("invertPalette")) {
163:                    this .invertPalette = this .invertPaletteCheckBox
164:                            .isSelected();
165:                } else if (command.equals("stepPalette")) {
166:                    this .stepPalette = this .stepPaletteCheckBox.isSelected();
167:                } else {
168:                    super .actionPerformed(event); // pass to super-class for handling
169:                }
170:            }
171:
172:            /**
173:             * Handle a palette selection.
174:             */
175:            private void attemptPaletteSelection() {
176:                PaletteChooserPanel panel = new PaletteChooserPanel(null,
177:                        this .availablePaletteSamples);
178:                int result = JOptionPane
179:                        .showConfirmDialog(this , panel, localizationResources
180:                                .getString("Palette_Selection"),
181:                                JOptionPane.OK_CANCEL_OPTION,
182:                                JOptionPane.PLAIN_MESSAGE);
183:
184:                if (result == JOptionPane.OK_OPTION) {
185:                    double zmin = this .currentPalette.getPalette().getMinZ();
186:                    double zmax = this .currentPalette.getPalette().getMaxZ();
187:                    this .currentPalette.setPalette(panel.getSelectedPalette());
188:                    this .currentPalette.getPalette().setMinZ(zmin);
189:                    this .currentPalette.getPalette().setMaxZ(zmax);
190:                }
191:            }
192:
193:            /**
194:             * Sets the properties of the specified axis to match the properties 
195:             * defined on this panel.
196:             * 
197:             * @param colorBar  the color bar.
198:             */
199:            public void setAxisProperties(ColorBar colorBar) {
200:                super .setAxisProperties(colorBar.getAxis());
201:                colorBar.setColorPalette(this .currentPalette.getPalette());
202:                colorBar.getColorPalette().setInverse(this .invertPalette); //dmo added
203:                colorBar.getColorPalette().setStepped(this .stepPalette); //dmo added
204:            }
205:
206:            /**
207:             * A static method that returns a panel that is appropriate for the axis
208:             * type.
209:             *
210:             * @param colorBar  the color bar.
211:             *
212:             * @return A panel or <code>null</code< if axis is <code>null</code>.
213:             */
214:            public static DefaultColorBarEditor getInstance(ColorBar colorBar) {
215:
216:                if (colorBar != null) {
217:                    return new DefaultColorBarEditor(colorBar);
218:                } else {
219:                    return null;
220:                }
221:
222:            }
223:
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.