Skip to content

Commit

Permalink
Attach Script names to enums, better defaults
Browse files Browse the repository at this point in the history
resolves #4
  • Loading branch information
Sammy1Am committed May 2, 2018
1 parent 3c7291a commit f85383f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public class MoppyConfig {

@Data
public static class MIDIScriptMapperConfig {
private String conditionChoice = "Custom";
private String conditionChoice = ConditionScripts.ALL_EVENTS.displayName();
private String conditionCustomScript = ConditionScripts.ALL_EVENTS.toString();
private String deviceAddressChoice = "Custom";
private String deviceAddressChoice = DeviceAddressScripts.DEVICE_ONE.displayName();
private String deviceAddressCustomScript = DeviceAddressScripts.DEVICE_ONE.toString();
private String subAddressChoice = "Custom";
private String subAddressChoice = SubAddressScripts.SUB_ADDRESS_PER_CHANNEL.displayName();
private String subAddressCustomScript = SubAddressScripts.SUB_ADDRESS_PER_CHANNEL.toString();
private String noteChoice = "Custom";
private String noteChoice = NoteScripts.STRAIGHT_THROUGH.displayName();
private String noteCustomScript = NoteScripts.STRAIGHT_THROUGH.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ public class MapperPanel extends javax.swing.JPanel {
private static final Map<String, String> NOTE_MAP = new HashMap<>();

static {
CONDITION_MAP.put("All Events", ConditionScripts.ALL_EVENTS.toString());
CONDITION_MAP.put("Channels 1-4", ConditionScripts.CHANNELS_ONE_TO_FOUR.toString());
CONDITION_MAP.put("Only Supported Notes", ConditionScripts.ONLY_SUPPORTED_NOTES.toString());
CONDITION_MAP.put(ConditionScripts.ALL_EVENTS.displayName(), ConditionScripts.ALL_EVENTS.toString());
CONDITION_MAP.put(ConditionScripts.CHANNELS_ONE_TO_FOUR.displayName(), ConditionScripts.CHANNELS_ONE_TO_FOUR.toString());
CONDITION_MAP.put(ConditionScripts.ONLY_SUPPORTED_NOTES.displayName(), ConditionScripts.ONLY_SUPPORTED_NOTES.toString());
CONDITION_MAP.put("Custom", "");

DEVICEADDRESS_MAP.put("Device 1", DeviceAddressScripts.DEVICE_ONE.toString());
DEVICEADDRESS_MAP.put("One Device per Channel", DeviceAddressScripts.ONE_DEVICE_PER_CHANNEL.toString());
DEVICEADDRESS_MAP.put(DeviceAddressScripts.DEVICE_ONE.displayName(), DeviceAddressScripts.DEVICE_ONE.toString());
DEVICEADDRESS_MAP.put(DeviceAddressScripts.ONE_DEVICE_PER_CHANNEL.displayName(), DeviceAddressScripts.ONE_DEVICE_PER_CHANNEL.toString());
DEVICEADDRESS_MAP.put("Custom", "");

SUBADDRESS_MAP.put("Sub Address per Channel", SubAddressScripts.SUB_ADDRESS_PER_CHANNEL.toString());
SUBADDRESS_MAP.put(SubAddressScripts.SUB_ADDRESS_PER_CHANNEL.displayName(), SubAddressScripts.SUB_ADDRESS_PER_CHANNEL.toString());
SUBADDRESS_MAP.put("Custom", "");

NOTE_MAP.put("Force Into Range", NoteScripts.FORCE_INTO_RANGE.toString());
NOTE_MAP.put("Ignore out of Range", NoteScripts.IGNORE_OUT_OF_RANGE.toString());
NOTE_MAP.put("Straight Through", NoteScripts.STRAIGHT_THROUGH.toString());
NOTE_MAP.put(NoteScripts.FORCE_INTO_RANGE.displayName(), NoteScripts.FORCE_INTO_RANGE.toString());
NOTE_MAP.put(NoteScripts.IGNORE_OUT_OF_RANGE.displayName(), NoteScripts.IGNORE_OUT_OF_RANGE.toString());
NOTE_MAP.put(NoteScripts.STRAIGHT_THROUGH.displayName(), NoteScripts.STRAIGHT_THROUGH.toString());
NOTE_MAP.put("Custom", "");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
*
*/
public enum ConditionScripts {

ALL_EVENTS("true"),
CHANNELS_ONE_TO_FOUR("c>=1 && c<=4"),
ONLY_SUPPORTED_NOTES("n>22 && n<67");

private final String script;

private ConditionScripts(String s) {
ALL_EVENTS("All Events", "true"),
CHANNELS_ONE_TO_FOUR("Channels 1-4", "c>=1 && c<=4"),
ONLY_SUPPORTED_NOTES("Only Supported Notes", "n>22 && n<67");

private final String displayName;
private final String script;

private ConditionScripts(String d, String s) {
displayName = d;
script = s;
}

@Override
public String toString() {
return this.script;
}

public String displayName() {
return this.displayName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
*
*/
public enum DeviceAddressScripts {

DEVICE_ONE("1"),
ONE_DEVICE_PER_CHANNEL("c+1");

private final String script;

private DeviceAddressScripts(String s) {
DEVICE_ONE("Device 1", "1"),
ONE_DEVICE_PER_CHANNEL("One Device per Channel", "c+1");

private final String displayName;
private final String script;

private DeviceAddressScripts(String d, String s) {
displayName = d;
script = s;
}

@Override
public String toString() {
return this.script;
}

public String displayName() {
return this.displayName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
*
*/
public enum NoteScripts {

STRAIGHT_THROUGH("n"),
IGNORE_OUT_OF_RANGE("(n>22 && n<67) ? n : null"),
FORCE_INTO_RANGE("((n-22)%48)+22");

private final String script;

private NoteScripts(String s) {
STRAIGHT_THROUGH("Straight Through", "n"),
IGNORE_OUT_OF_RANGE("Ignore out of Range", "(n>22 && n<67) ? n : null"),
FORCE_INTO_RANGE("Force into Range", "((n-22)%48)+22");

private final String displayName;
private final String script;

private NoteScripts(String d, String s) {
displayName = d;
script = s;
}

@Override
public String toString() {
return this.script;
}

public String displayName() {
return this.displayName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@
*
*/
public enum SubAddressScripts {

SUB_ADDRESS_PER_CHANNEL("c+1");

private final String script;

private SubAddressScripts(String s) {
SUB_ADDRESS_PER_CHANNEL("Sub-address per Channel", "c+1");

private final String displayName;
private final String script;

private SubAddressScripts(String d, String s) {
displayName = d;
script = s;
}

@Override
public String toString() {
return this.script;
}

public String displayName() {
return this.displayName;
}
}

0 comments on commit f85383f

Please sign in to comment.