package com.liyanframework.chart.service;
import java.awt.BasicStroke;
import java.awt.Color;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.List;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.labels.StandardPieToolTipGenerator;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.CategoryToPieDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.util.TableOrder;
import com.liyanframework.chart.dao.FruitDAO;
import com.liyanframework.chart.domain.Fruit;
public class FruitService {
private FruitDAO fruitDAO;
public List<Fruit> listAllFruit() {
return fruitDAO.listAll();
}
public void setFruitDAO(FruitDAO fruitDAO) {
this.fruitDAO = fruitDAO;
}
public JFreeChart listAllFruit4Bar() {
List<Fruit> fruit = fruitDAO.listAll();
CategoryDataset dataset = getDataSet(fruit);
JFreeChart chart = ChartFactory.createBarChart("水果产量图", "水果", "产量", dataset, PlotOrientation.VERTICAL,
true, false, false);
return chart;
}
public JFreeChart listAllFruit4Line() {
List<Fruit> fruit = fruitDAO.listAll();
CategoryDataset dataset = getDataSet(fruit);
JFreeChart chart = ChartFactory.createLineChart("水果产量图", "水果", "产量", dataset, PlotOrientation.VERTICAL,
true, false, false);
return chart;
}
private CategoryDataset getDataSet(List<Fruit> fruit) {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (Fruit f : fruit) {
dataset.addValue(f.getOutput(), f.getArea(), f.getName());
}
return dataset;
}
public JFreeChart listAllFruit4Pie() {
List<Fruit> fruit = fruitDAO.listAll();
PieDataset dataset = getDataSet2(fruit);
JFreeChart chart = ChartFactory.createPieChart("水果产量图", dataset, true, false, false);
resetPiePlot((PiePlot) chart.getPlot());
return chart;
}
private PieDataset getDataSet2(List<Fruit> fruit) {
DefaultPieDataset dataset = new DefaultPieDataset();
for (Fruit f : fruit) {
dataset.setValue(f.getName(), f.getOutput());
}
// return dataset;
CategoryToPieDataset d = new CategoryToPieDataset(getDataSet(fruit),TableOrder.BY_COLUMN ,0);
return d;
}
private static void resetPiePlot(PiePlot plot) {
String unitSytle = "{0}={1}({2})";
plot.setNoDataMessage("无对应的数据,请重新查询。");
plot.setNoDataMessagePaint(Color.red);
//指定 section 轮廓线的厚度(OutlinePaint不能为null)
plot.setOutlineStroke(new BasicStroke(0));
//设置第一个 section 的开始位置,默认是12点钟方向
plot.setStartAngle(90);
plot.setToolTipGenerator(new StandardPieToolTipGenerator(unitSytle,
NumberFormat.getNumberInstance(),
new DecimalFormat("0.00%")));
//指定图片的透明度
plot.setForegroundAlpha(0.65f);
//引出标签显示样式
plot.setLabelGenerator(new StandardPieSectionLabelGenerator(unitSytle,
NumberFormat.getNumberInstance(),
new DecimalFormat("0.00%")));
//图例显示样式
plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(unitSytle,
NumberFormat.getNumberInstance(),
new DecimalFormat("0.00%")));
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
struts2+spring2+hibernate3 Annotation整合
共43个文件
java:18个
xml:10个
jsp:6个
4星 · 超过85%的资源 需积分: 3 78 下载量 122 浏览量
2008-12-14
18:57:35
上传
评论
收藏 22KB RAR 举报
温馨提示
struts2+spring2+hibernate3 Annotation整合例子
资源推荐
资源详情
资源评论
收起资源包目录
liyanFramework.rar (43个子文件)
liyanFramework
.project 390B
bin
.settings
org.eclipse.core.resources.prefs 88B
conf
spring-datasource.xml 898B
spring-hibernate.xml 1KB
log4j.properties 1KB
struts
struts-chart.xml 3KB
jdbc.properties 94B
spring-dao.xml 350B
spring
spring-dao-chart.xml 576B
spring-service-chart.xml 601B
spring-service.xml 357B
hibernate.properties 52B
struts.xml 520B
WebRoot
WEB-INF
web.xml 1KB
chart
ListAllFruit4Chart.jsp 1KB
ListAllSales4Chart.jsp 1003B
ListAllFruit.jsp 658B
addSales.jsp 443B
ListAllSales.jsp 541B
index.jsp 490B
script
my.ini 399B
data.sql 1KB
schema.sql 579B
src
common
com
liyanframework
common
composition
ChartComposition.java 2KB
ChartBean.java 457B
domain
BaseDomain.java 438B
chart
com
liyanframework
chart
dao
SalesDAO.java 454B
FruitDAO.java 375B
action
ListAllSalesAction.java 688B
ListAllSales4LineAction.java 661B
ListAllFruitAction.java 688B
ListAllFruit4BarAction.java 659B
AddSalesAction.java 1KB
ListAllFruit4PieAction.java 659B
ListAllFruit4LineAction.java 661B
ListAllSales4PieAction.java 659B
ListAllSales4BarAction.java 659B
domain
Sales.java 630B
Fruit.java 805B
service
SalesService.java 2KB
FruitService.java 3KB
.classpath 900B
lib
report
struts2
hibernate3
spring2
build.xml 8KB
共 43 条
- 1
资源评论
- strawren2014-09-28还不错吧,年代太久远了
- kenorz2012-05-10可以把 思路清晰的
- changshenghua172012-02-17篇幅比较简短,内容较少,但是三个框架的整合还是有的,比较容易看懂
無名VF
- 粉丝: 96
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功