@Override protected Color doRestore(final String data) { return new Color(Integer.parseInt(data, 16)); }
@Override protected Color doParse(final Object context, final String text) { try { if (text.startsWith("0x")) { return new Color(Integer.parseInt(text.substring(2), 16)); } else if (text.startsWith("#")) { return new Color(Integer.parseInt(text.substring(1), 16)); } else { return new Color(Integer.parseInt(text)); } } catch (final NumberFormatException e) { throw new TextEntryParseException("Not a number " + text, e); } }
@Override public ObjectAdapter createValue(final ObjectAdapter object, final int colorAsInt) { final Color color = new Color(colorAsInt); return getAdapterMap().adapterFor(color); }
@Override protected ObjectAdapter setFromDBColumn(final Results results, final String columnName, final ObjectAssociation field) { ObjectAdapter restoredValue; final int intValue = results.getInt(columnName); final Color colorValue = new Color(intValue); restoredValue = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(colorValue); return restoredValue; }
@Test public void testTitleOfBlack() { assertEquals("Black", value.displayTitleOf(new Color(0))); }
@Test public void testTitleOfBlack() { assertEquals("Black", value.displayTitleOf(new Color(0), (Localization) null)); }
@Test public void testTitleOfWhite() { assertEquals("White", value.displayTitleOf(new Color(0xffffff), (Localization) null)); }
@Test public void testTitleOfWhite() { assertEquals("White", value.displayTitleOf(new Color(0xffffff))); }
@Before public void setUpObjects() throws Exception { color = new Color(0x3366ff); allowMockAdapterToReturn(color); holder = new FacetHolderImpl(); setValue(value = new ColorValueSemanticsProvider(holder, mockServicesInjector)); }
@Before public void setUpObjects() throws Exception { color = new Color(0x3366ff); allowMockAdapterToReturn(color); holder = new FacetHolderImpl(); setValue(value = new ColorValueSemanticsProvider(holder, mockConfiguration, mockContext)); }
@Test public void testToTitle() throws Exception { assertEquals("Black", Color.BLACK.title()); assertEquals("White", Color.WHITE.title()); assertEquals("#FE231D", new Color(0xfe231D).title()); }