List of usage examples for org.jfree.chart.renderer.category BarRenderer setShadowPaint
public void setShadowPaint(Paint paint)
From source file:org.eobjects.datacleaner.util.ChartUtils.java
public static void applyStyles(JFreeChart chart) { TextTitle title = chart.getTitle();/*www . j av a 2s .c om*/ if (title != null) { title.setFont(WidgetUtils.FONT_HEADER1); title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); } for (int i = 0; i < chart.getSubtitleCount(); i++) { Title subtitle = chart.getSubtitle(i); if (subtitle instanceof TextTitle) { ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL); } } LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setItemFont(WidgetUtils.FONT_SMALL); } // transparent background chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); chart.setBorderVisible(false); final Plot plot = chart.getPlot(); plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d)); plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlineVisible(true); if (plot instanceof PiePlot) { // tweaks for pie charts final PiePlot piePlot = (PiePlot) plot; piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK); piePlot.setBaseSectionOutlineStroke(normalStroke); piePlot.setLabelFont(WidgetUtils.FONT_SMALL); piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT); piePlot.setLabelOutlineStroke(normalStroke); piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK); piePlot.setSectionOutlinesVisible(false); piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); } else if (plot instanceof CategoryPlot) { // tweaks for bar charts final CategoryPlot categoryPlot = (CategoryPlot) plot; int columnCount = categoryPlot.getDataset().getColumnCount(); if (columnCount > 1) { categoryPlot.setDomainGridlinesVisible(true); } else { categoryPlot.setDomainGridlinesVisible(false); } categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.setDrawingSupplier(new DCDrawingSupplier()); final CategoryItemRenderer renderer = categoryPlot.getRenderer(); renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK); renderer.setBaseOutlineStroke(wideStroke); if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT); barRenderer.setBarPainter(new StandardBarPainter()); } } else if (plot instanceof XYPlot) { // tweaks for line charts final XYPlot xyPlot = (XYPlot) plot; xyPlot.setDrawingSupplier(new DCDrawingSupplier()); xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); final XYItemRenderer renderer = xyPlot.getRenderer(); final int seriesCount = xyPlot.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { renderer.setSeriesStroke(i, wideStroke); } } }
From source file:org.datacleaner.util.ChartUtils.java
public static void applyStyles(JFreeChart chart) { TextTitle title = chart.getTitle();//from ww w . j ava 2s.c o m if (title != null) { title.setFont(WidgetUtils.FONT_HEADER1); title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); } for (int i = 0; i < chart.getSubtitleCount(); i++) { Title subtitle = chart.getSubtitle(i); if (subtitle instanceof TextTitle) { ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL); } } LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setItemFont(WidgetUtils.FONT_SMALL); } // transparent background chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); chart.setBorderVisible(false); final Plot plot = chart.getPlot(); plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d)); plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlineVisible(true); if (plot instanceof PiePlot) { // tweaks for pie charts final PiePlot piePlot = (PiePlot) plot; piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK); piePlot.setBaseSectionOutlineStroke(STROKE_NORMAL); piePlot.setLabelFont(WidgetUtils.FONT_SMALL); piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT); piePlot.setLabelOutlineStroke(STROKE_NORMAL); piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK); piePlot.setSectionOutlinesVisible(false); piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); piePlot.setDrawingSupplier(new DCDrawingSupplier()); } else if (plot instanceof CategoryPlot) { // tweaks for bar charts final CategoryPlot categoryPlot = (CategoryPlot) plot; int columnCount = categoryPlot.getDataset().getColumnCount(); if (columnCount > 1) { categoryPlot.setDomainGridlinesVisible(true); } else { categoryPlot.setDomainGridlinesVisible(false); } categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.setDrawingSupplier(new DCDrawingSupplier()); final CategoryItemRenderer renderer = categoryPlot.getRenderer(); renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK); renderer.setBaseOutlineStroke(STROKE_WIDE); if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT); barRenderer.setBarPainter(new StandardBarPainter()); } } else if (plot instanceof XYPlot) { // tweaks for line charts final XYPlot xyPlot = (XYPlot) plot; xyPlot.setDrawingSupplier(new DCDrawingSupplier()); xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); final XYItemRenderer renderer = xyPlot.getRenderer(); final int seriesCount = xyPlot.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { renderer.setSeriesStroke(i, STROKE_WIDE); } } }
From source file:org.openfaces.component.chart.impl.configuration.ShadowConfigurator.java
private void configureShadowProperties(BarChartView chartView, BarRenderer renderer) { renderer.setShadowVisible(chartView.isShowShadow()); renderer.setShadowXOffset(chartView.getShadowXOffset()); renderer.setShadowYOffset(chartView.getShadowYOffset()); renderer.setShadowPaint(chartView.getShadowColor()); }
From source file:org.sakaiproject.gradebookng.tool.panels.AssignmentStatisticsPanel.java
@Override public void onInitialize() { super.onInitialize(); final Long assignmentId = ((Model<Long>) getDefaultModel()).getObject(); final Assignment assignment = this.businessService.getAssignment(assignmentId.longValue()); AssignmentStatisticsPanel.this.window.setTitle( (new StringResourceModel("label.statistics.title", null, new Object[] { assignment.getName() }) .getString()));//from ww w. jav a 2 s . co m final List<GbStudentGradeInfo> gradeInfo = this.businessService.buildGradeMatrix(Arrays.asList(assignment)); final List<Double> allGrades = new ArrayList<>(); for (int i = 0; i < gradeInfo.size(); i++) { final GbStudentGradeInfo studentGradeInfo = gradeInfo.get(i); final Map<Long, GbGradeInfo> studentGrades = studentGradeInfo.getGrades(); final GbGradeInfo grade = studentGrades.get(assignmentId); if (grade == null || grade.getGrade() == null) { // this is not the grade you are looking for } else { allGrades.add(Double.valueOf(grade.getGrade())); } } Collections.sort(allGrades); final DefaultCategoryDataset data = new DefaultCategoryDataset(); final Map<String, Integer> counts = new TreeMap<>(); Integer extraCredits = 0; // Start off with a 0-50% range counts.put(String.format("%d-%d", 0, 50), 0); final int range = 10; for (int start = 50; start < 100; start = start + range) { final String key = String.format("%d-%d", start, start + range); counts.put(key, 0); } for (final Double grade : allGrades) { if (isExtraCredit(grade, assignment)) { extraCredits = extraCredits + 1; continue; } final double percentage; if (GradingType.PERCENTAGE.equals(this.gradingType)) { percentage = grade; } else { percentage = grade / assignment.getPoints() * 100; } final int total = Double.valueOf(Math.ceil(percentage) / range).intValue(); int start = total * range; if (start == 100) { start = start - range; } String key = String.format("%d-%d", start, start + range); if (start < 50) { key = String.format("%d-%d", 0, 50); } counts.put(key, counts.get(key) + 1); } for (final String label : counts.keySet()) { data.addValue(counts.get(label), "count", label); } if (extraCredits > 0) { data.addValue(extraCredits, "count", getString("label.statistics.chart.extracredit")); } final JFreeChart chart = ChartFactory.createBarChart(null, // the chart title getString("label.statistics.chart.xaxis"), // the label for the category axis getString("label.statistics.chart.yaxis"), // the label for the value axis data, // the dataset for the chart PlotOrientation.VERTICAL, // the plot orientation false, // show legend true, // show tooltips false); // show urls chart.setBorderVisible(false); chart.setAntiAlias(false); final CategoryPlot categoryPlot = chart.getCategoryPlot(); final BarRenderer br = (BarRenderer) categoryPlot.getRenderer(); br.setItemMargin(0); br.setMinimumBarLength(0.05); br.setMaximumBarWidth(0.1); br.setSeriesPaint(0, new Color(51, 122, 183)); br.setBarPainter(new StandardBarPainter()); br.setShadowPaint(new Color(220, 220, 220)); BarRenderer.setDefaultShadowsVisible(true); br.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator(getString("label.statistics.chart.tooltip"), NumberFormat.getInstance())); categoryPlot.setRenderer(br); // show only integers in the count axis categoryPlot.getRangeAxis().setStandardTickUnits(new NumberTickUnitSource(true)); categoryPlot.setBackgroundPaint(Color.white); add(new JFreeChartImageWithToolTip("chart", Model.of(chart), "tooltip", 540, 300)); add(new Label("graded", String.valueOf(allGrades.size()))); if (allGrades.size() > 0) { add(new Label("average", constructAverageLabel(allGrades, assignment))); add(new Label("median", constructMedianLabel(allGrades, assignment))); add(new Label("lowest", constructLowestLabel(allGrades, assignment))); add(new Label("highest", constructHighestLabel(allGrades, assignment))); add(new Label("deviation", constructStandardDeviationLabel(allGrades))); } else { add(new Label("average", "-")); add(new Label("median", "-")); add(new Label("lowest", "-")); add(new Label("highest", "-")); add(new Label("deviation", "-")); } add(new GbAjaxLink("done") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { AssignmentStatisticsPanel.this.window.close(target); } }); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.BarChartExpression.java
protected void configureChart(final JFreeChart chart) { final CategoryPlot cpl = chart.getCategoryPlot(); final CategoryItemRenderer renderer = cpl.getRenderer(); final BarRenderer br = (BarRenderer) renderer; if (isAutoRange()) { br.setIncludeBaseInRange(false); }/* w w w . ja v a2 s.c om*/ super.configureChart(chart); br.setDrawBarOutline(isChartSectionOutline()); if (maxBarWidth != null) { br.setMaximumBarWidth(maxBarWidth.doubleValue()); } if (itemMargin != null) { br.setItemMargin(itemMargin.doubleValue()); } if ((isStacked()) && stackedBarRenderPercentages && (br instanceof StackedBarRenderer)) { final StackedBarRenderer sbr = (StackedBarRenderer) br; sbr.setRenderAsPercentages(true); } br.setShadowVisible(shadowVisible); if (shadowColor != null) { br.setShadowPaint(shadowColor); } br.setShadowXOffset(shadowXOffset); br.setShadowYOffset(shadowYOffset); }
From source file:org.sakaiproject.gradebookng.tool.panels.SettingsGradingSchemaPanel.java
/** * Build the data for the chart/*ww w .j a v a2s . c om*/ * * @return */ private JFreeChart getChartData() { // just need the list final List<CourseGrade> courseGrades = this.courseGradeMap.values().stream().collect(Collectors.toList()); // get current grading schema (from model so that it reflects current state) final List<GbGradingSchemaEntry> gradingSchemaEntries = this.model.getObject().getGradingSchemaEntries(); final DefaultCategoryDataset data = new DefaultCategoryDataset(); final Map<String, Integer> counts = new LinkedHashMap<>(); // must retain order so graph can be printed correctly // add all schema entries (these will be sorted according to {@link LetterGradeComparator}) gradingSchemaEntries.forEach(e -> { counts.put(e.getGrade(), 0); }); // now add the count of each course grade for those schema entries this.total = 0; for (final CourseGrade g : courseGrades) { // course grade may not be released so we have to skip it if (StringUtils.isBlank(g.getMappedGrade())) { continue; } counts.put(g.getMappedGrade(), counts.get(g.getMappedGrade()) + 1); this.total++; } // build the data final ListIterator<String> iter = new ArrayList<>(counts.keySet()).listIterator(0); while (iter.hasNext()) { final String c = iter.next(); data.addValue(counts.get(c), "count", c); } final JFreeChart chart = ChartFactory.createBarChart(null, // the chart title getString("settingspage.gradingschema.chart.xaxis"), // the label for the category (x) axis getString("label.statistics.chart.yaxis"), // the label for the value (y) axis data, // the dataset for the chart PlotOrientation.HORIZONTAL, // the plot orientation false, // show legend true, // show tooltips false); // show urls chart.getCategoryPlot().setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); chart.setBorderVisible(false); chart.setAntiAlias(false); final CategoryPlot plot = chart.getCategoryPlot(); final BarRenderer br = (BarRenderer) plot.getRenderer(); br.setItemMargin(0); br.setMinimumBarLength(0.05); br.setMaximumBarWidth(0.1); br.setSeriesPaint(0, new Color(51, 122, 183)); br.setBarPainter(new StandardBarPainter()); br.setShadowPaint(new Color(220, 220, 220)); BarRenderer.setDefaultShadowsVisible(true); br.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator(getString("label.statistics.chart.tooltip"), NumberFormat.getInstance())); plot.setRenderer(br); // show only integers in the count axis plot.getRangeAxis().setStandardTickUnits(new NumberTickUnitSource(true)); // make x-axis wide enough so we don't get ... suffix plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(2.0f); plot.setBackgroundPaint(Color.white); chart.setTitle(getString("settingspage.gradingschema.chart.heading")); return chart; }