jfreechart源码
⑴ 股票行情软件是用什么语言编写的
如下4种常见:
java:Java是一种可以撰写跨平台应用软件的面向对象的程序设计语言。Java 技术具有卓越的通用性、高效性、平台移植性和安全性,广泛应用于PC、数据中心、游戏控制台、科学超级计算机、移动电话和互联网,同时拥有全球最大的开发者专业社群
JFreeChart:JFreeChart是JAVA平台上的一个开放的图表绘制类库。它完全使用JAVA语言编写,是为applications, applets, servlets 以及JSP等使用所设计。JFreeChart可生成饼图(pie charts)、柱状图(bar charts)、散点图(scatter plots)、时序图(time series)、甘特图(Gantt charts)等等多种图表,并且可以产生PNG和JPEG格式的输出,还可以与PDF和EXCEL关联。
3.源码结构:源码就是指编写的最原始程序的代码。运行的软件是要经过编写的,程序员编写程序的过程中需要他们的“语言”。音乐家用五线谱,建筑师用图纸,那程序员的工作的语言就是“源码”了。
4.c++ 【目前最多的】: C++是在C语言的基础上开发的一种通用编程语言,应用广泛。C++支持多种编程范式 --面向对象编程、泛型编程和过程化编程。最新正式标准C++14于2014年8月18日公布。其编程领域众广,常用于系统开发,引擎开发等应用领域,是至今为止最受广大受用的最强大编程语言之一,支持类:类、封装、重载等!
⑵ jfreechart 鎶樼嚎锲炬庢牱鏄剧ず鏁版嵁鍊
//缁欎綘涓婧愪唬镰侊纴涓婇溃链夋敞閲婅存槑鍝娈垫槸鏄剧ず鏁版嵁镄
<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="java.awt.*"%>
<%@ page import="org.jfree.chart.*"%>
<%@ page import="org.jfree.chart.servlet.*"%>
<%@ page import="org.jfree.chart.plot.*"%>
<%@ page import="org.jfree.chart.renderer.*"%>
<%@ page import="org.jfree.chart.entity.*"%>
<%@ page import="org.jfree.chart.title.*"%>
<%@ page import="org.jfree.chart.axis.*"%>
<%@ page import="org.jfree.chart.renderer.category.LineAndShapeRenderer"%>
<%@ page import="org.jfree.data.*"%>
<%@ page import="org.jfree.data.general.*"%>
<%@ page import="org.jfree.data.category.*"%>
<%@ page import="org.jfree.ui.*"%>
<%@ page import="org.jfree.util.*"%>
<%@ page import="org.jfree.chart.labels.*"%>
<%!
String bookTitle[] = {"Python", "JAVA", "C#", "Perl", "PHP"};
String category[] = {"绗1锻", "绗2锻", "绗3锻", "绗4锻" };
double bookSales;
String chartTitle = "JFreeChart瀹炰緥11: 镊瀹氢箟绾挎靛浘";
// 鍒涘缓鏁版嵁闆
public CategoryDataset createDataset()
{
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (int i=0; i < bookTitle.length; i++)
{
for (int j=0; j < category.length; j++ )
{
bookSales = 1 + (Math.random() * 100);
dataset.addValue(bookSales, bookTitle[i], category[j]);
}
}
return dataset;
}
public JFreeChart createChart(CategoryDataset dataset)
{
// 鍒涘缓锲捐〃瀵硅薄
JFreeChart chart = ChartFactory.createLineChart
(
chartTitle, // 锲捐〃镙囬
"阌鍞镞堕棿:2005骞2链", // 鍧愭爣镙囬
"阌鍞閲", // 鍧愭爣镙囬
dataset, // 瀹氢箟缁桦埗鏁版嵁
PlotOrientation.VERTICAL, // 鐩存柟锲剧殑鏂瑰悜
true, // 瀹氢箟锲捐〃鏄钖﹀寘钖锲句緥
true, // 瀹氢箟锲捐〃鏄钖﹀寘钖鎻愮ず
false // 瀹氢箟锲捐〃鏄钖﹀寘钖玌RL
);
return chart;
}
%>
<%
// 鍒涘缓涓涓 500X375 镄勫浘镀
int width=500, height=375;
CategoryDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
// 寮濮嬭嚜瀹氢箟锲捐〃缁桦埗镄勭浉鍏冲睘镐
// 璁剧疆锲捐〃镄勮儗鏅棰滆壊
chart.setBackgroundPaint(new Color(205, 241, 197));
// 镊瀹氢箟锲捐〃镄勬爣棰樼殑瀛椾綋鍜岄滆壊
TextTitle title = chart.getTitle();
title.setFont(new Font("榛戜綋", Font.BOLD, 25));
// 銮峰缑锲捐〃瀵硅薄镄勫紩鐢锛岀敤浜庤剧疆镟村氱殑镊瀹氢箟缁桦埗灞炴
CategoryPlot plot = (CategoryPlot) chart.getPlot();
GradientPaint bg = new GradientPaint(0, 50, new Color(248, 253, 255),
0, 250, new Color(205, 237, 252));
plot.setBackgroundPaint(bg);
plot.setDomainGridlinePaint(Color.BLACK);
plot.setDomainGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.RED);
// 璁剧疆妯杞存爣棰樼殑瀛椾綋
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setLabelFont(new Font("榛戜綋", Font.BOLD, 15));
// 璁剧疆绾佃酱镙囬樻枃瀛楃殑瀛椾綋鍙婂叾镞嬭浆鏂瑰悜
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setLabelFont(new Font("榛戜綋", Font.BOLD, 15));
rangeAxis.setLabelAngle(Math.PI/2);
// 镊瀹氢箟锲句緥镄勬樉绀洪庢牸
StandardLegend legend = (StandardLegend) chart.getLegend();
legend.setDisplaySeriesShapes(true);
legend.setShapeScaleX(1.5);
legend.setShapeScaleY(1.5);
legend.setDisplaySeriesLines(true);
// 銮峰彇娓叉煋瀵硅薄
LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setBaseItemLabelsVisible(true);
//renderer.setDrawShapes(true);
//renderer.setShapesFilled(true);
//璁剧疆鏁版嵁鏄剧ず浣岖疆
//ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER_LEFT,TextAnchor.CENTER_LEFT, -Math.PI / 2.0 );
renderer.(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
//鏄剧ず鎶樼偣鐩稿簲鏁版嵁
renderer.setBaseLabelGenerator(new ());
// 镊瀹氢箟绾挎电殑缁桦埗棰滆壊
Color color[] = new Color[bookTitle.length];
color[0] = new Color(99,99,0);
color[1] = new Color(255,169,66);
color[2] = new Color(33,255, 66);
color[3] = new Color(33,0,255);
color[4] = new Color(255,0,66);
for (int i = 0; i < color.length; i++)
{
renderer.setSeriesPaint(i, color[i]);
}
// 镊瀹氢箟绾挎电殑缁桦埗椋庢牸
BasicStroke bs ;
for (int i = 0; i < bookTitle.length; i++)
{
float dashes[] = {10.0f};
bs = new BasicStroke(2.0f, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND, 10.f, dashes, 0.0f);
if (i % 2 != 0)
renderer.setSeriesStroke(i, bs);
else
renderer.setSeriesStroke(i, new BasicStroke(2.0f));
}
// 缁撴潫镊瀹氢箟锲捐〃缁桦埗镄勭浉鍏冲睘镐
ChartRenderingInfo info =
new ChartRenderingInfo(new StandardEntityCollection());
// 璁剧疆锲剧墖鐢熸垚镙煎纺
String fileName =
ServletUtilities.saveChartAsPNG(chart, width, height, info, session);
// 璁剧疆锲剧墖鐢熸垚璺寰
String graphURL =
request.getContextPath() + "/servlet/DisplayChart?filename=" + fileName;
%>
<HTML>
<HEAD>
<TITLE><%=chartTitle%></TITLE>
</HEAD>
<BODY>
<P ALIGN="CENTER">
<img src="<%=graphURL %>" border="1" >
</P>
</BODY>
</HTML>