List of usage examples for java.awt Color decode
public static Color decode(String nm) throws NumberFormatException
From source file:net.sourceforge.processdash.ui.web.reports.AreaChart.java
private void configureIndividualColors(CategoryPlot plot, CategoryDataset catData) { CategoryItemRenderer rend = plot.getRenderer(); for (int i = 0; i < catData.getRowCount(); i++) { String colorKey = "c" + (i + 1); String color = getParameter(colorKey); if (color != null) rend.setSeriesPaint(i, Color.decode("#" + color)); }/*from ww w . jav a 2s . c o m*/ }
From source file:org.n52.io.type.quantity.handler.img.LineRenderer.java
@Override public void setColorForSeries() { // each renderer renders just one series lineRenderer.setSeriesPaint(0, Color.decode(style.getColor())); }
From source file:org.kalypso.model.wspm.pdb.wspm.CheckoutVegetationUpdater.java
private void updateColor() { final String colorAsString = m_vegetation.getColor(); if (StringUtils.isEmpty(colorAsString)) return;/*w ww.ja v a 2 s. co m*/ final Color color = Color.decode(colorAsString); final RGB oldRGB = m_vegetationClass.getColor(); final Color oldColor = new Color(oldRGB.red, oldRGB.green, oldRGB.blue); if (ObjectUtils.equals(color, oldColor)) return; final RGB newRGB = new RGB(color.getRed(), color.getGreen(), color.getBlue()); m_vegetationClass.setColor(newRGB); m_changed = true; }
From source file:test.uk.co.modularaudio.util.swing.lwtc.TestShowLWTCSliderComparison.java
public void go(final int orientation) throws Exception { final JSlider testSwingJSlider = new JSlider(orientation); testSwingJSlider.setOpaque(false);//from w w w . j av a 2 s. c o m final BoundedRangeModel defaultSwingSliderModel = testSwingJSlider.getModel(); log.debug("Default swing slider model is " + defaultSwingSliderModel.toString()); final JFrame f = new JFrame(); f.getContentPane().setBackground(Color.decode("#3a5555")); final MigLayoutStringHelper msg = new MigLayoutStringHelper(); // msg.addLayoutConstraint( "debug" ); msg.addLayoutConstraint("fill"); msg.addLayoutConstraint("insets 0"); msg.addLayoutConstraint("gap 0"); if (orientation == SwingConstants.VERTICAL) { msg.addColumnConstraint("[][grow][grow][]"); msg.addRowConstraint("[][grow][]"); } else { msg.addColumnConstraint("[][grow][]"); msg.addRowConstraint("[][grow][grow][]"); } f.setLayout(msg.createMigLayout()); f.add(new JLabel("o"), "center"); f.add(new JLabel("o"), "center"); if (orientation == SwingConstants.VERTICAL) { f.add(new JLabel("o"), "center"); } f.add(new JLabel("o"), "center,wrap"); f.add(new JLabel("o"), "center"); if (orientation == SwingConstants.VERTICAL) { f.add(verticalKnobContainer, "center, grow"); f.add(testSwingJSlider, "center, grow"); } else { f.add(horizontalKnobContainer, "center, grow"); } f.add(new JLabel("o"), "center,wrap"); if (orientation == SwingConstants.HORIZONTAL) { f.add(new JLabel("o"), "center"); f.add(testSwingJSlider, "center, grow"); f.add(new JLabel("o"), "center, wrap"); } f.add(new JLabel("o"), "center"); if (orientation == SwingConstants.VERTICAL) { f.add(new JLabel("o"), "center"); } f.add(new JLabel("o"), "center"); f.add(new JLabel("o"), "center"); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { f.setVisible(true); } }); }
From source file:com.t3.macro.api.functions.input.ColumnPanel.java
/** * Adds a row to the ColumnPanel with a label and input field. * <code>addToVarList</code> controls whether the VarSpec is added to * the local listing.//from w w w. ja v a2s.c om */ protected void addVariable(VarSpec vs, boolean addToVarList) { if (addToVarList) varSpecs.add(vs); gbc.gridy = componentCount; gbc.gridwidth = 1; // add the label gbc.gridx = 0; JComponent l; Matcher m = Pattern.compile("^\\s*<html>(.*)<\\/html>\\s*$").matcher(vs.prompt); if (m.find()) { // For HTML values we use a HTMLPane. HTMLPane htmlp = new HTMLPane(); htmlp.setText("<html>" + m.group(1) + ":</html>"); htmlp.setBackground(Color.decode("0xECE9D8")); l = htmlp; } else { l = new JLabel(vs.prompt + ":"); } labels.add(l); if (!vs.optionValues.optionEquals("SPAN", "TRUE")) { // if the control is not set to span, we include the prompt label add(l, gbc); } // add the input component JComponent inputField = createInputControl(vs); if (vs.optionValues.optionEquals("SPAN", "TRUE")) { gbc.gridwidth = 2; // the control spans both columns inputField.setToolTipText(vs.prompt); } else { gbc.gridx = 1; // the control lives in the second column } inputFields.add(inputField); add(inputField, gbc); componentCount++; }
From source file:org.sonar.server.charts.deprecated.BaseChartWeb.java
protected void configureColors(String colors, AbstractRenderer renderer) { try {// w w w .j a v a 2 s . c om if (colors != null && colors.length() > 0) { StringTokenizer stringTokenizer = new StringTokenizer(colors, ","); int i = 0; while (stringTokenizer.hasMoreTokens()) { renderer.setSeriesPaint(i, Color.decode("0x" + stringTokenizer.nextToken())); i++; } } else { configureDefaultColors(renderer); } } catch (Exception e) { configureDefaultColors(renderer); } }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.DialCharts.java
public void configureChart(SourceBean content) { logger.debug("IN"); super.configureChart(content); try {//w ww .ja v a2s .c om // check if there is some info about additional labels style SourceBean styleTickLabelsSB = (SourceBean) content.getAttribute(STYLE_TICK_LABELS); if (styleTickLabelsSB != null) { String fontS = (String) styleTickLabelsSB.getAttribute(FONT_STYLE); if (fontS == null) { fontS = defaultLabelsStyle.getFontName(); } String sizeS = (String) styleTickLabelsSB.getAttribute(SIZE_STYLE); String colorS = (String) styleTickLabelsSB.getAttribute(COLOR_STYLE); try { Color color = Color.BLACK; if (colorS != null) { color = Color.decode(colorS); } else { defaultLabelsStyle.getColor(); } int size = 12; if (sizeS != null) { size = Integer.valueOf(sizeS).intValue(); } else { size = defaultLabelsStyle.getSize(); } labelsTickStyle = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style labels settings, use default"); } } else { labelsTickStyle = defaultLabelsStyle; } SourceBean styleValueLabelsSB = (SourceBean) content.getAttribute(STYLE_VALUE_LABEL); if (styleValueLabelsSB != null) { String fontS = (String) styleValueLabelsSB.getAttribute(FONT_STYLE); if (fontS == null) { fontS = defaultLabelsStyle.getFontName(); } String sizeS = (String) styleValueLabelsSB.getAttribute(SIZE_STYLE); String colorS = (String) styleValueLabelsSB.getAttribute(COLOR_STYLE); try { Color color = Color.BLACK; if (colorS != null) { color = Color.decode(colorS); } else { defaultLabelsStyle.getColor(); } int size = 12; if (sizeS != null) { size = Integer.valueOf(sizeS).intValue(); } else { size = defaultLabelsStyle.getSize(); } labelsValueStyle = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style labels settings, use default"); } } else { labelsValueStyle = defaultLabelsStyle; } if (isLovConfDefined == false) { // the configuration parameters are set in template logger.debug("Configuration in template"); confParameters = new HashMap(); SourceBean confSB = (SourceBean) content.getAttribute("CONF"); List confAttrsList = confSB.getAttributeAsList("PARAMETER"); Iterator confAttrsIter = confAttrsList.iterator(); while (confAttrsIter.hasNext()) { SourceBean param = (SourceBean) confAttrsIter.next(); String nameParam = (String) param.getAttribute("name"); String valueParam = (String) param.getAttribute("value"); confParameters.put(nameParam, valueParam); } if (confParameters.get(LOWER) != null) { String lower = (String) confParameters.get(LOWER); setLower(Double.valueOf(lower).doubleValue()); } else { logger.error("lower bound not defined"); throw new Exception("lower bound not defined"); } if (confParameters.get(UPPER) != null) { String upper = (String) confParameters.get(UPPER); setUpper(Double.valueOf(upper).doubleValue()); } else { logger.error("upper bound not defined"); throw new Exception("upper bound not defined"); } if (confParameters.get(UNITS) != null) { String units = (String) confParameters.get(UNITS); setUnits(units); } multichart = false; if (confParameters.get("multichart") != null && !(((String) confParameters.get(MULTICHART)).equalsIgnoreCase(""))) { String multiple = (String) confParameters.get(MULTICHART); if (multiple.equalsIgnoreCase("true")) setMultichart(true); } orientationMultichart = "horizontal"; if (confParameters.get(ORIENTATION_MULTICHART) != null && !(((String) confParameters.get(ORIENTATION_MULTICHART)).equalsIgnoreCase(""))) { String ori = (String) confParameters.get(ORIENTATION_MULTICHART); if (ori.equalsIgnoreCase("horizontal") || ori.equalsIgnoreCase("vertical")) setOrientationMultichart(ori); } } else { // configuration parameters are set in a LOV logger.debug("configuration parameters set in LOV"); //String parameters=LovAccessFunctions.getLovResult(profile, confLov); String parameters = DataSetAccessFunctions.getDataSetResultFromLabel(profile, confDataset, parametersObject); SourceBean sourceBeanResult = null; try { sourceBeanResult = SourceBean.fromXMLString(parameters); } catch (SourceBeanException e) { logger.error("error in reading configuration lov"); throw new Exception("error in reading configuration lov"); } sbRow = (SourceBean) sourceBeanResult.getAttribute("ROW"); String lower = (String) sbRow.getAttribute(LOWER); String upper = (String) sbRow.getAttribute(UPPER); String legend = (String) sbRow.getAttribute(LEGEND); String multichart = (String) sbRow.getAttribute(MULTICHART); String orientation = (String) sbRow.getAttribute(ORIENTATION_MULTICHART); if (lower == null || upper == null) { logger.error("error in reading configuration lov"); throw new Exception("error in reading configuration lov"); } setLower(Double.valueOf(lower).doubleValue()); setUpper(Double.valueOf(upper).doubleValue()); setMultichart((multichart.equalsIgnoreCase("true") ? true : false)); setLegend(legend.equalsIgnoreCase("true") ? true : false); setOrientationMultichart(orientation); } } catch (Exception e) { logger.error("error in reading template configurations"); } logger.debug("OUT"); }
From source file:ColorComboBox.java
public void setItem(Object newValue) { if (newValue instanceof Color) { Color color = (Color) newValue; editor.setBackground(color);// w w w.j a v a 2 s .c o m } else { // Try to decode try { Color color = Color.decode(newValue.toString()); editor.setBackground(color); } catch (NumberFormatException e) { // ignore - value unchanged } } }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.XYCharts.XYCharts.java
public void configureChart(SourceBean content) { logger.debug("IN"); super.configureChart(content); confParameters = new HashMap(); SourceBean confSB = (SourceBean) content.getAttribute("CONF"); if (confSB == null) return;//from w ww .j av a 2s. c o m List confAttrsList = confSB.getAttributeAsList("PARAMETER"); Iterator confAttrsIter = confAttrsList.iterator(); while (confAttrsIter.hasNext()) { SourceBean param = (SourceBean) confAttrsIter.next(); String nameParam = (String) param.getAttribute("name"); String valueParam = (String) param.getAttribute("value"); confParameters.put(nameParam, valueParam); } if (confParameters.get("x_label") != null) { xLabel = (String) confParameters.get("x_label"); } else { xLabel = "X"; } if (confParameters.get("y_label") != null) { yLabel = (String) confParameters.get("y_label"); } else { yLabel = "Y"; } if (confParameters.get("z_label") != null) { zLabel = (String) confParameters.get("z_label"); } else { zLabel = "Z"; } SourceBean styleLabelsSB = (SourceBean) content.getAttribute("STYLE_LABELS"); if (styleLabelsSB != null) { String fontS = (String) content.getAttribute("STYLE_LABELS.font"); String sizeS = (String) content.getAttribute("STYLE_LABELS.size"); String colorS = (String) content.getAttribute("STYLE_LABELS.color"); String orientationS = (String) content.getAttribute("STYLE_LABELS.orientation"); try { Color color = Color.decode(colorS); int size = Integer.valueOf(sizeS).intValue(); addLabelsStyle = new StyleLabel(fontS, size, color, orientationS); } catch (Exception e) { logger.error("Wrong style labels settings, use default"); } } logger.debug("OUT"); }
From source file:org.sonar.plugins.scmstats.charts.StackedBarChart3D.java
private JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createStackedBarChart3D(null, "Authors", "Activity", categorydataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setNumberFormatOverride(new DecimalFormat("0%")); StackedBarRenderer3D stackedbarrenderer3d = (StackedBarRenderer3D) categoryplot.getRenderer(); stackedbarrenderer3d.setRenderAsPercentages(true); stackedbarrenderer3d.setDrawBarOutline(false); stackedbarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{3}", NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%"))); stackedbarrenderer3d.setBaseItemLabelsVisible(true); stackedbarrenderer3d//from w w w . j av a 2s . c om .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); stackedbarrenderer3d .setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); stackedbarrenderer3d.setSeriesPaint(0, Color.decode("#66CD00")); stackedbarrenderer3d.setSeriesPaint(1, Color.decode("#4F94CD")); stackedbarrenderer3d.setSeriesPaint(2, Color.decode("#FF4040")); return jfreechart; }