/** * Internal method for adding an event to the event queue. * * @param event is the event to add to the event queue. */ private void addImpl(Event event) { if (eventQueue != null) { if (eventQueue.size() > MAX_QUEUE_SIZE) { robotProxy.println( "Not adding to " + robotProxy.getStatics().getName() + "'s queue, exceeded " + MAX_QUEUE_SIZE + " events in queue."); } else { HiddenAccess.setEventTime(event, getTime()); eventQueue.add(event); } } }
/** * 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()); } } }