// Path: src/ym2151/DataModel/Common.java
// public class Common {
// 	
// 	/**
// 	 * A Map that holds the different Controller Values<br>
// 	 * There KEYs for the Different Knobs are:
// 	 * <br><br> PAN, FL, CON, AMS, PMS, 
// 	 * <br>OP1_EN, OP2_EN, OP3_EN, OP4_EN, 
// 	 * <br>AMSEN_OP1, AMSEN_OP2, AMSEN_OP3, AMSEN_OP4
// 	 * */
// 	public final ListenerHashMap<String, Integer> map;
// 	
// 	
// 	/**
// 	 * Creates a new Common Data Model for the representation of a Instrument in the Controller
// 	 * */
// 	protected Common(){
// 		map = new ListenerHashMap<String, Integer>();
// 		map.put("VOL", 63);
// 	}
// 	
// 	
// 	/**
// 	 * This is Part of the OPM File Parsing. Use OPMFile to Load a OPM File.
// 	 * @param s the String Values to parse.
// 	 * @return "true" if parsing went OK and "false" if else.
// 	 * */
// 	protected boolean setVars(String[] s){
// 		if(s.length != 8){
// 			return false;
// 		}
// 
// 		map.put("PAN", Integer.parseInt(s[1]));
// 
// 		map.put("FL", Integer.parseInt(s[2]) << 4); //FB
// 
// 		map.put("CON", Integer.parseInt(s[3]) << 4); //ALGO
// 
// 		map.put("AMS", Integer.parseInt(s[4]) << 5);//AMS
// 
// 		map.put("PMS", Integer.parseInt(s[5]) << 4);//PMS
// 
// 		int slot = (Integer.parseInt(s[6]) >> 3) & 0x0F;
// 
// 		map.put("OP1_EN", ((slot) 	  & 0x01) * 127);
// 		map.put("OP3_EN", ((slot >> 1) & 0x01) * 127);
// 		map.put("OP2_EN", ((slot >> 2) & 0x01) * 127);
// 		map.put("OP4_EN", ((slot >> 3) & 0x01) * 127);
// 		
// 		return true;
// 	}
// 	
// 	/**
// 	 * This is Part of the OPM File Creation. Use OPMFile to Save a OPM File.
// 	 * @return the String to add to the OPM File
// 	 * */
// 	protected String toOPM(){
// 		
// 		String sp = "  ";
// 		int PAN = map.get("PAN");
// 		int FL = map.get("FL") >> 4;
// 		int CON = map.get("CON") >> 4;
// 		int AMS = map.get("AMS") >> 5;
// 		int PMS = map.get("PMS") >> 4;
// 		
// 		
// 		int OP1_EN = map.get("OP1_EN") >= 64 ? 1 : 0;
// 		int OP3_EN = map.get("OP3_EN") >= 64 ? 1 : 0;
// 		int OP2_EN = map.get("OP2_EN") >= 64 ? 1 : 0;
// 		int OP4_EN = map.get("OP4_EN") >= 64 ? 1 : 0;
// 		
// 		int SLOT = ((OP1_EN) | (OP3_EN << 1) | (OP2_EN << 2) |(OP4_EN << 3)) << 3;
// 		
// 		return PAN+sp+FL+sp+CON+sp+AMS+sp+PMS+sp+SLOT+sp;
// 	}
// 
// }
// 
// Path: src/ym2151/Swing/ListenerHashMap.java
// public interface HashMapListener<K,V>{
// 	public void valueChanged(K key, V value);
// }


import ym2151.DataModel.Common;
import ym2151.Swing.ListenerHashMap.HashMapListener;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.BoxLayout;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JButton;
		
		//Button to increase the Selected Algorithm
		JButton buttonRight = new JButton("");
		buttonRight.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				int algorithm = algorithmSelector.getAlgorithm();
				
				algorithm = (algorithm+1) % 8;
				algorithmSelector.setAlgorithm(algorithm);
				algorithmChanged(common.map);
				
			}
		});
		pnlAlgControl.add(buttonRight);
	}

	/**
	 * Change the Algorithm in the Data Model if the User Clicked on the Button
	 * */
	private void algorithmChanged(ListenerHashMap<String, Integer> map){
		int algorithm = algorithmSelector.getAlgorithm();
		
		if(map.get("CON")== null || !map.get("CON").equals(algorithm)){
			map.put("CON", algorithm << 4);
		}
	}
	
	/**
	 * Change the Algorithm in the algorithmSelector if it got Changed
	 * */
