Example usage for org.apache.commons.configuration DataConfiguration getColor

List of usage examples for org.apache.commons.configuration DataConfiguration getColor

Introduction

In this page you can find the example usage for org.apache.commons.configuration DataConfiguration getColor.

Prototype

public Color getColor(String key) 

Source Link

Document

Get a Color associated with the given configuration key.

Usage

From source file:org.debux.webmotion.server.ConfigurationTest.java

@Test
public void testData() throws ConfigurationException {
    PropertiesConfiguration test = new PropertiesConfiguration();
    test.load(new StringReader("color=#0000FF"));

    DataConfiguration configuration = new DataConfiguration(test);
    AssertJUnit.assertNotNull(configuration.getColor("color"));
}

From source file:pl.otros.logview.gui.message.pattern.StyleProperties.java

public static Style getStyle(StyleContext styleContext, DataConfiguration styleConfig, String styleName,
        int group) {
    Style style = styleContext.addStyle(styleName, styleContext.getStyle(StyleContext.DEFAULT_STYLE));

    String groupSuffix = "." + group;
    if (group <= 0) {
        groupSuffix = "";
    }/*from   w  w  w  . j a  v  a2s  .c om*/

    String fontFamily = styleConfig.getString(PROP_FONT_FAMILY + groupSuffix, "");
    if (fontFamily.trim().length() > 0) {
        StyleConstants.setFontFamily(style, styleConfig.getString(PROP_FONT_FAMILY + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_SIZE + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setFontSize(style, styleConfig.getInt(PROP_FONT_SIZE + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_BOLD + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setBold(style, styleConfig.getBoolean(PROP_FONT_BOLD + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_ITALIC + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setItalic(style, styleConfig.getBoolean(PROP_FONT_ITALIC + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_UNDERLINE + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setUnderline(style, styleConfig.getBoolean(PROP_FONT_UNDERLINE + groupSuffix));
    }

    if (styleConfig.getString(PROP_BACKGROUND + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setBackground(style, styleConfig.getColor(PROP_BACKGROUND + groupSuffix));
    }

    if (styleConfig.getString(PROP_FOREGROUND + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setForeground(style, styleConfig.getColor(PROP_FOREGROUND + groupSuffix));
    }
    return style;
}