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>