Package instantbach

Source Code of instantbach.InstantBach

package instantbach;

// Custom I/O
import instantbach.service.Service;
// Custom GUI
import instantbach.gui.MainFrame;
// Custom Data
import instantbach.data.SymbolList;
import instantbach.data.Chord;
// Standard Data
import java.util.ArrayList;
// Interfaces
import instantbach.gui.MainFrameInterface;
import instantbach.service.ServiceInterface;
// Exceptions
import instantbach.service.exception.BadRulesException;
// Standard GUI
import javax.swing.JOptionPane;

/**
* <p>Title: Instant Bach</p>
*
* <p>Description: Represents the main class for the program</p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author John Valentino II
* @version 1.0
*/
public class InstantBach implements MainFrameInterface, ServiceInterface {

    /** Represents the service tier of this application */
    private Service service;
    /** Represents the gui tier */
    private MainFrame mainFrame;
    /** Represents the version of this program */
    private static final String version = "2.0 BETA";

    /**
     * Entry point for the program
     * @param args String[]
     */
    public static void main(String[] args) {
        new InstantBach();
    }

    /**
     * Contructs the program
     */
    public InstantBach() {

        try {
            service = new Service(this);
        } catch (BadRulesException e) {
            String message = "The following problem was encountered with the rule.txt file:\n"+e.getMessage();
            JOptionPane.showMessageDialog(null,
                                          message,
                                          "Error",
                                          JOptionPane.ERROR_MESSAGE);

            System.exit(0);
        }
        mainFrame = new MainFrame(this, service.getAvailableSymbols());
        mainFrame.setVisible(true);

    }

    /** GUI TIER METHODS */

    /**
     * Displays the the given chords for the given progression
     * @param prog SymbolList
     * @param chords Chord[]
     */
    public void displayChords(SymbolList prog, Chord[] chords) {
        mainFrame.displayChords(prog, chords);
    }

    /**
     * Displays the given error
     * @param errors ArrayList
     */
    public synchronized void displayErrors(ArrayList<String> errors) {
        mainFrame.displayErrors(errors);
    }

    /**
     * Appends the given text to the information area
     * @param line String
     */
    public synchronized void appendInfo(String line) {
        mainFrame.appendInfo(line);
    }

    /** SERVICE TIER METHODS */

    /**
     * Attempts to voice the specified progression
     * @param progression SymbolList
     */
    public synchronized void voiceProgression(SymbolList progression) {
        service.voiceProgression(progression);
    }

    /**
     * Generates a random progression and attempts to voice it
     */
    public synchronized void generateAndVoiceProgression() {
        service.generateAndVoiceProgression();
    }

    /**
     * Returns the list of available symbols
     * @return SymbolList
     */
    public SymbolList getAvailableSymbols() {
        return service.getAvailableSymbols();
    }

    /** OTHER */

    /**
     * Returns the version of this program
     * @return String
     */
    public String getVersion() {
        return this.version;
    }
}
TOP

Related Classes of instantbach.InstantBach

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.