Convert apogee and simulation plot values to configured units.
This commit is contained in:
parent
6e849bcf30
commit
44d390272c
@ -264,7 +264,12 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
}
|
}
|
||||||
Simulation sim = this.getItem(position);
|
Simulation sim = this.getItem(position);
|
||||||
((TextView)v.findViewById(android.R.id.text1)).setText( sim.getName() );
|
((TextView)v.findViewById(android.R.id.text1)).setText( sim.getName() );
|
||||||
((TextView)v.findViewById(android.R.id.text2)).setText( "motors: " + sim.getConfiguration().getMotorConfigurationDescription() + " apogee: " + sim.getSimulatedData().getMaxAltitude() + "m time: " + sim.getSimulatedData().getFlightTime() + "s");
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("motors: ").append(sim.getConfiguration().getMotorConfigurationDescription());
|
||||||
|
Unit distanceUnit = UnitGroup.UNITS_DISTANCE.getDefaultUnit();
|
||||||
|
sb.append(" apogee: ").append( distanceUnit.toStringUnit(sim.getSimulatedData().getMaxAltitude()));
|
||||||
|
sb.append(" time: ").append(sim.getSimulatedData().getFlightTime()).append("s");
|
||||||
|
((TextView)v.findViewById(android.R.id.text2)).setText( sb.toString() );
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +280,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
Intent i = new Intent(OpenRocketViewer.this, SimulationViewer.class);
|
Intent i = new Intent(OpenRocketViewer.this, SimulationViewer.class);
|
||||||
Log.d(TAG,"onItemClick simulation number " + id );
|
Log.d(TAG,"onItemClick simulation number " + id );
|
||||||
i.putExtra("Simulation",(int)id);
|
i.putExtra("Simulation",(int)id);
|
||||||
startActivityForResult(i, 1/*magic*/);
|
startActivity(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -15,11 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package net.sf.openrocket.android.simulation;
|
package net.sf.openrocket.android.simulation;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.sf.openrocket.simulation.FlightDataBranch;
|
import net.sf.openrocket.simulation.FlightDataBranch;
|
||||||
import net.sf.openrocket.simulation.FlightDataType;
|
import net.sf.openrocket.simulation.FlightDataType;
|
||||||
import net.sf.openrocket.simulation.FlightEvent;
|
import net.sf.openrocket.simulation.FlightEvent;
|
||||||
|
import net.sf.openrocket.unit.Unit;
|
||||||
|
|
||||||
import org.achartengine.ChartFactory;
|
import org.achartengine.ChartFactory;
|
||||||
import org.achartengine.chart.LineChart;
|
import org.achartengine.chart.LineChart;
|
||||||
@ -157,7 +159,13 @@ public class SimulationChart {
|
|||||||
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
|
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
|
||||||
|
|
||||||
List<Double> timevalues = flightDataBranch.get(time);
|
List<Double> timevalues = flightDataBranch.get(time);
|
||||||
List<Double> series1values = flightDataBranch.get(series1);
|
List<Double> series1values = new ArrayList<Double>( flightDataBranch.get(series1).size() );
|
||||||
|
{
|
||||||
|
Unit u = series1.getUnitGroup().getDefaultUnit();
|
||||||
|
for( Double d: flightDataBranch.get(series1) ) {
|
||||||
|
series1values.add( u.toUnit(d));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// compute the axis limits using timevalues and series1values.
|
// compute the axis limits using timevalues and series1values.
|
||||||
double xmin = 0;
|
double xmin = 0;
|
||||||
@ -181,7 +189,15 @@ public class SimulationChart {
|
|||||||
|
|
||||||
if ( seriesCount > 1 ) {
|
if ( seriesCount > 1 ) {
|
||||||
// Add second series
|
// Add second series
|
||||||
addXYSeries(dataset, series2.getName(), timevalues, flightDataBranch.get(series2), 1);
|
List<Double> series2values = new ArrayList<Double>( flightDataBranch.get(series2).size() );
|
||||||
|
{
|
||||||
|
Unit u = series2.getUnitGroup().getDefaultUnit();
|
||||||
|
for( Double d: flightDataBranch.get(series2) ) {
|
||||||
|
series2values.add( u.toUnit(d));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addXYSeries(dataset, series2.getName(), timevalues, series2values, 1);
|
||||||
}
|
}
|
||||||
Intent intent = getLineChartIntent(context, dataset, renderer,"Simulation");
|
Intent intent = getLineChartIntent(context, dataset, renderer,"Simulation");
|
||||||
return intent;
|
return intent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user