// Path: src/main/java/com/orange/dgil/trail/android/AndroidMetrics.java
// @Getter
// @RequiredArgsConstructor
// public class AndroidMetrics {
//   private static final int MICROMETERS_PER_INCH = 25400;
// 
//   private final float ydpi;
//   private final float density;
//   private final int   widthPixels;
//   private final int   heightPixels;
// 
//   public int getMicrometersPerPixel() {
//     return (int) (MICROMETERS_PER_INCH/ydpi);
//   }
// 
//   public int pixelsToMillimeters(int pixels) {
//     return pixelsToMicrometers(pixels) / 1000;
//   }
// 
//   public int pixelsToMicrometers(int pixels) {
//     return pixels * getMicrometersPerPixel();
//   }
// 
//   public int micrometersToPixels(int micrometers) {
//     return micrometers / getMicrometersPerPixel();
//   }
// 
//   // not unit tested, android stuff
//   public static AndroidMetrics get(Context ctx) {
//     DisplayMetrics metrics = new DisplayMetrics();
//     WindowManager  wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
//     updateMetrics(wm.getDefaultDisplay(), metrics);
//     return new AndroidMetrics(metrics.ydpi, metrics.density, metrics.widthPixels, metrics.heightPixels);
//   }
// 
//   private static void updateMetrics(Display display, DisplayMetrics metrics) {
//     try {
//       doUpdateMetrics(display, metrics);
//     } catch (NoSuchMethodException e) {
//       showErrorAndSetDefaults(e, display, metrics);
//     } catch (IllegalAccessException e) {
//       showErrorAndSetDefaults(e, display, metrics);
//     } catch (InvocationTargetException e) {
//       showErrorAndSetDefaults(e, display, metrics);
//     }
//   }
// 
//   private static void doUpdateMetrics(Display display, DisplayMetrics metrics) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
//     if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17) {
//       updateMetricsBeforeJBMR1(display, metrics);
//     } else if (Build.VERSION.SDK_INT >= 17) {
//       updateMetricsStartingWithJBMR1(display, metrics);
//     } else {
//       throw new NoSuchMethodException("The library does not support devices before android ICE CREAM SANDWICH (api 14)");
//     }
//   }
// 
//   private static void updateMetricsBeforeJBMR1(Display display, DisplayMetrics metrics) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
//     // Mandatory for yDpi & density
//     display.getMetrics(metrics);
//     metrics.widthPixels = (int) Display.class.getMethod("getRawWidth").invoke(display);
//     metrics.heightPixels = (int) Display.class.getMethod("getRawHeight").invoke(display);
//   }
// 
//   private static void updateMetricsStartingWithJBMR1(Display display, DisplayMetrics metrics) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
//     Display.class.getMethod("getRealMetrics", DisplayMetrics.class).invoke(display, metrics);
//   }
// 
//   private static void showErrorAndSetDefaults(Exception e, Display display, DisplayMetrics metrics) {
//     Log.e(AndroidMetrics.class.getName(), String.format("Failed to get metrics, %s, %s", e.getMessage(), e.getClass().getName()));
//     display.getMetrics(metrics);
//   }
// }
// 
// Path: src/main/java/com/orange/dgil/trail/android/animation/AnimManager.java
// public class AnimManager {
// 
//   private final AnimRunnable animRunnable;
//   private final AnimParameters animParameters = new AnimParameters();
// 
//   public AnimManager(IAnimDrawer drawer) {
//     animRunnable = new AnimRunnable(drawer, animParameters);
//   }
// 
//   public void start() {
//     animRunnable.start();
//   }
// 
//   public int getAnimColor() {
//     int startColor = animParameters.getStartColor();
//     int endColor = animParameters.getEndColor();
//     return getInterpolatedColor(startColor, endColor, animRunnable.getFactor());
//   }
// 
//   public int getAnimShadowColor() {
//     int startColor = animParameters.getShadowStartColor();
//     int endColor = animParameters.getShadowEndColor();
//     return getInterpolatedColor(startColor, endColor, animRunnable.getFactor());
//   }
// 
//   private int getInterpolatedColor(int startColor, int endColor, float factor) {
//     return Color.argb(
//         getInterp(Color.alpha(startColor), Color.alpha(endColor), factor),
//         getInterp(Color.red  (startColor), Color.red  (endColor), factor),
//         getInterp(Color.green(startColor), Color.green(endColor), factor),
//         getInterp(Color.blue (startColor), Color.blue (endColor), factor));
//   }
//   private int getInterp(int start, int end, float factor) {
//     return (int) (start * factor + end * (1 - factor));
//   }
// 
// 
//   public float getFactor() {
//     return animRunnable.getFactor();
//   }
// 
//   /**
//    * The width factor is made to dilate the trail during fading
//    * @return the width factor
//    */
//   public float getWidthFactor() {
//     float factor = getFactor();
//     return 1 + animParameters.getWidthDilatationFactor() * (1-factor);
//   }
// 
//   public void reset() {
//     animRunnable.reset();
//   }
// 
//   public AnimParameters getAnimationParameters() {
//     return animParameters;
//   }
// 
//   public boolean isRunning() {
//     return animRunnable.isRunning();
//   }
// 
//   public boolean isAlphaAnimationRunning() {
//     return isRunning() && animParameters.areStartEndColorsRgbEqual();
//   }
// }


import android.view.View;
import com.orange.dgil.trail.android.AndroidMetrics;
import com.orange.dgil.trail.android.animation.AnimManager;
import lombok.Getter;
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.android.drawingtool;




