public class CombinedDomainXYPlotTests extends TestCase implements ChartChangeListener { /** A list of the events received. */ private List events = new java.util.ArrayList(); /** * Receives a chart change event. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.events.add(event); } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CombinedDomainXYPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CombinedDomainXYPlotTests(String name) { super(name); } /** * Confirm that the constructor will accept a null axis. */ public void testConstructor1() { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(null); assertEquals(null, plot.getDomainAxis()); } /** * This is a test to replicate the bug report 987080. */ public void testRemoveSubplot() { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(); 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); } /** * Tests the equals() method. */ public void testEquals() { CombinedDomainXYPlot plot1 = createPlot(); CombinedDomainXYPlot plot2 = createPlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); } /** * Confirm that cloning works. */ public void testCloning() { CombinedDomainXYPlot plot1 = createPlot(); CombinedDomainXYPlot plot2 = null; try { plot2 = (CombinedDomainXYPlot) plot1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(plot1 != plot2); assertTrue(plot1.getClass() == plot2.getClass()); assertTrue(plot1.equals(plot2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CombinedDomainXYPlot plot1 = createPlot(); CombinedDomainXYPlot plot2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(plot1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); plot2 = (CombinedDomainXYPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(plot1, plot2); } /** * Check that only one chart change event is generated by a change to a * subplot. */ public void testNotification() { CombinedDomainXYPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.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()); } /** * Creates a sample dataset. * * @return Series 1. */ private XYDataset createDataset1() { // create dataset 1... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 12353.3); series1.add(20.0, 13734.4); series1.add(30.0, 14525.3); series1.add(40.0, 13984.3); series1.add(50.0, 12999.4); series1.add(60.0, 14274.3); series1.add(70.0, 15943.5); series1.add(80.0, 14845.3); series1.add(90.0, 14645.4); series1.add(100.0, 16234.6); series1.add(110.0, 17232.3); series1.add(120.0, 14232.2); series1.add(130.0, 13102.2); series1.add(140.0, 14230.2); series1.add(150.0, 11235.2); XYSeries series2 = new XYSeries("Series 2"); series2.add(10.0, 15000.3); series2.add(20.0, 11000.4); series2.add(30.0, 17000.3); series2.add(40.0, 15000.3); series2.add(50.0, 14000.4); series2.add(60.0, 12000.3); series2.add(70.0, 11000.5); series2.add(80.0, 12000.3); series2.add(90.0, 13000.4); series2.add(100.0, 12000.6); series2.add(110.0, 13000.3); series2.add(120.0, 17000.2); series2.add(130.0, 18000.2); series2.add(140.0, 16000.2); series2.add(150.0, 17000.2); XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(series1); collection.addSeries(series2); return collection; } /** * Creates a sample dataset. * * @return Series 2. */ private XYDataset createDataset2() { XYSeries series2 = new XYSeries("Series 3"); series2.add(10.0, 16853.2); series2.add(20.0, 19642.3); series2.add(30.0, 18253.5); series2.add(40.0, 15352.3); series2.add(50.0, 13532.0); series2.add(100.0, 12635.3); series2.add(110.0, 13998.2); series2.add(120.0, 11943.2); series2.add(130.0, 16943.9); series2.add(140.0, 17843.2); series2.add(150.0, 16495.3); series2.add(160.0, 17943.6); series2.add(170.0, 18500.7); series2.add(180.0, 19595.9); return new XYSeriesCollection(series2); } /** * Creates a sample plot. * * @return A sample plot. */ private CombinedDomainXYPlot 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... CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); return plot
public class CombinedRangeXYPlotTests extends TestCase implements ChartChangeListener { /** A list of the events received. */ private List events = new java.util.ArrayList(); /** * Receives a chart change event. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.events.add(event); } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CombinedRangeXYPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CombinedRangeXYPlotTests(String name) { super(name); } /** * Test the equals method. */ public void testEquals() { CombinedRangeXYPlot plot1 = createPlot(); CombinedRangeXYPlot plot2 = createPlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); } /** * 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); } /** * Confirm that cloning works. */ public void testCloning() { CombinedRangeXYPlot plot1 = createPlot(); CombinedRangeXYPlot plot2 = null; try { plot2 = (CombinedRangeXYPlot) plot1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(plot1 != plot2); assertTrue(plot1.getClass() == plot2.getClass()); assertTrue(plot1.equals(plot2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CombinedRangeXYPlot plot1 = createPlot(); CombinedRangeXYPlot plot2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(plot1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); plot2 = (CombinedRangeXYPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(plot1, plot2); } /** * 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()); } /** * Creates a sample dataset. * * @return Series 1. */ private XYDataset createDataset1() { XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 12353.3); series1.add(20.0, 13734.4); series1.add(30.0, 14525.3); series1.add(40.0, 13984.3); series1.add(50.0, 12999.4); series1.add(60.0, 14274.3); series1.add(70.0, 15943.5); series1.add(80.0, 14845.3); series1.add(90.0, 14645.4); series1.add(100.0, 16234.6); series1.add(110.0, 17232.3); series1.add(120.0, 14232.2); series1.add(130.0, 13102.2); series1.add(140.0, 14230.2); series1.add(150.0, 11235.2); XYSeries series2 = new XYSeries("Series 2"); series2.add(10.0, 15000.3); series2.add(20.0, 11000.4); series2.add(30.0, 17000.3); series2.add(40.0, 15000.3); series2.add(50.0, 14000.4); series2.add(60.0, 12000.3); series2.add(70.0, 11000.5); series2.add(80.0, 12000.3); series2.add(90.0, 13000.4); series2.add(100.0, 12000.6); series2.add(110.0, 13000.3); series2.add(120.0, 17000.2); series2.add(130.0, 18000.2); series2.add(140.0, 16000.2); series2.add(150.0, 17000.2); XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(series1); collection.addSeries(series2); return collection; } /** * Creates a sample dataset. * * @return Series 2. */ private XYDataset createDataset2() { // create dataset 2... XYSeries series2 = new XYSeries("Series 3"); series2.add(10.0, 16853.2); series2.add(20.0, 19642.3); series2.add(30.0, 18253.5); series2.add(40.0, 15352.3); series2.add(50.0, 13532.0); series2.add(100.0, 12635.3); series2.add(110.0, 13998.2); series2.add(120.0, 11943.2); series2.add(130.0, 16943.9); series2.add(140.0, 17843.2); series2.add(150.0, 16495.3); series2.add(160.0, 17943.6); series2.add(170.0, 18500.7); series2.add(180.0, 19595.9); return new XYSeriesCollection(series2); } /** * 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
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/CombinedDomainXYPlotTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/CombinedRangeXYPlotTests.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class CombinedDomainXYPlotTests extends TestCase 
1
public class CombinedRangeXYPlotTests extends TestCase  
2
        implements ChartChangeListener {
2
        implements ChartChangeListener {
3
    /** A list of the events received. */
3
    /** A list of the events received. */
4
    private List events = new java.util.ArrayList();
4
    private List events = new java.util.ArrayList();
5
    
5
    
6
    /**
6
    /**
7
     * Receives a chart change event.
7
     * Receives a chart change event.
8
     * 
8
     * 
9
     * @param event  the event.
9
     * @param event  the event.
10
     */
10
     */
11
    public void chartChanged(ChartChangeEvent event) {
11
    public void chartChanged(ChartChangeEvent event) {
12
        this.events.add(event);
12
        this.events.add(event);
13
    }
13
    }
14
    /**
14
    /**
15
     * Returns the tests as a test suite.
15
     * Returns the tests as a test suite.
16
     *
16
     *
17
     * @return The test suite.
17
     * @return The test suite.
18
     */
18
     */
19
    public static Test suite() {
19
    public static Test suite() {
20
        return new TestSuite(CombinedDomainXYPlotTests.class);
20
        return new TestSuite(CombinedRangeXYPlotTests.class);
21
    }
21
    }
22
    /**
22
    /**
23
     * Constructs a new set of tests.
23
     * Constructs a new set of tests.
24
     *
24
     *
25
     * @param name  the name of the tests.
25
     * @param name  the name of the tests.
26
     */
26
     */
27
    public CombinedDomainXYPlotTests(String name) {
27
    public CombinedRangeXYPlotTests(String name) {
28
        super(name);
28
        super(name);
29
    }
29
    }
30
    /**
30
    /**
31
     * Confirm that the constructor will accept a null axis.
31
     * Test the equals method.
32
     */
32
     */
33
    public void testConstructor1() {
33
    public void testEquals() {
34
        CombinedDomainXYPlot plot = new
34
        CombinedRangeXYPlot plot1 = createPlot();
35
 CombinedDomainXYPlot(null);
35
        CombinedRangeXYPlot plot2 = createPlot();
36
        assertEquals(null, plot.getDomainAxis(
36
        assertTrue(plot1.equals(plot2));    
37
));
37
        assertTrue(plot2.equals(plot1));
38
    }
38
    }
39
    
40
    /**
39
    /**
41
     * This is a test to replicate the bug report 987080.
40
     * This is a test to replicate the bug report 987080.
42
     */
41
     */
43
    public void testRemoveSubplot() {
42
    public void testRemoveSubplot() {
44
        CombinedDomainXYPlot plot = new CombinedDomainXYPlot();
43
        CombinedRangeXYPlot plot = new CombinedRangeXYPlot();
45
        XYPlot plot1 = new XYPlot();
44
        XYPlot plot1 = new XYPlot();
46
        XYPlot plot2 = new XYPlot();
45
        XYPlot plot2 = new XYPlot();
47
        plot.add(plot1);
46
        plot.add(plot1);
48
        plot.add(plot2);
47
        plot.add(plot2);
49
        // remove plot2, but plot1 is removed instead
48
        // remove plot2, but plot1 is removed instead
50
        plot.remove(plot2);
49
        plot.remove(plot2);
51
        List plots = plot.getSubplots();
50
        List plots = plot.getSubplots();
52
        assertTrue(plots.get(0) == plot1);
51
        assertTrue(plots.get(0) == plot1);
53
    }
52
    }
54
    
53
    
55
    /**
56
     * Tests the equals() method.
57
     */
58
    public void testEquals() {
59
        CombinedDomainXYPlot plot1 = createPlot();
60
        CombinedDomainXYPlot plot2 = createPlot();
61
        assertTrue(plot1.equals(plot2));    
62
        assertTrue(plot2.equals(plot1));
63
    }
64
    /**
54
    /**
65
     * Confirm that cloning works.
55
     * Confirm that cloning works.
66
     */
56
     */
67
    public void testCloning() {
57
    public void testCloning() {
68
        CombinedDomainXYPlot plot1 = createPlot();        
58
        CombinedRangeXYPlot plot1 = createPlot();        
69
        CombinedDomainXYPlot plot2 = null;
59
        CombinedRangeXYPlot plot2 = null;
70
        try {
60
        try {
71
            plot2 = (CombinedDomainXYPlot) plot1.clone();
61
            plot2 = (CombinedRangeXYPlot) plot1.clone();
72
        }
62
        }
73
        catch (CloneNotSupportedException e) {
63
        catch (CloneNotSupportedException e) {
74
            e.printStackTrace();
64
            e.printStackTrace();
75
        }
65
        }
76
        assertTrue(plot1 != plot2);
66
        assertTrue(plot1 != plot2);
77
        assertTrue(plot1.getClass() == plot2.getClass());
67
        assertTrue(plot1.getClass() == plot2.getClass());
78
        assertTrue(plot1.equals(plot2));
68
        assertTrue(plot1.equals(plot2));
79
    }
69
    }
80
    /**
70
    /**
81
     * Serialize an instance, restore it, and check for equality.
71
     * Serialize an instance, restore it, and check for equality.
82
     */
72
     */
83
    public void testSerialization() {
73
    public void testSerialization() {
84
        CombinedDomainXYPlot plot1 = createPlot();
74
        CombinedRangeXYPlot plot1 = createPlot();
85
        CombinedDomainXYPlot plot2 = null;
75
        CombinedRangeXYPlot plot2 = null;
86
        try {
76
        try {
87
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
77
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
88
            ObjectOutput out = new ObjectOutputStream(buffer);
78
            ObjectOutput out = new ObjectOutputStream(buffer);
89
            out.writeObject(plot1);
79
            out.writeObject(plot1);
90
            out.close();
80
            out.close();
91
            ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
81
            ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
92
                    buffer.toByteArray()));
82
                    buffer.toByteArray()));
93
            plot2 = (CombinedDomainXYPlot) in.readObject();
83
            plot2 = (CombinedRangeXYPlot) in.readObject();
94
            in.close();
84
            in.close();
95
        }
85
        }
96
        catch (Exception e) {
86
        catch (Exception e) {
97
            e.printStackTrace();
87
            e.printStackTrace();
98
        }
88
        }
99
        assertEquals(plot1, plot2);
89
        assertEquals(plot1, plot2);
100
    }
90
    }
101
    
91
    
102
    /**
92
    /**
103
     * Check that only one chart change event is generated by a change to a
93
     * Check that only one chart change event is generated by a change to a
104
     * subplot.
94
     * subplot.
105
     */
95
     */
106
    public void testNotification() {
96
    public void testNotification() {
107
        CombinedDomainXYPlot plot = createPlot();
97
        CombinedRangeXYPlot plot = createPlot();
108
        JFreeChart chart = new JFreeChart(plot);
98
        JFreeChart chart = new JFreeChart(plot);
109
        chart.addChangeListener(this);
99
        chart.addChangeListener(this);
110
        XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0);
100
        XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0);
111
        NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis();
101
        NumberAxis xAxis = (NumberAxis) subplot1.getDomainAxis();
112
        yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero());
102
        xAxis.setAutoRangeIncludesZero(!xAxis.getAutoRangeIncludesZero());
113
        assertEquals(1, this.events.size());
103
        assertEquals(1, this.events.size());
114
        
104
        
115
        // a redraw should NOT trigger another change event
105
        // a redraw should NOT trigger another change event
116
        BufferedImage image = new BufferedImage(200, 100, 
106
        BufferedImage image = new BufferedImage(200, 100, 
117
                BufferedImage.TYPE_INT_RGB);
107
                BufferedImage.TYPE_INT_RGB);
118
        Graphics2D g2 = image.createGraphics();
108
        Graphics2D g2 = image.createGraphics();
119
        this.events.clear();
109
        this.events.clear();
120
        chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0));
110
        chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0));
121
        assertTrue(this.events.isEmpty());
111
        assertTrue(this.events.isEmpty());
122
    } 
