Skip to content

Commit

Permalink
Contrast-Finder v0.5.0
Browse files Browse the repository at this point in the history
----------------------

  set version to 0.5.0
  typo
  fixed typo DEFAULT_FOREGROUND
  Updated CSS
  Fixed #60 - Added the "required" attribute to the color fields
  Fixed #58 - Associated the user tips with the input fields
  fixed #54 - Upgraded outdated dependencies:: SpringFramework 4.3.9
  #57 Allowed colors by CSS name
  #57 Javascript: allowed colors by CSS name in isValidateColor()
  Updated JS / form.jsp
  fixed #55 (2) - Added "back to the homepage" link when result has errors
  CSS - Fixed .has-error .help-block
  IndexController - Fixed result.hasErrors()
  fixed #55 - Added "back to the homepage" link
  Updated css
  typo
  updated i18n FR
  fixed CSS for <code>
  updated i18n
  Changed DEFAULT_FOREGROUND
  fixed initial colors in results
  Added unit tests
  Added ColorConverter.colorFromStr() and ColorConverter.colorFromRgbStr()
  ColorConverter.formatColorStr() - Allowed rgb format
  #25 Javascript: allowed rgb format in isValidateColor()
  minor fix for ColorConverter.formatColorStr()
  Moved formatColor() into ColorConverter class + added unit tests
  typo
  webapp/(...)/ColorModel.java - a little refactored (2)
  webapp/(...)/ColorModel.java - a little refactored
  Javascript - Replaced change*Sample() functions by changeColorSample()
  Fixed #53 - White space allowed around the color in the form
  Fixed #52 - contrast-finder.conf: added option for debugging
  set version to 0.4.8-dev
  • Loading branch information
dzc34 committed Jun 8, 2017
2 parents 29fe8d0 + 68ba3ef commit 528eb7d
Show file tree
Hide file tree
Showing 33 changed files with 961 additions and 138 deletions.
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@

Contrast-Finder 0.5.0, 2017-06-09
---------------------------------

