Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Map<Long, Double> mapAxisX = new HashMap<>();
- private int countAxisXTimes;
- private double countAxisXSum;
- @Override public double calculateMiddleVarOfAxisX(double axisX) {
- long current = System.currentTimeMillis();
- countAxisXTimes++;
- countAxisXSum += axisX;
- mapAxisX.put(current, axisX);
- if (mapAxisX.size() == 1) {
- return axisX;
- }
- Iterator iterator = mapAxisX.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry<Long, Double> point = (Map.Entry) iterator.next();
- long pointTime = point.getKey();
- long difference = current - pointTime;
- if (difference > 2000) {
- double val = point.getValue();
- countAxisXTimes--;
- countAxisXSum -= val;
- iterator.remove();
- }
- }
- double result = countAxisXSum / countAxisXTimes;
- //Logger.logGeneral(String.valueOf(result) + " size : " + mapAxisX.size());
- return result;
- }
- axisX = presenter.calculateMiddleVarOfAxisX(event.values[0]);
- axisX = presenter.calculateMiddleVarOfAxisX(event.values[0]);
- axisY = presenter.calculateMiddleVarOfAxisX(event.values[1]);
- axisX = presenter.calculateMiddleVarOfAxisX(event.values[0]);
- axisY = presenter.calculateMiddleVarOfAxisX(event.values[1]);
Add Comment
Please, Sign In to add comment