112
    }
123
    
113
    
124
    /**
114
    /**
125
     * Creates a sample dataset.
115
     * Creates a sample dataset.
126
     *
116
     *
127
     * @return Series 1.
117
     * @return Series 1.
128
     */
118
     */
129
    private XYDataset createDataset1() {
119
    private XYDataset createDataset1() {
130
        // create dataset 1...
131
        XYSeries series1 = new XYSeries("Series 1");
120
        XYSeries series1 = new XYSeries("Series 1");
132
        series1.add(10.0, 12353.3);
121
        series1.add(10.0, 12353.3);
133
        series1.add(20.0, 13734.4);
122
        series1.add(20.0, 13734.4);
134
        series1.add(30.0, 14525.3);
123
        series1.add(30.0, 14525.3);
135
        series1.add(40.0, 13984.3);
124
        series1.add(40.0, 13984.3);
136
        series1.add(50.0, 12999.4);
125
        series1.add(50.0, 12999.4);
137
        series1.add(60.0, 14274.3);
126
        series1.add(60.0, 14274.3);
138
        series1.add(70.0, 15943.5);
127
        series1.add(70.0, 15943.5);
139
        series1.add(80.0, 14845.3);
128
        series1.add(80.0, 14845.3);
140
        series1.add(90.0, 14645.4);
129
        series1.add(90.0, 14645.4);
141
        series1.add(100.0, 16234.6);
130
        series1.add(100.0, 16234.6);
142
        series1.add(110.0, 17232.3);
131
        series1.add(110.0, 17232.3);
143
        series1.add(120.0, 14232.2);
132
        series1.add(120.0, 14232.2);
144
        series1.add(130.0, 13102.2);
133
        series1.add(130.0, 13102.2);
145
        series1.add(140.0, 14230.2);
134
        series1.add(140.0, 14230.2);
146
        series1.add(150.0, 11235.2);
135
        series1.add(150.0, 11235.2);
147
        XYSeries series2 = new XYSeries("Series 2");
136
        XYSeries series2 = new XYSeries("Series 2");
148
        series2.add(10.0, 15000.3);
137
        series2.add(10.0, 15000.3);
149
        series2.add(20.0, 11000.4);
138
        series2.add(20.0, 11000.4);
150
        series2.add(30.0, 17000.3);
139
        series2.add(30.0, 17000.3);
151
        series2.add(40.0, 15000.3);
140
        series2.add(40.0, 15000.3);
152
        series2.add(50.0, 14000.4);
141
        series2.add(50.0, 14000.4);
153
        series2.add(60.0, 12000.3);
142
        series2.add(60.0, 12000.3);
154
        series2.add(70.0, 11000.5);
143
        series2.add(70.0, 11000.5);
155
        series2.add(80.0, 12000.3);
144
        series2.add(80.0, 12000.3);
156
        series2.add(90.0, 13000.4);
145
        series2.add(90.0, 13000.4);
157
        series2.add(100.0, 12000.6);
146
        series2.add(100.0, 12000.6);
158
        series2.add(110.0, 13000.3);
147
        series2.add(110.0, 13000.3);
159
        series2.add(120.0, 17000.2);
148
        series2.add(120.0, 17000.2);
160
        series2.add(130.0, 18000.2);
149
        series2.add(130.0, 18000.2);
161
        series2.add(140.0, 16000.2);
150
        series2.add(140.0, 16000.2);
162
        series2.add(150.0, 17000.2);
151
        series2.add(150.0, 17000.2);
163
        XYSeriesCollection collection = new XYSeriesCollection();
152
        XYSeriesCollection collection = new XYSeriesCollection();
164
        collection.addSeries(series1);
153
        collection.addSeries(series1);
165
        collection.addSeries(series2);
154
        collection.addSeries(series2);
166
        return collection;
155
        return collection;
167
    }
156
    }
