Enhance the Simulation Events Dialog so it shows more like a table with altitude and velocity values as well as time.
This commit is contained in:
parent
fe5b8018de
commit
99d215fdd3
34
android/res/layout-land/simulation_event_item.xml
Normal file
34
android/res/layout-land/simulation_event_item.xml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/eventName"
|
||||||
|
style="@style/labelTextStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="eventName" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/eventTime"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="eventTime"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/eventVelocity"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="eventVelocity"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/eventAltitude"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="eventAltitude"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
</TableRow>
|
@ -1,12 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical" >
|
|
||||||
|
<TableLayout
|
||||||
<ListView
|
|
||||||
android:id="@+id/simulationEventsList"
|
android:id="@+id/simulationEventsList"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent" />
|
android:layout_height="wrap_content" >
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
</ScrollView>
|
||||||
|
40
android/res/layout/simulation_event_item.xml
Normal file
40
android/res/layout/simulation_event_item.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/eventName"
|
||||||
|
style="@style/labelTextStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="eventName" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/eventTime"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="eventTime"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/eventVelocity"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="eventVelocity"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/eventAltitude"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="eventAltitude"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</TableRow>
|
@ -1,22 +1,27 @@
|
|||||||
package net.sf.openrocket.android.simulation;
|
package net.sf.openrocket.android.simulation;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.sf.openrocket.R;
|
import net.sf.openrocket.R;
|
||||||
import net.sf.openrocket.android.Application;
|
import net.sf.openrocket.android.Application;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
|
import net.sf.openrocket.simulation.FlightDataBranch;
|
||||||
|
import net.sf.openrocket.simulation.FlightDataType;
|
||||||
import net.sf.openrocket.simulation.FlightEvent;
|
import net.sf.openrocket.simulation.FlightEvent;
|
||||||
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
|
import net.sf.openrocket.util.MathUtil;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.TableLayout;
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class SimulationEventsDialog extends DialogFragment {
|
public class SimulationEventsDialog extends DialogFragment {
|
||||||
|
|
||||||
private SimulationChart chart;
|
private SimulationChart chart;
|
||||||
private ListView eventList;
|
private TableLayout eventList;
|
||||||
|
|
||||||
public static SimulationEventsDialog newInstance( SimulationChart chart ) {
|
public static SimulationEventsDialog newInstance( SimulationChart chart ) {
|
||||||
SimulationEventsDialog d = new SimulationEventsDialog();
|
SimulationEventsDialog d = new SimulationEventsDialog();
|
||||||
@ -29,32 +34,29 @@ public class SimulationEventsDialog extends DialogFragment {
|
|||||||
|
|
||||||
View v = inflater.inflate(R.layout.simulation_event_dialog, container, false);
|
View v = inflater.inflate(R.layout.simulation_event_dialog, container, false);
|
||||||
|
|
||||||
eventList = (ListView) v.findViewById(R.id.simulationEventsList);
|
eventList = (TableLayout) v.findViewById(R.id.simulationEventsList);
|
||||||
|
eventList.setColumnShrinkable(0, true);
|
||||||
|
|
||||||
OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
final OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||||
// Initialize the eventList
|
|
||||||
ArrayAdapter<FlightEvent> events = new ArrayAdapter<FlightEvent>(
|
|
||||||
getActivity(),
|
|
||||||
android.R.layout.simple_list_item_1,
|
|
||||||
chart.getFlightDataBranch(rocketDocument).getEvents() ) {
|
|
||||||
|
|
||||||
@Override
|
List<FlightEvent> events = chart.getFlightDataBranch(rocketDocument).getEvents();
|
||||||
public View getView(int position, View convertView,
|
|
||||||
ViewGroup parent) {
|
for ( FlightEvent event : events ) {
|
||||||
View v = convertView;
|
|
||||||
if ( v == null ) {
|
|
||||||
LayoutInflater li = inflater;
|
|
||||||
v = li.inflate(android.R.layout.simple_list_item_1,null);
|
|
||||||
}
|
|
||||||
FlightEvent event = this.getItem(position);
|
|
||||||
((TextView)v.findViewById(android.R.id.text1)).setText( event.getType().toString() + " " + event.getTime() + " (s)" );
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
View tableRow = inflater.inflate(R.layout.simulation_event_item,null);
|
||||||
// Events are not selectable for plotting right now.
|
((TextView)tableRow.findViewById(R.id.eventName)).setText( event.getType().toString() );
|
||||||
//eventList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
((TextView)tableRow.findViewById(R.id.eventTime)).setText( event.getTime() + " (s)" );
|
||||||
eventList.setAdapter(events);
|
|
||||||
|
FlightDataBranch data = chart.getFlightDataBranch(rocketDocument);
|
||||||
|
double vel = MathUtil.interpolate(data.get(FlightDataType.TYPE_TIME), data.get(FlightDataType.TYPE_VELOCITY_TOTAL), event.getTime());
|
||||||
|
((TextView)tableRow.findViewById(R.id.eventVelocity)).setText( UnitGroup.UNITS_VELOCITY.getDefaultUnit().toStringUnit(vel) );
|
||||||
|
|
||||||
|
double alt = MathUtil.interpolate(data.get(FlightDataType.TYPE_TIME), data.get(FlightDataType.TYPE_ALTITUDE), event.getTime());
|
||||||
|
((TextView)tableRow.findViewById(R.id.eventAltitude)).setText( UnitGroup.UNITS_DISTANCE.getDefaultUnit().toStringUnit(alt) );
|
||||||
|
|
||||||
|
eventList.addView( tableRow );
|
||||||
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user