]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
a54ce36f68100af2fb62a0e7255bb1fcc4366366
[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.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 playback experiment.\r
26  * \r
27  * @author Teemu Lempinen\r
28  *\r
29  */\r
30 public class NewPlaybackExperimentNodeHandler  extends NewExperimentNodeHandler  {\r
31 \r
32     protected void configureExperiment(WriteGraph graph, Resource experiment) throws DatabaseException {\r
33         G2DResource g2d = G2DResource.getInstance(graph);\r
34         Resource defaultGradient = GraphUtils.create2(graph, g2d.ColorGradient);\r
35         graph.claim(experiment, g2d.HasColorGradient, defaultGradient);\r
36 \r
37         Resource placement = GraphUtils.create2(graph, g2d.ColorPlacement, \r
38                 g2d.HasGradientPosition, 0.0);\r
39         graph.claimLiteral(placement, g2d.HasColor, g2d.Color, new Color(0, 62, 133).getColorComponents(new float[4]));\r
40         graph.claim(defaultGradient, g2d.HasColorPlacement, placement);\r
41         \r
42         placement = GraphUtils.create2(graph, g2d.ColorPlacement, \r
43                 g2d.HasGradientPosition, 1.0);\r
44         graph.claimLiteral(placement, g2d.HasColor, g2d.Color, new Color(255, 230, 0).getColorComponents(new float[4]));\r
45         graph.claim(defaultGradient, g2d.HasColorPlacement, placement);\r
46     }\r
47 \r
48     protected Resource getExperimentType(ReadGraph g) {\r
49         return SysdynResource.getInstance(g).PlaybackExperiment;\r
50     }\r
51 \r
52     protected String getNameSuggestion() {\r
53         return "Playback Experiment";\r
54     }\r
55 }