]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
495a36e11a32da8faa74d3b4e55edadaf1ab5b69
[simantics/sysdyn.git] /
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011, 2014 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.jfreechart.chart.properties.xyline;\r
13 \r
14 import java.util.Collection;\r
15 import java.util.LinkedHashMap;\r
16 import java.util.Map;\r
17 \r
18 import org.eclipse.jface.layout.GridDataFactory;\r
19 import org.eclipse.jface.layout.GridLayoutFactory;\r
20 import org.eclipse.jface.viewers.StructuredSelection;\r
21 import org.eclipse.swt.SWT;\r
22 import org.eclipse.swt.custom.ScrolledComposite;\r
23 import org.eclipse.swt.graphics.Point;\r
24 import org.eclipse.swt.widgets.Composite;\r
25 import org.eclipse.swt.widgets.Display;\r
26 import org.eclipse.swt.widgets.Group;\r
27 import org.eclipse.swt.widgets.Label;\r
28 import org.eclipse.ui.IWorkbenchSite;\r
29 import org.simantics.browsing.ui.swt.widgets.Button;\r
30 import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
31 import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
32 import org.simantics.browsing.ui.swt.widgets.TrackedCombo;\r
33 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
34 import org.simantics.browsing.ui.swt.widgets.impl.ComboModifyListenerImpl;\r
35 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
36 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
37 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
38 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
39 import org.simantics.db.ReadGraph;\r
40 import org.simantics.db.Resource;\r
41 import org.simantics.db.WriteGraph;\r
42 import org.simantics.db.common.request.ObjectsWithType;\r
43 import org.simantics.db.common.request.PossibleObjectWithType;\r
44 import org.simantics.db.common.request.ReadRequest;\r
45 import org.simantics.db.exception.DatabaseException;\r
46 import org.simantics.db.management.ISessionContext;\r
47 import org.simantics.jfreechart.chart.properties.AdjustableTab;\r
48 import org.simantics.jfreechart.chart.properties.AxisHidePropertyComposite;\r
49 import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory;\r
50 import org.simantics.jfreechart.chart.properties.BooleanSelectionListener;\r
51 import org.simantics.jfreechart.chart.properties.DoubleValidator;\r
52 import org.simantics.jfreechart.chart.properties.JFreeChartPropertyColorProvider;\r
53 import org.simantics.jfreechart.chart.properties.RVIFactory;\r
54 import org.simantics.jfreechart.chart.properties.RVIModifier;\r
55 import org.simantics.jfreechart.chart.properties.TitleFactory;\r
56 import org.simantics.jfreechart.chart.properties.TitleModifier;\r
57 import org.simantics.jfreechart.chart.properties.VariableExistsValidator;\r
58 import org.simantics.layer0.Layer0;\r
59 import org.simantics.layer0.utils.direct.GraphUtils;\r
60 import org.simantics.modeling.ui.chart.property.DoublePropertyFactory;\r
61 import org.simantics.modeling.ui.chart.property.DoublePropertyModifier;\r
62 import org.simantics.sysdyn.JFreeChartResource;\r
63 import org.simantics.utils.ui.AdaptionUtils;\r
64 \r
65 /**\r
66  * PropertyTab displaying general properties and x-axis properties of a chart\r
67  * \r
68  * @author Teemu Lempinen\r
69  * @author Tuomas Miettinen\r
70  *\r
71  */\r
72 public class XYLineGeneralPropertiesTab extends AdjustableTab implements Widget {\r
73 \r
74     private ScrolledComposite sc;\r
75     private TrackedText name, title, xlabel, xvariable, xmin, xmax;\r
76     private TrackedCombo type;\r
77     private Button hgrid, htitle, hlegend;\r
78     private WidgetSupportImpl domainAxisSupport = new WidgetSupportImpl();\r
79         private Group general;\r
80         private Label nameLabel;\r
81         private Label labelTitle;\r
82         private Label labelType;\r
83         private Group hideGroup;\r
84         private Group xgroup;\r
85         private Label xVariableLabel;\r
86         private Label labelMin;\r
87         private AxisHidePropertyComposite axisHide;\r
88         private Label labelLabel;\r
89         private Label labelMax;\r
90         private Composite xColumn1;\r
91         private Composite xColumn2;\r
92 \r
93     @Override\r
94     public void setInput(final ISessionContext context, Object input) {\r
95         final Resource chart = AdaptionUtils.adaptToSingle(input, Resource.class);\r
96         if(chart == null)\r
97             return; \r
98 \r
99         context.getSession().asyncRequest(new ReadRequest() {\r
100 \r
101             @Override\r
102             public void run(ReadGraph graph) throws DatabaseException {\r
103                 Layer0 l0 = Layer0.getInstance(graph);\r
104                 JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
105                 Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.Plot));\r
106                 if(plot == null) return;\r
107                 final Resource domainAxis = graph.getPossibleObject(plot, jfree.Plot_domainAxis);\r
108                 if(domainAxis == null) return;\r
109                 Display.getDefault().asyncExec(new Runnable() {\r
110                                         @Override\r
111                                         public void run() {\r
112                                                 domainAxisSupport.fireInput(context, new StructuredSelection(domainAxis));\r
113                                         }\r
114                                 });\r
115                 \r
116             }\r
117         });\r
118     }\r
119     \r
120     /**\r
121      * \r
122      * @author Teemu Lempinen\r
123      *\r
124      */\r
125     private class TypeSelectionFactory extends ReadFactoryImpl<Resource, String> {\r
126         @Override\r
127         public String perform(ReadGraph graph, Resource chart) throws DatabaseException {\r
128             JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
129             Layer0 l0 = Layer0.getInstance(graph);\r
130 \r
131             Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.XYPlot));\r
132             if(plot != null) {\r
133                 Collection<Resource> datasets = graph.syncRequest(new ObjectsWithType(plot, l0.ConsistsOf, jfree.XYDataset));\r
134                 if(!datasets.isEmpty()) {\r
135                     Resource dataset = datasets.iterator().next();\r
136                     if(dataset != null) {\r
137                         Resource renderer = graph.syncRequest(new PossibleObjectWithType(dataset, jfree.Dataset_renderer, jfree.Renderer));\r
138                         if(renderer != null && graph.isInstanceOf(renderer, jfree.XYAreaRenderer))\r
139                             return "Area";\r
140                     }\r
141                 }\r
142             }\r
143             return "Line";\r
144         }\r
145     }\r
146 \r
147     /**\r
148      * RangeItemFactory finds all inexes of a given enumeration \r
149      * and adds "Sum" and "All" to the returned indexes\r
150      * @author Teemu Lempinen\r
151      *\r
152      */\r
153     private class TypeItemFactory extends ReadFactoryImpl<Resource, Map<String, Object>> {\r
154         @Override\r
155         public Map<String, Object> perform(ReadGraph graph, Resource series) throws DatabaseException {\r
156             LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>();\r
157             result.put("Line", "Line");\r
158             result.put("Area", "Area");\r
159 //            result.put("Stacked Area", "Stacked Area");\r
160             return result;\r
161         }\r
162     }\r
163 \r
164     /**\r
165      * TypeModifyListener for modifying the type of a bar chart \r
166      * @author Teemu Lempinen\r
167      *\r
168      */\r
169     private class TypeModifyListener  extends ComboModifyListenerImpl<Resource> {\r
170         @Override\r
171         public void applyText(WriteGraph graph, Resource chart, String text) throws DatabaseException {\r
172             JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
173             Layer0 l0 = Layer0.getInstance(graph);\r
174 \r
175             Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.XYPlot));\r
176             if(plot == null)\r
177                 return;\r
178 \r
179             Collection<Resource> datasets = graph.syncRequest(new ObjectsWithType(plot, l0.ConsistsOf, jfree.XYDataset));\r
180             if(datasets == null || datasets.isEmpty())\r
181                 return;\r
182 \r
183             for(Resource dataset : datasets) {\r
184                 graph.deny(dataset, jfree.Dataset_renderer);\r
185 \r
186                 Resource renderer;\r
187                 if(text.equals("Area"))\r
188                     renderer = GraphUtils.create2(graph, jfree.XYAreaRenderer);\r
189                 else\r
190                     renderer = GraphUtils.create2(graph, jfree.XYLineRenderer);\r
191 \r
192                 graph.claim(dataset, jfree.Dataset_renderer, renderer);\r
193             }\r
194         }\r
195     }\r
196 \r
197         @Override\r
198         protected void createAndAddControls(Composite body, IWorkbenchSite site,\r
199                         ISessionContext context, WidgetSupport support) {\r
200                 support.register(this);\r
201 \r
202         // Scrolled composite containing all of the properties in this tab\r
203         sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL);\r
204         sc.setExpandHorizontal(true);\r
205         sc.setExpandVertical(true);\r
206 \r
207         composite = new Composite(sc, SWT.NONE);\r
208 \r
209         // General properties\r
210         general = new Group(composite, SWT.NONE);\r
211         general.setText("General");\r
212 \r
213         // Name\r
214         nameLabel = new Label(general, SWT.NONE);\r
215         nameLabel.setText("Name:");\r
216         nameLabel.setAlignment(SWT.RIGHT);\r
217 \r
218         name = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER);\r
219         name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
220         name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
221         name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
222 \r
223         // Type\r
224         labelType = new Label(general, SWT.NONE);\r
225         labelType.setText("Type:");\r
226 \r
227         type = new TrackedCombo(general, support, SWT.BORDER | SWT.READ_ONLY);\r
228         type.addModifyListener(new TypeModifyListener());\r
229         type.setItemFactory(new TypeItemFactory());\r
230         type.setSelectionFactory(new TypeSelectionFactory());\r
231 \r
232         // Title (Which is different than name)\r
233         labelTitle = new Label(general, SWT.NONE);\r
234         labelTitle.setText("Title:");\r
235 \r
236         title = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER);\r
237         title.setTextFactory(new TitleFactory());\r
238         title.addModifyListener(new TitleModifier());\r
239         title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
240 \r
241         // Group for hide options\r
242         hideGroup = new Group(composite, SWT.NONE);\r
243         hideGroup.setText("Hide");\r
244 \r
245         hgrid = new Button(hideGroup, support, SWT.CHECK);\r
246         hgrid.setText("Grid");\r
247         hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true));\r
248         hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid));\r
249         htitle = new Button(hideGroup, support, SWT.CHECK);\r
250         htitle.setText("Title");\r
251         htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true));\r
252         htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible));\r
253         hlegend = new Button(hideGroup, support, SWT.CHECK);\r
254         hlegend.setText("Legend");\r
255         hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true));\r
256         hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend));\r
257 \r
258 \r
259         // X-Axis properties\r
260         xgroup = new Group(composite, SWT.NONE);\r
261         xgroup.setText("X-axis");\r
262 \r
263         xColumn1 = new Composite(xgroup, SWT.NONE);\r
264         \r
265         // Variable for x-axis (default: empty == time)\r
266         xVariableLabel = new Label(xColumn1, SWT.NONE);\r
267         xVariableLabel.setText("Variable:");\r
268         \r
269         xvariable = new TrackedText(xColumn1, domainAxisSupport, SWT.BORDER);\r
270         xvariable.setTextFactory(new RVIFactory());\r
271         xvariable.addModifyListener(new RVIModifier(xvariable.getWidget(), domainAxisSupport));\r
272         xvariable.setColorProvider(new JFreeChartPropertyColorProvider(xvariable.getResourceManager()));\r
273         xvariable.setInputValidator(new VariableExistsValidator(support, xvariable, true));\r
274         \r
275         // Label for x-axis\r
276         labelLabel = new Label(xColumn1, SWT.NONE);\r
277         labelLabel.setText("Label:");\r
278         \r
279         xlabel = new TrackedText(xColumn1, domainAxisSupport, SWT.BORDER);\r
280         xlabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, ""));\r
281         xlabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
282         xlabel.setColorProvider(new JFreeChartPropertyColorProvider(xlabel.getResourceManager()));\r
283 \r
284         xColumn2 = new Composite(xgroup, SWT.NONE);\r
285         \r
286         // Min value for x-axis\r
287         labelMin = new Label(xColumn2, SWT.NONE);\r
288         labelMin.setText("Min:");\r
289         labelMin.setAlignment(SWT.RIGHT);\r
290 \r
291         xmin = new TrackedText(xColumn2, domainAxisSupport, SWT.BORDER);\r
292         xmin.setColorProvider(new JFreeChartPropertyColorProvider(xmin.getResourceManager()));\r
293         xmin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min));\r
294         xmin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min));\r
295         xmin.setInputValidator(new DoubleValidator(true));\r
296         \r
297         // Max value for x-axis\r
298         labelMax = new Label(xColumn2, SWT.NONE);\r
299         labelMax.setText("Max:");\r
300         \r
301         xmax = new TrackedText(xColumn2, domainAxisSupport, SWT.BORDER);\r
302         xmax.setColorProvider(new JFreeChartPropertyColorProvider(xmax.getResourceManager()));\r
303         xmax.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max));\r
304         xmax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max));\r
305         xmax.setInputValidator(new DoubleValidator(true));\r
306         \r
307         // Axis hide buttons\r
308         axisHide = new AxisHidePropertyComposite(composite, context, domainAxisSupport, SWT.NONE);\r
309 \r
310         sc.setContent(composite);\r
311         }\r
312 \r
313         @Override\r
314         protected void createControlLayoutVertical() {\r
315                 // Scrolled composite containing all of the properties in this tab\r
316         GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
317         GridLayoutFactory.fillDefaults().applyTo(sc);\r
318 \r
319         GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite);\r
320 \r
321         // General properties\r
322         GridDataFactory.fillDefaults().grab(true, false).applyTo(general);\r
323         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(general);\r
324 \r
325         // Name\r
326         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(nameLabel);\r
327 \r
328         GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget());\r
329 \r
330         // Type\r
331         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelType);\r
332 \r
333         GridDataFactory.fillDefaults().applyTo(type.getWidget());\r
334 \r
335         // Title (Which is different than name)\r
336         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelTitle);\r
337 \r
338         GridDataFactory.fillDefaults().span(1, 1).grab(true, false).applyTo(title.getWidget());\r
339 \r
340         // Group for hide options\r
341         GridDataFactory.fillDefaults().applyTo(hideGroup);\r
342         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup);\r
343 \r
344         // X-Axis properties\r
345         GridDataFactory.fillDefaults().grab(true, false).applyTo(xgroup);\r
346         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(1).applyTo(xgroup);\r
347 \r
348         GridDataFactory.fillDefaults().grab(true, false).applyTo(xColumn1);\r
349         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(xColumn1);\r
350         \r
351         // Variable for x-axis (default: empty == time)\r
352         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(xVariableLabel);\r
353 \r
354         GridDataFactory.fillDefaults().grab(true, false).applyTo(xvariable.getWidget());\r
355         \r
356         // Label for x-axis\r
357         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelLabel);\r
358 \r
359         GridDataFactory.fillDefaults().grab(true, false).applyTo(xlabel.getWidget());\r
360 \r
361         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(xColumn2);\r
362 \r
363         // Min value for x-axis\r
364         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelMin);\r
365         GridDataFactory.fillDefaults().applyTo(xmin.getWidget());\r
366         \r
367         // Max value for x-axis\r
368         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelMax);\r
369         GridDataFactory.fillDefaults().applyTo(xmax.getWidget());\r
370         \r
371         // Axis hide buttons\r
372         GridDataFactory.fillDefaults().applyTo(axisHide);\r
373 \r
374         // Set the same width to both label rows\r
375         composite.layout();\r
376         GridDataFactory.fillDefaults().hint(xVariableLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(nameLabel);\r
377         GridDataFactory.fillDefaults().hint(xVariableLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(labelMin);\r
378         \r
379         Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
380         sc.setMinSize(size);\r
381         }\r
382 \r
383         @Override\r
384         protected void createControlLayoutHorizontal(boolean wideScreen) {\r
385                 // Scrolled composite containing all of the properties in this tab\r
386         GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
387         GridLayoutFactory.fillDefaults().applyTo(sc);\r
388 \r
389         GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite);\r
390 \r
391         // General properties\r
392         GridDataFactory.fillDefaults().grab(true, false).applyTo(general);\r
393         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(general);\r
394 \r
395         // Name\r
396         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(nameLabel);\r
397 \r
398         GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget());\r
399 \r
400         // Type\r
401         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelType);\r
402 \r
403         GridDataFactory.fillDefaults().applyTo(type.getWidget());\r
404 \r
405         // Title (Which is different than name)\r
406         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelTitle);\r
407 \r
408         GridDataFactory.fillDefaults().span(3, 1).grab(true, false).applyTo(title.getWidget());\r
409 \r
410         // Group for hide options\r
411         GridDataFactory.fillDefaults().applyTo(hideGroup);\r
412         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup);\r
413 \r
414         // X-Axis properties\r
415         GridDataFactory.fillDefaults().grab(true, false).applyTo(xgroup);\r
416         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(xgroup);\r
417 \r
418         GridDataFactory.fillDefaults().grab(true, false).applyTo(xColumn1);\r
419         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(xColumn1);\r
420         \r
421         // Variable for x-axis (default: empty == time)\r
422         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(xVariableLabel);\r
423 \r
424         GridDataFactory.fillDefaults().grab(true, false).applyTo(xvariable.getWidget());\r
425         \r
426         // Label for x-axis\r
427         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelLabel);\r
428 \r
429         GridDataFactory.fillDefaults().grab(true, false).applyTo(xlabel.getWidget());\r
430 \r
431         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(xColumn2);\r
432 \r
433         // Min value for x-axis\r
434         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelMin);\r
435         GridDataFactory.fillDefaults().applyTo(xmin.getWidget());\r
436         \r
437         // Max value for x-axis\r
438         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(labelMax);\r
439         GridDataFactory.fillDefaults().applyTo(xmax.getWidget());\r
440         \r
441         // Axis hide buttons\r
442         GridDataFactory.fillDefaults().applyTo(axisHide);\r
443 \r
444         // Set the same width to both label rows\r
445         composite.layout();\r
446         GridDataFactory.fillDefaults().hint(xVariableLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(nameLabel);\r
447        \r
448         Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
449         sc.setMinSize(size);\r
450         }\r
451 \r
452 }