Java 类org.jfree.chart.renderer.category.LayeredBarRenderer 实例源码

项目:parabuild-ci    文件:LayeredBarRendererTests.java   
/**
 * 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);
}
项目:nabs    文件:LayeredBarRendererTests.java   
/**
 * 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);
}
项目:astor    文件:LayeredBarRendererTests.java   
/**
 * 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);
}
项目:parabuild-ci    文件:LayeredBarRendererTests.java   
/**
 * 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);
}
项目:parabuild-ci    文件:LayeredBarRendererTests.java   
/**
 * 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);
}
项目:nabs    文件:LayeredBarRendererTests.java   
/**
 * 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);
}
项目:astor    文件:LayeredBarRendererTests.java   
/**
 * 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);
}
项目:dynamicreports-jasper    文件:LayeredBarRendererCustomizer.java   
@Override
public void customize(JFreeChart chart, ReportParameters reportParameters) {
    BarRenderer categoryRenderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
   LayeredBarRenderer renderer = new LayeredBarRenderer();

   renderer.setBaseItemLabelsVisible(categoryRenderer.getBaseItemLabelsVisible());
   renderer.setBaseItemLabelFont(categoryRenderer.getBaseItemLabelFont());
   renderer.setBaseItemLabelPaint(categoryRenderer.getBaseItemLabelPaint());
   renderer.setBaseItemLabelGenerator(categoryRenderer.getBaseItemLabelGenerator());
    renderer.setShadowVisible(categoryRenderer.getShadowsVisible());
    CategoryDataset categoryDataset = chart.getCategoryPlot().getDataset();
    if(categoryDataset != null) {
        for(int i = 0; i < categoryDataset.getRowCount(); i++) {
            Paint seriesOutlinePaint = categoryRenderer.getSeriesOutlinePaint(i);
            if (seriesOutlinePaint != null) {
                renderer.setSeriesOutlinePaint(i, seriesOutlinePaint);
            }
            Paint seriesPaint = categoryRenderer.getSeriesPaint(i);
            if (seriesPaint != null) {
                renderer.setSeriesPaint(i, seriesPaint);
            }
        }
    }
    renderer.setItemMargin(categoryRenderer.getItemMargin());
    GradientPaintTransformer gradientPaintTransformer = categoryRenderer.getGradientPaintTransformer();
    if (gradientPaintTransformer != null) {
        renderer.setGradientPaintTransformer(gradientPaintTransformer);
    }

   if (seriesBarWidths != null) {
    for (int i = 0; i < seriesBarWidths.size(); i++) {
        renderer.setSeriesBarWidth(i, seriesBarWidths.get(i));
        }
   }

   chart.getCategoryPlot().setRenderer(renderer);
 }
项目:dynamicreports-jasper    文件:LayeredBarChartTest.java   
@Override
public void test() {
    super.test();

    numberOfPagesTest(1);

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", LayeredBarRenderer.class, categoryPlot.getRenderer().getClass());
    Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
    Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible());
    Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}
项目:parabuild-ci    文件:LayeredBarRendererTests.java   
/**
 * Problem that the equals(...) method distinguishes all fields.
 */
public void testEquals() {
    LayeredBarRenderer r1 = new LayeredBarRenderer();
    LayeredBarRenderer r2 = new LayeredBarRenderer();
    assertEquals(r1, r2);
}
项目:parabuild-ci    文件:LayeredBarRendererTests.java   
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    LayeredBarRenderer r1 = new LayeredBarRenderer();
    LayeredBarRenderer r2 = new LayeredBarRenderer();
    assertEquals(r1, r2);
}
项目:HTML5_WebSite    文件:LayeredBarChartDemo2.java   
/**
   * Creates a sample chart.
   * 
   * @param dataset  the dataset.
   * 
   * @return The chart.
   */
  protected JFreeChart createChart(CategoryDataset dataset) {

      // create the chart...
      JFreeChart chart = ChartFactory.createBarChart(
          chartTitle,  // chart title
          domainLabel,                  // domain axis label
          rangeLabel,                     // range axis label
          dataset,                     // data
          PlotOrientation.HORIZONTAL,  // orientation
          !legendPanelOn,                        // include legend
          true,                        // tooltips?
          false                        // URLs?
      );

      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...
      LayeredBarRenderer renderer = new LayeredBarRenderer();
      renderer.setDrawBarOutline(false);
      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);
renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
setCategorySummary(dataset);
      return chart;

  }
项目:HTML5_WebSite    文件:LayeredBarChartDemo1.java   
/**
   * Creates a sample chart.
   * 
   * @param dataset  the dataset.
   * 
   * @return The chart.
   */
  protected JFreeChart createChart(CategoryDataset dataset) {

      // create the chart...
      JFreeChart chart = ChartFactory.createBarChart(
          chartTitle,  // chart title
          domainLabel,                  // domain axis label
          rangeLabel,                     // range axis label
          dataset,                     // data
          PlotOrientation.VERTICAL,    // orientation
          !legendPanelOn,                        // include legend
          true,                        // tooltips?
          false                        // URLs?
      );

      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...
      LayeredBarRenderer renderer = new LayeredBarRenderer();
      renderer.setDrawBarOutline(false);
      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);
renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
setCategorySummary(dataset);
      return chart;

  }
项目:sakai    文件:ServerWideReportManagerImpl.java   
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();
}
项目:nabs    文件:LayeredBarRendererTests.java   
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    LayeredBarRenderer r1 = new LayeredBarRenderer();
    LayeredBarRenderer r2 = new LayeredBarRenderer();
    assertEquals(r1, r2);
}
项目:astor    文件:LayeredBarRendererTests.java   
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    LayeredBarRenderer r1 = new LayeredBarRenderer();
    LayeredBarRenderer r2 = new LayeredBarRenderer();
    assertEquals(r1, r2);
}
项目:astor    文件:LayeredBarRendererTests.java   
/**
 * Check that this class implements PublicCloneable.
 */
public void testPublicCloneable() {
    LayeredBarRenderer r1 = new LayeredBarRenderer();
    assertTrue(r1 instanceof PublicCloneable);
}
项目:sakai    文件:ServerWideReportManagerImpl.java   
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();
}
项目:dynamicreports-jasper    文件:LayeredBarChartTest.java   
@Override
public void customize(JFreeChart chart, ReportParameters reportParameters) {
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", LayeredBarRenderer.class, categoryPlot.getRenderer().getClass());
 }