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

项目:parabuild-ci    文件:WaterfallBarRendererTests.java   
/**
 * Problem that the equals(...) method distinguishes all fields.
 */
public void testEquals() {
    WaterfallBarRenderer r1 = new WaterfallBarRenderer();
    WaterfallBarRenderer r2 = new WaterfallBarRenderer();
    assertEquals(r1, r2);

    // firstBarPaint;
    r1.setFirstBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setFirstBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    // lastBarPaint;
    r1.setLastBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setLastBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    // positiveBarPaint;
    r1.setPositiveBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setPositiveBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    //private Paint negativeBarPaint;
    r1.setNegativeBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setNegativeBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

}
项目:parabuild-ci    文件:WaterfallBarRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    WaterfallBarRenderer r1 = new WaterfallBarRenderer();
    WaterfallBarRenderer r2 = new WaterfallBarRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:parabuild-ci    文件:WaterfallBarRendererTests.java   
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    WaterfallBarRenderer r1 = new WaterfallBarRenderer();
    WaterfallBarRenderer r2 = new WaterfallBarRenderer();
    assertEquals(r1, r2);

    // firstBarPaint;
    r1.setFirstBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setFirstBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    // lastBarPaint;
    r1.setLastBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setLastBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    // positiveBarPaint;
    r1.setPositiveBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setPositiveBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    //private Paint negativeBarPaint;
    r1.setNegativeBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setNegativeBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

}
项目:parabuild-ci    文件:WaterfallBarRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    WaterfallBarRenderer r1 = new WaterfallBarRenderer();
    WaterfallBarRenderer r2 = new WaterfallBarRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:nabs    文件:WaterfallBarRendererTests.java   
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    WaterfallBarRenderer r1 = new WaterfallBarRenderer();
    WaterfallBarRenderer r2 = new WaterfallBarRenderer();
    assertEquals(r1, r2);

    // firstBarPaint;
    r1.setFirstBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setFirstBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    // lastBarPaint;
    r1.setLastBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setLastBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    // positiveBarPaint;
    r1.setPositiveBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setPositiveBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    //private Paint negativeBarPaint;
    r1.setNegativeBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setNegativeBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

}
项目:nabs    文件:WaterfallBarRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    WaterfallBarRenderer r1 = new WaterfallBarRenderer();
    WaterfallBarRenderer r2 = new WaterfallBarRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:astor    文件:WaterfallBarRendererTests.java   
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    WaterfallBarRenderer r1 = new WaterfallBarRenderer();
    WaterfallBarRenderer r2 = new WaterfallBarRenderer();
    assertEquals(r1, r2);

    // firstBarPaint;
    r1.setFirstBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setFirstBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    // lastBarPaint;
    r1.setLastBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setLastBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    // positiveBarPaint;
    r1.setPositiveBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setPositiveBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

    //private Paint negativeBarPaint;
    r1.setNegativeBarPaint(Color.cyan);
    assertFalse(r1.equals(r2));
    r2.setNegativeBarPaint(Color.cyan);
    assertTrue(r1.equals(r2));

}
项目:astor    文件:WaterfallBarRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    WaterfallBarRenderer r1 = new WaterfallBarRenderer();
    WaterfallBarRenderer r2 = new WaterfallBarRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:astor    文件:ChartFactory.java   
/**
 * Creates a waterfall chart.  The chart object returned by this method
 * uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
 * range axis, and a {@link WaterfallBarRenderer} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A waterfall chart.
 */
public static JFreeChart createWaterfallChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
    WaterfallBarRenderer renderer = new WaterfallBarRenderer();
    ItemLabelPosition position = new ItemLabelPosition(
            ItemLabelAnchor.CENTER, TextAnchor.CENTER,
            TextAnchor.CENTER, 0.0);
    renderer.setBasePositiveItemLabelPosition(position);
    renderer.setBaseNegativeItemLabelPosition(position);
    StandardCategoryToolTipGenerator generator
            = new StandardCategoryToolTipGenerator();
    renderer.setBaseToolTipGenerator(generator);
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.clearRangeMarkers();
    Marker baseline = new ValueMarker(0.0);
    baseline.setPaint(Color.black);
    plot.addRangeMarker(baseline, Layer.FOREGROUND);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:dynamicreports-jasper    文件:WaterfallBarChartTest.java   
@Override
public void test() {
    super.test();

    numberOfPagesTest(1);

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", WaterfallBarRenderer.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());
}
项目:astor    文件:WaterfallBarRendererTests.java   
/**
 * Some tests for the findRangeBounds() method.
 */
public void testFindRangeBounds() {
    WaterfallBarRenderer r = new WaterfallBarRenderer();
    assertNull(r.findRangeBounds(null));
}
项目:astor    文件:WaterfallBarRendererTests.java   
/**
 * Check that this class implements PublicCloneable.
 */
public void testPublicCloneable() {
    WaterfallBarRenderer r1 = new WaterfallBarRenderer();
    assertTrue(r1 instanceof PublicCloneable);
}
项目:dynamicreports-jasper    文件:WaterfallBarRendererCustomizer.java   
@Override
public void customize(JFreeChart chart, ReportParameters reportParameters) {
    BarRenderer categoryRenderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
    WaterfallBarRenderer renderer = new WaterfallBarRenderer();

   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 (firstBarPaint != null) {
        renderer.setFirstBarPaint(firstBarPaint);
    }
    if (lastBarPaint != null) {
        renderer.setLastBarPaint(lastBarPaint);
    }
    if (positiveBarPaint != null) {
        renderer.setPositiveBarPaint(positiveBarPaint);
    }
    if (negativeBarPaint != null) {
        renderer.setNegativeBarPaint(negativeBarPaint);
    }

   chart.getCategoryPlot().setRenderer(renderer);
 }