Ignore:
Timestamp:
05/10/18 16:04:51 (6 years ago)
Author:
davidb
Message:

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/apollo/meldex/RogTrack.java

    r315 r1102  
    11package org.apollo.meldex;
    2 
    32
    43import java.io.File;
    54import java.io.FileInputStream;
    65import java.io.FileOutputStream;
     6import java.io.IOException;
    77import java.util.ArrayList;
    8 import javax.swing.JOptionPane;
    9 
    10 @SuppressWarnings("unchecked") // code in java 1.4
     8
     9import org.expeditee.gio.EcosystemManager;
     10
    1111public class RogTrack
    1212{
     
    2020
    2121    // Data representing the track events
    22     ArrayList trackData = new ArrayList();
     22    ArrayList<RogTrackEvent> trackData = new ArrayList<RogTrackEvent>();
    2323
    2424
     
    217217        int track_len = trackData.size();
    218218
    219         ArrayList filtered_td = new ArrayList();
     219        ArrayList<RogTrackEvent> filtered_td = new ArrayList<RogTrackEvent>();
    220220
    221221        for (int i = 0; i < track_len; i++) {
     
    235235        }
    236236
    237         ArrayList me_list = new ArrayList();
     237        ArrayList<MelodyEvent> me_list = new ArrayList<MelodyEvent>();
    238238
    239239        for (int i = 0; i < filtered_track_len-1; i++) {
     
    283283    public boolean loadFromFile(File rogFile)
    284284    {
    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;
    306315    }
    307316
     
    406415            // Check that the noteName is valid
    407416            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.");
    409418                return;
    410419            }
     
    497506        }
    498507        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);
    500509            return false;
    501510        }
Note: See TracChangeset for help on using the changeset viewer.