List of usage examples for org.jfree.chart.plot CategoryPlot setRangeGridlineStroke
public void setRangeGridlineStroke(Stroke stroke)
From source file:net.imglib2.script.analysis.BarChart.java
static private void setBackgroundDefault(final JFreeChart chart) { BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 1.0f }, 0.0f); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangeGridlineStroke(gridStroke); plot.setDomainGridlineStroke(gridStroke); plot.setBackgroundPaint(new Color(235, 235, 235)); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setOutlineVisible(false);/*from www .j av a2 s. c om*/ plot.getDomainAxis().setAxisLineVisible(false); plot.getRangeAxis().setAxisLineVisible(false); plot.getDomainAxis().setLabelPaint(Color.gray); plot.getRangeAxis().setLabelPaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.gray); plot.getRangeAxis().setTickLabelPaint(Color.gray); chart.getTitle().setPaint(Color.gray); }
From source file:org.jfree.chart.demo.BarChartDemo9.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo 9", null, "Value", categorydataset, PlotOrientation.VERTICAL, false, true, false); TextTitle texttitle = jfreechart.getTitle(); texttitle.setBorder(0.0D, 0.0D, 1.0D, 0.0D); texttitle.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.red, 350F, 0.0F, Color.white, true)); texttitle.setExpandToFitSpace(true); jfreechart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.yellow, 350F, 0.0F, Color.white, true)); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setNoDataMessage("NO DATA!"); categoryplot.setBackgroundPaint(null); categoryplot.setInsets(new RectangleInsets(10D, 5D, 5D, 5D)); categoryplot.setOutlinePaint(Color.black); categoryplot.setRangeGridlinePaint(Color.gray); categoryplot.setRangeGridlineStroke(new BasicStroke(1.0F)); Paint apaint[] = createPaint(); CustomBarRenderer custombarrenderer = new CustomBarRenderer(apaint); custombarrenderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); categoryplot.setRenderer(custombarrenderer); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setRange(0.0D, 800D);//from www. j a v a2s . co m numberaxis.setTickMarkPaint(Color.black); return jfreechart; }
From source file:org.jreserve.gui.plot.charts.AbstractLineChart.java
@Override protected void formatPlot(Plot plot) { CategoryPlot cPlot = (CategoryPlot) plot; cPlot.setBackgroundPaint(format.getBackgroundColor()); cPlot.setRangeGridlinesVisible(true); cPlot.setRangeGridlinePaint(format.getGridColor()); cPlot.setRangeGridlineStroke(new BasicStroke(3)); cPlot.setDomainGridlinesVisible(true); cPlot.setDomainGridlinePaint(format.getGridColor()); cPlot.setDomainGridlineStroke(new BasicStroke(3)); formatSeries((LineAndShapeRenderer) cPlot.getRenderer()); formatRangeAxis(getMinValue(), getMaxValue()); }
From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo9.java
/** * Creates a sample chart.//w w w . ja v a2 s . com * * @param dataset the dataset. * * @return a sample chart. */ protected JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation !legendPanelOn, // include legend true, false); TextTitle title = chart.getTitle(); title.setBorder(0, 0, 1, 0); title.setBackgroundPaint(new GradientPaint(0f, 0f, Color.red, 350f, 0f, Color.white, true)); title.setExpandToFitSpace(true); chart.setBackgroundPaint(new GradientPaint(0f, 0f, Color.yellow, 350f, 0f, Color.white, true)); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA!"); plot.setBackgroundPaint(null); plot.setInsets(new RectangleInsets(10, 5, 5, 5)); plot.setOutlinePaint(Color.black); plot.setRangeGridlinePaint(Color.gray); plot.setRangeGridlineStroke(new BasicStroke(1.0f)); Paint[] colors = createPaint(); CustomBarRenderer renderer = new CustomBarRenderer(colors); renderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); plot.setRenderer(renderer); renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); // change the margin at the top of the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // rangeAxis.setRange(0.0, 800.0); rangeAxis.setTickMarkPaint(Color.black); setCategorySummary(dataset); return chart; }
From source file:ca.sqlpower.wabit.swingui.chart.ChartSwingUtil.java
/** * Sets the colours and gradients to be used when painting the given JFreeChart. * /*w w w . j a va 2 s. c o m*/ * @param chart * The JFreeChart to make nice. */ public static void makeChartNice(JFreeChart chart) { Plot plot = chart.getPlot(); chart.setBackgroundPaint(null); chart.setBorderStroke(new BasicStroke(1f)); chart.setBorderPaint(new Color(0xDDDDDD)); chart.setBorderVisible(true); // TODO Should we add an option for subtitles, this is where it would go. // TextTitle subTitle = new TextTitle("What's up doc?", // new Font("SansSerif", Font.BOLD, 8)); // chart.addSubtitle(subTitle); // overall plot plot.setOutlinePaint(null); plot.setInsets(new RectangleInsets(0, 5, 0, 5)); // also the overall chart panel plot.setBackgroundPaint(null); plot.setDrawingSupplier(new WabitDrawingSupplier()); // legend LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setBorder(0, 0, 0, 0); legend.setBackgroundPaint(null); legend.setPadding(2, 2, 2, 2); } if (plot instanceof CategoryPlot) { CategoryPlot cplot = (CategoryPlot) plot; CategoryItemRenderer renderer = cplot.getRenderer(); if (renderer instanceof BarRenderer) { BarRenderer brenderer = (BarRenderer) renderer; brenderer.setBarPainter(new StandardBarPainter()); brenderer.setDrawBarOutline(false); brenderer.setShadowVisible(false); brenderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); } else if (renderer instanceof LineAndShapeRenderer) { // it's all taken care of by WabitDrawingSupplier } else { logger.warn("I don't know how to make " + renderer + " pretty. Leaving ugly."); } cplot.setRangeGridlinePaint(Color.BLACK); cplot.setRangeGridlineStroke(GRIDLINE_STROKE); // axes for (int i = 0; i < cplot.getDomainAxisCount(); i++) { CategoryAxis axis = cplot.getDomainAxis(i); axis.setAxisLineVisible(false); } for (int i = 0; i < cplot.getRangeAxisCount(); i++) { ValueAxis axis = cplot.getRangeAxis(i); axis.setAxisLineVisible(false); } } if (plot instanceof MultiplePiePlot) { MultiplePiePlot mpplot = (MultiplePiePlot) plot; JFreeChart pchart = mpplot.getPieChart(); PiePlot3DGradient pplot = (PiePlot3DGradient) pchart.getPlot(); pplot.setBackgroundPaint(null); pplot.setOutlinePaint(null); pplot.setFaceGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); pplot.setSideGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); CategoryDataset data = mpplot.getDataset(); Color[][] colours = WabitDrawingSupplier.SERIES_COLOURS; //Set all colours for (int i = 0; i < colours.length; i++) { if (data.getColumnCount() >= i + 1) { pplot.setSectionOutlinePaint(data.getColumnKey(i), null); GradientPaint gradient = new GradientPaint(0, 0f, colours[i][0], 100, 0f, colours[i][1]); pplot.setSectionPaint(data.getColumnKey(i), gradient); gradient = new GradientPaint(0, 0f, colours[i][1], 100, 0f, colours[i][0]); pplot.setSidePaint(data.getColumnKey(i), gradient); } } } // Tweak the title font size chart.getTitle().setFont(chart.getTitle().getFont().deriveFont(14f)); chart.getTitle().setPadding(5, 0, 5, 0); chart.setAntiAlias(true); // shrink padding chart.setPadding(new RectangleInsets(0, 0, 0, 0)); }
From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java
/** * *//* w w w . j av a 2 s . co m*/ protected void configurePlot(Plot plot, JRChartPlot jrPlot) { super.configurePlot(plot, jrPlot); if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = (CategoryPlot) plot; CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { categoryRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT); } } categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); categoryPlot.setRangeGridlineStroke(new BasicStroke(0.5f)); categoryPlot.setDomainGridlinesVisible(false); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); } else if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; XYItemRenderer xyItemRenderer = xyPlot.getRenderer(); XYDataset xyDataset = xyPlot.getDataset(); if (xyDataset != null) { for (int i = 0; i < xyDataset.getSeriesCount(); i++) { xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT); } } xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); xyPlot.setRangeGridlineStroke(new BasicStroke(0.5f)); xyPlot.setDomainGridlinesVisible(false); xyPlot.setRangeZeroBaselineVisible(true); } }
From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.java
@Override protected void configurePlot(Plot plot, JRChartPlot jrPlot) { super.configurePlot(plot, jrPlot); if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = (CategoryPlot) plot; CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { categoryRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT); }/* w w w . java 2s . com*/ } categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); categoryPlot.setRangeGridlineStroke(new BasicStroke(0.5f)); categoryPlot.setDomainGridlinesVisible(false); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); } else if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; XYItemRenderer xyItemRenderer = xyPlot.getRenderer(); XYDataset xyDataset = xyPlot.getDataset(); if (xyDataset != null) { for (int i = 0; i < xyDataset.getSeriesCount(); i++) { xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT); } } xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); xyPlot.setRangeGridlineStroke(new BasicStroke(0.5f)); xyPlot.setDomainGridlinesVisible(false); xyPlot.setRangeZeroBaselineVisible(true); } }
From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java
/** * *//*from w ww.jav a 2s . co m*/ protected JFreeChart createGanttChart() throws JRException { JFreeChart jfreeChart = super.createGanttChart(); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); categoryPlot.setDomainGridlinesVisible(true); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.setDomainGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); categoryPlot.setRangeGridlinesVisible(true); categoryPlot.setRangeGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); // JRBarPlot barPlot = (BarPlot)categoryPlot; // categoryPlot.getDomainAxis().setTickLabelsVisible( // categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels(). // true // ); CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelsVisible(true); BarRenderer barRenderer = (BarRenderer) categoryRenderer; List seriesPaints = (List) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS); barRenderer.setSeriesPaint(0, (Paint) seriesPaints.get(3)); barRenderer.setSeriesPaint(1, (Paint) seriesPaints.get(0)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont()); barRenderer.setSeriesItemLabelsVisible(i, true); // barRenderer.setSeriesPaint(i, GRADIENT_PAINTS[i]); // CategoryMarker categoryMarker = new CategoryMarker(categoryDataset.getColumnKey(i),MARKER_COLOR, new BasicStroke(1f)); // categoryMarker.setAlpha(0.5f); // categoryPlot.addDomainMarker(categoryMarker, Layer.BACKGROUND); } } categoryPlot.setOutlinePaint(Color.DARK_GRAY); categoryPlot.setOutlineStroke(new BasicStroke(1.5f)); categoryPlot.setOutlineVisible(true); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.java
@Override protected JFreeChart createGanttChart() throws JRException { JFreeChart jfreeChart = super.createGanttChart(); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); categoryPlot.setDomainGridlinesVisible(true); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.setDomainGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); categoryPlot.setRangeGridlinesVisible(true); categoryPlot.setRangeGridlineStroke( new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0)); categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); // JRBarPlot barPlot = (BarPlot)categoryPlot; // categoryPlot.getDomainAxis().setTickLabelsVisible( // categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels(). // true // ); CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelsVisible(true); BarRenderer barRenderer = (BarRenderer) categoryRenderer; @SuppressWarnings("unchecked") List<Paint> seriesPaints = (List<Paint>) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS); barRenderer.setSeriesPaint(0, seriesPaints.get(3)); barRenderer.setSeriesPaint(1, seriesPaints.get(0)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont()); barRenderer.setSeriesItemLabelsVisible(i, true); // barRenderer.setSeriesPaint(i, GRADIENT_PAINTS[i]); // CategoryMarker categoryMarker = new CategoryMarker(categoryDataset.getColumnKey(i),MARKER_COLOR, new BasicStroke(1f)); // categoryMarker.setAlpha(0.5f); // categoryPlot.addDomainMarker(categoryMarker, Layer.BACKGROUND); }//from w ww. ja v a2s . co m } categoryPlot.setOutlinePaint(Color.DARK_GRAY); categoryPlot.setOutlineStroke(new BasicStroke(1.5f)); categoryPlot.setOutlineVisible(true); return jfreeChart; }
From source file:org.tiefaces.components.websheet.chart.ChartHelper.java
/** * finalize the style for jfreechart. The default setting is different from * jfreechart and Excel. We try to minimize the difference. * /*from ww w . j ava2 s . co m*/ * @param chart * jfreechart. * @param chartData * contain information gathered from excel chart object. */ private void setupStyle(final JFreeChart chart, final ChartData chartData) { CategoryPlot plot = (CategoryPlot) chart.getPlot(); List<ChartSeries> seriesList = chartData.getSeriesList(); BasicStroke bLine = new BasicStroke(2.0f); for (int i = 0; i < seriesList.size(); i++) { Color cColor = ColorUtility.xssfClrToClr(seriesList.get(i).getSeriesColor().getXssfColor()); plot.getRenderer().setSeriesPaint(i, cColor); plot.getRenderer().setSeriesStroke(i, bLine); } plot.setBackgroundPaint(ColorUtility.xssfClrToClr(chartData.getBgColor().getXssfColor())); // below are modifications for default setting in excel chart // to-do: need read setting from xml in future plot.setOutlineVisible(false); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setRangeGridlineStroke(new BasicStroke(TieConstants.DEFAULT_BASIC_STROKE)); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); chart.setBackgroundPaint(Color.WHITE); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); legend.setFrame(BlockBorder.NONE); }