@Override public void handleEvent(final PersonArrivalEvent arrivalEvent) { this.doReset(); PersonDepartureEvent departureEvent = this.pendantDepartures.remove(arrivalEvent.getPersonId()); String mode = arrivalEvent.getLegMode(); Frequency frequency; ResizableDoubleArray rawDataElement; // Consistency check... if (departureEvent == null) { log.warn( "One arrival do not correspond to any departure for agent " + arrivalEvent.getPersonId()); return; } else if (!mode.equals(departureEvent.getLegMode())) { log.warn("Departure and arrival have uncompatible modes!"); return; } // consistency check... DONE if (this.frequencies.containsKey(mode)) { frequency = this.frequencies.get(mode); rawDataElement = this.rawData.get(mode); } else { frequency = new Frequency(); rawDataElement = new ResizableDoubleArray(); this.frequencies.put(mode, frequency); this.rawData.put(mode, rawDataElement); } double xyVal = 0.0; if (this.xy.equals("times")) { xyVal = this.computeTimes(arrivalEvent, departureEvent); } else { xyVal = this.computeDistances(arrivalEvent, departureEvent); } // remember data frequency.addValue(xyVal); rawDataElement.addElement(xyVal); }
/** * Adds 1 to the frequency count for v. * * @param v the value to add. */ public void addValue(char v) { addValue(Character.valueOf(v)); }
/** * Adds 1 to the frequency count for v. * * @param v the value to add. */ public void addValue(long v) { addValue(Long.valueOf(v)); }
/** * Adds 1 to the frequency count for v. * * @param v the value to add. */ public void addValue(int v) { addValue(Long.valueOf(v)); }