Source Code Cross Referenced for JThermometer.java in  » Chart » jfreechart » org » jfree » chart » plot » 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.plot 
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:         * JThermometer.java
029:         * -----------------
030:         * A plot that displays a single value in a thermometer type display.
031:         *
032:         * (C) Copyright 2000-2007, Australian Antarctic Division and Contributors.
033:         *
034:         * Original Author:  Bryan Scott.
035:         * Contributor(s):   David Gilbert (for Object Refinery Limited);
036:         *                   Irv Thomae;
037:         *
038:         * Changes (from 17-Sep-2002)
039:         * --------------------------
040:         * 17-Sep-2002 : Reviewed with Checkstyle utility (DG);
041:         * 18-Sep-2003 : Integrated new methods contributed by Irv Thomae (DG);
042:         * 08-Jan-2004 : Renamed AbstractTitle --> Title and moved to new package (DG);
043:         * 31-May-2005 : Fixed typo in method name (DG);
044:         *
045:         */
046:
047:        package org.jfree.chart.plot;
048:
049:        import java.awt.CardLayout;
050:        import java.awt.Color;
051:        import java.awt.Font;
052:        import java.awt.Paint;
053:        import java.io.Serializable;
054:        import java.text.DecimalFormat;
055:
056:        import javax.swing.JPanel;
057:
058:        import org.jfree.chart.ChartPanel;
059:        import org.jfree.chart.JFreeChart;
060:        import org.jfree.chart.axis.ValueAxis;
061:        import org.jfree.chart.title.TextTitle;
062:        import org.jfree.chart.title.Title;
063:        import org.jfree.data.general.DefaultValueDataset;
064:        import org.jfree.ui.RectangleInsets;
065:
066:        /**
067:         * An initial quick and dirty.  The concept behind this class would be to
068:         * generate a gui bean that could be used within JBuilder, Netbeans etc...
069:         */
070:        public class JThermometer extends JPanel implements  Serializable {
071:
072:            /** For serialization. */
073:            private static final long serialVersionUID = 1079905665515589820L;
074:
075:            /** The dataset. */
076:            private DefaultValueDataset data;
077:
078:            /** The chart. */
079:            private JFreeChart chart;
080:
081:            /** The chart panel. */
082:            private ChartPanel panel;
083:
084:            /** The thermometer plot. */
085:            private ThermometerPlot plot = new ThermometerPlot();
086:
087:            /**
088:             * Default constructor.
089:             */
090:            public JThermometer() {
091:                super (new CardLayout());
092:                this .plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
093:                this .data = new DefaultValueDataset();
094:                this .plot.setDataset(this .data);
095:                this .chart = new JFreeChart(null,
096:                        JFreeChart.DEFAULT_TITLE_FONT, this .plot, false);
097:                this .panel = new ChartPanel(this .chart);
098:                add(this .panel, "Panel");
099:                setBackground(getBackground());
100:            }
101:
102:            /**
103:             * Adds a subtitle to the chart.
104:             *
105:             * @param subtitle  the subtitle.
106:             */
107:            public void addSubtitle(Title subtitle) {
108:                this .chart.addSubtitle(subtitle);
109:            }
110:
111:            /**
112:             * Adds a subtitle to the chart.
113:             *
114:             * @param subtitle  the subtitle.
115:             */
116:            public void addSubtitle(String subtitle) {
117:                this .chart.addSubtitle(new TextTitle(subtitle));
118:            }
119:
120:            /**
121:             * Adds a subtitle to the chart.
122:             *
123:             * @param subtitle  the subtitle.
124:             * @param font  the subtitle font.
125:             */
126:            public void addSubtitle(String subtitle, Font font) {
127:                this .chart.addSubtitle(new TextTitle(subtitle, font));
128:            }
129:
130:            /**
131:             * Sets the value format for the thermometer.
132:             *
133:             * @param df  the formatter.
134:             */
135:            public void setValueFormat(DecimalFormat df) {
136:                this .plot.setValueFormat(df);
137:            }
138:
139:            /**
140:             * Sets the lower and upper bounds for the thermometer.
141:             *
142:             * @param lower  the lower bound.
143:             * @param upper  the upper bound.
144:             */
145:            public void setRange(double lower, double upper) {
146:                this .plot.setRange(lower, upper);
147:            }
148:
149:            /**
150:             * Sets the range.
151:             *
152:             * @param range  the range type.
153:             * @param displayLow  the low value.
154:             * @param displayHigh  the high value.
155:             */
156:            public void setSubrangeInfo(int range, double displayLow,
157:                    double displayHigh) {
158:                this .plot.setSubrangeInfo(range, displayLow, displayHigh);
159:            }
160:
161:            /**
162:             * Sets the range.
163:             *
164:             * @param range  the range type.
165:             * @param rangeLow  the low value for the range.
166:             * @param rangeHigh  the high value for the range.
167:             * @param displayLow  the low value for display.
168:             * @param displayHigh  the high value for display.
169:             */
170:            public void setSubrangeInfo(int range, double rangeLow,
171:                    double rangeHigh, double displayLow, double displayHigh) {
172:
173:                this .plot.setSubrangeInfo(range, rangeLow, rangeHigh,
174:                        displayLow, displayHigh);
175:
176:            }
177:
178:            /**
179:             * Sets the location at which the temperature value is displayed.
180:             *
181:             * @param loc  the location.
182:             */
183:            public void setValueLocation(int loc) {
184:                this .plot.setValueLocation(loc);
185:                this .panel.repaint();
186:            }
187:
188:            /**
189:             * Sets the value paint.
190:             *
191:             * @param paint  the paint.
192:             */
193:            public void setValuePaint(Paint paint) {
194:                this .plot.setValuePaint(paint);
195:            }
196:
197:            /**
198:             * Returns the value of the thermometer.
199:             *
200:             * @return The value.
201:             */
202:            public Number getValue() {
203:                if (this .data != null) {
204:                    return this .data.getValue();
205:                } else {
206:                    return null;
207:                }
208:            }
209:
210:            /**
211:             * Sets the value of the thermometer.
212:             *
213:             * @param value  the value.
214:             */
215:            public void setValue(double value) {
216:                setValue(new Double(value));
217:            }
218:
219:            /**
220:             * Sets the value of the thermometer.
221:             *
222:             * @param value  the value.
223:             */
224:            public void setValue(Number value) {
225:                if (this .data != null) {
226:                    this .data.setValue(value);
227:                }
228:            }
229:
230:            /**
231:             * Sets the unit type.
232:             *
233:             * @param i  the unit type.
234:             */
235:            public void setUnits(int i) {
236:                if (this .plot != null) {
237:                    this .plot.setUnits(i);
238:                }
239:            }
240:
241:            /**
242:             * Sets the outline paint.
243:             *
244:             * @param p  the paint.
245:             */
246:            public void setOutlinePaint(Paint p) {
247:                if (this .plot != null) {
248:                    this .plot.setOutlinePaint(p);
249:                }
250:            }
251:
252:            /**
253:             * Sets the foreground color.
254:             *
255:             * @param fg  the foreground color.
256:             */
257:            public void setForeground(Color fg) {
258:                super .setForeground(fg);
259:                if (this .plot != null) {
260:                    this .plot.setThermometerPaint(fg);
261:                }
262:            }
263:
264:            /**
265:             * Sets the background color.
266:             *
267:             * @param bg  the background color.
268:             */
269:            public void setBackground(Color bg) {
270:                super .setBackground(bg);
271:                if (this .plot != null) {
272:                    this .plot.setBackgroundPaint(bg);
273:                }
274:                if (this .chart != null) {
275:                    this .chart.setBackgroundPaint(bg);
276:                }
277:                if (this .panel != null) {
278:                    this .panel.setBackground(bg);
279:                }
280:            }
281:
282:            /**
283:             * Sets the value font.
284:             *
285:             * @param f  the font.
286:             */
287:            public void setValueFont(Font f) {
288:                if (this .plot != null) {
289:                    this .plot.setValueFont(f);
290:                }
291:            }
292:
293:            /**
294:             * Returns the tick label font.
295:             *
296:             * @return The tick label font.
297:             */
298:            public Font getTickLabelFont() {
299:                ValueAxis axis = this .plot.getRangeAxis();
300:                return axis.getTickLabelFont();
301:            }
302:
303:            /**
304:             * Sets the tick label font.
305:             *
306:             * @param font  the font.
307:             */
308:            public void setTickLabelFont(Font font) {
309:                ValueAxis axis = this .plot.getRangeAxis();
310:                axis.setTickLabelFont(font);
311:            }
312:
313:            /**
314:             * Increases or decreases the tick font size.
315:             *
316:             * @param delta  the change in size.
317:             */
318:            public void changeTickFontSize(int delta) {
319:                Font f = getTickLabelFont();
320:                String fName = f.getFontName();
321:                Font newFont = new Font(fName, f.getStyle(),
322:                        (f.getSize() + delta));
323:                setTickLabelFont(newFont);
324:            }
325:
326:            /**
327:             * Sets the tick font style.
328:             *
329:             * @param style  the style.
330:             */
331:            public void setTickFontStyle(int style) {
332:                Font f = getTickLabelFont();
333:                String fName = f.getFontName();
334:                Font newFont = new Font(fName, style, f.getSize());
335:                setTickLabelFont(newFont);
336:            }
337:
338:            /**
339:             * Sets the flag that controls whether or not the display range follows the
340:             * data value.
341:             *
342:             * @param flag  the new value of the flag.
343:             */
344:            public void setFollowDataInSubranges(boolean flag) {
345:                this .plot.setFollowDataInSubranges(flag);
346:            }
347:
348:            /**
349:             * Sets the flag that controls whether or not value lines are displayed.
350:             *
351:             * @param b  the new flag value.
352:             */
353:            public void setShowValueLines(boolean b) {
354:                this .plot.setShowValueLines(b);
355:            }
356:
357:            /**
358:             * Sets the location for the axis.
359:             * 
360:             * @param location  the location.
361:             */
362:            public void setShowAxisLocation(int location) {
363:                this .plot.setAxisLocation(location);
364:            }
365:
366:            /**
367:             * Returns the location for the axis.
368:             * 
369:             * @return The location.
370:             */
371:            public int getShowAxisLocation() {
372:                return this.plot.getAxisLocation();
373:            }
374:
375:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.