/** * EventCatcher constructor that receives a list of event classes it is supposed to record, and the RecordedEventStore that * will store said event classes. * @param selectedClassesToRecord A list of classes that should be recorded and sent to the RecordedEventStore. * @param recordedEventStore The Store that will save the events selected to be recorded. */ public EventCatcher(List<Class<?>> selectedClassesToRecord, RecordedEventStore recordedEventStore) { this.selectedClassesToRecord = selectedClassesToRecord; this.eventCopier = new EventCopier(); this.recordedEventStore = recordedEventStore; }
} else if (toBeCopied instanceof BindButtonEvent) { BindButtonEvent originalEvent = (BindButtonEvent) toBeCopied; BindButtonEvent newEvent = (BindButtonEvent) createNewBindEvent(originalEvent); newEvent.prepare(originalEvent.getId(), originalEvent.getState(), originalEvent.getDelta()); inputEventSetup(newEvent, originalEvent); return newEvent; } else if (toBeCopied instanceof KeyEvent) { KeyEvent originalEvent = (KeyEvent) toBeCopied; KeyEvent newEvent = createNewKeyEvent(originalEvent); inputEventSetup(newEvent, originalEvent); return newEvent; } else if (toBeCopied instanceof BindAxisEvent) { BindAxisEvent originalEvent = (BindAxisEvent) toBeCopied; BindAxisEvent newEvent = (BindAxisEvent) createNewBindEvent(originalEvent); newEvent.prepare(originalEvent.getId(), originalEvent.getValue(), originalEvent.getDelta()); inputEventSetup(newEvent, originalEvent); return newEvent; } else if (toBeCopied instanceof MouseAxisEvent) { MouseAxisEvent originalEvent = (MouseAxisEvent) toBeCopied; MouseAxisEvent newEvent = createNewMouseAxisEvent(originalEvent); inputEventSetup(newEvent, originalEvent); return newEvent; } else if (toBeCopied instanceof CameraTargetChangedEvent) { MouseButtonEvent newEvent = new MouseButtonEvent(originalEvent.getButton(), originalEvent.getState(), originalEvent.getDelta()); newEvent.setMousePosition(originalEvent.getMousePosition()); inputEventSetup(newEvent, originalEvent); return newEvent; } else if (toBeCopied instanceof MouseWheelEvent) {
/** * Receives a PendingEvent and add it as a RecordedEvent in the RecordedEventStore if it is an event type that should be * recorded. * @param pendingEvent PendingEvent to be checked and added * @return If the event was added to the RecordedEventStore */ public boolean addEvent(PendingEvent pendingEvent) { if (shouldRecordEvent(pendingEvent)) { long timestamp = System.currentTimeMillis() - this.startTime; Event e = this.eventCopier.copyEvent(pendingEvent.getEvent()); PendingEvent newPendingEvent = new PendingEvent(pendingEvent.getEntity(), e); RecordedEvent recordedEvent; if (pendingEvent.getComponent() == null) { recordedEvent = new RecordedEvent(newPendingEvent.getEntity().getId(), newPendingEvent.getEvent(), timestamp, this.eventCounter); } else { recordedEvent = new RecordedEvent(newPendingEvent.getEntity().getId(), newPendingEvent.getEvent(), newPendingEvent.getComponent(), timestamp, eventCounter); } this.eventCounter++; return recordedEventStore.add(recordedEvent); } else { return false; } }