Example usage for java.awt Color decode

List of usage examples for java.awt Color decode

Introduction

In this page you can find the example usage for java.awt Color decode.

Prototype

public static Color decode(String nm) throws NumberFormatException 

Source Link

Document

Converts a String to an integer and returns the specified opaque Color .

Usage

From source file:probe.com.model.util.vaadintoimageutil.HeatmapSwingComponent.java

private JPanel initCell(String color, int x, int y) {
    JPanel cell = new JPanel();
    cell.setSize(50, 50);/*www . j  a  v  a2s . c  o  m*/
    cell.setBackground(Color.decode(color));
    cell.setOpaque(true);
    cell.setLocation(x, y);
    cell.setBorder(new LineBorder(Color.WHITE));
    return cell;

}

From source file:me.openMap.ApplicationSettings.java

/**
 * //w w w . ja v  a 2 s.co m
 */
private ApplicationSettings() {
    gradParms.add(new GradientParameters(Color.decode("#A0A0FF"), Color.BLUE, 0.1, 29.9, 15, 95));
    gradParms.add(new GradientParameters(Color.BLUE, Color.GREEN, 30, 29.9, 10, 95));
    gradParms.add(new GradientParameters(Color.GREEN, Color.YELLOW, 60.0, 19.9, 10, 95));
    gradParms.add(new GradientParameters(Color.YELLOW, Color.decode("#FF0000"), 80.0, 9.9, 10, 95));
    gradParms.add(new GradientParameters(Color.decode("#FF0000"), Color.RED, 90.0, 10.0, 10, 95));
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.RadarChartExpressionTest.java

@Test
public void testComputeChart() {
    System.out.println("Start");
    RadarChartExpression radarChart = new RadarChartExpression();
    TableModel tm = new AggregateTestDataTableModel();
    Map<String, Object> data = new HashMap<String, Object>();
    CollectorFunctionResult cfr = Mockito.mock(CollectorFunctionResult.class);
    Mockito.when(cfr.getDataSet()).thenReturn(Mockito.mock(org.jfree.data.general.Dataset.class));

    data.put("name1", cfr);
    StaticDataRow dr = new StaticDataRow(data);
    ProcessingContext pc = new DefaultProcessingContext();
    DebugExpressionRuntime der = new DebugExpressionRuntime(dr, tm, 0, pc);
    radarChart.setRuntime(der);/*from  w  w w . ja  v  a  2s  . c  om*/
    radarChart.setSeriesColor(new String[] { "maroon", "#FDDF00" });
    radarChart.setDataSource("name1");
    JFreeChartReportDrawable chart = (JFreeChartReportDrawable) radarChart.getValue();
    Assert.assertTrue("first color is maroon : ", (((SpiderWebPlot) chart.getChart().getPlot())
            .getSeriesPaint(0).equals(ColorHelper.lookupColor("maroon"))));
    Assert.assertTrue("second color is #FDDF00 : ",
            (((SpiderWebPlot) chart.getChart().getPlot()).getSeriesPaint(1).equals(Color.decode("#FDDF00"))));
    System.out.println("Finish");
}

From source file:org.sonar.server.charts.deprecated.CustomBarChart.java

private void configureColors(String colorsParam) {
    Paint[] colors = CustomBarRenderer.COLORS;
    if (colorsParam != null && colorsParam.length() > 0) {
        StringTokenizer stColors = new StringTokenizer(colorsParam, ",");
        colors = new Paint[stColors.countTokens()];
        int i = 0;
        while (stColors.hasMoreTokens()) {
            colors[i] = Color.decode("0x" + stColors.nextToken());
            i++;//from   w w w  . j a  va2 s .  c o  m
        }
    }

    renderer.setColors(colors);
}

From source file:org.orbisgis.view.toc.actions.cui.legend.components.ColorScheme.java

/**
 * Parses the given String and adds the results in the collections.
 * @param line The line to be parsed.//  w ww  . j  a va 2 s. com
 */
private static void add(String line) {
    StringTokenizer tokenizer = new StringTokenizer(line, ",");
    String name = tokenizer.nextToken();
    boolean range = tokenizer.nextToken().equals("range");
    (range ? rangeColorSchemeNames : discreteColorSchemeNames).add(name);
    List<Color> list = new ArrayList<Color>();
    while (tokenizer.hasMoreTokens()) {
        String hex = tokenizer.nextToken();
        Assert.isTrue(hex.length() == 6, hex);
        list.add(Color.decode("#" + hex));
    }
    nameToColorsMap().put(name, list);
}

From source file:org.sonar.api.charts.AbstractChart.java

/**
 * Helper to set color of series. If the parameter colorsHex is null, then default Sonar colors are used.
 *///from   w  w  w.j  a  v  a2 s  .  c om
protected void configureColors(Values2D dataset, CategoryPlot plot, String[] colorsHex) {
    Color[] colors = COLORS;
    if (colorsHex != null && colorsHex.length > 0) {
        colors = new Color[colorsHex.length];
        for (int i = 0; i < colorsHex.length; i++) {
            colors[i] = Color.decode("#" + colorsHex[i]);
        }
    }

    dataset.getColumnCount();
    AbstractRenderer renderer = (AbstractRenderer) plot.getRenderer();
    for (int i = 0; i < dataset.getColumnCount(); i++) {
        renderer.setSeriesPaint(i, colors[i % colors.length]);

    }
}

From source file:org.saiku.adhoc.utils.TemplateUtils.java

/**
 * Converts a webcolor string to a awt color.
 * //w  w w .j  a v a  2s .c o m
 * @param str
 * @return
 */
private static Color strToColor(String str) {
    if (str != null) {
        return Color.decode(str.replaceFirst("#", "0x"));
    } else {
        return null;
    }
}

From source file:fr.exanpe.t5.lib.services.ExanpeLibraryModule.java

public static void contributeTypeCoercer(
        @SuppressWarnings("rawtypes") Configuration<CoercionTuple> configuration) {
    configuration.add(CoercionTuple.create(String.class, SecurePasswordEventTypeEnum.class,
            StringToEnumCoercion.create(SecurePasswordEventTypeEnum.class)));
    configuration.add(CoercionTuple.create(String.class, AccordionEventTypeEnum.class,
            StringToEnumCoercion.create(AccordionEventTypeEnum.class)));
    configuration.add(CoercionTuple.create(String.class, DialogRenderModeEnum.class,
            StringToEnumCoercion.create(DialogRenderModeEnum.class)));
    configuration.add(CoercionTuple.create(String.class, SliderOrientationTypeEnum.class,
            StringToEnumCoercion.create(SliderOrientationTypeEnum.class)));
    configuration.add(CoercionTuple.create(String.class, MenuEventTypeEnum.class,
            StringToEnumCoercion.create(MenuEventTypeEnum.class)));
    configuration.add(CoercionTuple.create(String.class, PasswordStrengthCheckerTypeEnum.class,
            StringToEnumCoercion.create(PasswordStrengthCheckerTypeEnum.class)));
    configuration.add(CoercionTuple.create(String.class, GMapTypeEnum.class,
            StringToEnumCoercion.create(GMapTypeEnum.class)));

    // ColorPicker
    Coercion<String, Color> coercionStringColor = new Coercion<String, Color>() {
        public Color coerce(String input) {
            if (StringUtils.isEmpty(input))
                return null;
            return Color.decode("0x" + input);
        }//from w  ww . j a v a2  s .c o m
    };

    configuration.add(new CoercionTuple<String, Color>(String.class, Color.class, coercionStringColor));

    Coercion<Color, String> coercionColorString = new Coercion<Color, String>() {
        public String coerce(Color input) {
            if (input == null)
                return null;

            String rgb = Integer.toHexString(input.getRGB());
            rgb = rgb.substring(2, rgb.length());
            return rgb;
        }
    };

    configuration.add(new CoercionTuple<Color, String>(Color.class, String.class, coercionColorString));
}

From source file:org.pentaho.ui.xul.swing.tags.SwingHbox.java

@Override
public void layout() {
    resetContainer();/*from  w  ww . j a  v  a  2  s  . c  o  m*/
    if (getBgcolor() != null) {
        container.setOpaque(true);
        container.setBackground(Color.decode(getBgcolor()));
    }
    super.layout();
}

From source file:se.trixon.jota.client.ui.SpeedDialButton.java

void updateColor() {
    if (mJob == null || !ClientOptions.INSTANCE.isCustomColors()) {
        setBackground(null);/*  www .j  ava  2  s. c  om*/
        setForeground(null);
    } else {
        try {
            Job job = mManager.getServerCommander().getJob(mJobId);
            //if (StringUtils.isNotBlank(job.getColorBackground())) {
            //    setBackground(Color.decode(job.getColorBackground()));
            //}
            if (StringUtils.isNotBlank(job.getColorForeground())) {
                setForeground(Color.decode(job.getColorForeground()));
            }
        } catch (RemoteException | NumberFormatException ex) {
            setBackground(null);
            setForeground(null);
        }
    }
}