168
    /**
157
    /**
169
     * Creates a sample dataset.
158
     * Creates a sample dataset.
170
     *
159
     *
171
     * @return Series 2.
160
     * @return Series 2.
172
     */
161
     */
173
    private XYDataset createDataset2() {
162
    private XYDataset createDataset2() {
163
        // create dataset 2...
174
        XYSeries series2 = new XYSeries("Series 3");
164
        XYSeries series2 = new XYSeries("Series 3");
175
        series2.add(10.0, 16853.2);
165
        series2.add(10.0, 16853.2);
176
        series2.add(20.0, 19642.3);
166
        series2.add(20.0, 19642.3);
177
        series2.add(30.0, 18253.5);
167
        series2.add(30.0, 18253.5);
178
        series2.add(40.0, 15352.3);
168
        series2.add(40.0, 15352.3);
179
        series2.add(50.0, 13532.0);
169
        series2.add(50.0, 13532.0);
180
        series2.add(100.0, 12635.3);
170
        series2.add(100.0, 12635.3);
181
        series2.add(110.0, 13998.2);
171
        series2.add(110.0, 13998.2);
182
        series2.add(120.0, 11943.2);
172
        series2.add(120.0, 11943.2);
183
        series2.add(130.0, 16943.9);
173
        series2.add(130.0, 16943.9);
184
        series2.add(140.0, 17843.2);
174
        series2.add(140.0, 17843.2);
185
        series2.add(150.0, 16495.3);
175
        series2.add(150.0, 16495.3);
186
        series2.add(160.0, 17943.6);
176
        series2.add(160.0, 17943.6);
187
        series2.add(170.0, 18500.7);
177
        series2.add(170.0, 18500.7);
188
        series2.add(180.0, 19595.9);
178
        series2.add(180.0, 19595.9);
189
        return new XYSeriesCollection(series2);
179
        return new XYSeriesCollection(series2);
190
    }
180
    }
