From e766449e15744e054c6acc57bedf969beb2cb58f Mon Sep 17 00:00:00 2001 From: Kevin Ruland Date: Wed, 11 Jan 2012 14:56:40 +0000 Subject: [PATCH] Modified RocketUtils.getCG to take a MassCalcType parameter. In the OpenRocketViewer, calculate mass empty. Changed the order of the fields in the openrocketviewer layout. Added a spinner for the configurations stored in the ork file - though this still needs to have motors wired in. --- android/res/layout/openrocketviewer.xml | 40 ++++++++----------- .../android/rocket/OpenRocketViewer.java | 16 ++++++-- .../rocketcomponent/RocketUtils.java | 4 +- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/android/res/layout/openrocketviewer.xml b/android/res/layout/openrocketviewer.xml index 8ddc4c4f1..e25ec6d8b 100644 --- a/android/res/layout/openrocketviewer.xml +++ b/android/res/layout/openrocketviewer.xml @@ -31,17 +31,6 @@ android:layout_height="wrap_content" android:orientation="vertical" > - - - - - - - - + android:text="Empty Mass" /> + + + + + + spinnerAdapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item); + for( String config: motorConfigs ) { + spinnerAdapter.add(rocket.getMotorConfigurationNameOrDescription(config)); + } + + configurationSpinner.setAdapter(spinnerAdapter); + Unit LengthUnit = UnitGroup.UNITS_LENGTH.getDefaultUnit(); Unit MassUnit = UnitGroup.UNITS_MASS.getDefaultUnit(); - Coordinate cg = RocketUtils.getCG(rocket); + Coordinate cg = RocketUtils.getCG(rocket, MassCalcType.NO_MOTORS); double length = RocketUtils.getLength(rocket); - ((TextView) findViewById(R.id.openrocketviewerRocketName)).setText( rocket.getName()); ((TextView)findViewById(R.id.openrocketviewerDesigner)).setText(rocket.getDesigner()); ((TextView)findViewById(R.id.openrocketviewerCG)).setText(LengthUnit.toStringUnit(cg.x) ); ((TextView)findViewById(R.id.openrocketviewerLength)).setText(LengthUnit.toStringUnit(length)); diff --git a/core/src/net/sf/openrocket/rocketcomponent/RocketUtils.java b/core/src/net/sf/openrocket/rocketcomponent/RocketUtils.java index 2e4b63b8a..71360b9a2 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RocketUtils.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RocketUtils.java @@ -25,9 +25,9 @@ public abstract class RocketUtils { return length; } - public static Coordinate getCG(Rocket rocket) { + public static Coordinate getCG(Rocket rocket, MassCalcType calcType) { MassCalculator massCalculator = new BasicMassCalculator(); - Coordinate cg = massCalculator.getCG(rocket.getDefaultConfiguration(), MassCalcType.LAUNCH_MASS); + Coordinate cg = massCalculator.getCG(rocket.getDefaultConfiguration(), calcType); return cg; }