1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
\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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.sysdyn.ui.handlers.newComponents;
\r
14 import java.awt.Color;
\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
25 * Creates a new playback experiment.
\r
27 * @author Teemu Lempinen
\r
30 public class NewPlaybackExperimentNodeHandler extends NewExperimentNodeHandler {
\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
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
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
48 protected Resource getExperimentType(ReadGraph g) {
\r
49 return SysdynResource.getInstance(g).PlaybackExperiment;
\r
52 protected String getNameSuggestion() {
\r
53 return "Playback Experiment";
\r