<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    大夢想家

    5年開發(fā)工程師,2年實(shí)施經(jīng)理,X年售前顧問,......
    數(shù)據(jù)加載中……
    SWT中使用JFreeChart(無需SWT_AWT)
        好像從1.03開始Jfc就已經(jīng)提供了在SWT中使用JFC的專用包和類,只是沒有人寫這些東西而已~今天我就貼一些Demo,以后再也不用SWT_AWT了~
      1/* ===========================================================
      2 * JFreeChart : a free chart library for the Java(tm) platform
      3 * ===========================================================
      4 *
      5 * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
      6 *
      7 * Project Info:  http://www.jfree.org/jfreechart/index.html
      8 *
      9 * This library is free software; you can redistribute it and/or modify it 
     10 * under the terms of the GNU Lesser General Public License as published by 
     11 * the Free Software Foundation; either version 2.1 of the License, or 
     12 * (at your option) any later version.
     13 *
     14 * This library is distributed in the hope that it will be useful, but 
     15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
     16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
     17 * License for more details.
     18 *
     19 * You should have received a copy of the GNU Lesser General Public
     20 * License along with this library; if not, write to the Free Software
     21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
     22 * USA.  
     23 *
     24 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
     25 * in the United States and other countries.]
     26 *
     27 * ---------------------
     28 * SWTBarChartDemo1.java
     29 * ---------------------
     30 * (C) Copyright 2006, 2007, by Object Refinery Limited and Contributors.
     31 *
     32 * Original Author:  David Gilbert (for Object Refinery Limited);
     33 * Contributor(s):
     34 *
     35 * Changes
     36 * -------
     37 * 23-Aug-2006 : New class (DG);
     38 * 
     39 */

     40
     41package org.jfree.experimental.chart.swt.demo;
     42
     43import java.awt.Color;
     44
     45import org.eclipse.swt.SWT;
     46import org.eclipse.swt.layout.FillLayout;
     47import org.eclipse.swt.widgets.Display;
     48import org.eclipse.swt.widgets.Shell;
     49import org.jfree.chart.ChartFactory;
     50import org.jfree.chart.JFreeChart;
     51import org.jfree.chart.axis.CategoryAxis;
     52import org.jfree.chart.axis.CategoryLabelPositions;
     53import org.jfree.chart.axis.NumberAxis;
     54import org.jfree.chart.plot.CategoryPlot;
     55import org.jfree.chart.plot.PlotOrientation;
     56import org.jfree.chart.renderer.category.BarRenderer;
     57import org.jfree.data.category.CategoryDataset;
     58import org.jfree.data.category.DefaultCategoryDataset;
     59import org.jfree.experimental.chart.swt.ChartComposite;
     60
     61/**
     62 * An SWT demo.
     63 */

     64public class SWTBarChartDemo1 {
     65    
     66    /**
     67     * Returns a sample dataset.
     68     * 
     69     * @return The dataset.
     70     */

     71    private static CategoryDataset createDataset() {
     72        
     73        // row keys
     74        String series1 = "First";
     75        String series2 = "Second";
     76        String series3 = "Third";
     77
     78        // column keys
     79        String category1 = "Category 1";
     80        String category2 = "Category 2";
     81        String category3 = "Category 3";
     82        String category4 = "Category 4";
     83        String category5 = "Category 5";
     84
     85        // create the dataset
     86        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
     87
     88        dataset.addValue(1.0, series1, category1);
     89        dataset.addValue(4.0, series1, category2);
     90        dataset.addValue(3.0, series1, category3);
     91        dataset.addValue(5.0, series1, category4);
     92        dataset.addValue(5.0, series1, category5);
     93
     94        dataset.addValue(5.0, series2, category1);
     95        dataset.addValue(7.0, series2, category2);
     96        dataset.addValue(6.0, series2, category3);
     97        dataset.addValue(8.0, series2, category4);
     98        dataset.addValue(4.0, series2, category5);
     99
    100        dataset.addValue(4.0, series3, category1);
    101        dataset.addValue(3.0, series3, category2);
    102        dataset.addValue(2.0, series3, category3);
    103        dataset.addValue(3.0, series3, category4);
    104        dataset.addValue(6.0, series3, category5);
    105        
    106        return dataset;
    107        
    108    }

    109    
    110    /**
    111     * Creates a sample chart.
    112     * 
    113     * @param dataset  the dataset.
    114     * 
    115     * @return The chart.
    116     */

    117    private static JFreeChart createChart(CategoryDataset dataset) {
    118        
    119        // create the chart
    120        JFreeChart chart = ChartFactory.createBarChart(
    121            "Bar Chart Demo",         // chart title
    122            "Category",               // domain axis label
    123            "Value",                  // range axis label
    124            dataset,                  // data
    125            PlotOrientation.VERTICAL, // orientation
    126            true,                     // include legend
    127            true,                     // tooltips?
    128            false                     // URLs?
    129        );
    130
    131        // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART
    132
    133        // set the background color for the chart
    134        chart.setBackgroundPaint(Color.white);
    135
    136        // get a reference to the plot for further customisation
    137        CategoryPlot plot = (CategoryPlot) chart.getPlot();
    138        plot.setBackgroundPaint(Color.lightGray);
    139        plot.setDomainGridlinePaint(Color.white);
    140        plot.setDomainGridlinesVisible(true);
    141        plot.setRangeGridlinePaint(Color.white);
    142
    143        // set the range axis to display integers only
    144        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    145        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    146
    147        // disable bar outlines
    148        BarRenderer renderer = (BarRenderer) plot.getRenderer();
    149        renderer.setDrawBarOutline(false);
    150
    151        CategoryAxis domainAxis = plot.getDomainAxis();
    152        domainAxis.setCategoryLabelPositions(
    153            CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
    154        );
    155        // OPTIONAL CUSTOMISATION COMPLETED.
    156        
    157        return chart;
    158        
    159    }

    160    
    161    /**
    162     * Starting point for the demonstration application.
    163     *
    164     * @param args  ignored.
    165     */

    166    public static void main( String[] args ) 
    167    {
    168        JFreeChart chart = createChart(createDataset());
    169        Display display = new Display();
    170        Shell shell = new Shell(display);
    171        shell.setSize(600300);
    172        shell.setLayout(new FillLayout());
    173        shell.setText("Test for jfreechart running with SWT");
    174        final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart,
    175                true);
    176        frame.pack();
    177        shell.open();
    178        while (!shell.isDisposed()) {
    179            if (!display.readAndDispatch())
    180                display.sleep();
    181        }

    182    }

    183
    184}

    185
    186
    187
    這個是JFC里面自帶的一個例子,例子里面使用了一個ChartComposite來放置chart對象~這樣對使用者來說更加方便了,其實(shí)JFC的SWT包下還有好幾個很好用的類,只是沒有文檔而已~
    更重要的是SWT_AWT主要是將AWT嵌入SWT中,而ChartComposite則是將chart對象直接轉(zhuǎn)換為SWT中的東東,連右鍵都是SWT的了~

    客戶虐我千百遍,我待客戶如初戀!

    posted on 2007-08-21 09:22 阿南 閱讀(3997) 評論(2)  編輯  收藏 所屬分類: 西安java用戶群Eclipse-SWT

    評論

    # re: SWT中使用JFreeChart(無需SWT_AWT)[未登錄] 2007-08-21 17:37 寒武紀(jì)

    這樣應(yīng)該比SWT_AWT橋接方式要穩(wěn)定。
      回復(fù)  更多評論    

    # re: SWT中使用JFreeChart(無需SWT_AWT) 2012-01-31 15:27 cala

    @寒武紀(jì)
    我的JFreeChart怎么沒有ChartComposite!! 求指點(diǎn)!!!
      回復(fù)  更多評論    
    主站蜘蛛池模板: 91麻豆最新在线人成免费观看| 亚洲伊人久久大香线蕉结合| 久久亚洲中文字幕精品一区四| 又大又硬又爽免费视频| 免费A级毛片无码久久版| 免费jjzz在在线播放国产| 国产亚洲福利一区二区免费看| 国产精品黄页在线播放免费| 又粗又大又长又爽免费视频| 免费va人成视频网站全| 亚洲综合最新无码专区| 久久夜色精品国产亚洲av| 亚洲精品国产成人片| 亚洲av鲁丝一区二区三区| 97se亚洲综合在线| 亚洲一区动漫卡通在线播放| 日本亚洲免费无线码| 极品色天使在线婷婷天堂亚洲| 深夜a级毛片免费无码| 韩国免费A级毛片久久| 午夜视频在线免费观看| 国拍在线精品视频免费观看| 免费无码又爽又刺激高潮| 亚洲国产av无码精品| 日韩亚洲人成在线综合日本| 亚洲卡一卡2卡三卡4卡无卡三| 亚洲国产成人精品久久| 亚洲成a人无码亚洲成av无码| 暖暖免费中文在线日本| 日批视频网址免费观看| 在线看片韩国免费人成视频| 国产日产成人免费视频在线观看| 久久精品国产亚洲Aⅴ蜜臀色欲| 亚洲国产精品久久久久网站| 精品亚洲AV无码一区二区三区| 美国毛片亚洲社区在线观看| 中文字幕在线成人免费看| 99无码人妻一区二区三区免费 | 亚洲影院天堂中文av色| 特级av毛片免费观看| 久久99热精品免费观看动漫|