// Path: engine/api/src/main/java/org/asqatasun/contrastfinder/result/factory/ColorCombinaisonFactory.java
// public interface ColorCombinaisonFactory {
// 
//     /**
//      *
//      * @param color1
//      * @param color2
//      * @param threashold
//      * @return a ColorCombinaison instance
//      */
//     ColorCombinaison getColorCombinaison(Color color1, Color color2, Double threashold);
// 
// }
// 
// Path: engine/utils/src/main/java/org/asqatasun/utils/distancecalculator/DistanceCalculator.java
// public final class DistanceCalculator {
// 
//     private static final int CUBIC = 3;
//     private static final int ROUND_VALUE = 100;
// 
//     private DistanceCalculator() {
//     }
// 
//     /**
//      *
//      * @param colorToChange
//      * @param colorToKeep
//      * @return the calculated distance between 2 colors regarding the
//      * distance definition that can be found here
//      * http://en.wikipedia.org/wiki/Euclidean_distance#Three_dimensions
//      */
//     public static double calculate(Color colorToChange, Color colorToKeep) {
//         return (double) Math.round(Math.abs((Math.cbrt(Math.pow(Double.valueOf(colorToChange.getRed()) - Double.valueOf(colorToKeep.getRed()), CUBIC)
//                 + Math.pow(Double.valueOf(colorToChange.getGreen()) - Double.valueOf(colorToKeep.getGreen()), CUBIC)
//                 + Math.pow(Double.valueOf(colorToChange.getBlue()) - Double.valueOf(colorToKeep.getBlue()), CUBIC)))) * ROUND_VALUE) / ROUND_VALUE;
//     }
// }


import java.awt.Color;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import org.asqatasun.contrastfinder.result.factory.ColorCombinaisonFactory;
import org.asqatasun.utils.distancecalculator.DistanceCalculator;
    public Float getThreashold() {
        return Float.valueOf(submittedColors.getThreshold().floatValue());
    }

    @Override
    public void setSubmittedColors(Color colorToChange, Color colorToKeep, Float threashold) {
        submittedColors =
                colorCombinaisonFactory.getColorCombinaison(
                colorToChange,
                colorToKeep,
                Double.valueOf(threashold));
    }

    @Override
    public ColorCombinaison getSubmittedCombinaisonColor() {
        return submittedColors;
    }

    @Override
    public boolean isCombinaisonValid() {
        return submittedColors.isContrastValid();
    }

    @Override
    public Collection<ColorCombinaison> getSuggestedColors() {
        return suggestedColors;
    }

    @Override
    public void addSuggestedColor(ColorCombinaison colorCombinaison) {
// Path: engine/api/src/main/java/org/asqatasun/contrastfinder/result/factory/ColorCombinaisonFactory.java
// public interface ColorCombinaisonFactory {
// 
//     /**
//      *
//      * @param color1
//      * @param color2
//      * @param threashold
//      * @return a ColorCombinaison instance
//      */
//     ColorCombinaison getColorCombinaison(Color color1, Color color2, Double threashold);
// 
// }
// 
// Path: engine/utils/src/main/java/org/asqatasun/utils/distancecalculator/DistanceCalculator.java
// public final class DistanceCalculator {
// 
//     private static final int CUBIC = 3;
//     private static final int ROUND_VALUE = 100;
// 
//     private DistanceCalculator() {
//     }
// 
//     /**
//      *
//      * @param colorToChange
//      * @param colorToKeep
//      * @return the calculated distance between 2 colors regarding the
//      * distance definition that can be found here
//      * http://en.wikipedia.org/wiki/Euclidean_distance#Three_dimensions
//      */
//     public static double calculate(Color colorToChange, Color colorToKeep) {
//         return (double) Math.round(Math.abs((Math.cbrt(Math.pow(Double.valueOf(colorToChange.getRed()) - Double.valueOf(colorToKeep.getRed()), CUBIC)
//                 + Math.pow(Double.valueOf(colorToChange.getGreen()) - Double.valueOf(colorToKeep.getGreen()), CUBIC)
//                 + Math.pow(Double.valueOf(colorToChange.getBlue()) - Double.valueOf(colorToKeep.getBlue()), CUBIC)))) * ROUND_VALUE) / ROUND_VALUE;
//     }
// }


// Path: engine/impl/src/main/java/org/asqatasun/contrastfinder/result/ColorResultImpl.java
import java.awt.Color;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import org.asqatasun.contrastfinder.result.factory.ColorCombinaisonFactory;
import org.asqatasun.utils.distancecalculator.DistanceCalculator;

    public Float getThreashold() {
        return Float.valueOf(submittedColors.getThreshold().floatValue());
    }

    @Override
    public void setSubmittedColors(Color colorToChange, Color colorToKeep, Float threashold) {
        submittedColors =
                colorCombinaisonFactory.getColorCombinaison(
                colorToChange,
                colorToKeep,
                Double.valueOf(threashold));
    }

    @Override
    public ColorCombinaison getSubmittedCombinaisonColor() {
        return submittedColors;
    }

    @Override
    public boolean isCombinaisonValid() {
        return submittedColors.isContrastValid();
    }

    @Override
    public Collection<ColorCombinaison> getSuggestedColors() {
        return suggestedColors;
    }

    @Override
    public void addSuggestedColor(ColorCombinaison colorCombinaison) {
        colorCombinaison.setDistanceFromInitialColor(DistanceCalculator.calculate(submittedColors.getColor(), colorCombinaison.getColor()));