List of usage examples for java.awt Color decode
public static Color decode(String nm) throws NumberFormatException
From source file:org.pentaho.plugin.jfreereport.reportcharts.RadarChartExpression.java
protected JFreeChart computeChart(final Dataset dataset) { //Initializing a default CategoryDataset DefaultCategoryDataset defaultDataset = new DefaultCategoryDataset(); if (dataset instanceof DefaultCategoryDataset) { defaultDataset = (DefaultCategoryDataset) dataset; }// w w w . java 2s.c o m //Retrieving the size of the dataset for parsing //Parse the dataset in order to find the biggest value if (drawgrid == true) { initializeGrid(defaultDataset); } //Instantiate a spiderwebplot final ExtendedSpiderWebPlot plot = new ExtendedSpiderWebPlot(defaultDataset); for (int i = 0; i < this.getSeriesColor().length; i++) { Color seriesColor; String colorDef = this.getSeriesColor(i); if (colorDef == null) { seriesColor = Color.RED; } else { seriesColor = ColorHelper.lookupColor(colorDef); if (seriesColor == null) { seriesColor = Color.decode(colorDef); } } plot.setSeriesPaint(i, seriesColor); } //Instantiate a JFreeChart using the plot from above return new JFreeChart(computeTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, isShowLegend()); }
From source file:org.cerberus.crud.service.impl.TestCaseExecutionwwwDetService.java
private BufferedImage bi(TimeSeriesCollection timeseriescollection, String xname, String name, int count) { BufferedImage bi = null;/*from w ww. j a va2 s . c o m*/ boolean fc = false; XYDataset xydataset = timeseriescollection; JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(name, xname, name, xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(false); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { Shape point = ShapeUtilities.createDiagonalCross(1, 1); String[] seriesColors = { "#FF0000", "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01" }; String[] seriesColors2 = { "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01" }; XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); for (int a = 0; a < count; a++) { xylineandshaperenderer.setSeriesShape(a, point); xyitemrenderer.setSeriesStroke(a, new BasicStroke(1.0F)); //TODO check this - fc is always false if (fc) { xylineandshaperenderer.setSeriesPaint(a, Color.decode(seriesColors[count - a - 1])); } else { xylineandshaperenderer.setSeriesPaint(a, Color.decode(seriesColors2[count - a - 1])); } } } DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("hh:mm")); bi = jfreechart.createBufferedImage(500, 270); return bi; }
From source file:org.pentaho.ui.xul.swt.tags.SwtGrid.java
public void setBgcolor(String bgcolor) { this.bgcolor = bgcolor; Color c = Color.decode(bgcolor); grid.setBackground(//from w w w. j a v a2 s.co m new org.eclipse.swt.graphics.Color(grid.getDisplay(), c.getRed(), c.getGreen(), c.getBlue())); grid.setBackgroundMode(SWT.INHERIT_DEFAULT); }
From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.ComparisonsSelectionOverviewBubbleChart.java
public ComparisonsSelectionOverviewBubbleChart(final QuantCentralManager Quant_Central_Manager, final CSFPRHandler CSFPR_Handler, int chartWidth, int chartHeight, Set<QuantDiseaseGroupsComparison> selectedComparisonList, List<QuantProtein> searchQuantificationProtList) { userDataCounter = 0;//from w ww . ja va 2 s . co m this.searchQuantificationProtList = searchQuantificationProtList; Map<String, String> diseaseHashedColorMap = Quant_Central_Manager.getDiseaseHashedColorMap(); for (String str : diseaseHashedColorMap.keySet()) { diseaseColorMap.put(str, Color.decode(diseaseHashedColorMap.get(str))); } this.width = chartWidth; this.height = 600; this.CSFPR_Handler = CSFPR_Handler; this.setWidth(width + "px"); this.setHeightUndefined(); this.Quant_Central_Manager = Quant_Central_Manager; this.Quant_Central_Manager.registerStudySelectionListener(ComparisonsSelectionOverviewBubbleChart.this); this.setSpacing(true); //init toplayout topLayout.setHeight(30 + "px"); topLayout.setSpacing(true); topLayout.setMargin(new MarginInfo(false, false, true, false)); this.addComponent(topLayout); Label overviewLabel = new Label("<font style='margin-left :50px;'>Overview</font> "); overviewLabel.setContentMode(ContentMode.HTML); topLayout.addComponent(overviewLabel); overviewLabel.setStyleName("subtitle"); overviewLabel.setWidth("120px"); InfoPopupBtn info = new InfoPopupBtn( "The bubble chart give an overview for the proteins existed in the selected comparisons.<br/>The diameter of the bubble represents the number of the proteins in the selected comparison and the color represents the trend<br/>"); info.setWidth("16px"); info.setHeight("16px"); topLayout.addComponent(info); this.topLayout.setVisible(false); //end of toplayout //init chartlayout this.chartLayoutContainer.setVisible(false); this.addComponent(chartLayoutContainer); chartLayoutContainer.setWidth(width + "px"); chartLayoutContainer.setHeight(height + "px"); chartLayoutContainer.addComponent(chartImage, "left: " + 0 + "px; top: " + 0 + "px;"); chartLayoutContainer.addComponent(chartLayout, "left: " + 0 + "px; top: " + 0 + "px;"); chartLayout.setWidth(width + "px"); chartLayout.setHeight(height + "px"); chartLayout.addLayoutClickListener(ComparisonsSelectionOverviewBubbleChart.this); //end of chartlayout //init bottomlayout bottomLayout.setWidth("100%"); this.addComponent(bottomLayout); this.setComponentAlignment(bottomLayout, Alignment.BOTTOM_RIGHT); bottomLayout.setVisible(false); HorizontalLayout btnContainerLayout = new HorizontalLayout(); btnContainerLayout.setSpacing(true); // btnContainerLayout.setMargin(new MarginInfo(false, false, false, false)); btnContainerLayout.setWidthUndefined(); btnContainerLayout.setHeightUndefined(); // btnContainerLayout.addStyleName("leftspacer"); bottomLayout.addComponent(btnContainerLayout); bottomLayout.setComponentAlignment(btnContainerLayout, Alignment.TOP_RIGHT); TrendLegend legendLayout = new TrendLegend("bubblechart"); legendLayout.setWidthUndefined(); legendLayout.setHeight("24px"); btnContainerLayout.addComponent(legendLayout); btnContainerLayout.setComponentAlignment(legendLayout, Alignment.TOP_RIGHT); // btnContainerLayout.setExpandRatio(legendLayout, 600); // btnContainerLayout.setExpandRatio(btnContainerLayout, 210); // VerticalLayout stableBtnWrapper = new VerticalLayout(); //// stableBtnWrapper.setWidth("64px"); // HorizontalLayout stableBtn = new HorizontalLayout(); // stableBtnWrapper.addComponent(stableBtn); // stableBtnWrapper.setComponentAlignment(stableBtn, Alignment.TOP_LEFT); // btnContainerLayout.addComponent(stableBtnWrapper); groupSwichBtn = new GroupSwichBtn(Quant_Central_Manager, searchQuantificationProtList); btnContainerLayout.addComponent(groupSwichBtn); final VerticalLayout appliedIcon = new VerticalLayout(); appliedIcon.setStyleName("appliedicon"); appliedIcon.setWidth("24px"); appliedIcon.setHeight("24px"); appliedIcon.setDescription("Hide stable proteins"); btnContainerLayout.addComponent(appliedIcon); // stableBtn.setStyleName("stablebtn"); // stableBtn.setHeight("24px"); // Label stableLabel = new Label("Equal"); // stableLabel.setWidth("44px"); // stableBtn.addComponent(stableLabel); appliedIcon.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { if (appliedIcon.getStyleName().equalsIgnoreCase("appliedicon")) { appliedIcon.setStyleName("unappliedicon"); Quant_Central_Manager.updateSignificantOnlySelection(true); appliedIcon.setDescription("Show stable proteins"); } else { appliedIcon.setStyleName("appliedicon"); Quant_Central_Manager.updateSignificantOnlySelection(false); appliedIcon.setDescription("Hide stable proteins"); } } }); exportPdfBtn = new Button(""); exportPdfBtn.setWidth("24px"); exportPdfBtn.setHeight("24px"); exportPdfBtn.setPrimaryStyleName("exportpdfbtn"); exportPdfBtn.setDescription("Export chart image"); StreamResource myResource = createResource(); FileDownloader fileDownloader = new FileDownloader(myResource); fileDownloader.extend(exportPdfBtn); btnContainerLayout.addComponent(exportPdfBtn); VerticalLayout unselectAllBtn = new VerticalLayout(); unselectAllBtn.setStyleName("unselectallbtn"); btnContainerLayout.addComponent(unselectAllBtn); btnContainerLayout.setComponentAlignment(unselectAllBtn, Alignment.TOP_LEFT); unselectAllBtn.setDescription("Clear selection"); unselectAllBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { Quant_Central_Manager.setBubbleChartQuantProteinsSelection(new HashSet<String>(), ""); resetChart(); } }); final VerticalLayout selectMultiBtn = new VerticalLayout(); selectMultiBtn.setStyleName("selectmultiselectedbtn"); btnContainerLayout.addComponent(selectMultiBtn); btnContainerLayout.setComponentAlignment(selectMultiBtn, Alignment.TOP_LEFT); selectMultiBtn.setDescription("Multiple selection"); activeMultiSelect = true; selectMultiBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { if (selectMultiBtn.getStyleName().equalsIgnoreCase("selectmultiselectedbtn")) { selectMultiBtn.setStyleName("selectmultibtn"); activeMultiSelect = false; } else { selectMultiBtn.setStyleName("selectmultiselectedbtn"); activeMultiSelect = true; } } }); //end of btns layout //init empty layout emptySelectionLayout = new VerticalLayout(); this.addComponent(emptySelectionLayout); emptySelectionLayout.setWidth(100 + "%"); emptySelectionLayout.setHeightUndefined(); VerticalLayout spacer = new VerticalLayout(); spacer.setHeight("100px"); spacer.setWidth("10px"); spacer.setStyleName(Reindeer.LAYOUT_WHITE); emptySelectionLayout.addComponent(spacer); emptySelectionLayout.setComponentAlignment(spacer, Alignment.BOTTOM_RIGHT); Label startLabel = new Label( "<center><h2 style='color:gray;'><b>Select comparison from the table</b></h2></center>"); startLabel.setContentMode(ContentMode.HTML); emptySelectionLayout.addComponent(startLabel); emptySelectionLayout.setComponentAlignment(startLabel, Alignment.MIDDLE_CENTER); Image handleft = new Image(); handleft.setSource(new ThemeResource("img/handleft.png")); emptySelectionLayout.addComponent(handleft); emptySelectionLayout.setComponentAlignment(handleft, Alignment.MIDDLE_CENTER); //init bubble chart }
From source file:org.jls.toolbox.util.ResourceManager.java
/** * Get a color associated with the given configuration key. If the key does * not exist, an {@link IllegalArgumentException} is thrown. If the value * cannot be decoded using {@link Color#decode(String)}, an * {@link IllegalArgumentException} is thrown. * /*from w w w . j a va 2 s .co m*/ * @param key * The configuration key. * @return The associated color. */ public Color getColor(final String key) { String str = getString(key); if (!str.isEmpty()) { try { return Color.decode(str); } catch (Exception e) { throw new IllegalArgumentException( "String cannot be interpreted as a decimal, octal, or hexadecimal integer : " + str, e); } } throw new IllegalStateException("Empty value"); }
From source file:es.emergya.ui.gis.popups.ListaCapas.java
private void cargarGpx(File file) throws IOException { GpxImporter importer = new GpxImporter(); if (!importer.acceptFile(file)) { new IOException("Gpx inaccesible."); }/*from w ww . j ava 2s. c o m*/ final String absolutePath = file.getAbsolutePath(); for (Layer l : capasActuales) { if (l.name.equals(file.getAbsolutePath())) return; } importer.importData(file); GpxLayer layer = new MyGpxLayer(importer.getLastData(), absolutePath, this.mapView); Main.pref.putColor("layer " + layer.name, Color.decode(LogicConstants.getNextColor())); addCapa(layer); }
From source file:org.deegree.portal.standard.wms.control.DynLegendListener.java
@Override public void actionPerformed(FormEvent event) { super.actionPerformed(event); missing = new ArrayList<String>(); try {/*w w w . j a va2 s . co m*/ init(); } catch (IOException e) { LOG.logError("Error occurred initializing DynLegendListener: ", e); gotoErrorPage("Error occurred initializing DynLegendListener: " + e); } RPCWebEvent rpc = (RPCWebEvent) event; RPCMethodCall mc = rpc.getRPCMethodCall(); RPCParameter[] para = mc.getParameters(); RPCStruct struct = (RPCStruct) para[0].getValue(); HttpSession session = ((HttpServletRequest) this.getRequest()).getSession(); ViewContext vc = (ViewContext) session.getAttribute(Constants.CURRENTMAPCONTEXT); // check if at least one layer is visible Layer[] layers = vc.getLayerList().getLayers(); boolean required = false; for (Layer layer : layers) { if (!layer.isHidden()) { required = true; break; } } // if no layer is visible send an empty image if (!required) { BufferedImage bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); saveImage(vc, bi); getRequest().setAttribute("LEGENDWIDTH", String.valueOf(bi.getWidth())); getRequest().setAttribute("LEGENDHEIGHT", String.valueOf(bi.getHeight())); return; } HashMap<String, String>[] model = createWMSRequestModel(struct); try { GetLegendGraphic legendParam = getLegendRequestParameter(); HashMap<String, Object> symbols = (HashMap<String, Object>) readLegendSymbols(legendParam, model, vc); Rectangle rect = calcLegendSize(symbols); BufferedImage bi = new BufferedImage(rect.width + leftMargin + rightMargin, rect.height + topMargin + bottomMargin, BufferedImage.TYPE_INT_RGB); Color color = Color.decode((String) struct.getMember("bgColor").getValue()); bi = drawSymbolsToBI(symbols, bi, color); saveImage(vc, bi); getRequest().setAttribute("LEGENDWIDTH", String.valueOf(bi.getWidth())); getRequest().setAttribute("LEGENDHEIGHT", String.valueOf(bi.getHeight())); } catch (Exception e) { LOG.logError("Error occurred in DynLegendListener: ", e); gotoErrorPage("Error occurred in DynLegendListener: " + e); } }
From source file:com.uttesh.pdfngreport.handler.PdfReportHandler.java
/** * This method will generate the chart image file by using the Jfree chart * library/*from ww w . j a v a2 s. c om*/ * * @param dataSet * @throws FileNotFoundException * @throws IOException * * @see DefaultPieDataset */ public void generateChart(DefaultPieDataset dataSet, String os) throws FileNotFoundException, IOException { try { JFreeChart chart = ChartFactory.createPieChart3D("", dataSet, true, true, false); ChartStyle.theme(chart); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setForegroundAlpha(0.6f); plot.setCircular(true); plot.setSectionPaint("Passed", Color.decode("#019244")); plot.setSectionPaint("Failed", Color.decode("#EE6044")); plot.setSectionPaint("Skipped", Color.decode("#F0AD4E")); Color transparent = new Color(0.0f, 0.0f, 0.0f, 0.0f); plot.setLabelOutlinePaint(transparent); plot.setLabelBackgroundPaint(transparent); plot.setLabelShadowPaint(transparent); plot.setLabelLinkPaint(Color.GRAY); Font font = new Font("SansSerif", Font.PLAIN, 10); plot.setLabelFont(font); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(gen); if (os != null && os.equalsIgnoreCase("w")) { ChartUtilities.saveChartAsPNG( new File(reportLocation + Constants.BACKWARD_SLASH + Constants.REPORT_CHART_FILE), chart, 560, 200); } else { ChartUtilities.saveChartAsPNG( new File(reportLocation + Constants.FORWARD_SLASH + Constants.REPORT_CHART_FILE), chart, 560, 200); } } catch (Exception e) { e.printStackTrace(System.err); if (os != null && os.equalsIgnoreCase("w")) { new File(reportLocation + Constants.BACKWARD_SLASH + Constants.REPORT_CHART_FILE).delete(); } else { new File(reportLocation + Constants.FORWARD_SLASH + Constants.REPORT_CHART_FILE).delete(); } System.exit(-1); } }
From source file:org.deegree.ogcwebservices.wms.dataaccess.ID2PInterpolation.java
private void parseColorMap() throws IOException { XMLFragment dummy = new XMLFragment(); dummy.setSystemId(configFileURL);/*from w w w. j ava 2 s .c o m*/ URL url = dummy.resolve(prop.getProperty("colorMapFile")); Properties p = new Properties(); p.load(url.openStream()); Iterator<Object> iter = p.keySet().iterator(); colorMap = new HashMap<double[], Color>(); while (iter.hasNext()) { String s = (String) iter.next(); double[] d = null; if (s.startsWith("<")) { d = new double[2]; d[0] = -9E9; d[1] = Double.parseDouble(s.substring(1, s.length())); } else if (s.startsWith(">")) { d = new double[2]; d[0] = Double.parseDouble(s.substring(1, s.length())); d[1] = 9E9; } else { d = StringTools.toArrayDouble(s, "-"); } colorMap.put(d, Color.decode(p.getProperty(s))); } }
From source file:org.apache.uima.ruta.engine.StyleMapFactory.java
private Color parseColorBackground(String color) { if (color == null) { return Color.BLACK; }/*from w w w. j a v a 2s .co m*/ if (color.startsWith("#")) { return Color.decode(color); } else { String string = (String) colorNameMap.get(color); if (string != null) return Color.decode(string); else return Color.LIGHT_GRAY; } }