Search in sources :

Example 1 with StandardXYItemLabelGenerator

use of org.jfree.chart.labels.StandardXYItemLabelGenerator in project tdq-studio-se by Talend.

the class TopChartFactory method createBlockingBarChart.

public static JFreeChart createBlockingBarChart(String title, HistogramDataset dataset) {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart chart = // $NON-NLS-1$
    ChartFactory.createHistogram(// $NON-NLS-1$
    null, // $NON-NLS-1$
    title, // $NON-NLS-1$
    "Key frequency", // $NON-NLS-1$
    dataset, // $NON-NLS-1$
    PlotOrientation.VERTICAL, // $NON-NLS-1$
    false, true, false);
    XYPlot plot = chart.getXYPlot();
    plot.getRangeAxis().setUpperMargin(0.08);
    // plot.getRangeAxis().setLowerBound(-0.08);
    decorateCategoryPlot(chart);
    plot.setRangeGridlinesVisible(true);
    XYBarRenderer renderer = new XYBarRenderer() {

        private static final long serialVersionUID = 4168794048090452033L;

        @Override
        public Paint getItemPaint(int row, int column) {
            return ChartDecorator.COLOR_LIST.get(0);
        }
    };
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    renderer.setShadowVisible(Boolean.FALSE);
    plot.setRenderer(renderer);
    return chart;
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) StandardXYItemLabelGenerator(org.jfree.chart.labels.StandardXYItemLabelGenerator) ItemLabelPosition(org.jfree.chart.labels.ItemLabelPosition) JFreeChart(org.jfree.chart.JFreeChart) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer)

Example 2 with StandardXYItemLabelGenerator

use of org.jfree.chart.labels.StandardXYItemLabelGenerator in project SIMVA-SoS by SESoS.

the class YIntervalRendererTest method testCloning.

/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    YIntervalRenderer r1 = new YIntervalRenderer();
    YIntervalRenderer r2 = (YIntervalRenderer) r1.clone();
    assertTrue(r1 != r2);
    assertTrue(r1.getClass() == r2.getClass());
    assertTrue(r1.equals(r2));
    // check independence
    r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertTrue(r1.equals(r2));
    r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertTrue(r1.equals(r2));
    r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.FOREGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.FOREGROUND);
    assertTrue(r1.equals(r2));
    r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.BACKGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.BACKGROUND);
    assertTrue(r1.equals(r2));
}
Also used : XYTextAnnotation(org.jfree.chart.annotations.XYTextAnnotation) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) StandardXYItemLabelGenerator(org.jfree.chart.labels.StandardXYItemLabelGenerator) Test(org.junit.Test)

Example 3 with StandardXYItemLabelGenerator

use of org.jfree.chart.labels.StandardXYItemLabelGenerator in project SIMVA-SoS by SESoS.

the class AbstractXYItemRendererTest method testEquals_ObjectList.

@Test
public void testEquals_ObjectList() {
    XYBarRenderer r1 = new XYBarRenderer();
    r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    XYBarRenderer r2 = new XYBarRenderer();
    r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertEquals(r1, r2);
    r2.setSeriesItemLabelGenerator(1, new StandardXYItemLabelGenerator("X"));
    assertNotEquals(r1, r2);
}
Also used : StandardXYItemLabelGenerator(org.jfree.chart.labels.StandardXYItemLabelGenerator) Test(org.junit.Test)

Example 4 with StandardXYItemLabelGenerator

use of org.jfree.chart.labels.StandardXYItemLabelGenerator in project SIMVA-SoS by SESoS.

the class YIntervalRendererTest method testEquals.

/**
 * Check that the equals() method distinguishes all fields.
 */
@Test
public void testEquals() {
    YIntervalRenderer r1 = new YIntervalRenderer();
    YIntervalRenderer r2 = new YIntervalRenderer();
    assertEquals(r1, r2);
    // the following fields are inherited from the AbstractXYItemRenderer
    r1.setItemLabelGenerator(new StandardXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setItemLabelGenerator(new StandardXYItemLabelGenerator());
    assertTrue(r1.equals(r2));
    r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertTrue(r1.equals(r2));
    r1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    assertTrue(r1.equals(r2));
    r1.setToolTipGenerator(new StandardXYToolTipGenerator());
    assertFalse(r1.equals(r2));
    r2.setToolTipGenerator(new StandardXYToolTipGenerator());
    assertTrue(r1.equals(r2));
    r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertTrue(r1.equals(r2));
    r1.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    assertFalse(r1.equals(r2));
    r2.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    assertTrue(r1.equals(r2));
    r1.setURLGenerator(new StandardXYURLGenerator());
    assertFalse(r1.equals(r2));
    r2.setURLGenerator(new StandardXYURLGenerator());
    assertTrue(r1.equals(r2));
    r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND);
    assertTrue(r1.equals(r2));
    r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND);
    assertTrue(r1.equals(r2));
    r1.setDefaultEntityRadius(99);
    assertFalse(r1.equals(r2));
    r2.setDefaultEntityRadius(99);
    assertTrue(r1.equals(r2));
    r1.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator("{0} {1}"));
    assertFalse(r1.equals(r2));
    r2.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator("{0} {1}"));
    assertTrue(r1.equals(r2));
    r1.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator());
    assertTrue(r1.equals(r2));
    r1.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator());
    assertTrue(r1.equals(r2));
    r1.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator());
    assertTrue(r1.equals(r2));
}
Also used : XYTextAnnotation(org.jfree.chart.annotations.XYTextAnnotation) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) StandardXYSeriesLabelGenerator(org.jfree.chart.labels.StandardXYSeriesLabelGenerator) StandardXYItemLabelGenerator(org.jfree.chart.labels.StandardXYItemLabelGenerator) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) IntervalXYItemLabelGenerator(org.jfree.chart.labels.IntervalXYItemLabelGenerator) Test(org.junit.Test)

Aggregations

StandardXYItemLabelGenerator (org.jfree.chart.labels.StandardXYItemLabelGenerator)4 Test (org.junit.Test)3 XYTextAnnotation (org.jfree.chart.annotations.XYTextAnnotation)2 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)2 JFreeChart (org.jfree.chart.JFreeChart)1 IntervalXYItemLabelGenerator (org.jfree.chart.labels.IntervalXYItemLabelGenerator)1 ItemLabelPosition (org.jfree.chart.labels.ItemLabelPosition)1 StandardXYSeriesLabelGenerator (org.jfree.chart.labels.StandardXYSeriesLabelGenerator)1 XYPlot (org.jfree.chart.plot.XYPlot)1 XYBarRenderer (org.jfree.chart.renderer.xy.XYBarRenderer)1 StandardXYURLGenerator (org.jfree.chart.urls.StandardXYURLGenerator)1