org.jbudget.util
Class ColorParser

java.lang.Object
  extended by org.jbudget.util.ColorParser

public class ColorParser
extends java.lang.Object

A class that contains functions for saving Colors as strings and creating Color objects from strings.

Author:
petrov

Field Summary
private static java.util.regex.Pattern colorPattern
          A regular expression pattern that is used for parsing the colors
 
Constructor Summary
private ColorParser()
          No need for any instances.
 
Method Summary
static java.lang.String colorToString(java.awt.Color color)
          Creates a string representation of a color.
static java.awt.Color parse(java.lang.String string)
          Parses the string and returns a color object that is represented by the string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colorPattern

private static java.util.regex.Pattern colorPattern
A regular expression pattern that is used for parsing the colors

Constructor Detail

ColorParser

private ColorParser()
No need for any instances.

Method Detail

colorToString

public static java.lang.String colorToString(java.awt.Color color)
Creates a string representation of a color. We assume that the alpha is always 1, so only three rgb values are saved.


parse

public static java.awt.Color parse(java.lang.String string)
Parses the string and returns a color object that is represented by the string. The string should contain three integer rgb values separated by white space

Throws:
java.lang.IllegalArgumentException - if the string can not be parsed.