package demo;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Rectangle2D;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.filechooser.FileFilter;
import javax.swing.tree.*;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.ui.*;
// Referenced classes of package demo:
// MemoryUsageDemo, DemoDescription
public class SuperDemo extends ApplicationFrame
implements ActionListener, TreeSelectionListener
{
static class DisplayDemo
implements Runnable
{
public void run()
{
try
{
Class class1 = Class.forName(demoDescription.getClassName());
Method method = class1.getDeclaredMethod("createDemoPanel", null);
JPanel jpanel = (JPanel)method.invoke(null, null);
app.chartContainer.removeAll();
app.chartContainer.add(jpanel);
app.displayPanel.validate();
String s = class1.getName();
String s1 = s;
int i = s.lastIndexOf('.');
if(i > 0)
s1 = s.substring(i + 1);
s1 = s1 + ".html";
app.displayDescription(s1);
}
catch(ClassNotFoundException classnotfoundexception)
{
classnotfoundexception.printStackTrace();
}
catch(NoSuchMethodException nosuchmethodexception)
{
nosuchmethodexception.printStackTrace();
}
catch(InvocationTargetException invocationtargetexception)
{
invocationtargetexception.printStackTrace();
}
catch(IllegalAccessException illegalaccessexception)
{
illegalaccessexception.printStackTrace();
}
}
private SuperDemo app;
private DemoDescription demoDescription;
public DisplayDemo(SuperDemo superdemo, DemoDescription demodescription)
{
app = superdemo;
demoDescription = demodescription;
}
}
static class PDFExportTask
implements Runnable
{
public void run()
{
try
{
SuperDemo.saveChartAsPDF(file, chart, width, height, new DefaultFontMapper());
}
catch(IOException ioexception)
{
ioexception.printStackTrace();
}
}
JFreeChart chart;
int width;
int height;
File file;
public PDFExportTask(JFreeChart jfreechart, int i, int j, File file1)
{
chart = jfreechart;
file = file1;
width = i;
height = j;
jfreechart.setBorderVisible(true);
jfreechart.setPadding(new RectangleInsets(2D, 2D, 2D, 2D));
}
}
public SuperDemo(String s)
{
super(s);
setContentPane(createContent());
setJMenuBar(createMenuBar());
}
private JComponent createContent()
{
JPanel jpanel = new JPanel(new BorderLayout());
JTabbedPane jtabbedpane = new JTabbedPane();
JPanel jpanel1 = new JPanel(new BorderLayout());
jpanel1.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
JSplitPane jsplitpane = new JSplitPane(1);
JTree jtree = new JTree(createTreeModel());
jtree.addTreeSelectionListener(this);
JScrollPane jscrollpane = new JScrollPane(jtree);
jscrollpane.setPreferredSize(new Dimension(300, 100));
jsplitpane.setLeftComponent(jscrollpane);
jsplitpane.setRightComponent(createChartDisplayPanel());
jpanel1.add(jsplitpane);
jtabbedpane.add("Demos", jpanel1);
MemoryUsageDemo memoryusagedemo = new MemoryUsageDemo(0x493e0);
(new MemoryUsageDemo.DataGenerator(memoryusagedemo, 1000)).start();
jtabbedpane.add("Memory Usage", memoryusagedemo);
jtabbedpane.add("Source Code", createSourceCodePanel());
jtabbedpane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
jpanel.add(jtabbedpane);
return jpanel;
}
private JMenuBar createMenuBar()
{
JMenuBar jmenubar = new JMenuBar();
JMenu jmenu = new JMenu("File", true);
jmenu.setMnemonic('F');
JMenuItem jmenuitem = new JMenuItem("Export to PDF...", 112);
jmenuitem.setActionCommand("EXPORT_TO_PDF");
jmenuitem.addActionListener(this);
jmenu.add(jmenuitem);
jmenu.addSeparator();
JMenuItem jmenuitem1 = new JMenuItem("Exit", 120);
jmenuitem1.setActionCommand("EXIT");
jmenuitem1.addActionListener(this);
jmenu.add(jmenuitem1);
jmenubar.add(jmenu);
return jmenubar;
}
private JPanel createSourceCodePanel()
{
JPanel jpanel = new JPanel(new BorderLayout());
jpanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
JEditorPane jeditorpane = new JEditorPane();
jeditorpane.setEditable(false);
java.net.URL url = (demo.SuperDemo.class).getResource("source.html");
if(url != null)
try
{
jeditorpane.setPage(url);
}
catch(IOException ioexception)
{
System.err.println("Attempted to read a bad URL: " + url);
}
else
System.err.println("Couldn't find file: source.html");
JScrollPane jscrollpane = new JScrollPane(jeditorpane);
jscrollpane.setVerticalScrollBarPolicy(20);
jscrollpane.setPreferredSize(new Dimension(250, 145));
jscrollpane.setMinimumSize(new Dimension(10, 10));
jpanel.add(jscrollpane);
return jpanel;
}
public void actionPerformed(ActionEvent actionevent)
{
String s = actionevent.getActionCommand();
if(s.equals("EXPORT_TO_PDF"))
exportToPDF();
else
if(s.equals("EXIT"))
attemptExit();
}
private void exportToPDF()
{
java.awt.Component component = chartContainer.getComponent(0);
if(component instanceof ChartPanel)
{
JFileChooser jfilechooser = new JFileChooser();
jfilechooser.setName("untitled.pdf");
jfilechooser.setFileFilter(new FileFilter() {
public boolean accept(File file)
{
return file.isDirectory() || file.getName().endsWith(".pdf");
}
public String getDescription()
{
return "Portable Document Format (PDF)";
}
}
);
int i = jfilechooser.showSaveDialog(this);
if(i == 0)
{
ChartPanel chartpanel = (ChartPanel)component;
try
{
JFreeChart jfreechart = (JFreeChart)chartpanel.getChart().clone();
PDFExportTask pdfexporttask = new PDFExportTask(jfreechart, chartpanel.getWidth(), chartpanel.getHeight(), jfilechooser.getSelectedFile());
Thread thread = new Thread(pdfexporttask);
thread.start();
}
catch(CloneNotSupportedException clonenotsupportedexception)
{
clonenotsupportedexception.printStackTrac
没有合适的资源?快使用搜索试试~ 我知道了~
java实现各种数据统计图(柱形图,饼图,折线图)
共307个文件
java:286个
jar:12个
class:5个
5星 · 超过95%的资源 需积分: 39 1.0k 下载量 153 浏览量
2012-05-24
22:16:15
上传
评论 55
收藏 12.84MB ZIP 举报
温馨提示
java 柱形图 饼图 折线图 JFreeChart,里面包含与JFreeChart有关的所有jar包,还有我自己写的例子,通俗易懂!
资源详情
资源评论
资源推荐
收起资源包目录
java实现各种数据统计图(柱形图,饼图,折线图) (307个子文件)
API.chm 7.67MB
TimeSeriesChart.class 4KB
BarChart.class 3KB
PieChart.class 3KB
BarChart1.class 3KB
mainClass.class 1KB
.classpath 480B
jfreechart-1.0.13.jar 1.36MB
jfreechart-1.0.13.jar 1.36MB
iText-2.1.5.jar 1.07MB
jcommon-1.0.16.jar 302KB
jcommon-1.0.16.jar 302KB
gnujaxp.jar 226KB
gnujaxp.jar 226KB
junit.jar 118KB
servlet.jar 78KB
jfreechart-1.0.13-swt.jar 71KB
swtgraphics2d.jar 15KB
jfreechart-1.0.13-experimental.jar 13KB
SuperDemo.java 64KB
DifferenceChartDemo2.java 48KB
XYBoxAnnotationDemo1.java 43KB
CombinedXYPlotDemo1.java 31KB
PriceVolumeDemo1.java 28KB
CombinedXYPlotDemo3.java 21KB
TimeSeriesDemo8.java 21KB
TimeSeriesDemo7.java 20KB
GanttRenderer2.java 14KB
CrosshairDemo2.java 13KB
HighLowChartDemo2.java 11KB
SurveyResultsDemo1.java 11KB
HighLowChartDemo1.java 11KB
CandlestickChartDemo1.java 11KB
CrosshairDemo1.java 9KB
ExtendedStackedBarRenderer.java 9KB
StackedBarChartDemo4.java 9KB
AnnotationDemo1.java 8KB
CombinedTimeSeriesDemo1.java 7KB
DrawStringDemo.java 7KB
CompassFormatDemo2.java 7KB
CrosshairDemo3.java 7KB
GanttDemo3.java 7KB
OverlaidXYPlotDemo2.java 7KB
DualAxisDemo2.java 6KB
YieldCurveDemo.java 6KB
TranslateDemo1.java 6KB
CylinderRenderer.java 6KB
MarkerDemo1.java 6KB
MarkerDemo2.java 6KB
StackedXYBarChartDemo2.java 6KB
PerformanceTest1.java 6KB
DualAxisDemo1.java 6KB
CategoryLabelPositionsDemo1.java 6KB
PeriodAxisDemo1.java 6KB
AnnotationDemo2.java 6KB
XYTitleAnnotationDemo1.java 6KB
ImageMapDemo6.java 6KB
ClusteredXYBarRendererDemo1.java 6KB
StackedBarChartDemo2.java 6KB
ChartPanelSerializationTest.java 6KB
CombinedXYPlotDemo4.java 6KB
CombinedCategoryPlotDemo1.java 6KB
DialDemo2.java 6KB
DynamicDataDemo3.java 6KB
XYBlockChartDemo1.java 6KB
DynamicDataDemo2.java 6KB
OverlaidBarChartDemo1.java 6KB
LineChartDemo5.java 6KB
PlotOrientationDemo1.java 6KB
CombinedXYPlotDemo5.java 6KB
MouseListenerDemo3.java 5KB
XYLineAndShapeRendererDemo2.java 5KB
QuarterDateFormatDemo.java 5KB
DualAxisDemo5.java 5KB
ImageMapDemo7.java 5KB
PieChartDemo4.java 5KB
CombinedCategoryPlotDemo2.java 5KB
MultiplePieChartDemo4.java 5KB
DualAxisDemo3.java 5KB
BarChartDemo7.java 5KB
TimeSeriesDemo1.java 5KB
PlotOrientationDemo2.java 5KB
GradientPaintTransformerDemo1.java 5KB
CombinedXYPlotDemo2.java 5KB
GanttDemo1.java 5KB
XYBlockChartDemo3.java 5KB
HideSeriesDemo3.java 5KB
GanttDemo2.java 5KB
HideSeriesDemo2.java 5KB
RegressionDemo1.java 5KB
PeriodAxisDemo2.java 5KB
AreaChartDemo1.java 5KB
MultipleAxisDemo1.java 5KB
OverlaidXYPlotDemo1.java 5KB
DialDemo5.java 5KB
BarChart3DDemo1.java 5KB
XYBarChartDemo1.java 5KB
ItemLabelDemo2.java 5KB
StackedBarChart3DDemo4.java 5KB
StackedBarChart3DDemo2.java 5KB
共 307 条
- 1
- 2
- 3
- 4
pzhtpf
- 粉丝: 1117
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论30