Features:
- [#25 - Allowed RGB values in the form](https://github.com/Asqatasun/Contrast-Finder/issues/25)
- [#57 - Allowed color names (CSS3) in the form](https://github.com/Asqatasun/Contrast-Finder/issues/57)

Security:
- [#54 - Upgraded SpringFramework to v4.3.9](https://github.com/Asqatasun/Contrast-Finder/issues/54)

Bugs:
- [#53 - White spaces allowed around the color in the form](https://github.com/Asqatasun/Contrast-Finder/issues/53)
- [#55 - Added "back to the homepage" link](https://github.com/Asqatasun/Contrast-Finder/issues/55)
- [#58 - Associated the user tips with the color fields](https://github.com/Asqatasun/Contrast-Finder/issues/58)
- [#60 - Added the "required" attribute to the color fields](https://github.com/Asqatasun/Contrast-Finder/issues/60)

Configuration:
- [#52 - contrast-finder.conf: added option for debugging](https://github.com/Asqatasun/Contrast-Finder/issues/52)

Documentation:
none

Upgrade-o-meter: just replace the .war file and restart Tomcat


Contrast-Finder 0.4.7, 2017-06-01
---------------------------------

Expand All @@ -13,7 +38,7 @@ Bugs:
- [#46 - Fixed maven warnings: 'version' contains an expression but should be a constant](https://github.com/Asqatasun/Contrast-Finder/issues/46)

Configuration:
- [#50 - contrast-finder.conf file: added option to override the default algorithm](https://github.com/Asqatasun/Contrast-Finder/issues/50)
- [#50 - contrast-finder.conf: added option to override the default algorithm](https://github.com/Asqatasun/Contrast-Finder/issues/50)
- [#47 - Added prerequisites for maven (version 3.1)](https://github.com/Asqatasun/Contrast-Finder/issues/47)
- [#49 - Dockerfile: added HEALTHCHECK instruction](https://github.com/Asqatasun/Contrast-Finder/issues/49)

Expand Down
4 changes: 2 additions & 2 deletions contrast-finder-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<parent>
<groupId>org.asqatasun</groupId>
<artifactId>contrast-finder</artifactId>
<version>0.4.7</version>
<version>0.5.0</version>
</parent>
<artifactId>contrast-finder-api</artifactId>
<version>0.4.7</version>
<version>0.5.0</version>
<packaging>jar</packaging>

<name>contrast-finder-api</name>
Expand Down
4 changes: 2 additions & 2 deletions contrast-finder-hsv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<parent>
<groupId>org.asqatasun</groupId>
<artifactId>contrast-finder</artifactId>
<version>0.4.7</version>
<version>0.5.0</version>
</parent>
<artifactId>contrast-finder-hsv</artifactId>
<version>0.4.7</version>
<version>0.5.0</version>
<packaging>jar</packaging>

<name>contrast-finder-hsv</name>
Expand Down
4 changes: 2 additions & 2 deletions contrast-finder-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<parent>
<groupId>org.asqatasun</groupId>
<artifactId>contrast-finder</artifactId>
<version>0.4.7</version>
<version>0.5.0</version>
</parent>
<artifactId>contrast-finder-impl</artifactId>
<version>0.4.7</version>
<version>0.5.0</version>
<packaging>jar</packaging>

<name>contrast-finder-impl</name>
Expand Down
4 changes: 2 additions & 2 deletions contrast-finder-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<parent>
<groupId>org.asqatasun</groupId>
<artifactId>contrast-finder</artifactId>
<version>0.4.7</version>
<version>0.5.0</version>
</parent>
<artifactId>contrast-finder-resources</artifactId>
<version>0.4.7</version>
<version>0.5.0</version>
<name>contrast-finder-resources</name>
<url>https://contrast-finder.org</url>
<organization>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
# default_algorithm=HSV
# default_algorithm=Rgb

# environment
###############################################
# env=debug

# Web analytics Piwik
###############################################
# piwik_analytics_server=
# piwik_analytics_key=

4 changes: 2 additions & 2 deletions contrast-finder-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<parent>
<groupId>org.asqatasun</groupId>
<artifactId>contrast-finder</artifactId>
<version>0.4.7</version>
<version>0.5.0</version>
</parent>
<artifactId>contrast-finder-utils</artifactId>
<version>0.4.7</version>
<version>0.5.0</version>
<packaging>jar</packaging>

<name>contrast-finder-utils</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
package org.asqatasun.utils.colorconvertor;

import java.awt.Color;
import org.asqatasun.utils.colornamelookup.ColorNameLookup;

/**
*
* @author alingua
*/
public final class ColorConverter {
Expand All @@ -38,7 +38,12 @@ public final class ColorConverter {
private static final int RGB_SHORT_HEXA_LENGTH = 3;
private static final int CONVERT_TO_BASE_16 = 16;
private static final int MAX_ANGLE = 360;
private static final String HEXADECIMAL_DICTIONNARY = "[0-9A-Fa-f]+";
private static final int RGB_MIN = 0;
private static final int RGB_MAX = 255;
private static final String HEXADECIMAL_DICTIONNARY = "[0-9A-Fa-f]+"; // FFF, FFFFFF
private static final String HEXADECIMAL_DICTIONNARY_V2 = "^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"; // #FFF, #FFFFFF, FFF, FFFFFF (but not FF or FFFF)
private static final String SHORT_RGB_DICTIONNARY = "^[0-9]{1,3},[0-9]{1,3},[0-9]{1,3}$"; // ex: 255,255,255
private static final String RGB_DICTIONNARY = "^rgb\\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3}\\)$"; // ex: rgb(255,255,255)

/**
* Private constructor, utility class
Expand Down Expand Up @@ -114,6 +119,85 @@ public static Color offsetRgbColor(Color bgColor, int offsetRed, int offsetGreen
return new Color(bgColor.getRed() + offsetRed, bgColor.getGreen() + offsetGreen, bgColor.getBlue() + offsetBlue);
}

/**
* @param colorStr ex: fff, FFF, #fff, #FFF, ffffff, rgb(255,255,255) or 255,255,255, color name (black, darkmagenta, ...)
* @return color in hexadecimal, with '#' appended if necessary, in upper case
*/
public static String formatColorStr(String colorStr) {
String str = colorStr.replaceAll("\\s", ""); // replace ' ', \t, \n, ...
if (str.toLowerCase().matches(RGB_DICTIONNARY)){ // ex: rgb(255,255,255)
colorStr = str.toLowerCase();
}
else if(str.matches(SHORT_RGB_DICTIONNARY)){ // ex: 255,255,255
colorStr = "rgb(" + str + ")";
}
else if(str.matches(HEXADECIMAL_DICTIONNARY_V2)) {
if (str.charAt(0) != '#') {
str = "#" + str;
}
colorStr = str.toUpperCase();
}
else {
ColorNameLookup c = new ColorNameLookup();
String name = c.getColorNameFromStr(str);
if(name != ""){
colorStr = name;
}
}
return colorStr;
}


/**
* @param colorStr ex: fff, FFF, #fff, #FFF, ffffff, rgb(255,255,255) or 255,255,255, color name (black, darkmagenta, ...)
* @return Color object or NULL
*/
public static Color colorFromStr(String colorStr) {
Color color = hex2Rgb(colorStr);
if (color == null) {
color = colorFromRgbStr(colorStr);
if (color == null) {
color = colorFromColorName(colorStr);
}
}
return color;
}


/**
* @param colorStr ex: silver, red, SteelBlue, ...
* @return Color object or NULL
*/
public static Color colorFromColorName(String colorStr) {
colorStr = colorStr.replaceAll("\\s", ""); // replace ' ', \t, \n, ...
ColorNameLookup c = new ColorNameLookup();
return c.getColorFromName(colorStr);
}


/**
* @param colorStr ex: rgb(255,255,255) or 255,255,255
* @return Color object or NULL
*/
public static Color colorFromRgbStr(String colorStr) {
Color color = null;
colorStr = colorStr.toLowerCase().replaceAll("\\s", ""); // replace ' ', \t, \n, ...
if (colorStr.matches(RGB_DICTIONNARY) | colorStr.matches(SHORT_RGB_DICTIONNARY)){ // ex: rgb(255,255,255) or 255,255,255
colorStr = colorStr.replaceAll("rgb\\(","");
colorStr = colorStr.replaceAll("\\)","");
String[] strList = colorStr.split(",");
int r = Integer.parseInt(strList[0]);
int g = Integer.parseInt(strList[1]);
int b = Integer.parseInt(strList[2]);
if( r <= RGB_MAX && g <= RGB_MAX && b <= RGB_MAX
&& r >= RGB_MIN && g >= RGB_MIN && b >= RGB_MIN){
color = new Color(r, g, b);
}
}
return color;
}


/**
* @param colorStr color in short hexadecimal format, example: #FFF or #FFFFFF
* @return the RGB Color from hex Color
Expand Down
Loading

0 comments on commit 528eb7d

Please sign in to comment.