]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/threedee/Java3DWindow.java
0bde564c373fe45199aca872bdbcf49f18cf97de
[GpsPrune.git] / tim / prune / threedee / Java3DWindow.java
1 package tim.prune.threedee;
2
3 import java.awt.FlowLayout;
4 import java.awt.BorderLayout;
5 import java.awt.Font;
6 import java.awt.GraphicsConfiguration;
7 import java.awt.GraphicsEnvironment;
8 import java.awt.event.ActionEvent;
9 import java.awt.event.ActionListener;
10 import java.awt.event.WindowAdapter;
11 import java.awt.event.WindowEvent;
12 import java.awt.geom.GeneralPath;
13
14 import javax.media.j3d.AmbientLight;
15 import javax.media.j3d.Appearance;
16 import javax.media.j3d.BoundingSphere;
17 import javax.media.j3d.BranchGroup;
18 import javax.media.j3d.Canvas3D;
19 import javax.media.j3d.Font3D;
20 import javax.media.j3d.FontExtrusion;
21 import javax.media.j3d.GraphicsConfigTemplate3D;
22 import javax.media.j3d.Group;
23 import javax.media.j3d.Material;
24 import javax.media.j3d.PointLight;
25 import javax.media.j3d.Shape3D;
26 import javax.media.j3d.Text3D;
27 import javax.media.j3d.Transform3D;
28 import javax.media.j3d.TransformGroup;
29 import javax.swing.JButton;
30 import javax.swing.JFrame;
31 import javax.swing.JOptionPane;
32 import javax.swing.JPanel;
33 import javax.vecmath.Color3f;
34 import javax.vecmath.Matrix3d;
35 import javax.vecmath.Point3d;
36 import javax.vecmath.Point3f;
37 import javax.vecmath.Vector3d;
38
39 import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
40 import com.sun.j3d.utils.geometry.Box;
41 import com.sun.j3d.utils.geometry.Cylinder;
42 import com.sun.j3d.utils.geometry.Sphere;
43 import com.sun.j3d.utils.universe.SimpleUniverse;
44
45 import tim.prune.FunctionLibrary;
46 import tim.prune.I18nManager;
47 import tim.prune.data.Altitude;
48 import tim.prune.data.Track;
49
50
51 /**
52  * Class to hold main window for java3d view of data
53  */
54 public class Java3DWindow implements ThreeDWindow
55 {
56         private Track _track = null;
57         private JFrame _parentFrame = null;
58         private JFrame _frame = null;
59         private ThreeDModel _model = null;
60         private OrbitBehavior _orbit = null;
61         private int _altitudeCap = ThreeDModel.MINIMUM_ALTITUDE_CAP;
62
63         /** only prompt about big track size once */
64         private static boolean TRACK_SIZE_WARNING_GIVEN = false;
65
66         // Constants
67         private static final double INITIAL_Y_ROTATION = -25.0;
68         private static final double INITIAL_X_ROTATION = 15.0;
69         private static final String CARDINALS_FONT = "Arial";
70         private static final int MAX_TRACK_SIZE = 2500; // threshold for warning
71
72
73         /**
74          * Constructor
75          * @param inFrame parent frame
76          */
77         public Java3DWindow(JFrame inFrame)
78         {
79                 _parentFrame = inFrame;
80         }
81
82
83         /**
84          * Set the track object
85          * @param inTrack Track object
86          */
87         public void setTrack(Track inTrack)
88         {
89                 _track = inTrack;
90         }
91
92
93         /**
94          * Show the window
95          */
96         public void show() throws ThreeDException
97         {
98                 // Get the altitude cap to use
99                 String altitudeUnits = getAltitudeUnitsLabel(_track);
100                 Object altCapString = JOptionPane.showInputDialog(_parentFrame,
101                         I18nManager.getText("dialog.3d.altitudecap") + " (" + altitudeUnits + ")",
102                         I18nManager.getText("dialog.3d.title"),
103                         JOptionPane.QUESTION_MESSAGE, null, null, "" + _altitudeCap);
104                 if (altCapString == null) return;
105                 try
106                 {
107                         _altitudeCap = Integer.parseInt(altCapString.toString());
108                 }
109                 catch (Exception e) {} // Ignore parse errors
110
111                 // Set up the graphics config
112                 GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
113                 if (config == null)
114                 {
115                         // Config shouldn't be null, but we can try to create a new one as a workaround
116                         GraphicsConfigTemplate3D gc = new GraphicsConfigTemplate3D();
117                         gc.setDepthSize(0);
118                         config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(gc);
119                 }
120
121                 if (config == null)
122                 {
123                         // Second attempt also failed, going to have to give up here.
124                         throw new ThreeDException("Couldn't create graphics config");
125                 }
126
127                 // Check number of points in model isn't too big, and suggest compression
128                 Object[] buttonTexts = {I18nManager.getText("button.continue"), I18nManager.getText("button.cancel")};
129                 if (_track.getNumPoints() > MAX_TRACK_SIZE && !TRACK_SIZE_WARNING_GIVEN)
130                 {
131                         if (JOptionPane.showOptionDialog(_frame,
132                                         I18nManager.getText("dialog.exportpov.warningtracksize"),
133                                         I18nManager.getText("function.exportpov"), JOptionPane.OK_CANCEL_OPTION,
134                                         JOptionPane.WARNING_MESSAGE, null, buttonTexts, buttonTexts[1])
135                                 == JOptionPane.OK_OPTION)
136                         {
137                                 // opted to continue, don't show warning again
138                                 TRACK_SIZE_WARNING_GIVEN = true;
139                         }
140                         else
141                         {
142                                 // opted to cancel - show warning again next time
143                                 return;
144                         }
145                 }
146
147                 Canvas3D canvas = new Canvas3D(config);
148                 canvas.setSize(400, 300);
149
150                 // Create the scene and attach it to the virtual universe
151                 BranchGroup scene = createSceneGraph();
152                 SimpleUniverse u = new SimpleUniverse(canvas);
153
154                 // This will move the ViewPlatform back a bit so the
155                 // objects in the scene can be viewed.
156                 u.getViewingPlatform().setNominalViewingTransform();
157
158                 // Add behaviour to rotate using mouse
159                 _orbit = new OrbitBehavior(canvas, OrbitBehavior.REVERSE_ALL |
160                                                                   OrbitBehavior.STOP_ZOOM);
161                 BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
162                 _orbit.setSchedulingBounds(bounds);
163                 u.getViewingPlatform().setViewPlatformBehavior(_orbit);
164                 u.addBranchGraph(scene);
165
166                 // Don't reuse _frame object from last time, because data and/or scale might be different
167                 // Need to regenerate everything
168                 _frame = new JFrame(I18nManager.getText("dialog.3d.title"));
169                 _frame.getContentPane().setLayout(new BorderLayout());
170                 _frame.getContentPane().add(canvas, BorderLayout.CENTER);
171                 _frame.setIconImage(_parentFrame.getIconImage());
172                 // Make panel for render, close buttons
173                 JPanel panel = new JPanel();
174                 panel.setLayout(new FlowLayout(FlowLayout.RIGHT));
175                 // Add callback button for render
176                 JButton renderButton = new JButton(I18nManager.getText("function.exportpov"));
177                 renderButton.addActionListener(new ActionListener()
178                 {
179                         /** Render button pressed */
180                         public void actionPerformed(ActionEvent e)
181                         {
182                                 if (_orbit != null)
183                                 {
184                                         callbackRender();
185                                 }
186                         }});
187                 panel.add(renderButton);
188                 // Display coordinates of lat/long lines of 3d graph in separate dialog
189                 JButton showLinesButton = new JButton(I18nManager.getText("button.showlines"));
190                 showLinesButton.addActionListener(new ActionListener() {
191                         public void actionPerformed(ActionEvent e)
192                         {
193                                 double[] latLines = _model.getLatitudeLines();
194                                 double[] lonLines = _model.getLongitudeLines();
195                                 LineDialog dialog = new LineDialog(_frame, latLines, lonLines);
196                                 dialog.showDialog();
197                         }
198                 });
199                 panel.add(showLinesButton);
200                 // Close button
201                 JButton closeButton = new JButton(I18nManager.getText("button.close"));
202                 closeButton.addActionListener(new ActionListener()
203                 {
204                         /** Close button pressed - clean up */
205                         public void actionPerformed(ActionEvent e)
206                         {
207                                 _frame.dispose();
208                                 _frame = null;
209                                 _orbit = null;
210                         }
211                 });
212                 panel.add(closeButton);
213                 _frame.getContentPane().add(panel, BorderLayout.SOUTH);
214                 _frame.setSize(500, 350);
215                 _frame.pack();
216                 // Add a listener to clean up when window closed
217                 _frame.addWindowListener(new WindowAdapter() {
218                         public void windowClosing(WindowEvent e)
219                         {
220                                 dispose();
221                         }
222                 });
223
224                 // show frame
225                 _frame.setVisible(true);
226                 if (_frame.getState() == JFrame.ICONIFIED)
227                 {
228                         _frame.setState(JFrame.NORMAL);
229                 }
230         }
231
232         /**
233          * Dispose of the frame and its resources
234          */
235         public void dispose()
236         {
237                 if (_frame != null) {
238                         _frame.dispose();
239                         _frame = null;
240                 }
241         }
242
243         /**
244          * Create the whole scenery from the given track
245          * @return all objects in the scene
246          */
247         private BranchGroup createSceneGraph()
248         {
249                 // Create the root of the branch graph
250                 BranchGroup objRoot = new BranchGroup();
251
252                 // Create the transform group node and initialize it.
253                 // Enable the TRANSFORM_WRITE capability so it can be spun by the mouse
254                 TransformGroup objTrans = new TransformGroup();
255                 objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
256
257                 // Create a translation
258                 Transform3D shiftz = new Transform3D();
259                 shiftz.setScale(0.055);
260                 TransformGroup shiftTrans = new TransformGroup(shiftz);
261
262                 objRoot.addChild(shiftTrans);
263                 Transform3D rotTrans = new Transform3D();
264                 rotTrans.rotY(Math.toRadians(INITIAL_Y_ROTATION));
265                 Transform3D rot2 = new Transform3D();
266                 rot2.rotX(Math.toRadians(INITIAL_X_ROTATION));
267                 TransformGroup tg2 = new TransformGroup(rot2);
268                 objTrans.setTransform(rotTrans);
269                 shiftTrans.addChild(tg2);
270                 tg2.addChild(objTrans);
271
272                 // Base plane
273                 Appearance planeAppearance = null;
274                 Box plane = null;
275                 planeAppearance = new Appearance();
276                 planeAppearance.setMaterial(new Material(new Color3f(0.1f, 0.2f, 0.2f),
277                  new Color3f(0.0f, 0.0f, 0.0f), new Color3f(0.3f, 0.4f, 0.4f),
278                  new Color3f(0.3f, 0.3f, 0.3f), 0.0f));
279                 plane = new Box(10f, 0.04f, 10f, planeAppearance);
280                 objTrans.addChild(plane);
281
282                 // N, S, E, W
283                 GeneralPath bevelPath = new GeneralPath();
284                 bevelPath.moveTo(0.0f, 0.0f);
285                 for (int i=0; i<91; i+= 5)
286                         bevelPath.lineTo((float) (0.1 - 0.1 * Math.cos(Math.toRadians(i))),
287                           (float) (0.1 * Math.sin(Math.toRadians(i))));
288                 for (int i=90; i>0; i-=5)
289                         bevelPath.lineTo((float) (0.3 + 0.1 * Math.cos(Math.toRadians(i))),
290                           (float) (0.1 * Math.sin(Math.toRadians(i))));
291                 Font3D compassFont = new Font3D(
292                         new Font(CARDINALS_FONT, Font.PLAIN, 1),
293                         new FontExtrusion(bevelPath));
294                 objTrans.addChild(createCompassPoint(I18nManager.getText("cardinal.n"), new Point3f(0f, 0f, -10f), compassFont));
295                 objTrans.addChild(createCompassPoint(I18nManager.getText("cardinal.s"), new Point3f(0f, 0f, 10f), compassFont));
296                 objTrans.addChild(createCompassPoint(I18nManager.getText("cardinal.w"), new Point3f(-11f, 0f, 0f), compassFont));
297                 objTrans.addChild(createCompassPoint(I18nManager.getText("cardinal.e"), new Point3f(10f, 0f, 0f), compassFont));
298
299                 // create and scale model
300                 _model = new ThreeDModel(_track);
301                 _model.setAltitudeCap(_altitudeCap);
302                 _model.scale();
303
304                 // Lat/Long lines
305                 objTrans.addChild(createLatLongs(_model));
306
307                 // Add points to model
308                 objTrans.addChild(createDataPoints(_model));
309
310                 // Create lights
311                 BoundingSphere bounds =
312                   new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
313                 AmbientLight aLgt = new AmbientLight(new Color3f(1.0f, 1.0f, 1.0f));
314                 aLgt.setInfluencingBounds(bounds);
315                 objTrans.addChild(aLgt);
316
317                 PointLight pLgt = new PointLight(new Color3f(1.0f, 1.0f, 1.0f),
318                  new Point3f(0f, 0f, 2f),
319                  new Point3f(0.25f, 0.05f, 0.0f) );
320                 pLgt.setInfluencingBounds(bounds);
321                 objTrans.addChild(pLgt);
322
323                 PointLight pl2 = new PointLight(new Color3f(0.8f, 0.9f, 0.4f),
324                  new Point3f(6f, 1f, 6f),
325                  new Point3f(0.2f, 0.1f, 0.05f) );
326                 pl2.setInfluencingBounds(bounds);
327                 objTrans.addChild(pl2);
328
329                 PointLight pl3 = new PointLight(new Color3f(0.7f, 0.7f, 0.7f),
330                  new Point3f(0.0f, 12f, -2f),
331                  new Point3f(0.1f, 0.1f, 0.0f) );
332                 pl3.setInfluencingBounds(bounds);
333                 objTrans.addChild(pl3);
334
335                 // Have Java 3D perform optimizations on this scene graph.
336                 objRoot.compile();
337
338                 return objRoot;
339         }
340
341
342         /**
343          * Create a text object for compass point, N S E or W
344          * @param text text to display
345          * @param locn position at which to display
346          * @param font 3d font to use
347          * @return Shape3D object
348          */
349         private Shape3D createCompassPoint(String inText, Point3f inLocn, Font3D inFont)
350         {
351                 Text3D txt = new Text3D(inFont, inText, inLocn, Text3D.ALIGN_FIRST, Text3D.PATH_RIGHT);
352                 Material mat = new Material(new Color3f(0.5f, 0.5f, 0.55f),
353                  new Color3f(0.05f, 0.05f, 0.1f), new Color3f(0.3f, 0.4f, 0.5f),
354                  new Color3f(0.4f, 0.5f, 0.7f), 70.0f);
355                 mat.setLightingEnable(true);
356                 Appearance app = new Appearance();
357                 app.setMaterial(mat);
358                 Shape3D shape = new Shape3D(txt, app);
359                 return shape;
360         }
361
362
363         /**
364          * Create all the latitude and longitude lines on the base plane
365          * @param inModel model containing data
366          * @return Group object containing cylinders for lat and long lines
367          */
368         private static Group createLatLongs(ThreeDModel inModel)
369         {
370                 Group group = new Group();
371                 int numlines = inModel.getLatitudeLines().length;
372                 for (int i=0; i<numlines; i++)
373                 {
374                         group.addChild(createLatLine(inModel.getScaledLatitudeLine(i), inModel.getModelSize()));
375                 }
376                 numlines = inModel.getLongitudeLines().length;
377                 for (int i=0; i<numlines; i++)
378                 {
379                         group.addChild(createLonLine(inModel.getScaledLongitudeLine(i), inModel.getModelSize()));
380                 }
381                 return group;
382         }
383
384
385         /**
386          * Make a single latitude line for the specified latitude
387          * @param inLatitude latitude in scaled units
388          * @param inSize size of model, for length of line
389          * @return Group object containing cylinder for latitude line
390          */
391         private static Group createLatLine(double inLatitude, double inSize)
392         {
393                 Cylinder latline = new Cylinder(0.1f, (float) (inSize*2));
394                 Transform3D horizShift = new Transform3D();
395                 horizShift.setTranslation(new Vector3d(0.0, 0.0, inLatitude));
396                 TransformGroup horizTrans = new TransformGroup(horizShift);
397                 Transform3D zRot = new Transform3D();
398                 zRot.rotZ(Math.toRadians(90.0));
399                 TransformGroup zTrans = new TransformGroup(zRot);
400                 horizTrans.addChild(zTrans);
401                 zTrans.addChild(latline);
402                 return horizTrans;
403         }
404
405
406         /**
407          * Make a single longitude line for the specified longitude
408          * @param inLongitude longitude in scaled units
409          * @param inSize size of model, for length of line
410          * @return Group object containing cylinder for longitude line
411          */
412         private static Group createLonLine(double inLongitude, double inSize)
413         {
414                 Cylinder lonline = new Cylinder(0.1f, (float) (inSize*2));
415                 Transform3D horizShift = new Transform3D();
416                 horizShift.setTranslation(new Vector3d(inLongitude, 0.0, 0.0));
417                 TransformGroup horizTrans = new TransformGroup(horizShift);
418                 Transform3D xRot = new Transform3D();
419                 xRot.rotX(Math.toRadians(90.0));
420                 TransformGroup xTrans = new TransformGroup(xRot);
421                 horizTrans.addChild(xTrans);
422                 xTrans.addChild(lonline);
423                 return horizTrans;
424         }
425
426
427         /**
428          * Make a Group of the data points to be added
429          * @param inModel model containing data
430          * @return Group object containing spheres, rods etc
431          */
432         private static Group createDataPoints(ThreeDModel inModel)
433         {
434                 // Add points to model
435                 Group group = new Group();
436                 int numPoints = inModel.getNumPoints();
437                 for (int i=0; i<numPoints; i++)
438                 {
439                         byte pointType = inModel.getPointType(i);
440                         if (pointType == ThreeDModel.POINT_TYPE_WAYPOINT)
441                         {
442                                 // Add waypoint
443                                 // Note that x, y and z are horiz, altitude, -vert
444                                 group.addChild(createWaypoint(new Point3d(
445                                         inModel.getScaledHorizValue(i), inModel.getScaledAltValue(i), -inModel.getScaledVertValue(i))));
446                         }
447                         else
448                         {
449                                 // Add colour-coded track point
450                                 // Note that x, y and z are horiz, altitude, -vert
451                                 group.addChild(createTrackpoint(new Point3d(
452                                         inModel.getScaledHorizValue(i), inModel.getScaledAltValue(i), -inModel.getScaledVertValue(i)),
453                                         inModel.getPointHeightCode(i)));
454                         }
455                 }
456                 return group;
457         }
458
459
460         /**
461          * Create a waypoint sphere
462          * @param inPointPos position of point
463          * @return Group object containing sphere
464          */
465         private static Group createWaypoint(Point3d inPointPos)
466         {
467                 Material mat = getWaypointMaterial();
468                 // MAYBE: sort symbol scaling
469                 Sphere dot = new Sphere(0.35f); // * symbolScaling / 100f);
470                 return createBall(inPointPos, dot, mat);
471         }
472
473
474         /**
475          * @return a new Material object to define waypoint colour / shine etc
476          */
477         private static Material getWaypointMaterial()
478         {
479                 return new Material(new Color3f(0.1f, 0.1f, 0.4f),
480                          new Color3f(0.0f, 0.0f, 0.0f), new Color3f(0.0f, 0.2f, 0.7f),
481                          new Color3f(1.0f, 0.6f, 0.6f), 40.0f);
482         }
483
484
485         private static Group createTrackpoint(Point3d inPointPos, byte inHeightCode)
486         {
487                 Material mat = getTrackpointMaterial(inHeightCode);
488                 // MAYBE: sort symbol scaling
489                 Sphere dot = new Sphere(0.2f); // * symbolScaling / 100f);
490                 return createBall(inPointPos, dot, mat);
491         }
492
493
494         private static Material getTrackpointMaterial(byte inHeightCode)
495         {
496                 // create default material
497                 Material mat = new Material(new Color3f(0.3f, 0.2f, 0.1f),
498                         new Color3f(0.0f, 0.0f, 0.0f), new Color3f(0.0f, 0.6f, 0.0f),
499                         new Color3f(1.0f, 0.6f, 0.6f), 70.0f);
500                 // change colour according to height code
501                 if (inHeightCode == 1) mat.setDiffuseColor(new Color3f(0.4f, 0.9f, 0.2f));
502                 if (inHeightCode == 2) mat.setDiffuseColor(new Color3f(0.7f, 0.8f, 0.2f));
503                 if (inHeightCode == 3) mat.setDiffuseColor(new Color3f(0.5f, 0.85f, 0.95f));
504                 if (inHeightCode == 4) mat.setDiffuseColor(new Color3f(0.1f, 0.9f, 0.9f));
505                 if (inHeightCode >= 5) mat.setDiffuseColor(new Color3f(1.0f, 1.0f, 1.0f));
506                 // return object
507                 return mat;
508         }
509
510
511         /**
512          * Create a ball at the given point
513          * @param inPosition scaled position of point
514          * @param inSphere sphere object
515          * @param inMaterial material object
516          * @return Group containing sphere
517          */
518         private static Group createBall(Point3d inPosition, Sphere inSphere, Material inMaterial)
519         {
520                 Group group = new Group();
521                 // Create ball and add to group
522                 Transform3D ballShift = new Transform3D();
523                 ballShift.setTranslation(new Vector3d(inPosition));
524                 TransformGroup ballShiftTrans = new TransformGroup(ballShift);
525                 inMaterial.setLightingEnable(true);
526                 Appearance ballApp = new Appearance();
527                 ballApp.setMaterial(inMaterial);
528                 inSphere.setAppearance(ballApp);
529                 ballShiftTrans.addChild(inSphere);
530                 group.addChild(ballShiftTrans);
531                 // Also create rod for ball to sit on
532                 Cylinder rod = new Cylinder(0.1f, (float) inPosition.y);
533                 Material rodMat = new Material(new Color3f(0.2f, 0.2f, 0.2f),
534                  new Color3f(0.0f, 0.0f, 0.0f), new Color3f(0.2f, 0.2f, 0.2f),
535                  new Color3f(0.05f, 0.05f, 0.05f), 0.4f);
536                 rodMat.setLightingEnable(true);
537                 Appearance rodApp = new Appearance();
538                 rodApp.setMaterial(rodMat);
539                 rod.setAppearance(rodApp);
540                 Transform3D rodShift = new Transform3D();
541                 rodShift.setTranslation(new Vector3d(inPosition.x,
542                  inPosition.y/2.0, inPosition.z));
543                 TransformGroup rodShiftTrans = new TransformGroup(rodShift);
544                 rodShiftTrans.addChild(rod);
545                 group.addChild(rodShiftTrans);
546                 // return the pair
547                 return group;
548         }
549
550
551         /**
552          * Calculate the angles and call them back to the app
553          */
554         private void callbackRender()
555         {
556                 Transform3D trans3d = new Transform3D();
557                 _orbit.getViewingPlatform().getViewPlatformTransform().getTransform(trans3d);
558                 Matrix3d matrix = new Matrix3d();
559                 trans3d.get(matrix);
560                 Point3d point = new Point3d(0.0, 0.0, 1.0);
561                 matrix.transform(point);
562                 // Set up initial rotations
563                 Transform3D firstTran = new Transform3D();
564                 firstTran.rotY(Math.toRadians(-INITIAL_Y_ROTATION));
565                 Transform3D secondTran = new Transform3D();
566                 secondTran.rotX(Math.toRadians(-INITIAL_X_ROTATION));
567                 // Apply inverse rotations in reverse order to test point
568                 Point3d result = new Point3d();
569                 secondTran.transform(point, result);
570                 firstTran.transform(result);
571                 // Callback settings to pov export function
572                 FunctionLibrary.FUNCTION_POVEXPORT.setCameraCoordinates(result.x, result.y, result.z);
573                 FunctionLibrary.FUNCTION_POVEXPORT.setAltitudeCap(_altitudeCap);
574                 FunctionLibrary.FUNCTION_POVEXPORT.begin();
575         }
576
577
578         /**
579          * Get a units label for the altitudes in the given Track
580          * @param inTrack Track object
581          * @return units label for altitude used in Track
582          */
583         private static String getAltitudeUnitsLabel(Track inTrack)
584         {
585                 Altitude.Format altitudeFormat = inTrack.getAltitudeRange().getFormat();
586                 if (altitudeFormat == Altitude.Format.METRES)
587                         return I18nManager.getText("units.metres.short");
588                 return I18nManager.getText("units.feet.short");
589         }
590
591 }