List of usage examples for java.awt Color decode
public static Color decode(String nm) throws NumberFormatException
From source file:it.eng.spagobi.engines.chart.bo.charttypes.clusterchart.ClusterCharts.java
/** * Calculates chart value;// ww w .j a va 2s.co m * * * public Dataset calculateValue(String cat, Map parameters) throws Exception { * logger.debug("IN"); * String res=DataSetAccessFunctions.getDataSetResult(profile, getData(),parameters); * * DefaultCategoryDataset dataset = new DefaultCategoryDataset(); * * SourceBean sbRows=SourceBean.fromXMLString(res); * List listAtts=sbRows.getAttributeAsList("ROW"); * * * // run all categories (one for each row) * categoriesNumber=0; * for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) { * SourceBean category = (SourceBean) iterator.next(); * List atts=category.getContainedAttributes(); * * HashMap series=new HashMap(); * String catValue=""; * * String name=""; * String value=""; * * //run all the attributes, to define series! * for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) { * SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next(); * * name=new String(object.getKey()); * value=new String((String)object.getValue()); * if(name.equalsIgnoreCase("x"))catValue=value; * else series.put(name, value); * } * for (Iterator iterator3 = series.keySet().iterator(); iterator3.hasNext();) { * String nameS = (String) iterator3.next(); * String valueS=(String)series.get(nameS); * dataset.addValue(Double.valueOf(valueS).doubleValue(), nameS, catValue); * categoriesNumber=categoriesNumber+1; * } * * } * logger.debug("OUT"); * return dataset; * } * * @param content the content */ public void configureChart(SourceBean content) { logger.debug("IN"); super.configureChart(content); confParameters = new HashMap(); SourceBean confSB = (SourceBean) content.getAttribute("CONF"); if (confSB == null) return; 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"; } //'column_sel' defines the column in witch there is the indicator of serie selected, //so the widget can colors the bubbles with the color read into template, otherwise the bubble is white/trasparent. //'default_color' defines the default series color. if (confParameters.get("column_sel") != null) colSel = (String) confParameters.get("column_sel"); else colSel = ""; if (confParameters.get("default_color") != null) defaultColor = (String) confParameters.get("default_color"); else defaultColor = "#FFFFFF"; //reading series colors if present SourceBean colors = (SourceBean) content.getAttribute("SERIES_COLORS"); if (colors == null) { colors = (SourceBean) content.getAttribute("CONF.SERIES_COLORS"); } if (colors != null) { colorMap = new HashMap(); List atts = colors.getContainedAttributes(); String colorNum = ""; String colorSerie = ""; String num = ""; for (Iterator iterator = atts.iterator(); iterator.hasNext();) { SourceBeanAttribute object = (SourceBeanAttribute) iterator.next(); //System.out.println(object.getKey()); String seriesName = new String(object.getKey()); colorSerie = new String((String) object.getValue()); Color col = new Color(Integer.decode(colorSerie).intValue()); if (col != null) { colorMap.put(seriesName, col); } } } // check if there is some info about additional labels style SourceBean styleXaxisLabelsSB = (SourceBean) content.getAttribute("STYLE_X_AXIS_LABELS"); if (styleXaxisLabelsSB != null) { String fontS = (String) content.getAttribute("STYLE_X_AXIS_LABELS.font"); if (fontS == null) { fontS = defaultLabelsStyle.getFontName(); } String sizeS = (String) content.getAttribute("STYLE_X_AXIS_LABELS.size"); String colorS = (String) content.getAttribute("STYLE_X_AXIS_LABELS.color"); String orientationS = (String) content.getAttribute("STYLE_X_AXIS_LABELS.orientation"); if (orientationS == null) { orientationS = "horizontal"; } 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(); } styleXaxesLabels = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style labels settings, use default"); } } else { styleXaxesLabels = defaultLabelsStyle; } SourceBean styleYaxisLabelsSB = (SourceBean) content.getAttribute("STYLE_Y_AXIS_LABELS"); if (styleYaxisLabelsSB != null) { String fontS = (String) content.getAttribute("STYLE_Y_AXIS_LABELS.font"); if (fontS == null) { fontS = defaultLabelsStyle.getFontName(); } String sizeS = (String) content.getAttribute("STYLE_Y_AXIS_LABELS.size"); String colorS = (String) content.getAttribute("STYLE_Y_AXIS_LABELS.color"); String orientationS = (String) content.getAttribute("STYLE_Y_AXIS_LABELS.orientation"); if (orientationS == null) { orientationS = "horizontal"; } 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(); } styleYaxesLabels = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style labels settings, use default"); } } else { styleYaxesLabels = defaultLabelsStyle; } SourceBean styleValueLabelsSB = (SourceBean) content.getAttribute("STYLE_VALUE_LABELS"); if (styleValueLabelsSB != null) { String fontS = (String) content.getAttribute("STYLE_VALUE_LABELS.font"); if (fontS == null) { fontS = defaultLabelsStyle.getFontName(); } String sizeS = (String) content.getAttribute("STYLE_VALUE_LABELS.size"); String colorS = (String) content.getAttribute("STYLE_VALUE_LABELS.color"); String orientationS = (String) content.getAttribute("STYLE_VALUE_LABELS.orientation"); if (orientationS == null) { orientationS = "horizontal"; } 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(); } styleValueLabels = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style labels settings, use default"); } } else { styleValueLabels = defaultLabelsStyle; } logger.debug("OUT"); }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java
JFreeChart rxAndLabChart(String demographicNo, String typeIdName, String typeIdName2, String patientName, String chartTitle) {/* w ww . jav a 2 s . co m*/ org.jfree.data.time.TimeSeriesCollection dataset = new org.jfree.data.time.TimeSeriesCollection(); ArrayList<EctMeasurementsDataBean> list = getList(demographicNo, typeIdName); String typeYAxisName = ""; if (typeIdName.equals("BP")) { log.debug("Using BP LOGIC FOR type 1 "); EctMeasurementsDataBean sampleLine = list.get(0); typeYAxisName = sampleLine.getTypeDescription(); TimeSeries systolic = new TimeSeries("Systolic", Day.class); TimeSeries diastolic = new TimeSeries("Diastolic", Day.class); for (EctMeasurementsDataBean mdb : list) { // dataVector) { String[] str = mdb.getDataField().split("/"); systolic.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(str[0])); diastolic.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(str[1])); } dataset.addSeries(diastolic); dataset.addSeries(systolic); } else { log.debug("Not Using BP LOGIC FOR type 1 "); // get the name from the TimeSeries EctMeasurementsDataBean sampleLine = list.get(0); String typeLegendName = sampleLine.getTypeDisplayName(); typeYAxisName = sampleLine.getTypeDescription(); // this should be the type of measurement TimeSeries newSeries = new TimeSeries(typeLegendName, Day.class); for (EctMeasurementsDataBean mdb : list) { //dataVector) { newSeries.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(mdb.getDataField())); } dataset.addSeries(newSeries); } JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Days", typeYAxisName, dataset, true, true, true); chart.setBackgroundPaint(Color.decode("#ccccff")); XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setAutoRange(true); log.debug("LEN " + plot.getDomainAxis().getLowerBound() + " ddd " + plot.getDomainAxis().getUpperMargin() + " eee " + plot.getDomainAxis().getLowerMargin()); //plot.getDomainAxis().setUpperMargin(plot.getDomainAxis().getUpperMargin()*6); //plot.getDomainAxis().setLowerMargin(plot.getDomainAxis().getLowerMargin()*6); // plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin()*1.7); plot.getDomainAxis().setUpperMargin(0.9); plot.getDomainAxis().setLowerMargin(0.9); plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 4); ValueAxis va = plot.getRangeAxis(); va.setAutoRange(true); XYItemRenderer renderer = plot.getRenderer(); //DateFormat.getInstance() XYItemLabelGenerator generator = new StandardXYItemLabelGenerator("{1} \n {2}", new SimpleDateFormat("yyyy.MM.dd"), new DecimalFormat("0.00")); renderer.setSeriesItemLabelGenerator(0, generator);//setLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); plot.setBackgroundPaint(Color.WHITE); plot.setDomainCrosshairPaint(Color.GRAY); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer rend = (XYLineAndShapeRenderer) renderer; rend.setBaseShapesVisible(true); rend.setBaseShapesFilled(true); } plot.setRenderer(renderer); /////// TaskSeriesCollection datasetDrug = new TaskSeriesCollection(); TaskSeries s1 = new TaskSeries("WARFARIN"); TaskSeries s2 = new TaskSeries("ALLOPUINOL"); TaskSeries s3 = new TaskSeries("LIPITOR"); s1.add(new Task("WARFARIN", UtilDateUtilities.StringToDate("2007-01-01"), UtilDateUtilities.StringToDate("2009-01-01"))); s2.add(new Task("ALLOPUINOL", UtilDateUtilities.StringToDate("2008-01-01"), new Date())); s3.add(new Task("LIPITOR", UtilDateUtilities.StringToDate("2007-01-01"), UtilDateUtilities.StringToDate("2008-01-01"))); datasetDrug.add(s1); datasetDrug.add(s2); datasetDrug.add(s3); XYTaskDataset dataset2 = new XYTaskDataset(datasetDrug); dataset2.setTransposed(true); dataset2.setSeriesWidth(0.6); DateAxis xAxis = new DateAxis("Date/Time"); SymbolAxis yAxis = new SymbolAxis("Meds", new String[] { "WARFARIN", "ALLOPURINOL", "LIPITOR" }); yAxis.setGridBandsVisible(false); XYBarRenderer xyrenderer = new XYBarRenderer(); xyrenderer.setUseYInterval(true); xyrenderer.setBarPainter(new StandardXYBarPainter()); xyrenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator("HAPPY{1} \n {2}", new SimpleDateFormat("yyyy.MM.dd"), new DecimalFormat("0.00"))); XYPlot xyplot = new XYPlot(dataset2, xAxis, yAxis, xyrenderer); xyplot.getDomainAxis().setUpperMargin(0.9); xyplot.getDomainAxis().setLowerMargin(0.9); CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(new DateAxis("Date/Time")); cplot.add(plot); cplot.add(xyplot); /////// chart = new JFreeChart("MED + LAB CHART", cplot); chart.setBackgroundPaint(Color.white); return chart; }
From source file:com.pronoiahealth.olhie.server.services.BookCoverImageService.java
/** * Create a back cover/*from w w w .ja va2s . c om*/ * * @param coverId * @param titleStr * @param textColor * @param width * @param height * @param type * @param imgFormat * @param macColors * - for PNG images reduce the color palette (must be greater * than 2) * @return * @throws Exception */ public byte[] createBackCover(String coverId, String titleStr, String spineColor, String textColor, int width, int height, int type, ImageFormat imgFormat, int maxColors) throws Exception { Graphics2D g2D = null; try { // Front cover first // Read in base cover image BufferedImage coverImg = Imaging.getBufferedImage(coverMap.get(coverId)); // Resize cover image to the basic 300 X 400 for front cover BufferedImage backCoverImg = resize(coverImg, 300, 400, type); g2D = (Graphics2D) backCoverImg.getGraphics(); // Add title if present if (titleStr != null && titleStr.length() > 0) { BufferedImage titleTextImg = createText(82, 220, titleStr, textColor, true, backTitleFontMap, type); g2D.drawImage(titleTextImg, 40, 35, null); } // Add spine if present if (spineColor != null && spineColor.length() > 0) { g2D.setColor(Color.decode(spineColor)); g2D.fillRect(backCoverImg.getWidth() - 2, 0, 2, backCoverImg.getHeight()); } // If the requested size is not 300X400 convert the image BufferedImage outImg = null; if (width != 300 || height != 400) { outImg = resize(backCoverImg, width, height, type); } else { outImg = backCoverImg; } // Do we want a PNG with a fixed number of colors if (maxColors >= 2 && imgFormat == ImageFormat.IMAGE_FORMAT_PNG) { outImg = ImageUtils.reduce32(outImg, maxColors); } // Return bytes Map<String, Object> params = new HashMap<String, Object>(); byte[] outBytes = Imaging.writeImageToBytes(outImg, imgFormat, params); return outBytes; } finally { if (g2D != null) { g2D.dispose(); } } }
From source file:net.sourceforge.processdash.ui.web.CGIChartBase.java
protected Color getColorSetting(String name) { String val = getParameter(name); if (val != null) try {// ww w . j ava 2s . c om if (val.startsWith("_")) val = "#" + val.substring(1); return Color.decode(val); } catch (Exception e) { } return Color.decode(Settings.getVal(SETTING_PREFIX + name)); }
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, QuantDiseaseGroupsComparison userCustomizedComparison) { this.userCustomizedComparison = userCustomizedComparison; userDataCounter = 1;/*w w w . j a va 2 s .c om*/ 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); //end of toplayout //init chartlayout this.chartLayoutContainer.setVisible(false); this.addComponent(chartLayoutContainer); 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); Quant_Central_Manager.insertNoftfication("Quantitative Datasets", "Remeber you can flip the disease group comparisons using (Swich disease groups button)<img src='VAADIN/themes/dario-theme/img/flip-v-updated.png' height='25px' width='25' alt='Reorder and select' Align='center'/> ", width, width, "flipnotification"); // 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(width + "px"); 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); }
From source file:net.sf.dynamicreports.adhoc.transformation.XmlToAdhocTransform.java
protected Color color(String color) { if (color == null) { return null; } return Color.decode(color); }
From source file:com.openkm.servlet.admin.StampServlet.java
/** * View text color//from w w w. jav a 2 s .c om */ private void textColor(Session session, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, DatabaseException { log.debug("textColor({}, {}, {})", new Object[] { session, request, response }); int stId = WebUtils.getInt(request, "st_id"); StampText st = StampTextDAO.findByPk(stId); BufferedImage bi = new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB); Graphics g = bi.getGraphics(); g.setColor(Color.decode(st.getColor())); g.fillRect(0, 0, 16, 16); response.setContentType("image/jpeg"); ImageIO.write(bi, "jpg", response.getOutputStream()); log.debug("textColor: void"); }
From source file:userinterface.StateNetworkAdminRole.StateReportsJPanel.java
private JFreeChart createpatientDonorReportsChart(CategoryDataset dataset) { JFreeChart barChart = ChartFactory.createBarChart("Patients:Donor in the state", "Year", "Number of Donors/Patients", dataset, PlotOrientation.VERTICAL, true, true, false); barChart.setBackgroundPaint(Color.white); // Set the background color of the chart barChart.getTitle().setPaint(Color.DARK_GRAY); barChart.setBorderVisible(true);/*from w w w .j a v a2s.c om*/ // Adjust the color of the title CategoryPlot plot = barChart.getCategoryPlot(); plot.getRangeAxis().setLowerBound(0.0); // Get the Plot object for a bar graph plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.blue); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.decode("#00008B")); //return chart; return barChart; }
From source file:com.openkm.servlet.admin.StampServlet.java
/** * Test text stamp// w ww .java2 s . c om */ private void textTest(Session session, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, DatabaseException, DocumentException, EvalError { log.debug("textTest({}, {}, {})", new Object[] { session, request, response }); int stId = WebUtils.getInt(request, "st_id"); StampText st = StampTextDAO.findByPk(stId); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PDFUtils.generateSample(5, baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); baos = new ByteArrayOutputStream(); PDFUtils.stampText(bais, st.getText(), st.getLayer(), st.getOpacity(), st.getSize(), Color.decode(st.getColor()), st.getRotation(), st.getAlign(), st.getExprX(), st.getExprY(), baos); bais = new ByteArrayInputStream(baos.toByteArray()); WebUtils.sendFile(request, response, "sample.pdf", Config.MIME_PDF, true, bais); log.debug("textTest: void"); }
From source file:probe.com.view.body.quantdatasetsoverview.quantproteinstabsheet.studies.ProteinStudyComparisonScatterPlotLayout.java
/** * Creates a sample jFreeChart.// w ww. j av a 2 s . c o m * * @param dataset the dataset. * * @return The jFreeChart. */ private void generateScatterplotchart(DiseaseGroupsComparisonsProteinLayout cp, int w, int h) { final XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries downSer = new XYSeries(0); XYSeries stableSer = new XYSeries(1); XYSeries upSer = new XYSeries(2); XYSeries novalueProvidedSer = new XYSeries(3); XYSeries downSerII = new XYSeries(4); XYSeries stableSerII = new XYSeries(5); XYSeries upSerII = new XYSeries(6); XYSeries novalueProvidedSerII = new XYSeries(7); // XYSeries plusSeries = new XYSeries(6); double downCounter = 1; double stableCounter = 3; double upCounter = 5; double novalueProvidedCounter = 3; patientGroupsNumToDsIdMap.clear(); final Map<Integer, int[]> paTGrNumbtrendMap = new HashMap<Integer, int[]>(); double maxPatNumber = -1.0; for (String protTrend : cp.getPatientsNumToTrindMap().keySet()) { List<Integer> patNums = cp.getPatientsNumToTrindMap().get(protTrend); int coun = 0; for (int i : patNums) { if (i > maxPatNumber) { maxPatNumber = i; } if (!patientGroupsNumToDsIdMap.containsKey(i)) { ComparisonDetailsBean pGr = new ComparisonDetailsBean(); patientGroupsNumToDsIdMap.put(i, pGr); } if (!paTGrNumbtrendMap.containsKey(i)) { int[] values = new int[4]; paTGrNumbtrendMap.put(i, values); } int[] values = paTGrNumbtrendMap.get(i); ComparisonDetailsBean pGr = patientGroupsNumToDsIdMap.get(i); if (protTrend.equalsIgnoreCase("noValueProvided")) { values[3] = values[3] + 1; pGr.addNovalueProvided(cp.getDSID(3, coun)); } else if (protTrend.equalsIgnoreCase("up")) { values[2] = values[2] + 1; pGr.addUpRegulated(cp.getDSID(0, coun)); } else if (protTrend.equalsIgnoreCase("down")) { values[0] = values[0] + 1; pGr.addDownRegulated(cp.getDSID(2, coun)); } else { values[1] = values[1] + 1; pGr.addNotRegulated(cp.getDSID(1, coun)); } paTGrNumbtrendMap.put(i, values); patientGroupsNumToDsIdMap.put(i, pGr); coun++; } } for (int i : paTGrNumbtrendMap.keySet()) { int[] values = paTGrNumbtrendMap.get(i); if ((values[2] > 1)) { upSer.add(upCounter, i); upSerII.add(upCounter, i); } else if ((values[2] == 1)) { upSer.add(upCounter, i); } if ((values[1] == 1)) { stableSer.add(stableCounter, i); } else if ((values[1] > 1)) { stableSer.add(stableCounter, i); stableSerII.add(stableCounter, i); } if ((values[0] > 1)) { downSer.add(downCounter, i); downSerII.add(downCounter, i); } else if ((values[0] == 1)) { downSer.add(downCounter, i); } if ((values[3] == 1)) { novalueProvidedSer.add(novalueProvidedCounter, i); } else if ((values[3] > 1)) { novalueProvidedSer.add(stableCounter, i); novalueProvidedSerII.add(stableCounter, i); } } dataset.addSeries(downSer); dataset.addSeries(stableSer); dataset.addSeries(upSer); dataset.addSeries(novalueProvidedSer); dataset.addSeries(downSerII); dataset.addSeries(stableSerII); dataset.addSeries(upSerII); dataset.addSeries(novalueProvidedSerII); // if((downSerII.getItemCount()+stableSerII.getItemCount()+upSerII.getItemCount()+downSer.getItemCount()+stableSer.getItemCount()+upSer.getItemCount())==0) // return; // dataset.addSeries(plusSeries); final String[] labels = new String[] { " ", ("Decreased (" + cp.getSignificantDown() + ")"), " ", ("Equal (" + cp.getStable() + ")"), " ", ("Increased (" + cp.getSignificantUp() + ")"), "" }; final Color[] labelsColor = new Color[] { Color.LIGHT_GRAY, new Color(80, 183, 71), Color.LIGHT_GRAY, new Color(1, 141, 244), Color.LIGHT_GRAY, Color.RED, Color.LIGHT_GRAY }; final SymbolAxis domainAxis = new SymbolAxis("X", labels) { @Override protected void drawGridBandsVertical(Graphics2D g2, Rectangle2D drawArea, Rectangle2D plotArea, boolean firstGridBandIsDark, List ticks) { List udatedTicksList = new ArrayList(); for (Object tick : ticks) { if (tick.toString().equalsIgnoreCase(labels[custTrend + 1])) { udatedTicksList.add(tick); } } // System.out.println("at ticks is "+ticks); // System.out.println("at udatedTicksList is "+udatedTicksList); // int factor = (int) ((plotArea.getHeight() / 5) * 0.25); // // Rectangle2D up = new Rectangle((int) drawArea.getX(), (int) drawArea.getY() - factor, (int) drawArea.getWidth(), (int) drawArea.getHeight()); // Rectangle2D pa = new Rectangle((int) plotArea.getX(), (int) plotArea.getY() - factor, (int) plotArea.getWidth(), (int) plotArea.getHeight()); super.drawGridBandsVertical(g2, drawArea, plotArea, firstGridBandIsDark, udatedTicksList); //To change body of generated methods, choose Tools | Templates. } int x = 0; @Override public Paint getTickLabelPaint() { if (x >= labels.length) { x = 0; } return labelsColor[x++]; } }; domainAxis.setAutoRangeIncludesZero(false); Font f = new Font("Verdana", Font.PLAIN, 11); domainAxis.setTickLabelFont(f); domainAxis.setAutoRange(false); domainAxis.setLabel(null); // domainAxis.setGridBandsVisible(false); String xTile = "#Patients"; JFreeChart jFreeChart = ChartFactory.createScatterPlot(null, null, // domain axis label null, // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend false, // tooltips? false // URLs? ); XYPlot plot1 = (XYPlot) jFreeChart.getPlot(); XYPlot xyplot = new XYPlot(dataset, plot1.getDomainAxis(), plot1.getRangeAxis(), plot1.getRenderer()) { @Override public void drawDomainTickBands(Graphics2D g2, Rectangle2D dataArea, List ticks) { if (custTrend == -1) { super.drawDomainTickBands(g2, dataArea, ticks); return; } List udatedTicksList = new ArrayList(); for (Object tick : ticks) { if (tick.toString().equalsIgnoreCase(labels[custTrend + 1])) { udatedTicksList.add(tick); } } Rectangle2D up; int factor = (int) ((dataArea.getHeight() / 5) * 0.5); if (custTrend == 4) { up = new Rectangle((int) dataArea.getX(), (int) dataArea.getY() + factor, (int) dataArea.getWidth(), (int) dataArea.getHeight()); } else if (custTrend == 2) { up = new Rectangle((int) dataArea.getX(), (int) dataArea.getY() - factor, (int) dataArea.getWidth(), (int) dataArea.getHeight()); } else { up = new Rectangle((int) dataArea.getX(), (int) dataArea.getY() - factor, (int) dataArea.getWidth(), (int) dataArea.getHeight()); } super.drawDomainTickBands(g2, up, udatedTicksList); //To change body of generated methods, choose Tools | Templates. } @Override protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { super.drawDomainGridlines(g2, dataArea, ticks); //To change body of generated methods, choose Tools | Templates. } private int x = 0; @Override public Paint getDomainGridlinePaint() { if (x >= labels.length) { x = 0; } if (x == 1 || x == 3 || x == 5) { x++; return Color.WHITE; } else { x++; return super.getDomainGridlinePaint(); //To change body of generated methods, choose Tools | Templates. } } }; if (custTrend != -1) { domainAxis.setGridBandsVisible(true); if (custTrend == 4) { domainAxis.setGridBandPaint(Color.decode("#ffe5e5")); xyplot.setDomainTickBandPaint(Color.decode("#ffe5e5")); domainAxis.setGridBandAlternatePaint(Color.decode("#ffe5e5")); } else if (custTrend == 0) { domainAxis.setGridBandPaint(Color.decode("#e5ffe5")); xyplot.setDomainTickBandPaint(Color.white); } else if (custTrend == 2) { domainAxis.setGridBandPaint(Color.decode("#e6f4ff")); xyplot.setDomainTickBandPaint(Color.white); } } else { domainAxis.setGridBandsVisible(false); } xyplot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart tempScatterPlot = new JFreeChart(xyplot); tempScatterPlot.setBackgroundPaint(Color.WHITE); tempScatterPlot.getLegend().setVisible(false); Color c = new Color(242, 242, 242); xyplot.setDomainAxis(domainAxis); xyplot.setDomainGridlinePaint(Color.GRAY); xyplot.setDomainGridlinesVisible(true); xyplot.setRangeGridlinesVisible(true); xyplot.setRangeGridlinePaint(Color.GRAY); xyplot.setOutlinePaint(Color.GRAY); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); ValueAxis va = xyplot.getDomainAxis(); va.setAutoRange(false); va.setMinorTickCount(0); va.setVisible(true); maxPatNumber = Math.ceil(maxPatNumber / 100.0) * 100; xyplot.getRangeAxis().setRange(0, maxPatNumber); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabel(xTile); rangeAxis.setLabelFont(f); rangeAxis.setLabelPaint(Color.GRAY); va.setRange(0, 6); xyplot.setBackgroundPaint(Color.WHITE); renderer.setUseOutlinePaint(true); Color c0 = new Color(80, 183, 71); renderer.setSeriesPaint(0, c0); renderer.setSeriesOutlinePaint(0, Color.WHITE); Color c1 = new Color(1, 141, 244); renderer.setSeriesPaint(1, c1); renderer.setSeriesOutlinePaint(1, Color.WHITE); Color c2 = new Color(204, 0, 0); renderer.setSeriesPaint(2, c2); renderer.setSeriesOutlinePaint(2, Color.WHITE); renderer.setSeriesPaint(3, Color.decode("#b5babb")); renderer.setSeriesOutlinePaint(3, Color.WHITE); renderer.setSeriesPaint(4, new Color(150, 212, 145)); renderer.setSeriesOutlinePaint(4, new Color(150, 212, 145)); renderer.setSeriesPaint(5, new Color(103, 187, 248)); renderer.setSeriesOutlinePaint(5, new Color(103, 187, 248)); renderer.setSeriesPaint(6, new Color(224, 102, 102)); renderer.setSeriesOutlinePaint(6, new Color(224, 102, 102)); renderer.setSeriesPaint(7, Color.decode("#b5babb")); renderer.setSeriesOutlinePaint(7, Color.GRAY); // renderer.setSeriesPaint(6, Color.BLACK); // renderer.setSeriesOutlinePaint(6, Color.BLACK); Shape downArr = ShapeUtilities.createDownTriangle(7f); Shape notRShape = ShapeUtilities.createDiamond(7f); Shape upArr = ShapeUtilities.createUpTriangle(7); Shape downArrII = ShapeUtilities.createTranslatedShape(ShapeUtilities.createDownTriangle(6f), 5, -5); Shape notRShapeII = ShapeUtilities.createTranslatedShape(ShapeUtilities.createDiamond(6f), 0, -7); Shape upArrII = ShapeUtilities.createTranslatedShape(ShapeUtilities.createUpTriangle(6f), 4, -4); // Shape plus = ShapeUtilities.createTranslatedShape(ShapeUtilities.createRegularCross(3f, 0.4f), 11, -7); renderer.setSeriesShape(0, downArr); renderer.setSeriesShape(1, notRShape); renderer.setSeriesShape(2, upArr); renderer.setSeriesShape(3, notRShape); renderer.setSeriesShape(4, downArrII); renderer.setSeriesShape(5, notRShapeII); renderer.setSeriesShape(6, upArrII); renderer.setSeriesShape(7, notRShapeII); // renderer.setSeriesShape(6, plus); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new SymbolicXYItemLabelGenerator() { private final int[] indexer = new int[] { 0, 1, 2, 3, 0, 1, 2, 3 }; @Override public String generateLabel(XYDataset dataset, int series, int category) { if (series > 3) { int patNumber = (int) dataset.getYValue(series, category); // int trend = (int) dataset.getXValue(series, category); if (series == 7 || series == 5) { return "\t " + paTGrNumbtrendMap.get(patNumber)[indexer[series]]; } else { return "\t " + paTGrNumbtrendMap.get(patNumber)[indexer[series]]; } } return ""; //To change body of generated methods, choose Tools | Templates. } }); ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT, TextAnchor.TOP_LEFT, 0.0); renderer.setSeriesPositiveItemLabelPosition(4, position); renderer.setSeriesPositiveItemLabelPosition(5, position); renderer.setSeriesPositiveItemLabelPosition(6, position); renderer.setSeriesPositiveItemLabelPosition(7, position); renderer.setBaseItemLabelFont(f); tempScatterPlot.setBorderVisible(false); xyplot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE); heighlightedScatterPlottImgUrl = saveToFile(tempScatterPlot, w, h, defaultScatterPlotRenderingInfo); xyplot.setBackgroundPaint(Color.WHITE); defaultScatterPlottImgUrl = saveToFile(tempScatterPlot, w, h, defaultScatterPlotRenderingInfo); // xyplot.setBackgroundPaint(c); if (custTrend != -1) { domainAxis.setGridBandsVisible(true); if (custTrend == 4) { domainAxis.setGridBandPaint(Color.decode("#ffe5e5")); xyplot.setDomainTickBandPaint(Color.decode("#ffe5e5")); domainAxis.setGridBandAlternatePaint(Color.decode("#ffe5e5")); } else if (custTrend == 0) { domainAxis.setGridBandPaint(Color.decode("#e5ffe5")); xyplot.setDomainTickBandPaint(c); } else if (custTrend == 2) { domainAxis.setGridBandPaint(Color.decode("#e6f4ff")); xyplot.setDomainTickBandPaint(c); } } String textTitle = comparisonTitle.getValue().split("bold;'>")[1].replace("</font>", ""); TextTitle title = new TextTitle(textTitle, f); scatterPlot = new JFreeChart(xyplot); scatterPlot.setTitle(title); scatterPlot.setBorderVisible(false); scatterPlot.setBackgroundPaint(Color.WHITE); scatterPlot.getLegend().setVisible(false); dsKeyDatasetMap.clear(); for (int i = 0; i < defaultScatterPlotRenderingInfo.getEntityCollection().getEntityCount(); i++) { final ChartEntity entity = defaultScatterPlotRenderingInfo.getEntityCollection().getEntity(i); if (entity instanceof XYItemEntity) { int x = ((XYItemEntity) entity).getSeriesIndex(); int y = ((XYItemEntity) entity).getItem(); if (((XYItemEntity) entity).getDataset().getYValue(x, y) > (int) ((XYItemEntity) entity).getDataset().getYValue(x, y)) { continue; } if (((XYItemEntity) entity).getSeriesIndex() > 3) { continue; } String[] arr = ((XYItemEntity) entity).getShapeCoords().split(","); int xSer = Integer.valueOf(arr[0]); int ySer = Integer.valueOf(arr[1]); int ySerEnd = Integer.valueOf(arr[3]); int patGrNumber = (int) ((XYItemEntity) entity).getDataset().getYValue(x, y); int trend = Integer.valueOf(((XYItemEntity) entity).getDataset() .getSeriesKey(((XYItemEntity) entity).getSeriesIndex()).toString()); ComparisonDetailsBean cpDetails = patientGroupsNumToDsIdMap.get(patGrNumber); List<Integer> dsList = cpDetails.getRegulatedList(trend); StringBuilder sb = new StringBuilder(); for (int dsId : dsList) { QuantDatasetObject ds; sb.append("<h4>").append((Quant_Central_Manager.getFullQuantDatasetMap().get(dsId)).getAuthor()) .append(" ") .append((Quant_Central_Manager.getFullQuantDatasetMap().get(dsId)).getYear()) .append("<h4/>"); sb.append("<p></p>"); ds = Quant_Central_Manager.getFullQuantDatasetMap().get(dsId); dsKeyDatasetMap.put("_-_" + dsId + "_-_" + comparisonProtein.getProteinAccssionNumber() + "_-_", ds); } String tooltip = sb.toString().substring(0, sb.toString().length() - 7); SquaredDot square = new SquaredDot("squared"); if (paTGrNumbtrendMap.get(patGrNumber)[trend] > 1) { square.setWidth(20 + "px"); square.setHeight(15 + "px"); } else { square.setWidth(10 + "px"); square.setHeight(10 + "px"); } square.setDescription(tooltip); square.setParam("trend", trend); square.setParam("pGrNumber", patGrNumber); int top = (ySer - 4); if (ySer > ySerEnd) { top = ySerEnd - 3; } defaultChartLayout.addComponent(square, "left: " + (xSer - 5) + "px; top: " + top + "px;"); } } }