List of usage examples for org.jfree.chart.renderer.category BarRenderer3D setBaseItemLabelGenerator
@Override public void setBaseItemLabelGenerator(CategoryItemLabelGenerator generator)
From source file:org.eevolution.form.CRPDetail.java
/** * Create Chart based on UOM/*from w w w .j av a2 s . c o m*/ * * @param dataset * @param title * @param uom * @return JFreeChart Chart based On UOM */ public JFreeChart createChart(CategoryDataset dataset, String title, MUOM uom) { JFreeChart chart = ChartFactory.createBarChart3D(title, Msg.translate(Env.getCtx(), "Day"), // X-Axis label Msg.translate(Env.getCtx(), (uom == null) ? "" : uom.getName()), // Y-Axis // label dataset, // Dataset PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); chart.setBackgroundPaint(Color.WHITE); chart.setAntiAlias(true); chart.setBorderVisible(true); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.GRAY); BarRenderer3D barrenderer = (BarRenderer3D) plot.getRenderer(); barrenderer.setDrawBarOutline(false); barrenderer.setBaseItemLabelGenerator(new LabelGenerator()); barrenderer.setBaseItemLabelsVisible(true); barrenderer.setSeriesPaint(0, new Color(10, 80, 150, 128)); barrenderer.setSeriesPaint(1, new Color(180, 60, 50, 128)); ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER); barrenderer.setPositiveItemLabelPosition(itemlabelposition); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:org.bench4Q.console.ui.section.S_SummarizeSection.java
/** * @return/* w w w. ja v a 2 s.c o m*/ * @throws IOException */ public JPanel drawSessionPic() throws IOException { CategoryDataset dataset = getDataSet(); JFreeChart chart = ChartFactory.createBarChart3D("Session", "Session type", "Session number", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.1); domainAxis.setUpperMargin(0.1); domainAxis.setCategoryLabelPositionOffset(10); domainAxis.setCategoryMargin(0.2); org.jfree.chart.axis.ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setUpperMargin(0.1); org.jfree.chart.renderer.category.BarRenderer3D renderer; renderer = new org.jfree.chart.renderer.category.BarRenderer3D(); renderer.setBaseOutlinePaint(Color.red); renderer.setSeriesPaint(0, new Color(0, 255, 255)); renderer.setSeriesOutlinePaint(0, Color.BLACK); renderer.setSeriesPaint(1, new Color(0, 255, 0)); renderer.setSeriesOutlinePaint(1, Color.red); renderer.setItemMargin(0.1); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelFont(new Font("", Font.PLAIN, 12)); renderer.setItemLabelPaint(Color.black); renderer.setItemLabelsVisible(true); plot.setRenderer(renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setBackgroundPaint(Color.WHITE); return new ChartPanel(chart); }
From source file:com.netflix.ice.basic.BasicWeeklyCostEmailService.java
private File createImage(ApplicationGroup appgroup) throws IOException { Map<String, Double> costs = Maps.newHashMap(); DateTime end = new DateTime(DateTimeZone.UTC).withDayOfWeek(1).withMillisOfDay(0); Interval interval = new Interval(end.minusWeeks(numWeeks), end); for (Product product : products) { List<ResourceGroup> resourceGroups = getResourceGroups(appgroup, product); if (resourceGroups.size() == 0) { continue; }/*w ww. j av a 2s. c o m*/ DataManager dataManager = config.managers.getCostManager(product, ConsolidateType.weekly); if (dataManager == null) { continue; } TagLists tagLists = new TagLists(accounts, regions, null, Lists.newArrayList(product), null, null, resourceGroups); Map<Tag, double[]> data = dataManager.getData(interval, tagLists, TagType.Product, AggregateType.none, false); for (Tag tag : data.keySet()) { for (int week = 0; week < numWeeks; week++) { String key = tag + "|" + week; if (costs.containsKey(key)) costs.put(key, data.get(tag)[week] + costs.get(key)); else costs.put(key, data.get(tag)[week]); } } } boolean hasData = false; for (Map.Entry<String, Double> entry : costs.entrySet()) { if (!entry.getKey().contains("monitor") && entry.getValue() != null && entry.getValue() >= 0.1) { hasData = true; break; } } if (!hasData) return null; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Product product : products) { for (int week = 0; week < numWeeks; week++) { String weekStr = String.format("%s - %s week", formatter.print(end.minusWeeks(numWeeks - week)).substring(5), formatter.print(end.minusWeeks(numWeeks - week - 1)).substring(5)); dataset.addValue(costs.get(product + "|" + week), product.name, weekStr); } } JFreeChart chart = ChartFactory.createBarChart3D(appgroup.getDisplayName() + " Weekly AWS Costs", "", "Costs", dataset, PlotOrientation.VERTICAL, true, false, false); CategoryPlot categoryplot = (CategoryPlot) chart.getPlot(); BarRenderer3D renderer = (BarRenderer3D) categoryplot.getRenderer(); renderer.setItemLabelAnchorOffset(10.0); TextTitle title = chart.getTitle(); title.setFont(title.getFont().deriveFont((title.getFont().getSize() - 3))); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator() { public java.lang.String generateLabel(org.jfree.data.category.CategoryDataset dataset, int row, int column) { return costFormatter.format(dataset.getValue(row, column)); } }); renderer.setBaseItemLabelsVisible(true); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER)); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setNumberFormatOverride(costFormatter); BufferedImage image = chart.createBufferedImage(1200, 400); File outputfile = File.createTempFile("awscost", "png"); ImageIO.write(image, "png", outputfile); return outputfile; }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
protected JFreeChart createBar3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBarChart3D( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBar3DPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRBar3DPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false);// w w w.j a va2s.co m configureChart(jfreeChart); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); JRBar3DPlot bar3DPlot = (JRBar3DPlot) getPlot(); BarRenderer3D barRenderer3D = new BarRenderer3D( bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(), bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()); boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels(); barRenderer3D.setBaseItemLabelsVisible(isShowLabels); if (isShowLabels) { JRItemLabel itemLabel = bar3DPlot.getItemLabel(); barRenderer3D.setBaseItemLabelFont( fontUtil.getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale())); if (itemLabel != null) { if (itemLabel.getColor() != null) { barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor()); } else { barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } // categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor()); // if (itemLabel.getMask() != null) // { // barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( // StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, // new DecimalFormat(itemLabel.getMask()))); // } // else // { barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); // } } else { barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } } categoryPlot.setRenderer(barRenderer3D); // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(), bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(), bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisVerticalTickLabels(), bar3DPlot.getCategoryAxisLineColor(), false, (Comparable<?>) evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(), bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(), bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisVerticalTickLabels(), bar3DPlot.getValueAxisLineColor(), true, (Comparable<?>) evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java
private JFreeChart createCategoryBarChart(String title, String xLabel, String yLabel, CategoryDataset dataset) { // System.out.println("layout = "+layout); JFreeChart chart;// www . j a va 2 s. c om if (dimension.equalsIgnoreCase("3d")) { chart = ChartFactory.createBarChart3D(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data orientation, // orientation true, // include legend true, // tooltips false // urls ); CategoryPlot plot = chart.getCategoryPlot(); plot.setDomainGridlinesVisible(true); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0)); BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); //renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); renderer.setDrawBarOutline(false); return chart; } if (layout.equalsIgnoreCase("stacked")) { chart = ChartFactory.createStackedBarChart(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data orientation, // the plot orientation true, // legend true, // tooltips false // urls ); } else if (layout.equalsIgnoreCase("waterfall")) { chart = ChartFactory.createWaterfallChart(title, xLabel, yLabel, dataset, orientation, true, true, false); CategoryPlot plot = chart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); DecimalFormat labelFormatter = new DecimalFormat("$##,###.00"); labelFormatter.setNegativePrefix("("); labelFormatter.setNegativeSuffix(")"); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", labelFormatter)); renderer.setBaseItemLabelsVisible(true); } else { chart = ChartFactory.createBarChart(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data orientation, // orientation true, // include legend true, // tooltips? false // URLs? ); } // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... if (layout.equalsIgnoreCase("stacked")) { StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setBaseItemLabelsVisible(true); renderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator()); } else if (layout.equalsIgnoreCase("layered")) { LayeredBarRenderer renderer = new LayeredBarRenderer(); renderer.setDrawBarOutline(false); plot.setRenderer(renderer); plot.setRowRenderingOrder(SortOrder.DESCENDING); } else { BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); } /* CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0) );*/ // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
protected JFreeChart createBar3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBarChart3D( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRBar3DPlot) getPlot()).getCategoryAxisLabelExpression()), (String) evaluateExpression(((JRBar3DPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); JRBar3DPlot bar3DPlot = (JRBar3DPlot) getPlot(); BarRenderer3D barRenderer3D = new BarRenderer3D( bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble().doubleValue(), bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble().doubleValue()); boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels().booleanValue(); barRenderer3D.setBaseItemLabelsVisible(isShowLabels); if (isShowLabels) { JRItemLabel itemLabel = bar3DPlot.getItemLabel(); JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : new JRBaseFont(getChart(), null); barRenderer3D.setBaseItemLabelFont(JRFontUtil.getAwtFont(font, getLocale())); if (itemLabel != null) { if (itemLabel.getColor() != null) { barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor()); } else { barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); }/*w w w .jav a2 s .co m*/ // categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor()); // if(itemLabel.getMask() != null) // { // barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( // StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, // new DecimalFormat(itemLabel.getMask()))); // } // else // { barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); // } } else { barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } } categoryPlot.setRenderer(barRenderer3D); // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(), bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(), bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisVerticalTickLabels(), bar3DPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable) evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(), bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(), bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisVerticalTickLabels(), bar3DPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable) evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
protected JFreeChart createBar3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBarChart3D( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRBar3DPlot) getPlot()).getCategoryAxisLabelExpression()), (String) evaluateExpression(((JRBar3DPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); JRBar3DPlot bar3DPlot = (JRBar3DPlot) getPlot(); BarRenderer3D barRenderer3D = new BarRenderer3D( bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble().doubleValue(), bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble().doubleValue()); boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels().booleanValue(); barRenderer3D.setBaseItemLabelsVisible(isShowLabels); if (isShowLabels) { JRItemLabel itemLabel = bar3DPlot.getItemLabel(); Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE); JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null; barRenderer3D.setBaseItemLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize)); if (itemLabel != null) { if (itemLabel.getColor() != null) { barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor()); } else { barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); }/*from www . j av a 2 s . co m*/ // categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor()); // if(itemLabel.getMask() != null) // { // barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( // StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, // new DecimalFormat(itemLabel.getMask()))); // } // else // { barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); // } } else { barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } } categoryPlot.setRenderer(barRenderer3D); // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(), bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(), bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisVerticalTickLabels(), bar3DPlot.getOwnCategoryAxisLineColor(), false, (Comparable) evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(), bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(), bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisVerticalTickLabels(), bar3DPlot.getOwnValueAxisLineColor(), true, (Comparable) evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
protected JFreeChart createBar3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBarChart3D( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBar3DPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRBar3DPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false);//from w w w . j a va 2 s .co m configureChart(jfreeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); JRBar3DPlot bar3DPlot = (JRBar3DPlot) getPlot(); BarRenderer3D barRenderer3D = new BarRenderer3D( bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(), bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()); boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels(); barRenderer3D.setBaseItemLabelsVisible(isShowLabels); if (isShowLabels) { JRItemLabel itemLabel = bar3DPlot.getItemLabel(); JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : new JRBaseFont(getChart(), null); barRenderer3D.setBaseItemLabelFont(getFontUtil().getAwtFont(font, getLocale())); if (itemLabel != null) { if (itemLabel.getColor() != null) { barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor()); } else { barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } // categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor()); // if (itemLabel.getMask() != null) // { // barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( // StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, // new DecimalFormat(itemLabel.getMask()))); // } // else // { barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); // } } else { barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } } categoryPlot.setRenderer(barRenderer3D); // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(), bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(), bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisVerticalTickLabels(), bar3DPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable<?>) evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(), bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(), bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisVerticalTickLabels(), bar3DPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>) evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
protected JFreeChart createBar3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBarChart3D( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBar3DPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRBar3DPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false);/*from w w w.jav a2 s . c o m*/ configureChart(jfreeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); JRBar3DPlot bar3DPlot = (JRBar3DPlot) getPlot(); BarRenderer3D barRenderer3D = new BarRenderer3D( bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(), bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()); boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels(); barRenderer3D.setBaseItemLabelsVisible(isShowLabels); if (isShowLabels) { JRItemLabel itemLabel = bar3DPlot.getItemLabel(); Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE); JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null; barRenderer3D.setBaseItemLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize)); if (itemLabel != null) { if (itemLabel.getColor() != null) { barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor()); } else { barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } // categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor()); // if (itemLabel.getMask() != null) // { // barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( // StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, // new DecimalFormat(itemLabel.getMask()))); // } // else // { barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); // } } else { barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } } categoryPlot.setRenderer(barRenderer3D); // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(), bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(), bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisVerticalTickLabels(), bar3DPlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>) evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(), bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(), bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisVerticalTickLabels(), bar3DPlot.getOwnValueAxisLineColor(), true, (Comparable<?>) evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }