]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
b0363b95a901e73d029f11cf3d25165fd916e2db
[simantics/sysdyn.git] /
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2012 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.browser.actions.newActions;\r
13 \r
14 import java.awt.Color;\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.exception.DatabaseException;\r
20 import org.simantics.diagram.stubs.G2DResource;\r
21 import org.simantics.layer0.utils.direct.GraphUtils;\r
22 import org.simantics.sysdyn.SysdynResource;\r
23 \r
24 /**\r
25  * Creates a new simulation playback experiment\r
26  * @author Teemu Lempinen\r
27  *\r
28  */\r
29 public class NewSimulationPlaybackExperimentAction extends NewExperimentAction {\r
30     \r
31     protected void configureExperiment(WriteGraph graph, Resource experiment) throws DatabaseException {\r
32         G2DResource g2d = G2DResource.getInstance(graph);\r
33         Resource defaultGradient = GraphUtils.create2(graph, g2d.ColorGradient);\r
34         graph.claim(experiment, g2d.HasColorGradient, defaultGradient);\r
35 \r
36         Resource placement = GraphUtils.create2(graph, g2d.ColorPlacement, \r
37                 g2d.HasGradientPosition, 0.0);\r
38         graph.claimLiteral(placement, g2d.HasColor, g2d.Color, new Color(0, 62, 133).getColorComponents(new float[4]));\r
39         graph.claim(defaultGradient, g2d.HasColorPlacement, placement);\r
40         \r
41         placement = GraphUtils.create2(graph, g2d.ColorPlacement, \r
42                 g2d.HasGradientPosition, 1.0);\r
43         graph.claimLiteral(placement, g2d.HasColor, g2d.Color, new Color(255, 230, 0).getColorComponents(new float[4]));\r
44         graph.claim(defaultGradient, g2d.HasColorPlacement, placement);\r
45     }\r
46 \r
47     protected Resource getExperimentType(ReadGraph g) {\r
48         return SysdynResource.getInstance(g).PlaybackExperiment;\r
49     }\r
50 \r
51     protected String getNameSuggestion() {\r
52         return "Playback Experiment";\r
53     }\r
54 \r
55 }\r