]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
c1be4933173df5736b27569c88f3a317a2009960
[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.sysdyn.ui.handlers.newComponents;\r
13 \r
14 import java.util.ArrayList;\r
15 \r
16 import org.simantics.db.ReadGraph;\r
17 import org.simantics.db.Resource;\r
18 import org.simantics.db.WriteGraph;\r
19 import org.simantics.db.common.utils.ListUtils;\r
20 import org.simantics.db.exception.DatabaseException;\r
21 import org.simantics.layer0.Layer0;\r
22 import org.simantics.layer0.utils.direct.GraphUtils;\r
23 import org.simantics.sysdyn.SysdynResource;\r
24 \r
25 /**\r
26  * Creates a new sensitivity analysis experiment.\r
27  * \r
28  * @author Tuomas Miettinen\r
29  *\r
30  */\r
31 public class NewSensitivityAnalysisExperimentNodeHandler extends NewExperimentNodeHandler  {\r
32 \r
33     @Override\r
34     protected void configureExperiment(WriteGraph graph, Resource experiment) throws DatabaseException {\r
35         SysdynResource sr = SysdynResource.getInstance(graph);\r
36         Layer0 L0 = Layer0.getInstance(graph);\r
37         \r
38         Resource distribution = GraphUtils.create2(graph, sr.UniformDistribution,\r
39                 sr.UniformDistribution_minValue, 0.0,\r
40                 sr.UniformDistribution_maxValue, 10.0);\r
41         \r
42         Resource parameter = GraphUtils.create2(graph, sr.SensitivityAnalysisExperiment_Parameter,\r
43                 sr.SensitivityAnalysisExperiment_Parameter_propabilityDistribution, distribution,\r
44                 sr.SensitivityAnalysisExperiment_Parameter_variable, "",\r
45                 sr.SensitivityAnalysisExperiment_Parameter_numberOfValues, 10,\r
46                 L0.PartOf, experiment);\r
47         \r
48         ArrayList<Resource> parameterList = new ArrayList<Resource>();\r
49         parameterList.add(parameter);\r
50         \r
51         graph.claim(experiment, sr.SensitivityAnalysisExperiment_parameterList, ListUtils.create(graph, parameterList));\r
52     }\r
53 \r
54     @Override\r
55     protected Resource getExperimentType(ReadGraph g) {\r
56         return SysdynResource.getInstance(g).SensitivityAnalysisExperiment;\r
57     }\r
58 \r
59     @Override\r
60     protected String getNameSuggestion() {\r
61         return "Sensitivity Experiment";\r
62     }\r
63 }