jaitools.numeric.Processor Maven / Gradle / Ivy
Show all versions of jt-all Show documentation
/*
* Copyright 2009-2010 Michael Bedward
*
* This file is part of jai-tools.
*
* jai-tools is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* jai-tools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with jai-tools. If not, see .
*
*/
package jaitools.numeric;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* Defines methods that must be implemented by statistics processors
* working with {@code StreamingSampleStats}.
*
* @see Statistic
* @see StreamingSampleStats
*
* @author Michael Bedward
* @author Daniele Romagnoli, GeoSolutions S.A.S.
* @since 1.0
* @version $Id: Processor.java 1504 2011-03-05 10:56:10Z michael.bedward $
*/
public interface Processor {
/**
* Gets the {@code Statistics} supported by this processor.
*
* @return supported {@code Statistics}
*/
public Collection getSupported();
/**
* Sets a range of values to be considered as NoData. Processors
* count the number of NoData values offered as samples but exclude them from
* calculations.
*
* NoData ranges take precedence over included / excluded data ranges.
*
* @param noData a range of values to be excluded
*/
public void addNoDataRange(Range noData);
/**
* Convenience method to specify a single value to be considered as NoData.
*
* @param noData the value to be treated as NoData
*
* @see #addNoDataRange
*/
public void addNoDataValue(Double noData);
/**
* Sets a range of values to exclude from or include in calculations.
* Note that you can only add ranges of the same type to a Processor.
*
* @param range a range of values to be checked
*
* @param rangeType the type of range
*
* @throws IllegalArgumentException if {@code rangeType} is different to that
* of a previously added range.
*/
public void addRange(Range range, final Range.Type rangeType);
/**
* Sets a range of values to exclude from or include in from
* calculations. Ie. if a sample value in this range is offered it will
* be ignored or accepted with the behavior depending on which
* range type has been set previously.
*
* @param range the range
*/
public void addRange(Range range);
/**
* Sets the type of the ranges to be added to the processor.
* It is worth to point out that this method can be called only one time in case the rangesType
* haven't been specified at construction time and no ranges have been added yet.
*
* @param rangeType the type of range.
*/
public void setRangesType(Range.Type rangeType);
/**
* Gets the type of ranges being used by this processor.
*
* @return the rangesType of this processor
*/
public Range.Type getRangesType();
/**
* Gets the ranges of sample values to be considered as NoData.
*
* @return the NoData {@code Ranges} or an empty list if no NoData are defined
*/
public List> getNoDataRanges();
/**
* Gets the {@code Ranges} of sample values excluded from/included in calculations.
*
* @return the {@code Ranges} or an empty list if no ranges are defined
*/
public List> getRanges();
/**
* Tests whether a sample value will be accepted for calculations by
* the processor.
*
* @param sample the sample value
*
* @return true if the sample is accepted in compliance with the ranges settings.
* false otherwise
*/
public boolean isAccepted(Double sample);
/**
* Offers a sample value to the processor.
*
* @param sample the sample value
*/
public void offer(Double sample);
/**
* Gets the number of samples that have been offered to this processor.
*
* @return number of samples offered
*/
public long getNumOffered();
/**
* Gets the number of samples that have been accepted by this processor
* (ie. contributed to the calculations).
*
* @return number of samples used for calculations
*/
public long getNumAccepted();
/**
* Gets the number of NaN samples passed to the processor
*
* @return number of NaN samples
*/
public long getNumNaN();
/**
* Gets the number of NoData samples passed to the processor. This count
* includes values in user-specified NoData ranges as well as Double.NaN values.
*
* @return number of NoData samples
*
* @see #addNoDataRange(jaitools.numeric.Range)
* @see #addNoDataValue(java.lang.Double)
*/
public long getNumNoData();
/**
* Gets the value of the statistic calculated by this processor.
*
* @param stat the specified statistic
*
* @return the value of the statistic if it has been calculated or
* Double.NaN otherwise
*
* @throws IllegalArgumentException if {@code stat} is not supported
* by this processor
*/
public Double get(Statistic stat) throws IllegalArgumentException;
/**
* Gets the value of all statistics calculated by this processor.
*
* @return the calculated statistic(s)
*/
public Map get();
}