Rewrite the simulation graph component. It is now implemented as a fragment with...
[debian/openrocket] / android / src / net / sf / openrocket / android / simulation / SimulationViewActivity.java
1 /**\r
2  * Copyright (C) 2009, 2010 SC 4ViewSoft SRL\r
3  *  \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *  \r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *  \r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 package net.sf.openrocket.android.simulation;\r
17 \r
18 import net.sf.openrocket.android.Application;\r
19 import net.sf.openrocket.document.OpenRocketDocument;\r
20 import net.sf.openrocket.document.Simulation;\r
21 import android.os.Bundle;\r
22 import android.support.v4.app.Fragment;\r
23 import android.support.v4.app.FragmentActivity;\r
24 import android.support.v4.app.FragmentTransaction;\r
25 \r
26 /**\r
27  * An activity that encapsulates a graphical view of the chart.\r
28  */\r
29 public class SimulationViewActivity extends FragmentActivity {\r
30 \r
31         @Override\r
32         protected void onCreate(Bundle savedInstanceState) {\r
33                 super.onCreate(savedInstanceState);\r
34                 //setContentView(R.layout.simulation_graph_activity);\r
35                 int simulationNumber = getIntent().getIntExtra("Simulation", 0);\r
36 \r
37                 final OpenRocketDocument rocketDocument = ((Application)getApplication()).getRocketDocument();\r
38 \r
39                 Simulation sim = rocketDocument.getSimulation(simulationNumber);\r
40                 \r
41                 SimulationChart chart = new SimulationChart( simulationNumber);\r
42                 chart.setSeries1(sim.getSimulatedData().getBranch(0).getTypes()[1]);\r
43                 chart.setSeries2(sim.getSimulatedData().getBranch(0).getTypes()[2]);\r
44 \r
45                 Fragment graph = SimulationFragment.newInstance(chart);\r
46 \r
47                 FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
48                 ft.add(android.R.id.content, graph);\r
49                 ft.commit();\r
50         }\r
51 \r
52 }