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