use of org.asqatasun.contrastFinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.
the class ColorFinderRgb 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()) {
if (colorCombinaison.getContrast() < (getCoefficientLevel() + maxCoefficient)) {
LOGGER.debug("New Contrast" + colorCombinaison.getContrast());
LOGGER.debug("MAX contrast possible" + (getCoefficientLevel() + maxCoefficient));
if (Math.abs((ColorConverter.getHue(newColor) - ColorConverter.getHue(initialColor))) < maxMoveHue) {
getColorResult().addSuggestedColor(colorCombinaison);
LOGGER.debug("Add color with contrast : " + colorCombinaison.getContrast());
} 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());
}
}
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());
}
}
use of org.asqatasun.contrastFinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.
the class ColorFinderHsvPsychoTest method testFindColorsNearColorOrange.
@Test
public void testFindColorsNearColorOrange() {
System.out.println("FindColorsNearColor");
Color foregroundColor = new Color(255, 165, 0);
Color backgroundColor = new Color(255, 255, 255);
Float coefficientLevel = 3f;
ColorFinderHsvPsycho instance = new ColorFinderHsvPsycho();
List<ColorCombinaison> colorCombinaison = new ArrayList<ColorCombinaison>();
instance.getColorFinderKey();
instance.setHueBounder(15.0f);
instance.setMaxCoefficient(0.01f);
instance.setMaxBlue(60.0f);
instance.setMaxGreen(60.0f);
instance.setMaxRed(60.0f);
instance.findColors(foregroundColor, backgroundColor, false, coefficientLevel);
LOGGER.info("Nb SuggestedColors:" + instance.getColorResult().getSuggestedColors().size());
Float initialHue = ColorConverter.getHue(foregroundColor);
int counter = 0;
for (ColorCombinaison combinaisons : instance.getColorResult().getSuggestedColors()) {
LOGGER.info("Color found " + combinaisons.getHexaColor());
}
// if ((ColorConverter.getHue(combinaisons.getColor()) - initialHue) > (10.0f * STEP_HUE)) {
// LOGGER.debug("Color :" + combinaisons.getColor() + " COLOR : " + combinaisons.getContrast());
// counter++;
// }
// else if ((initialHue - ColorConverter.getHue(combinaisons.getColor())) > (10.0f * STEP_HUE)) {
// LOGGER.debug("Color :" + combinaisons.getColor() + " COLOR : " + combinaisons.getContrast());
// counter++;
// }
// // LOGGER.debug("HashCode :" + colorCombinaison.hashCode() + " COLOR : " + combinaisons.getContrast());
// // colorCombinaison.add(combinaisons);
// }
// LOGGER.debug("Out of bound values " + counter );
}
use of org.asqatasun.contrastFinder.result.ColorCombinaison in project Contrast-Finder by Asqatasun.
the class ColorFinderRgbTest method testFindColorsNearColorOrange.
@Test
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 ColorFinderHsvTest method testFindColorsWithFgAndBg.
/**
* Test of findColors method, of class ColorFinderHsv.
*/
@Test
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());
}
Aggregations