X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FFileInfo.java;fp=tim%2Fprune%2Fdata%2FFileInfo.java;h=41900cb8736df60d668238306079256bf2dca175;hp=ffcc95b04bcd2a5e7b34bb5fe0ad73eb973eac7b;hb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465;hpb=1a735a99408fd3b0c5ac4fe7b2fdbdbb23d38f40 diff --git a/tim/prune/data/FileInfo.java b/tim/prune/data/FileInfo.java index ffcc95b..41900cb 100644 --- a/tim/prune/data/FileInfo.java +++ b/tim/prune/data/FileInfo.java @@ -68,16 +68,18 @@ public class FileInfo */ public String getFilename() { - if (getNumFiles() == 1) + if (getNumFiles() == 1) { return _sources.get(0).getName(); + } return ""; } /** - * @param inIndex index number + * @param inIndex index number, starting from zero * @return source info object */ - public SourceInfo getSource(int inIndex) { + public SourceInfo getSource(int inIndex) + { return _sources.get(inIndex); } @@ -88,7 +90,8 @@ public class FileInfo */ public SourceInfo getSourceForPoint(DataPoint inPoint) { - for (SourceInfo source : _sources) { + for (SourceInfo source : _sources) + { if (source.getIndex(inPoint) >= 0) { return source; } @@ -96,6 +99,43 @@ public class FileInfo return null; } + /** + * @return the info about the last file loaded, if any + */ + public SourceInfo getLastFileInfo() + { + if (getNumFiles() == 0) + { + return null; + } + return getSource(getNumFiles()-1); + } + + /** + * @return the most recent file title loaded, if any + */ + public String getLastFileTitle() + { + final int numFiles = getNumFiles(); + if (numFiles == 0) + { + return null; + } + for (int i=(numFiles-1); i>=0; i--) + { + SourceInfo info = getSource(i); + if (info != null) + { + String title = info.getFileTitle(); + if (title != null && !title.equals("")) + { + return title; + } + } + } + return null; + } + /** * Clone contents of file info */