Package org.apache.isis.applib.value

Examples of org.apache.isis.applib.value.Color


    private Color color;
    private FacetHolder holder;

    @Before
    public void setUpObjects() throws Exception {
        color = new Color(0x3366ff);
        allowMockAdapterToReturn(color);
        holder = new FacetHolderImpl();

        setValue(value = new ColorValueSemanticsProvider(holder, mockConfiguration, mockContext));
    }
View Full Code Here


        assertEquals("#3366FF", value.displayTitleOf(color, (Localization) null));
    }

    @Test
    public void testTitleOfBlack() {
        assertEquals("Black", value.displayTitleOf(new Color(0), (Localization) null));
    }
View Full Code Here

        assertEquals("Black", value.displayTitleOf(new Color(0), (Localization) null));
    }

    @Test
    public void testTitleOfWhite() {
        assertEquals("White", value.displayTitleOf(new Color(0xffffff), (Localization) null));
    }
View Full Code Here

    @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);
        }
    }
View Full Code Here

        }
    }

    @Override
    public String titleString(final Object object, final Localization localization) {
        final Color color = (Color) object;
        return color.title();
    }
View Full Code Here

        return color.title();
    }

    @Override
    public String titleStringWithMask(final Object object, final String usingMask) {
        final Color color = (Color) object;
        return titleString(new DecimalFormat(usingMask), color.intValue());
    }
View Full Code Here

    // Encode, Decode
    // //////////////////////////////////////////////////////////////////

    @Override
    protected String doEncode(final Object object) {
        final Color color = (Color) object;
        return Integer.toHexString(color.intValue());
    }
View Full Code Here

        return Integer.toHexString(color.intValue());
    }

    @Override
    protected Color doRestore(final String data) {
        return new Color(Integer.parseInt(data, 16));
    }
View Full Code Here

    @Override
    public int colorValue(final ObjectAdapter object) {
        if (object == null) {
            return 0;
        }
        final Color color = (Color) object.getObject();
        return color.intValue();
    }
View Full Code Here

        return color.intValue();
    }

    @Override
    public ObjectAdapter createValue(final ObjectAdapter object, final int colorAsInt) {
        final Color color = new Color(colorAsInt);
        return getAdapterManager().adapterFor(color);
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.applib.value.Color

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.