package map_test;
import java.io.FileOutputStream;
import java.io.IOException;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.io.File;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
//import java.util.List;
import math.PriceNow;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.time.Day;
import org.jfree.data.time.RegularTimePeriod;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.time.TimeSeriesDataItem;
import org.jfree.chart.ChartFactory;
public class gf {
private CategoryDataset dataset=null;
public void main_run()throws IOException{
JFreeChart chart=ChartFactory.createLineChart(
"stock_maps", "time", "nowPrice", dataset, PlotOrientation.VERTICAL, true, false, false);
Font font=new Font("宋体",Font.BOLD,16);
chart.getTitle().setFont(font);
chart.getLegend().setItemFont(font);
CategoryPlot pieplot=(CategoryPlot)chart.getPlot();
NumberAxis rangeAxis=(NumberAxis)pieplot.getRangeAxis();
CategoryAxis domainAxis=pieplot.getDomainAxis();
rangeAxis.setLabelFont(font);
domainAxis.setLabelFont(font);
domainAxis.setTickLabelFont(font);
FileOutputStream gf=null;
LineAndShapeRenderer renderer = (LineAndShapeRenderer)pieplot.getRenderer();
renderer.setShapesVisible(true);
renderer.setDrawOutlines(true);
renderer.setUseFillPaint(true);
renderer.setFillPaint(java.awt.Color.white);
//
//
// renderer.setBaseItemLabelGenerator (new StandardCategoryItemLabelGenerator ());
// renderer.setItemLabelFont (new Font ("黑体", Font.PLAIN, 12));
// renderer.setItemLabelsVisible (true);
try{
gf=new FileOutputStream("D:\\gf.jpg");
ChartUtilities.writeChartAsJPEG(gf, 1f, chart, 1024,768,null);
}finally{
try{
gf.close();
}catch(Exception E){}
}
}
public ArrayList<PriceNow> getArrayList(ArrayList<PriceNow> list)
{
return list;
}
public CategoryDataset getDataSet2(ArrayList<PriceNow> list,ArrayList<PriceNow> list2){
DefaultCategoryDataset dataset=new DefaultCategoryDataset();
String temp="1";
String temp2="2";
for(int i=0;i<list.size();i++)
{
dataset.addValue(list.get(i).value, temp, String.valueOf(i+1));
}
for(int i=1;i<list2.size();i++)
{
if(list2.get(i).deleteFlag==false)
list2.get(i).value=list2.get(i-1).value;
}
for(int i=0;i<list2.size()-1;i++)
{
dataset.addValue(list2.get(i).value, temp2, String.valueOf(i+1));
}
//huifu***
dataset.addValue(list2.get(list2.size()-1).value, temp2, String.valueOf(list2.size()));
// dataset.addValue(3, "1", "1");
// dataset.addValue(5, "1", "2");
// dataset.addValue(8, "1", "3");
// dataset.addValue(4, "1", "4");
// dataset.addValue(9, "1", "5");
// dataset.addValue(12, "1", "6");
// dataset.addValue(3, "1", "7");
this.dataset=dataset;
return dataset;
}
}