@RequiredArgsConstructor
@Getter
public class DrawingToolsContext {
  private final View view;
// Path: src/main/java/com/orange/dgil/trail/android/AndroidMetrics.java
// @Getter
// @RequiredArgsConstructor
// public class AndroidMetrics {
//   private static final int MICROMETERS_PER_INCH = 25400;
// 
//   private final float ydpi;
//   private final float density;
//   private final int   widthPixels;
//   private final int   heightPixels;
// 
//   public int getMicrometersPerPixel() {
//     return (int) (MICROMETERS_PER_INCH/ydpi);
//   }
// 
//   public int pixelsToMillimeters(int pixels) {
//     return pixelsToMicrometers(pixels) / 1000;
//   }
// 
//   public int pixelsToMicrometers(int pixels) {
//     return pixels * getMicrometersPerPixel();
//   }
// 
//   public int micrometersToPixels(int micrometers) {
//     return micrometers / getMicrometersPerPixel();
//   }
// 
//   // not unit tested, android stuff
//   public static AndroidMetrics get(Context ctx) {
//     DisplayMetrics metrics = new DisplayMetrics();
//     WindowManager  wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
//     updateMetrics(wm.getDefaultDisplay(), metrics);
//     return new AndroidMetrics(metrics.ydpi, metrics.density, metrics.widthPixels, metrics.heightPixels);
//   }
// 
//   private static void updateMetrics(Display display, DisplayMetrics metrics) {
//     try {
//       doUpdateMetrics(display, metrics);
//     } catch (NoSuchMethodException e) {
//       showErrorAndSetDefaults(e, display, metrics);
//     } catch (IllegalAccessException e) {
//       showErrorAndSetDefaults(e, display, metrics);
//     } catch (InvocationTargetException e) {
//       showErrorAndSetDefaults(e, display, metrics);
//     }
//   }
// 
//   private static void doUpdateMetrics(Display display, DisplayMetrics metrics) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
//     if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17) {
//       updateMetricsBeforeJBMR1(display, metrics);
//     } else if (Build.VERSION.SDK_INT >= 17) {
//       updateMetricsStartingWithJBMR1(display, metrics);
//     } else {
//       throw new NoSuchMethodException("The library does not support devices before android ICE CREAM SANDWICH (api 14)");
//     }
//   }
// 
//   private static void updateMetricsBeforeJBMR1(Display display, DisplayMetrics metrics) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
//     // Mandatory for yDpi & density
//     display.getMetrics(metrics);
//     metrics.widthPixels = (int) Display.class.getMethod("getRawWidth").invoke(display);
//     metrics.heightPixels = (int) Display.class.getMethod("getRawHeight").invoke(display);
//   }
// 
//   private static void updateMetricsStartingWithJBMR1(Display display, DisplayMetrics metrics) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
//     Display.class.getMethod("getRealMetrics", DisplayMetrics.class).invoke(display, metrics);
//   }
// 
//   private static void showErrorAndSetDefaults(Exception e, Display display, DisplayMetrics metrics) {
//     Log.e(AndroidMetrics.class.getName(), String.format("Failed to get metrics, %s, %s", e.getMessage(), e.getClass().getName()));
//     display.getMetrics(metrics);
//   }
// }
// 
// Path: src/main/java/com/orange/dgil/trail/android/animation/AnimManager.java
// public class AnimManager {
// 
//   private final AnimRunnable animRunnable;
//   private final AnimParameters animParameters = new AnimParameters();
// 
//   public AnimManager(IAnimDrawer drawer) {
//     animRunnable = new AnimRunnable(drawer, animParameters);
//   }
// 
//   public void start() {
//     animRunnable.start();
//   }
// 
//   public int getAnimColor() {
//     int startColor = animParameters.getStartColor();
//     int endColor = animParameters.getEndColor();
//     return getInterpolatedColor(startColor, endColor, animRunnable.getFactor());
//   }
// 
//   public int getAnimShadowColor() {
//     int startColor = animParameters.getShadowStartColor();
//     int endColor = animParameters.getShadowEndColor();
//     return getInterpolatedColor(startColor, endColor, animRunnable.getFactor());
//   }
// 
//   private int getInterpolatedColor(int startColor, int endColor, float factor) {
//     return Color.argb(
//         getInterp(Color.alpha(startColor), Color.alpha(endColor), factor),
//         getInterp(Color.red  (startColor), Color.red  (endColor), factor),
//         getInterp(Color.green(startColor), Color.green(endColor), factor),
//         getInterp(Color.blue (startColor), Color.blue (endColor), factor));
//   }
//   private int getInterp(int start, int end, float factor) {
//     return (int) (start * factor + end * (1 - factor));
//   }
// 
// 
//   public float getFactor() {
//     return animRunnable.getFactor();
//   }
// 
//   /**
//    * The width factor is made to dilate the trail during fading
//    * @return the width factor
//    */
//   public float getWidthFactor() {
//     float factor = getFactor();
//     return 1 + animParameters.getWidthDilatationFactor() * (1-factor);
//   }
// 
//   public void reset() {
//     animRunnable.reset();
//   }
// 
//   public AnimParameters getAnimationParameters() {
//     return animParameters;
//   }
// 
//   public boolean isRunning() {
//     return animRunnable.isRunning();
//   }
// 
//   public boolean isAlphaAnimationRunning() {
//     return isRunning() && animParameters.areStartEndColorsRgbEqual();
//   }
// }


// Path: src/main/java/com/orange/dgil/trail/android/drawingtool/DrawingToolsContext.java
import android.view.View;
import com.orange.dgil.trail.android.AndroidMetrics;
import com.orange.dgil.trail.android.animation.AnimManager;
import lombok.Getter;
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.android.drawingtool;




@RequiredArgsConstructor
@Getter
public class DrawingToolsContext {
  private final View view;
  private final AnimManager animManager;