191
    /**
181
    /**
192
     * Creates a sample plot.
182
     * Creates a sample plot.
193
     * 
183
     * 
194
     * @return A sample plot.
184
     * @return A sample plot.
195
     */
185
     */
196
    private CombinedDomainXYPlot createPlot() {
186
    private CombinedRangeXYPlot createPlot() {
197
        // create subplot 1...
187
        // create subplot 1...
198
        XYDataset data1 = createDataset1();
188
        XYDataset data1 = createDataset1();
199
        XYItemRenderer renderer1 = new StandardXYItemRenderer();
189
        XYItemRenderer renderer1 = new StandardXYItemRenderer();
200
        NumberAxis rangeAxis1 = new NumberAxis("Range 1");
190
        NumberAxis xAxis1 = new NumberAxis("X1");
201
        XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
191
        XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
202
        subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
192
        subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
203
        
193
         
204
        XYTextAnnotation annotation 
194
        XYTextAnnotation annotation 
205
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
195
                = new XYTextAnnotation("Hello!", 50.0, 10000.0);
206
        annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
196
        annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
207
        annotation.setRotationAngle(Math.PI / 4.0);
197
        annotation.setRotationAngle(Math.PI / 4.0);
208
        subplot1.addAnnotation(annotation);
198
        subplot1.addAnnotation(annotation);
209
        
199
         
210
        // create subplot 2...
200
        // create subplot 2...
211
        XYDataset data2 = createDataset2();
201
        XYDataset data2 = createDataset2();
212
        XYItemRenderer renderer2 = new StandardXYItemRenderer();
202
        XYItemRenderer renderer2 = new StandardXYItemRenderer();
213
        NumberAxis rangeAxis2 = new NumberAxis("Range 2");
203
        NumberAxis xAxis2 = new NumberAxis("X2");
214
        rangeAxis2.setAutoRangeIncludesZero(false);
204
        xAxis2.setAutoRangeIncludesZero(false);
215
        XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
205
        XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
216
        subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
206
        subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); 
217
        // parent plot...
207
        // parent plot...
218
        CombinedDomainXYPlot plot 
208
        CombinedRangeXYPlot plot 
219
            = new CombinedDomainXYPlot(new NumberAxis("Domain
209
= new CombinedRangeXYPlot(new NumberAxis(
220
"));
210
                "Range"));
221
        plot.setGap(10.0);
211
        plot.setGap(10.0);
222
        
212
        
223
        // add the subplots...
213
        // add the subplots...
224
        plot.add(subplot1, 1);
214
        plot.add(subplot1, 1);
225
        plot.add(subplot2, 1);
215
        plot.add(subplot2, 1);
226
        plot.setOrientation(PlotOrientation.VERTICAL);
216
        plot.setOrientation(PlotOrientation.VERTICAL);
227
        return plot
217
        return plot
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0