List of usage examples for java.awt Color decode
public static Color decode(String nm) throws NumberFormatException
From source file:org.sonar.plugins.core.charts.XradarChart.java
private void configureColors(SpiderWebPlot plot, ChartParameters params) { String[] colors = params.getValues(PARAM_COLOR, "|"); for (int i = 0; i < colors.length; i++) { plot.setSeriesPaint(i, Color.decode("0x" + colors[i])); }/*w w w . j a va 2s . com*/ }
From source file:com.gargoylesoftware.htmlunit.javascript.host.canvas.rendering.AwtRenderingBackend.java
/** * {@inheritDoc}/*from w w w. ja v a 2s .c o m*/ */ public void setFillStyle(final String fillStyle) { final String tmpFillStyle = fillStyle.replaceAll("\\s", ""); Color color = null; if (tmpFillStyle.startsWith("rgb(")) { final String[] colors = tmpFillStyle.substring(4, tmpFillStyle.length() - 1).split(","); color = new Color(Integer.parseInt(colors[0]), Integer.parseInt(colors[1]), Integer.parseInt(colors[2])); } else if (tmpFillStyle.startsWith("rgba(")) { final String[] colors = tmpFillStyle.substring(5, tmpFillStyle.length() - 1).split(","); color = new Color(Integer.parseInt(colors[0]), Integer.parseInt(colors[1]), Integer.parseInt(colors[2]), (int) (Float.parseFloat(colors[3]) * 255)); } else if (tmpFillStyle.startsWith("#")) { color = Color.decode(tmpFillStyle); } else { try { final Field f = Color.class.getField(tmpFillStyle); color = (Color) f.get(null); } catch (final Exception e) { LOG.info("Can not find color '" + tmpFillStyle + '\''); color = Color.black; } } graphics2D_.setColor(color); }
From source file:com.uimirror.image.form.UimImageFormParam.java
public Color getFg() { try {/* w w w . j ava 2 s . c o m*/ Color cl = StringUtils.hasText(fg) ? Color.decode(fg) : Color.WHITE; return cl; } catch (Exception e) { return Color.WHITE; } }
From source file:ch.jamiete.hilda.moderatortools.commands.UserinfoCommand.java
@Override public void execute(final Message message, final String[] arguments, final String label) { final List<User> tocheck = new ArrayList<User>(); if (arguments.length == 0) { tocheck.add(message.getAuthor()); } else if (message.getMentionedUsers().isEmpty()) { this.usage(message, "[@user...]", label); return;/* w w w. j a va 2 s . c om*/ } else { tocheck.addAll(message.getMentionedUsers()); } for (final User user : tocheck) { final Member member = message.getGuild().getMember(user); final EmbedBuilder eb = new EmbedBuilder(); if (user.isBot()) { eb.setTitle(Util.getName(user) + " (Bot account)"); } else { eb.setTitle(Util.getName(user)); } eb.setThumbnail(user.getEffectiveAvatarUrl()); switch (member.getOnlineStatus()) { case ONLINE: eb.setColor(Color.decode("#008E09")); break; case DO_NOT_DISTURB: eb.setColor(Color.decode("#FF0303")); break; case IDLE: eb.setColor(Color.decode("#FFBF00")); break; case INVISIBLE: case OFFLINE: case UNKNOWN: default: eb.setColor(Color.decode("#C2CBCE")); break; } eb.addField("User ID", user.getId(), false); if (member.getNickname() != null) { eb.addField("Nickname", member.getNickname(), false); } eb.addField("Shared servers", String.valueOf(user.getMutualGuilds().size()), false); eb.addField("Online status", WordUtils.capitalize(member.getOnlineStatus().toString().toLowerCase().replace("_", "")), false); if (member.getGame() != null) { String value = member.getGame().getName(); if (member.getGame().getUrl() != null) { value = "[" + value + "](" + member.getGame().getUrl() + ")"; } eb.addField("Currently playing", value, false); } eb.addField("Account created on", user.getCreationTime().format(this.dtf) + " GMT", false); eb.addField("Joined server on", member.getJoinDate().format(this.dtf) + " GMT", false); final long existence = System.currentTimeMillis() - message.getGuild().getCreationTime().toInstant().toEpochMilli(); final long usertime = System.currentTimeMillis() - member.getJoinDate().toInstant().toEpochMilli(); final double percentage = (double) usertime / (double) existence * 100D; String value = Util.getFriendlyTime(usertime); value += " or \u2248" + Math.round(percentage) + "% of the server's existence."; eb.addField("Has been a member for", value, false); if (!member.getRoles().isEmpty()) { eb.addField("Roles (" + member.getRoles().size() + ")", Util.getRolesAsString(member.getRoles()), false); } this.reply(message, eb.build()); } }
From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.heatmap.HeatMapImgGenerator.java
private JPanel initCell(String color, int x, int y) { JPanel cell = new JPanel(); cell.setSize(50, 50);/*from w w w .j a va 2 s .c om*/ Color c; if (color.contains("#")) { c = Color.decode(color); } else if (color.toLowerCase().contains("rgb")) { String rgb = color.toLowerCase().replace("rgb", "").replace("(", "").replace(")", "").replace(" ", ""); String[] stringRGBArr = rgb.split(","); c = new Color(Integer.valueOf(stringRGBArr[0]), Integer.valueOf(stringRGBArr[1]), Integer.valueOf(stringRGBArr[2])); } else { c = Color.RED; } cell.setBackground(c); cell.setOpaque(true); cell.setLocation(x, y); cell.setBorder(new LineBorder(Color.WHITE)); return cell; }
From source file:es.emergya.cliente.Mobile.java
@Override protected void configureUI() { UIManager.put("swing.boldMetal", Boolean.FALSE); //$NON-NLS-1$ UIManager.put("TabbedPane.selected", Color.decode("#B1BEF0")); final Enumeration<Object> keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof javax.swing.plaf.FontUIResource) { UIManager.put(key, getLightFont()); }/*from ww w. j a v a 2 s . c o m*/ } UIManager.put("TableHeader.font", deriveBoldFont(10f)); UIManager.put("TabbedPane.font", deriveLightFont(9f)); }
From source file:umich.ms.batmass.filesupport.files.types.mzrt.providers.MzrtFeaturesDataSource.java
@Override public MzrtFeatures load() throws DataLoadingException { Path path = Paths.get(this.getOriginURI()); MzrtFile file = new MzrtFile(path); file.load();//from w w w . ja v a2 s . c om MzrtFeatures features = new MzrtFeatures(file); Map<String, Integer> header = file.getHeader(); List<CSVRecord> records = file.getRecords(); int[] idxs = file.getIndexesMzRtColorOpacity(); for (CSVRecord record : records) { String mzLo = record.get(idxs[0]); String mzHi = record.get(idxs[1]); String rtLo = record.get(idxs[2]); String rtHi = record.get(idxs[3]); double mlo, mhi, rlo, rhi; try { mlo = Double.parseDouble(mzLo); mhi = Double.parseDouble(mzHi); rlo = Double.parseDouble(rtLo); rhi = Double.parseDouble(rtHi); double mz = (mlo + mhi) / 2; MzrtBox box = new MzrtBox(mz, rlo, rhi, mlo, mhi); MzrtFeature mzrtFeature = new MzrtFeature(new MzrtBox[] { box }, record); if (idxs[4] >= 0) { String colorStr = record.get(idxs[4]); try { Color color = Color.decode(colorStr); mzrtFeature.setColor(color); } catch (NumberFormatException ex) { throw new DataLoadingException("Could not decode color string"); } } if (idxs[5] >= 0) { String opacityStr = record.get(idxs[5]); float opacity = Float.parseFloat(opacityStr); mzrtFeature.setOpacity(opacity); } features.add(mzrtFeature, 1, null); } catch (NumberFormatException ex) { throw new DataLoadingException(ex); } } return features; }
From source file:ru.runa.wfe.graph.DrawProperties.java
private static Color getColorProperty(String propertyName, Color defaultColor) { String colorValue = resources.getStringProperty(propertyName, null); if (colorValue != null) { try {/*from w w w . j av a2 s . c o m*/ return Color.decode(colorValue); } catch (NumberFormatException e) { log.error(e.getMessage(), e); } } return defaultColor; }
From source file:org.pentaho.ui.xul.swt.tags.SwtBox.java
public void setBgcolor(String bgcolor) { this.bgcolor = bgcolor; Color c = Color.decode(bgcolor); box.setBackground(/*from w ww.j a v a2 s .c o m*/ new org.eclipse.swt.graphics.Color(box.getDisplay(), c.getRed(), c.getGreen(), c.getBlue())); box.setBackgroundMode(SWT.INHERIT_DEFAULT); }
From source file:org.sonar.server.charts.deprecated.PieChart.java
private void configureColors(String colors) { try {//from w w w . j a v a2 s . c om if (colors != null && colors.length() > 0) { StringTokenizer stringTokenizer = new StringTokenizer(colors, ","); int i = 0; while (stringTokenizer.hasMoreTokens()) { ((PiePlot) jfreechart.getPlot()).setSectionPaint(Integer.toString(i), Color.decode("0x" + stringTokenizer.nextToken())); i++; } } else { configureDefaultColors(); } } catch (Exception e) { configureDefaultColors(); } }