Slt,

J'ai adapté une classe JFreeChart qui genere des graphes et qui les affiches avec JPanel, JFrame, alors je ne sais pas Comment on peut generer un fichier.html et afficher ces graphes dedans?

Merci en avence.





Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
public class parser {
 
	private static final String dir="MONITOR/";
	private static FileOutputStream MyFile;	
	private static FileOutputStream MyFile_2;
 
	private static DefaultCategoryDataset dataset = new DefaultCategoryDataset(); 	
 
	public parser(){  
		try {
			MyFile= new FileOutputStream("FINAL");
			MyFile_2= new FileOutputStream("FINAL_2");	
 
		}
		catch (FileNotFoundException e) {
			System.err.println("Fichier introuvable !");
			System.err.println("Fichier introuvable !");
 
		}	
	}	
 
 
	public void parsing(String f){
 
	 try
		{			
			BufferedReader b = new BufferedReader(new FileReader(f));
			String c;			
			boolean catapult=false;
			boolean ville=false;		
			int gnx=0;
			int gva=0;
			int tun=0;
			int h;			
			String bis, date=null;
 
			while((c=b.readLine())!=null){					
				if(c.contains("Date")){	
					date=c.substring(90,109);
					MyFile.write((c.substring(90,109)+" ").getBytes());
					MyFile_2.write((c.substring(90,109)+" ").getBytes());					
 
				}
 
				if(catapult && ville){									
 
						if ((c.contains("LICENSE MAX")&& c.contains("catapultsl_c"))){							
 
 
						MyFile.write(("  "+c.substring(66,67)).getBytes());	
 
					    dataset.addValue(Integer.parseInt(c.substring(66,67)), "MAX", date); 
 
 
						}
						else if((c.contains("LICENSE MAX")&& c.contains("catapultflpwr_c"))){
 
							  MyFile_2.write(("  "+c.substring(66,67)).getBytes());	
 
						}
 
					if (c.contains("   used")&& c.contains("catapultsl_c")){						
 
						MyFile.write(("   "+c.substring(66,67)).getBytes());
						 dataset.addValue(Integer.parseInt(c.substring(66,67)), "USED", date);		
 
				    }
 
					else if ((c.contains("   used")&& c.contains("catapultflpwr_c"))){
 
						MyFile_2.write(("   "+c.substring(66,67)+"\n").getBytes());
 
					}						
 
					if(c.contains("--->")){
 
						h=c.substring(20, 50).indexOf(" ");					
						bis=c.substring(h+21, h+21+3);
						if(bis.contains("gnx"))
						{
							gnx++;
						}
						else if(bis.contains("tun")){
 
							tun++;
 
						}
 
						else if (bis.contains("gva")){
							gva++;
						}
 
					}
 
				}
				if (c.contains("GRENOBLE")){
					 ville=true; 
 
				}
 
				if(c.contains("NOIDA")||c.contains("CROLLES")){
					 ville=false;
				} 
 
				if(c.contains("CatapultC Synthesis")) {
					catapult=true;					
 
				}
				if(c.contains("Mentor SLEC")||c.contains("Library Builder")||c.contains("SLEC")||c.contains("SYNFORA")){
					catapult=false;
				}
			}
 
			  int total=gnx+gva+tun;
			  MyFile.write(("      "+gnx).getBytes()); 
	          MyFile.write(("     "+gva).getBytes()); 
	          MyFile.write(("     "+tun).getBytes());
	          MyFile.write(("      "+total+"\n").getBytes());
 
	            dataset.addValue(gnx, "grenoble", date);
				dataset.addValue(gva, "geneve", date);
				dataset.addValue(tun, "tunis", date);
 
		}	  
 
 
		catch (FileNotFoundException e1) {
			System.err.println("Fichier introuvable !");
			e1.printStackTrace();
 
			System.exit(-1);
		} catch (IOException e2) {
			System.err.println("Problème de lecture !");
			System.exit(-1);
		}
 
 
	}
 
 
	public static  void main(String args []) {
 
		parser fich=new parser (); 	
 
		TestBarChart vv=new TestBarChart();
 
		File cour = new File(dir);
 
		JFreeChart barChart = ChartFactory.createBarChart("Evolution des ventes", "", 
      	"Unité vendue", dataset, PlotOrientation.VERTICAL, true, true, false); 
      	ChartPanel cPanel = new ChartPanel(barChart);       
      	vv.pnl.add(cPanel);      	
 
		vv.setVisible(true); 
 
		File[] fichs = cour.listFiles();
		try {
 
			MyFile.write(("    Date"+"             MAX"+" Used"+"   Gnx"+"   Gva"+"   Tun"+"   Total"+"\n").getBytes());
			MyFile_2.write(("    Date"+"             MAX"+" Used"+"\n").getBytes());
 
			long x = System.currentTimeMillis();			
			for (int i=0; i<fichs.length;i++){
				fich.parsing(dir+fichs[i].getName());}			
			x = System.currentTimeMillis() - x;
			System.out.println("Temps de traitement: "+x+" ms");
		}
 
		catch(IOException e) {
			System.err.println("ERROR...");
		}
	}	
 
	}