org.jfree.chart.renderer.xy.XYStepRenderer Java Examples

The following examples show how to use org.jfree.chart.renderer.xy.XYStepRenderer. 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: XYStepRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    XYStepRenderer r1 = new XYStepRenderer();
    XYStepRenderer r2 = new XYStepRenderer();
    assertEquals(r1, r2);

    r1.setStepPoint(0.44);
    assertFalse(r1.equals(r2));
    r2.setStepPoint(0.44);
    assertTrue(r1.equals(r2));

    // try something from the base class
    r1.setBaseCreateEntities(false);
    assertFalse(r1.equals(r2));
    r2.setBaseCreateEntities(false);
    assertTrue(r1.equals(r2));
}
 
Example #2
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a stepped XY plot with default settings.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-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 chart.
 */
public static JFreeChart createXYStepChart(String title, String xAxisLabel,
        String yAxisLabel, XYDataset dataset, boolean legend) {

    DateAxis xAxis = new DateAxis(xAxisLabel);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYItemRenderer renderer = new XYStepRenderer();
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    plot.setRenderer(renderer);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #3
Source File: XYStepRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    XYStepRenderer r1 = new XYStepRenderer();
    XYStepRenderer r2 = new XYStepRenderer();
    assertEquals(r1, r2);
    
    r1.setStepPoint(0.44);
    assertFalse(r1.equals(r2));
    r2.setStepPoint(0.44);
    assertTrue(r1.equals(r2));
    
    // try something from the base class
    r1.setBaseCreateEntities(false);
    assertFalse(r1.equals(r2));
    r2.setBaseCreateEntities(false);
    assertTrue(r1.equals(r2));
}
 
Example #4
Source File: StepCustomizer.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void customize(JFreeChart jfc, JRChart jrc) 
{
	Plot plot = jfc.getPlot();
	if (plot instanceof XYPlot)
	{
		((XYPlot)plot).setRenderer(new XYStepRenderer());
	}
}
 
Example #5
Source File: XYStepRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    XYStepRenderer r1 = new XYStepRenderer();
    r1.setStepPoint(0.123);
    XYStepRenderer r2 = new XYStepRenderer();
    r2.setStepPoint(0.123);
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
 
Example #6
Source File: XYStepRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 {
        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 XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
Example #7
Source File: XYStepRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the chart with a <code>null</code> value in the dataset to make
 * sure that no exceptions are thrown.
 */
public void testDrawWithNullValue() {
    boolean success = false;
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, null);
        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, null);
        s2.add(20.0, null);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                new XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
Example #8
Source File: XYStepRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    XYStepRenderer r1 = new XYStepRenderer();
    r1.setStepPoint(0.123);
    XYStepRenderer r2 = new XYStepRenderer();
    r2.setStepPoint(0.123);
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
 
Example #9
Source File: XYStepRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 {
        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 XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
Example #10
Source File: XYStepRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the chart with a <code>null</code> value in the dataset to make 
 * sure that no exceptions are thrown.
 */
public void testDrawWithNullValue() {
    boolean success = false;
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();
    
        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, null);
        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, null);
        s2.add(20.0, null);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset, 
                new NumberAxis("X"), new NumberAxis("Y"), 
                new XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
Example #11
Source File: XYStepRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Verify that this class implements {@link PublicCloneable}.
 */
public void testPublicCloneable() {
    XYStepRenderer r1 = new XYStepRenderer();
    assertTrue(r1 instanceof PublicCloneable);
}