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

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

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

    大夢(mèng)想家

    5年開發(fā)工程師,2年實(shí)施經(jīng)理,X年售前顧問,......
    數(shù)據(jù)加載中……
    SWT中使用JFreechart(例子)
      1package com.glnpu.dmp.test;
      2
      3import java.awt.Color;
      4import java.awt.Font;
      5import java.awt.Frame;
      6import java.util.Calendar;
      7import java.util.Date;
      8
      9import org.eclipse.jface.window.ApplicationWindow;
     10import org.eclipse.swt.SWT;
     11import org.eclipse.swt.awt.SWT_AWT;
     12import org.eclipse.swt.graphics.Point;
     13import org.eclipse.swt.widgets.Composite;
     14import org.eclipse.swt.widgets.Control;
     15import org.eclipse.swt.widgets.Display;
     16import org.eclipse.swt.widgets.Shell;
     17import org.eclipse.swt.widgets.TabFolder;
     18import org.eclipse.swt.widgets.TabItem;
     19import org.jfree.chart.ChartFactory;
     20import org.jfree.chart.ChartPanel;
     21import org.jfree.chart.JFreeChart;
     22import org.jfree.chart.plot.PiePlot;
     23import org.jfree.chart.title.TextTitle;
     24import org.jfree.data.category.IntervalCategoryDataset;
     25import org.jfree.data.gantt.Task;
     26import org.jfree.data.gantt.TaskSeries;
     27import org.jfree.data.gantt.TaskSeriesCollection;
     28import org.jfree.data.general.DefaultPieDataset;
     29
     30public class Test extends ApplicationWindow {
     31
     32    /**
     33     * Create the application window
     34     */

     35    public Test() {
     36        super(null);
     37        addToolBar(SWT.FLAT | SWT.WRAP);
     38        addMenuBar();
     39        addStatusLine();
     40    }

     41
     42    /**
     43     * Create contents of the application window
     44     * 
     45     * @param parent
     46     */

     47    @Override
     48    protected Control createContents(Composite parent) {
     49        TabFolder tf = new TabFolder(parent, SWT.TOP);
     50        TabItem ti = new TabItem(tf, SWT.NULL);
     51        ti.setText("分類");
     52        Composite composite = new Composite(tf, SWT.NO_BACKGROUND
     53                | SWT.EMBEDDED);
     54        Frame frame = SWT_AWT.new_Frame(composite);
     55        frame.add(new ChartPanel(createBarChart()));
     56        ti.setControl(composite);
     57        TabItem ti1 = new TabItem(tf, SWT.NULL);
     58        ti1.setText("項(xiàng)目組");
     59        Composite composite1 = new Composite(tf, SWT.NO_BACKGROUND
     60                | SWT.EMBEDDED);
     61        Frame frame1 = SWT_AWT.new_Frame(composite1);
     62        frame1.add(new ChartPanel(createGanttChart()));
     63        ti1.setControl(composite1);
     64        tf.setSelection(0);
     65        return tf;
     66    }

     67
     68    /**
     69     * 方法名稱: 內(nèi)容摘要:
     70     * 
     71     * @return
     72     * @return JFreeChart
     73     * @throws
     74     */

     75    private JFreeChart createGanttChart() {
     76        String title = "Gantt測(cè)試";
     77        IntervalCategoryDataset dataset = createSampleDataset();
     78
     79        JFreeChart jfc = ChartFactory.createGanttChart(title, "項(xiàng)目各階段詳細(xì)實(shí)施計(jì)劃",
     80                "項(xiàng)目周期", dataset, falsefalsefalse);
     81
     82        return jfc;
     83    }

     84
     85    /**
     86      * 方法名稱:
     87      * 內(nèi)容摘要:創(chuàng)建gantt內(nèi)容
     88      *
     89      * @return
     90      * @return IntervalCategoryDataset
     91      * @throws
     92     */

     93    private IntervalCategoryDataset createSampleDataset() {
     94        TaskSeries s1 = new TaskSeries("日程表");
     95
     96        Task t1 = new Task("項(xiàng)目立項(xiàng)", date(1, Calendar.APRIL, 2001), date(5,
     97                Calendar.APRIL, 2001));
     98        t1.setPercentComplete(1.00);
     99        
    100        Task t2 = new Task("項(xiàng)目立項(xiàng)討論", date(6, Calendar.APRIL, 2001), date(19,
    101                Calendar.APRIL, 2001));
    102        
    103        s1.add(t1);
    104        s1.add(t2);
    105        
    106        
    107        final Task t3 = new Task(
    108                "需求分析"
    109                date(10, Calendar.APRIL, 2001), date(5, Calendar.MAY, 2001)
    110            );
    111            final Task st31 = new Task(
    112                "需求1"
    113                date(10, Calendar.APRIL, 2001), date(25, Calendar.APRIL, 2001)
    114            );
    115            st31.setPercentComplete(1.0);
    116            final Task st32 = new Task(
    117                "需求2"
    118                date(1, Calendar.MAY, 2001), date(5, Calendar.MAY, 2001)
    119            );
    120            st32.setPercentComplete(1.0);
    121            t3.addSubtask(st31);
    122            t3.addSubtask(st32);
    123            s1.add(t3);
    124        
    125        
    126        
    127        final TaskSeriesCollection collection = new TaskSeriesCollection();
    128        collection.add(s1);
    129
    130        return collection;
    131    }

    132
    133    /** */
    134    /**
    135     * Utility method for creating <code>Date</code> objects.
    136     * 
    137     * @param day
    138     *            日
    139     * @param month
    140     *            月
    141     * @param year
    142     *            年
    143     * 
    144     * @return a date.
    145     */

    146    private static Date date(final int day, final int month, final int year) {
    147
    148        final Calendar calendar = Calendar.getInstance();
    149        calendar.set(year, month, day);
    150
    151        final Date result = calendar.getTime();
    152        return result;
    153
    154    }

    155
    156    /**
    157     * 方法名稱: 內(nèi)容摘要:餅圖測(cè)試
    158     * 
    159     * @return
    160     * @return JFreeChart
    161     * @throws
    162     */

    163    private JFreeChart createBarChart() {
    164        String title = "空調(diào)2002年市場(chǎng)占有率";
    165        DefaultPieDataset piedata = new DefaultPieDataset();
    166        piedata.setValue("聯(lián)想"27.3);
    167        piedata.setValue("長(zhǎng)城"12.2);
    168        piedata.setValue("海爾"5.5);
    169        piedata.setValue("美的"17.1);
    170        piedata.setValue("松下"9.0);
    171        piedata.setValue("科龍"19.0);
    172        JFreeChart chart = ChartFactory.createPieChart(title, piedata, true,
    173                truetrue);
    174        chart.setTitle(new TextTitle(title, new Font("隸書", Font.ITALIC, 15)));
    175        chart.addSubtitle(new TextTitle("2002財(cái)年分析"new Font("隸書", Font.ITALIC,
    176                12)));
    177        chart.setBackgroundPaint(Color.white);
    178        PiePlot pie = (PiePlot) chart.getPlot();
    179        pie.setBackgroundPaint(Color.white);
    180        pie.setBackgroundAlpha(0.6f);
    181        pie.setForegroundAlpha(0.90f);
    182        return chart;
    183    }

    184
    185    /**
    186     * Launch the application
    187     * 
    188     * @param args
    189     */

    190    public static void main(String args[]) {
    191        try {
    192            Test window = new Test();
    193            window.setBlockOnOpen(true);
    194            window.open();
    195            Display.getCurrent().dispose();
    196        }
     catch (Exception e) {
    197            e.printStackTrace();
    198        }

    199    }

    200
    201    /**
    202     * Configure the shell
    203     * 
    204     * @param newShell
    205     */

    206    @Override
    207    protected void configureShell(Shell newShell) {
    208        super.configureShell(newShell);
    209        newShell.setText("New Application");
    210    }

    211
    212    /**
    213     * Return the initial size of the window
    214     */

    215    @Override
    216    protected Point getInitialSize() {
    217        return new Point(500375);
    218    }

    219
    220}

    221
    核心在:
    Composite composite = new Composite(tf, SWT.NO_BACKGROUND
        | SWT.EMBEDDED);
      Frame frame = SWT_AWT.new_Frame(composite);
    使用SWT_AWT進(jìn)行橋連接~速度有點(diǎn)慢!

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

    posted on 2007-08-20 15:59 阿南 閱讀(3498) 評(píng)論(5)  編輯  收藏 所屬分類: 西安java用戶群Eclipse-SWT

    評(píng)論

    # re: SWT中使用JFreechart(例子) 2007-08-20 22:59 交口稱贊

    我以前寫過(guò)一個(gè)view,用在eclipse rcp里面
    可以用來(lái)顯示jfc的報(bào)表。

    # re: SWT中使用JFreechart(例子) 2007-08-21 22:12 三告習(xí)習(xí)

    jfreechart里面有個(gè)jar包例子,不過(guò)要看源碼的話就要反編譯過(guò)來(lái)。
    其中有個(gè)類是管理其他所有例子的。以前曾經(jīng)常查看過(guò),記錄了每個(gè)之間的不同用法。但不知丟哪去了...

    # re: SWT中使用JFreechart(例子) 2007-08-21 22:33 阿南

    用我以前推薦的代碼搜索引擎,一個(gè)一個(gè)都找出來(lái),慢慢看!

    # re: SWT中使用JFreechart(例子) 2008-07-21 23:43 何敏··

    還看不懂


    # re: SWT中使用JFreechart(例子)[未登錄] 2012-01-12 10:02 steven

    咋就不能貼個(gè)圖呢...樓主
    主站蜘蛛池模板: 性做久久久久免费观看| 亚洲日韩在线观看| 国产91精品一区二区麻豆亚洲| 亚洲AV无码日韩AV无码导航| 亚洲一区二区三区丝袜| 中文字幕免费在线看| 最新中文字幕电影免费观看| 亚洲欧洲日产国码无码网站 | 亚洲精品无码不卡| 亚洲高清乱码午夜电影网| 久久免费高清视频| 在线观看免费亚洲| 亚洲高清日韩精品第一区| 免费看黄网站在线看| 五月亭亭免费高清在线| 亚洲综合区小说区激情区| 亚洲AV无码乱码麻豆精品国产| 美女网站在线观看视频免费的| 免费可以在线看A∨网站| 亚洲AV永久无码精品一百度影院 | 全部免费a级毛片| 亚洲午夜精品在线| 免费看黄的成人APP| 国产99视频精品免费视频7| 亚洲日本在线观看网址| 美女被免费网站91色| 四虎永久成人免费| 亚洲人成毛片线播放| 免费观看男人吊女人视频| 亚洲国产精品一区二区第一页免 | 亚洲理论片在线观看| 中文字幕乱理片免费完整的| 国产黄色片在线免费观看| 亚洲国产精品网站久久| 日本免费污片中国特一级| 亚洲国产一区二区视频网站| 亚洲国产精品嫩草影院 | 成年人视频免费在线观看| 亚洲精品无码高潮喷水在线| 久久精品国产亚洲AV未满十八| 国产成人免费午夜在线观看|