Search in sources :

Example 26 with ColorCombinaison

use of org.asqatasun.contrastfinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.

the class ColorFinderHsvTest method testFindColorsWithFgAndBg2.

@Test
public void testFindColorsWithFgAndBg2() {
    System.out.println("FindColorsWithFgAndBg2");
    Color foregroundColor = new Color(127, 127, 127);
    Color backgroundColor = new Color(128, 128, 128);
    Float coefficientLevel = 4.5f;
    ColorFinderHsv instance = new ColorFinderHsv();
    List<ColorCombinaison> colorCombinaison = new ArrayList<ColorCombinaison>();
    instance.findColors(foregroundColor, backgroundColor, false, coefficientLevel);
    for (ColorCombinaison combinaisons : instance.getColorResult().getSuggestedColors()) {
        LOGGER.debug("HashCode :" + colorCombinaison.hashCode() + "    COLOR : " + combinaisons.getContrast());
        colorCombinaison.add(combinaisons);
    }
    int sizeList = colorCombinaison.size();
    Color firstColor = new Color(1, 1, 1);
    assertEquals(firstColor, colorCombinaison.get(0).getColor());
    Color mediumColor = new Color(27, 15, 15);
    assertEquals(mediumColor, colorCombinaison.get(4).getColor());
    Color endColor = new Color(52, 4, 4);
    assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor());
}
Also used : ColorCombinaison(org.asqatasun.contrastfinder.result.ColorCombinaison) Color(java.awt.Color) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 27 with ColorCombinaison

use of org.asqatasun.contrastfinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.

the class ColorFinderHsvTest method testFindColorsBornWhite2.

@Test
public void testFindColorsBornWhite2() {
    System.out.println("FindColorsBornWhite2");
    Color foregroundColor = new Color(254, 254, 254);
    Color backgroundColor = new Color(255, 255, 255);
    Float coefficientLevel = 4.5f;
    ColorFinderHsv instance = new ColorFinderHsv();
    List<ColorCombinaison> colorCombinaison = new ArrayList<ColorCombinaison>();
    instance.findColors(foregroundColor, backgroundColor, false, coefficientLevel);
    for (ColorCombinaison combinaisons : instance.getColorResult().getSuggestedColors()) {
        LOGGER.debug("HashCode :" + colorCombinaison.hashCode() + "    COLOR : " + combinaisons.getContrast());
        colorCombinaison.add(combinaisons);
    }
    int sizeList = colorCombinaison.size();
    Color firstColor = new Color(104, 104, 104);
    assertEquals(firstColor, colorCombinaison.get(0).getColor());
    Color mediumColor = new Color(154, 93, 93);
    assertEquals(mediumColor, colorCombinaison.get(4).getColor());
    Color endColor = new Color(229, 4, 4);
    assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor());
}
Also used : ColorCombinaison(org.asqatasun.contrastfinder.result.ColorCombinaison) Color(java.awt.Color) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 28 with ColorCombinaison

use of org.asqatasun.contrastfinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.

the class AbstractColorFinder method isNewColorValid.

/**
 * @param newColor
 * @return
 */
protected boolean isNewColorValid(Color newColor) {
    ColorCombinaison colorCombinaison = colorCombinaisonFactory.getColorCombinaison(newColor, colorToKeep, Double.valueOf(coefficientLevel));
    if (colorCombinaison.isContrastValid() && colorCombinaison.getContrast() < (coefficientLevel + MAX_COEFFICIENT_LEVEL)) {
        LOGGER.debug("Adding a color to list : " + newColor.getRed() + " " + newColor.getGreen() + " " + newColor.getBlue() + " Contrast : " + ContrastChecker.getConstrastRatio(newColor, colorToKeep));
        colorResult.addSuggestedColor(colorCombinaison);
        return true;
    }
    return false;
}
Also used : ColorCombinaison(org.asqatasun.contrastfinder.result.ColorCombinaison)

Example 29 with ColorCombinaison

use of org.asqatasun.contrastfinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.

the class ColorFinderHsvTest method testFindColorsGreenAlert2.

@Test
public void testFindColorsGreenAlert2() {
    System.out.println("FindColorsGreenAlert2");
    Color foregroundColor = new Color(70, 136, 71);
    Color backgroundColor = new Color(223, 240, 216);
    Float coefficientLevel = 4.5f;
    ColorFinderHsv instance = new ColorFinderHsv();
    List<ColorCombinaison> colorCombinaison = new ArrayList<ColorCombinaison>();
    instance.findColors(foregroundColor, backgroundColor, false, coefficientLevel);
    for (ColorCombinaison combinaisons : instance.getColorResult().getSuggestedColors()) {
        LOGGER.debug("HashCode :" + colorCombinaison.hashCode() + "    COLOR : " + combinaisons.getContrast());
        colorCombinaison.add(combinaisons);
    }
    int sizeList = colorCombinaison.size();
    Color firstColor = new Color(57, 111, 58);
    assertEquals(firstColor, colorCombinaison.get(0).getColor());
    Color mediumColor = new Color(79, 86, 79);
    assertEquals(mediumColor, colorCombinaison.get(4).getColor());
    Color endColor = new Color(136, 70, 133);
    assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor());
}
Also used : ColorCombinaison(org.asqatasun.contrastfinder.result.ColorCombinaison) Color(java.awt.Color) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 30 with ColorCombinaison

use of org.asqatasun.contrastfinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.

the class ColorFinderHsvTest method testFindColorsNearColor2.

@Test
public void testFindColorsNearColor2() {
    System.out.println("FindColorsNearColor2");
    Color foregroundColor = new Color(255, 165, 0);
    Color backgroundColor = new Color(255, 255, 255);
    Float coefficientLevel = 4.5f;
    ColorFinderHsv instance = new ColorFinderHsv();
    List<ColorCombinaison> colorCombinaison = new ArrayList<ColorCombinaison>();
    instance.getColorFinderKey();
    instance.findColors(foregroundColor, backgroundColor, false, coefficientLevel);
    for (ColorCombinaison combinaisons : instance.getColorResult().getSuggestedColors()) {
        LOGGER.debug("HashCode :" + colorCombinaison.hashCode() + "    COLOR : " + combinaisons.getContrast());
        colorCombinaison.add(combinaisons);
    }
}
Also used : ColorCombinaison(org.asqatasun.contrastfinder.result.ColorCombinaison) Color(java.awt.Color) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Color (java.awt.Color)28 ArrayList (java.util.ArrayList)24 ColorCombinaison (org.asqatasun.contrastFinder.result.ColorCombinaison)15 ColorCombinaison (org.asqatasun.contrastfinder.result.ColorCombinaison)15 Test (org.junit.Test)12