-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrbitViewer.java
More file actions
3469 lines (3155 loc) · 128 KB
/
Copy pathOrbitViewer.java
File metadata and controls
3469 lines (3155 loc) · 128 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Orbit Projector
*
* Example (Comet)
*
* <APPLET CODE="OrbitViewer" WIDTH=510 HEIGHT=400>
* <PARAM NAME="Name" VALUE="1P/Halley">
* <PARAM NAME="T" VALUE="19860209.7695">
* <PARAM NAME="e" VALUE="0.967267">
* <PARAM NAME="q" VALUE="0.587096">
* <PARAM NAME="Peri" VALUE="111.8466">
* <PARAM NAME="Node" VALUE=" 58.1440">
* <PARAM NAME="Incl" VALUE="162.2393">
* <PARAM NAME="Eqnx" VALUE="1950.0">
* </APPLET>
*
* Example (Minor Planet)
*
* <APPLET CODE="OrbitViewer" WIDTH=510 HEIGHT=400>
* <PARAM NAME="Name" VALUE="Ceres(1)">
* <PARAM NAME="Epoch" VALUE="19991118.5">
* <PARAM NAME="M" VALUE="356.648434">
* <PARAM NAME="e" VALUE="0.07831587">
* <PARAM NAME="a" VALUE="2.76631592">
* <PARAM NAME="Peri" VALUE=" 73.917708">
* <PARAM NAME="Node" VALUE=" 80.495123">
* <PARAM NAME="Incl" VALUE=" 10.583393">
* <PARAM NAME="Eqnx" VALUE="2000.0">
* </APPLET>
*
* Optional parameter "Date" specifies initial date to display.
* If "Date" parameter omitted, it start with current date.
*
* <PARAM NAME="Date" VALUE="19860209.7695">
*
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.math.*;
import java.text.DecimalFormat; // (awp)
import astro.*;
import util.*; // (awp)
import javax.swing.JOptionPane; // (awp)
import java.lang.Thread; // (awp)
//import javax.swing.SwingConstants; //fiddling (awp)
/**
* Main Applet Class
*/
public class OrbitViewer extends java.applet.Applet {
/**
* Components
*/
public static String newline = System.getProperty("line.separator");
private Color myPaleGray = new Color(230, 230, 230);
private Scrollbar scrollA;
private TextField textA;
private Scrollbar scrollE;
private TextField textE;
private Scrollbar scrollIncl;
private TextField textIncl;
private Scrollbar scrollNode;
private TextField textNode;
private Scrollbar scrollPeri;
private TextField textPeri;
private Scrollbar scrollM;
private TextField textM;
private Scrollbar scrollHorz;
private Scrollbar scrollVert;
private Scrollbar scrollZoom;
private TextField textZoom;
private OrbitCanvas orbitCanvas;
private Button buttonDate;
private Button buttonMeasure;
private Label aLabel;
public String QorA = "a";
public Comet object;
public Comet tempobj;
public Xyz[] xyzObs;
public String[] nameObs;
public int nClones = 0;
public int nClonesMax = 3000;
public int nClonesPreload = 0;
public Comet[] clone = new Comet[nClonesMax];
private Button buttonRevPlay;
private Button buttonRevStep;
private Button buttonStop;
private Button buttonForStep;
private Button buttonForPlay;
private Choice choiceTimeStep;
private Choice choiceCenterObject;
private Choice choiceOrbitObject;
private Choice choicePrimaryObject;
private Checkbox checkPlanetName;
private Checkbox checkObjectName;
private Checkbox checkCloneName;
private Checkbox checkDistanceLabel;
// private Checkbox checkDateLabel;
private Checkbox checkFineControl;
private Checkbox checkLock;
private Button buttonClone;
private DateDialog dateDialog = null;
private Panel mainPanel;
/**
* Player thread
*/
private OrbitPlayer orbitPlayer;
Thread playerThread = null;
/**
* Current Time Setting
*/
private ATime atime;
public double jdStopped = -1.;
/**
* Time step
*/
static final int timeStepCount = 9; //11; // 8;
static final String timeStepLabel[] = {
"1 Minute", //"10 Minutes", // (awp)
"1 Hour",
// "6 Hours", // (awp)
"1 Day", "3 Days", "10 Days",
"1 Month", "(3 Months)", "(6 Months)",
"(1 Year)"
};
static final TimeSpan timeStepSpan[] = {
new TimeSpan(0, 0, 0, 0, 1, 0.0), // (awp)
// new TimeSpan(0, 0, 0, 0, 10, 0.0), // (awp)
new TimeSpan(0, 0, 0, 1, 0, 0.0),
// new TimeSpan(0, 0, 0, 6, 0, 0.0), // (awp)
new TimeSpan(0, 0, 1, 0, 0, 0.0),
new TimeSpan(0, 0, 3, 0, 0, 0.0),
new TimeSpan(0, 0, 10, 0, 0, 0.0),
new TimeSpan(0, 1, 0, 0, 0, 0.0),
new TimeSpan(0, 3, 0, 0, 0, 0.0),
new TimeSpan(0, 6, 0, 0, 0, 0.0),
new TimeSpan(1, 0, 0, 0, 0, 0.0),
};
public TimeSpan timeStep = timeStepSpan[2]; // [1]; // see also choiceTimeStep.select(timeStepLabel[...]);
public int playDirection = ATime.F_INCTIME;
/**
* Centered Object
*/
static final int CenterObjectCount = 11;
static final String CenterObjectLabel[] = {
"Sun", "Asteroid/Comet", "Mercury", "Venus", "Earth",
"Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"
};
public int CenterObjectSelected = 0;
public int CometTooFar = 0;
public Xyz bogusCenter = new Xyz(0., 0., 0.);
public Xyz lastKnownCenter = bogusCenter;
/**
* Orbits Displayed
*/
static final int OrbitDisplayCount = 14;
static final String OrbitDisplayLabel[] = {
"Default Orbits", "All Planetary Orbits", "No Orbits", "------",
"Asteroid/Comet", "Mercury", "Venus", "Earth",
"Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"
};
public int OrbitCount = 11;
public boolean OrbitDisplay[] = {false, true, true, true, true, true, true,
false, false, false, false };
public boolean OrbitDisplayDefault[] = {false, true, true, true, true, true, true,
false, false, false, false };
/**
* Primary Object
*/
// public int PrimaryObjectCount = nClones;
// public String PrimaryObjectLabel[];
public int PrimaryObjectSelected = 0;
public int PrimaryObjectPrevious = 0;
public int[] cloneHash = new int[nClonesMax];
/**
* Limit of ATime
*/
// private ATime minATime = new ATime(-30000,1,1,0,0,0.0,0.0);
private ATime minATime = new ATime( 1600,1,1,0,0,0.0,0.0);
private ATime maxATime = new ATime( 2200,1,1,0,0,0.0,0.0);
/**
* Initial Settings
*/
static final int factorA = 100000; // (awp)
static final int factorE = 100000; // (awp)
static final int factorIncl = 10000; // (awp)
static final int factorNode = 10000; // (awp)
static final int factorPeri = 10000; // (awp)
static final int factorM = 10000; // (awp)
DecimalFormat aeFormat = new DecimalFormat("##0.00000"); // (awp)
DecimalFormat degFormat = new DecimalFormat("##0.0000"); // (awp)
static final int initialScrollVert = 90+40;
static final int initialScrollHorz = 255;
// static final int initialScrollZoom = 67;
static private final int intExtraZoom = 20; // see extraZoom in OrbitCanvas
public int initialScrollZoom = 67*intExtraZoom;
static final int fontSize = 12; // 16;
static final int textFieldFontSize = 10;
/**
* Scroll Increment Settings (awp)
*/
static final double blockA = 0.10; // AU
static final double unitA = 0.01; //
static final double blockE = 0.010; // unitless
static final double unitE = 0.001; //
static final double blockIncl = 1.0; // deg
static final double unitIncl = 0.1; //
static final double blockNode = 1.0; // deg
static final double unitNode = 0.1; //
static final double blockPeri = 1.0; // deg
static final double unitPeri = 0.1; //
static final double blockM = 1.0; // deg
static final double unitM = 0.1; //
static final double blockFineA = 0.00010; // AU
static final double unitFineA = 0.00001; //
static final double blockFineE = 0.00010; // unitless
static final double unitFineE = 0.00001; //
static final double blockFineIncl = 0.010; // deg
static final double unitFineIncl = 0.001; //
static final double blockFineNode = 0.010; // deg
static final double unitFineNode = 0.001; //
static final double blockFinePeri = 0.010; // deg
static final double unitFinePeri = 0.001; //
static final double blockFineM = 0.0010; // deg
static final double unitFineM = 0.0001; //
/**
* Applet information
*/
public String getAppletInfo() {
return "OrbitMaster v1.0 Copyright(C) 2010 by A.W.Puckett,"+newline+
" based on OrbitViewer v1.3 (C) 1996-2001 by O.Ajiki/R.Baalke";
}
/**
* Parameter Information
*/
public String[][] getParameterInfo() {
String info[][] = {
{ "Name", "String", "Name of the object ex. 1P/Halley" },
{ "T", "double", "Time of perihelion passage ex. 19860209.7695" },
{ "e", "double", "Eccentricity ex. 0.967267" },
{ "q", "double", "Perihelion distance AU ex. 0.587096" },
{ "Peri", "double", "Argument of perihelion deg. ex. 111.8466" },
{ "Node", "double", "Ascending node deg. ex. 58.1440" },
{ "Incl", "double", "Inclination deg. ex. 162.2393" },
{ "Eqnx", "double", "Year of equinox ex. 1950.0" },
{ "Epoch", "double", "Year/Month/Day of epoch ex. 19991118.5" },
{ "M", "double", "Mean anomaly deg. ex. 356.648434" },
{ "a", "double", "Semimajor axis AU ex. 2.76631592" },
{ "Date", "double", "Initial date ex. 19860209.7695" },
};
return info;
}
/**
* Convert time in format "YYYYMMDD.D" to ATime
*/
private ATime ymdStringToAtime(String strYmd) {
double fYmd = Double.valueOf(strYmd).doubleValue();
int nYear = (int)Math.floor(fYmd / 10000.0);
fYmd -= (double)nYear * 10000.0;
int nMonth = (int)Math.floor(fYmd / 100.0);
double fDay = fYmd - (double)nMonth * 100.0;
return new ATime(nYear, nMonth, fDay, 0.0);
}
/**
* Get required double parameter
*/
private double getRequiredParameter(String strName) {
String strValue = getParameter(strName);
if (strValue == null) {
throw new Error("Required parameter '"
+ strName + "' not found.");
}
return Double.valueOf(strValue).doubleValue();
}
/**
* Get orbital parameters of the object from applet parameter [read / parse]
*/
private Comet getObject(int cloneNum) {
String prefix = "";
if (cloneNum > 0) {
prefix = cloneNum+prefix+"-";
// System.out.println("Reading Clone #"+prefix);
} else {
// System.out.println("Reading primary orbit");
}
// System.out.println("Reading applet params");
String strName = getParameter(prefix+"Name");
if (strName == null) {
strName = "Object";
}
double e, q;
ATime T;
String strParam;
if ((strParam = getParameter(prefix+"e")) == null) {
throw new Error("required parameter 'e' not found.");
}
e = Double.valueOf(strParam).doubleValue();
if ((strParam = getParameter(prefix+"T")) != null) {
T = ymdStringToAtime(strParam);
if ((strParam = getParameter(prefix+"q")) != null) {
q = Double.valueOf(strParam).doubleValue();
} else if ((strParam = getParameter(prefix+"a")) != null) {
double a = Double.valueOf(strParam).doubleValue();
if (Math.abs(e - 1.0) < 1.0e-15) {
throw new Error("Orbit is parabolic, but 'q' not found.");
}
q = a * (1.0 - e);
} else {
throw new Error("Required parameter 'q' or 'a' not found.");
}
} else if ((strParam = getParameter(prefix+"Epoch")) != null) {
ATime Epoch = ymdStringToAtime(strParam);
if (e > 0.95) {
throw new
Error("Orbit is nearly parabolic, but 'T' not found.");
}
double a;
if ((strParam = getParameter(prefix+"a")) != null) {
a = Double.valueOf(strParam).doubleValue();
q = a * (1.0 - e);
} else if ((strParam = getParameter(prefix+"q")) != null) {
q = Double.valueOf(strParam).doubleValue();
a = q / (1.0 - e);
} else {
throw new Error("Required parameter 'q' or 'a' not found.");
}
if (q < 1.0e-15) {
throw new Error("Too small perihelion distance.");
}
double n = Astro.GAUSS / (a * Math.sqrt(a));
if ((strParam = getParameter(prefix+"M")) == null) {
throw new Error("Required parameter 'M' not found.");
}
double M = Double.valueOf(strParam).doubleValue() * Math.PI / 180.0;
if (M < Math.PI) {
T = new ATime(Epoch.getJd() - M / n, 0.0);
} else {
T = new ATime(Epoch.getJd() + (Math.PI*2.0 - M) / n, 0.0);
}
} else {
throw new Error("Required parameter 'T' or 'Epoch' not found.");
}
// System.out.println("1 initialScrollZoom = "+initialScrollZoom);
// initialScrollZoom = Math.min((int)Math.round(200./(q/(1.0 - e)))*intExtraZoom, initialScrollZoom);
initialScrollZoom = Math.min((int)Math.ceil(200./(q/(1.0 - e)))*intExtraZoom, initialScrollZoom);
// System.out.println("2 initialScrollZoom = "+initialScrollZoom);
return new Comet(strName, T.getJd(), e, q,
getRequiredParameter(prefix+"Peri")*Math.PI/180.0,
getRequiredParameter(prefix+"Node")*Math.PI/180.0,
getRequiredParameter(prefix+"Incl")*Math.PI/180.0,
getRequiredParameter(prefix+"Eqnx"));
}
/**
* Get observation points (x,y,z) from applet parameter [read / parse]
*/
private Xyz[] getObs() {
// System.out.println("Reading applet params (xyz obs)");
String strObs = getParameter("xyz");
if (strObs != null) {
// System.out.println("all obs: "+strObs);
String[] strArr;
String[] strArr1 = strObs.split(": *");
int numObs = strArr1.length;
// System.out.println("#obs = "+numObs);
Xyz[] xyzObs = new Xyz[numObs];
String[] nameObs = new String[numObs];
for (int i=0; i<numObs; i++) {
strArr = strArr1[i].trim().split(" +");
xyzObs[i] = new Xyz(Double.valueOf(strArr[0]),
Double.valueOf(strArr[1]),
Double.valueOf(strArr[2]));
// System.out.println("strArr.length = "+strArr.length);
if (strArr.length > 3) {
nameObs[i] = strArr[3];
} else {
nameObs[i] = "";
}
// System.out.println("obs name = "+nameObs[i]);
}
this.nameObs = nameObs;
return xyzObs;
} else {
return null;
}
}
/**
* Limit ATime between minATime and maxATime
*/
private ATime limitATime(ATime atime) {
if (atime.getJd() <= minATime.getJd()) {
return new ATime(minATime);
} else if (maxATime.getJd() <= atime.getJd()) {
return new ATime(maxATime);
}
return atime;
}
/**
* Set date and redraw canvas
*/
private void setNewDate() { // Used for single time-steps
this.atime = limitATime(this.atime);
orbitCanvas.setDate(this.atime);
orbitCanvas.repaint();
}
/**
* OrbitPlayer interface
*/
public ATime getAtime() {
return atime;
}
public void setNewDate(ATime atime) { // Used for continuous animation
this.atime = limitATime(atime);
orbitCanvas.setDate(this.atime);
orbitCanvas.repaint();
}
/**
* Initialization of applet
*/
public void init() {
this.setBackground(Color.white);
//*********************************************************************
// Main Panel
//*********************************************************************
// Panel mainPanel = new Panel();
mainPanel = new Panel();
GridBagLayout gblMainPanel = new GridBagLayout();
GridBagConstraints gbcMainPanel = new GridBagConstraints();
gbcMainPanel.fill = GridBagConstraints.BOTH;
mainPanel.setLayout(gblMainPanel);
// Orbit Canvas
object = getObject(0); // INIT ORBIT PARAMS ARE READ-IN HERE.
// About cloneHash[]:
//-------------------
// spits out clone[] indices: -1=obj, 0=zerothClone, etc
// cloneHash[] indices are positions on choicePrimary list
cloneHash[0] = -1; // initially cloneHash[1]=0, cloneHash[2]=1, etc...
String strValue = getParameter("nClones");
if (strValue != null) {
nClonesPreload = Integer.parseInt(strValue);
// System.out.println("Preloading "+nClonesPreload+" clones");
if (nClones != 0) {
throw new Error("nClones="+nClones+", nonzero when reading applet params! Why?");
}
for (int i=0; i<nClonesPreload; i++) {
// System.out.println("i="+i+"; nClones="+nClones);
clone[nClones] = getObject(nClones+1);
cloneHash[i+1] = nClones; // e.g., cloneHash[1] = 0
nClones++;
}
// System.out.println("End: nClones="+nClones);
}
xyzObs = getObs();
String strParam;
if ((strParam = getParameter("Date")) != null) {
this.atime = ymdStringToAtime(strParam);
} else {
Date date = new Date();
this.atime = new ATime(date.getYear() + 1900, date.getMonth() + 1,
(double)date.getDate(), 0.0);
}
orbitCanvas = new OrbitCanvas(object, this.atime, this, xyzObs, this.nameObs);
gbcMainPanel.weightx = 1.0;
gbcMainPanel.weighty = 1.0;
gbcMainPanel.gridwidth = GridBagConstraints.RELATIVE;
gblMainPanel.setConstraints(orbitCanvas, gbcMainPanel);
mainPanel.add(orbitCanvas);
// Vertical Scrollbar
scrollVert = new Scrollbar(Scrollbar.VERTICAL,
initialScrollVert, 12, 0, 180+12);
gbcMainPanel.weightx = 0.0;
gbcMainPanel.weighty = 0.0;
gbcMainPanel.gridwidth = GridBagConstraints.REMAINDER;
gblMainPanel.setConstraints(scrollVert, gbcMainPanel);
mainPanel.add(scrollVert);
orbitCanvas.setRotateVert(180 - scrollVert.getValue());
// Horizontal Scrollbar
scrollHorz = new Scrollbar(Scrollbar.HORIZONTAL,
initialScrollHorz, 15, 0, 360+15);
gbcMainPanel.weightx = 1.0;
gbcMainPanel.weighty = 0.0;
gbcMainPanel.gridwidth = 1;
gblMainPanel.setConstraints(scrollHorz, gbcMainPanel);
mainPanel.add(scrollHorz);
// Initializes the scrollbar? (Event Handler is below...)
orbitCanvas.setRotateHorz(270 - scrollHorz.getValue());
// Right-Bottom Corner Rectangle
Panel cornerPanel = new Panel();
gbcMainPanel.weightx = 0.0;
gbcMainPanel.weighty = 0.0;
gbcMainPanel.gridwidth = GridBagConstraints.REMAINDER;
gblMainPanel.setConstraints(cornerPanel, gbcMainPanel);
mainPanel.add(cornerPanel);
//*********************************************************************
// Control Panel
//*********************************************************************
Panel ctrlPanel = new Panel();
GridBagLayout gblCtrlPanel = new GridBagLayout();
GridBagConstraints gbcCtrlPanel = new GridBagConstraints();
gbcCtrlPanel.fill = GridBagConstraints.BOTH;
ctrlPanel.setLayout(gblCtrlPanel);
ctrlPanel.setBackground(myPaleGray); //white);
// Set Date Button
buttonDate = new Button(" Date ");
buttonDate.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 4; //compacting 0;
gbcCtrlPanel.gridy = 1; //compacting 0;
gbcCtrlPanel.weightx = 1.0; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 2; // 1; //compacting 2;
// gbcCtrlPanel.insets = new Insets(2, 0, 2, 12); // TLBR
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(buttonDate, gbcCtrlPanel);
ctrlPanel.add(buttonDate);
// Reverse-Play Button
buttonRevPlay = new Button("<<");
buttonRevPlay.setFont(new Font("Dialog", Font.BOLD, fontSize-2));
gbcCtrlPanel.gridx = 0;
gbcCtrlPanel.gridy = 0;
gbcCtrlPanel.weightx = 1.0; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(buttonRevPlay, gbcCtrlPanel);
ctrlPanel.add(buttonRevPlay);
// Reverse-Step Button
buttonRevStep = new Button("|<");
buttonRevStep.setFont(new Font("Dialog", Font.BOLD, fontSize-2));
gbcCtrlPanel.gridx = 1;
gbcCtrlPanel.gridy = 0;
gbcCtrlPanel.weightx = 1.0; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(buttonRevStep, gbcCtrlPanel);
ctrlPanel.add(buttonRevStep);
// Stop Button
buttonStop = new Button("||");
buttonStop.setFont(new Font("Dialog", Font.BOLD, fontSize-2));
gbcCtrlPanel.gridx = 2;
gbcCtrlPanel.gridy = 0;
gbcCtrlPanel.weightx = 1.0; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(buttonStop, gbcCtrlPanel);
ctrlPanel.add(buttonStop);
// Step Button
buttonForStep = new Button(">|");
buttonForStep.setFont(new Font("Dialog", Font.BOLD, fontSize-2));
gbcCtrlPanel.gridx = 3;
gbcCtrlPanel.gridy = 0;
gbcCtrlPanel.weightx = 1.0; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(buttonForStep, gbcCtrlPanel);
ctrlPanel.add(buttonForStep);
// Play Button
buttonForPlay = new Button(">>");
buttonForPlay.setFont(new Font("Dialog", Font.BOLD, fontSize-2));
gbcCtrlPanel.gridx = 4;
gbcCtrlPanel.gridy = 0;
gbcCtrlPanel.weightx = 1.0; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(buttonForPlay, gbcCtrlPanel);
ctrlPanel.add(buttonForPlay);
// Step choice Label
Label stepLabel = new Label("Time Step: ");
stepLabel.setAlignment(Label.RIGHT); // .LEFT);
stepLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 0;
gbcCtrlPanel.gridy = 1;
gbcCtrlPanel.weightx = 0.01; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(stepLabel, gbcCtrlPanel);
ctrlPanel.add(stepLabel);
// Step choice box
choiceTimeStep = new Choice();
choiceTimeStep.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 1; //compacting 1;
gbcCtrlPanel.gridy = 1;
gbcCtrlPanel.weightx = 1.0; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 3; //compacting 5;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(choiceTimeStep, gbcCtrlPanel);
ctrlPanel.add(choiceTimeStep);
for (int i = 0; i < timeStepCount; i++) {
choiceTimeStep.addItem(timeStepLabel[i]);
choiceTimeStep.select(timeStepLabel[2]); // [1]); // see also timeStep = timeStepSpan[...];
}
// Center Object Label
Label centerLabel = new Label("Center: ");
centerLabel.setAlignment(Label.RIGHT); // .LEFT);
centerLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 0;
gbcCtrlPanel.gridy = 2;
gbcCtrlPanel.weightx = 0.01; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(centerLabel, gbcCtrlPanel);
ctrlPanel.add(centerLabel);
// Center Object choice box
choiceCenterObject = new Choice();
choiceCenterObject.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 1;
gbcCtrlPanel.gridy = 2;
gbcCtrlPanel.weightx = 0.01; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 3; //compacting 5;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(choiceCenterObject, gbcCtrlPanel);
ctrlPanel.add(choiceCenterObject);
for (int i = 0; i < CenterObjectCount; i++) {
choiceCenterObject.addItem(CenterObjectLabel[i]);
}
orbitCanvas.SelectCenterObject(0);
// Display Orbits Label
Label orbitLabel = new Label("Orbits: ");
orbitLabel.setAlignment(Label.RIGHT); // .LEFT);
orbitLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 0;
gbcCtrlPanel.gridy = 3;
gbcCtrlPanel.weightx = 0.01; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(orbitLabel, gbcCtrlPanel);
ctrlPanel.add(orbitLabel);
// Display Orbit choice box
choiceOrbitObject = new Choice();
choiceOrbitObject.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 1;
gbcCtrlPanel.gridy = 3;
gbcCtrlPanel.weightx = 0.01; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 3; //compacting 5;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(choiceOrbitObject, gbcCtrlPanel);
ctrlPanel.add(choiceOrbitObject);
for (int i = 0; i < OrbitDisplayCount; i++) {
choiceOrbitObject.addItem(OrbitDisplayLabel[i]);
}
for (int i = 0; i < OrbitCount; i++) {
OrbitDisplay[i] = OrbitDisplayDefault[i];
}
orbitCanvas.SelectOrbits(OrbitDisplay, OrbitCount);
// Display Primary Label
Label primaryLabel = new Label("Primary: ");
primaryLabel.setAlignment(Label.RIGHT); // .LEFT);
primaryLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 0;
gbcCtrlPanel.gridy = 4;
gbcCtrlPanel.weightx = 0.01; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(primaryLabel, gbcCtrlPanel);
ctrlPanel.add(primaryLabel);
// Display Primary choice box
choicePrimaryObject = new Choice();
choicePrimaryObject.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 1;
gbcCtrlPanel.gridy = 4;
gbcCtrlPanel.weightx = 0.01; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 3; //compacting 5;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(choicePrimaryObject, gbcCtrlPanel);
ctrlPanel.add(choicePrimaryObject);
choicePrimaryObject.addItem(object.getName());
for (int i = 0; i < nClones; i++) {
choicePrimaryObject.addItem(clone[i].getName());
}
// orbitCanvas.SelectPrimaryObject(0);
// Display Labels Label
Label labelLabel = new Label("Labels: ");
labelLabel.setAlignment(Label.RIGHT); // .LEFT);
labelLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 0;
gbcCtrlPanel.gridy = 5;
gbcCtrlPanel.weightx = 0.01; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(labelLabel, gbcCtrlPanel);
ctrlPanel.add(labelLabel);
// Date Label Checkbox
/* checkDateLabel = new Checkbox("Date"); // Label");
checkDateLabel.setState(true);
checkDateLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 1; //compacting 2; //fiddling 0; // 6;
gbcCtrlPanel.gridy = 4; // 0;
gbcCtrlPanel.weightx = 1.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1; //was 2
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(2, 9, 0, 0); // TLBR
gblCtrlPanel.setConstraints(checkDateLabel, gbcCtrlPanel);
ctrlPanel.add(checkDateLabel);
orbitCanvas.switchDateLabel(checkDateLabel.getState());
*/
// Info (Distance) Label Checkbox
checkDistanceLabel = new Checkbox("Info");
checkDistanceLabel.setState(true);
checkDistanceLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 1; //compacting 2; //fiddling 0; // 6;
gbcCtrlPanel.gridy = 5; // 1;
gbcCtrlPanel.weightx = 1.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1; //was 2
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(0, 9, 2, 0); // TLBR
gblCtrlPanel.setConstraints(checkDistanceLabel, gbcCtrlPanel);
ctrlPanel.add(checkDistanceLabel);
orbitCanvas.switchDistanceLabel(checkDistanceLabel.getState());
orbitCanvas.switchDateLabel(checkDistanceLabel.getState());
// Object Name Checkbox
checkObjectName = new Checkbox("Object");
checkObjectName.setState(true);
checkObjectName.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 3;
gbcCtrlPanel.gridy = 5;
gbcCtrlPanel.weightx = 1.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1; //was 2
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(0, 9, 2, 0); // TLBR
gblCtrlPanel.setConstraints(checkObjectName, gbcCtrlPanel);
ctrlPanel.add(checkObjectName);
orbitCanvas.switchObjectName(checkObjectName.getState());
// Clones/Peers Name Checkbox
// checkCloneName = new Checkbox("Clones/Peers");
String initPeers = getParameter("Peers");
if (initPeers == null) {
initPeers = "False";
}
if (initPeers.equals("True") || initPeers.equals("TRUE") || initPeers.equals("T") || initPeers.equals("t") ||
initPeers.equals("Yes") || initPeers.equals("YES") || initPeers.equals("Y") || initPeers.equals("y")) {
checkCloneName = new Checkbox("Peers");
checkCloneName.setState(true);
} else {
checkCloneName = new Checkbox("Clones");
checkCloneName.setState(false);
}
checkCloneName.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 4;
gbcCtrlPanel.gridy = 5;
gbcCtrlPanel.weightx = 1.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(0, 9, 2, 0); // TLBR
gblCtrlPanel.setConstraints(checkCloneName, gbcCtrlPanel);
ctrlPanel.add(checkCloneName);
orbitCanvas.switchCloneName(checkCloneName.getState());
// Planet Name Checkbox
checkPlanetName = new Checkbox("Planets");
checkPlanetName.setState(true);
checkPlanetName.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 2; //compacting 4; //fiddling 3; // 7;
gbcCtrlPanel.gridy = 5; // 0;
gbcCtrlPanel.weightx = 1.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1; //was 2
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(0, 9, 2, 0); // TLBR
gblCtrlPanel.setConstraints(checkPlanetName, gbcCtrlPanel);
ctrlPanel.add(checkPlanetName);
orbitCanvas.switchPlanetName(checkPlanetName.getState());
// Measurement Button
buttonMeasure = new Button("Measure");
buttonMeasure.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 4;
gbcCtrlPanel.gridy = 3;
gbcCtrlPanel.weightx = 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 2;
gbcCtrlPanel.insets = new Insets(2, 0, 2, 0); // TLBR
gblCtrlPanel.setConstraints(buttonMeasure, gbcCtrlPanel);
ctrlPanel.add(buttonMeasure);
buttonMeasure.setEnabled(false);
// Zoom Label
Label zoomLabel = new Label("Zoom: ");
zoomLabel.setAlignment(Label.RIGHT); //fiddling .LEFT);
zoomLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcCtrlPanel.gridx = 0; // 6;
gbcCtrlPanel.gridy = 6; // 2;
gbcCtrlPanel.weightx = 1.0; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1; // 2;
gbcCtrlPanel.gridheight = 1;
// gbcCtrlPanel.insets = new Insets(2, 0, 0, 0); // TLBR
gbcCtrlPanel.insets = new Insets(4, 0, 0, 0); // TLBR
gblCtrlPanel.setConstraints(zoomLabel, gbcCtrlPanel);
ctrlPanel.add(zoomLabel);
// Zoom Scrollbar (orient, init value, visible, min, max)
scrollZoom = new Scrollbar(Scrollbar.HORIZONTAL,
initialScrollZoom, 15*intExtraZoom, 1, 450*intExtraZoom); // 5, 450);
gbcCtrlPanel.gridx = 1;
gbcCtrlPanel.gridy = 6;
gbcCtrlPanel.weightx = 1.0; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 3; // 5;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(4, 5, 6, 5); // (4, 0, 6, 0); // TLBR
gblCtrlPanel.setConstraints(scrollZoom, gbcCtrlPanel);
ctrlPanel.add(scrollZoom);
orbitCanvas.setZoom(scrollZoom.getValue());
// Zoom Textfield (awp)
textZoom = new TextField(""+initialScrollZoom); //scrollZoom.getValue());
textZoom.setFont(new Font("Dialog", Font.PLAIN, textFieldFontSize));
textZoom.addKeyListener( new IntegerKeyListener(textZoom) );
textZoom.addTextListener( new TextListener() {
public void textValueChanged(TextEvent e) {
if (textZoom.isFocusOwner()) { // Do nothing when Scroll changes Text
int newZoomText;
if (textZoom.getText().length() == 0) {
newZoomText = 1;
} else if (Integer.valueOf(textZoom.getText()) < 1) {
newZoomText = 1;
textZoom.setText(""+newZoomText);
} else {
newZoomText = Integer.valueOf(textZoom.getText());
}
orbitCanvas.setZoom(newZoomText);
scrollZoom.setValue(newZoomText);
orbitCanvas.repaint();
}
}
});
gbcCtrlPanel.gridx = 4;
gbcCtrlPanel.gridy = 6;
gbcCtrlPanel.weightx = 1.0; //fiddling 0.0;
gbcCtrlPanel.weighty = 0.0;
gbcCtrlPanel.gridwidth = 1;
gbcCtrlPanel.gridheight = 1;
gbcCtrlPanel.insets = new Insets(3, 3, 4, 5); // 1); // TLBR
gblCtrlPanel.setConstraints(textZoom, gbcCtrlPanel);
ctrlPanel.add(textZoom);
//*********************************************************************
// Elements Panel
//*********************************************************************
Panel eltsPanel = new Panel();
GridBagLayout gblEltsPanel = new GridBagLayout();
GridBagConstraints gbcEltsPanel = new GridBagConstraints();
gbcEltsPanel.fill = GridBagConstraints.HORIZONTAL; //BOTH;
eltsPanel.setLayout(gblEltsPanel);
eltsPanel.setBackground(myPaleGray); //white);
// Elements Label (awp)
Label eltsLabel = new Label("Orbital Parameters:");
eltsLabel.setAlignment(Label.LEFT);
eltsLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcEltsPanel.gridx = 0;
gbcEltsPanel.gridy = 0;
gbcEltsPanel.weightx = 0.0;
gbcEltsPanel.weighty = 1.0;
gbcEltsPanel.gridwidth = 1;
gbcEltsPanel.gridheight = 1;
gbcEltsPanel.insets = new Insets(6, 10, 0, 0); // TLBR
gblEltsPanel.setConstraints(eltsLabel, gbcEltsPanel);
eltsPanel.add(eltsLabel);
// Clone Button (awp)
buttonClone = new Button("Clone");
buttonClone.setFont(new Font("Dialog", Font.PLAIN, fontSize-2));
gbcEltsPanel.fill = GridBagConstraints.NONE; //BOTH;
gbcEltsPanel.anchor = GridBagConstraints.WEST;
gbcEltsPanel.gridx = 1;
gbcEltsPanel.gridy = 0;
gbcEltsPanel.weightx = 0.0;
gbcEltsPanel.weighty = 1.0;
gbcEltsPanel.gridwidth = 1;
gbcEltsPanel.gridheight = 1;
gbcEltsPanel.insets = new Insets(3, 5, 0, 5); // TLBR
gblEltsPanel.setConstraints(buttonClone, gbcEltsPanel);
eltsPanel.add(buttonClone);
if (nClonesPreload == 0) { // If clones were preloaded, then don't allow user to create more!
buttonClone.setEnabled(true);
} else {
buttonClone.setEnabled(false);
}
// buttonClone.setEnabled(false);
// Fine Control Checkbox
checkFineControl = new Checkbox("Fine"); //fiddling Control");
checkFineControl.setState(false);
checkFineControl.setFont(new Font("Dialog", Font.PLAIN, fontSize));
gbcEltsPanel.fill = GridBagConstraints.NONE; //BOTH;
gbcEltsPanel.anchor = GridBagConstraints.WEST;
gbcEltsPanel.gridx = 3;
gbcEltsPanel.gridy = 0;
gbcEltsPanel.weightx = 0.0; //fiddling??
gbcEltsPanel.weighty = 0.0;