List of usage examples for org.jfree.chart.renderer.category BarRenderer setDefaultShadowsVisible
public static void setDefaultShadowsVisible(boolean visible)
From source file:net.sourceforge.processdash.ui.web.reports.DashboardChartDefaults.java
public static void initialize() { // install the legacy theme for chart colors ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); // turn off shadows on bar charts by default BarRenderer.setDefaultShadowsVisible(false); XYBarRenderer.setDefaultShadowsVisible(false); // the standard set of colors includes yellow, which is nearly // impossible to see on a white background. Replace those yellows with // variations on orange. DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[3] = Color.orange; DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[18] = new Color(215, 170, 0); DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[31] = new Color(255, 200, 128); }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputHistogram.java
public static void enableFlatLook(final boolean flat) { if (flat) {//from w w w. j av a2 s .c o m BarRenderer.setDefaultBarPainter(new StandardBarPainter()); BarRenderer.setDefaultShadowsVisible(false); XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter()); XYBarRenderer.setDefaultShadowsVisible(false); StackedBarRenderer.setDefaultBarPainter(new StandardBarPainter()); StackedBarRenderer.setDefaultShadowsVisible(false); } else { BarRenderer.setDefaultBarPainter(new GradientBarPainter()); BarRenderer.setDefaultShadowsVisible(true); XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter()); XYBarRenderer.setDefaultShadowsVisible(true); StackedBarRenderer.setDefaultBarPainter(new GradientBarPainter()); StackedBarRenderer.setDefaultShadowsVisible(true); } }
From source file:org.sbml.bargraph.MainWindow.java
/** * Creates an empty bar graph.//www .ja v a 2 s.com * @return */ public JFreeChart createModelBarGraph() { // Initialize the style. Have to do this before creating charts. BarRenderer.setDefaultShadowsVisible(false); ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); // Create the actual chart. chartData = new DefaultCategoryDataset(); JFreeChart chart = ChartFactory.createBarChart(null, // chart title null, // domain axis label "Total count", // range axis label chartData, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend false, // tooltips? false // URLs? ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, new Color(0, 101, 178)); return chart; }
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()));/* w w 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.sakaiproject.gradebookng.tool.panels.SettingsGradingSchemaPanel.java
/** * Build the data for the chart//w w w . j a va 2 s .c o m * * @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; }