/** * Adds an event to the event queue. * * @param event is the event to add to the event queue. */ public void add(Event event) { if (!HiddenAccess.isCriticalEvent(event)) { final int priority = getEventPriority(event.getClass().getName()); HiddenAccess.setEventPriority(event, priority); } addImpl(event); }
/** * Registers the full and simple class name of the specified event and sets the default priority * of the event class. * * @param event an event belonging to the event class to register the class name for etc. */ private void registerEventNames(Event event) { if (!HiddenAccess.isCriticalEvent(event)) { HiddenAccess.setDefaultPriority(event); } final Class<?> type = event.getClass(); eventNames.put(type.getName(), event); // full name with package name eventNames.put(type.getSimpleName(), event); // only the class name }
/** * Dispatches an event for a robot. * * <p>Too old events will not be dispatched and a critical event is always dispatched. * * @param event the event to dispatch to the robot. */ private void dispatch(Event event) { if (robot != null && event != null) { try { // skip too old events if ((event.getTime() > getTime() - MAX_EVENT_STACK) || HiddenAccess.isCriticalEvent(event)) { HiddenAccess.dispatch( event, robot, robotProxy.getStatics(), robotProxy.getGraphicsImpl()); } } catch (Exception ex) { robotProxy.println("SYSTEM: Exception occurred on " + event.getClass().getName()); ex.printStackTrace(robotProxy.getOut()); } } }