Skip to content

Commit

Permalink
further warnings fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
IOOI-SqAR committed Jan 1, 2024
1 parent f118d04 commit 0a516bf
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 100 deletions.
98 changes: 48 additions & 50 deletions src/main/java/org/sqar/virtualjtc/jtcemu/audio/AudioFrm.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,41 @@ public class AudioFrm extends BaseFrm implements ActionListener

private static AudioFrm instance = null;

private Z8 z8;
private JTCSys jtcSys;
private Thread emuThread;
private final Z8 z8;
private final JTCSys jtcSys;
private final Thread emuThread;
private javax.swing.filechooser.FileFilter readFileFilter;
private javax.swing.filechooser.FileFilter writeFileFilter;
private File curFile;
private File lastFile;
private AudioFormat audioFmt;
private AudioIO audioIO;
private JRadioButton btnSoundOut;
private JRadioButton btnDataOut;
private JRadioButton btnDataIn;
private JRadioButton btnFileOut;
private JRadioButton btnFileIn;
private JRadioButton btnFileLastIn;
private JLabel labelSampleRate;
private JComboBox comboSampleRate;
private JLabel labelSpeed;
private JSpinner spinnerSpeed;
private JLabel labelThreshold;
private JSlider sliderThreshold;
private JLabel labelChannel;
private JRadioButton btnChannel0;
private JRadioButton btnChannel1;
private JCheckBox btnMonitorPlay;
private JLabel labelFileName;
private JTextField fldFileName;
private JLabel labelFormat;
private JTextField fldFormat;
private JLabel labelProgress;
private JProgressBar progressBar;
private JButton btnEnable;
private JButton btnDisable;
private JButton btnHelp;
private JButton btnClose;
private final JRadioButton btnSoundOut;
private final JRadioButton btnDataOut;
private final JRadioButton btnDataIn;
private final JRadioButton btnFileOut;
private final JRadioButton btnFileIn;
private final JRadioButton btnFileLastIn;
private final JLabel labelSampleRate;
private final JComboBox<String> comboSampleRate;
private final JLabel labelSpeed;
private final JSpinner spinnerSpeed;
private final JLabel labelThreshold;
private final JSlider sliderThreshold;
private final JLabel labelChannel;
private final JRadioButton btnChannel0;
private final JRadioButton btnChannel1;
private final JCheckBox btnMonitorPlay;
private final JLabel labelFileName;
private final JTextField fldFileName;
private final JLabel labelFormat;
private final JTextField fldFormat;
private final JLabel labelProgress;
private final JProgressBar progressBar;
private final JButton btnEnable;
private final JButton btnDisable;
private final JButton btnHelp;
private final JButton btnClose;


public void doQuit()
Expand Down Expand Up @@ -300,12 +300,12 @@ private AudioFrm( Z8 z8, JTCSys jtcSys, Thread emuThread )
this.labelSampleRate = new JLabel( audioFrmResourceBundle.getString("label.sampleRate") );
panelOpt.add( this.labelSampleRate, gbcOpt );

this.comboSampleRate = new JComboBox();
this.comboSampleRate = new JComboBox<String>();
this.comboSampleRate.setEditable( false );
this.comboSampleRate.addItem( "Standard" );
for( int i = 0; i < this.sampleRates.length; i++ ) {
this.comboSampleRate.addItem( String.valueOf( this.sampleRates[ i ] ) );
}
for (int sampleRate : sampleRates) {
this.comboSampleRate.addItem(String.valueOf(sampleRate));
}
gbcOpt.gridwidth = GridBagConstraints.REMAINDER;
gbcOpt.gridx++;
panelOpt.add( this.comboSampleRate, gbcOpt );
Expand All @@ -321,7 +321,7 @@ private AudioFrm( Z8 z8, JTCSys jtcSys, Thread emuThread )
"org.sqar.virtualjtc.jtcemu.audio.speed_adjustment.percent" );
this.spinnerSpeed = new JSpinner(
new SpinnerNumberModel(
pValue != null ? pValue.intValue() : 0,
pValue != null ? pValue : 0,
-20,
20,
1 ) );
Expand All @@ -340,7 +340,7 @@ private AudioFrm( Z8 z8, JTCSys jtcSys, Thread emuThread )
JSlider.HORIZONTAL,
0,
100,
pValue != null ? pValue.intValue() : 50 );
pValue != null ? pValue : 50 );
this.sliderThreshold.setMajorTickSpacing( 50 );
this.sliderThreshold.setMinorTickSpacing( 10 );
this.sliderThreshold.setPaintLabels( true );
Expand Down Expand Up @@ -481,20 +481,20 @@ private static javax.swing.filechooser.FileFilter createFileFilter(
if( fmts != null ) {
if( fmts.length > 0 ) {
Collection<String> suffixes = new ArrayList<String>( fmts.length );
for( int i = 0; i < fmts.length; i++ ) {
String suffix = fmts[ i ].getExtension();
if( suffix != null ) {
if( suffix.length() > 0 )
suffixes.add( suffix );
for (AudioFileFormat.Type fmt : fmts) {
String suffix = fmt.getExtension();
if (suffix != null) {
if (!suffix.isEmpty())
suffixes.add(suffix);
}
}
}
if( !suffixes.isEmpty() ) {
try {
rv = new FileNameExtensionFilter(
text,
suffixes.toArray( new String[ suffixes.size() ] ) );
suffixes.toArray(new String[0]) );
}
catch( ArrayStoreException ex ) {}
catch( ArrayStoreException ignored) {}
}
}
}
Expand Down Expand Up @@ -705,8 +705,7 @@ private AudioFileFormat.Type getAudioFileType( File file )
}

