org.jfree.chart.plot.CombinedRangeXYPlot Java Examples

The following examples show how to use org.jfree.chart.plot.CombinedRangeXYPlot. 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: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check that only one chart change event is generated by a change to a
 * subplot.
 */
public void testNotification() {
    CombinedRangeXYPlot plot = createPlot();
    JFreeChart chart = new JFreeChart(plot);
    chart.addChangeListener(this);
    XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0);
    NumberAxis xAxis = (NumberAxis) subplot1.getDomainAxis();
    xAxis.setAutoRangeIncludesZero(!xAxis.getAutoRangeIncludesZero());
    assertEquals(1, this.events.size());

    // a redraw should NOT trigger another change event
    BufferedImage image = new BufferedImage(200, 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    this.events.clear();
    chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0));
    assertTrue(this.events.isEmpty());
}
 
Example #2
Source File: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test the equals method.
 */
public void testEquals() {
    CombinedRangeXYPlot plot1 = createPlot();
    CombinedRangeXYPlot plot2 = createPlot();
    assertTrue(plot1.equals(plot2));
    assertTrue(plot2.equals(plot1));
}
 
Example #3
Source File: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a test to replicate the bug report 987080.
 */
public void testRemoveSubplot() {
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot();
    XYPlot plot1 = new XYPlot();
    XYPlot plot2 = new XYPlot();
    plot.add(plot1);
    plot.add(plot2);
    // remove plot2, but plot1 is removed instead
    plot.remove(plot2);
    List plots = plot.getSubplots();
    assertTrue(plots.get(0) == plot1);
}
 
Example #4
Source File: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example #5
Source File: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test the equals method.
 */
public void testEquals() {
    CombinedRangeXYPlot plot1 = createPlot();
    CombinedRangeXYPlot plot2 = createPlot();
    assertTrue(plot1.equals(plot2));    
    assertTrue(plot2.equals(plot1));
}
 
Example #6
Source File: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a test to replicate the bug report 987080.
 */
public void testRemoveSubplot() {
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot();
    XYPlot plot1 = new XYPlot();
    XYPlot plot2 = new XYPlot();
    plot.add(plot1);
    plot.add(plot2);
    // remove plot2, but plot1 is removed instead
    plot.remove(plot2);
    List plots = plot.getSubplots();
    assertTrue(plots.get(0) == plot1);
}
 
Example #7
Source File: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 * 
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
     
    XYTextAnnotation annotation 
        = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);
     
    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); 

    // parent plot...
    CombinedRangeXYPlot plot 
        = new CombinedRangeXYPlot(new NumberAxis("Range"));
    plot.setGap(10.0);
    
    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}