* Target.SELF toegevoegd.
* Voormalige Events hernoemd naar States (Press, Release, Hold) --> Nu komt Event vrij als naam voor de parent van Task en toekomstig Feedback --> Exception namen nagelopen, controleren! * Aantal classes verplaatst (Sequence en SequenceListener)
This commit is contained in:
@@ -4,36 +4,36 @@ import java.util.ArrayList;
|
||||
|
||||
import pm.exception.MacroException;
|
||||
import pm.exception.macro.MacroEventOrderException;
|
||||
import pm.macro.Event;
|
||||
import pm.macro.event.Sequence;
|
||||
import pm.macro.event.Hold;
|
||||
import pm.macro.event.Press;
|
||||
import pm.macro.event.Release;
|
||||
import pm.macro.Sequence;
|
||||
import pm.macro.State;
|
||||
import pm.macro.state.Hold;
|
||||
import pm.macro.state.Press;
|
||||
import pm.macro.state.Release;
|
||||
|
||||
public class Macro extends Sequence {
|
||||
public Macro(Press press) {
|
||||
Button button = press.getButton();
|
||||
this.eventArray = new Event[] {press, new Release(button)};
|
||||
this.eventArray = new State[] {press, new Release(button)};
|
||||
}
|
||||
|
||||
public Macro(Event... eventArray) throws MacroException {
|
||||
public Macro(State... eventArray) throws MacroException {
|
||||
ArrayList<Button> holdList = new ArrayList<Button>();
|
||||
ArrayList<Event> eventList = new ArrayList<Event>();
|
||||
for (Event event : eventArray) {
|
||||
Button button = event.getButton();
|
||||
if (event instanceof Press) {
|
||||
ArrayList<State> eventList = new ArrayList<State>();
|
||||
for (State state : eventArray) {
|
||||
Button button = state.getButton();
|
||||
if (state instanceof Press) {
|
||||
if (holdList.contains(button)) {
|
||||
throw new MacroEventOrderException("Press events cannot follow hold events for the same button.");
|
||||
}
|
||||
eventList.add(event);
|
||||
eventList.add(state);
|
||||
eventList.add(new Release(button));
|
||||
} else if (event instanceof Release) {
|
||||
} else if (state instanceof Release) {
|
||||
if (!holdList.contains(button)) {
|
||||
throw new MacroEventOrderException("Cannot release a button that is not held.");
|
||||
}
|
||||
holdList.remove(button);
|
||||
eventList.add(event);
|
||||
} else if (event instanceof Hold) {
|
||||
eventList.add(state);
|
||||
} else if (state instanceof Hold) {
|
||||
if (holdList.contains(button)) {
|
||||
throw new MacroEventOrderException("Cannot hold a button more than once.");
|
||||
}
|
||||
@@ -44,6 +44,6 @@ public class Macro extends Sequence {
|
||||
if (!holdList.isEmpty()) {
|
||||
throw new MacroEventOrderException("One or more buttons are not released.");
|
||||
}
|
||||
eventArray = (Event[]) eventList.toArray(new Event[0]);
|
||||
eventArray = (State[]) eventList.toArray(new State[0]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user