// Path: src/main/java/com/orange/dgil/trail/core/common/TrailPoint.java
// @Getter
// @NoArgsConstructor
// public class TrailPoint {
//   private int x = -1;
//   private int y = -1;
// 
//   public TrailPoint(int x, int y) {
//     set(x, y);
//   }
// 
//   public void set(int x, int y) {
//     this.x = x;
//     this.y = y;
//   }
// 
//   public boolean isSameAs(TrailPoint point) {
//     return x == point.x && y == point.y;
//   }
// 
//   public double getDistanceTo(TrailPoint point) {
//     int dx = x - point.getX();
//     int dy = y - point.getY();
//     return Math.sqrt(dx * dx + dy * dy);
//   }
// 
//   public void deepCopy(TrailPoint point) {
//     x = point.x;
//     y = point.y;
//   }
// }
// 
// Path: src/main/java/com/orange/dgil/trail/core/vecto/linearwindowfilter/LinearWindowFilter.java
// public class LinearWindowFilter {
// 
//   /** window elements weight */
//   private final int[] windowWeights = {1, 2, 1};
// 
//   /** window elements */
//   private final SlidingWindow slidingWindow = new SlidingWindow(windowWeights.length);
// 
//   private final LinearWindowFilterListener linearWindowFilterListener;
// 
//   private int weightsSum;
// 
// 
//   public LinearWindowFilter(LinearWindowFilterListener linearWindowFilterListener) {
//     this.linearWindowFilterListener = linearWindowFilterListener;
//     initProperties();
//   }
// 
//   void initProperties() {
//     weightsSum = getWeightsSum();
//   }
// 
//   int getWeightsSum() {
//     int sum = 0;
//     for (int weight : windowWeights) {
//       sum+= weight;
//     }
//     return sum;
//   }
// 
// 
//   public void reset() {
//     slidingWindow.reset();
//   }
// 
//   public TrailPoint getLastPoint() {
//     return slidingWindow.getLastElement();
//   }
// 
//   public void addPoint(TrailPoint point) {
//     if (!slidingWindow.isSameAsLast(point)) {
//       doAddPoint(point);
//     }
//   }
// 
//   void doAddPoint(TrailPoint point) {
//     slidingWindow.add(point);
//     if (isNewPointAvailable()) {
//       computeNewPointAndNotifyListener();
//     }
//   }
// 
//   boolean isNewPointAvailable() {
//     return slidingWindow.getAddedElementsNumber() == 1 || slidingWindow.isFull();
//   }
// 
//   void computeNewPointAndNotifyListener() {
//     int x;
//     int y;
//     if (slidingWindow.getAddedElementsNumber() == 1) {
//       x = slidingWindow.getX(0);
//       y = slidingWindow.getY(0);
//     } else {
//       x = getMeanX();
//       y = getMeanY();
//     }
//     linearWindowFilterListener.onNewFilteredPointAvailable(x, y);
//   }
// 
//   int getMeanX() {
//     int sumX = 0;
//     for (int i = 0; i < windowWeights.length; i++) {
//       sumX += slidingWindow.getX(i) * windowWeights[i];
//     }
//     return (sumX + weightsSum/2) / weightsSum;
//   }
//   int getMeanY() {
//     int sumY = 0;
//     for (int i = 0; i < windowWeights.length; i++) {
//       sumY += slidingWindow.getY(i) * windowWeights[i];
//     }
//     return (sumY + weightsSum/2) / weightsSum;
//   }
// }
// 
// Path: src/main/java/com/orange/dgil/trail/core/vecto/linearwindowfilter/LinearWindowFilterListener.java
// public interface LinearWindowFilterListener {
//   void onNewFilteredPointAvailable(int x, int y);
// }


