Package nl.tudelft.simulation.dsol.animation.gis.parser

## Class ColorParser

- java.lang.Object
- - nl.tudelft.simulation.dsol.animation.gis.parser.ColorParser

    public final class ColorParser
    extends Object

ColorParser parses a string that contains a color as rgb(r,g,b), rgba(r,g,b,a), or hex #rrggbb or #rrggbbaa.

Copyright (c) 2022-2022 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information DSOL Manual. The DSOL project is distributed under a three-clause BSD-style license, which can be found at DSOL License.

Author:
  Alexander Verbraeck

### Method Summary

All Methods Static Methods Concrete Methods
`static Color` `parse​(String colorString)` Parse a string that contains a color as rgb(r,g,b), rgba(r,g,b,a), or hex #rrggbb or #rrggbbaa.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### parse

    public static Color parse​(String colorString)
                       throws IllegalArgumentException

Parse a string that contains a color as rgb(r,g,b), rgba(r,g,b,a), or hex #rrggbb or #rrggbbaa. When the string is empty or contains "null", null is returned.

Parameters:
  `colorString` - String; the textual representation of the color
Returns:
  Color; the parsed color, or null in casethe input was "null" or empty
Throws:
  `IllegalArgumentException` - when the text representation is not valid
  `IllegalArgumentException` - if r, g, b or a are outside of the range0 to 255, inclusive
  `NumberFormatException` - when one of the r, g, b, or a values could not be converted from string to int