Révision 2386
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/tests/SWtSwingSnippet.java (revision 2386) | ||
|---|---|---|
| 2 | 2 |
|
| 3 | 3 |
import java.awt.BorderLayout; |
| 4 | 4 |
import java.awt.Frame; |
| 5 |
import java.awt.GridLayout; |
|
| 6 | 5 |
import java.awt.Panel; |
| 7 |
import java.awt.event.KeyAdapter; |
|
| 8 |
import java.awt.event.KeyEvent; |
|
| 6 |
import java.awt.TextField; |
|
| 9 | 7 |
|
| 10 |
import javax.swing.JLabel; |
|
| 11 |
import javax.swing.JRootPane; |
|
| 12 |
import javax.swing.JTextField; |
|
| 13 |
|
|
| 14 | 8 |
import org.eclipse.swt.SWT; |
| 15 | 9 |
import org.eclipse.swt.awt.SWT_AWT; |
| 16 | 10 |
import org.eclipse.swt.layout.FillLayout; |
| 17 | 11 |
import org.eclipse.swt.widgets.Composite; |
| 18 | 12 |
import org.eclipse.swt.widgets.Display; |
| 19 |
import org.eclipse.swt.widgets.Event; |
|
| 20 |
import org.eclipse.swt.widgets.Listener; |
|
| 21 | 13 |
import org.eclipse.swt.widgets.Shell; |
| 22 | 14 |
import org.eclipse.swt.widgets.Text; |
| 23 | 15 |
|
| 16 |
/** |
|
| 17 |
* Focus bug in Linux minimal sample. |
|
| 18 |
* 1) if the AWT TextField has gained focus once, when clicking in the SWT Text widget, the key events are not transmitted |
|
| 19 |
* 2) the AWT Window never loses the focus |
|
| 20 |
* |
|
| 21 |
*/ |
|
| 24 | 22 |
public class SWtSwingSnippet {
|
| 25 | 23 |
|
| 26 | 24 |
public static void main(String[] args) {
|
| ... | ... | |
| 29 | 27 |
final Shell shell = new Shell(display); |
| 30 | 28 |
shell.setLayout(new FillLayout()); |
| 31 | 29 |
|
| 32 |
Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED);
|
|
| 30 |
Composite composite = new Composite(shell, SWT.EMBEDDED); |
|
| 33 | 31 |
|
| 34 |
try {
|
|
| 35 |
System.setProperty("sun.awt.noerasebackground","true");
|
|
| 36 |
} catch (NoSuchMethodError error) {}
|
|
| 37 |
|
|
| 38 |
/* Create and setting up frame */ |
|
| 39 | 32 |
Frame frame = SWT_AWT.new_Frame(composite); |
| 40 |
Panel panel = new Panel(new BorderLayout()) {
|
|
| 41 |
public void update(java.awt.Graphics g) {
|
|
| 42 |
paint(g); |
|
| 43 |
} |
|
| 44 |
}; |
|
| 33 |
Panel panel = new Panel(new BorderLayout()); |
|
| 45 | 34 |
frame.add(panel); |
| 46 |
JRootPane root = new JRootPane(); |
|
| 47 |
panel.add(root); |
|
| 48 |
java.awt.Container contentPane = root.getContentPane(); |
|
| 49 |
|
|
| 50 |
JLabel label1 = new JLabel("Text 1");
|
|
| 51 |
JTextField field1 = new JTextField(10); |
|
| 35 |
panel.add(new TextField()); |
|
| 52 | 36 |
|
| 53 |
JLabel label2 = new JLabel("Text 2");
|
|
| 54 |
JTextField field2 = new JTextField(10); |
|
| 55 |
|
|
| 56 |
contentPane.setLayout(new GridLayout(2,2)); |
|
| 57 |
contentPane.add(label1); |
|
| 58 |
contentPane.add(field1); |
|
| 59 |
contentPane.add(label2); |
|
| 60 |
contentPane.add(field2); |
|
| 61 |
|
|
| 62 | 37 |
Text text = new Text(shell, SWT.BORDER); |
| 63 | 38 |
|
| 64 |
|
|
| 65 | 39 |
shell.setSize(200,70); |
| 66 | 40 |
shell.open(); |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
field1.addKeyListener(new KeyAdapter() {
|
|
| 73 |
public void keyPressed(KeyEvent e) {
|
|
| 74 |
System.out.println("key pressed in swing");
|
|
| 75 |
} |
|
| 76 |
public void keyReleased(KeyEvent e) {
|
|
| 77 |
System.out.println("key released in swing"); }
|
|
| 78 |
public void keyTyped(KeyEvent e) {
|
|
| 79 |
System.out.println("key typed in swing");
|
|
| 80 |
} |
|
| 81 |
}); |
|
| 82 |
display.addFilter(SWT.KeyDown,new Listener() {
|
|
| 83 |
public void handleEvent(Event event) {
|
|
| 84 |
System.out.println("key down in SWT");
|
|
| 85 |
} |
|
| 86 |
}); |
|
| 87 |
display.addFilter(SWT.KeyUp,new Listener() {
|
|
| 88 |
public void handleEvent(Event event) {
|
|
| 89 |
System.out.println("key up in SWT");
|
|
| 90 |
} |
|
| 91 |
}); |
|
| 92 |
display.addFilter(SWT.MouseMove,new Listener() {
|
|
| 93 |
public void handleEvent(Event event) {
|
|
| 94 |
System.out.println("mouse move in SWT");
|
|
| 95 |
} |
|
| 96 |
}); |
|
| 97 |
display.addFilter(SWT.MouseDown,new Listener() {
|
|
| 98 |
public void handleEvent(Event event) {
|
|
| 99 |
System.out.println("mouse down in SWT");
|
|
| 100 |
} |
|
| 101 |
}); |
|
| 102 |
display.addFilter(SWT.MouseUp,new Listener() {
|
|
| 103 |
public void handleEvent(Event event) {
|
|
| 104 |
System.out.println("mouse up in SWT");
|
|
| 105 |
} |
|
| 106 |
}); |
|
| 107 |
display.addFilter(SWT.MouseEnter,new Listener() {
|
|
| 108 |
public void handleEvent(Event event) {
|
|
| 109 |
System.out.println("mouse enter in SWT");
|
|
| 110 |
} |
|
| 111 |
}); |
|
| 112 | 41 |
|
| 113 | 42 |
while(!shell.isDisposed()) {
|
| 114 |
if (!display.readAndDispatch()) display.sleep(); |
|
| 43 |
if (!display.readAndDispatch()) {
|
|
| 44 |
display.sleep(); |
|
| 45 |
} |
|
| 115 | 46 |
} |
| 116 | 47 |
display.dispose(); |
| 117 | 48 |
} |
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 2386) | ||
|---|---|---|
| 162 | 162 |
|
| 163 | 163 |
for(int i = 0; i < contributions.length; i++) {
|
| 164 | 164 |
|
| 165 |
// FIXME: to manage more than one input format, Store them in the class rather than in the extension schema? |
|
| 165 |
// FIXME: SJ: to manage more than one input format, Store them in the class rather than in the extension schema?
|
|
| 166 | 166 |
String formatsStr = contributions[i].getAttribute("inputFormat").replace(" ", "").trim(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
| 167 | 167 |
String[] formats = formatsStr.split(","); //$NON-NLS-1$
|
| 168 | 168 |
|
| ... | ... | |
| 227 | 227 |
* @param chartsEngine |
| 228 | 228 |
* @return the first components provider that manages the format of the specified charts engine |
| 229 | 229 |
*/ |
| 230 |
public static SWTChartsComponentsProvider getComponentsProvider(ChartsEngine chartsEngine) {
|
|
| 230 |
public static SWTChartsComponentsProvider getComponentsProvider(ChartsEngine chartsEngine) {
|
|
| 231 | 231 |
|
| 232 | 232 |
SWTChartsComponentsProvider chartsComponentsProvider = null; |
| 233 | 233 |
|
| 234 |
for(int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
|
|
| 235 |
if(SWTChartsComponentsProvider.chartsComponentsProviders.get(i).canCreateView(chartsEngine)) {
|
|
| 236 |
|
|
| 234 |
for (int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
|
|
| 235 |
if (SWTChartsComponentsProvider.chartsComponentsProviders.get(i).canCreateView(chartsEngine)) {
|
|
| 236 |
|
|
| 237 | 237 |
chartsComponentsProvider = SWTChartsComponentsProvider.chartsComponentsProviders.get(i); |
| 238 | 238 |
break; |
| 239 | 239 |
} |
| ... | ... | |
| 249 | 249 |
* @param type |
| 250 | 250 |
* @return the installed charts components provider according to its class type if it exists otherwise null |
| 251 | 251 |
*/ |
| 252 |
public static SWTChartsComponentsProvider getComponentsProvider(Class type) {
|
|
| 252 |
public static SWTChartsComponentsProvider getComponentsProvider(Class type) {
|
|
| 253 | 253 |
|
| 254 | 254 |
SWTChartsComponentsProvider provider = null; |
| 255 | 255 |
|
| 256 |
for(int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
|
|
| 257 |
if(SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getClass().equals(type)) {
|
|
| 256 |
for (int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
|
|
| 257 |
if (SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getClass().equals(type)) {
|
|
| 258 | 258 |
provider = SWTChartsComponentsProvider.chartsComponentsProviders.get(i); |
| 259 | 259 |
break; |
| 260 | 260 |
} |
| ... | ... | |
| 262 | 262 |
|
| 263 | 263 |
return provider; |
| 264 | 264 |
} |
| 265 |
|
|
| 265 |
|
|
| 266 | 266 |
/** |
| 267 | 267 |
* Checks if the components provider can create a composite to render a chart generated by the specified charts engine using its current output format. |
| 268 | 268 |
* |
| 269 | 269 |
* @param chartsEngine |
| 270 | 270 |
* @return |
| 271 | 271 |
*/ |
| 272 |
protected boolean canCreateView(ChartsEngine chartsEngine) {
|
|
| 272 |
protected boolean canCreateView(ChartsEngine chartsEngine) {
|
|
| 273 | 273 |
return this.getEditorSupportedInputFormats().contains(chartsEngine.getOutputFormat()); |
| 274 | 274 |
} |
| 275 | 275 |
|
| 276 | 276 |
|
| 277 | 277 |
/** |
| 278 | 278 |
* Set the current charts engine. |
| 279 |
* |
|
| 279 | 280 |
* @param chartsEngine the chartsEngine to set |
| 280 | 281 |
*/ |
| 281 | 282 |
public void setChartsEngine(ChartsEngine chartsEngine) {
|
| 282 | 283 |
this.chartsEngine = chartsEngine; |
| 283 | 284 |
} |
| 284 |
|
|
| 285 |
|
|
| 285 |
|
|
| 286 |
|
|
| 286 | 287 |
/** |
| 287 | 288 |
* Gets the charts engine. |
| 289 |
* |
|
| 288 | 290 |
* @return the chartsEngine |
| 289 | 291 |
*/ |
| 290 | 292 |
public ChartsEngine getChartsEngine() {
|
| tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 2386) | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
/** |
| 15 | 15 |
* Chart result. |
| 16 |
* |
|
| 16 | 17 |
* @author sjacquot |
| 17 | 18 |
* |
| 18 | 19 |
*/ |
| 19 | 20 |
public abstract class ChartResult extends TXMResult {
|
| 20 |
|
|
| 21 |
|
|
| 21 |
|
|
| 22 |
|
|
| 22 | 23 |
/** |
| 23 | 24 |
* Linked charts engine. |
| 24 | 25 |
*/ |
| 25 | 26 |
protected ChartsEngine chartsEngine; |
| 26 |
|
|
| 27 |
|
|
| 27 | 28 |
/** |
| 28 | 29 |
* The chart object. |
| 29 | 30 |
*/ |
| 30 | 31 |
protected Object chart; |
| 31 |
|
|
| 32 |
|
|
| 32 | 33 |
/** |
| 33 | 34 |
* The chart dirty state. |
| 34 | 35 |
*/ |
| 35 | 36 |
protected boolean chartDirty; |
| 36 |
|
|
| 37 |
|
|
| 37 | 38 |
/** |
| 38 | 39 |
* If true, the view (zoom, pan, etc.) will be reset when the chart will be updated. |
| 39 | 40 |
*/ |
| 40 | 41 |
protected boolean needsToResetView; |
| 41 |
|
|
| 42 |
|
|
| 42 | 43 |
/** |
| 43 | 44 |
* If true, the items selection will cleared when the chart will be updated. |
| 44 | 45 |
*/ |
| 45 | 46 |
protected boolean needsToClearItemsSelection; |
| 46 |
|
|
| 47 |
|
|
| 47 | 48 |
/** |
| 48 | 49 |
* If true, the items selection will cleared when the chart will be updated. |
| 49 | 50 |
*/ |
| 50 | 51 |
protected boolean needsToSquareOff; |
| 51 |
|
|
| 52 | 52 |
|
| 53 |
|
|
| 53 | 54 |
/** |
| 54 | 55 |
* To show/hide domain grid lines. |
| 55 | 56 |
*/ |
| 56 | 57 |
protected boolean domainGridLinesVisible; |
| 57 | 58 |
|
| 58 |
|
|
| 59 |
|
|
| 59 | 60 |
/** |
| 60 | 61 |
* The chart type; |
| 61 | 62 |
*/ |
| 62 |
@Parameter(key=ChartsEnginePreferences.CHART_TYPE, type=Parameter.RENDERING)
|
|
| 63 |
@Parameter(key = ChartsEnginePreferences.CHART_TYPE, type = Parameter.RENDERING)
|
|
| 63 | 64 |
protected String chartType; |
| 64 |
|
|
| 65 |
|
|
| 65 |
|
|
| 66 |
|
|
| 66 | 67 |
/** |
| 67 | 68 |
* To show/hide title. |
| 68 | 69 |
*/ |
| 69 |
@Parameter(key=ChartsEnginePreferences.SHOW_TITLE, type=Parameter.RENDERING)
|
|
| 70 |
@Parameter(key = ChartsEnginePreferences.SHOW_TITLE, type = Parameter.RENDERING)
|
|
| 70 | 71 |
protected boolean titleVisible; |
| 71 |
|
|
| 72 |
|
|
| 72 | 73 |
/** |
| 73 | 74 |
* To show/hide legend. |
| 74 | 75 |
*/ |
| 75 |
@Parameter(key=ChartsEnginePreferences.SHOW_LEGEND, type=Parameter.RENDERING)
|
|
| 76 |
@Parameter(key = ChartsEnginePreferences.SHOW_LEGEND, type = Parameter.RENDERING)
|
|
| 76 | 77 |
protected boolean legendVisible; |
| 77 |
|
|
| 78 |
|
|
| 78 | 79 |
/** |
| 79 | 80 |
* To show/hide grid. |
| 80 | 81 |
*/ |
| 81 |
@Parameter(key=ChartsEnginePreferences.SHOW_GRID, type=Parameter.RENDERING)
|
|
| 82 |
@Parameter(key = ChartsEnginePreferences.SHOW_GRID, type = Parameter.RENDERING)
|
|
| 82 | 83 |
protected boolean gridVisible; |
| 83 |
|
|
| 84 |
|
|
| 84 | 85 |
/** |
| 85 | 86 |
* Rendering colors mode |
| 86 | 87 |
*/ |
| 87 |
@Parameter(key=ChartsEnginePreferences.RENDERING_COLORS_MODE, type=Parameter.RENDERING)
|
|
| 88 |
@Parameter(key = ChartsEnginePreferences.RENDERING_COLORS_MODE, type = Parameter.RENDERING)
|
|
| 88 | 89 |
protected int renderingColorsMode; |
| 89 |
|
|
| 90 |
|
|
| 90 | 91 |
/** |
| 91 | 92 |
* Font. |
| 92 | 93 |
*/ |
| 93 |
@Parameter(key=ChartsEnginePreferences.FONT, type=Parameter.RENDERING)
|
|
| 94 |
@Parameter(key = ChartsEnginePreferences.FONT, type = Parameter.RENDERING)
|
|
| 94 | 95 |
protected String font; |
| 95 |
|
|
| 96 |
|
|
| 96 |
|
|
| 97 |
|
|
| 97 | 98 |
/** |
| 98 | 99 |
* Multiple lines styles/strokes. |
| 99 | 100 |
*/ |
| 100 |
@Parameter(key=ChartsEnginePreferences.MULTIPLE_LINE_STROKES, type=Parameter.RENDERING)
|
|
| 101 |
@Parameter(key = ChartsEnginePreferences.MULTIPLE_LINE_STROKES, type = Parameter.RENDERING)
|
|
| 101 | 102 |
protected boolean multipleLineStrokes; |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 106 | 107 |
/** |
| 107 | 108 |
* Creates a new ChartResult child of the specified parent. |
| 109 |
* |
|
| 108 | 110 |
* @param parent |
| 109 | 111 |
*/ |
| 110 | 112 |
public ChartResult(TXMResult parent) {
|
| 111 | 113 |
this(null, parent); |
| 112 | 114 |
} |
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 115 | 117 |
/** |
| 116 | 118 |
* Creates a new ChartResult with no parent. |
| 117 |
* If a local node exist with the parent_uuid, the parent will be retrieved and this result will be added to it. |
|
| 119 |
* If a local node exist with the parent_uuid, the parent will be retrieved and this result will be added to it. |
|
| 120 |
* |
|
| 118 | 121 |
* @param parametersNodePath |
| 119 | 122 |
*/ |
| 120 | 123 |
public ChartResult(String parametersNodePath) {
|
| 121 | 124 |
this(parametersNodePath, null); |
| 122 | 125 |
} |
| 123 |
|
|
| 126 |
|
|
| 124 | 127 |
/** |
| 125 | 128 |
* Creates a new ChartResult child of the specified parent. |
| 129 |
* |
|
| 126 | 130 |
* @param uuid |
| 127 | 131 |
* @param parent |
| 128 | 132 |
*/ |
| ... | ... | |
| 135 | 139 |
this.needsToSquareOff = false; |
| 136 | 140 |
this.domainGridLinesVisible = true; |
| 137 | 141 |
} |
| 138 |
|
|
| 139 |
|
|
| 142 |
|
|
| 143 |
|
|
| 140 | 144 |
@Override |
| 141 | 145 |
protected boolean autoLoadParametersFromAnnotations() throws Exception {
|
| 142 | 146 |
return (super.autoLoadParametersFromAnnotations() |
| 143 | 147 |
&& super.autoLoadParametersFromAnnotations(Parameter.RENDERING)); |
| 144 | 148 |
} |
| 145 |
|
|
| 146 |
|
|
| 149 |
|
|
| 150 |
|
|
| 147 | 151 |
@Override |
| 148 | 152 |
public void setDirty() {
|
| 149 | 153 |
super.setDirty(); |
| 150 |
//this.chart = null;
|
|
| 154 |
// this.chart = null; // FIXME: SJ: became useless?
|
|
| 151 | 155 |
this.setChartDirty(); |
| 152 | 156 |
} |
| 153 |
|
|
| 157 |
|
|
| 154 | 158 |
/** |
| 155 | 159 |
* |
| 156 | 160 |
*/ |
| 157 | 161 |
public void setChartDirty() {
|
| 158 | 162 |
this.chartDirty = true; |
| 159 | 163 |
} |
| 160 |
|
|
| 164 |
|
|
| 161 | 165 |
@Override |
| 162 | 166 |
public boolean compute(IProgressMonitor monitor) {
|
| 163 | 167 |
return compute(monitor, true); |
| 164 | 168 |
} |
| 165 |
|
|
| 169 |
|
|
| 166 | 170 |
/** |
| 167 |
* This method is dedicated to be implemented by the inherited chart result classes to define the computing steps. |
|
| 171 |
* This method is dedicated to be implemented by the inherited chart result classes to define the computing steps. |
|
| 172 |
* |
|
| 168 | 173 |
* @return true if the result was computed |
| 169 | 174 |
* |
| 170 | 175 |
* @throws Exception |
| ... | ... | |
| 173 | 178 |
|
| 174 | 179 |
|
| 175 | 180 |
@Override |
| 176 |
protected final boolean _compute() {
|
|
| 181 |
protected final boolean _compute() {
|
|
| 177 | 182 |
|
| 178 | 183 |
boolean computingState = true; |
| 179 | 184 |
|
| 180 | 185 |
try {
|
| 181 | 186 |
Log.finest("*** ChartResult._compute(): " + this.getClass().getSimpleName() + ": starting computing process...");
|
| 182 | 187 |
|
| 183 |
// Computes the result only if at least one computing parameter has changed |
|
| 184 |
//if(this.hasParameterChanged()) {
|
|
| 185 |
computingState = this.__compute();
|
|
| 186 |
//} |
|
| 187 |
if (computingState) {
|
|
| 188 |
computingState = this.renderChart();
|
|
| 189 |
}
|
|
| 188 |
// FIXME: SJ: Computes the result only if at least one computing parameter has changed
|
|
| 189 |
// if(this.hasParameterChanged()) {
|
|
| 190 |
computingState = this.__compute(); |
|
| 191 |
// }
|
|
| 192 |
if (computingState) {
|
|
| 193 |
computingState = this.renderChart(); |
|
| 194 |
} |
|
| 190 | 195 |
} |
| 191 | 196 |
catch (Exception e) {
|
| 192 | 197 |
e.printStackTrace(); |
| ... | ... | |
| 196 | 201 |
|
| 197 | 202 |
return computingState; |
| 198 | 203 |
} |
| 199 |
|
|
| 204 |
|
|
| 200 | 205 |
/** |
| 201 | 206 |
* Renders the chart using the right chart creator. |
| 202 | 207 |
* The chart is created if needed then it is updated. |
| ... | ... | |
| 205 | 210 |
* @throws Exception |
| 206 | 211 |
*/ |
| 207 | 212 |
protected boolean renderChart() throws Exception {
|
| 208 |
|
|
| 213 |
|
|
| 209 | 214 |
this.subTask("Rendering chart for result " + this.getClass() + " and chart type " + this.getChartType() + ".");
|
| 210 |
|
|
| 215 |
|
|
| 211 | 216 |
Log.finest("*** ChartResult.renderChart(): rendering chart for result " + this.getClass() + " and chart type " + this.getChartType() + "..."); //$NON-NLS-1$
|
| 212 |
|
|
| 217 |
|
|
| 213 | 218 |
// update the chart dirty state from history if a parameter has changed since last computing |
| 214 | 219 |
this.updateChartDirtyFromHistory(); |
| 215 | 220 |
|
| ... | ... | |
| 217 | 222 |
Log.finest("--- ChartResult.renderChart(): chart rendering parameters have not changed since last rendering, rendering skipped."); //$NON-NLS-1$
|
| 218 | 223 |
return true; |
| 219 | 224 |
} |
| 220 |
|
|
| 225 |
|
|
| 221 | 226 |
ChartCreator chartCreator = this.getChartCreator(); |
| 222 |
|
|
| 227 |
|
|
| 223 | 228 |
// try to find a chart creator in other charts engines |
| 224 |
if(chartCreator == null) {
|
|
| 229 |
if (chartCreator == null) {
|
|
| 225 | 230 |
for (int i = 0; i < ChartsEngine.getChartsEngines().size(); i++) {
|
| 226 |
ChartsEngine chartsEngine = ChartsEngine.getChartsEngines().get(i);
|
|
| 227 |
if(chartsEngine == this.chartsEngine) {
|
|
| 231 |
ChartsEngine chartsEngine = ChartsEngine.getChartsEngines().get(i); |
|
| 232 |
if (chartsEngine == this.chartsEngine) {
|
|
| 228 | 233 |
continue; |
| 229 | 234 |
} |
| 230 | 235 |
chartCreator = chartsEngine.getChartCreator(this); |
| 231 |
if(chartCreator != null) {
|
|
| 236 |
if (chartCreator != null) {
|
|
| 232 | 237 |
Log.finest("ChartResult.renderChart(): another suitable chart creator has been found in charts engine: " + chartsEngine + "."); //$NON-NLS-1$
|
| 233 | 238 |
this.chartsEngine = chartsEngine; |
| 234 | 239 |
break; |
| 235 | 240 |
} |
| 236 | 241 |
} |
| 237 | 242 |
} |
| 238 |
|
|
| 239 |
|
|
| 240 |
if(chartCreator != null) {
|
|
| 241 |
|
|
| 243 |
|
|
| 244 |
|
|
| 245 |
if (chartCreator != null) {
|
|
| 246 |
|
|
| 242 | 247 |
// FIXME: fix #1 |
| 243 | 248 |
// FIXME: SJ: without this, this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE) returns true for results that added their computing parameters in the parameter history. |
| 244 |
// Since the stack is shared by computing and rendering parameters, this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE) returns true because the parameter doesn't exist in the last stack entry filled only with the computing parameter |
|
| 249 |
// Since the stack is shared by computing and rendering parameters, this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE) returns true because the parameter doesn't exist in the |
|
| 250 |
// last stack entry filled only with the computing parameter |
|
| 245 | 251 |
// may need to fix this in another way: |
| 246 | 252 |
// Solution 1: store two stacks, one for computing parameters and another for rendering parameters |
| 247 | 253 |
// Solution 2: stop to dissociate rendering parameters and computing parameters. Maybe the best way but need to check if this dissociation is very useless |
| 248 | 254 |
// clear the last computing parameters |
| 249 |
// if(this.parametersHistory.size() > 2
|
|
| 250 |
//
|
|
| 251 |
// //|| this.getLastParametersFromHistory().isEmpty()
|
|
| 252 |
// ) {
|
|
| 253 |
// this.clearLastComputingParameters();
|
|
| 254 |
// }
|
|
| 255 |
|
|
| 255 |
// if(this.parametersHistory.size() > 2
|
|
| 256 |
//
|
|
| 257 |
// //|| this.getLastParametersFromHistory().isEmpty()
|
|
| 258 |
// ) {
|
|
| 259 |
// this.clearLastComputingParameters();
|
|
| 260 |
// }
|
|
| 261 |
|
|
| 256 | 262 |
// Creating, if needed. |
| 257 | 263 |
// The change of the chart type parameter can occur if: |
| 258 | 264 |
// - the chart has never been created |
| 259 | 265 |
// - the chart type has been changed, e.g. to dynamically change the type of chart or the current charts engine |
| 260 |
if (this.chart == null ||
|
|
| 261 |
(this.getLastParametersFromHistory().get(ChartsEnginePreferences.CHART_TYPE) != null &&
|
|
| 262 |
this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE)) |
|
| 263 |
//)
|
|
| 264 |
|
|
| 265 |
) {
|
|
| 266 |
if (this.chart == null || |
|
| 267 |
(this.getLastParametersFromHistory().get(ChartsEnginePreferences.CHART_TYPE) != null && |
|
| 268 |
this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE))
|
|
| 269 |
// )
|
|
| 270 |
|
|
| 271 |
) {
|
|
| 266 | 272 |
Log.finest("+++ ChartResult.renderChart(): creating chart..."); //$NON-NLS-1$
|
| 267 |
|
|
| 273 |
|
|
| 268 | 274 |
this.chart = chartCreator.createChart(this); |
| 269 | 275 |
} |
| 270 |
|
|
| 276 |
|
|
| 271 | 277 |
// Updating |
| 272 | 278 |
Log.finest("ChartResult.renderChart(): updating chart..."); //$NON-NLS-1$
|
| 273 |
|
|
| 274 |
// the update must be done here (BEFORE the call of this.updateLastRenderingParameters()) rather than in the SWTChartComponentsProvider => the problem is that for File based Engine, the file may be created twice, need to check this |
|
| 275 |
// also before the call of this.updateLastParameters() to be able to check if a computing parameter has changed in the chart creators |
|
| 276 |
//FIXME: SJ: this call doesn't work well with File based charts engines, the file is created one time in createChartFile() and a second time in updateChart() |
|
| 279 |
|
|
| 280 |
// the update must be done here (BEFORE the call of this.updateLastRenderingParameters()) rather than in the SWTChartComponentsProvider => the problem is that for File based Engine, the |
|
| 281 |
// file may be created twice, need to check this |
|
| 282 |
// also before the call of this.updateLastParameters() to be able to check if a computing parameter has changed in the chart creators |
|
| 283 |
// FIXME: SJ: this call doesn't work well with File based charts engines, the file is created one time in createChartFile() and a second time in updateChart() |
|
| 277 | 284 |
chartCreator.updateChart(this); |
| 278 |
|
|
| 285 |
|
|
| 279 | 286 |
// FIXME: needed by the above fix #1 |
| 280 | 287 |
// reupdate the last computing parameters |
| 281 |
//this.updateLastParameters(); |
|
| 282 |
|
|
| 283 |
//this.updateLastRenderingParameters(); |
|
| 284 |
|
|
| 288 |
// this.updateLastParameters();
|
|
| 289 |
|
|
| 290 |
// this.updateLastRenderingParameters();
|
|
| 291 |
|
|
| 285 | 292 |
this.needsToClearItemsSelection = false; |
| 286 | 293 |
this.needsToResetView = false; |
| 287 |
|
|
| 294 |
|
|
| 288 | 295 |
this.chartDirty = false; |
| 289 |
|
|
| 296 |
|
|
| 290 | 297 |
// Debug |
| 291 | 298 |
Log.finest("ChartResult.renderChart(): chart rendering done."); //$NON-NLS-1$
|
| 292 |
|
|
| 299 |
|
|
| 293 | 300 |
return true; |
| 294 |
|
|
| 301 |
|
|
| 295 | 302 |
} |
| 296 |
else {
|
|
| 303 |
else {
|
|
| 297 | 304 |
Log.severe("ChartResult.renderChart(): can not find any suitable chart creator for result: " + this.getClass() + "."); //$NON-NLS-1$
|
| 298 | 305 |
return false; |
| 299 | 306 |
} |
| 300 | 307 |
} |
| 301 |
|
|
| 308 |
|
|
| 302 | 309 |
@Override |
| 303 | 310 |
public String dumpParameters() {
|
| 304 | 311 |
return super.dumpParameters() + "\n" + this.dumpParameters(Parameter.RENDERING); //$NON-NLS-1$ |
| 305 | 312 |
} |
| 306 |
|
|
| 313 |
|
|
| 307 | 314 |
/** |
| 308 | 315 |
* Clears the parameters used for last rendering. |
| 309 | 316 |
* Dedicated to force a chart recreation, eg. for cloning the chart result or for dynamically changing the chart type . |
| 317 |
* |
|
| 310 | 318 |
* @throws Exception |
| 311 | 319 |
*/ |
| 312 | 320 |
public void clearLastRenderingParameters() {
|
| 313 | 321 |
this.clearLastParameters(Parameter.RENDERING); |
| 314 | 322 |
} |
| 315 |
|
|
| 323 |
|
|
| 316 | 324 |
/** |
| 317 | 325 |
* Checks if at least one rendering parameter value has changed since last computing. |
| 326 |
* |
|
| 318 | 327 |
* @return |
| 319 | 328 |
* @throws Exception |
| 320 | 329 |
*/ |
| ... | ... | |
| 325 | 334 |
@Override |
| 326 | 335 |
public void updateDirtyFromHistory() throws Exception {
|
| 327 | 336 |
this.dirty = super.hasParameterChanged(); |
| 328 |
if(!this.dirty) {
|
|
| 337 |
if (!this.dirty) {
|
|
| 329 | 338 |
this.dirty = this.hasRenderingParameterChanged(); |
| 330 | 339 |
} |
| 331 | 340 |
} |
| ... | ... | |
| 333 | 342 |
|
| 334 | 343 |
/** |
| 335 | 344 |
* Sets the chart dirty state to true if a rendering parameter has changed since last computing. |
| 345 |
* |
|
| 336 | 346 |
* @return |
| 337 | 347 |
* @throws Exception |
| 338 | 348 |
*/ |
| 339 | 349 |
public void updateChartDirtyFromHistory() throws Exception {
|
| 340 |
|
|
| 341 |
if(this.hasRenderingParameterChanged()) {
|
|
| 350 |
|
|
| 351 |
if (this.hasRenderingParameterChanged()) {
|
|
| 342 | 352 |
this.chartDirty = true; |
| 343 | 353 |
} |
| 344 | 354 |
} |
| 345 |
|
|
| 355 |
|
|
| 346 | 356 |
@Override |
| 347 | 357 |
public ChartResult clone() {
|
| 348 | 358 |
ChartResult clone = null; |
| 349 | 359 |
clone = (ChartResult) super.clone(); |
| 350 | 360 |
clone.chart = null; |
| 351 | 361 |
// FIXME: SJ: would be nice to clone the chart if possible instead of clearing the last rendering parameters? |
| 352 |
//clone.chart = this.chart.clone(); |
|
| 362 |
// clone.chart = this.chart.clone();
|
|
| 353 | 363 |
clone.clearLastRenderingParameters(); // to force recreation of the chart at next computing // FIXME: SJ: need to see if it's necessary, the chartDirty state may be sufficient |
| 354 | 364 |
clone.chartDirty = true; |
| 355 | 365 |
clone.hasBeenComputedOnce = false; |
| 356 | 366 |
return clone; |
| 357 | 367 |
} |
| 358 |
|
|
| 368 |
|
|
| 359 | 369 |
/** |
| 360 | 370 |
* @return the chart |
| 361 | 371 |
*/ |
| 362 | 372 |
public Object getChart() {
|
| 363 | 373 |
return chart; |
| 364 | 374 |
} |
| 365 |
|
|
| 366 |
|
|
| 375 |
|
|
| 376 |
|
|
| 367 | 377 |
/** |
| 368 | 378 |
* @return the chartType |
| 369 | 379 |
*/ |
| 370 | 380 |
public String getChartType() {
|
| 371 | 381 |
return chartType; |
| 372 | 382 |
} |
| 373 |
|
|
| 374 |
|
|
| 383 |
|
|
| 384 |
|
|
| 375 | 385 |
/** |
| 376 |
* Gets a chart creator for this chart result according to its current type and current charts engine. |
|
| 386 |
* Gets a chart creator for this chart result according to its current type and current charts engine. |
|
| 387 |
* |
|
| 377 | 388 |
* @return a suitable chart creator if exists, otherwise null |
| 378 | 389 |
*/ |
| 379 |
public ChartCreator getChartCreator() {
|
|
| 390 |
public ChartCreator getChartCreator() {
|
|
| 380 | 391 |
return this.chartsEngine.getChartCreator(this); |
| 381 | 392 |
} |
| 382 |
|
|
| 393 |
|
|
| 383 | 394 |
/** |
| 384 | 395 |
* @param chartType the chartType to set |
| 385 | 396 |
*/ |
| ... | ... | |
| 388 | 399 |
|
| 389 | 400 |
// FIXME: SJ: need to validate this |
| 390 | 401 |
this.getLastParametersFromHistory().put(ChartsEnginePreferences.CHART_TYPE, "__undef___"); //$NON-NLS-1$ |
| 391 |
|
|
| 392 | 402 |
|
| 393 |
//this.getLastParametersFromHistory().put(ChartsEnginePreferences.CHART_TYPE, "[Default]"); |
|
| 394 | 403 |
|
| 395 |
|
|
| 404 |
// this.getLastParametersFromHistory().put(ChartsEnginePreferences.CHART_TYPE, "[Default]"); |
|
| 396 | 405 |
|
| 406 |
|
|
| 407 |
|
|
| 397 | 408 |
// clear all last parameters to force a full recomputing |
| 398 |
//this.clearLastRenderingParameters(); |
|
| 399 |
// this.clearLastRenderingParameters();
|
|
| 409 |
// this.clearLastRenderingParameters();
|
|
| 410 |
// this.clearLastRenderingParameters();
|
|
| 400 | 411 |
} |
| 401 |
|
|
| 412 |
|
|
| 402 | 413 |
/** |
| 403 | 414 |
* Sets the chart type as default. |
| 404 | 415 |
*/ |
| 405 |
public void setDefaultChartType() {
|
|
| 416 |
public void setDefaultChartType() {
|
|
| 406 | 417 |
this.setChartType(ChartsEnginePreferences.DEFAULT_CHART_TYPE); |
| 407 | 418 |
} |
| 408 |
|
|
| 419 |
|
|
| 409 | 420 |
/** |
| 410 | 421 |
* Checks if the current chart type is the default one. |
| 422 |
* |
|
| 411 | 423 |
* @return |
| 412 | 424 |
*/ |
| 413 |
public boolean isDefaultChartType() {
|
|
| 425 |
public boolean isDefaultChartType() {
|
|
| 414 | 426 |
return ChartsEnginePreferences.DEFAULT_CHART_TYPE.equals(this.chartType); |
| 415 | 427 |
} |
| 416 |
|
|
| 417 |
|
|
| 418 |
|
|
| 428 |
|
|
| 429 |
|
|
| 430 |
|
|
| 419 | 431 |
/** |
| 420 | 432 |
* @return the chartDirty |
| 421 | 433 |
*/ |
| 422 | 434 |
public boolean isChartDirty() {
|
| 423 | 435 |
return chartDirty; |
| 424 | 436 |
} |
| 425 |
|
|
| 437 |
|
|
| 426 | 438 |
/** |
| 427 | 439 |
* @return the needsToResetView |
| 428 | 440 |
*/ |
| 429 | 441 |
public boolean needsToResetView() {
|
| 430 | 442 |
return needsToResetView; |
| 431 | 443 |
} |
| 432 |
|
|
| 433 |
|
|
| 444 |
|
|
| 445 |
|
|
| 434 | 446 |
/** |
| 435 | 447 |
* @param needsToResetView the needsToResetView to set |
| 436 | 448 |
*/ |
| 437 | 449 |
public void setNeedsToResetView(boolean needsToResetView) {
|
| 438 | 450 |
this.needsToResetView = needsToResetView; |
| 439 | 451 |
} |
| 440 |
|
|
| 441 |
|
|
| 452 |
|
|
| 453 |
|
|
| 442 | 454 |
/** |
| 443 | 455 |
* @return the needsClearItemsSelection |
| 444 | 456 |
*/ |
| 445 | 457 |
public boolean needsToClearItemsSelection() {
|
| 446 | 458 |
return needsToClearItemsSelection; |
| 447 | 459 |
} |
| 448 |
|
|
| 449 |
|
|
| 460 |
|
|
| 461 |
|
|
| 450 | 462 |
/** |
| 451 | 463 |
* @param needsToClearItemsSelection the needsClearItemsSelection to set |
| 452 | 464 |
*/ |
| 453 | 465 |
public void setNeedsToClearItemsSelection(boolean needsToClearItemsSelection) {
|
| 454 | 466 |
this.needsToClearItemsSelection = needsToClearItemsSelection; |
| 455 | 467 |
} |
| 456 |
|
|
| 468 |
|
|
| 457 | 469 |
/** |
| 458 | 470 |
* Gets the square off constraint state. |
| 471 |
* |
|
| 459 | 472 |
* @return the square off constraint state |
| 460 | 473 |
*/ |
| 461 | 474 |
public boolean needsToSquareOff() {
|
| 462 | 475 |
return needsToSquareOff; |
| 463 | 476 |
} |
| 464 |
|
|
| 465 |
|
|
| 477 |
|
|
| 478 |
|
|
| 466 | 479 |
/** |
| 467 | 480 |
* Sets the square off constraint state. |
| 481 |
* |
|
| 468 | 482 |
* @param needsToSquareOff the square off constraint state to set |
| 469 | 483 |
*/ |
| 470 | 484 |
public void setNeedsToSquareOff(boolean needsToSquareOff) {
|
| 471 | 485 |
this.needsToSquareOff = needsToSquareOff; |
| 472 | 486 |
} |
| 473 |
|
|
| 474 | 487 |
|
| 488 |
|
|
| 475 | 489 |
/** |
| 476 | 490 |
* Gets the title visibility state. |
| 491 |
* |
|
| 477 | 492 |
* @return the titleVisible |
| 478 | 493 |
*/ |
| 479 | 494 |
public boolean isTitleVisible() {
|
| 480 | 495 |
return titleVisible; |
| 481 | 496 |
} |
| 482 |
|
|
| 497 |
|
|
| 483 | 498 |
/** |
| 484 | 499 |
* Sets the title visibility state. |
| 500 |
* |
|
| 485 | 501 |
* @param titleVisible the titleVisible to set |
| 486 | 502 |
*/ |
| 487 | 503 |
public void setTitleVisible(boolean titleVisible) {
|
| 488 | 504 |
this.titleVisible = titleVisible; |
| 489 | 505 |
} |
| 490 |
|
|
| 506 |
|
|
| 491 | 507 |
/** |
| 492 | 508 |
* Gets the legend visibility state. |
| 509 |
* |
|
| 493 | 510 |
* @return the legendVisible |
| 494 | 511 |
*/ |
| 495 | 512 |
public boolean isLegendVisible() {
|
| 496 | 513 |
return legendVisible; |
| 497 | 514 |
} |
| 498 |
|
|
| 515 |
|
|
| 499 | 516 |
/** |
| 500 | 517 |
* Sets the legend visibility state. |
| 518 |
* |
|
| 501 | 519 |
* @param legendVisible the legendVisible to set |
| 502 | 520 |
*/ |
| 503 | 521 |
public void setLegendVisible(boolean legendVisible) {
|
| 504 | 522 |
this.legendVisible = legendVisible; |
| 505 | 523 |
} |
| 506 |
|
|
| 524 |
|
|
| 507 | 525 |
/** |
| 508 | 526 |
* Gets the grid visibility state. |
| 527 |
* |
|
| 509 | 528 |
* @return the gridVisible |
| 510 | 529 |
*/ |
| 511 | 530 |
public boolean isGridVisible() {
|
| 512 | 531 |
return gridVisible; |
| 513 | 532 |
} |
| 514 |
|
|
| 533 |
|
|
| 515 | 534 |
/** |
| 516 | 535 |
* Gets the domain grid lines visibility state. |
| 536 |
* |
|
| 517 | 537 |
* @return the domainGridLinesVisible |
| 518 | 538 |
*/ |
| 519 | 539 |
public boolean isDomainGridLinesVisible() {
|
| 520 | 540 |
return domainGridLinesVisible; |
| 521 | 541 |
} |
| 522 |
|
|
| 523 | 542 |
|
| 543 |
|
|
| 524 | 544 |
/** |
| 525 | 545 |
* Sets the visiiblity visibility state. |
| 546 |
* |
|
| 526 | 547 |
* @param gridVisible the gridVisible to set |
| 527 | 548 |
*/ |
| 528 | 549 |
public void setGridVisible(boolean gridVisible) {
|
| 529 | 550 |
this.gridVisible = gridVisible; |
| 530 | 551 |
} |
| 531 |
|
|
| 532 |
|
|
| 552 |
|
|
| 553 |
|
|
| 533 | 554 |
/** |
| 534 | 555 |
* Gets the rendering color mode as integer. |
| 556 |
* |
|
| 535 | 557 |
* @return the renderingColorsMode |
| 536 | 558 |
*/ |
| 537 | 559 |
public int getRenderingColorsMode() {
|
| 538 | 560 |
return renderingColorsMode; |
| 539 | 561 |
} |
| 540 |
|
|
| 541 |
|
|
| 562 |
|
|
| 563 |
|
|
| 542 | 564 |
/** |
| 543 | 565 |
* Gets the rendering color mode. |
| 566 |
* |
|
| 544 | 567 |
* @param renderingColorsMode the renderingColorsMode to set |
| 545 | 568 |
*/ |
| 546 | 569 |
public void setRenderingColorsMode(int renderingColorsMode) {
|
| 547 | 570 |
this.renderingColorsMode = renderingColorsMode; |
| 548 | 571 |
} |
| 549 |
|
|
| 550 |
|
|
| 572 |
|
|
| 573 |
|
|
| 551 | 574 |
/** |
| 552 | 575 |
* Gets the font. |
| 576 |
* |
|
| 553 | 577 |
* @return the font |
| 554 | 578 |
*/ |
| 555 | 579 |
public String getFont() {
|
| 556 | 580 |
return font; |
| 557 | 581 |
} |
| 558 |
|
|
| 559 |
|
|
| 582 |
|
|
| 583 |
|
|
| 560 | 584 |
/** |
| 561 | 585 |
* Sets the font. |
| 586 |
* |
|
| 562 | 587 |
* @param font the font to set |
| 563 | 588 |
*/ |
| 564 | 589 |
public void setFont(String font) {
|
| 565 | 590 |
this.font = font; |
| 566 | 591 |
} |
| 567 |
|
|
| 568 |
|
|
| 569 |
|
|
| 592 |
|
|
| 593 |
|
|
| 594 |
|
|
| 570 | 595 |
/** |
| 571 | 596 |
* Gets the multiple line strokes state. |
| 597 |
* |
|
| 572 | 598 |
* @return the multipleLineStrokes |
| 573 | 599 |
*/ |
| 574 | 600 |
public boolean isMultipleLineStrokes() {
|
| 575 | 601 |
return multipleLineStrokes; |
| 576 | 602 |
} |
| 577 |
|
|
| 578 |
|
|
| 579 |
|
|
| 603 |
|
|
| 604 |
|
|
| 605 |
|
|
| 580 | 606 |
/** |
| 581 | 607 |
* Sets the multiple line strokes state. |
| 608 |
* |
|
| 582 | 609 |
* @param multipleStrokes the multiple line strokes state to set |
| 583 | 610 |
*/ |
| 584 | 611 |
public void setMultipleLineStrokes(boolean multipleStrokes) {
|
| 585 | 612 |
this.multipleLineStrokes = multipleStrokes; |
| 586 | 613 |
} |
| 587 |
|
|
| 588 |
|
|
| 614 |
|
|
| 615 |
|
|
| 589 | 616 |
/** |
| 590 | 617 |
* Gets the current charts engine used for the rendering. |
| 618 |
* |
|
| 591 | 619 |
* @return the chartsEngine |
| 592 | 620 |
*/ |
| 593 | 621 |
public ChartsEngine getChartsEngine() {
|
| 594 | 622 |
return chartsEngine; |
| 595 | 623 |
} |
| 596 |
|
|
| 597 |
|
|
| 624 |
|
|
| 625 |
|
|
| 598 | 626 |
/** |
| 599 | 627 |
* Sets the charts engine to use for the rendering. |
| 628 |
* |
|
| 600 | 629 |
* @param chartsEngine the chartsEngine to set |
| 601 | 630 |
*/ |
| 602 | 631 |
public void setChartsEngine(ChartsEngine chartsEngine) {
|
| 603 | 632 |
this.chartsEngine = chartsEngine; |
| 604 | 633 |
} |
| 605 |
|
|
| 606 |
|
|
| 634 |
|
|
| 635 |
|
|
| 607 | 636 |
/** |
| 608 | 637 |
* Sets the chart object. |
| 638 |
* |
|
| 609 | 639 |
* @param chart the chart to set |
| 610 | 640 |
*/ |
| 611 | 641 |
public void setChart(Object chart) {
|
| 612 | 642 |
this.chart = chart; |
| 613 | 643 |
} |
| 614 |
|
|
| 615 |
|
|
| 616 |
|
|
| 644 |
|
|
| 645 |
|
|
| 646 |
|
|
| 617 | 647 |
} |
| tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEngine.java (revision 2386) | ||
|---|---|---|
| 34 | 34 |
/** |
| 35 | 35 |
* Constants for output formats and file extensions. |
| 36 | 36 |
*/ |
| 37 |
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"; |
|
| 37 |
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", |
|
| 38 |
OUTPUT_FORMAT_BMP = "bmp", OUTPUT_FORMAT_GIF = "gif"; |
|
| 38 | 39 |
|
| 39 | 40 |
/** |
| 40 | 41 |
* Constants for the colors rendering modes. |
| 41 | 42 |
*/ |
| 42 | 43 |
public final static int RENDERING_COLORS_MODE = 0, RENDERING_GRAYSCALE_MODE = 1, RENDERING_BLACK_AND_WHITE_MODE = 2, RENDERING_MONOCHROME_MODE = 3; |
| 43 |
|
|
| 44 |
|
|
| 44 | 45 |
/** |
| 45 | 46 |
* The engine description. |
| 46 | 47 |
*/ |
| 47 | 48 |
protected String description; |
| 48 |
|
|
| 49 |
|
|
| 49 | 50 |
/** |
| 50 | 51 |
* The current output format. |
| 51 | 52 |
*/ |
| ... | ... | |
| 55 | 56 |
* Chart creators extension contributions. |
| 56 | 57 |
*/ |
| 57 | 58 |
protected HashMap<Class, HashMap<String, ChartCreator>> chartCreators; |
| 58 |
|
|
| 59 |
|
|
| 59 | 60 |
/** |
| 60 | 61 |
* Installed charts engines. |
| 61 |
* TODO remove this static member and use the ChartsEnginesManager
|
|
| 62 |
* TODO remove this static member and use the ChartsEnginesManager |
|
| 62 | 63 |
*/ |
| 63 | 64 |
protected static ArrayList<ChartsEngine> chartsEngines; |
| 64 | 65 |
|
| ... | ... | |
| 70 | 71 |
/** |
| 71 | 72 |
* UI related, this preference can be used to tell if the chart must be updated directly after editing a widget value or only after pressed a "Compute" button. |
| 72 | 73 |
*/ |
| 73 |
//FIXME: SJ: this preference is not used at this time, see if it's useless or not. |
|
| 74 |
protected boolean directComputing; |
|
| 75 |
|
|
| 74 |
// FIXME: SJ: this preference is not used at this time, see if it's useless or not. |
|
| 75 |
protected boolean directComputing; |
|
| 76 | 76 |
|
| 77 |
|
|
| 77 | 78 |
// add the preference node qualifier to the preferences so the command use some preferences if they do not define themselves |
| 78 |
static {
|
|
| 79 |
static {
|
|
| 79 | 80 |
TXMPreferences.alternativeNodesQualifiers.add(ChartsEnginePreferences.getInstance().getPreferencesNodeQualifier()); |
| 80 | 81 |
} |
| 81 | 82 |
|
| 82 | 83 |
/** |
| 83 | 84 |
* Creates a charts engine with the specified name, description and output format. |
| 85 |
* |
|
| 84 | 86 |
* @param name |
| 85 | 87 |
* @param description |
| 86 | 88 |
* @param outputFormat |
| 87 | 89 |
*/ |
| 88 | 90 |
protected ChartsEngine(String description, String outputFormat) {
|
| 89 |
this.chartCreators = new HashMap<Class, HashMap<String,ChartCreator>>(); |
|
| 91 |
this.chartCreators = new HashMap<Class, HashMap<String, ChartCreator>>();
|
|
| 90 | 92 |
this.description = description; |
| 91 | 93 |
this.outputFormat = outputFormat; |
| 92 | 94 |
this.theme = new Theme(); |
| 93 |
//FIXME: SJ: this preference is not used at this time, see if it's useless or not. |
|
| 95 |
// FIXME: SJ: this preference is not used at this time, see if it's useless or not.
|
|
| 94 | 96 |
this.directComputing = true; |
| 95 | 97 |
} |
| 96 |
|
|
| 98 |
|
|
| 97 | 99 |
/** |
| 98 | 100 |
* Gets a chart creator for the specified result and chart type. |
| 99 | 101 |
* |
| ... | ... | |
| 102 | 104 |
* @param showLogWarning |
| 103 | 105 |
* @return A chart creator if it exists otherwise <code>null</code> |
| 104 | 106 |
*/ |
| 105 |
public ChartCreator getChartCreator(ChartResult result, String chartType, boolean showLogWarning) {
|
|
| 107 |
public ChartCreator getChartCreator(ChartResult result, String chartType, boolean showLogWarning) {
|
|
| 106 | 108 |
ChartCreator chartCreator = null; |
| 107 | 109 |
HashMap<String, ChartCreator> map = this.chartCreators.get(result.getClass()); |
| 108 |
if(map != null) {
|
|
| 110 |
if (map != null) {
|
|
| 109 | 111 |
chartCreator = map.get(chartType); |
| 110 | 112 |
} |
| 111 | 113 |
|
| 112 |
if(chartCreator == null && showLogWarning) {
|
|
| 114 |
if (chartCreator == null && showLogWarning) {
|
|
| 113 | 115 |
Log.fine(this.getName() + ": No chart creator can be found for result: " + result.getClass() + " and chart type: " + chartType + "."); //$NON-NLS-1$ |
| 114 | 116 |
} |
| 115 | 117 |
return chartCreator; |
| ... | ... | |
| 117 | 119 |
|
| 118 | 120 |
/** |
| 119 | 121 |
* Gets a chart creator for the specified result and default chart type. |
| 122 |
* |
|
| 120 | 123 |
* @param result |
| 121 | 124 |
* @param showLogWarning |
| 122 | 125 |
* @return |
| 123 | 126 |
*/ |
| 124 |
public ChartCreator getChartCreator(ChartResult result, boolean showLogWarning) {
|
|
| 127 |
public ChartCreator getChartCreator(ChartResult result, boolean showLogWarning) {
|
|
| 125 | 128 |
return this.getChartCreator(result, result.getChartType(), showLogWarning); |
| 126 | 129 |
} |
| 127 | 130 |
|
| 128 | 131 |
/** |
| 129 | 132 |
* Gets a chart creator for the specified result and chart type. |
| 133 |
* |
|
| 130 | 134 |
* @param result |
| 131 | 135 |
* @param chartType |
| 132 | 136 |
* @return |
| 133 | 137 |
*/ |
| 134 |
public ChartCreator getChartCreator(ChartResult result, String chartType) {
|
|
| 138 |
public ChartCreator getChartCreator(ChartResult result, String chartType) {
|
|
| 135 | 139 |
return this.getChartCreator(result, chartType, true); |
| 136 | 140 |
} |
| 137 | 141 |
|
| 138 |
|
|
| 142 |
|
|
| 139 | 143 |
/** |
| 140 | 144 |
* Gets a chart creator for the specified result and default chart type. |
| 141 | 145 |
* |
| 142 | 146 |
* @param result |
| 143 | 147 |
* @return |
| 144 | 148 |
*/ |
| 145 |
public ChartCreator getChartCreator(ChartResult result) {
|
|
| 149 |
public ChartCreator getChartCreator(ChartResult result) {
|
|
| 146 | 150 |
return this.getChartCreator(result, result.getChartType()); |
| 147 | 151 |
} |
| 148 |
|
|
| 149 | 152 |
|
| 153 |
|
|
| 150 | 154 |
/** |
| 151 | 155 |
* Gets a list of all installed chart creators for the specified result. |
| 152 | 156 |
* |
| 153 | 157 |
* @param result |
| 154 | 158 |
* @return |
| 155 | 159 |
*/ |
| 156 |
public ArrayList<ChartCreator> getChartCreators(ChartResult result) {
|
|
| 160 |
public ArrayList<ChartCreator> getChartCreators(ChartResult result) {
|
|
| 157 | 161 |
ArrayList<ChartCreator> chartCreators = new ArrayList<ChartCreator>(); |
| 158 | 162 |
HashMap<String, ChartCreator> map = this.chartCreators.get(result.getClass()); |
| 159 |
if(map != null) {
|
|
| 163 |
if (map != null) {
|
|
| 160 | 164 |
chartCreators.addAll(map.values()); |
| 161 | 165 |
} |
| 162 | 166 |
return chartCreators; |
| 163 | 167 |
} |
| 164 | 168 |
|
| 165 |
|
|
| 169 |
|
|
| 166 | 170 |
/** |
| 167 | 171 |
* Checks if the charts engine can create a chart according to the specified result and chart type. |
| 168 | 172 |
* |
| ... | ... | |
| 170 | 174 |
* @param chartType |
| 171 | 175 |
* @return <code>True</code> if a chart creator can be found, otherwise <code>false</code> |
| 172 | 176 |
*/ |
| 173 |
public boolean canCreateChart(ChartResult result, String chartType) {
|
|
| 177 |
public boolean canCreateChart(ChartResult result, String chartType) {
|
|
| 174 | 178 |
return this.getChartCreator(result, chartType, false) != null; |
| 175 | 179 |
} |
| 176 |
|
|
| 180 |
|
|
| 177 | 181 |
/** |
| 178 | 182 |
* Checks if the charts engine can create a chart according to the specified result data type. |
| 179 | 183 |
* |
| 180 | 184 |
* @param resultDataType |
| 181 | 185 |
* @return <code>True</code> if a chart creator can be found, otherwise <code>false</code> |
| 182 | 186 |
*/ |
| 183 |
public boolean canCreateChart(ChartResult result) {
|
|
| 187 |
public boolean canCreateChart(ChartResult result) {
|
|
| 184 | 188 |
return this.getChartCreator(result, false) != null; |
| 185 | 189 |
} |
| 186 | 190 |
|
| 187 | 191 |
|
| 188 | 192 |
/** |
| 189 | 193 |
* Adds a chart creator for the specified result data type and chart type. |
| 194 |
* |
|
| 190 | 195 |
* @param resultDataType |
| 191 | 196 |
* @param chartCreator |
| 192 | 197 |
* @param chartType |
| 193 | 198 |
*/ |
| 194 |
public void addChartCreator(Class resultDataType, ChartCreator chartCreator) {
|
|
| 199 |
public void addChartCreator(Class resultDataType, ChartCreator chartCreator) {
|
|
| 195 | 200 |
|
| 196 |
|
|
| 197 | 201 |
String chartType = chartCreator.getChartType(); |
| 198 |
if(chartType == null) {
|
|
| 202 |
if (chartType == null) {
|
|
| 199 | 203 |
chartType = ChartsEnginePreferences.DEFAULT_CHART_TYPE; |
| 200 | 204 |
} |
| 201 | 205 |
|
| 202 |
if(!this.chartCreators.containsKey(resultDataType)) {
|
|
| 206 |
if (!this.chartCreators.containsKey(resultDataType)) {
|
|
| 203 | 207 |
HashMap<String, ChartCreator> m = new HashMap<String, ChartCreator>(); |
| 204 | 208 |
m.put(chartType, chartCreator); |
| 205 | 209 |
this.chartCreators.put(resultDataType, m); |
| 206 | 210 |
} |
| 207 |
else {
|
|
| 211 |
else {
|
|
| 208 | 212 |
this.chartCreators.get(resultDataType).put(chartType, chartCreator); |
| 209 | 213 |
} |
| 210 | 214 |
|
| 211 | 215 |
|
| 212 |
chartCreator.setChartsEngine(this);
|
|
| 213 |
|
|
| 216 |
chartCreator.setChartsEngine(this); |
|
| 217 |
|
|
| 214 | 218 |
String log = this.getName() + ": Chart creator " + chartCreator.getClass().getSimpleName() + " added for result data type: " + resultDataType; //$NON-NLS-1$ //$NON-NLS-2$ |
| 215 | 219 |
|
| 216 |
if(chartType != null) {
|
|
| 220 |
if (chartType != null) {
|
|
| 217 | 221 |
log += " (chart type: " + chartType + ")"; //$NON-NLS-1$ //$NON-NLS-2$ |
| 218 | 222 |
} |
| 219 | 223 |
|
| 220 |
log +="."; //$NON-NLS-1$ |
|
| 224 |
log += "."; //$NON-NLS-1$
|
|
| 221 | 225 |
|
| 222 | 226 |
Log.finest(log); |
| 223 | 227 |
|
| 224 | 228 |
} |
| 225 |
|
|
| 229 |
|
|
| 226 | 230 |
/** |
| 227 | 231 |
* Gets the current charts engine. |
| 228 | 232 |
* Convenience method to return the current chart engine of the charts engines manager. |
| 233 |
* |
|
| 229 | 234 |
* @return the current charts engine |
| 230 | 235 |
*/ |
| 231 |
public static ChartsEngine getCurrent() {
|
|
| 236 |
public static ChartsEngine getCurrent() {
|
|
| 232 | 237 |
return ChartsEnginesManager.getInstance().getCurrentEngine(); |
| 233 | 238 |
} |
| 234 | 239 |
|
| 235 |
// FIXME: SJ: became useless?
|
|
| 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 |
// /**
|
|
| 253 |
// * Gets an installed charts engine according to its name.
|
|
| 254 |
// * @param type
|
|
| 255 |
// * @return the installed charts engine according to its name if it exists otherwise null
|
|
| 256 |
// */
|
|
| 257 |
// @Deprecated
|
|
| 258 |
// public static ChartsEngine getChartsEngineByName(String name) {
|
|
| 259 |
// ChartsEngine chartsEngine = null;
|
|
| 260 |
// for(int i = 0; i < ChartsEngine.chartsEngines.size(); i++) {
|
|
| 261 |
// if(chartsEngines.get(i).getName().equals(name)) {
|
|
| 262 |
// chartsEngine = ChartsEngine.chartsEngines.get(i);
|
|
| 263 |
// break;
|
|
| 264 |
// }
|
|
| 265 |
// }
|
|
| 266 |
// return chartsEngine;
|
|
| 267 |
// }
|
|
| 268 |
//
|
|
| 269 |
// /**
|
|
| 270 |
// * Gets the first charts engine that can render the specified result.
|
|
| 271 |
// * @param result
|
|
| 272 |
// * @return
|
|
| 273 |
// */
|
|
| 274 |
// @Deprecated
|
|
| 275 |
// public static ChartsEngine getChartsEngine(ChartResult result) {
|
|
| 276 |
// ChartsEngine chartsEngine = null;
|
|
| 277 |
// for (int i = 0; i < ChartsEngine.chartsEngines.size(); i++) {
|
|
| 278 |
// if(ChartsEngine.chartsEngines.get(i).canCreateChart(result)) {
|
|
| 279 |
// chartsEngine = ChartsEngine.chartsEngines.get(i);
|
|
| 280 |
// break;
|
|
| 281 |
// }
|
|
| 282 |
// }
|
|
| 283 |
// return chartsEngine;
|
|
| 284 |
// }
|
|
| 240 |
// FIXME: SJ: became useless?
|
|
| 241 |
// /**
|
|
| 242 |
// * Gets an installed charts engine according to its class type.
|
|
| 243 |
// * @param type
|
|
| 244 |
// * @return the installed charts engine according to its class type if it exists otherwise null
|
|
| 245 |
// */
|
|
| 246 |
// @Deprecated
|
|
| 247 |
// public static ChartsEngine getChartsEngine(Class type) {
|
|
| 248 |
// ChartsEngine chartsEngine = null;
|
|
| 249 |
// for(int i = 0; i < ChartsEngine.chartsEngines.size(); i++) {
|
|
| 250 |
// if(ChartsEngine.chartsEngines.get(i).getClass().equals(type)) {
|
|
| 251 |
// chartsEngine = ChartsEngine.chartsEngines.get(i);
|
|
| 252 |
// break;
|
|
| 253 |
// }
|
|
| 254 |
// }
|
|
| 255 |
// return chartsEngine;
|
|
| 256 |
// }
|
|
| 257 |
// /**
|
|
| 258 |
// * Gets an installed charts engine according to its name.
|
|
| 259 |
// * @param type
|
|
| 260 |
// * @return the installed charts engine according to its name if it exists otherwise null
|
|
| 261 |
// */
|
|
| 262 |
// @Deprecated
|
|
| 263 |
// public static ChartsEngine getChartsEngineByName(String name) {
|
|
| 264 |
// ChartsEngine chartsEngine = null;
|
|
| 265 |
// for(int i = 0; i < ChartsEngine.chartsEngines.size(); i++) {
|
|
| 266 |
// if(chartsEngines.get(i).getName().equals(name)) {
|
|
| 267 |
// chartsEngine = ChartsEngine.chartsEngines.get(i);
|
|
| 268 |
// break;
|
|
| 269 |
// }
|
|
| 270 |
// }
|
|
| 271 |
// return chartsEngine;
|
|
| 272 |
// }
|
|
| 273 |
//
|
|
| 274 |
// /**
|
|
| 275 |
// * Gets the first charts engine that can render the specified result.
|
|
| 276 |
// * @param result
|
|
| 277 |
// * @return
|
|
| 278 |
// */
|
|
| 279 |
// @Deprecated
|
|
| 280 |
// public static ChartsEngine getChartsEngine(ChartResult result) {
|
|
| 281 |
// ChartsEngine chartsEngine = null;
|
|
| 282 |
// for (int i = 0; i < ChartsEngine.chartsEngines.size(); i++) {
|
|
| 283 |
// if(ChartsEngine.chartsEngines.get(i).canCreateChart(result)) {
|
|
| 284 |
// chartsEngine = ChartsEngine.chartsEngines.get(i);
|
|
| 285 |
// break;
|
|
| 286 |
// }
|
|
| 287 |
// }
|
|
| 288 |
// return chartsEngine;
|
|
| 289 |
// }
|
|
| 285 | 290 |
|
| 286 | 291 |
|
| 287 | 292 |
/** |
| 288 | 293 |
* Returns the installed charts engine contributions. |
| 294 |
* |
|
| 289 | 295 |
* @return |
| 290 | 296 |
*/ |
| 291 | 297 |
@Deprecated |
| 292 |
public static ArrayList<ChartsEngine> getChartsEngines() {
|
|
| 298 |
public static ArrayList<ChartsEngine> getChartsEngines() {
|
|
| 293 | 299 |
return ChartsEngine.chartsEngines; |
| 294 | 300 |
} |
| 295 |
|
|
| 296 | 301 |
|
| 302 |
|
|
| 297 | 303 |
@Override |
| 298 | 304 |
public boolean initialize() throws Exception {
|
| 299 | 305 |
this.registerChartCreatorExtensions(); |
| 300 | 306 |
return true; |
| 301 | 307 |
} |
| 302 | 308 |
|
| 303 |
|
|
| 304 | 309 |
|
| 310 |
|
|
| 305 | 311 |
/** |
| 306 | 312 |
* Populates the chart creators from loaded extensions according to the specified chars engine name. |
| 313 |
* |
|
| 307 | 314 |
* @param chartsEngineName |
| 308 | 315 |
*/ |
| 309 |
protected void registerChartCreatorExtensions(Class chartsEngineClass) {
|
|
| 316 |
protected void registerChartCreatorExtensions(Class chartsEngineClass) {
|
|
| 317 |
|
|
| 310 | 318 |
IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(ChartCreator.extensionPointId); |
| 311 | 319 |
|
| 312 |
for(int i = 0; i < contributions.length; i++) {
|
|
| 320 |
for (int i = 0; i < contributions.length; i++) {
|
|
| 313 | 321 |
|
| 314 | 322 |
try {
|
| 315 | 323 |
ChartCreator chartCreator = (ChartCreator) contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
|
| 316 | 324 |
|
| 317 |
if(chartsEngineClass.equals(chartCreator.getChartsEngineClass())) {
|
|
| 325 |
if (chartsEngineClass.equals(chartCreator.getChartsEngineClass())) {
|
|
| 318 | 326 |
chartCreator.setFileNamePrefix(contributions[i].getAttribute("fileNamePrefix")); //$NON-NLS-1$
|
| 319 | 327 |
chartCreator.setChartType(contributions[i].getAttribute("chartType")); //$NON-NLS-1$
|
| 320 |
this.addChartCreator(chartCreator.getResultDataClass(), chartCreator); //$NON-NLS-1$ |
|
| 328 |
this.addChartCreator(chartCreator.getResultDataClass(), chartCreator); // $NON-NLS-1$
|
|
| 321 | 329 |
} |
| 322 | 330 |
} |
| 323 |
catch(CoreException e) {
|
|
| 331 |
catch (CoreException e) {
|
|
| 324 | 332 |
// TODO Auto-generated catch block |
| 325 | 333 |
e.printStackTrace(); |
| 326 |
}
|
|
| 327 |
|
|
| 334 |
} |
|
| 335 |
|
|
| 328 | 336 |
} |
| 329 | 337 |
} |
| 330 |
|
|
| 338 |
|
|
| 331 | 339 |
/** |
| 332 | 340 |
* Populates the chart creators from loaded extensions. |
| 333 | 341 |
*/ |
| 334 |
public void registerChartCreatorExtensions() {
|
|
| 342 |
public void registerChartCreatorExtensions() {
|
|
| 335 | 343 |
this.registerChartCreatorExtensions(this.getClass()); |
| 336 | 344 |
} |
| 337 | 345 |
|
| 338 | 346 |
/** |
| 339 | 347 |
* Creates a font from the specified encoded String in JFace format (eg.: "1|Lucida Sans Unicode|12.0|0|WINDOWS|1|-16|0|0|0|400|0|0|0|0|3|2|1|34|Lucida Sans Unicode;") |
| 348 |
* |
|
| 340 | 349 |
* @param encodedStr |
| 341 | 350 |
* @return the decoded font |
| 342 | 351 |
*/ |
| 343 |
public static Font createFont(String encodedStr) {
|
|
| 352 |
public static Font createFont(String encodedStr) {
|
|
| 344 | 353 |
String[] data = encodedStr.split("\\|");
|
| 345 | 354 |
Font font = new Font(data[1], Integer.valueOf(data[3]), Integer.parseInt(data[2].split("\\.")[0]));
|
| 346 | 355 |
return font; |
| ... | ... | |
| 348 | 357 |
|
| 349 | 358 |
/** |
| 350 | 359 |
* Creates a font from the current global charts engine font preference. |
| 360 |
* |
|
| 351 | 361 |
* @return |
| 352 | 362 |
*/ |
| 353 |
public static Font createFont() {
|
|
| 363 |
public static Font createFont() {
|
|
| 354 | 364 |
return createFont(ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.FONT)); |
| 355 | 365 |
} |
| 356 | 366 |
|
| ... | ... | |
| 360 | 370 |
* |
| 361 | 371 |
* @return |
| 362 | 372 |
*/ |
| 363 |
public File createTmpFile(String prefix) {
|
|
| 373 |
public File createTmpFile(String prefix) {
|
|
| 364 | 374 |
File file = null; |
| 365 | 375 |
try {
|
| 366 | 376 |
File resultsDir = new File(Toolbox.getTxmHomePath(), "results"); //$NON-NLS-1$ |
| 367 | 377 |
resultsDir.mkdirs(); |
| 368 | 378 |
|
| 369 | 379 |
// right padding to 3 characters long |
| 370 |
if(prefix.length() < 3) {
|
|
| 371 |
prefix = String.format("%1$-3s", prefix).replace(' ', '_'); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
| 380 |
if (prefix.length() < 3) {
|
|
| 381 |
prefix = String.format("%1$-3s", prefix).replace(' ', '_'); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
| 372 | 382 |
} |
| 373 | 383 |
|
| 374 | 384 |
file = File.createTempFile(prefix, "." + this.outputFormat, resultsDir); |
| ... | ... | |
| 377 | 387 |
Log.severe(NLS.bind(ChartsEngineCoreMessages.error_cantCreateTmpChartFileP0, e)); |
| 378 | 388 |
Log.printStackTrace(e); |
| 379 | 389 |
} |
| 380 |
|
|
| 390 |
|
|
| 381 | 391 |
// TODO : old code, useful ? and/or return null instead of the file if canWrite() return false ? |
| 382 |
if(!file.canWrite()) {
|
|
| 392 |
if (!file.canWrite()) {
|
|
| 383 | 393 |
Log.severe(NLS.bind(ChartsEngineCoreMessages.error_cantWriteInFileP0, file)); |
| 384 | 394 |
} |
| 385 | 395 |
return file; |
| 386 | 396 |
} |
| 387 |
|
|
| 397 |
|
|
| 388 | 398 |
/** |
| 389 | 399 |
* Creates a file form the specified chart object. |
| 400 |
* |
|
| 390 | 401 |
* @param chart |
| 391 | 402 |
* @param file |
| 392 | 403 |
* @return |
| ... | ... | |
| 395 | 406 |
|
| 396 | 407 |
/** |
| 397 | 408 |
* Creates a chart according to the specified result and output format and writes it in the specified file. |
| 409 |
* |
|
| 398 | 410 |
* @param result |
| 399 | 411 |
* @param file |
| 400 | 412 |
* @param outputFormat |
| 401 | 413 |
* @return |
| 402 | 414 |
*/ |
| 403 |
//FIXME: check that modification works well |
|
| 404 |
public File createChartFile(ChartResult result, File file, String outputFormat) {
|
|
| 405 |
// FIXME : bad ? Switch the current charts engine output format, export the chart, and then roll back the output format |
|
| 415 |
public File createChartFile(ChartResult result, File file, String outputFormat) {
|
|
| 416 |
// FIXME : SJ: bad ? Switch the current charts engine output format, export the chart, and then roll back the output format |
|
| 406 | 417 |
String oldOutputFormat = this.outputFormat; |
| 407 | 418 |
this.setOutputFormat(outputFormat); |
| 408 | 419 |
file = this.createChartFile(result.getChart(), file); |
| 409 |
//this.setOutputFormat(oldOutputFormat); |
|
| 410 | 420 |
this.outputFormat = oldOutputFormat; |
| 411 | 421 |
return file; |
| 412 | 422 |
} |
| 413 | 423 |
|
| 414 |
|
|
| 424 |
|
|
Formats disponibles : Unified diff