// Path: src/ym2151/DataModel/Common.java
// public class Common {
// 	
// 	/**
// 	 * A Map that holds the different Controller Values<br>
// 	 * There KEYs for the Different Knobs are:
// 	 * <br><br> PAN, FL, CON, AMS, PMS, 
// 	 * <br>OP1_EN, OP2_EN, OP3_EN, OP4_EN, 
// 	 * <br>AMSEN_OP1, AMSEN_OP2, AMSEN_OP3, AMSEN_OP4
// 	 * */
// 	public final ListenerHashMap<String, Integer> map;
// 	
// 	
// 	/**
// 	 * Creates a new Common Data Model for the representation of a Instrument in the Controller
// 	 * */
// 	protected Common(){
// 		map = new ListenerHashMap<String, Integer>();
// 		map.put("VOL", 63);
// 	}
// 	
// 	
// 	/**
// 	 * This is Part of the OPM File Parsing. Use OPMFile to Load a OPM File.
// 	 * @param s the String Values to parse.
// 	 * @return "true" if parsing went OK and "false" if else.
// 	 * */
// 	protected boolean setVars(String[] s){
// 		if(s.length != 8){
// 			return false;
// 		}
// 
// 		map.put("PAN", Integer.parseInt(s[1]));
// 
// 		map.put("FL", Integer.parseInt(s[2]) << 4); //FB
// 
// 		map.put("CON", Integer.parseInt(s[3]) << 4); //ALGO
// 
// 		map.put("AMS", Integer.parseInt(s[4]) << 5);//AMS
// 
// 		map.put("PMS", Integer.parseInt(s[5]) << 4);//PMS
// 
// 		int slot = (Integer.parseInt(s[6]) >> 3) & 0x0F;
// 
// 		map.put("OP1_EN", ((slot) 	  & 0x01) * 127);
// 		map.put("OP3_EN", ((slot >> 1) & 0x01) * 127);
// 		map.put("OP2_EN", ((slot >> 2) & 0x01) * 127);
// 		map.put("OP4_EN", ((slot >> 3) & 0x01) * 127);
// 		
// 		return true;
// 	}
// 	
// 	/**
// 	 * This is Part of the OPM File Creation. Use OPMFile to Save a OPM File.
// 	 * @return the String to add to the OPM File
// 	 * */
// 	protected String toOPM(){
// 		
// 		String sp = "  ";
// 		int PAN = map.get("PAN");
// 		int FL = map.get("FL") >> 4;
// 		int CON = map.get("CON") >> 4;
// 		int AMS = map.get("AMS") >> 5;
// 		int PMS = map.get("PMS") >> 4;
// 		
// 		
// 		int OP1_EN = map.get("OP1_EN") >= 64 ? 1 : 0;
// 		int OP3_EN = map.get("OP3_EN") >= 64 ? 1 : 0;
// 		int OP2_EN = map.get("OP2_EN") >= 64 ? 1 : 0;
// 		int OP4_EN = map.get("OP4_EN") >= 64 ? 1 : 0;
// 		
// 		int SLOT = ((OP1_EN) | (OP3_EN << 1) | (OP2_EN << 2) |(OP4_EN << 3)) << 3;
// 		
// 		return PAN+sp+FL+sp+CON+sp+AMS+sp+PMS+sp+SLOT+sp;
// 	}
// 
// }
// 
// Path: src/ym2151/Swing/ListenerHashMap.java
// public interface HashMapListener<K,V>{
// 	public void valueChanged(K key, V value);
// }


// Path: src/ym2151/Swing/CommonPanel.java
import ym2151.DataModel.Common;
import ym2151.Swing.ListenerHashMap.HashMapListener;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.BoxLayout;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JButton;

		
		//Button to increase the Selected Algorithm
		JButton buttonRight = new JButton("");
		buttonRight.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				int algorithm = algorithmSelector.getAlgorithm();
				
				algorithm = (algorithm+1) % 8;
				algorithmSelector.setAlgorithm(algorithm);
				algorithmChanged(common.map);
				
			}
		});
		pnlAlgControl.add(buttonRight);
	}

	/**
	 * Change the Algorithm in the Data Model if the User Clicked on the Button
	 * */
	private void algorithmChanged(ListenerHashMap<String, Integer> map){
		int algorithm = algorithmSelector.getAlgorithm();
		
		if(map.get("CON")== null || !map.get("CON").equals(algorithm)){
			map.put("CON", algorithm << 4);
		}
	}
	
	/**
	 * Change the Algorithm in the algorithmSelector if it got Changed
	 * */
	private class AlgorithmSelectorListener implements HashMapListener<String, Integer>{