import com.orange.dgil.trail.core.common.TrailPoint;
import com.orange.dgil.trail.core.vecto.linearwindowfilter.LinearWindowFilter;
import com.orange.dgil.trail.core.vecto.linearwindowfilter.LinearWindowFilterListener;
import lombok.RequiredArgsConstructor;
/**
 * Trail drawing library
 * Copyright (C) 2014 Orange
 * Authors: christophe.maldivi@orange.com, eric.petit@orange.com
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package com.orange.dgil.trail.core.vecto.vecto;



@RequiredArgsConstructor
public class VectoFilter implements LinearWindowFilterListener, VectoFilterListener {

  private final LinearWindowFilter linearWindowFilter = new LinearWindowFilter(this);
  private final RawVectoFilter rawVectoFilter = new RawVectoFilter(this);
  private final VectoFilterListener vectoFilterListener;
// Path: src/main/java/com/orange/dgil/trail/core/common/TrailPoint.java
// @Getter
// @NoArgsConstructor
// public class TrailPoint {
//   private int x = -1;
//   private int y = -1;
// 
//   public TrailPoint(int x, int y) {
//     set(x, y);
//   }
// 
//   public void set(int x, int y) {
//     this.x = x;
//     this.y = y;
//   }
// 
//   public boolean isSameAs(TrailPoint point) {
//     return x == point.x && y == point.y;
//   }
// 
//   public double getDistanceTo(TrailPoint point) {
//     int dx = x - point.getX();
//     int dy = y - point.getY();
//     return Math.sqrt(dx * dx + dy * dy);
//   }
// 
//   public void deepCopy(TrailPoint point) {
//     x = point.x;
//     y = point.y;
//   }
// }
// 
// Path: src/main/java/com/orange/dgil/trail/core/vecto/linearwindowfilter/LinearWindowFilter.java
// public class LinearWindowFilter {
// 
//   /** window elements weight */
//   private final int[] windowWeights = {1, 2, 1};
// 
//   /** window elements */
//   private final SlidingWindow slidingWindow = new SlidingWindow(windowWeights.length);
// 
//   private final LinearWindowFilterListener linearWindowFilterListener;
// 
//   private int weightsSum;
// 
// 
//   public LinearWindowFilter(LinearWindowFilterListener linearWindowFilterListener) {
//     this.linearWindowFilterListener = linearWindowFilterListener;
//     initProperties();
//   }
// 
//   void initProperties() {
//     weightsSum = getWeightsSum();
//   }
// 
//   int getWeightsSum() {
//     int sum = 0;
//     for (int weight : windowWeights) {
//       sum+= weight;
//     }
//     return sum;
//   }
// 
// 
//   public void reset() {
//     slidingWindow.reset();
//   }
// 
//   public TrailPoint getLastPoint() {
//     return slidingWindow.getLastElement();
//   }
// 
//   public void addPoint(TrailPoint point) {
//     if (!slidingWindow.isSameAsLast(point)) {
//       doAddPoint(point);
//     }
//   }
// 
//   void doAddPoint(TrailPoint point) {
//     slidingWindow.add(point);
//     if (isNewPointAvailable()) {
//       computeNewPointAndNotifyListener();
//     }
//   }
// 
//   boolean isNewPointAvailable() {
//     return slidingWindow.getAddedElementsNumber() == 1 || slidingWindow.isFull();
//   }
// 
//   void computeNewPointAndNotifyListener() {
//     int x;
//     int y;
//     if (slidingWindow.getAddedElementsNumber() == 1) {
//       x = slidingWindow.getX(0);
//       y = slidingWindow.getY(0);
//     } else {
//       x = getMeanX();
//       y = getMeanY();
//     }
//     linearWindowFilterListener.onNewFilteredPointAvailable(x, y);
//   }
// 
//   int getMeanX() {
//     int sumX = 0;
//     for (int i = 0; i < windowWeights.length; i++) {
//       sumX += slidingWindow.getX(i) * windowWeights[i];
//     }
//     return (sumX + weightsSum/2) / weightsSum;
//   }
//   int getMeanY() {
//     int sumY = 0;
//     for (int i = 0; i < windowWeights.length; i++) {
//       sumY += slidingWindow.getY(i) * windowWeights[i];
//     }
//     return (sumY + weightsSum/2) / weightsSum;
//   }
// }
// 
// Path: src/main/java/com/orange/dgil/trail/core/vecto/linearwindowfilter/LinearWindowFilterListener.java
// public interface LinearWindowFilterListener {
//   void onNewFilteredPointAvailable(int x, int y);
// }


// Path: src/main/java/com/orange/dgil/trail/core/vecto/vecto/VectoFilter.java
import com.orange.dgil.trail.core.common.TrailPoint;
import com.orange.dgil.trail.core.vecto.linearwindowfilter.LinearWindowFilter;
import com.orange.dgil.trail.core.vecto.linearwindowfilter.LinearWindowFilterListener;
import lombok.RequiredArgsConstructor;

/**
 * Trail drawing library
 * Copyright (C) 2014 Orange
 * Authors: christophe.maldivi@orange.com, eric.petit@orange.com
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package com.orange.dgil.trail.core.vecto.vecto;



@RequiredArgsConstructor
public class VectoFilter implements LinearWindowFilterListener, VectoFilterListener {

  private final LinearWindowFilter linearWindowFilter = new LinearWindowFilter(this);
  private final RawVectoFilter rawVectoFilter = new RawVectoFilter(this);
  private final VectoFilterListener vectoFilterListener;
  private final TrailPoint trailPoint = new TrailPoint();