// Path: contrast-finder-api/src/main/java/org/opens/colorfinder/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: contrast-finder-utils/src/main/java/org/opens/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.opens.colorfinder.result.factory.ColorCombinaisonFactory;
import org.opens.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: contrast-finder-api/src/main/java/org/opens/colorfinder/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: contrast-finder-utils/src/main/java/org/opens/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: contrast-finder-impl/src/main/java/org/opens/colorfinder/result/ColorResultImpl.java
import java.awt.Color;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import org.opens.colorfinder.result.factory.ColorCombinaisonFactory;
import org.opens.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()));