DistributionSensor.java |
package org.lucci.madhoc.simulation.measure; import java.util.Collection; import java.util.Iterator; import org.lucci.madhoc.simulation.projection.Projection; import org.lucci.math.StatisticalCounter; /* * Created on Jul 20, 2004 */ /** * @author luc.hogie */ public abstract class DistributionSensor extends Sensor { /** * Iterating on the set given by <code>getTargetSet()</code> each element * is asked for providing a specific value. This value is used for * building the distribution of this value. * @param object * @return */ public abstract double getTargetedValue(Object object); /** * The set to iterate for harversting values. It is typically the * set of stations in the network, or the set of station applications * of a certain sort. * @return */ public abstract Collection getTargetSet(Projection projection); /** * Return the name of the set to iterate on. This is used * only for presentation purposes. * @return */ public abstract String getTargetSetName(); /** * Return the unit of the distribution. This is used for presentation * purposes only. * @return */ public abstract Unit getYUnit(); /* (non-Javadoc) * @see org.lucci.madhoc.simulation.Measure#getValueClass() */ public Class getValueClass() { return StatisticalCounter.class; } /* (non-Javadoc) * @see org.lucci.madhoc.simulation.Measure#takeNewValue(org.lucci.madhoc.simulation.Simulation) */ public Object takeNewValue(Projection projection) { if (projection == null) throw new IllegalArgumentException("null projection"); StatisticalCounter counter = new StatisticalCounter(); for (Object object : getTargetSet(projection)) { double value = getTargetedValue(object); counter.addItemAt(value); } return counter; } }