File: GenericTableModel.java

package info (click to toggle)
gpsprune 10-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,220 kB
  • ctags: 3,013
  • sloc: java: 22,662; sh: 23; makefile: 16; python: 15
file content (50 lines) | stat: -rw-r--r-- 1,226 bytes parent folder | download | duplicates (8)
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
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<DataPoint> _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<DataPoint> 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;
	}
}