Skip to content

Instantly share code, notes, and snippets.

@CalebWhiting
Last active November 24, 2016 22:43
Show Gist options
  • Save CalebWhiting/1a116fc2d0d9b20927b6 to your computer and use it in GitHub Desktop.
Save CalebWhiting/1a116fc2d0d9b20927b6 to your computer and use it in GitHub Desktop.
DTM Central Class
import java.awt.*;
/**
* @author Caleb Date: 28/03/12 Time: 15:22
*/
public class DTMCentral {
private final Color color;
private final int tolerance;
/**
* @param string "r_g_b_t"
*
* @return returns the String converted into a DTMCentral
*/
public static DTMCentral fromString(final String string) {
final String[] split = string.split("_");
for (int x = 0; x < split.length; x++) {
split[x] = split[x].replaceFirst("_", "");
}
final int r = Integer.parseInt(split[0]);
final int g = Integer.parseInt(split[1]);
final int b = Integer.parseInt(split[2]);
final int t = Integer.parseInt(split[3]);
return new DTMCentral(new Color(r, g, b), t);
}
public DTMCentral(final Color color, final int tolerance) {
this.color = color;
this.tolerance = tolerance;
}
public Color getColor() {
return this.color;
}
public int getTolerance() {
return this.tolerance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment