source: other-projects/trunk/greenstone3-extension/mat/Greenstone3Project/src/org/greenstone3/ms/DrawSymbolAxis.java@ 17156

Last change on this file since 17156 was 17156, checked in by cc108, 16 years ago

Adding the project Metadata Quality for Digital Libraries into the repository

File size: 3.1 KB
Line 
1package org.greenstone3.ms;
2
3import java.awt.Color;
4import java.awt.Font;
5import java.util.ArrayList;
6import javax.swing.JPanel;
7import org.jfree.chart.ChartPanel;
8import org.jfree.chart.JFreeChart;
9import org.jfree.chart.axis.NumberAxis;
10import org.jfree.chart.axis.NumberTickUnit;
11import org.jfree.chart.axis.SymbolAxis;
12import org.jfree.chart.plot.XYPlot;
13import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
14import org.jfree.data.xy.XYDataset;
15import org.jfree.data.xy.XYSeries;
16import org.jfree.data.xy.XYSeriesCollection;
17import org.jfree.ui.ApplicationFrame;
18import org.jfree.ui.RefineryUtilities;
19
20public class DrawSymbolAxis extends ApplicationFrame
21{
22 //private String Title;
23 private static String[] metadataName;
24
25 private static String[] documentIDs;
26
27 private static ArrayList dataset;
28
29 public DrawSymbolAxis(String string, String[] metadata, String[] ids, ArrayList set) {
30 super(string);
31 //Title = string;
32 metadataName = metadata;
33 documentIDs = ids;
34 dataset = set;
35
36 JPanel jpanel = createDemoPanel();
37
38 setContentPane(jpanel);
39
40 pack();
41 RefineryUtilities.centerFrameOnScreen(this);
42 setVisible(true);
43 }
44
45 private static JFreeChart createChart(XYDataset xydataset) {
46 SymbolAxis symbolaxis
47 = new SymbolAxis("Document ID", documentIDs);
48 SymbolAxis symbolaxis_0_
49 = new SymbolAxis("Indexes", metadataName);
50
51 XYLineAndShapeRenderer xylineandshaperenderer
52 = new XYLineAndShapeRenderer(false, true);
53
54 XYPlot xyplot = new XYPlot(xydataset,symbolaxis_0_,symbolaxis,
55 xylineandshaperenderer);
56 xyplot.setDomainGridlinePaint(Color.black);
57 xyplot.setRangeGridlinePaint(Color.black);
58
59 NumberAxis domainAxis = (NumberAxis)xyplot.getDomainAxis();
60 domainAxis.setAutoTickUnitSelection(true);
61 double rangetick = 1;
62 domainAxis.setTickUnit(new NumberTickUnit(rangetick));
63
64 xyplot.getRenderer().setSeriesPaint(0,Color.blue);
65 xyplot.getRenderer().setSeriesShape(0, xyplot.DEFAULT_LEGEND_ITEM_BOX);
66 JFreeChart jfreechart = new JFreeChart("",new Font("", Font.PLAIN, 12),xyplot,false);
67 return jfreechart;
68 }
69
70 private static XYDataset createDataset() {
71
72 XYSeries xyseries = new XYSeries("Series");
73
74 for(int a= 0; a<dataset.size(); a++){
75
76 int[] row = (int[])dataset.get(a);
77 //System.out.print
78 for(int b = 0; b<row.length; b++){
79 if(row[b]==1){xyseries.add(a,b);}
80 }
81
82 }
83
84 XYSeriesCollection xyseriescollection = new XYSeriesCollection();
85 xyseriescollection.addSeries(xyseries);
86 return xyseriescollection;
87 }
88
89 public static JPanel createDemoPanel() {
90 return new ChartPanel(createChart(createDataset()));
91 }
92 public static void main(String[] strings) {
93 DrawSymbolAxis symbolaxisdemo1 = new DrawSymbolAxis("Symbolic Axis Demo", null, null, null);
94
95 }
96 public void windowClosing(java.awt.event.WindowEvent event){
97 this.dispose();
98 }
99}
Note: See TracBrowser for help on using the repository browser.