1 42 43 package org.jfree.chart.plot.junit; 44 45 import java.awt.BasicStroke ; 46 import java.awt.Color ; 47 import java.awt.Stroke ; 48 import java.io.ByteArrayInputStream ; 49 import java.io.ByteArrayOutputStream ; 50 import java.io.ObjectInput ; 51 import java.io.ObjectInputStream ; 52 import java.io.ObjectOutput ; 53 import java.io.ObjectOutputStream ; 54 55 import junit.framework.Test; 56 import junit.framework.TestCase; 57 import junit.framework.TestSuite; 58 59 import org.jfree.chart.ChartFactory; 60 import org.jfree.chart.JFreeChart; 61 import org.jfree.chart.LegendItemCollection; 62 import org.jfree.chart.axis.AxisLocation; 63 import org.jfree.chart.axis.DateAxis; 64 import org.jfree.chart.axis.NumberAxis; 65 import org.jfree.chart.labels.StandardXYToolTipGenerator; 66 import org.jfree.chart.plot.IntervalMarker; 67 import org.jfree.chart.plot.PlotOrientation; 68 import org.jfree.chart.plot.ValueMarker; 69 import org.jfree.chart.plot.XYPlot; 70 import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; 71 import org.jfree.chart.renderer.xy.StandardXYItemRenderer; 72 import org.jfree.chart.renderer.xy.XYBarRenderer; 73 import org.jfree.chart.renderer.xy.XYItemRenderer; 74 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; 75 import org.jfree.data.time.Day; 76 import org.jfree.data.time.TimeSeries; 77 import org.jfree.data.time.TimeSeriesCollection; 78 import org.jfree.data.xy.IntervalXYDataset; 79 import org.jfree.data.xy.XYDataset; 80 import org.jfree.data.xy.XYSeries; 81 import org.jfree.data.xy.XYSeriesCollection; 82 import org.jfree.date.MonthConstants; 83 import org.jfree.ui.Layer; 84 import org.jfree.ui.RectangleInsets; 85 86 89 public class XYPlotTests extends TestCase { 90 91 96 public static Test suite() { 97 return new TestSuite(XYPlotTests.class); 98 } 99 100 105 public XYPlotTests(String name) { 106 super(name); 107 } 108 109 112 public void testGetDatasetCount() { 113 XYPlot plot = new XYPlot(); 114 assertEquals(0, plot.getDatasetCount()); 115 } 116 117 120 public void testEquals() { 121 122 XYPlot plot1 = new XYPlot(); 123 XYPlot plot2 = new XYPlot(); 124 assertTrue(plot1.equals(plot2)); 125 126 plot1.setOrientation(PlotOrientation.HORIZONTAL); 128 assertFalse(plot1.equals(plot2)); 129 plot2.setOrientation(PlotOrientation.HORIZONTAL); 130 assertTrue(plot1.equals(plot2)); 131 132 plot1.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05)); 134 assertFalse(plot1.equals(plot2)); 135 plot2.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05)); 136 assertTrue(plot1.equals(plot2)); 137 138 plot1.setDomainAxis(new NumberAxis("Domain Axis")); 140 assertFalse(plot1.equals(plot2)); 141 plot2.setDomainAxis(new NumberAxis("Domain Axis")); 142 assertTrue(plot1.equals(plot2)); 143 144 plot1.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); 146 assertFalse(plot1.equals(plot2)); 147 plot2.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); 148 assertTrue(plot1.equals(plot2)); 149 150 plot1.setDomainAxis(11, new NumberAxis("Secondary Domain Axis")); 152 assertFalse(plot1.equals(plot2)); 153 plot2.setDomainAxis(11, new NumberAxis("Secondary Domain Axis")); 154 assertTrue(plot1.equals(plot2)); 155 156 plot1.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT); 158 assertFalse(plot1.equals(plot2)); 159 plot2.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT); 160 assertTrue(plot1.equals(plot2)); 161 162 plot1.setRangeAxis(new NumberAxis("Range Axis")); 164 assertFalse(plot1.equals(plot2)); 165 plot2.setRangeAxis(new NumberAxis("Range Axis")); 166 assertTrue(plot1.equals(plot2)); 167 168 plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); 170 assertFalse(plot1.equals(plot2)); 171 plot2.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); 172 assertTrue(plot1.equals(plot2)); 173 174 plot1.setRangeAxis(11, new NumberAxis("Secondary Range Axis")); 176 assertFalse(plot1.equals(plot2)); 177 plot2.setRangeAxis(11, new NumberAxis("Secondary Range Axis")); 178 assertTrue(plot1.equals(plot2)); 179 180 plot1.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT); 182 assertFalse(plot1.equals(plot2)); 183 plot2.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT); 184 assertTrue(plot1.equals(plot2)); 185 186 plot1.mapDatasetToDomainAxis(11, 11); 188 assertFalse(plot1.equals(plot2)); 189 plot2.mapDatasetToDomainAxis(11, 11); 190 assertTrue(plot1.equals(plot2)); 191 192 plot1.mapDatasetToRangeAxis(11, 11); 194 assertFalse(plot1.equals(plot2)); 195 plot2.mapDatasetToRangeAxis(11, 11); 196 assertTrue(plot1.equals(plot2)); 197 198 plot1.setRenderer(new DefaultXYItemRenderer()); 200 assertFalse(plot1.equals(plot2)); 201 plot2.setRenderer(new DefaultXYItemRenderer()); 202 assertTrue(plot1.equals(plot2)); 203 204 plot1.setRenderer(11, new DefaultXYItemRenderer()); 206 assertFalse(plot1.equals(plot2)); 207 plot2.setRenderer(11, new DefaultXYItemRenderer()); 208 assertTrue(plot1.equals(plot2)); 209 210 plot1.setDomainGridlinesVisible(false); 212 assertFalse(plot1.equals(plot2)); 213 plot2.setDomainGridlinesVisible(false); 214 assertTrue(plot1.equals(plot2)); 215 216 Stroke stroke = new BasicStroke (2.0f); 218 plot1.setDomainGridlineStroke(stroke); 219 assertFalse(plot1.equals(plot2)); 220 plot2.setDomainGridlineStroke(stroke); 221 assertTrue(plot1.equals(plot2)); 222 223 plot1.setDomainGridlinePaint(Color.blue); 225 assertFalse(plot1.equals(plot2)); 226 plot2.setDomainGridlinePaint(Color.blue); 227 assertTrue(plot1.equals(plot2)); 228 229 plot1.setRangeGridlinesVisible(false); 231 assertFalse(plot1.equals(plot2)); 232 plot2.setRangeGridlinesVisible(false); 233 assertTrue(plot1.equals(plot2)); 234 235 plot1.setRangeGridlineStroke(stroke); 237 assertFalse(plot1.equals(plot2)); 238 plot2.setRangeGridlineStroke(stroke); 239 assertTrue(plot1.equals(plot2)); 240 241 plot1.setRangeGridlinePaint(Color.blue); 243 assertFalse(plot1.equals(plot2)); 244 plot2.setRangeGridlinePaint(Color.blue); 245 assertTrue(plot1.equals(plot2)); 246 247 plot1.setRangeZeroBaselineVisible(true); 249 assertFalse(plot1.equals(plot2)); 250 plot2.setRangeZeroBaselineVisible(true); 251 assertTrue(plot1.equals(plot2)); 252 253 plot1.setRangeZeroBaselineStroke(stroke); 255 assertFalse(plot1.equals(plot2)); 256 plot2.setRangeZeroBaselineStroke(stroke); 257 assertTrue(plot1.equals(plot2)); 258 259 plot1.setRangeZeroBaselinePaint(Color.blue); 261 assertFalse(plot1.equals(plot2)); 262 plot2.setRangeZeroBaselinePaint(Color.blue); 263 assertTrue(plot1.equals(plot2)); 264 265 plot1.setRangeCrosshairVisible(true); 267 assertFalse(plot1.equals(plot2)); 268 plot2.setRangeCrosshairVisible(true); 269 assertTrue(plot1.equals(plot2)); 270 271 plot1.setRangeCrosshairValue(100.0); 273 assertFalse(plot1.equals(plot2)); 274 plot2.setRangeCrosshairValue(100.0); 275 assertTrue(plot1.equals(plot2)); 276 277 plot1.setRangeCrosshairStroke(stroke); 279 assertFalse(plot1.equals(plot2)); 280 plot2.setRangeCrosshairStroke(stroke); 281 assertTrue(plot1.equals(plot2)); 282 283 plot1.setRangeCrosshairPaint(Color.red); 285 assertFalse(plot1.equals(plot2)); 286 plot2.setRangeCrosshairPaint(Color.red); 287 assertTrue(plot1.equals(plot2)); 288 289 plot1.setRangeCrosshairLockedOnData(false); 291 assertFalse(plot1.equals(plot2)); 292 plot2.setRangeCrosshairLockedOnData(false); 293 assertTrue(plot1.equals(plot2)); 294 295 plot1.addRangeMarker(new ValueMarker(4.0)); 297 assertFalse(plot1.equals(plot2)); 298 plot2.addRangeMarker(new ValueMarker(4.0)); 299 assertTrue(plot1.equals(plot2)); 300 301 plot1.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND); 303 assertFalse(plot1.equals(plot2)); 304 plot2.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND); 305 assertTrue(plot1.equals(plot2)); 306 307 plot1.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND); 308 assertFalse(plot1.equals(plot2)); 309 plot2.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND); 310 assertTrue(plot1.equals(plot2)); 311 312 plot1.setWeight(3); 314 assertFalse(plot1.equals(plot2)); 315 plot2.setWeight(3); 316 assertTrue(plot1.equals(plot2)); 317 318 } 319 320 323 public void testCloning() { 324 XYPlot p1 = new XYPlot(); 325 XYPlot p2 = null; 326 try { 327 p2 = (XYPlot) p1.clone(); 328 } 329 catch (CloneNotSupportedException e) { 330 e.printStackTrace(); 331 System.err.println("XYPlotTests.testCloning: failed to clone."); 332 } 333 assertTrue(p1 != p2); 334 assertTrue(p1.getClass() == p2.getClass()); 335 assertTrue(p1.equals(p2)); 336 } 337 338 341 public void testCloning2() { 342 XYPlot p1 = new XYPlot( 343 null, new NumberAxis("Domain Axis"), new NumberAxis("Range Axis"), 344 new StandardXYItemRenderer() 345 ); 346 p1.setRangeAxis(1, new NumberAxis("Range Axis 2")); 347 p1.setRenderer(1, new XYBarRenderer()); 348 XYPlot p2 = null; 349 try { 350 p2 = (XYPlot) p1.clone(); 351 } 352 catch (CloneNotSupportedException e) { 353 e.printStackTrace(); 354 System.err.println("Failed to clone."); 355 } 356 assertTrue(p1 != p2); 357 assertTrue(p1.getClass() == p2.getClass()); 358 assertTrue(p1.equals(p2)); 359 } 360 361 364 public void testCloneIndependence() { 365 XYPlot p1 = new XYPlot( 366 null, new NumberAxis("Domain Axis"), new NumberAxis("Range Axis"), 367 new StandardXYItemRenderer() 368 ); 369 p1.setDomainAxis(1, new NumberAxis("Domain Axis 2")); 370 p1.setDomainAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); 371 p1.setRangeAxis(1, new NumberAxis("Range Axis 2")); 372 p1.setRangeAxisLocation(1, AxisLocation.TOP_OR_RIGHT); 373 p1.setRenderer(1, new XYBarRenderer()); 374 XYPlot p2 = null; 375 try { 376 p2 = (XYPlot) p1.clone(); 377 } 378 catch (CloneNotSupportedException e) { 379 e.printStackTrace(); 380 System.err.println("Failed to clone."); 381 } 382 assertTrue(p1.equals(p2)); 383 384 p1.getDomainAxis().setLabel("Label"); 385 assertFalse(p1.equals(p2)); 386 p2.getDomainAxis().setLabel("Label"); 387 assertTrue(p1.equals(p2)); 388 389 p1.getDomainAxis(1).setLabel("S1"); 390 assertFalse(p1.equals(p2)); 391 p2.getDomainAxis(1).setLabel("S1"); 392 assertTrue(p1.equals(p2)); 393 394 p1.setDomainAxisLocation(1, AxisLocation.TOP_OR_RIGHT); 395 assertFalse(p1.equals(p2)); 396 p2.setDomainAxisLocation(1, AxisLocation.TOP_OR_RIGHT); 397 assertTrue(p1.equals(p2)); 398 399 p1.mapDatasetToDomainAxis(2, 1); 400 assertFalse(p1.equals(p2)); 401 p2.mapDatasetToDomainAxis(2, 1); 402 assertTrue(p1.equals(p2)); 403 404 p1.getRangeAxis().setLabel("Label"); 405 assertFalse(p1.equals(p2)); 406 p2.getRangeAxis().setLabel("Label"); 407 assertTrue(p1.equals(p2)); 408 409 p1.getRangeAxis(1).setLabel("S1"); 410 assertFalse(p1.equals(p2)); 411 p2.getRangeAxis(1).setLabel("S1"); 412 assertTrue(p1.equals(p2)); 413 414 p1.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT); 415 assertFalse(p1.equals(p2)); 416 p2.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT); 417 assertTrue(p1.equals(p2)); 418 419 p1.mapDatasetToRangeAxis(2, 1); 420 assertFalse(p1.equals(p2)); 421 p2.mapDatasetToRangeAxis(2, 1); 422 assertTrue(p1.equals(p2)); 423 424 p1.getRenderer().setOutlinePaint(Color.cyan); 425 assertFalse(p1.equals(p2)); 426 p2.getRenderer().setOutlinePaint(Color.cyan); 427 assertTrue(p1.equals(p2)); 428 429 p1.getRenderer(1).setOutlinePaint(Color.red); 430 assertFalse(p1.equals(p2)); 431 p2.getRenderer(1).setOutlinePaint(Color.red); 432 assertTrue(p1.equals(p2)); 433 434 } 435 436 440 public void testSetNullRenderer() { 441 boolean failed = false; 442 try { 443 XYPlot plot = new XYPlot( 444 null, new NumberAxis("X"), new NumberAxis("Y"), null 445 ); 446 plot.setRenderer(null); 447 } 448 catch (Exception e) { 449 failed = true; 450 } 451 assertTrue(!failed); 452 } 453 454 457 public void testSerialization1() { 458 459 XYDataset data = new XYSeriesCollection(); 460 NumberAxis domainAxis = new NumberAxis("Domain"); 461 NumberAxis rangeAxis = new NumberAxis("Range"); 462 StandardXYItemRenderer renderer = new StandardXYItemRenderer(); 463 XYPlot p1 = new XYPlot(data, domainAxis, rangeAxis, renderer); 464 XYPlot p2 = null; 465 466 try { 467 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 468 ObjectOutput out = new ObjectOutputStream (buffer); 469 out.writeObject(p1); 470 out.close(); 471 472 ObjectInput in = new ObjectInputStream ( 473 new ByteArrayInputStream (buffer.toByteArray()) 474 ); 475 p2 = (XYPlot) in.readObject(); 476 in.close(); 477 } 478 catch (Exception e) { 479 fail(e.toString()); 480 } 481 assertEquals(p1, p2); 482 483 } 484 485 489 public void testSerialization2() { 490 491 IntervalXYDataset data1 = createDataset1(); 492 XYItemRenderer renderer1 = new XYBarRenderer(0.20); 493 renderer1.setToolTipGenerator( 494 StandardXYToolTipGenerator.getTimeSeriesInstance() 495 ); 496 XYPlot p1 = new XYPlot(data1, new DateAxis("Date"), null, renderer1); 497 XYPlot p2 = null; 498 499 try { 500 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 501 ObjectOutput out = new ObjectOutputStream (buffer); 502 out.writeObject(p1); 503 out.close(); 504 505 ObjectInput in = new ObjectInputStream ( 506 new ByteArrayInputStream (buffer.toByteArray()) 507 ); 508 p2 = (XYPlot) in.readObject(); 509 in.close(); 510 } 511 catch (Exception e) { 512 fail(e.toString()); 513 } 514 assertEquals(p1, p2); 515 516 } 517 518 528 public void testSerialization3() { 529 530 XYSeriesCollection dataset = new XYSeriesCollection(); 531 JFreeChart chart = ChartFactory.createXYLineChart( 532 "Test Chart", 533 "Domain Axis", 534 "Range Axis", 535 dataset, 536 PlotOrientation.VERTICAL, 537 true, 538 true, 539 false 540 ); 541 JFreeChart chart2 = null; 542 543 try { 545 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 546 ObjectOutput out = new ObjectOutputStream (buffer); 547 out.writeObject(chart); 548 out.close(); 549 550 ObjectInput in = new ObjectInputStream ( 551 new ByteArrayInputStream (buffer.toByteArray()) 552 ); 553 chart2 = (JFreeChart) in.readObject(); 554 in.close(); 555 } 556 catch (Exception e) { 557 fail(e.toString()); 558 } 559 560 boolean b = chart.equals(chart2); 561 System.out.println(b); 562 assertEquals(chart, chart2); 563 boolean passed = true; 564 try { 565 chart2.createBufferedImage(300, 200); 566 } 567 catch (Exception e) { 568 passed = false; 569 e.printStackTrace(); 570 } 571 assertTrue(passed); 572 } 573 574 578 public void testSerialization4() { 579 580 XYSeriesCollection dataset = new XYSeriesCollection(); 581 JFreeChart chart = ChartFactory.createXYLineChart( 582 "Test Chart", 583 "Domain Axis", 584 "Range Axis", 585 dataset, 586 PlotOrientation.VERTICAL, 587 true, 588 true, 589 false 590 ); 591 XYPlot plot = (XYPlot) chart.getPlot(); 592 plot.addDomainMarker(new ValueMarker(1.0), Layer.FOREGROUND); 593 plot.addDomainMarker(new IntervalMarker(2.0, 3.0), Layer.BACKGROUND); 594 plot.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND); 595 plot.addRangeMarker(new IntervalMarker(5.0, 6.0), Layer.BACKGROUND); 596 JFreeChart chart2 = null; 597 598 try { 600 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 601 ObjectOutput out = new ObjectOutputStream (buffer); 602 out.writeObject(chart); 603 out.close(); 604 605 ObjectInput in = new ObjectInputStream ( 606 new ByteArrayInputStream (buffer.toByteArray()) 607 ); 608 chart2 = (JFreeChart) in.readObject(); 609 in.close(); 610 } 611 catch (Exception e) { 612 fail(e.toString()); 613 } 614 615 assertEquals(chart, chart2); 616 boolean passed = true; 617 try { 618 chart2.createBufferedImage(300, 200); 619 } 620 catch (Exception e) { 621 passed = false; 622 e.printStackTrace(); 623 } 624 assertTrue(passed); 625 } 626 627 632 public void testSerialization5() { 633 XYSeriesCollection dataset1 = new XYSeriesCollection(); 634 NumberAxis domainAxis1 = new NumberAxis("Domain 1"); 635 NumberAxis rangeAxis1 = new NumberAxis("Range 1"); 636 StandardXYItemRenderer renderer1 = new StandardXYItemRenderer(); 637 XYPlot p1 = new XYPlot(dataset1, domainAxis1, rangeAxis1, renderer1); 638 NumberAxis domainAxis2 = new NumberAxis("Domain 2"); 639 NumberAxis rangeAxis2 = new NumberAxis("Range 2"); 640 StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); 641 XYSeriesCollection dataset2 = new XYSeriesCollection(); 642 p1.setDataset(1, dataset2); 643 p1.setDomainAxis(1, domainAxis2); 644 p1.setRangeAxis(1, rangeAxis2); 645 p1.setRenderer(1, renderer2); 646 XYPlot p2 = null; 647 try { 648 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 649 ObjectOutput out = new ObjectOutputStream (buffer); 650 out.writeObject(p1); 651 out.close(); 652 ObjectInput in = new ObjectInputStream ( 653 new ByteArrayInputStream (buffer.toByteArray()) 654 ); 655 p2 = (XYPlot) in.readObject(); 656 in.close(); 657 } 658 catch (Exception e) { 659 fail(e.toString()); 660 } 661 assertEquals(p1, p2); 662 663 NumberAxis domainAxisA = (NumberAxis) p2.getDomainAxis(0); 666 NumberAxis rangeAxisA = (NumberAxis) p2.getRangeAxis(0); 667 XYSeriesCollection datasetA = (XYSeriesCollection) p2.getDataset(0); 668 StandardXYItemRenderer rendererA 669 = (StandardXYItemRenderer) p2.getRenderer(0); 670 NumberAxis domainAxisB = (NumberAxis) p2.getDomainAxis(1); 671 NumberAxis rangeAxisB = (NumberAxis) p2.getRangeAxis(1); 672 XYSeriesCollection datasetB = (XYSeriesCollection) p2.getDataset(1); 673 StandardXYItemRenderer rendererB 674 = (StandardXYItemRenderer) p2.getRenderer(1); 675 assertTrue(datasetA.hasListener(p2)); 676 assertTrue(domainAxisA.hasListener(p2)); 677 assertTrue(rangeAxisA.hasListener(p2)); 678 assertTrue(rendererA.hasListener(p2)); 679 assertTrue(datasetB.hasListener(p2)); 680 assertTrue(domainAxisB.hasListener(p2)); 681 assertTrue(rangeAxisB.hasListener(p2)); 682 assertTrue(rendererB.hasListener(p2)); 683 } 684 685 688 public void testGetRendererForDataset() { 689 XYDataset d0 = new XYSeriesCollection(); 690 XYDataset d1 = new XYSeriesCollection(); 691 XYDataset d2 = new XYSeriesCollection(); 692 XYDataset d3 = new XYSeriesCollection(); XYItemRenderer r0 = new XYLineAndShapeRenderer(); 694 XYItemRenderer r2 = new XYLineAndShapeRenderer(); 695 XYPlot plot = new XYPlot(); 696 plot.setDataset(0, d0); 697 plot.setDataset(1, d1); 698 plot.setDataset(2, d2); 699 plot.setRenderer(0, r0); 700 plot.setRenderer(2, r2); 702 assertEquals(r0, plot.getRendererForDataset(d0)); 703 assertEquals(r0, plot.getRendererForDataset(d1)); 704 assertEquals(r2, plot.getRendererForDataset(d2)); 705 assertEquals(null, plot.getRendererForDataset(d3)); 706 assertEquals(null, plot.getRendererForDataset(null)); 707 } 708 709 712 public void testGetLegendItems() { 713 XYDataset d0 = createDataset1(); 716 XYDataset d1 = createDataset2(); 717 XYItemRenderer r0 = new XYLineAndShapeRenderer(); 718 XYPlot plot = new XYPlot(); 719 plot.setDataset(0, d0); 720 plot.setDataset(1, d1); 721 plot.setRenderer(0, r0); 722 LegendItemCollection items = plot.getLegendItems(); 723 assertEquals(2, items.getItemCount()); 724 } 725 726 731 private IntervalXYDataset createDataset1() { 732 733 TimeSeries series1 = new TimeSeries("Series 1", Day.class); 735 series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); 736 series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); 737 series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); 738 series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); 739 series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); 740 series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); 741 series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); 742 series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); 743 series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); 744 series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); 745 series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); 746 series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); 747 series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); 748 series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); 749 series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); 750 751 TimeSeriesCollection collection = new TimeSeriesCollection(series1); 752 collection.setDomainIsPointsInTime(false); 753 return collection; 759 760 } 761 762 767 private XYDataset createDataset2() { 768 XYSeries series = new XYSeries("Series 2"); 770 XYSeriesCollection collection = new XYSeriesCollection(series); 771 return collection; 772 773 } 774 775 779 public void testSetRenderer() { 780 XYPlot plot = new XYPlot(); 781 XYItemRenderer renderer = new XYLineAndShapeRenderer(); 782 plot.setRenderer(renderer); 783 MyPlotChangeListener listener = new MyPlotChangeListener(); 786 plot.addChangeListener(listener); 787 renderer.setSeriesPaint(0, Color.black); 788 assertTrue(listener.getEvent() != null); 789 } 790 791 } 792 | Popular Tags |