- 浏览: 147382 次
- 性别:
文章分类
最新评论
-
yjp:
效果丢失了,也好不了多少
SWT中使用JFreeChart(无需SWT_AWT) -
vfbrhvfbgd:
LZ,您好,
在网上找到了很多类似你这样的代码,请问您这 ...
一个使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ -
sdyjmc:
我也在看,发现Search不起作用。msn:sdyjmc@16 ...
读jlibrary代码的部分疑问,希望有人解答~ -
alaham:
jlibray研究得如何了呢?权限问题解决了吗?
我目前也正 ...
读jlibrary代码的部分疑问,希望有人解答~ -
bbiao:
你把代码抄错了,范型是不可以这么定义的....
这种模式我也 ...
从Hibernate范型DAO设计打造的自用DAO
SWT中使用JFreeChart(无需SWT_AWT)
好像从1.03开始Jfc就已经提供了在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(600, 300);
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
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(600, 300);
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
发表评论
-
来自网络上的经典文章收藏帖(不断增加中... ...)
2007-05-15 09:14 1024教你如何使用JFace创建Wizards Creating J ... -
RCP程序怎样实现自适应分辩率最大化(增加版)
2007-05-15 14:02 1300交口称赞在BLOG中提到了一种让RCP最大化的方法: 在App ... -
如何在ViewPart上添加ViewToolBar
2007-05-15 17:58 3780ViewToolBar其实就是Actions。在ViewPar ... -
郁闷的Perspective
2007-05-15 18:11 939下午正式开始RCP开发,于是乎轻车熟路的开始打基础框架。 ... -
读jlibrary代码的部分疑问,希望有人解答~
2007-05-18 10:30 1324昨天在Bolg中贴出来一个很不错的RCP项目http://jl ... -
简单应用Maven2
2007-05-18 13:54 864Maven2对项目的管理确实可以说是无微不至的,而且给出了大量 ... -
介绍一个好站
2007-05-20 10:42 783http://www.krugle.com/代码搜索工具,使用 ... -
Eclipse3.3m7 VS Eclipse3.2.2
2007-05-22 08:37 1082Eclipse3.3m7 VS Eclipse3.2.2没有深 ... -
西安java用户群成立~_~
2007-05-23 15:58 786西安java用户群,感谢dudu,为我们开通团队,所有西安ja ... -
RCP的异常
2007-05-25 12:53 876上次的一篇文章问到为什么TreeViewer没有刷新, ... -
正在规划一个Eclipse上看RSS的Plugin
2007-06-04 08:50 945目前正在规划阶段,初步想法是,实现一个周博通的EclipseP ... -
初识DB4O
2007-06-10 11:15 747DB4O? 新出的OODBMS~取谐音DB fo ... -
如何用WebStart部署RCP应用程序?
2007-06-11 17:19 881上传一份同事写的预研文档:WebStartToRCP.doc ... -
RCP开发者的好去处之ICON系列(持续更新中... ...)
2007-06-11 20:49 872为了找个合适的图片是不是头大的不像样子了?OK,我现在 ... -
庆祝一下~RCP开发者的福音到了!
2007-06-14 22:04 827今天在Eclipse站上学习如何使用Maven2管理Eclip ... -
再次理解Eclipse的类加载机制
2007-06-18 15:13 1069今天在写RCP的基础运行插件的时候,发现一个非常有意思的问题: ... -
插件开发依赖其他插件时一定要注意!
2007-06-19 14:18 2208插件开发依赖其他插件时,我们要在plugin.xml的depe ... -
RCP实践之软件架构
2007-06-19 21:22 681RCP还是新兴的东西,大家都是用它做做小东东,所以在网 ... -
RCP实践之第三方JAR包
2007-06-20 21:43 3189感谢大家对上一篇文章的拍砖,引起的反响不小,目的达到了 ... -
RCP实践之安全模型
2007-06-21 21:52 1062感谢大家最近对本 ...
相关推荐
今天遇到一个问题,就是要在一个Eclipse插件里显示JFreeChart的图形,因为后者是基于Java2D的,要把图形显示在SWT应用程序里需要利用SWT-AWT桥接器来实现,虽说桥接的方式多半会伴随着性能下降,但总归是一个解决...
"JFreeChartLeida_jfreechart_leaffv3_DEMO_"这个项目显然是一个关于JFreeChart的示例集合,旨在展示如何利用JFreeChart库自定义绘制各种类型的图表,如柱状图,并调整颜色、刻度等关键元素。 首先,我们来看看...
在本教程中,我们将深入探讨如何使用 JFreeChart 创建饼状图(Pie Chart),这是一个常用于展示数据部分比例的可视化工具。 **创建 PieDataset 对象(准备数据)** 在 JFreeChart 中,饼状图的数据由 `PieDataset`...
Java使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的...
`JFreeChart_GUI_Demo` 提供了一系列示例代码,帮助开发者了解如何在Java图形用户界面(GUI)中集成和展示`JFreeChart`图表。 **核心知识点** 1. **JFreeChart库** - `JFreeChart`提供了丰富的图表类型,如条形图...
用JFreeChart画统计分析柱状图建站指南网页制作网页特效Flash动画网络编程素材下载教程下载建站服务HTML学习CSS学习JAVASCRIPT教程ASP技术PHP技术JSP技术ASP_NET技术数据库技术
3. 使用JFreeChart创建图表:通过JFreeChart提供的API,开发者可以构建所需的图表类型,设置颜色、字体、标签、图例等样式,并添加数据到图表中。例如,`CategoryDataset`用于创建柱状图和线图,`PieDataset`则用于...
本DEMO,"tb_jfreechart_java_swimckz_DEMO_necknho_",将JFreeChart这一成熟的库引入到Android环境中,为开发者提供了一种在移动设备上实现复杂统计图表的新途径。 首先,JFreeChart库的核心优势在于其高度定制化...
Jfreechart提供的SWT接口,并不支持滚动条,本资源实现了这个方法
5. **导出和打印**:JFreeChart可以将图表导出为多种格式,如JPEG、PNG、PDF、SVG等,方便在报告或网页中使用。同时,它还支持打印功能,让硬拷贝图表成为可能。 6. **兼容性**:由于JFreeChart基于Java,所以它...
在这个场景中,我们将深入探讨如何在 SWT(Standard Widget Toolkit)和 JSP(JavaServer Pages)环境中使用 JFreeChart 的源代码来生成这些图表。 首先,让我们了解 JFreeChart 的核心功能。JFreeChart 提供了多种...
5. **导出功能**:JFreeChart 提供了将图表导出为 PNG、JPEG、SVG、PDF、EPS 等格式的功能,方便在报告、网页和打印中使用。 **JFreeChart 在 Web 开发中的应用** 在 Web 开发中,JFreeChart 主要通过 JavaServer ...
JFreeChart不仅功能强大,而且完全免费,遵循LGPL许可协议,允许在商业项目中使用。 **1. 图表类型** JFreeChart支持多种图表类型,每种都有其特定的应用场景: - **柱状图(Bar Chart)**:适用于比较不同类别的...
JFreeChartDeveloperGuide_Version_1.0.4.rarJFreeChartDeveloperGuide_Version_1.0.4.rarJFreeChartDeveloperGuide_Version_1.0.4.rar
jfreechart-1.0.12_api_doc.CHM 里面我添加了jcommon的api
标题 "JFreehelp_JfreeChartweb_jfreechart_jfreechartGuide_" 和描述 "JFree chart v 1.0.9 helper" 显然指向了 JFreeChart 的使用指南或帮助文档,特别关注的是版本 1.0.9。标签 "JfreeChartweb jfreechart ...
5. **多平台兼容**:作为Java库,JFreeChart可在任何Java运行环境中使用,包括桌面应用、Web应用和移动应用。 《JFreeChart Developer Guide Version 1.0.4》的内容可能涵盖了以下几个方面: 1. **入门指南**:...
在Jfreechart_jdbc压缩包中,可能包含了实现这个过程所需的JFreeChart库文件和其他相关资源。确保正确导入所有必要的JAR文件,如jfreechart.jar、jcommon.jar,以及可能的数据库驱动JAR。 总结来说,JFreeChart与...
- 该文档旨在为开发者提供全面的指南,帮助他们了解如何使用JFreeChart来创建和自定义图表。 - **受众**: 主要面向希望使用JFreeChart创建图表的开发人员。 - **内容**: 包括了从下载安装、基础图表绘制到高级...