2 * Copyright (C) 2009, 2010 SC 4ViewSoft SRL
\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
8 * http://www.apache.org/licenses/LICENSE-2.0
\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
16 package net.sf.openrocket.android.simulation;
\r
18 import net.sf.openrocket.R;
\r
19 import net.sf.openrocket.android.ActivityHelpers;
\r
20 import net.sf.openrocket.android.Application;
\r
21 import net.sf.openrocket.document.OpenRocketDocument;
\r
22 import net.sf.openrocket.document.Simulation;
\r
23 import android.os.Bundle;
\r
24 import android.support.v4.app.Fragment;
\r
25 import android.support.v4.app.FragmentActivity;
\r
26 import android.support.v4.app.FragmentTransaction;
\r
27 import android.view.Menu;
\r
28 import android.view.MenuItem;
\r
31 * An activity that encapsulates a graphical view of the chart.
\r
33 public class SimulationViewActivity extends FragmentActivity {
\r
36 protected void onCreate(Bundle savedInstanceState) {
\r
37 super.onCreate(savedInstanceState);
\r
38 //setContentView(R.layout.simulation_graph_activity);
\r
39 int simulationNumber = getIntent().getIntExtra("Simulation", 0);
\r
41 final OpenRocketDocument rocketDocument = ((Application)getApplication()).getRocketDocument();
\r
43 Simulation sim = rocketDocument.getSimulation(simulationNumber);
\r
45 SimulationChart chart = new SimulationChart( simulationNumber);
\r
46 chart.setSeries1(sim.getSimulatedData().getBranch(0).getTypes()[1]);
\r
47 chart.setSeries2(sim.getSimulatedData().getBranch(0).getTypes()[2]);
\r
49 Fragment graph = SimulationFragment.newInstance(chart);
\r
51 FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
\r
52 ft.replace(android.R.id.content, graph);
\r
57 public boolean onMenuItemSelected(int featureId, MenuItem item) {
\r
58 switch (item.getItemId()) {
\r
59 case R.id.preference_menu_option:
\r
60 ActivityHelpers.startPreferences(this);
\r
63 return super.onMenuItemSelected(featureId, item);
\r
67 public boolean onCreateOptionsMenu(Menu menu) {
\r
68 MenuItem prefItem = menu.add(Menu.NONE, R.id.preference_menu_option, Menu.CATEGORY_SYSTEM, R.string.Preferences);
\r
69 prefItem.setIcon(R.drawable.ic_menu_preferences);
\r