Various cleanups as recommended by FindBug
This commit is contained in:
@@ -171,7 +171,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
toolsOptions = new JMenuItem("Options");
|
||||
toolsOptions.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Options o = new Options(AudiobookRecorder.this);
|
||||
new Options(AudiobookRecorder.this);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -580,7 +580,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
}
|
||||
|
||||
|
||||
AudiobookRecorder frame = new AudiobookRecorder();
|
||||
new AudiobookRecorder();
|
||||
}
|
||||
|
||||
public void createNewBook() {
|
||||
@@ -758,7 +758,6 @@ public class AudiobookRecorder extends JFrame {
|
||||
Sentence s = (Sentence)o.getObject();
|
||||
if (!s.isLocked()) {
|
||||
s.deleteFiles();
|
||||
Chapter c = (Chapter)s.getParent();
|
||||
bookTreeModel.removeNodeFromParent(s);
|
||||
}
|
||||
}
|
||||
@@ -1628,7 +1627,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
play.write(data, 0, data.length);
|
||||
}
|
||||
s = (Sentence)next;
|
||||
bookTree.setSelectionPath(new TreePath(s.getPath()));
|
||||
if (s != null) {
|
||||
bookTree.setSelectionPath(new TreePath(s.getPath()));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
playing = null;
|
||||
@@ -1651,7 +1652,6 @@ public class AudiobookRecorder extends JFrame {
|
||||
if (len == 0) return null;
|
||||
|
||||
AudioFormat f = roomNoise.getAudioFormat();
|
||||
int frameSize = f.getFrameSize();
|
||||
|
||||
float sr = f.getSampleRate();
|
||||
|
||||
|
||||
@@ -3,23 +3,23 @@ package uk.co.majenko.audiobookrecorder;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Icons {
|
||||
static public ImageIcon book = new ImageIcon(Icons.class.getResource("icons/book.png"));
|
||||
static public ImageIcon chapter = new ImageIcon(Icons.class.getResource("icons/chapter.png"));
|
||||
static public ImageIcon sentence = new ImageIcon(Icons.class.getResource("icons/sentence.png"));
|
||||
static public ImageIcon play = new ImageIcon(Icons.class.getResource("icons/play.png"));
|
||||
static public ImageIcon playon = new ImageIcon(Icons.class.getResource("icons/playon.png"));
|
||||
static public ImageIcon stop = new ImageIcon(Icons.class.getResource("icons/stop.png"));
|
||||
static public ImageIcon record = new ImageIcon(Icons.class.getResource("icons/record.png"));
|
||||
static public ImageIcon openBook = new ImageIcon(Icons.class.getResource("icons/open.png"));
|
||||
static public ImageIcon newBook = new ImageIcon(Icons.class.getResource("icons/new.png"));
|
||||
static public ImageIcon newChapter = new ImageIcon(Icons.class.getResource("icons/new-chapter.png"));
|
||||
static public ImageIcon recordRoom = new ImageIcon(Icons.class.getResource("icons/record-room.png"));
|
||||
static public ImageIcon save = new ImageIcon(Icons.class.getResource("icons/save.png"));
|
||||
static public ImageIcon redo = new ImageIcon(Icons.class.getResource("icons/redo.png"));
|
||||
static public ImageIcon fft = new ImageIcon(Icons.class.getResource("icons/fft.png"));
|
||||
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"));
|
||||
static public final ImageIcon book = new ImageIcon(Icons.class.getResource("icons/book.png"));
|
||||
static public final ImageIcon chapter = new ImageIcon(Icons.class.getResource("icons/chapter.png"));
|
||||
static public final ImageIcon sentence = new ImageIcon(Icons.class.getResource("icons/sentence.png"));
|
||||
static public final ImageIcon play = new ImageIcon(Icons.class.getResource("icons/play.png"));
|
||||
static public final ImageIcon playon = new ImageIcon(Icons.class.getResource("icons/playon.png"));
|
||||
static public final ImageIcon stop = new ImageIcon(Icons.class.getResource("icons/stop.png"));
|
||||
static public final ImageIcon record = new ImageIcon(Icons.class.getResource("icons/record.png"));
|
||||
static public final ImageIcon openBook = new ImageIcon(Icons.class.getResource("icons/open.png"));
|
||||
static public final ImageIcon newBook = new ImageIcon(Icons.class.getResource("icons/new.png"));
|
||||
static public final ImageIcon newChapter = new ImageIcon(Icons.class.getResource("icons/new-chapter.png"));
|
||||
static public final ImageIcon recordRoom = new ImageIcon(Icons.class.getResource("icons/record-room.png"));
|
||||
static public final ImageIcon save = new ImageIcon(Icons.class.getResource("icons/save.png"));
|
||||
static public final ImageIcon redo = new ImageIcon(Icons.class.getResource("icons/redo.png"));
|
||||
static public final ImageIcon fft = new ImageIcon(Icons.class.getResource("icons/fft.png"));
|
||||
static public final ImageIcon peak = new ImageIcon(Icons.class.getResource("icons/peak.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 star = new ImageIcon(Icons.class.getResource("icons/star.png"));
|
||||
|
||||
}
|
||||
|
||||
@@ -14,20 +14,6 @@ public class OpenBookPanel extends JPanel {
|
||||
|
||||
JTable table;
|
||||
|
||||
class BookInfo {
|
||||
public String name;
|
||||
public String author;
|
||||
public String genre;
|
||||
public String comment;
|
||||
|
||||
public BookInfo(String n, String a, String g, String c) {
|
||||
name = n;
|
||||
author = a;
|
||||
genre = g;
|
||||
comment = c;
|
||||
}
|
||||
}
|
||||
|
||||
public class BookCellRenderer implements TableCellRenderer {
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (value == null) return null;
|
||||
@@ -96,12 +82,15 @@ public class OpenBookPanel extends JPanel {
|
||||
try {
|
||||
File dir = new File(Options.get("path.storage"));
|
||||
|
||||
for (File b : dir.listFiles()) {
|
||||
if (!b.isDirectory()) continue;
|
||||
File xml = new File(b, "audiobook.abk");
|
||||
if (xml.exists()) {
|
||||
BookPanel book = new BookPanel(b);
|
||||
model.addBook(book);
|
||||
if (dir.exists() && dir.isDirectory()) {
|
||||
for (File b : dir.listFiles()) {
|
||||
if (b == null) continue;
|
||||
if (!b.isDirectory()) continue;
|
||||
File xml = new File(b, "audiobook.abk");
|
||||
if (xml.exists()) {
|
||||
BookPanel book = new BookPanel(b);
|
||||
model.addBook(book);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -322,16 +322,14 @@ public class Options extends JDialog {
|
||||
|
||||
boolean supported = false;
|
||||
|
||||
Line l;
|
||||
|
||||
try {
|
||||
l = m.getLine(stereoDIF);
|
||||
m.getLine(stereoDIF);
|
||||
supported = true;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
l = m.getLine(monoDIF);
|
||||
m.getLine(monoDIF);
|
||||
supported = true;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
@@ -360,16 +358,14 @@ public class Options extends JDialog {
|
||||
|
||||
boolean supported = false;
|
||||
|
||||
Line l;
|
||||
|
||||
try {
|
||||
l = m.getLine(stereoDIF);
|
||||
m.getLine(stereoDIF);
|
||||
supported = true;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
l = m.getLine(monoDIF);
|
||||
m.getLine(monoDIF);
|
||||
supported = true;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
@@ -63,11 +63,6 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
false
|
||||
);
|
||||
|
||||
if (format == null) {
|
||||
JOptionPane.showMessageDialog(AudiobookRecorder.window, "Sample format not supported", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
|
||||
Mixer.Info mixer = Options.getRecordingMixer();
|
||||
|
||||
line = null;
|
||||
@@ -418,7 +413,6 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
try {
|
||||
AudioInputStream s = AudioSystem.getAudioInputStream(f);
|
||||
AudioFormat format = s.getFormat();
|
||||
long len = s.getFrameLength();
|
||||
int frameSize = format.getFrameSize();
|
||||
|
||||
s.skip(frameSize * startOffset);
|
||||
@@ -447,7 +441,6 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
try {
|
||||
AudioInputStream s = AudioSystem.getAudioInputStream(f);
|
||||
AudioFormat format = s.getFormat();
|
||||
long len = s.getFrameLength();
|
||||
int frameSize = format.getFrameSize();
|
||||
|
||||
updateCrossings();
|
||||
|
||||
Reference in New Issue
Block a user