Révision 1997
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEngine.java (revision 1997) | ||
---|---|---|
24 | 24 |
/** |
25 | 25 |
* Common charts engine. This is the superclass of all chart engine implementations. |
26 | 26 |
* This class provides methods to create charts from variable chart creators stored by type of result data such as CA, CAH, Singular values, etc. |
27 |
* |
|
27 | 28 |
* @author sjacquot |
28 | 29 |
* |
29 | 30 |
*/ |
... | ... | |
34 | 35 |
/** |
35 | 36 |
* Constants for output formats and file extensions. |
36 | 37 |
*/ |
37 |
public final static String OUTPUT_FORMAT_JPEG = "jpeg", OUTPUT_FORMAT_PDF = "pdf", OUTPUT_FORMAT_PNG = "png", OUTPUT_FORMAT_PS = "ps", OUTPUT_FORMAT_SVG = "svg", OUTPUT_FORMAT_BMP = "bmp", OUTPUT_FORMAT_GIF = "gif"; |
|
38 |
public final static String OUTPUT_FORMAT_NONE = "NONE", OUTPUT_FORMAT_JPEG = "jpeg", OUTPUT_FORMAT_PDF = "pdf", OUTPUT_FORMAT_PNG = "png", OUTPUT_FORMAT_PS = "ps", OUTPUT_FORMAT_SVG = "svg", OUTPUT_FORMAT_BMP = "bmp", OUTPUT_FORMAT_GIF = "gif";
|
|
38 | 39 |
|
39 | 40 |
/** |
40 | 41 |
* Constants for the colors rendering modes. |
... | ... | |
73 | 74 |
protected boolean directComputing; |
74 | 75 |
|
75 | 76 |
|
77 |
// add the preference node qualifier to the preferences so the command use some preferences if they do not define themselves |
|
76 | 78 |
static { |
77 | 79 |
TXMPreferences.alternativeNodesQualifiers.add(ChartsEnginePreferences.getInstance().getPreferencesNodeQualifier()); |
78 | 80 |
} |
... | ... | |
93 | 95 |
} |
94 | 96 |
|
95 | 97 |
/** |
96 |
* Gets a chart creator for the specified result. |
|
97 |
* @param resultDataType |
|
98 |
* Gets a chart creator for the specified result and chart type. |
|
99 |
* |
|
100 |
* @param result |
|
98 | 101 |
* @param chartType |
102 |
* @param showLogWarning |
|
99 | 103 |
* @return A chart creator if it exists otherwise <code>null</code> |
100 | 104 |
*/ |
101 | 105 |
public ChartCreator getChartCreator(ChartResult result, String chartType, boolean showLogWarning) { |
... | ... | |
111 | 115 |
return chartCreator; |
112 | 116 |
} |
113 | 117 |
|
114 |
|
|
118 |
/** |
|
119 |
* Gets a chart creator for the specified result and default chart type. |
|
120 |
* @param result |
|
121 |
* @param showLogWarning |
|
122 |
* @return |
|
123 |
*/ |
|
115 | 124 |
public ChartCreator getChartCreator(ChartResult result, boolean showLogWarning) { |
116 | 125 |
return this.getChartCreator(result, result.getChartType(), showLogWarning); |
117 | 126 |
} |
118 | 127 |
|
128 |
/** |
|
129 |
* Gets a chart creator for the specified result and chart type. |
|
130 |
* @param result |
|
131 |
* @param chartType |
|
132 |
* @return |
|
133 |
*/ |
|
119 | 134 |
public ChartCreator getChartCreator(ChartResult result, String chartType) { |
120 | 135 |
return this.getChartCreator(result, chartType, true); |
121 | 136 |
} |
122 | 137 |
|
123 | 138 |
|
124 | 139 |
/** |
125 |
* Gets a chart creator for the specified result. |
|
140 |
* Gets a chart creator for the specified result and default chart type. |
|
141 |
* |
|
126 | 142 |
* @param result |
127 |
* @param showLogWarning |
|
128 | 143 |
* @return |
129 | 144 |
*/ |
130 | 145 |
public ChartCreator getChartCreator(ChartResult result) { |
... | ... | |
133 | 148 |
|
134 | 149 |
|
135 | 150 |
/** |
136 |
* Gets a list of all installed chart creators for the specified result. |
|
137 |
* @param resultDataType |
|
151 |
* Gets a list of all installed chart creators for the specified result. |
|
152 |
* |
|
153 |
* @param result |
|
138 | 154 |
* @return |
139 | 155 |
*/ |
140 | 156 |
public ArrayList<ChartCreator> getChartCreators(ChartResult result) { |
... | ... | |
148 | 164 |
|
149 | 165 |
|
150 | 166 |
/** |
151 |
* Checks if the charts engine can create a chart according to the specified result data type and chart type. |
|
167 |
* Checks if the charts engine can create a chart according to the specified result and chart type. |
|
168 |
* |
|
152 | 169 |
* @param resultDataType |
153 | 170 |
* @param chartType |
154 | 171 |
* @return <code>True</code> if a chart creator can be found, otherwise <code>false</code> |
... | ... | |
159 | 176 |
|
160 | 177 |
/** |
161 | 178 |
* Checks if the charts engine can create a chart according to the specified result data type. |
179 |
* |
|
162 | 180 |
* @param resultDataType |
163 | 181 |
* @return <code>True</code> if a chart creator can be found, otherwise <code>false</code> |
164 | 182 |
*/ |
... | ... | |
193 | 211 |
|
194 | 212 |
chartCreator.setChartsEngine(this); |
195 | 213 |
|
196 |
String log = this.getName() + ": Chart creator " + chartCreator.getClass().getSimpleName() + " added for result data type: " + resultDataType; |
|
214 |
String log = this.getName() + ": Chart creator " + chartCreator.getClass().getSimpleName() + " added for result data type: " + resultDataType; //$NON-NLS-1$ //$NON-NLS-2$
|
|
197 | 215 |
|
198 | 216 |
if(chartType != null) { |
199 |
log += " (chart type: " + chartType + ")"; |
|
217 |
log += " (chart type: " + chartType + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
200 | 218 |
} |
201 | 219 |
|
202 |
log +="."; |
|
220 |
log +="."; //$NON-NLS-1$
|
|
203 | 221 |
|
204 | 222 |
Log.finest(log); |
205 | 223 |
|
206 | 224 |
} |
207 | 225 |
|
208 |
// /** |
|
209 |
// * Creates and stores charts engines from installed extension contributions. |
|
210 |
// * @param outputFormat |
|
211 |
// */ |
|
212 |
// @Deprecated |
|
213 |
// public static void createChartsEngines() { |
|
214 |
// |
|
215 |
// Log.finest("Looking for charts engines contributions with extension point id " + ChartsEngine.EXTENSION_POINT_ID + "."); |
|
216 |
// |
|
217 |
// ChartsEngine.chartsEngines = new ArrayList<ChartsEngine>(); |
|
218 |
// ChartsEngine.currentChartsEngineIndex = 0; |
|
219 |
// |
|
220 |
// IConfigurationElement[] contributions = RegistryFactory.getRegistry().getConfigurationElementsFor(ChartsEngine.EXTENSION_POINT_ID); |
|
221 |
// |
|
222 |
// Log.finest(contributions.length + " charts engines found."); |
|
223 |
// |
|
224 |
// for(int i = 0; i < contributions.length; i++) { |
|
225 |
// try { |
|
226 |
// ChartsEngine chartsEngine = (ChartsEngine)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$ |
|
227 |
// chartsEngine.registerChartCreatorExtensions(); |
|
228 |
// ChartsEngine.chartsEngines.add(chartsEngine); |
|
229 |
// } |
|
230 |
// catch(CoreException e) { |
|
231 |
// e.printStackTrace(); |
|
232 |
// } |
|
233 |
// } |
|
234 |
// } |
|
235 |
|
|
236 | 226 |
/** |
237 | 227 |
* Gets the current charts engine. |
228 |
* Convenience method to return the current chart engine of the charts engines manager. |
|
238 | 229 |
* @return the current charts engine |
239 | 230 |
*/ |
240 |
@Deprecated |
|
241 | 231 |
public static ChartsEngine getCurrent() { |
242 |
return (ChartsEngine) Toolbox.getEngineManager(EngineType.CHARTS).getCurrentEngine();
|
|
232 |
return ChartsEnginesManager.getInstance().getCurrentEngine();
|
|
243 | 233 |
} |
244 | 234 |
|
245 |
|
|
246 |
/** |
|
247 |
* Gets an installed charts engine according to its class type. |
|
248 |
* @param type |
|
249 |
* @return the installed charts engine according to its class type if it exists otherwise null |
|
250 |
*/ |
|
251 |
@Deprecated |
|
252 |
public static ChartsEngine getChartsEngine(Class type) { |
|
253 |
ChartsEngine chartsEngine = null; |
|
254 |
for(int i = 0; i < ChartsEngine.chartsEngines.size(); i++) { |
|
255 |
if(ChartsEngine.chartsEngines.get(i).getClass().equals(type)) { |
|
256 |
chartsEngine = ChartsEngine.chartsEngines.get(i); |
|
257 |
break; |
|
258 |
} |
|
259 |
} |
|
260 |
return chartsEngine; |
|
261 |
} |
|
262 |
|
|
263 |
/** |
|
264 |
* Gets an installed charts engine that supports the specified output format. |
|
265 |
* @param outputFormat |
|
266 |
* @return |
|
267 |
*/ |
|
268 |
@Deprecated |
|
269 |
public static ChartsEngine getChartsEngine(String outputFormat) { |
|
270 |
ChartsEngine chartsEngine = null; |
|
271 |
for(int i = 0; i < ChartsEngine.chartsEngines.size(); i++) { |
|
272 |
if(ChartsEngine.chartsEngines.get(i).getSupportedOutputDisplayFormats().contains(outputFormat) || ChartsEngine.chartsEngines.get(i).getSupportedOutputFileFormats().contains(outputFormat)) { |
|
273 |
chartsEngine = ChartsEngine.chartsEngines.get(i); |
|
274 |
break; |
|
275 |
} |
|
276 |
} |
|
277 |
return chartsEngine; |
|
278 |
} |
|
279 |
|
|
280 |
|
|
235 |
// FIXME: SJ: became useless? |
|
281 | 236 |
// /** |
237 |
// * Gets an installed charts engine according to its class type. |
|
238 |
// * @param type |
|
239 |
// * @return the installed charts engine according to its class type if it exists otherwise null |
|
240 |
// */ |
|
241 |
// @Deprecated |
|
242 |
// public static ChartsEngine getChartsEngine(Class type) { |
|
243 |
// ChartsEngine chartsEngine = null; |
|
244 |
// for(int i = 0; i < ChartsEngine.chartsEngines.size(); i++) { |
|
245 |
// if(ChartsEngine.chartsEngines.get(i).getClass().equals(type)) { |
|
246 |
// chartsEngine = ChartsEngine.chartsEngines.get(i); |
|
247 |
// break; |
|
248 |
// } |
|
249 |
// } |
|
250 |
// return chartsEngine; |
|
251 |
// } |
|
252 |
// /** |
|
282 | 253 |
// * Gets an installed charts engine according to its name. |
283 | 254 |
// * @param type |
284 | 255 |
// * @return the installed charts engine according to its name if it exists otherwise null |
... | ... | |
386 | 357 |
/** |
387 | 358 |
* Creates a temporary file in USER_TXM_HOME\results with the specified prefix for writing the chart. |
388 | 359 |
* The suffix is computed according to the current output format of the charts engine. |
360 |
* |
|
389 | 361 |
* @return |
390 | 362 |
*/ |
391 | 363 |
public File createTmpFile(String prefix) { |
... | ... | |
591 | 563 |
//nothing to do |
592 | 564 |
} |
593 | 565 |
|
566 |
@Override |
|
594 | 567 |
public String getDetails() { |
595 |
return this.getClass()+ " "+ this.toString() + " - is Running = " + this.isRunning(); |
|
568 |
return this.description; |
|
569 |
//return this.getClass()+ " "+ this.toString() + " - is Running = " + this.isRunning(); |
|
596 | 570 |
} |
597 | 571 |
} |
Formats disponibles : Unified diff