List of usage examples for org.jfree.chart ChartFactory setChartTheme
public static void setChartTheme(ChartTheme theme)
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
/** * /*from ww w .j a v a 2 s.co m*/ * mzhao create bar chart with default bar render class. * * @param titile * @param dataset * @param showLegend * @return */ public static JFreeChart createBarChart(String titile, CategoryDataset dataset, boolean showLegend) { // MOD hcheng for 6965,Use 2D bar charts instead of 3D bar charts // ADD msjian TDQ-5112 2012-4-10: after upgrate to jfreechart-1.0.12.jar, change the default chart wallPaint ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); // TDQ-5112~ JFreeChart chart = ChartFactory.createBarChart(null, titile, Messages.getString("TopChartFactory.count"), //$NON-NLS-1$ dataset, PlotOrientation.VERTICAL, showLegend, true, false); ChartDecorator.decorateBarChart(chart, new TalendBarRenderer(true, ChartDecorator.COLOR_LIST)); return chart; }
From source file:jhplot.HChart.java
/** * Set a custom theme for chart.. It can be: LEGACY_THEME, JFREE_THEME, * DARKNESS_THEME/*w w w . j a va 2s. co m*/ * * @param s * a theme, can be either LEGACY_THEME, JFREE_THEME, * DARKNESS_THEME */ public void setTheme(String s) { if (s.equals("LEGACY_THEME")) { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); applyThemeToChart(); } else if (s.equals("JFREE_THEME")) { ChartFactory.setChartTheme(StandardChartTheme.createJFreeTheme()); applyThemeToChart(); } else if (s.equals("DARKNESS_THEME")) { ChartFactory.setChartTheme(StandardChartTheme.createDarknessTheme()); applyThemeToChart(); } }
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
/** * create bar chart./*from ww w .ja va 2 s. co m*/ * * @param titile * @param dataset * @return */ public static JFreeChart createBarChartByKCD(String title, CategoryDataset dataset, Object cusmomerDataset) { // ADD msjian TDQ-5112 2012-4-10: after upgrate to jfreechart-1.0.12.jar, change the default chart wallPaint ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); // TDQ-5112~ JFreeChart createBarChart = ChartFactory.createBarChart(null, Messages.getString("TopChartFactory.Value"), //$NON-NLS-1$ title, dataset, PlotOrientation.HORIZONTAL, false, false, false); CategoryPlot plot = createBarChart.getCategoryPlot(); if (cusmomerDataset != null) { plot.setDataset(1, new EncapsulationCumstomerDataset(dataset, cusmomerDataset)); } CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelPaint(NULL_FIELD, Color.RED); domainAxis.setTickLabelPaint(NULL_FIELD2, Color.RED); domainAxis.setTickLabelPaint(EMPTY_FIELD, Color.RED); // ADD TDQ-5251 msjian 2012-7-31: do not display the shadow BarRenderer renderer = new TalendBarRenderer(false, ChartDecorator.COLOR_LIST); renderer.setShadowVisible(false); // TDQ-5251~ plot.setRenderer(renderer); return createBarChart; }
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
/** * //from w w w.j av a2 s. c o m * DOC zshen Comment method "createMatchRuleBarChart". * * @param title * @param dataset * @return */ public static JFreeChart createMatchRuleBarChart(String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset) { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart localJFreeChart = ChartFactory.createBarChart(null, categoryAxisLabel, valueAxisLabel, dataset, PlotOrientation.VERTICAL, false, true, false); localJFreeChart.addSubtitle(new TextTitle( Messages.getString("DataChart.title", sumItemCount(dataset), sumGroupCount(dataset)))); //$NON-NLS-1$ CategoryPlot plot = (CategoryPlot) localJFreeChart.getPlot(); // get real color list from ChartDecorator.COLOR_LIST dataset.getColumnKeys() List<Color> currentColorList = null; try { currentColorList = getCurrentColorList(dataset.getColumnKeys()); } catch (NumberFormatException e) { log.warn(e, e); currentColorList = ChartDecorator.COLOR_LIST; } BarRenderer barRenderer = new TalendBarRenderer(true, currentColorList); barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); barRenderer.setBaseItemLabelsVisible(true); // remove the shadow barRenderer.setShadowVisible(Boolean.FALSE); plot.setRenderer(barRenderer); CategoryAxis localCategoryAxis = plot.getDomainAxis(); localCategoryAxis.setCategoryMargin(0.25D); localCategoryAxis.setUpperMargin(0.02D); localCategoryAxis.setLowerMargin(0.02D); NumberAxis localNumberAxis = (NumberAxis) plot.getRangeAxis(); localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); localNumberAxis.setUpperMargin(0.1D); return localJFreeChart; }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
/** * *//*www.j a v a 2s . co m*/ protected JFreeChart createAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createAreaChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false, (Comparable) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true, (Comparable) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
/** * *//*from w ww . j a v a2 s .c o m*/ protected JFreeChart createAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true, (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
public static JFreeChart createBlockingBarChart(String title, HistogramDataset dataset) { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart chart = ChartFactory.createHistogram(null, title, "Key frequency", dataset, //$NON-NLS-1$ PlotOrientation.VERTICAL, false, true, false); XYPlot plot = chart.getXYPlot();// ww w .j a va 2 s .c o m plot.getRangeAxis().setUpperMargin(0.08); // plot.getRangeAxis().setLowerBound(-0.08); decorateCategoryPlot(chart); plot.setRangeGridlinesVisible(true); XYBarRenderer renderer = new XYBarRenderer() { private static final long serialVersionUID = 4168794048090452033L; @Override public Paint getItemPaint(int row, int column) { return ChartDecorator.COLOR_LIST.get(0); } }; renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); renderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); renderer.setShadowVisible(Boolean.FALSE); plot.setRenderer(renderer); return chart; }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
/** * *///from w w w . j a v a2 s. co m protected JFreeChart createAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createAreaChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.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 w w w . jav a 2 s . c o 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
/** * */// w w w . ja v a 2 s . co m protected JFreeChart createAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }