Search in sources :

Example 81 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.

the class ChartPanelTest method test2502355_zoomOutRange.

/**
 * Checks that a call to the zoomOutRange() method, for a plot with more
 * than one range axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomOutRange() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomOutRange(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Test(org.junit.Test)

Example 82 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.

the class XYTitleAnnotationTest method testDrawWithNullInfo.

/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown.
 */
@Test
public void testDrawWithNullInfo() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();
        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);
        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYLineAndShapeRenderer());
        plot.addAnnotation(new XYTitleAnnotation(5.0, 6.0, new TextTitle("Hello World!")));
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, null);
    } catch (NullPointerException e) {
        fail("There should be no exception.");
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset) TextTitle(org.jfree.chart.title.TextTitle) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 83 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.

the class XYPlotTest method testCloning3.

/**
 * Tests cloning for a plot where the fixed legend items have been
 * specified.
 */
@Test
public void testCloning3() throws CloneNotSupportedException {
    XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), new NumberAxis("Range Axis"), new StandardXYItemRenderer());
    LegendItemCollection c1 = new LegendItemCollection();
    p1.setFixedLegendItems(c1);
    XYPlot p2 = (XYPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
    // verify independence of fixed legend item collection
    c1.add(new LegendItem("X"));
    assertFalse(p1.equals(p2));
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) LegendItem(org.jfree.chart.LegendItem) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) LegendItemCollection(org.jfree.chart.LegendItemCollection) Test(org.junit.Test)

Example 84 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.

the class XYPlotTest method testEquals_ObjectList.

/**
 * This test covers a flaw in the ObjectList equals() method.
 */
@Test
public void testEquals_ObjectList() {
    XYPlot p1 = new XYPlot();
    p1.setDomainAxis(new NumberAxis("A"));
    XYPlot p2 = new XYPlot();
    p2.setDomainAxis(new NumberAxis("A"));
    assertEquals(p1, p2);
    p2.setDomainAxis(1, new NumberAxis("B"));
    assertNotEquals(p1, p2);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) Test(org.junit.Test)

Example 85 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.

the class XYPlotTest method testSetNullRenderer.

/**
 * Setting a null renderer should be allowed, but is generating a null
 * pointer exception in 0.9.7.
 */
@Test
public void testSetNullRenderer() {
    boolean failed = false;
    try {
        XYPlot plot = new XYPlot(null, new NumberAxis("X"), new NumberAxis("Y"), null);
        plot.setRenderer(null);
    } catch (Exception e) {
        failed = true;
    }
    assertTrue(!failed);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) Test(org.junit.Test)

Aggregations

NumberAxis (org.jfree.chart.axis.NumberAxis)259 JFreeChart (org.jfree.chart.JFreeChart)146 Test (org.junit.Test)118 XYPlot (org.jfree.chart.plot.XYPlot)98 CategoryAxis (org.jfree.chart.axis.CategoryAxis)95 CategoryPlot (org.jfree.chart.plot.CategoryPlot)80 ValueAxis (org.jfree.chart.axis.ValueAxis)45 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)44 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)40 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)39 XYSeries (org.jfree.data.xy.XYSeries)38 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)37 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)30 XYDataset (org.jfree.data.xy.XYDataset)30 Color (java.awt.Color)28 DateAxis (org.jfree.chart.axis.DateAxis)27 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)27 BasicStroke (java.awt.BasicStroke)25 StandardXYItemRenderer (org.jfree.chart.renderer.xy.StandardXYItemRenderer)24 CategoryDataset (org.jfree.data.category.CategoryDataset)21