|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.widget.Button;
|
|
|
import android.widget.Button;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.ListView;
|
|
|
|
|
|
import android.widget.ScrollView;
|
|
|
import android.widget.ScrollView;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
private static final int MIN_DISTANCE = 50;
|
|
|
private static final int MIN_DISTANCE = 50;
|
|
|
private static final double CENTI = 0.01;
|
|
|
private static final double CENTI = 0.01;
|
|
|
private static final double MILLI = 0.001;
|
|
|
private static final double MILLI = 0.001;
|
|
|
private static final String TAB = "\u0009";
|
|
|
|
|
|
|
|
|
|
|
|
private ViewFlipper viewFlipper;
|
|
|
private ViewFlipper viewFlipper;
|
|
|
private ScrollView paramsScrollView;
|
|
|
private ScrollView paramsScrollView;
|
|
|
private ScrollView sightCfgScrollView;
|
|
|
private ScrollView sightCfgScrollView;
|
|
|
private float lastX;
|
|
|
private float lastX;
|
|
|
private ListView listView1;
|
|
|
|
|
|
private XTextView txtViewParams;
|
|
|
private XTextView txtViewParams;
|
|
|
private XTextView txtViewResults;
|
|
|
private XTextView txtViewResults;
|
|
|
private XTextView txtViewSight;
|
|
|
private XTextView txtViewSight;
|
|
|
|
|
|
|
|
|
addRiserAndSightSpinnerListeners();
|
|
|
addRiserAndSightSpinnerListeners();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void onSaveInstanceState(final Bundle outState) {
|
|
|
|
|
|
super.onSaveInstanceState(outState);
|
|
|
|
|
|
outState.putInt("ViewFlipper.SelectedView", this.viewFlipper.getDisplayedChild());
|
|
|
|
|
|
if (this.selectedArcherySetup != null) {
|
|
|
|
|
|
outState.putLong("SelectedArcherySetup", this.selectedArcherySetup.getId());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.startAngle != null) {
|
|
|
|
|
|
outState.putDouble("StartAngle", this.startAngle);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.scHeVSSpinner.getSelectedItem() != null) {
|
|
|
|
|
|
outState.putString("SelectedHeVS", this.scHeVSSpinner.getSelectedItem().toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@Override
|
|
|
protected void onRestoreInstanceState(final Bundle savedInstanceState) {
|
|
|
protected void onRestoreInstanceState(final Bundle savedInstanceState) {
|
|
|
super.onRestoreInstanceState(savedInstanceState);
|
|
|
super.onRestoreInstanceState(savedInstanceState);
|
|
|
|
|
|
|
|
|
if (savedInstanceState.containsKey("SelectedArcherySetup")) {
|
|
|
if (savedInstanceState.containsKey("SelectedArcherySetup")) {
|
|
|
this.selectedArcherySetup = ArcherySetupDao.getInstance().loadById(savedInstanceState.getLong("SelectedArcherySetup"));
|
|
|
this.selectedArcherySetup = ArcherySetupDao.getInstance().loadById(savedInstanceState.getLong("SelectedArcherySetup"));
|
|
|
}
|
|
|
}
|
|
|
this.startAngle = savedInstanceState.getDouble("StartAngle", 0);
|
|
|
|
|
|
|
|
|
this.startAngle = savedInstanceState.getDouble("StartAngle");
|
|
|
this.selectedHeVS = savedInstanceState.getString("SelectedHeVS");
|
|
|
this.selectedHeVS = savedInstanceState.getString("SelectedHeVS");
|
|
|
|
|
|
|
|
|
deactivateAllXTextView();
|
|
|
deactivateAllXTextView();
|
|
|
|
|
|
|
|
|
switch (selView) {
|
|
|
switch (selView) {
|
|
|
case 0:
|
|
|
case 0:
|
|
|
xTextViewUp(this.txtViewParams);
|
|
|
xTextViewUp(this.txtViewParams);
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void onSaveInstanceState(final Bundle outState) {
|
|
|
|
|
|
super.onSaveInstanceState(outState);
|
|
|
|
|
|
outState.putInt("ViewFlipper.SelectedView", this.viewFlipper.getDisplayedChild());
|
|
|
|
|
|
if (this.selectedArcherySetup != null) {
|
|
|
|
|
|
outState.putLong("SelectedArcherySetup", this.selectedArcherySetup.getId());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.startAngle != null) {
|
|
|
|
|
|
outState.putDouble("StartAngle", this.startAngle);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.scHeVSSpinner.getSelectedItem() != null) {
|
|
|
|
|
|
outState.putString("SelectedHeVS", this.scHeVSSpinner.getSelectedItem().toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initializeComponents() {
|
|
|
private void initializeComponents() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void onCalculationDone(final Double[][] flightCurve, final Double startAngle, final Double[] maxHCurve) {
|
|
|
public void onCalculationDone(final Double[][] flightCurve, final Double startAngle, final Double[] maxHCurve) {
|
|
|
this.startAngle = startAngle;
|
|
|
this.startAngle = startAngle;
|
|
|
|
|
|
|
|
|
|
|
|
fillFlightCurveTxtFld(flightCurve, startAngle, maxHCurve);
|
|
|
|
|
|
calculateSettings();
|
|
|
|
|
|
|
|
|
|
|
|
if (this.calculationAlert != null) {
|
|
|
|
|
|
this.calculationAlert.dismiss();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.txtViewSight.doSingleTouch();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void fillFlightCurveTxtFld(final Double[][] flightCurve, final Double startAngle,
|
|
|
|
|
|
final Double[] maxHCurve) {
|
|
|
this.flightCurveTxtFld.setText("");
|
|
|
this.flightCurveTxtFld.setText("");
|
|
|
this.flightCurveTxtFld.append("Abschusswinkel:" + TAB + DF_FC.format(startAngle) + " °\n");
|
|
|
|
|
|
this.flightCurveTxtFld.append("Max. Höhe der Flugbahn:" + TAB + DF_FC.format(maxHCurve[0])
|
|
|
|
|
|
|
|
|
this.flightCurveTxtFld.append("Abschusswinkel:\n" + DF_FC.format(startAngle) + " °\n\n");
|
|
|
|
|
|
this.flightCurveTxtFld.append("Max. Höhe der Flugbahn:\n" + DF_FC.format(maxHCurve[0])
|
|
|
+ " m / " + DF_FC.format(maxHCurve[0] + Double.valueOf(this.arrowNockHeightTxtFld.getText().toString().trim()))
|
|
|
+ " m / " + DF_FC.format(maxHCurve[0] + Double.valueOf(this.arrowNockHeightTxtFld.getText().toString().trim()))
|
|
|
+ " m, [t = " + DF_FC.format(maxHCurve[1]) + " s]\n");
|
|
|
|
|
|
this.flightCurveTxtFld.append("Flugzeit:" + TAB + TAB
|
|
|
|
|
|
|
|
|
+ " m, [t = " + DF_FC.format(maxHCurve[1]) + " s]\n\n");
|
|
|
|
|
|
this.flightCurveTxtFld.append("Flugzeit:\n"
|
|
|
+ DF_FC.format(flightCurve[flightCurve.length - 1][TrajectoryCalculator.IDX_T])
|
|
|
+ DF_FC.format(flightCurve[flightCurve.length - 1][TrajectoryCalculator.IDX_T])
|
|
|
+ " sec\n\n");
|
|
|
+ " sec\n\n");
|
|
|
|
|
|
|
|
|
int width = this.flightCurveTxtFld.getMeasuredWidth();
|
|
|
int width = this.flightCurveTxtFld.getMeasuredWidth();
|
|
|
|
|
|
|
|
|
SpannableString line = new SpannableString("t [sec]\tVx [m/s]\tVy [m/s]\tx [m]\ty [m]\n\n");
|
|
|
SpannableString line = new SpannableString("t [sec]\tVx [m/s]\tVy [m/s]\tx [m]\ty [m]\n\n");
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5), 0, 36, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5 * 2), 0, 36, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5 * 3), 0, 36, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5 * 4), 0, 36, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5), 0, line.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5 * 2), 0, line.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5 * 3), 0, line.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5 * 4), 0, line.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
this.flightCurveTxtFld.append(line);
|
|
|
this.flightCurveTxtFld.append(line);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.flightCurveTxtFld.append("t [sec]" + TAB + TAB + "Vx [m/s]" + TAB + TAB + "Vy [m/s]" + TAB + TAB + "x [m]" + TAB + TAB + "y [m]\n\n");
|
|
|
|
|
|
//
|
|
|
|
|
|
// for (int i = 0; i < flightCurve.length; i++) {
|
|
|
|
|
|
// Double[] r1 = flightCurve[i];
|
|
|
|
|
|
// StringBuffer line = new StringBuffer();
|
|
|
|
|
|
// line.append(DF_FC.format(r1[TrajectoryCalculator.IDX_T]) + TAB + TAB
|
|
|
|
|
|
// + DF_FC.format(r1[TrajectoryCalculator.IDX_VX]) + TAB + TAB + TAB
|
|
|
|
|
|
// + DF_FC.format(r1[TrajectoryCalculator.IDX_VY]) + TAB + TAB + TAB + TAB
|
|
|
|
|
|
// + DF_FC.format(r1[TrajectoryCalculator.IDX_X]) + TAB + TAB
|
|
|
|
|
|
// + DF_FC.format(r1[TrajectoryCalculator.IDX_Y]) + "\n");
|
|
|
|
|
|
// this.flightCurveTxtFld.append(line.toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
calculateSettings();
|
|
|
|
|
|
|
|
|
|
|
|
if (this.calculationAlert != null) {
|
|
|
|
|
|
this.calculationAlert.dismiss();
|
|
|
|
|
|
|
|
|
for (int i = 0; i < flightCurve.length; i++) {
|
|
|
|
|
|
Double[] r1 = flightCurve[i];
|
|
|
|
|
|
line = new SpannableString(DF_FC.format(r1[TrajectoryCalculator.IDX_T]) + '\t'
|
|
|
|
|
|
+ DF_FC.format(r1[TrajectoryCalculator.IDX_VX]) + '\t'
|
|
|
|
|
|
+ DF_FC.format(r1[TrajectoryCalculator.IDX_VY]) + '\t'
|
|
|
|
|
|
+ DF_FC.format(r1[TrajectoryCalculator.IDX_X]) + '\t'
|
|
|
|
|
|
+ DF_FC.format(r1[TrajectoryCalculator.IDX_Y]) + "\n");
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5), 0, line.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5 * 2), 0, line.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5 * 3), 0, line.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
line.setSpan(new TabStopSpan.Standard(width / 5 * 4), 0, line.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
this.flightCurveTxtFld.append(line);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
this.txtViewSight.doSingleTouch();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|