Merge chapters (#1)

This commit is contained in:
2018-09-16 12:20:48 +01:00
parent 9ee4acfc8d
commit 9fb3d1f816
5 changed files with 45 additions and 0 deletions

View File

@@ -775,6 +775,32 @@ public class AudiobookRecorder extends JFrame {
JMenuObject peak = new JMenuObject("Auto-trim all (Peak)", c);
JMenuObject moveUp = new JMenuObject("Move Up", c);
JMenuObject moveDown = new JMenuObject("Move Down", c);
JMenu mergeWith = new JMenu("Merge chapter with");
for (Enumeration<Chapter> bc = book.children(); bc.hasMoreElements();) {
Chapter chp = bc.nextElement();
if (chp.getId().equals(c.getId())) {
continue;
}
JMenuObject2 m = new JMenuObject2(chp.getName(), c, chp);
m.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JMenuObject2 ob = (JMenuObject2)e.getSource();
Chapter source = (Chapter)ob.getObject1();
Chapter target = (Chapter)ob.getObject2();
DefaultMutableTreeNode n = source.getFirstLeaf();
while (n instanceof Sentence) {
bookTreeModel.removeNodeFromParent(n);
bookTreeModel.insertNodeInto(n, target, target.getChildCount());
n = source.getFirstLeaf();
}
}
});
mergeWith.add(m);
}
int idNumber = s2i(c.getId());
@@ -835,6 +861,9 @@ public class AudiobookRecorder extends JFrame {
menu.add(moveUp);
menu.add(moveDown);
menu.addSeparator();
menu.add(mergeWith);
menu.addSeparator();
menu.add(peak);

View File

@@ -10,12 +10,17 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
JLabel ret = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (value instanceof Sentence) {
Sentence s = (Sentence)value;
if (s.isLocked()) {
ret.setForeground(new Color(0x20, 0x00, 0x00));
ret.setIcon(Icons.locked);
} else {
ret.setIcon(Icons.sentence);
}
if (s.isInSample()) {
ret.setIcon(Icons.star);
}
} else if (value instanceof Chapter) {
ret.setIcon(Icons.chapter);
} else if (value instanceof Book) {

View File

@@ -20,5 +20,6 @@ public class Icons {
static public ImageIcon peak = new ImageIcon(Icons.class.getResource("icons/peak.png"));
static public ImageIcon locked = new ImageIcon(Icons.class.getResource("icons/locked.png"));
static public ImageIcon appIcon = new ImageIcon(Icons.class.getResource("icons/appIcon.png"));
static public ImageIcon star = new ImageIcon(Icons.class.getResource("icons/star.png"));
}

View File

@@ -27,6 +27,8 @@ public class Sentence extends DefaultMutableTreeNode {
boolean recording;
boolean inSample;
TargetDataLine line;
AudioInputStream inputStream;
@@ -520,4 +522,12 @@ public class Sentence extends DefaultMutableTreeNode {
public boolean isLocked() {
return locked;
}
public void setInSample(boolean s) {
inSample = s;
}
public boolean isInSample() {
return inSample;
}
}