List of usage examples for java.awt Color gray
Color gray
To view the source code for java.awt Color gray.
Click Source Link
From source file:org.cyberoam.iview.charts.CustomToolTipGeneratorForPie3D.java
/** * This method generates JFreeChart instance for 3D Pie chart with iView customization. * @param reportID specifies that for which report Chart is being prepared. * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from uri. * @return jfreechart instance with iView Customization. *///w ww . j a v a 2 s.c o m public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { boolean xFlag = false; ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null; try { ReportColumnBean reportColumnBean, reportColumnBeanX = null; GraphBean graphBean = null; DataLinkBean dataLinkBean = null; DefaultPieDataset dataset = new DefaultPieDataset(); graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis // String xColumnDBname = reportColumnBeanX.getDbColumnName(); if (reportColumnBeanX.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBeanX.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getZColumnId()); rsw.beforeFirst(); reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnName = reportColumnBean.getColumnName(); if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } String xData = null; while (rsw.next()) { xData = rsw.getString(reportColumnBeanX.getDbColumnName()); if (xData == null || "".equalsIgnoreCase(xData) || "null".equalsIgnoreCase(xData)) { xData = "N/A"; } else if (reportColumnBeanX.getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING && xData.indexOf(':') != -1) { String data = data = ProtocolBean.getProtocolNameById(Integer.parseInt( rsw.getString(reportColumnBeanX.getDbColumnName()).substring(0, xData.indexOf(':')))); xData = data + rsw.getString(reportColumnBeanX.getDbColumnName()).substring(xData.indexOf(':'), xData.length()); } dataset.setValue(xData, new Long(rsw.getLong(reportColumnBean.getDbColumnName()))); } chart = ChartFactory.createPieChart3D("", // chart title dataset, // data true, // include legend true, // tooltips? false // URLs? ); /* *Setting additional customization to the chart. */ //Set the background color for the chart... chart.setBackgroundPaint(Color.white); //Get a reference to the plot for further customisation... PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setBackgroundAlpha(0.0f); plot.setSectionOutlinesVisible(false); plot.setOutlineVisible(false); plot.setStartAngle(290); plot.setDepthFactor(0.1); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage("No data to display"); plot.setSectionOutlinesVisible(false); plot.setSectionOutlinePaint(Color.white); plot.setOutlineVisible(false); plot.setExplodePercent(dataset.getKey(0), 0.3); plot.setLabelLinkPaint(Color.gray); plot.setLabelBackgroundPaint(Color.white); plot.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10)); plot.setLabelOutlinePaint(Color.white); plot.setLabelShadowPaint(Color.white); LegendTitle legend = chart.getLegend(); legend.setItemFont(new Font("Arial", Font.CENTER_BASELINE, 10)); legend.setMargin(0, 0, 2, 0); legend.setHorizontalAlignment(HorizontalAlignment.CENTER); plot.setToolTipGenerator(new CustomToolTipGeneratorForPie3D("{0}: ({1} " + yColumnName + ", {2})")); //Setting Color try { plot.setSectionPaint(dataset.getKey(0), Pie3D.pieSections[0]); plot.setSectionPaint(dataset.getKey(1), Pie3D.pieSections[1]); plot.setSectionPaint(dataset.getKey(2), Pie3D.pieSections[2]); plot.setSectionPaint(dataset.getKey(3), Pie3D.pieSections[3]); plot.setSectionPaint(dataset.getKey(4), Pie3D.pieSections[4]); } catch (Exception e) { } } catch (Exception e) { CyberoamLogger.appLog.debug("Pie3D.e:" + e, e); } return chart; }
From source file:com.manydesigns.portofino.chart.Chart2DGenerator.java
public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); java.util.List<Object[]> result; String query = chartDefinition.getQuery(); logger.info(query);/*from w w w .ja va 2 s. c o m*/ Session session = persistence.getSession(chartDefinition.getDatabase()); result = QueryUtils.runSql(session, query); for (Object[] current : result) { ComparableWrapper x = new ComparableWrapper((Comparable) current[0]); ComparableWrapper y = new ComparableWrapper((Comparable) current[1]); if (current.length > 3) { x.setLabel(current[3].toString()); } if (current.length > 4) { y.setLabel(current[4].toString()); } dataset.setValue((Number) current[2], x, y); } PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL; if (chartDefinition.getActualOrientation() == ChartDefinition.Orientation.VERTICAL) { plotOrientation = PlotOrientation.VERTICAL; } JFreeChart chart = createChart(chartDefinition, dataset, plotOrientation); chart.setAntiAlias(antiAlias); // impostiamo il bordo invisibile // eventualmente e' il css a fornirne uno chart.setBorderVisible(borderVisible); // impostiamo il titolo TextTitle title = chart.getTitle(); title.setFont(titleFont); title.setMargin(10.0, 0.0, 0.0, 0.0); // ottieni il Plot CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); String urlExpression = chartDefinition.getUrlExpression(); if (!StringUtils.isBlank(urlExpression)) { CategoryURLGenerator urlGenerator = new ChartBarUrlGenerator(chartDefinition.getUrlExpression()); renderer.setBaseItemURLGenerator(urlGenerator); } else { renderer.setBaseItemURLGenerator(null); } renderer.setBaseOutlinePaint(Color.BLACK); // /////////////// if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setDrawBarOutline(true); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardBarPainter()); } // /////////////// // il plot ha sfondo e bordo trasparente // (quindi si vede il colore del chart) plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); // Modifico il toolTip // plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} = {1} ({2})")); // imposta il messaggio se non ci sono dati plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available")); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.GRAY); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); // Category axis CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setAxisLinePaint(Color.BLACK); categoryAxis.setLabelFont(axisFont); categoryAxis.setAxisLineVisible(true); // impostiamo la rotazione dell'etichetta if (plot.getOrientation() == PlotOrientation.VERTICAL) { CategoryLabelPosition pos = new CategoryLabelPosition(RectangleAnchor.TOP_LEFT, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 4.0, CategoryLabelWidthType.CATEGORY, 100); CategoryLabelPositions positions = new CategoryLabelPositions(pos, pos, pos, pos); categoryAxis.setCategoryLabelPositions(positions); categoryAxis.setMaximumCategoryLabelWidthRatio(6.0f); height = 333; } else { categoryAxis.setMaximumCategoryLabelWidthRatio(0.4f); // recuperiamo 8 pixel a sinistra plot.setInsets(new RectangleInsets(4.0, 0.0, 4.0, 8.0)); height = 74; // contiamo gli elementi nel dataset height += 23 * dataset.getColumnCount(); height += 57; } Axis rangeAxis = plot.getRangeAxis(); rangeAxis.setAxisLinePaint(Color.BLACK); rangeAxis.setLabelFont(axisFont); DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier()); plot.setDrawingSupplier(supplier); // ? plot.setForegroundAlpha(1.0f); // impostiamo il titolo della legenda String legendString = chartDefinition.getLegend(); Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); subtitle.setMargin(0, 0, 5, 0); chart.addSubtitle(subtitle); // impostiamo la legenda LegendTitle legend = chart.getLegend(); legend.setBorder(0, 0, 0, 0); legend.setItemFont(legendItemFont); int legendMargin = 10; legend.setMargin(0.0, legendMargin, legendMargin, legendMargin); legend.setBackgroundPaint(transparentColor); // impostiamo un gradiente orizzontale Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, height, Color.WHITE); chart.setBackgroundPaint(chartBgPaint); return chart; }
From source file:it.cnr.istc.utils.gui.ReverseGradientXYBarPainter.java
/** * Paints a single bar instance./*ww w . j ava2 s .c om*/ * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param bar the bar * @param base indicates which side of the rectangle is the base of the bar. * @param pegShadow peg the shadow to the base of the bar? */ @Override public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base, boolean pegShadow) { // handle a special case - if the bar colour has alpha == 0, it is // invisible so we shouldn't draw any shadow Paint itemPaint = renderer.getItemPaint(row, column); if (itemPaint instanceof Color) { Color c = (Color) itemPaint; if (c.getAlpha() == 0) { return; } } RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), renderer.getShadowYOffset(), base, pegShadow); g2.setPaint(Color.gray); g2.fill(shadow); }
From source file:i2p.bote.web.PeerInfoTag.java
private String createDhtChart(DhtPeerStats dhtStats) throws IOException { RingPlot plot;//from w ww . j a va2 s . c o m int numDhtPeers = dhtStats.getData().size(); if (numDhtPeers == 0) { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("", 100); plot = new RingPlot(dataset); plot.setSectionPaint("", Color.gray); } else { int reachable = 0; for (List<String> row : dhtStats.getData()) { if (_t("No").equals(row.get(4))) reachable += 1; } int unreachable = numDhtPeers - reachable; DefaultPieDataset dataset = new DefaultPieDataset(); if (reachable > 0) dataset.setValue(_t("Reachable"), reachable); if (unreachable > 0) dataset.setValue(_t("Unreachable"), unreachable); plot = new RingPlot(dataset); plot.setSectionPaint(_t("Reachable"), Color.green); plot.setSectionPaint(_t("Unreachable"), Color.red); } plot.setLabelGenerator(null); plot.setShadowGenerator(null); JFreeChart dhtChart = new JFreeChart(_t("Kademlia Peers:"), JFreeChart.DEFAULT_TITLE_FONT, plot, numDhtPeers == 0 ? false : true); return ServletUtilities.saveChartAsPNG(dhtChart, 400, 300, null); }
From source file:org.bench4Q.console.ui.section.LW_ConfigLoadShowSection.java
/** * @param args/*from w w w. j ava 2 s . c om*/ * @return * @throws IOException */ public JPanel drawPreviewPic(Args args) throws IOException { XYSeriesCollection dataset = new XYSeriesCollection(); ArrayList<TestPhase> ebs = args.getEbs(); int prepairTime = args.getPrepair(); int cooldownTime = args.getCooldown(); ArrayList<XYSeries> series = new ArrayList<XYSeries>(); int i = 1; for (TestPhase phase : ebs) { XYSeries seriesBasic = new XYSeries("Basic " + i); XYSeries seriesRandom = new XYSeries("Random " + i); series.add(seriesBasic); series.add(seriesRandom); int startTime = prepairTime + phase.getTriggerTime(); int endTime = startTime + phase.getStdyTime(); int startLoad = phase.getBaseLoad(); int endLoad = startLoad + phase.getStdyTime() * phase.getRate(); int startRadomLoad = startLoad + phase.getRandomLoad(); int endRadomLoad = endLoad + phase.getRandomLoad(); seriesBasic.add(new Double(startTime), new Integer(0)); seriesBasic.add(new Double(startTime), new Integer(startLoad)); seriesBasic.add(new Double(endTime), new Integer(endLoad)); seriesBasic.add(new Double(endTime), new Integer(0)); dataset.addSeries(seriesBasic); seriesRandom.add(new Double(startTime), new Integer(endLoad)); seriesRandom.add(new Double(startTime), new Integer(startRadomLoad)); seriesRandom.add(new Double(endTime), new Integer(endRadomLoad)); seriesRandom.add(new Double(endTime), new Integer(0)); dataset.addSeries(seriesRandom); i++; } final JFreeChart chart = ChartFactory.createXYStepAreaChart("Stacked Area Chart", // chart // title "time", // domain axis label "load", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, false); chart.setBackgroundPaint(Color.white); // color final XYPlot plot = chart.getXYPlot(); int j = 0; for (XYSeries s : series) { if (j % 2 == 0) { plot.getRenderer().setSeriesPaint(j, Color.white); } else { plot.getRenderer().setSeriesPaint(j, Color.gray); } j++; } // fill shapes final XYStepAreaRenderer rend = (XYStepAreaRenderer) plot.getRenderer(); rend.setShapesFilled(true); return new ChartPanel(chart); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.Meter.java
/** * Creates the chart ./*w w w .j a v a 2s. co m*/ * * @param chartTitle the chart title. * @param dataset the dataset. * * @return A chart . */ public JFreeChart createChart(DatasetMap datasets) { Dataset dataset = (Dataset) datasets.getDatasets().get("1"); MeterPlot plot = new MeterPlot((ValueDataset) dataset); plot.setRange(new Range(lower, upper)); for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); plot.addInterval(new MeterInterval(interval.getLabel(), new Range(interval.getMin(), interval.getMax()), Color.lightGray, new BasicStroke(2.0f), interval.getColor())); } plot.setNeedlePaint(Color.darkGray); plot.setDialBackgroundPaint(Color.white); plot.setDialOutlinePaint(Color.gray); plot.setDialShape(DialShape.CHORD); plot.setMeterAngle(260); plot.setTickLabelsVisible(true); //set tick label style Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize()); plot.setTickLabelFont(tickLabelsFont); plot.setTickLabelPaint(labelsTickStyle.getColor()); plot.setTickSize(5.0); plot.setTickPaint(Color.lightGray); if (units != null) { plot.setUnits(units); } plot.setValuePaint(labelsValueStyle.getColor()); plot.setValueFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize())); JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(color); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } return chart; }
From source file:playground.dgrether.analysis.categoryhistogram.CategoryHistogramWriter.java
public JFreeChart getGraphic(final CategoryHistogram histo, final String modeName) { this.checkIndex(histo); final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries departuresSerie = new XYSeries(this.departuresName, false, true); final XYSeries arrivalsSerie = new XYSeries(this.arrivalsName, false, true); final XYSeries onRouteSerie = new XYSeries(this.enRouteName, false, true); Integer enRoute = 0;/* w w w . ja va 2s. co m*/ for (int i = histo.getFirstIndex() - 2; i <= histo.getLastIndex() + 2; i++) { int departures = histo.getDepartures(modeName, i); int arrivals = histo.getArrivals(modeName, i); int stuck = histo.getAbort(modeName, i); enRoute = enRoute + departures - arrivals - stuck; double hour = i * histo.getBinSizeSeconds() / 60.0 / 60.0; departuresSerie.add(hour, departures); arrivalsSerie.add(hour, arrivals); onRouteSerie.add(hour, enRoute); } xyData.addSeries(departuresSerie); xyData.addSeries(arrivalsSerie); xyData.addSeries(onRouteSerie); final JFreeChart chart = ChartFactory.createXYStepChart( this.title + ", " + modeName + ", " + "it." + histo.getIteration(), "time [h]", yTitle, xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(1.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(1.0f)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setDomainGridlinePaint(Color.gray); return chart; }
From source file:org.knime.knip.core.ui.imgviewer.panels.HistogramBC.java
private final void setTheme(final JFreeChart chart) { final XYPlot plot = (XYPlot) chart.getPlot(); final XYBarRenderer r = (XYBarRenderer) plot.getRenderer(); final StandardXYBarPainter bp = new StandardXYBarPainter(); r.setBarPainter(bp);/*from w w w .j ava2 s . com*/ // set Bar Color r.setSeriesPaint(0, Color.gray); r.setSeriesOutlinePaint(0, Color.gray); r.setShadowVisible(false); r.setDrawBarOutline(true); setBackgroundDefault(chart); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setTickLabelsVisible(false); rangeAxis.setTickMarksVisible(false); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setTickLabelsVisible(false); domainAxis.setTickMarksVisible(false); }
From source file:com.rapidminer.gui.plotter.charts.SeriesChartPlotter.java
private JFreeChart createChart(XYDataset dataset, boolean createLegend) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, createLegend, // include legend true, // tooltips false // urls );/*from w w w .jav a 2 s. c o m*/ chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customization... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); DeviationRenderer renderer = new DeviationRenderer(true, false); // colors if (dataset.getSeriesCount() == 1) { renderer.setSeriesStroke(0, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setSeriesPaint(0, getColorProvider().getPointColor(1.0d)); } else { // special case needed for avoiding devision by zero for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setSeriesPaint(i, getColorProvider().getPointColor(1.0d - i / (double) (dataset.getSeriesCount() - 1))); } } // background for bounds if (plotBounds) { float[] dashArray = new float[] { 7, 14 }; renderer.setSeriesStroke(boundsSeriesIndex, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, dashArray, 0)); renderer.setSeriesPaint(boundsSeriesIndex, Color.GRAY.brighter()); renderer.setSeriesFillPaint(boundsSeriesIndex, Color.GRAY); } // alpha renderer.setAlpha(0.25f); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); if (axis[INDEX] < 0) { xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US)); xAxis.setLabel(SERIESINDEX_LABEL); Range range = getRangeForName(SERIESINDEX_LABEL); if (range == null) { xAxis.setAutoRange(true); xAxis.setAutoRangeStickyZero(false); xAxis.setAutoRangeIncludesZero(false); } else { xAxis.setRange(range, true, false); } } else { xAxis.setLabel(dataTable.getColumnName(axis[INDEX])); Range range = getRangeForDimension(axis[INDEX]); if (range == null) { xAxis.setAutoRange(true); xAxis.setAutoRangeStickyZero(false); xAxis.setAutoRangeIncludesZero(false); } else { xAxis.setRange(range, true, false); } } xAxis.setLabelFont(LABEL_FONT_BOLD); xAxis.setTickLabelFont(LABEL_FONT); xAxis.setVerticalTickLabels(isLabelRotating()); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setLabel(VALUEAXIS_LABEL); yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); setYAxisRange(yAxis); yAxis.setLabelFont(LABEL_FONT_BOLD); yAxis.setTickLabelFont(LABEL_FONT); return chart; }
From source file:com.envision.envservice.report.template.PraiseReportExcel.java
private static void buildTitleRow(XSSFWorkbook workbook, XSSFSheet sheet) { buildTitleCells(sheet.createRow(INDEX_SHEET_DAY), buildStyle(workbook, Color.GRAY)); }