Revision 2324
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEnginesManager.java (revision 2324) | ||
---|---|---|
1 | 1 |
package org.txm.chartsengine.core; |
2 | 2 |
|
3 | 3 |
import java.util.ArrayList; |
4 |
import java.util.Arrays; |
|
4 | 5 |
import java.util.Map; |
5 | 6 |
import java.util.TreeSet; |
6 | 7 |
|
... | ... | |
12 | 13 |
import org.txm.core.engines.EnginesManager; |
13 | 14 |
import org.txm.utils.logger.Log; |
14 | 15 |
|
15 |
import cern.colt.Arrays; |
|
16 |
|
|
17 | 16 |
/** |
18 | 17 |
* Charts engines manager. |
19 | 18 |
* |
... | ... | |
36 | 35 |
// and directly manage that in the Manager |
37 | 36 |
ChartsEngine.chartsEngines = new ArrayList<ChartsEngine>(); |
38 | 37 |
// ChartsEngine.currentChartsEngineIndex = 0; |
38 |
// |
|
39 | 39 |
|
40 |
|
|
41 | 40 |
for (ChartsEngine engine : this.values()) { |
42 | 41 |
ChartsEngine.chartsEngines.add(engine); |
43 | 42 |
} |
... | ... | |
45 | 44 |
// add the engines sorted by order defined in preferences |
46 | 45 |
this.sortEngines(); |
47 | 46 |
|
48 |
|
|
47 |
|
|
48 |
// String[] orderedEnginesNames = ((ChartsEnginePreferences) ChartsEnginePreferences.getInstance()).getEnginesOrder(); |
|
49 |
// ChartsEngine[] engines = new ChartsEngine[this.size()]; |
|
50 |
// |
|
51 |
// for (ChartsEngine engine : this.values()) { |
|
52 |
// //ChartsEngine.chartsEngines.add(engine); |
|
53 |
// engines[ArrayUtils.indexOf(orderedEnginesNames, engine.getName())] = engine; |
|
54 |
// |
|
55 |
// } |
|
56 |
// for (int i = 0; i < engines.length; i++) { |
|
57 |
// ChartsEngine.chartsEngines.add(engines[i]); |
|
58 |
// } |
|
59 |
|
|
60 |
|
|
49 | 61 |
//ChartsEngine.setCurrrentChartsEngine(this.getEngine(ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.CURRENT_NAME))); |
50 | 62 |
|
51 | 63 |
this.setCurrentEngine(ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.CURRENT_NAME)); |
52 | 64 |
|
65 |
|
|
53 | 66 |
|
54 | 67 |
//TXMPreferences.alternativeNodesQualifiers.add(ChartsEnginePreferences.getInstance().getPreferencesNodeQualifier()); |
55 | 68 |
|
... | ... | |
71 | 84 |
|
72 | 85 |
for (ChartsEngine engine : this.values()) { |
73 | 86 |
//ChartsEngine.chartsEngines.add(engine); |
74 |
int idx = ArrayUtils.indexOf(orderedEnginesNames, engine.getName());
|
|
75 |
if (idx >= 0) {
|
|
76 |
engines[idx] = engine;
|
|
87 |
int index = ArrayUtils.indexOf(orderedEnginesNames, engine.getName());
|
|
88 |
if (index >= 0) {
|
|
89 |
engines[index] = engine;
|
|
77 | 90 |
} else { |
78 | 91 |
Log.warning("Chart engine='"+engine.getName()+"' not found in engines ordered list: "+Arrays.toString(orderedEnginesNames)); |
79 | 92 |
} |
... | ... | |
108 | 121 |
|
109 | 122 |
/** |
110 | 123 |
* Gets an installed charts engine that supports the specified output format. |
124 |
* Looking for display formats and file formats support. |
|
125 |
* |
|
111 | 126 |
* @param outputFormat |
112 |
* @return |
|
127 |
* @return the first suitable ChartsEngine if exists otherwise null
|
|
113 | 128 |
*/ |
114 |
public ChartsEngine getChartsEngine(String outputFormat) { |
|
129 |
public ChartsEngine getChartsEngine(String outputFormat) { |
|
130 |
|
|
115 | 131 |
ChartsEngine chartsEngine = null; |
116 |
for(int i = 0; i < ChartsEngine.chartsEngines.size(); i++) { |
|
117 |
ChartsEngine ce = ChartsEngine.chartsEngines.get(i); |
|
118 |
if (ce == null) continue; |
|
132 |
for (int i = 0; i < ChartsEngine.chartsEngines.size(); i++) { |
|
119 | 133 |
|
120 |
ArrayList<String> formats = ce.getSupportedOutputDisplayFormats(); |
|
121 |
if(formats != null && formats.contains(outputFormat) || formats.contains(outputFormat)) { |
|
122 |
chartsEngine = ce; |
|
134 |
ChartsEngine tmpChartsEngine = ChartsEngine.chartsEngines.get(i); |
|
135 |
|
|
136 |
// checking display formats |
|
137 |
ArrayList<String> displayFormats = tmpChartsEngine.getSupportedOutputDisplayFormats(); |
|
138 |
if (displayFormats != null && displayFormats.contains(outputFormat)) { |
|
139 |
chartsEngine = tmpChartsEngine; |
|
123 | 140 |
break; |
124 | 141 |
} |
142 |
|
|
143 |
// checking file formats |
|
144 |
ArrayList<String> fileFormats = tmpChartsEngine.getSupportedOutputFileFormats(); |
|
145 |
if (fileFormats != null && fileFormats.contains(outputFormat)) { |
|
146 |
chartsEngine = tmpChartsEngine; |
|
147 |
break; |
|
148 |
} |
|
125 | 149 |
} |
126 | 150 |
return chartsEngine; |
127 | 151 |
} |
Also available in: Unified diff