📄 thermometerdemo.java
字号:
/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2004, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * ThermometerDemo.java * -------------------- * (C) Copyright 2002-2004, by Australian Antarctic Division and Contributors. * * Original Author: Bryan Scott (for Australian Antarctic Division). * Contributor(s): David Gilbert (for Object Refinery Limited); * * $Id: ThermometerDemo.java,v 1.13 2004/04/26 19:12:03 taqua Exp $ * * Changes (since 24-Apr-2002) * --------------------------- * 24-Apr-2002 : added standard source header (DG); * 17-Sep-2002 : fixed errors reported by Checkstyle 2.3 (DG); * 19-Nov-2003 : Added support for Left value display * */package org.jfree.chart.demo;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Dimension;import java.awt.Font;import java.awt.GridLayout;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.text.DecimalFormat;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JFrame;import javax.swing.JPanel;import org.jfree.chart.ChartPanel;import org.jfree.chart.JFreeChart;import org.jfree.chart.plot.JThermometer;import org.jfree.chart.plot.MeterPlot;import org.jfree.data.DefaultValueDataset;/** * A demonstration application for the thermometer plot. * * @author Bryan Scott */public class ThermometerDemo extends JPanel { /** Options for the value label position combo box. */ protected static final String[] OPTIONS = { "None", "Right", "Left", "Bulb"}; /** Axis position options. */ protected static final String[] AXIS_OPTIONS = { "None", "Right", "Left"}; /** The dataset. */ private DefaultValueDataset data = new DefaultValueDataset(20.0); /** The meter plot (dial). */ private MeterPlot meterplot = new MeterPlot(this.data); /** The meter chart (dial). */ private JFreeChart meterchart = new JFreeChart("Meter Chart", JFreeChart.DEFAULT_TITLE_FONT, this.meterplot, false); /** The meter panel. */ private ChartPanel panelMeter = new ChartPanel(this.meterchart); /** Panel 1. */ private JPanel jPanel1 = new JPanel(); /** Increment button for thermometer ?. */ private JButton butUp3 = new JButton(); /** Decrement button for thermometer ?. */ private JButton butDown3 = new JButton(); /** Panel 2. */ private JPanel jPanel2 = new JPanel(); /** Borderlayout 2. */ private BorderLayout borderLayout2 = new BorderLayout(); /** Panel 3. */ private JPanel jPanel3 = new JPanel(); /** Borderlayout 3. */ private BorderLayout borderLayout3 = new BorderLayout(); /** Panel 4. */ private JPanel jPanel4 = new JPanel(); /** Decrement button for thermometer ?. */ private JButton butDown2 = new JButton(); /** Increment button for thermometer ?. */ private JButton butUp2 = new JButton(); /** Panel 5. */ private JPanel jPanel5 = new JPanel(); /** Grid layout 1. */ private GridLayout gridLayout1 = new GridLayout(); /** Panel 6. */ private JPanel jPanel6 = new JPanel(); /** Increment button for thermometer ?. */ private JButton butUp1 = new JButton(); /** Decrement button for thermometer ?. */ private JButton butDown1 = new JButton(); /** Thermometer 1. */ private JThermometer thermo1 = new JThermometer(); /** Thermometer 2. */ private JThermometer thermo2 = new JThermometer(); /** Thermometer 2. */ private JThermometer thermo3 = new JThermometer(); /** Array of thermometers. */ private JThermometer[] thermo = new JThermometer[3]; /** Borderlayout 1. */ private BorderLayout borderLayout1 = new BorderLayout(); /** Panel 7. */ private JPanel jPanel7 = new JPanel(); /** Panel 8. */ private JPanel jPanel8 = new JPanel(); /** Panel 9. */ private JPanel jPanel9 = new JPanel(); /** Grid layout 2. */ private GridLayout gridLayout2 = new GridLayout(); /** Grid layout 3. */ private GridLayout gridLayout3 = new GridLayout(); /** Grid layout 4. */ private GridLayout gridLayout4 = new GridLayout(); /** Combo box 1 for value label position. */ private JComboBox pickShow0 = new JComboBox(OPTIONS); /** Combo box 2 for value label position. */ private JComboBox pickShow1 = new JComboBox(OPTIONS); /** Combo box 3 for value label position. */ private JComboBox pickShow2 = new JComboBox(OPTIONS); /** Combo box 1 for axis position. */ private JComboBox pickAxis0 = new JComboBox(AXIS_OPTIONS); /** Combo box 2 for axis position. */ private JComboBox pickAxis1 = new JComboBox(AXIS_OPTIONS); /** Combo box 3 for axis position. */ private JComboBox pickAxis2 = new JComboBox(AXIS_OPTIONS); /** An array of combo boxes. */ private JComboBox[] pickShow = new JComboBox[3]; /** An array of combo boxes. */ private JComboBox[] pickAxis = new JComboBox[3]; /** Panel 10. */ private JPanel jPanel10 = new JPanel(); /** Borderlayout 4. */ private BorderLayout borderLayout4 = new BorderLayout(); /** Panel 11. */ private JPanel jPanel11 = new JPanel(); /** Decrement button for thermometer ?. */ private JButton butDown4 = new JButton(); /** Increment button for thermometer ?. */ private JButton butUp4 = new JButton(); /** * Default constructor. */ public ThermometerDemo() { try { jbInit(); } catch (Exception ex) { ex.printStackTrace(); } } // **************************************************************************** // * COMMERCIAL SUPPORT / JFREECHART DEVELOPER GUIDE * // * Please note that commercial support and documentation is available from: * // * * // * http://www.object-refinery.com/jfreechart/support.html * // * * // * This is not only a great service for developers, but is a VERY IMPORTANT * // * source of funding for the JFreeChart project. Please support us so that * // * we can continue developing free software. * // **************************************************************************** /** * Initialises the class. * * @throws Exception for any exception. */ void jbInit() throws Exception { //data.setRange(new Double(-20), new Double(20)); this.thermo[0] = this.thermo1; this.thermo[1] = this.thermo2; this.thermo[2] = this.thermo3; this.thermo[0].setValue(0.0); this.thermo[1].setValue(0.2); this.thermo[2].setValue(0.3); this.thermo[0].setBackground(Color.white); this.thermo[2].setBackground(Color.white); this.thermo[0].setOutlinePaint(null); this.thermo[1].setOutlinePaint(null);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -