Chromeshesia.java
package chromesthesia0;

import painter.SPainter;
import javax.swing.SwingUtilities;
import java.util.Scanner;
import javax.swing.JOptionPane;


public class Chromeshesia {
    //Infrastructure For The Program -- Launching A "Graphics" Thread

    public static void main(String[] args){
        SwingUtilities.invokeLater(new ThreadForGUI());
    }
    private static class ThreadForGUI implements Runnable{
        @Override
        public void run(){
            new Chromeshesia();
        }
    }

    public Chromeshesia(){
        interpreter();
    }
    //Featured Variables
    private static SPainter miro;
    private static Pitch[] pitches;

//The Interpreter
public static void interpreter(){
    initialization();//miro and pitches
    while (true){
    String input = getInput();
    if (input.equalsIgnoreCase("EXIT")) {
        break;
    }else{
        try{
            playMelody(input,pitches);
            } catch (Exception ex){
            showErrorMEssage(ex.toString());
        }
    }
  }
    cleanup(); //Miro has to go
 }
 //Methods Pertaining to the Chromesthetic Pitches
 private static Pitch[] establishPitches(SPainter painter) {
     Pitch[] pitches = new Pitch[9];
     Pitch pitchMiddleC = new Pitch("C", painter);
     pitches[0] = pitchMiddleC;
     Pitch pitchLowC = new Pitch("C,", painter);
     pitches[1] = pitchLowC;
     Pitch pitchHighC = new Pitch("c", painter);
     pitches[2] = pitchHighC;
     Pitch pitchMiddleD = new Pitch("D", painter);
     pitches[3] = pitchMiddleD;
     Pitch pitchLowD = new Pitch("D,", painter);
     pitches[4] = pitchLowD;
     Pitch pitchHighD = new Pitch("d", painter);
     pitches[5] = pitchHighD;
     Pitch pitchMiddleE = new Pitch("E", painter);
     pitches[6] = pitchMiddleE;
     Pitch pitchLowE = new Pitch("E,", painter);
     pitches[7] = pitchLowE;
     Pitch pitchHighE = new Pitch("e", painter);
     pitches[8] = pitchHighE;
     return pitches;
 }
 private static Pitch find(String token, Pitch[] pitches)throws Exception{
    for (int i = 0; i < pitches.length; i++){
        Pitch pitch = pitches[i];
        if (pitch.abcName().equals(token)){
            return pitch;
        }
    }
    throw new Exception("### PITCH" + token + "NOT FOUND");
 }

private static void display(Pitch[] pitches){
    for (int i = 0; i  < pitches.length; i = i + 1 ) {
        System.out.println(pitches[i].toString());
    }
}

private static void playMelody(String input, Pitch[] pitches) throws Exception{
    Scanner scanner = new Scanner(input);
    while (scanner.hasNext()){
        String token = scanner.next();
        Pitch pitch = find(token, pitches);
        pitch.play("1");
    }
}
//Initalization,Cleanup, Getting Input, Error Messaging
    static private void showErrorMEssage(String message){
    miro.setVisible(false);
    JOptionPane.showMessageDialog(null, message);
    }
    private static void initialization(){
    //Establish The Painter And Give It A Substantial Brush Width
        miro = new SPainter("Chromesthesia",500,500);
        miro.setVisible(false);
        miro.setBrushWidth(7);
        //Establish The ChromesthesiaPitch Class Object
        pitches = establishPitches(miro);
        display(pitches);
}
private static String getInput(){
    miro.setVisible(false);
    String label = "Please enter A melody in ABC notation or EXIT";
    String input = JOptionPane.showInputDialog(null,label);
    miro.setVisible(true);
    if ( input == null) {
        input = "";}
    return input;
    }
    static private void cleanup(){
    System.exit(0);
    }
}