]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/distance/GenericTableModel.java
Version 7, February 2009
[GpsPrune.git] / tim / prune / function / distance / GenericTableModel.java
1 package tim.prune.function.distance;
2
3 import java.util.ArrayList;
4
5 import javax.swing.table.AbstractTableModel;
6
7 import tim.prune.I18nManager;
8 import tim.prune.data.DataPoint;
9
10 /**
11  * General table model class for the two models in the distance function
12  */
13 public abstract class GenericTableModel extends AbstractTableModel
14 {
15         /** list of points */
16         protected ArrayList<DataPoint> _pointList = null;
17         /** Column heading */
18         private static String _currPointLabel = I18nManager.getText("dialog.distances.currentpoint");
19
20         /**
21          * Initialize the table model with the point list
22          * @param inPointList list of points
23          */
24         public void init(ArrayList<DataPoint> inPointList)
25         {
26                 _pointList = inPointList;
27         }
28
29         /**
30          * @return row count
31          */
32         public int getRowCount()
33         {
34                 if (_pointList == null) {return 0;}
35                 return _pointList.size();
36         }
37
38         /**
39          * Get the name of the specified point from the list
40          * @param inIndex index of point
41          * @return waypoint name if waypoint, otherwise "current point"
42          */
43         protected String getPointName(int inIndex)
44         {
45                 if (_pointList == null) {return "null";}
46                 DataPoint point = _pointList.get(inIndex);
47                 if (point.isWaypoint()) {return point.getWaypointName();}
48                 return _currPointLabel;
49         }
50 }