⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 symbolicxyplotdemo.java

📁 这是一个segy数据显示程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* =========================================================== * 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.] * * ----------------------- * SymbolicXYPlotDemo.java * ----------------------- * (C) Copyright 2002-2004, by Anthony Boulestreau and Contributors. * * Original Author:  Anthony Boulestreau; * Contributor(s):   David Gilbert (for Object Refinery Limited); * * * Changes * ------- * 29-Mar-2002 : Version 1 (AB); * 09-Apr-2002 : Minor changes reflecting the API change for XYItemRenderer (DG); * 23-Apr-2002 : Updated to reflect changes in the combined plot classes (DG); * 11-Oct-2002 : Fixed errors reported by Checkstyle (DG); * */package org.jfree.chart.demo;import java.awt.Color;import java.awt.GradientPaint;import java.lang.reflect.Array;import javax.swing.JFrame;import org.jfree.chart.ChartFrame;import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.SymbolicAxis;import org.jfree.chart.labels.SymbolicXYItemLabelGenerator;import org.jfree.chart.plot.CombinedDomainXYPlot;import org.jfree.chart.plot.CombinedRangeXYPlot;import org.jfree.chart.plot.XYPlot;import org.jfree.chart.renderer.StandardXYItemRenderer;import org.jfree.chart.renderer.XYItemRenderer;import org.jfree.data.CombinedDataset;import org.jfree.data.SubSeriesDataset;import org.jfree.data.XYDataset;import org.jfree.data.XisSymbolic;import org.jfree.data.YisSymbolic;import org.jfree.ui.RefineryUtilities;/** * A demonstration application for the symbolic XY plots. * * @author Anthony Boulestreau */public class SymbolicXYPlotDemo {    /**     * Creates a XY graph with symbolic value on X and Y axis.     *     * @param title  the title.     * @param xAxisLabel  the x axis label.     * @param yAxisLabel  the y axis label.     * @param data  the dataset.     * @param legend  create a legend?     *     * @return a chart.     */    public static JFreeChart createXYSymbolicPlot(final String title, final String xAxisLabel,                                                  final String yAxisLabel, final XYDataset data,                                                  final boolean legend) {        final SymbolicAxis xSymbolicAxis            = new SymbolicAxis(xAxisLabel, ((XisSymbolic) data).getXSymbolicValues());        final SymbolicAxis ySymbolicAxis            = new SymbolicAxis(yAxisLabel, ((YisSymbolic) data).getYSymbolicValues());        final XYPlot plot = new XYPlot(data, xSymbolicAxis, ySymbolicAxis, null);        final XYItemRenderer renderer = new StandardXYItemRenderer(            StandardXYItemRenderer.SHAPES, new SymbolicXYItemLabelGenerator()        );        plot.setRenderer(renderer);        final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);        return chart;    }    /**     * Creates a sample dataset.     *     * @return a dataset.     */    public static SampleYSymbolicDataset createYSymbolicSample1() {        final String[] sData = {"Lion", "Elephant", "Monkey", "Hippopotamus", "Giraffe"};        final SampleYSymbolicDataset data = new SampleYSymbolicDataset(            "AY Sample", 20, sData, 4, 20, new String[] {"Fall", "Spring", "Summer", "Winter"}        );        return data;    }    /**     * Creates a sample dataset.     *     * @return a dataset.     */    public static SampleYSymbolicDataset createYSymbolicSample2() {        final String[] sData = {"Giraffe", "Gazelle", "Zebra", "Gnu"};        final SampleYSymbolicDataset data = new SampleYSymbolicDataset(            "BY Sample", 40, sData, 4, 10, new String[] {"Fall", "Spring", "Summer", "Winter"}        );        return data;    }    /**     * Creates a sample dataset.     *     * @return a dataset.     */    public static SampleXYSymbolicDataset createXYSymbolicSample1() {        final String[] xsData = {"Atmosphere", "Continental Ecosystem",                           "Limnic Ecosystem", "Marine Ecosystem"};        final String[] ysData = {"Ionizing radiations", "Thermic pollutants", "Hydrocarbon",                           "Synthetic materials", "Pesticides", "Detergent",                           "Synthetic organic materials", "Sulphur", "Nitrate", "Phosphate",                           "Heavy metals", "Fluors", "Aerosols", "Dead organic materials",                           "Pathogen micro-organisms"};        final int[][] xd = {            {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,             2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}        };        final int[][] yd = {            {0, 2, 3, 7, 10, 11, 12, 14, 0, 2, 3, 4, 7, 8, 9, 10, 11, 12, 14, 0, 1, 2, 3,             4, 5, 7, 8, 9, 10, 13, 14, 0, 1, 2, 3, 4, 5, 8, 9, 10, 13, 14}        };        final Integer[][] xData = (Integer[][]) toArray(xd);        final Integer[][] yData = (Integer[][]) toArray(yd);        final SampleXYSymbolicDataset xySymbolicData = new SampleXYSymbolicDataset(            "AXY Sample", xData, yData, xsData, ysData, new String[] {"A"}        );        return xySymbolicData;    }    /**     * Creates a sample dataset.     *     * @return a dataset.     */    public static SampleXYSymbolicDataset createXYSymbolicSample2() {        final String[] xsData = {"Physic pollutant", "Chemical pollutant", "Biological pollutant"};        final String[] ysData = {"Ionizing radiations", "Thermic pollutants", "Hydrocarbon",                            "Synthetic materials", "Pesticides", "Detergent",                            "Synthetic organic materials", "Sulphur", "Nitrate", "Phosphate",                            "Heavy metals", "Fluors", "Aerosols", "Dead organic materials",                            "Pathogen micro-organisms"};        final int[][] xd = {{0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2}};        final int[][] yd = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}};        final Integer[][] xData = (Integer[][]) toArray(xd);        final Integer[][] yData = (Integer[][]) toArray(yd);        final SampleXYSymbolicDataset xySymbolicData = new SampleXYSymbolicDataset("BXY Sample",            xData, yData, xsData, ysData, new String[] {"B"});        return xySymbolicData;    }    /**     * Displays an XYPlot with symbolic axes.     *     * @param frameTitle  the frame title.     * @param data  the dataset.     * @param chartTitle  the chart title.     * @param xAxisLabel  the x axis label.     * @param yAxisLabel  the y axis label.     */    private static void displayXYSymbolic(final String frameTitle,                                          final XYDataset data, final String chartTitle,                                          final String xAxisLabel, final String yAxisLabel) {        final JFreeChart chart = createXYSymbolicPlot(            chartTitle, xAxisLabel, yAxisLabel, data, true        );        chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.green));        final JFrame frame = new ChartFrame(frameTitle, chart);        frame.pack();        RefineryUtilities.positionFrameRandomly(frame);        frame.show();    }   /**    * Displays an overlaid XYPlot with X and Y symbolic data.    *    * @param frameTitle  the frame title.    * @param data1  the dataset 1.    * @param data2  the dataset 2.    */    private static void displayXYSymbolicOverlaid(final String frameTitle,                                                  final XYDataset data1, final XYDataset data2) {        final String title = "Pollutant Overlaid";        final String xAxisLabel = "Contamination and Type";        final String yAxisLabel = "Pollutant";        // combine the x symbolic values of the two data sets        final String[] combinedXSymbolicValues            = SampleXYSymbolicDataset.combineXSymbolicDataset((XisSymbolic) data1,                                                              (XisSymbolic) data2);        // combine the y symbolic values of the two data sets        final String[] combinedYSymbolicValues            = SampleXYSymbolicDataset.combineYSymbolicDataset((YisSymbolic) data1,                                                              (YisSymbolic) data2);        // make master dataset...        final CombinedDataset data = new CombinedDataset();        data.add(data1);        data.add(data2);        // decompose data...        final XYDataset series0 = new SubSeriesDataset(data, 0);        final XYDataset series1 = new SubSeriesDataset(data, 1);        // create overlaid plot...        final SymbolicAxis hsymbolicAxis = new SymbolicAxis(xAxisLabel, combinedXSymbolicValues);        final SymbolicAxis vsymbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues);        final XYItemRenderer renderer1 = new StandardXYItemRenderer(            StandardXYItemRenderer.SHAPES, null        );        final XYPlot plot = new XYPlot(series0, hsymbolicAxis, vsymbolicAxis, renderer1);        final XYItemRenderer renderer2 = new StandardXYItemRenderer(            StandardXYItemRenderer.SHAPES, null        );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -