use of org.asqatasun.contrastFinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.
the class ColorFinderHsvTest method testFindColorsGreenAlert2.
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());
}
use of org.asqatasun.contrastFinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.
the class ColorFinderHsvTest method testFindColorsWithFgAndBg.
/**
* Test of findColors method, of class ColorFinderHsv.
*/
public void testFindColorsWithFgAndBg() {
System.out.println("FindColorsWithFgAndBg");
Color foregroundColor = new Color(127, 127, 127);
Color backgroundColor = new Color(128, 128, 128);
Float coefficientLevel = 4.5f;
ColorFinderHsv instance = new ColorFinderHsv();
instance.findColors(foregroundColor, backgroundColor, true, coefficientLevel);
List<ColorCombinaison> colorCombinaison = new ArrayList<ColorCombinaison>();
for (ColorCombinaison combinaisons : instance.getColorResult().getSuggestedColors()) {
LOGGER.debug("HashCode :" + combinaisons.hashCode() + " COLOR : " + combinaisons.getContrast());
colorCombinaison.add(combinaisons);
}
int sizeList = colorCombinaison.size();
Color firstColor = new Color(2, 2, 2);
assertEquals(firstColor, colorCombinaison.get(0).getColor());
Color mediumColor = new Color(28, 10, 10);
assertEquals(mediumColor, colorCombinaison.get(4).getColor());
Color endColor = new Color(28, 3, 3);
assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor());
}
use of org.asqatasun.contrastFinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.
the class ColorFinderHsvTest method testFindColorsBornWhite.
public void testFindColorsBornWhite() {
System.out.println("FindColorsBornWhite");
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, true, 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(105, 105, 105);
assertEquals(firstColor, colorCombinaison.get(0).getColor());
Color mediumColor = new Color(155, 94, 94);
assertEquals(mediumColor, colorCombinaison.get(4).getColor());
Color endColor = new Color(230, 1, 1);
assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor());
}
use of org.asqatasun.contrastFinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.
the class ColorFinderRgbTest method testFindColorsNearColorOrange.
public void testFindColorsNearColorOrange() {
System.out.println("FindColorsNearColor");
Color foregroundColor = new Color(255, 255, 255);
Color backgroundColor = new Color(255, 192, 7);
Float coefficientLevel = 3.0f;
ColorFinderRgb instance = new ColorFinderRgb();
List<ColorCombinaison> colorCombinaison = new ArrayList<ColorCombinaison>();
instance.findColors(foregroundColor, backgroundColor, true, coefficientLevel);
LOGGER.info("nb SuggestedColors: " + instance.getColorResult().getSuggestedColors().size());
for (ColorCombinaison combinaisons : instance.getColorResult().getSuggestedColors()) {
LOGGER.info("Color found " + combinaisons.getHexaColor());
}
}
use of org.asqatasun.contrastFinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.
the class ColorFinderHsvPsycho method addNewColorValid.
/**
* @param newColor
*/
private void addNewColorValid(Color newColor) {
ColorCombinaison colorCombinaison = getColorCombinaisonFactory().getColorCombinaison(newColor, getColorToKeep(), Double.valueOf(getCoefficientLevel()));
Color initialColor = getColorResult().getSubmittedCombinaisonColor().getColor();
/**/
if (colorCombinaison.isContrastValid()) {
/* Is contrast within bounds ie. the actual coefficient plus the max allowed coefficient difference */
if (colorCombinaison.getContrast() < (getCoefficientLevel() + maxCoefficient)) {
/**/
if (Math.abs((ColorConverter.getHue(newColor) - ColorConverter.getHue(initialColor))) < (hueBounder * UNITARY_STEP_HUE)) {
/**/
if (Math.abs(newColor.getRed() - initialColor.getRed()) <= maxRed) {
/**/
if (Math.abs(newColor.getGreen() - initialColor.getGreen()) <= maxGreen) {
/**/
if (Math.abs(newColor.getBlue() - initialColor.getBlue()) <= maxBlue) {
LOGGER.debug("Add new color " + newColor);
getColorResult().addSuggestedColor(colorCombinaison);
} else {
LOGGER.debug("blue out of bounf " + newColor);
}
} else {
LOGGER.debug("green out of bounf " + newColor);
}
} else {
LOGGER.debug("red out of bounf " + newColor);
}
} else {
LOGGER.debug("hue out of bound " + newColor);
}
} else {
LOGGER.debug("contrast too high " + newColor + " , " + colorCombinaison.getContrast());
}
} else {
LOGGER.debug("contrast invalide " + newColor + " , " + colorCombinaison.getContrast());
}
}
Aggregations