Add lock and unlock all #15
This commit is contained in:
BIN
resources/uk/co/majenko/audiobookrecorder/icons/important.png
Normal file
BIN
resources/uk/co/majenko/audiobookrecorder/icons/important.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@@ -796,6 +796,8 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
JMenuObject moveUp = new JMenuObject("Move Up", c);
|
JMenuObject moveUp = new JMenuObject("Move Up", c);
|
||||||
JMenuObject moveDown = new JMenuObject("Move Down", c);
|
JMenuObject moveDown = new JMenuObject("Move Down", c);
|
||||||
JMenu mergeWith = new JMenu("Merge chapter with");
|
JMenu mergeWith = new JMenu("Merge chapter with");
|
||||||
|
JMenuObject lockAll = new JMenuObject("Lock all sentences", c);
|
||||||
|
JMenuObject unlockAll = new JMenuObject("Unlock all sentences", c);
|
||||||
|
|
||||||
for (Enumeration<Chapter> bc = book.children(); bc.hasMoreElements();) {
|
for (Enumeration<Chapter> bc = book.children(); bc.hasMoreElements();) {
|
||||||
Chapter chp = bc.nextElement();
|
Chapter chp = bc.nextElement();
|
||||||
@@ -878,6 +880,30 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
lockAll.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
JMenuObject o = (JMenuObject)e.getSource();
|
||||||
|
Chapter c = (Chapter)o.getObject();
|
||||||
|
for (Enumeration<Sentence> s = c.children(); s.hasMoreElements();) {
|
||||||
|
Sentence snt = s.nextElement();
|
||||||
|
snt.setLocked(true);
|
||||||
|
bookTreeModel.reload(snt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
unlockAll.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
JMenuObject o = (JMenuObject)e.getSource();
|
||||||
|
Chapter c = (Chapter)o.getObject();
|
||||||
|
for (Enumeration<Sentence> s = c.children(); s.hasMoreElements();) {
|
||||||
|
Sentence snt = s.nextElement();
|
||||||
|
snt.setLocked(false);
|
||||||
|
bookTreeModel.reload(snt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
menu.add(moveUp);
|
menu.add(moveUp);
|
||||||
menu.add(moveDown);
|
menu.add(moveDown);
|
||||||
|
|
||||||
@@ -887,6 +913,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
menu.add(peak);
|
menu.add(peak);
|
||||||
|
menu.addSeparator();
|
||||||
|
menu.add(lockAll);
|
||||||
|
menu.add(unlockAll);
|
||||||
menu.show(bookTree, e.getX(), e.getY());
|
menu.show(bookTree, e.getX(), e.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
if (s.isLocked()) {
|
if (s.isLocked()) {
|
||||||
ret.setForeground(new Color(0x20, 0x00, 0x00));
|
ret.setForeground(new Color(0x20, 0x00, 0x00));
|
||||||
ret.setIcon(Icons.locked);
|
ret.setIcon(Icons.locked);
|
||||||
|
} else if (s.getStartOffset() == 0) {
|
||||||
|
ret.setIcon(Icons.important);
|
||||||
} else {
|
} else {
|
||||||
ret.setIcon(Icons.sentence);
|
ret.setIcon(Icons.sentence);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,6 @@ public class Icons {
|
|||||||
static public final ImageIcon locked = new ImageIcon(Icons.class.getResource("icons/locked.png"));
|
static public final ImageIcon locked = new ImageIcon(Icons.class.getResource("icons/locked.png"));
|
||||||
static public final ImageIcon appIcon = new ImageIcon(Icons.class.getResource("icons/appIcon.png"));
|
static public final ImageIcon appIcon = new ImageIcon(Icons.class.getResource("icons/appIcon.png"));
|
||||||
static public final ImageIcon star = new ImageIcon(Icons.class.getResource("icons/star.png"));
|
static public final ImageIcon star = new ImageIcon(Icons.class.getResource("icons/star.png"));
|
||||||
|
static public final ImageIcon important = new ImageIcon(Icons.class.getResource("icons/important.png"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
storedAudioData = null;
|
storedAudioData = null;
|
||||||
|
|
||||||
if (!id.equals("room-noise")) {
|
if (!id.equals("room-noise")) {
|
||||||
autoTrimSampleFFT();
|
autoTrimSamplePeak();
|
||||||
if (Options.getBoolean("process.sphinx")) {
|
if (Options.getBoolean("process.sphinx")) {
|
||||||
recognise();
|
recognise();
|
||||||
}
|
}
|
||||||
@@ -574,6 +574,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
|
|
||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
storedAudioData = null;
|
storedAudioData = null;
|
||||||
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean lockedInCache() {
|
public boolean lockedInCache() {
|
||||||
@@ -582,6 +583,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
|
|
||||||
public int findNearestZeroCrossing(int pos, int range) {
|
public int findNearestZeroCrossing(int pos, int range) {
|
||||||
int[] data = getAudioData();
|
int[] data = getAudioData();
|
||||||
|
if (data == null) return 0;
|
||||||
|
|
||||||
if (pos < 0) pos = 0;
|
if (pos < 0) pos = 0;
|
||||||
if (pos >= data.length) pos = data.length-1;
|
if (pos >= data.length) pos = data.length-1;
|
||||||
|
|||||||
Reference in New Issue
Block a user