]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/correlate/PhotoSelectionTableModel.java
Version 4, January 2008
[GpsPrune.git] / tim / prune / correlate / PhotoSelectionTableModel.java
1 package tim.prune.correlate;
2
3 import java.util.ArrayList;
4 import javax.swing.table.AbstractTableModel;
5
6 import tim.prune.I18nManager;
7 import tim.prune.data.Photo;
8
9 /**
10  * Class to act as table model for the photo selection table
11  */
12 public class PhotoSelectionTableModel extends AbstractTableModel
13 {
14         private ArrayList _list = new ArrayList();
15
16
17         /**
18          * @return the column count, always 4
19          */
20         public int getColumnCount()
21         {
22                 return 4;
23         }
24
25
26         /**
27          * Get the name of the column
28          * @param inColNum column number
29          * @return column name
30          */
31         public String getColumnName(int inColNum)
32         {
33                 if (inColNum == 0) return I18nManager.getText("dialog.correlate.photoselect.photoname");
34                 else if (inColNum == 1) return I18nManager.getText("fieldname.timestamp");
35                 else if (inColNum == 2) return I18nManager.getText("dialog.correlate.photoselect.timediff");
36                 return I18nManager.getText("dialog.correlate.photoselect.photolater");
37         }
38
39
40         /**
41          * @return the row count
42          */
43         public int getRowCount()
44         {
45                 return _list.size();
46         }
47
48
49         /**
50          * Get the selected row from the table
51          * @param inRowIndex row index
52          * @return table row object
53          */
54         public PhotoSelectionTableRow getRow(int inRowIndex)
55         {
56                 PhotoSelectionTableRow row = (PhotoSelectionTableRow) _list.get(inRowIndex);
57                 return row;
58         }
59
60
61         /**
62          * Get the value of the specified cell
63          * @param inRowIndex row index
64          * @param inColumnIndex column index
65          * @return value of specified cell
66          */
67         public Object getValueAt(int inRowIndex, int inColumnIndex)
68         {
69                 // TODO: only show time of photos (not date) if dates all identical
70                 PhotoSelectionTableRow row = (PhotoSelectionTableRow) _list.get(inRowIndex);
71                 if (inColumnIndex == 0) return row.getPhoto().getFile().getName();
72                 else if (inColumnIndex == 1) return row.getPhoto().getTimestamp().getText();
73                 else if (inColumnIndex == 2) return row.getTimeDiff().getDescription();
74                 return (row.getTimeDiff().getIsPositive() ? I18nManager.getText("dialog.about.yes") :
75                         I18nManager.getText("dialog.about.no"));
76         }
77
78
79         /**
80          * Clear the list
81          */
82         public void reset()
83         {
84                 _list.clear();
85         }
86
87         /**
88          * Add a photo to the list
89          * @param inPhoto photo to add
90          * @param inTimeDiff time difference
91          */
92         public void addPhoto(Photo inPhoto, long inTimeDiff)
93         {
94                 _list.add(new PhotoSelectionTableRow(inPhoto, inTimeDiff));
95         }
96 }