SensorConverter.java
public class SensorConverter {
 
    private int min;
    private int max;
    private int diff;
 
    private GraphMaker gm;
 
    public SensorConverter(int min, int max) {
        this.min = min;
        this.max = max;
        diff = max - min;
        gm = new GraphMaker(min, max);
    }
 
    public int normalize(int value) {
        if (value > max) {
            max = value;
            diff = max - min;
            gm.setMax(value);
        } else if (value < min) {
            min = value;
            diff = max - min;
            gm.setMin(value);
        }
        gm.drawNext(value);
        return (int) (100 * (0.0 + value - min) / diff);
    }
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License