X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fdistance%2FGenericTableModel.java;fp=src%2Ftim%2Fprune%2Ffunction%2Fdistance%2FGenericTableModel.java;h=bc565409b70cd0cea61680781e009964f010141a;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/function/distance/GenericTableModel.java b/src/tim/prune/function/distance/GenericTableModel.java new file mode 100644 index 0000000..bc56540 --- /dev/null +++ b/src/tim/prune/function/distance/GenericTableModel.java @@ -0,0 +1,50 @@ +package tim.prune.function.distance; + +import java.util.ArrayList; + +import javax.swing.table.AbstractTableModel; + +import tim.prune.I18nManager; +import tim.prune.data.DataPoint; + +/** + * General table model class for the two models in the distance function + */ +public abstract class GenericTableModel extends AbstractTableModel +{ + /** list of points */ + protected ArrayList _pointList = null; + /** Column heading */ + private static String _currPointLabel = I18nManager.getText("dialog.distances.currentpoint"); + + /** + * Initialize the table model with the point list + * @param inPointList list of points + */ + public void init(ArrayList inPointList) + { + _pointList = inPointList; + } + + /** + * @return row count + */ + public int getRowCount() + { + if (_pointList == null) {return 0;} + return _pointList.size(); + } + + /** + * Get the name of the specified point from the list + * @param inIndex index of point + * @return waypoint name if waypoint, otherwise "current point" + */ + protected String getPointName(int inIndex) + { + if (_pointList == null) {return "null";} + DataPoint point = _pointList.get(inIndex); + if (point.isWaypoint()) {return point.getWaypointName();} + return _currPointLabel; + } +}