コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
 /**
  * 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
 }
コード例 #3
0
 /**
  * Sets the event priority of events belonging to a specific class.
  *
  * @param eventClass is a string with the full class name of the event type to set the priority
  *     for.
  * @param priority is the new priority
  */
 public void setEventPriority(String eventClass, int priority) {
   if (eventClass == null) {
     return;
   }
   final Event event = eventNames.get(eventClass);
   if (event == null) {
     robotProxy.println("SYSTEM: Unknown event class: " + eventClass);
     return;
   }
   if (HiddenAccess.isCriticalEvent(event)) {
     robotProxy.println("SYSTEM: You may not change the priority of a system event.");
   }
   HiddenAccess.setEventPriority(event, priority);
 }
コード例 #4
0
 /**
  * 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());
     }
   }
 }