import java.util.*; public class Model{ private int xPos; // This class calculates the graph bars' horizontal positions private float barlength; // This class calculates the length of the bars Model(){ xPos = 0; barlength = 0; } public int getxPos() { return xPos; } private void setxPos(int xPos) { this.xPos = xPos; } public float getBarlength() { return barlength; } private void setBarlength(float barlength) { barlength = mapRange(barlength, 0, 1023, 0, 300); this.barlength = barlength; } public float mapRange( float s,int i, int j, int k, int l){ return (k + ((s - i)*(l - k))/(j - i)); } public void update(int time, String barL){ if (barL != null) try{ float temp = Float.parseFloat(barL); this.setBarlength(mapRange(temp, 0, 1023, 0, 300)); this.setBarlength(temp); } catch(Exception e){} this.setxPos(time); } }