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