Changeset 1102 for trunk/src/org/apollo/meldex/RogTrack.java
- Timestamp:
- 05/10/18 16:04:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/meldex/RogTrack.java
r315 r1102 1 1 package org.apollo.meldex; 2 3 2 4 3 import java.io.File; 5 4 import java.io.FileInputStream; 6 5 import java.io.FileOutputStream; 6 import java.io.IOException; 7 7 import java.util.ArrayList; 8 import javax.swing.JOptionPane; 9 10 @SuppressWarnings("unchecked") // code in java 1.4 8 9 import org.expeditee.gio.EcosystemManager; 10 11 11 public class RogTrack 12 12 { … … 20 20 21 21 // Data representing the track events 22 ArrayList trackData = new ArrayList();22 ArrayList<RogTrackEvent> trackData = new ArrayList<RogTrackEvent>(); 23 23 24 24 … … 217 217 int track_len = trackData.size(); 218 218 219 ArrayList filtered_td = new ArrayList();219 ArrayList<RogTrackEvent> filtered_td = new ArrayList<RogTrackEvent>(); 220 220 221 221 for (int i = 0; i < track_len; i++) { … … 235 235 } 236 236 237 ArrayList me_list = new ArrayList();237 ArrayList<MelodyEvent> me_list = new ArrayList<MelodyEvent>(); 238 238 239 239 for (int i = 0; i < filtered_track_len-1; i++) { … … 283 283 public boolean loadFromFile(File rogFile) 284 284 { 285 try { 286 // Open the file with a FileInputStream, ready for parsing 287 FileInputStream fileIn = new FileInputStream(rogFile); 288 289 // Get the number of bytes in the file 290 int rogLength = fileIn.available(); 291 292 // Create a buffer to store the file, and read the file into it 293 byte[] rogData = new byte[rogLength]; 294 fileIn.read(rogData, 0, rogLength); 295 296 // Parse the .rog file 297 parseFile(rogData, rogLength); 298 } 299 catch (Exception ex) { 300 JOptionPane.showMessageDialog(null, "Exception occurred reading file.\n\n" + ex); 301 return false; 302 } 303 304 // File loaded successfully 305 return true; 285 boolean success = true; 286 FileInputStream fileIn = null; 287 try { 288 // Open the file with a FileInputStream, ready for parsing 289 fileIn = new FileInputStream(rogFile); 290 291 // Get the number of bytes in the file 292 int rogLength = fileIn.available(); 293 294 // Create a buffer to store the file, and read the file into it 295 byte[] rogData = new byte[rogLength]; 296 fileIn.read(rogData, 0, rogLength); 297 298 // Parse the .rog file 299 parseFile(rogData, rogLength); 300 } catch (Exception ex) { 301 EcosystemManager.getGraphicsManager().showDialog("Exception", "Exception occurred reading file.\n\n" + ex); 302 success = false; 303 } finally { 304 if (fileIn != null) { 305 try { 306 fileIn.close(); 307 } catch (IOException e) { 308 // If an IO exception occurs when closing the file, just sweep it under the rug 309 } 310 } 311 } 312 313 // File loaded successfully 314 return success; 306 315 } 307 316 … … 406 415 // Check that the noteName is valid 407 416 if (noteName < 'A' || noteName > 'G') { 408 JOptionPane.showMessageDialog(null, "Parsing error - check that the Rog file is valid.");417 EcosystemManager.getGraphicsManager().showDialog("Exception", "Parsing error - check that the Rog file is valid."); 409 418 return; 410 419 } … … 497 506 } 498 507 catch (Exception ex) { 499 JOptionPane.showMessageDialog(null, "Exception occurred writing to file.\n\n" + ex);508 EcosystemManager.getGraphicsManager().showDialog("Exception", "Exception occurred writing to file.\n\n" + ex); 500 509 return false; 501 510 }
Note:
See TracChangeset
for help on using the changeset viewer.