org.jfree.chart.renderer.category.LayeredBarRenderer Java Examples
The following examples show how to use
org.jfree.chart.renderer.category.LayeredBarRenderer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LayeredBarRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new LayeredBarRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example #2
Source File: LayeredBarRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new LayeredBarRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example #3
Source File: LayeredBarRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { LayeredBarRenderer r1 = new LayeredBarRenderer(); LayeredBarRenderer r2 = new LayeredBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
Example #4
Source File: LayeredBarRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { LayeredBarRenderer r1 = new LayeredBarRenderer(); LayeredBarRenderer r2 = new LayeredBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
Example #5
Source File: DerivedCounter.java From mts with GNU General Public License v3.0 | 4 votes |
public JFreeChart getHistogramChart() { double[] hits = this.counter.histogramDataset.getHistogramArray(); double[] intervals = this.counter.histogramDataset.histogramParameters.histogramIntervals; double hitsCount = this.counter.histogramDataset.hits; DefaultCategoryDataset datasetNormal = new DefaultCategoryDataset(); datasetNormal.addValue(0, "a", " -INF"); datasetNormal.addValue(0, "b", " -INF"); double cumul = 0; for (int i = 0; i < intervals.length - 1; i++) { String intervalName; if (i == intervals.length - 2) { intervalName = " +INF"; } else { intervalName = " " + Double.toString(intervals[i + 1]); } cumul += hits[i]; datasetNormal.addValue((100 * hits[i]) / hitsCount, "a", intervalName); datasetNormal.addValue((100 * cumul) / hitsCount, "b", intervalName); } JFreeChart jFreeChart = ChartFactory.createBarChart("", "", "%", datasetNormal, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = jFreeChart.getCategoryPlot(); CategoryAxis axis = plot.getDomainAxis(); LayeredBarRenderer layeredBarRenderer = new LayeredBarRenderer(); layeredBarRenderer.setSeriesPaint(0, new Color(0, 0, 255, 85)); layeredBarRenderer.setSeriesPaint(1, new Color(255, 0, 0, 85)); plot.setRenderer(layeredBarRenderer); plot.setRowRenderingOrder(SortOrder.DESCENDING); axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); axis.setMaximumCategoryLabelWidthRatio(1); jFreeChart.setBackgroundPaint(Color.WHITE); return jFreeChart; }
Example #6
Source File: ServerWideReportManagerImpl.java From sakai with Educational Community License v2.0 | 4 votes |
private byte[] generateLayeredBarChart (CategoryDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createBarChart (null, // chart title null, // domain axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation true, // legend true, // tooltips false // urls ); // set background chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ())); // set chart border chart.setPadding (new RectangleInsets (10, 5, 5, 5)); chart.setBorderVisible (true); chart.setBorderPaint (parseColor ("#cccccc")); // set anti alias chart.setAntiAlias (true); CategoryPlot plot = (CategoryPlot) chart.getPlot (); // disable bar outlines... LayeredBarRenderer renderer = new LayeredBarRenderer (); renderer.setDrawBarOutline (false); renderer.setSeriesBarWidth (0, .6); renderer.setSeriesBarWidth (1, .8); renderer.setSeriesBarWidth (2, 1.0); plot.setRenderer (renderer); // for this renderer, we need to draw the first series last... plot.setRowRenderingOrder (SortOrder.DESCENDING); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint (0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color (0, 0, 64)); GradientPaint gp1 = new GradientPaint (0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color (0, 64, 0)); GradientPaint gp2 = new GradientPaint (0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color (64, 0, 0)); renderer.setSeriesPaint (0, gp0); renderer.setSeriesPaint (1, gp1); renderer.setSeriesPaint (2, gp2); CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis (); domainAxis.setCategoryLabelPositions (CategoryLabelPositions.DOWN_45); domainAxis.setLowerMargin (0.0); domainAxis.setUpperMargin (0.0); BufferedImage img = chart.createBufferedImage (width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try{ ImageIO.write(img, "png", out); }catch(IOException e){ log.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }
Example #7
Source File: LayeredBarRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { LayeredBarRenderer r1 = new LayeredBarRenderer(); LayeredBarRenderer r2 = new LayeredBarRenderer(); assertEquals(r1, r2); }
Example #8
Source File: LayeredBarRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { LayeredBarRenderer r1 = new LayeredBarRenderer(); assertTrue(r1 instanceof PublicCloneable); }
Example #9
Source File: LayeredBarRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { LayeredBarRenderer r1 = new LayeredBarRenderer(); LayeredBarRenderer r2 = new LayeredBarRenderer(); assertEquals(r1, r2); }
Example #10
Source File: ServerWideReportManagerImpl.java From sakai with Educational Community License v2.0 | 4 votes |
private byte[] generateLayeredBarChart (CategoryDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createBarChart (null, // chart title null, // domain axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation true, // legend true, // tooltips false // urls ); // set background chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ())); // set chart border chart.setPadding (new RectangleInsets (10, 5, 5, 5)); chart.setBorderVisible (true); chart.setBorderPaint (parseColor ("#cccccc")); // set anti alias chart.setAntiAlias (true); CategoryPlot plot = (CategoryPlot) chart.getPlot (); // disable bar outlines... LayeredBarRenderer renderer = new LayeredBarRenderer (); renderer.setDrawBarOutline (false); renderer.setSeriesBarWidth (0, .6); renderer.setSeriesBarWidth (1, .8); renderer.setSeriesBarWidth (2, 1.0); plot.setRenderer (renderer); // for this renderer, we need to draw the first series last... plot.setRowRenderingOrder (SortOrder.DESCENDING); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint (0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color (0, 0, 64)); GradientPaint gp1 = new GradientPaint (0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color (0, 64, 0)); GradientPaint gp2 = new GradientPaint (0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color (64, 0, 0)); renderer.setSeriesPaint (0, gp0); renderer.setSeriesPaint (1, gp1); renderer.setSeriesPaint (2, gp2); CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis (); domainAxis.setCategoryLabelPositions (CategoryLabelPositions.DOWN_45); domainAxis.setLowerMargin (0.0); domainAxis.setUpperMargin (0.0); BufferedImage img = chart.createBufferedImage (width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try{ ImageIO.write(img, "png", out); }catch(IOException e){ log.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }