?? contourplotdemo2.java
字號:
/* ======================================
* JFreeChart : a free Java chart library
* ======================================
*
* Project Info: http://www.jfree.org/jfreechart/index.html
* Project Lead: David Gilbert (david.gilbert@object-refinery.com);
*
* (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
*
* 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.
*
* ---------------------
* ContourPlotDemo2.java
* ---------------------
* (C) Copyright 2003, by David M. O'Donnell and Contributors.
*
* Original Author: David M. O'Donnell;
* Contributor(s): David Gilbert (for Object Refinery Limited);
*
* $Id: ContourPlotDemo2.java,v 1.12 2003/09/03 15:08:49 mungady Exp $
*
* Changes
* -------
* 22-Apr-2003 : Added standard header (DG);
*
*/
package org.jfree.chart.demo;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.util.Date;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ClipPath;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.annotations.XYTextAnnotation;
import org.jfree.chart.axis.ColorBar;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.LogarithmicAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.ContourPlot;
import org.jfree.data.ContourDataset;
import org.jfree.data.DefaultContourDataset;
import org.jfree.data.NonGridContourDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
/**
* A demonstration application to illustrate ContourPlot.
* Command line options exist to control different plot properties
* such as colorbar orientation, etc. List of options are available
* by launching with the -? option, e.g., ContourPlotDemo -?
*
* @author DMO
*/
public class ContourPlotDemo2 extends ApplicationFrame {
/** The x axis. */
private ValueAxis xAxis = null;
/** The y axis. */
private NumberAxis yAxis = null;
/** The z axis. */
private ColorBar zColorBar = null;
/** A flag controlling the orientation of the z axis. */
private static boolean zIsVertical = false;
/** A flag indicating whether or not the x-values are dates. */
private static boolean xIsDate = false;
/** ??. */
private static boolean asPoints = false;
/** Logarithmic x-axis? */
private static boolean xIsLog = false;
/** Logarithmic y axis? */
private static boolean yIsLog = false;
/** Logarithmic z axis? */
private static boolean zIsLog = false;
/** Inverted x axis? */
private static boolean xIsInverted = true;
/** Inverted y axis? */
private static boolean yIsInverted = false;
/** Inverted z axis? */
private static boolean zIsInverted = false;
/** Annotate? */
private static boolean annotate = false;
/** Number of x intervals. */
private static int numX = 10;
/** Number of y intervals. */
private static int numY = 20;
/** The plot ratio. */
private static double ratio = 0.0;
/** Temp data storage. */
private double[] tmpDoubleY = null;
/** Temp data storage. */
private double[] tmpDoubleX = null;
/** Temp data storage. */
private double[] tmpDoubleZ = null;
/** X outline. */
private double[] xOutline = null;
/** Y outline. */
private double[] yOutline = null;
/** Draw the outline? */
static boolean drawOutline = false;
/** Fill the outline? */
static boolean fillOutline = false;
/** ??. */
static int power = 4;
/**
* Constructs a new demonstration application.
*
* @param title the frame title.
*/
public ContourPlotDemo2(String title) {
super(title);
JFreeChart chart = createContourPlot();
ChartPanel panel = new ChartPanel(chart, true, true, true, true, true);
panel.setPreferredSize(new java.awt.Dimension(1000, 800));
panel.setMaximumDrawHeight(100000); //stop chartpanel from scaling
panel.setMaximumDrawWidth(100000); //stop chartpanel from scaling
panel.setHorizontalZoom(true);
panel.setVerticalZoom(true);
panel.setFillZoomRectangle(true);
setContentPane(panel);
}
/**
* Creates a ContourPlot chart.
*
* @return the ContourPlot chart.
*/
private JFreeChart createContourPlot() {
String title = "Contour Plot";
String xAxisLabel = "X Values";
String yAxisLabel = "Y Values";
String zAxisLabel = "Color Values";
if (xIsDate) {
xAxis = new DateAxis(xAxisLabel);
xIsLog = false; // force axis to be linear when displaying dates
}
else {
if (xIsLog) {
xAxis = new LogarithmicAxis(xAxisLabel);
}
else {
xAxis = new NumberAxis(xAxisLabel);
}
}
if (yIsLog) {
yAxis = new LogarithmicAxis(yAxisLabel);
}
else {
yAxis = new NumberAxis(yAxisLabel);
}
if (zIsLog) {
zColorBar = new ColorBar(zAxisLabel);
}
else {
zColorBar = new ColorBar(zAxisLabel);
}
if (xAxis instanceof NumberAxis) {
((NumberAxis) xAxis).setAutoRangeIncludesZero(false);
((NumberAxis) xAxis).setInverted(xIsInverted);
}
yAxis.setAutoRangeIncludesZero(false);
yAxis.setInverted(yIsInverted);
if (!xIsDate) {
((NumberAxis) xAxis).setLowerMargin(0.0);
((NumberAxis) xAxis).setUpperMargin(0.0);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -