]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
70d0076e25457ec69080ca397c20c9116c4d67be
[simantics/sysdyn.git] /
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011 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.pie;\r
13 \r
14 import java.util.Collection;\r
15 \r
16 import org.eclipse.jface.layout.GridDataFactory;\r
17 import org.eclipse.jface.layout.GridLayoutFactory;\r
18 import org.eclipse.swt.SWT;\r
19 import org.eclipse.swt.widgets.Composite;\r
20 import org.eclipse.swt.widgets.Label;\r
21 import org.simantics.browsing.ui.swt.widgets.Button;\r
22 import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
23 import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
24 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
25 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
26 import org.simantics.db.management.ISessionContext;\r
27 import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory;\r
28 import org.simantics.jfreechart.chart.properties.BooleanSelectionListener;\r
29 import org.simantics.jfreechart.chart.properties.ChartVariable;\r
30 import org.simantics.jfreechart.chart.properties.ChartVariableFactory;\r
31 import org.simantics.jfreechart.chart.properties.ChartVariableModifier;\r
32 import org.simantics.jfreechart.chart.properties.ColorPicker;\r
33 import org.simantics.jfreechart.chart.properties.DoubleValidator;\r
34 import org.simantics.jfreechart.chart.properties.JFreeChartPropertyColorProvider;\r
35 import org.simantics.jfreechart.chart.properties.RangeComposite;\r
36 import org.simantics.jfreechart.chart.properties.StringChooser;\r
37 import org.simantics.layer0.Layer0;\r
38 import org.simantics.modeling.ui.chart.property.DoublePropertyFactory;\r
39 import org.simantics.modeling.ui.chart.property.DoublePropertyModifier;\r
40 import org.simantics.sysdyn.JFreeChartResource;\r
41 \r
42 /**\r
43  * Composite containing the properties of a series\r
44  * @author Teemu Lempinen\r
45  *\r
46  */\r
47 public class PieSeriesPropertyComposite2 extends Composite {\r
48     \r
49     private TrackedText label, time;\r
50     private StringChooser<ChartVariable> variable;\r
51     \r
52     public PieSeriesPropertyComposite2(Composite parent, ISessionContext context, WidgetSupport support, Collection<ChartVariable> variables,int style) {\r
53         super(parent, style);\r
54         \r
55         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this);\r
56 \r
57         // Variable for the series\r
58         Label label = new Label(this, SWT.NONE);\r
59         label.setText("Variable:");\r
60         GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
61 \r
62         \r
63         variable = new StringChooser<ChartVariable>(this, support, SWT.BORDER);\r
64         variable.setData(variables);\r
65         variable.setObjectFactory(new ChartVariableFactory(variables));\r
66         variable.addModifyListener(new ChartVariableModifier(variable.getWidget(), support));\r
67         \r
68         variable.setColorProvider(new JFreeChartPropertyColorProvider(this.variable.getResourceManager()));\r
69         GridDataFactory.fillDefaults().grab(true, false).applyTo(this.variable.getWidget());\r
70 \r
71         // Range\r
72         label = new Label(this, SWT.NONE);\r
73         label.setText("Range:");\r
74         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
75         \r
76         RangeComposite rangeComposite = new RangeComposite(this, context, support, SWT.NONE);\r
77         GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite);\r
78         \r
79         \r
80         // Label to be displayed in chart for this series\r
81         label = new Label(this, SWT.NONE);\r
82         label.setText("Label:");\r
83         GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
84 \r
85         this.label = new TrackedText(this, support, SWT.BORDER);\r
86         this.label.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, ""));\r
87         this.label.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
88         this.label.setColorProvider(new JFreeChartPropertyColorProvider(this.label.getResourceManager()));\r
89         GridDataFactory.fillDefaults().grab(true, false).applyTo(this.label.getWidget());\r
90 \r
91         // Color\r
92         label = new Label(this, SWT.NONE);\r
93         label.setText("Color:");\r
94         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
95 \r
96         Composite colorPicker = new ColorPicker(this, context, support, SWT.NONE);\r
97         GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker);\r
98 \r
99         // Time\r
100         label = new Label(this, SWT.NONE);\r
101         GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
102         label.setText("Time:");\r
103         \r
104         Composite composite = new Composite(this, SWT.NONE);\r
105         GridDataFactory.fillDefaults().applyTo(composite);\r
106         GridLayoutFactory.fillDefaults().applyTo(composite);\r
107         \r
108         time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER);\r
109         time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time));\r
110         time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time));\r
111         time.setInputValidator(new DoubleValidator(true));\r
112         time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));\r
113         GridDataFactory.fillDefaults().applyTo(time.getWidget());\r
114         \r
115         // Exploded\r
116         label = new Label(this, SWT.NONE);\r
117         label.setText("");\r
118         GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
119         \r
120         Button exploded = new Button(this, support, SWT.CHECK);\r
121         exploded.setText("Exploded");\r
122         exploded.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Series_exploded));\r
123         exploded.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Series_exploded));\r
124         GridDataFactory.fillDefaults().applyTo(exploded.getWidget());\r
125     }\r
126 \r
127 }\r