Révision 175
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEngine.java (revision 175) | ||
---|---|---|
122 | 122 |
*/ |
123 | 123 |
protected static int currentChartsEngineIndex; |
124 | 124 |
|
125 |
|
|
126 |
protected File workDirectory; |
|
127 |
/** |
|
128 |
* Creates a charts engine. |
|
129 |
*/ |
|
130 |
// FIXME : useless ? |
|
131 |
// protected ChartsEngine() { |
|
132 |
// this("abstract_charts_engine", "Abstract Charts Engine"); //$NON-NLS-1$ |
|
133 |
// } |
|
134 | 125 |
|
135 |
// /** |
|
136 |
// * Creates a charts engine with the specified name, description and output format. |
|
137 |
// * @param name |
|
138 |
// * @param description |
|
139 |
// * @param outputFormat |
|
140 |
// */ |
|
141 |
// protected ChartsEngine(String name, String description, String outputFormat) { |
|
142 |
// this(name, description, outputFormat); |
|
143 |
// Log.warning("Starting Charts Engine: " + this); |
|
144 |
// } |
|
145 |
|
|
146 |
|
|
147 | 126 |
/** |
148 | 127 |
* Creates a charts engine with the specified name, description and output format. |
149 | 128 |
* @param name |
... | ... | |
155 | 134 |
this.name = name; |
156 | 135 |
this.description = description; |
157 | 136 |
this.outputFormat = outputFormat; |
158 |
this.workDirectory = new File(BundleUtils.getBundleLocation("org.txm.chartengine.core")); |
|
159 |
//this.setOutputFormat(outputFormat); |
|
160 | 137 |
Log.warning("Starting Charts Engine: " + this); |
161 | 138 |
} |
162 | 139 |
|
... | ... | |
168 | 145 |
this.chartCreators = new HashMap<Class, HashMap<String,ChartCreator>>(); |
169 | 146 |
} |
170 | 147 |
|
148 |
|
|
171 | 149 |
/** |
172 | 150 |
* Gets a chart creator for the specified result data type and chart type. |
173 | 151 |
* @param resultDataType |
... | ... | |
178 | 156 |
ChartCreator chartCreator = null; |
179 | 157 |
HashMap<String, ChartCreator> map = this.chartCreators.get(resultDataType); |
180 | 158 |
if(map != null) { |
181 |
if(chartType == null) { |
|
182 |
chartType = resultDataType.getName(); |
|
183 |
} |
|
184 | 159 |
chartCreator = map.get(chartType); |
185 | 160 |
} |
186 | 161 |
|
... | ... | |
196 | 171 |
* @return A chart creator if it exists otherwise <code>null</code> |
197 | 172 |
*/ |
198 | 173 |
public ChartCreator getChartCreator(Class resultDataType) { |
199 |
return this.getChartCreator(resultDataType, resultDataType.getName());
|
|
174 |
return this.getChartCreator(resultDataType, null);
|
|
200 | 175 |
} |
201 | 176 |
|
202 | 177 |
/** |
... | ... | |
207 | 182 |
*/ |
208 | 183 |
public void addChartCreator(Class resultDataType, ChartCreator chartCreator, String chartType) { |
209 | 184 |
|
210 |
if(chartType == null) { |
|
211 |
chartType = resultDataType.getName(); |
|
212 |
} |
|
213 |
|
|
214 | 185 |
if(!this.chartCreators.containsKey(resultDataType)) { |
215 | 186 |
HashMap<String, ChartCreator> m = new HashMap<String, ChartCreator>(); |
216 | 187 |
m.put(chartType, chartCreator); |
... | ... | |
223 | 194 |
|
224 | 195 |
chartCreator.setChartsEngine(this); |
225 | 196 |
|
226 |
Log.warning(this.name + ": Chart creator " + chartCreator.getClass().getSimpleName() + " added for result: " + resultDataType + " and chart type: " + chartType); |
|
197 |
String log = this.name + ": Chart creator " + chartCreator.getClass().getSimpleName() + " added for result data type: " + resultDataType; |
|
198 |
|
|
199 |
if(chartType != null) { |
|
200 |
log += " (chart type: " + chartType + ")"; |
|
201 |
} |
|
202 |
|
|
203 |
log +="."; |
|
204 |
|
|
205 |
Log.warning(log); |
|
206 |
|
|
227 | 207 |
} |
228 | 208 |
|
229 | 209 |
|
... | ... | |
333 | 313 |
return ChartsEngine.chartsEngines; |
334 | 314 |
} |
335 | 315 |
|
336 |
|
|
337 |
// FIXME: old method managing only one charts engine |
|
338 |
// FIXME: this method should create all possible charts engines from currently installed extensions and store them in a list then define a current charts engine. |
|
339 |
// It would permit to call some ChartCreator of another chart engine than the current if a chart creator for a specified result doesn't exist |
|
340 |
// for a specified type of chart |
|
341 |
// SWTChartsComponentsProvider should do the same thing, then in createChartEditor go through all the Providers? or through all the charts engine that match the provider input format? |
|
342 |
// public static ChartsEngine createChartsEngines(String name) { |
|
343 |
// |
|
344 |
// ChartsEngine chartsEngine = null; |
|
345 |
// |
|
346 |
// String extensionPointId = "org.txm.tbx.chartsengine"; //$NON-NLS-1$ |
|
347 |
// IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId); |
|
348 |
// IConfigurationElement chartsEngineExtension = null; |
|
349 |
// |
|
350 |
// Log.warning("Installed Chart Engine extensions: "); |
|
351 |
// |
|
352 |
// for(int i = 0; i < contributions.length; i++) { |
|
353 |
// Log.warning(contributions[i].getAttribute("name")); //$NON-NLS-1$ |
|
354 |
// if(contributions[i].getAttribute("name").equals(name)) { //$NON-NLS-1$ |
|
355 |
// chartsEngineExtension = contributions[i]; |
|
356 |
// //break; |
|
357 |
// } |
|
358 |
// } |
|
359 |
// if(chartsEngineExtension != null) { |
|
360 |
// try { |
|
361 |
// chartsEngine = (ChartsEngine)chartsEngineExtension.createExecutableExtension("class"); //$NON-NLS-1$ |
|
362 |
// } |
|
363 |
// catch(CoreException e) { |
|
364 |
// // TODO Auto-generated catch block |
|
365 |
// e.printStackTrace(); |
|
366 |
// } |
|
367 |
// } |
|
368 |
// |
|
369 |
// chartsEngine.registerChartCreatorExtensions(); |
|
370 |
// |
|
371 |
// Log.warning("Charts Engine initialized."); |
|
372 |
// |
|
373 |
// return chartsEngine; |
|
374 |
// } |
|
375 |
// |
|
376 | 316 |
|
377 | 317 |
/** |
378 | 318 |
* Populates the chart creators from loaded extensions according to the specified chars engine name. |
... | ... | |
417 | 357 |
public File createTmpFile(String prefix) { |
418 | 358 |
File file = null; |
419 | 359 |
try { |
420 |
File resultsDir = new File(workDirectory, "results"); //$NON-NLS-1$
|
|
360 |
File resultsDir = new File(BundleUtils.getBundleLocation("org.txm.chartengine.core"), "results"); //$NON-NLS-1$
|
|
421 | 361 |
resultsDir.mkdirs(); |
422 | 362 |
file = File.createTempFile(prefix, "." + this.outputFormat, resultsDir); |
423 | 363 |
} |
Formats disponibles : Unified diff