Add book length
This commit is contained in:
@@ -710,4 +710,21 @@ public class Book extends BookTreeNode {
|
||||
}
|
||||
return cleanName.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLength() {
|
||||
Debug.trace();
|
||||
double len = 0;
|
||||
for (Enumeration o = children(); o.hasMoreElements();) {
|
||||
Object ob = (Object)o.nextElement();
|
||||
if (ob instanceof Chapter) {
|
||||
Chapter c = (Chapter)ob;
|
||||
len += c.getLength();
|
||||
len += (c.getPreGap() / 1000d);
|
||||
len += (c.getPostGap() / 1000d);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public abstract class BookTreeNode extends DefaultMutableTreeNode {
|
||||
|
||||
public abstract void setNotes(String t);
|
||||
public abstract String getNotes();
|
||||
|
||||
public abstract void onSelect(BookTreeNode target);
|
||||
public abstract Book getBook();
|
||||
public abstract double getLength();
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||
ret.setIcon(b.getIcon());
|
||||
p.add(ret, ctx);
|
||||
|
||||
JLabel author = new JLabel(b.getAuthor());
|
||||
JLabel author = new JLabel(b.getAuthor() + " - " + Utils.secToTime(b.getLength(), "HH:mm:ss"));
|
||||
ctx.gridy++;
|
||||
author.setBorder(new EmptyBorder(0, 27, 0, 0));
|
||||
Font f = author.getFont();
|
||||
|
||||
@@ -383,6 +383,7 @@ public class Chapter extends BookTreeNode {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLength() {
|
||||
Debug.trace();
|
||||
double len = 0;
|
||||
@@ -391,6 +392,7 @@ public class Chapter extends BookTreeNode {
|
||||
if (ob instanceof Sentence) {
|
||||
Sentence s = (Sentence)ob;
|
||||
len += s.getLength();
|
||||
len += (s.getPostGap() / 1000d);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
|
||||
@@ -817,6 +817,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
}
|
||||
|
||||
/* Get the length of the sample in seconds */
|
||||
@Override
|
||||
public double getLength() {
|
||||
Debug.trace();
|
||||
if (runtime > 0.01d) return runtime;
|
||||
|
||||
Reference in New Issue
Block a user