1 package org.jfree.chart.demo; 2 3 7 8 import java.awt.Color ; 9 import java.awt.Font ; 10 import java.awt.GradientPaint ; 11 12 import org.jfree.chart.ChartFactory; 13 import org.jfree.chart.ChartPanel; 14 import org.jfree.chart.JFreeChart; 15 import org.jfree.chart.Legend; 16 import org.jfree.chart.TextTitle; 17 import org.jfree.chart.plot.PlotOrientation; 18 import org.jfree.data.WaferMapDataset; 19 import org.jfree.ui.ApplicationFrame; 20 import org.jfree.ui.RefineryUtilities; 21 22 25 public class WaferMapChartDemo extends ApplicationFrame { 26 27 public static void main(String [] args) { 28 WaferMapChartDemo demo = new WaferMapChartDemo("Wafer Map Demo"); 29 demo.pack(); 30 RefineryUtilities.centerFrameOnScreen(demo); 31 demo.setVisible(true); 32 } 33 34 public WaferMapChartDemo(String title) { 35 super(title); 36 WaferMapDataset dataset = waferdata(); 37 JFreeChart chart = ChartFactory.createWaferMapChart( 38 "Wafer Map Demo", dataset, PlotOrientation.VERTICAL, true, false, false); Legend legend = chart.getLegend(); 45 legend.setAnchor(Legend.EAST); 46 chart.setBackgroundPaint( 47 new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 48 49 TextTitle copyright = 50 new TextTitle( 51 "JFreeChart WaferMapPlot", 52 new Font ("SansSerif", Font.PLAIN, 9)); 53 copyright.setPosition(TextTitle.BOTTOM); 54 copyright.setHorizontalAlignment(TextTitle.RIGHT); 55 chart.addSubtitle(copyright); 56 57 ChartPanel chartPanel = new ChartPanel(chart); 58 chartPanel.setPreferredSize(new java.awt.Dimension (500, 400)); 59 setContentPane(chartPanel); 60 } 61 62 67 private WaferMapDataset waferdata() { 68 WaferMapDataset data = new WaferMapDataset(30, 20); 69 data.addValue(1, 5, 14); data.addValue(2, 5, 13); 71 data.addValue(3, 5, 12); 72 data.addValue(4, 5, 11); 73 data.addValue(5, 5, 10); 74 data.addValue(6, 5, 9); 75 data.addValue(7, 5, 8); 76 data.addValue(8, 5, 7); 77 data.addValue(9, 5, 6); 78 data.addValue(10, 6, 10); 79 data.addValue(11, 7, 10); 80 data.addValue(12, 8, 10); 81 data.addValue(13, 9, 10); 82 data.addValue(14, 10, 10); 83 data.addValue(15, 11, 10); 84 data.addValue(16, 11, 11); 85 data.addValue(17, 11, 12); 86 data.addValue(18, 11, 13); 87 data.addValue(19, 11, 14); 88 data.addValue(20, 11, 9); 89 data.addValue(21, 11, 8); 90 data.addValue(22, 11, 7); 91 data.addValue(23, 11, 6); 92 93 data.addValue(6, 16, 6); 94 data.addValue(6, 17, 6); 95 data.addValue(6, 18, 6); 96 data.addValue(6, 19, 6); 97 data.addValue(6, 20, 6); 98 data.addValue(6, 21, 6); 99 data.addValue(6, 22, 6); 100 data.addValue(3, 19, 7); 101 data.addValue(3, 19, 8); 102 data.addValue(3, 19, 9); 103 data.addValue(3, 19, 10); 104 data.addValue(3, 19, 11); 105 data.addValue(3, 19, 12); 106 data.addValue(3, 19, 13); 107 data.addValue(4, 19, 14); 108 data.addValue(4, 18, 14); 109 data.addValue(4, 17, 14); 110 data.addValue(4, 16, 14); 111 data.addValue(4, 20, 14); 112 data.addValue(4, 21, 14); 113 data.addValue(4, 22, 14); 114 return data; 115 } 117 } | Popular Tags |