String fileName = file.getName();
if( fileName != null ) {
fileName = fileName.toUpperCase( Locale.ENGLISH );
fileName = fileName.toUpperCase(Locale.ENGLISH);
for( AudioFileFormat.Type fileType : types ) {
String ext = fileType.getExtension();
if( ext != null ) {
Expand All @@ -718,9 +717,8 @@ private AudioFileFormat.Type getAudioFileType( File file )
return fileType;
}
}
}

StringBuilder buf = new StringBuilder( 64 );
StringBuilder buf = new StringBuilder( 64 );
buf.append( audioFrmResourceBundle.getString("error.getAudioFileType.fileFormatNotSupported.message") );
if( !types.isEmpty() ) {
buf.append( audioFrmResourceBundle.getString("error.getAudioFileType.fileFormatNotSupported.possibleExtensions") );
Expand Down Expand Up @@ -772,8 +770,8 @@ public static String getAudioFormatText( AudioFormat fmt )
private int getSampleRate()
{
int i = this.comboSampleRate.getSelectedIndex() - 1; // 0: automatisch
return ((i >= 0) && (i < this.sampleRates.length)) ?
this.sampleRates[ i ] : 0;
return ((i >= 0) && (i < sampleRates.length)) ?
sampleRates[ i ] : 0;
}


Expand Down Expand Up @@ -835,7 +833,7 @@ private void setEmuThreadPriority( int priority )
try {
this.emuThread.setPriority( priority );
}
catch( Exception ex ) {}
catch( Exception ignored) {}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ else if( v > this.maxValue ) {
* Anzahl der verstrichenen Taktzyklen auf den Wert
* des letzten gelesenen Samples korrigieren
*/
this.lastCycles += (nSamples * this.cyclesPerFrame);
this.lastCycles += ((long) nSamples * this.cyclesPerFrame);
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/sqar/virtualjtc/jtcemu/audio/AudioInFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class AudioInFile extends AudioIn
private static final Locale locale = Locale.getDefault();
private static final ResourceBundle audioInFileResourceBundle = ResourceBundle.getBundle("AudioInFile", locale);

private AudioFrm audioFrm;
private File file;
private boolean monitorPlay;
private final AudioFrm audioFrm;
private final File file;
private final boolean monitorPlay;
private AudioInputStream in;
private byte[] frameBuf;
private long frameCount;
Expand Down Expand Up @@ -113,7 +113,8 @@ public AudioFormat startAudio(
this.errorText = audioInFileResourceBundle.getString("error.startAudio.unknownError.errorText") + ex.getMessage();
}
if( (this.in != null) || (fmt != null) ) {
this.frameBuf = new byte[ fmt.getFrameSize() ];
assert fmt != null;
this.frameBuf = new byte[ fmt.getFrameSize() ];
this.cyclesPerFrame = Math.round( (float) cyclesPerSecond
/ fmt.getFrameRate() );
this.thresholdValue = thresholdValue;
Expand Down Expand Up @@ -142,7 +143,7 @@ public void stopAudio()
try {
in.close();
}
catch( Exception ex ) {}
catch( Exception ignored) {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class AudioInLine extends AudioIn
{
private static int[] sampleRates = { 44100, 32000, 22050 };
private static final int[] sampleRates = { 44100, 32000, 22050 };

private TargetDataLine dataLine;
private byte[] frameBuf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void writePhase( boolean phase )
* Anzahl der verstrichenen Taktzyklen auf den Wert
* des letzten ausgegebenen Samples korrigieren
*/
this.lastCycles += (nSamples * this.cyclesPerFrame);
this.lastCycles += ((long) nSamples * this.cyclesPerFrame);
this.lastPhaseSamples = nSamples;
}
}
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/org/sqar/virtualjtc/jtcemu/audio/AudioOutFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public class AudioOutFile extends AudioOut
private static final Locale locale = Locale.getDefault();
private static final ResourceBundle audioOutFileResourceBundle = ResourceBundle.getBundle("AudioOutFile", locale);

private AudioFrm audioFrm;
private File file;
private AudioFileFormat.Type fileType;
private boolean monitorPlay;
private AudioFormat audioFmt;
private AudioDataQueue queue;
private final AudioFrm audioFrm;
private final File file;
private final AudioFileFormat.Type fileType;
private final boolean monitorPlay;
private AudioFormat audioFmt;
private AudioDataQueue queue;


public AudioOutFile(
Expand Down Expand Up @@ -109,8 +109,9 @@ public void stopAudio()
{
closeMonitorLine();

AudioDataQueue queue = this.queue;
this.enabled = false;
AudioDataQueue queue;
queue = this.queue;
this.enabled = false;
this.errorText = queue.getErrorText();
if( (this.errorText == null) && (queue.getTotalSampleCount() > 0) ) {
try {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/sqar/virtualjtc/jtcemu/audio/AudioOutLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

public class AudioOutLine extends AudioOut
{
private static int[] sampleRatesSound = { 22050, 16000, 8000 };
private static int[] sampleRatesData = { 44100, 32000, 22050 };
private static final int[] sampleRatesSound = { 22050, 16000, 8000 };
private static final int[] sampleRatesData = { 44100, 32000, 22050 };

private boolean forDataTransfer;
private SourceDataLine dataLine;
private byte[] audioDataBuf;
private int audioDataPos;
private final boolean forDataTransfer;
private SourceDataLine dataLine;
private byte[] audioDataBuf;
private int audioDataPos;


public AudioOutLine(Z8 z8, JTCSys jtcSys, boolean forDataTransfer )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void closeDataLine( DataLine dataLine )
try {
thread.join( 1000 );
}
catch( InterruptedException ex ) {}
catch( InterruptedException ignored) {}
}
}
}
Expand All @@ -46,17 +46,17 @@ public void run()
try {
this.dataLine.flush();
}
catch( Exception ex ) {}
catch( Exception ignored) {}

try {
this.dataLine.stop();
}
catch( Exception ex ) {}
catch( Exception ignored) {}

try {
this.dataLine.close();
}
catch( Exception ex ) {}
catch( Exception ignored) {}

this.dataLine = null;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/sqar/virtualjtc/z8/Z8Breakpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

public class Z8Breakpoint implements Comparable<Z8Breakpoint>
{
private int addr;
private boolean enabled;
private String text;
private final int addr;
private boolean enabled;
private String text;


public Z8Breakpoint( int addr )
Expand Down
41 changes: 20 additions & 21 deletions src/main/java/org/sqar/virtualjtc/z8/Z8Reassembler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public class Z8Reassembler
"P01M", "IPR", "IRQ", "IMR", "FLAGS", "RP", "SPH", "SPL" };


private Z8Memory memory;
private StringBuilder buf;
private int addr;
private String lastInstName;
private String[] lastInstArgs;
private final Z8Memory memory;
private StringBuilder buf;
private int addr;
private String lastInstName;
private String[] lastInstArgs;


public Z8Reassembler( Z8Memory memory )
Expand Down Expand Up @@ -203,24 +203,23 @@ private void reassNextInst( boolean includeAddr )
begPos = this.buf.length();
this.buf.append( this.lastInstName );
if( this.lastInstArgs != null ) {
for( int i = 0; i < this.lastInstArgs.length; i++ ) {
String arg = this.lastInstArgs[ i ];
if( arg != null ) {
if( begPos >= 0 ) {
n = begPos + 8 - this.buf.length();
if( n < 1 ) {
n = 1;
for (String arg : this.lastInstArgs) {
if (arg != null) {
if (begPos >= 0) {
n = begPos + 8 - this.buf.length();
if (n < 1) {
n = 1;
}
for (int k = 0; k < n; k++) {
this.buf.append((char) '\u0020');
}
begPos = -1;
} else {
this.buf.append(", ");
}
this.buf.append(arg);
}
for( int k = 0; k < n; k++ ) {
this.buf.append( (char) '\u0020' );
}
begPos = -1;
} else {
this.buf.append( ", " );
}
this.buf.append( arg );
}
}
}
}

Expand Down

0 comments on commit 0a516bf

Please sign in to comment.