File: TileSetTableModel.java

package info (click to toggle)
gpsprune 19.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,516 kB
  • sloc: java: 42,704; sh: 25; makefile: 24; python: 15
file content (77 lines) | stat: -rw-r--r-- 1,889 bytes parent folder | download | duplicates (7)
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
package tim.prune.function.cache;

import javax.swing.table.AbstractTableModel;

import tim.prune.I18nManager;

/**
 * Class to act as a table model for the list of tile sets
 */
public final class TileSetTableModel extends AbstractTableModel
{
	/** Model from which values are drawn */
	private TileCacheModel _model = null;


	/**
	 * Constructor
	 * @param inModel model to use
	 */
	public TileSetTableModel(TileCacheModel inModel) {
		_model = inModel;
	}

	/** @return the column count (always constant) */
	public int getColumnCount() {
		return 5;
	}

	/** @return name of specified column */
	public String getColumnName(int inColumnIndex)
	{
		switch (inColumnIndex)
		{
			case 0: return I18nManager.getText("dialog.diskcache.table.path");
			case 1: return I18nManager.getText("dialog.diskcache.table.usedby");
			case 2: return I18nManager.getText("dialog.diskcache.table.zoom");
			case 3: return I18nManager.getText("dialog.diskcache.table.tiles");
			case 4: return I18nManager.getText("dialog.diskcache.table.megabytes");
		}
		return "";
	}

	/**
	 * @return number of rows in the table
	 */
	public int getRowCount()
	{
		if (_model == null)
			return 0;
		return _model.getNumTileSets();
	}

	/**
	 * @param inRowIndex row index
	 * @param inColumnIndex column index
	 * @return the value of the specified cell
	 */
	public Object getValueAt(int inRowIndex, int inColumnIndex)
	{
		if (_model != null && inColumnIndex >= 0 && inColumnIndex < getColumnCount())
		{
			TileSet set = _model.getTileSet(inRowIndex);
			if (set != null)
			{
				switch (inColumnIndex)
				{
					case 0: return set.getPath();
					case 1: return set.getUsedBy();
					case 2: return set.getRowInfo().getZoomRange();
					case 3: return "" + set.getRowInfo().getNumTiles();
					case 4: return "" + (set.getRowInfo().getTotalSize() / 1024 / 1024) + " MB";
				}
			}
		}
		return null;
	}
}