ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyColorRGBA, Poolable { public static ColorRGBA parseColor(final String colorString, final ColorRGBA store) { ColorRGBA rVal = store; if (rVal == null) { rVal = new ColorRGBA(); } if (colorString.length() == 0 || colorString.charAt(0) != '#') { throw new IllegalArgumentException("must start with #."); } float r = 1, g = 1, b = 1, a = 1; final int length = colorString.length(); if (length == 2) { r = Integer.parseInt(colorString.substring(1, 2), 16) / 15f; g = b = r; a = 1; } else if (length == 3) { r = Integer.parseInt(colorString.substring(1, 2), 16) / 15f; g = b = r; a = Integer.parseInt(colorString.substring(2, 3), 16) / 15f; } else if (length == 4) { r = Integer.parseInt(colorString.substring(1, 2), 16) / 15f; g = Integer.parseInt(colorString.substring(2, 3), 16) / 15f; b = Integer.parseInt(colorString.substring(3, 4), 16) / 15f; a = 1; } else if (length == 5) { r = Integer.parseInt(colorString.substring(1, 2), 16) / 15f; g = Integer.parseInt(colorString.substring(2, 3), 16) / 15f; b = Integer.parseInt(colorString.substring(3, 4), 16) / 15f; a = Integer.parseInt(colorString.substring(4, 5), 16) / 15f; } else if (length == 7) { r = Integer.parseInt(colorString.substring(1, 3), 16) / 255f; g = Integer.parseInt(colorString.substring(3, 5), 16) / 255f; b = Integer.parseInt(colorString.substring(5, 7), 16) / 255f; a = 1; } else if (length == 9) { r = Integer.parseInt(colorString.substring(1, 3), 16) / 255f; g = Integer.parseInt(colorString.substring(3, 5), 16) / 255f; b = Integer.parseInt(colorString.substring(5, 7), 16) / 255f; a = Integer.parseInt(colorString.substring(7, 9), 16) / 255f; } else { throw new IllegalArgumentException("unsupported value, must be 1, 2, 3, 4, 5, 7 or 9 hexvalues: " + colorString); } rVal.set(r, g, b, a); return rVal; } ColorRGBA();  ColorRGBA(final ReadOnlyColorRGBA src);  ColorRGBA(final float r, final float g, final float b, final float a); @Override float getRed(); @Override float getGreen(); @Override float getBlue(); @Override float getAlpha(); @Override float getValue(final int index); void setValue(final int index, final float value); @Override float[] toArray(float[] store); void setRed(final float r); void setGreen(final float g); void setBlue(final float b); void setAlpha(final float a); ColorRGBA set(final float r, final float g, final float b, final float a); ColorRGBA set(final ReadOnlyColorRGBA source); ColorRGBA zero(); @Override ColorRGBA clamp(final ColorRGBA store); ColorRGBA clampLocal(); static ColorRGBA randomColor(final ColorRGBA store); @Override int asIntARGB(); @Override int asIntRGBA(); ColorRGBA fromIntARGB(final int color); ColorRGBA fromIntRGBA(final int color); @Override String asHexRRGGBBAA(); @Override ColorRGBA add(final float r, final float g, final float b, final float a, final ColorRGBA store); ColorRGBA addLocal(final float r, final float g, final float b, final float a); @Override ColorRGBA add(final ReadOnlyColorRGBA source, final ColorRGBA store); ColorRGBA addLocal(final ReadOnlyColorRGBA source); @Override ColorRGBA subtract(final float r, final float g, final float b, final float a, final ColorRGBA store); ColorRGBA subtractLocal(final float r, final float g, final float b, final float a); @Override ColorRGBA subtract(final ReadOnlyColorRGBA source, final ColorRGBA store); ColorRGBA subtractLocal(final ReadOnlyColorRGBA source); @Override ColorRGBA multiply(final float scalar, final ColorRGBA store); ColorRGBA multiplyLocal(final float scalar); @Override ColorRGBA multiply(final ReadOnlyColorRGBA scale, final ColorRGBA store); ColorRGBA multiplyLocal(final ReadOnlyColorRGBA scale); @Override ColorRGBA divide(final float scalar, final ColorRGBA store); ColorRGBA divideLocal(final float scalar); @Override ColorRGBA divide(final ReadOnlyColorRGBA scale, final ColorRGBA store); ColorRGBA divideLocal(final ReadOnlyColorRGBA scale); @Override ColorRGBA lerp(final ReadOnlyColorRGBA endColor, final float scalar, final ColorRGBA store); ColorRGBA lerpLocal(final ReadOnlyColorRGBA endColor, final float scalar); static ColorRGBA lerp(final ReadOnlyColorRGBA beginColor, final ReadOnlyColorRGBA endColor, final float scalar,
      final ColorRGBA store); ColorRGBA lerpLocal(final ReadOnlyColorRGBA beginColor, final ReadOnlyColorRGBA endColor, final float scalar); static boolean isValid(final ReadOnlyColorRGBA color); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object o); @Override ColorRGBA clone(); @Override Class<? extends ColorRGBA> getClassTag(); @Override void write(final OutputCapsule capsule); @Override void read(final InputCapsule capsule); @Override void readExternal(final ObjectInput in); @Override void writeExternal(final ObjectOutput out); final static ColorRGBA fetchTempInstance(); final static void releaseTempInstance(final ColorRGBA color); static ColorRGBA parseColor(final String colorString, final ColorRGBA store); static final ReadOnlyColorRGBA BLACK; static final ReadOnlyColorRGBA BLACK_NO_ALPHA; static final ReadOnlyColorRGBA WHITE; static final ReadOnlyColorRGBA DARK_GRAY; static final ReadOnlyColorRGBA GRAY; static final ReadOnlyColorRGBA LIGHT_GRAY; static final ReadOnlyColorRGBA RED; static final ReadOnlyColorRGBA GREEN; static final ReadOnlyColorRGBA BLUE; static final ReadOnlyColorRGBA YELLOW; static final ReadOnlyColorRGBA MAGENTA; static final ReadOnlyColorRGBA CYAN; static final ReadOnlyColorRGBA ORANGE; static final ReadOnlyColorRGBA BROWN; static final ReadOnlyColorRGBA PINK; }
@Test(expected = IllegalArgumentException.class) public void testHexFail1() { ColorRGBA.parseColor("000", null); }
@Test(expected = IllegalArgumentException.class) public void testHexFail2() { ColorRGBA.parseColor("#000000000000000000000", null); }