List of usage examples for java.awt Color decode
public static Color decode(String nm) throws NumberFormatException
From source file:ColorGradient.java
/** * Get the gradient start and end colors as applet parameter values, and * parse them using Color.decode(). If they are malformed, use white. *//*w w w . j a v a 2 s .c o m*/ public void init() { try { startColor = Color.decode(getParameter("startColor")); endColor = Color.decode(getParameter("endColor")); } catch (Exception e) { startColor = Color.yellow; endColor = Color.red; } bigFont = new Font("Helvetica", Font.BOLD, 72); }
From source file:probe.com.model.util.vaadintoimageutil.Convertor.java
public Convertor() { backgroundMap.put("blue", Color.decode("#bcd3de")); backgroundMap.put("white", Color.decode("#fff")); backgroundMap.put("black", Color.decode("#1e2022"));// backgroundMap.put("", Color.decode("#f5f5f5")); }
From source file:com.github.fritaly.graphml4j.Utils.java
/** * Decodes the given hexadecimal string (like "#RRGGBBAA" or "#RRGGBB" * (whether the transparency is set to 0)) into an instance of {@link Color} * ./*from ww w .j av a 2 s . c o m*/ * * @param value * a string representing the encoded color.Can't be null. * @return a {@link Color}. */ static Color decode(String value) { Validate.notNull(value, "The given encoded value is null"); if (value.length() == 9) { final int i = Integer.decode(value).intValue(); return new Color((i >> 24) & 0xFF, (i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF); } return Color.decode(value); }
From source file:HtmlColor.java
/** * Decode HTML-attribute style of color to {@link Color} * @param color - color name or #RRGGBB string * @return - color for this value./*w w w .j ava 2s .c om*/ */ public static Color decode(String color) { if (null == color) { throw new IllegalArgumentException("NULL_COLOR_PARAMETER_ERROR"); } Color c = (Color) colorNames.get(color.trim().toLowerCase()); if (null == c) { try { c = Color.decode(color.trim()); } catch (NumberFormatException e) { throw new IllegalArgumentException("DECODE_COLOR_PARAMETER_ERROR"); } } return c; }
From source file:se.trixon.jota.client.ui.editor.module.job.JobAppearancePanel.java
@Override public void loadJob(Job job) { if (StringUtils.isNotBlank(job.getColorBackground())) { previewButton.setBackground(Color.decode(job.getColorBackground())); }/*from w w w . jav a2 s. c om*/ if (StringUtils.isNotBlank(job.getColorForeground())) { previewButton.setForeground(Color.decode(job.getColorForeground())); } }
From source file:org.tros.utils.converters.ColorConverter.java
/** * Convert./*from w w w .j av a2 s . c o m*/ * * @param <T> * @param type * @param value * @return */ @Override @SuppressWarnings("unchecked") public <T> T convert(Class<T> type, Object value) { if (type == String.class) { if (value.getClass() == Color.class) { Color c = (Color) value; return (T) String.format("#%02x%02x%02x", c.getRed(), c.getGreen(), c.getBlue()); } else { return (T) value; } } else { try { return (T) Color.class.getField(value.toString()).get(null); } catch (NoSuchFieldException ex) { } catch (SecurityException | IllegalArgumentException | IllegalAccessException ex) { } return (T) Color.decode(value.toString()); } }
From source file:org.sonar.plugins.ral.GaugeChart.java
@Override protected Plot getPlot(ChartParameters params) { ThermometerPlot plot = new ThermometerPlot(createDataset(params)); plot.setGap(1);/*from ww w . jav a2s. com*/ plot.setRange(0, 1); plot.setSubrange(0, 0, 1); plot.setSubrangePaint(0, Color.decode("#ffffff")); plot.setSubrangePaint(1, Color.decode("#ffffff")); plot.setSubrangePaint(2, Color.decode("#ffffff")); plot.setMercuryPaint(Color.decode("#dddddd")); plot.setThermometerPaint(Color.decode("#aaaaaa")); plot.setValuePaint(Color.decode("#333333")); plot.setUseSubrangePaint(false); plot.setUnits(ThermometerPlot.UNITS_NONE); plot.setBulbRadius(15); plot.setColumnRadius(6); NumberAxis axis = new NumberAxis(); axis.setNumberFormatOverride(NumberFormat.getPercentInstance()); plot.setRangeAxis(axis); plot.setValueLocation(ThermometerPlot.NONE); return plot; }
From source file:ColorComboBoxEditor.java
public void setItem(Object newValue) { if (newValue instanceof Color) { Color color = (Color) newValue; editor.setBackground(color);// w ww . j a v a 2 s . c o m } else { try { Color color = Color.decode(newValue.toString()); editor.setBackground(color); } catch (NumberFormatException e) { } } }
From source file:org.jets3t.gui.skins.SkinUtils.java
/** * Loads a skin property setting for a color. * * @param skinProperties// ww w . ja v a 2 s . c om * contains skin property settings. * @param colorPropertyName * the name of the property expected to contain a color value. * * @return * the parsed color value if the given property is available and valid, null otherwise. */ public Color loadColor(Properties skinProperties, String colorPropertyName) { Color color = null; String colorValue = skinProperties.getProperty(colorPropertyName, null); log.debug("Loading skin color with property '" + colorPropertyName + "', value: " + colorValue); if (colorValue != null) { color = Color.decode(colorValue); } else { log.warn("Color is not available for property '" + colorPropertyName + "'"); } return color; }
From source file:org.pentaho.ui.xul.swing.tags.SwingStatusbar.java
public SwingStatusbar(Element self, XulComponent parent, XulDomContainer domContainer, String tagName) { super("statusbar"); container = new ScrollablePanel(new GridBagLayout()); container.setBackground(Color.decode("#EFEFEF")); container.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.gray)); setManagedObject(container);//w w w . ja v a 2 s . c o m resetContainer(); }