1 42 43 package org.jfree.chart.block.junit; 44 45 import java.awt.Graphics2D ; 46 import java.awt.image.BufferedImage ; 47 import java.io.ByteArrayInputStream ; 48 import java.io.ByteArrayOutputStream ; 49 import java.io.ObjectInput ; 50 import java.io.ObjectInputStream ; 51 import java.io.ObjectOutput ; 52 import java.io.ObjectOutputStream ; 53 54 import junit.framework.Test; 55 import junit.framework.TestCase; 56 import junit.framework.TestSuite; 57 58 import org.jfree.chart.block.Block; 59 import org.jfree.chart.block.BlockContainer; 60 import org.jfree.chart.block.BorderArrangement; 61 import org.jfree.chart.block.EmptyBlock; 62 import org.jfree.chart.block.LengthConstraintType; 63 import org.jfree.chart.block.RectangleConstraint; 64 import org.jfree.data.Range; 65 import org.jfree.ui.RectangleEdge; 66 import org.jfree.ui.Size2D; 67 68 71 public class BorderArrangementTests extends TestCase { 72 73 private static final double EPSILON = 0.0000000001; 74 75 80 public static Test suite() { 81 return new TestSuite(BorderArrangementTests.class); 82 } 83 84 89 public BorderArrangementTests(String name) { 90 super(name); 91 } 92 93 96 public void testEquals() { 97 BorderArrangement b1 = new BorderArrangement(); 98 BorderArrangement b2 = new BorderArrangement(); 99 assertTrue(b1.equals(b2)); 100 assertTrue(b2.equals(b1)); 101 102 b1.add(new EmptyBlock(99.0, 99.0), null); 103 assertFalse(b1.equals(b2)); 104 b2.add(new EmptyBlock(99.0, 99.0), null); 105 assertTrue(b1.equals(b2)); 106 107 b1.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT); 108 assertFalse(b1.equals(b2)); 109 b2.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT); 110 assertTrue(b1.equals(b2)); 111 112 b1.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT); 113 assertFalse(b1.equals(b2)); 114 b2.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT); 115 assertTrue(b1.equals(b2)); 116 117 b1.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP); 118 assertFalse(b1.equals(b2)); 119 b2.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP); 120 assertTrue(b1.equals(b2)); 121 122 b1.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM); 123 assertFalse(b1.equals(b2)); 124 b2.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM); 125 assertTrue(b1.equals(b2)); 126 } 127 128 131 public void testCloning() { 132 BorderArrangement b1 = new BorderArrangement(); 133 assertFalse(b1 instanceof Cloneable ); 134 } 135 136 139 public void testSerialization() { 140 BorderArrangement b1 = new BorderArrangement(); 141 BorderArrangement b2 = null; 142 try { 143 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 144 ObjectOutput out = new ObjectOutputStream (buffer); 145 out.writeObject(b1); 146 out.close(); 147 148 ObjectInput in = new ObjectInputStream ( 149 new ByteArrayInputStream (buffer.toByteArray()) 150 ); 151 b2 = (BorderArrangement) in.readObject(); 152 in.close(); 153 } 154 catch (Exception e) { 155 fail(e.toString()); 156 } 157 assertEquals(b1, b2); 158 } 159 160 163 public void testSizing() { 164 BlockContainer container = new BlockContainer(new BorderArrangement()); 165 BufferedImage image = new BufferedImage ( 166 200, 100, BufferedImage.TYPE_INT_RGB 167 ); 168 Graphics2D g2 = image.createGraphics(); 169 170 Size2D size = container.arrange(g2); 173 assertEquals(0.0, size.width, EPSILON); 174 assertEquals(0.0, size.height, EPSILON); 175 176 container.add(new EmptyBlock(123.4, 567.8)); 179 size = container.arrange(g2); 180 assertEquals(123.4, size.width, EPSILON); 181 assertEquals(567.8, size.height, EPSILON); 182 183 container.clear(); 186 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); 187 size = container.arrange(g2); 188 assertEquals(12.3, size.width, EPSILON); 189 assertEquals(45.6, size.height, EPSILON); 190 191 container.clear(); 194 container.add(new EmptyBlock(10.0, 20.0)); 195 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); 196 size = container.arrange(g2); 197 assertEquals(22.3, size.width, EPSILON); 198 assertEquals(45.6, size.height, EPSILON); 199 200 container.clear(); 202 Block rb = new EmptyBlock(12.3, 15.6); 203 container.add(new EmptyBlock(10.0, 20.0)); 204 container.add(rb, RectangleEdge.RIGHT); 205 size = container.arrange(g2); 206 assertEquals(22.3, size.width, EPSILON); 207 assertEquals(20.0, size.height, EPSILON); 208 assertEquals(20.0, rb.getBounds().getHeight(), EPSILON); 209 210 container.clear(); 213 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 214 size = container.arrange(g2); 215 assertEquals(12.3, size.width, EPSILON); 216 assertEquals(45.6, size.height, EPSILON); 217 218 container.clear(); 221 container.add(new EmptyBlock(10.0, 20.0)); 222 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 223 size = container.arrange(g2); 224 assertEquals(22.3, size.width, EPSILON); 225 assertEquals(45.6, size.height, EPSILON); 226 227 container.clear(); 229 Block lb = new EmptyBlock(12.3, 15.6); 230 container.add(new EmptyBlock(10.0, 20.0)); 231 container.add(lb, RectangleEdge.LEFT); 232 size = container.arrange(g2); 233 assertEquals(22.3, size.width, EPSILON); 234 assertEquals(20.0, size.height, EPSILON); 235 assertEquals(20.0, lb.getBounds().getHeight(), EPSILON); 236 237 container.clear(); 240 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); 241 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 242 size = container.arrange(g2); 243 assertEquals(22.3, size.width, EPSILON); 244 assertEquals(45.6, size.height, EPSILON); 245 246 container.clear(); 249 container.add(new EmptyBlock(10.0, 20.0)); 250 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 251 container.add(new EmptyBlock(5.4, 3.2), RectangleEdge.RIGHT); 252 size = container.arrange(g2); 253 assertEquals(27.7, size.width, EPSILON); 254 assertEquals(45.6, size.height, EPSILON); 255 256 container.clear(); 259 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 260 size = container.arrange(g2); 261 assertEquals(12.3, size.width, EPSILON); 262 assertEquals(45.6, size.height, EPSILON); 263 264 container.clear(); 267 container.add(new EmptyBlock(10.0, 20.0)); 268 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 269 size = container.arrange(g2); 270 assertEquals(12.3, size.width, EPSILON); 271 assertEquals(65.6, size.height, EPSILON); 272 273 container.clear(); 276 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); 277 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 278 size = container.arrange(g2); 279 assertEquals(12.3, size.width, EPSILON); 280 assertEquals(65.6, size.height, EPSILON); 281 282 container.clear(); 285 container.add(new EmptyBlock(21.0, 12.3)); 286 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); 287 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 288 size = container.arrange(g2); 289 assertEquals(31.0, size.width, EPSILON); 290 assertEquals(65.6, size.height, EPSILON); 291 292 container.clear(); 295 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); 296 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 297 size = container.arrange(g2); 298 assertEquals(12.3, size.width, EPSILON); 299 assertEquals(65.6, size.height, EPSILON); 300 301 container.clear(); 304 container.add(new EmptyBlock(21.0, 12.3)); 305 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); 306 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 307 size = container.arrange(g2); 308 assertEquals(31.0, size.width, EPSILON); 309 assertEquals(65.6, size.height, EPSILON); 310 311 container.clear(); 314 container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); 315 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); 316 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 317 size = container.arrange(g2); 318 assertEquals(31.0, size.width, EPSILON); 319 assertEquals(65.6, size.height, EPSILON); 320 321 container.clear(); 324 container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); 325 container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); 326 container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); 327 container.add(new EmptyBlock(9.0, 10.0)); 328 size = container.arrange(g2); 329 assertEquals(21.0, size.width, EPSILON); 330 assertEquals(14.0, size.height, EPSILON); 331 332 container.clear(); 335 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); 336 size = container.arrange(g2); 337 assertEquals(12.3, size.width, EPSILON); 338 assertEquals(45.6, size.height, EPSILON); 339 340 container.clear(); 343 container.add(new EmptyBlock(10.0, 20.0)); 344 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); 345 size = container.arrange(g2); 346 assertEquals(12.3, size.width, EPSILON); 347 assertEquals(65.6, size.height, EPSILON); 348 349 container.clear(); 352 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); 353 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); 354 size = container.arrange(g2); 355 assertEquals(12.3, size.width, EPSILON); 356 assertEquals(65.6, size.height, EPSILON); 357 358 container.clear(); 361 container.add(new EmptyBlock(21.0, 12.3)); 362 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 363 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); 364 size = container.arrange(g2); 365 assertEquals(33.3, size.width, EPSILON); 366 assertEquals(65.6, size.height, EPSILON); 367 368 container.clear(); 371 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); 372 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); 373 size = container.arrange(g2); 374 assertEquals(12.3, size.width, EPSILON); 375 assertEquals(65.6, size.height, EPSILON); 376 377 container.clear(); 380 container.add(new EmptyBlock(21.0, 12.3)); 381 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 382 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 383 size = container.arrange(g2); 384 assertEquals(33.3, size.width, EPSILON); 385 assertEquals(65.6, size.height, EPSILON); 386 387 container.clear(); 390 container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); 391 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 392 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 393 size = container.arrange(g2); 394 assertEquals(33.3, size.width, EPSILON); 395 assertEquals(65.6, size.height, EPSILON); 396 397 container.clear(); 400 container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); 401 container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); 402 container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); 403 container.add(new EmptyBlock(9.0, 10.0)); 404 size = container.arrange(g2); 405 assertEquals(21.0, size.width, EPSILON); 406 assertEquals(12.0, size.height, EPSILON); 407 408 container.clear(); 411 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 412 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 413 size = container.arrange(g2); 414 assertEquals(12.3, size.width, EPSILON); 415 assertEquals(65.6, size.height, EPSILON); 416 417 container.clear(); 420 container.add(new EmptyBlock(21.0, 12.3)); 421 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 422 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 423 size = container.arrange(g2); 424 assertEquals(21.0, size.width, EPSILON); 425 assertEquals(77.9, size.height, EPSILON); 426 427 container.clear(); 430 container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); 431 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 432 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 433 size = container.arrange(g2); 434 assertEquals(21.0, size.width, EPSILON); 435 assertEquals(77.9, size.height, EPSILON); 436 437 container.clear(); 440 container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); 441 container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); 442 container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); 443 container.add(new EmptyBlock(9.0, 10.0)); 444 size = container.arrange(g2); 445 assertEquals(16.0, size.width, EPSILON); 446 assertEquals(16.0, size.height, EPSILON); 447 448 container.clear(); 451 container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.LEFT); 452 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 453 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 454 size = container.arrange(g2); 455 assertEquals(21.0, size.width, EPSILON); 456 assertEquals(77.9, size.height, EPSILON); 457 458 container.clear(); 461 container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); 462 container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); 463 container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); 464 container.add(new EmptyBlock(9.0, 10.0)); 465 size = container.arrange(g2); 466 assertEquals(14.0, size.width, EPSILON); 467 assertEquals(16.0, size.height, EPSILON); 468 469 container.clear(); 472 container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); 473 container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); 474 container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); 475 container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); 476 size = container.arrange(g2); 477 assertEquals(12.0, size.width, EPSILON); 478 assertEquals(14.0, size.height, EPSILON); 479 480 container.clear(); 483 container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); 484 container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); 485 container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); 486 container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); 487 container.add(new EmptyBlock(9.0, 10.0)); 488 size = container.arrange(g2); 489 assertEquals(21.0, size.width, EPSILON); 490 assertEquals(16.0, size.height, EPSILON); 491 492 } 493 494 497 public void testSizingWithWidthConstraint() { 498 RectangleConstraint constraint = new RectangleConstraint( 499 10.0, new Range(10.0, 10.0), LengthConstraintType.FIXED, 500 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE 501 ); 502 503 BlockContainer container = new BlockContainer(new BorderArrangement()); 504 BufferedImage image = new BufferedImage ( 505 200, 100, BufferedImage.TYPE_INT_RGB 506 ); 507 Graphics2D g2 = image.createGraphics(); 508 509 container.add(new EmptyBlock(5.0, 6.0)); 512 Size2D size = container.arrange(g2, constraint); 513 assertEquals(10.0, size.width, EPSILON); 514 assertEquals(6.0, size.height, EPSILON); 515 516 container.clear(); 517 container.add(new EmptyBlock(15.0, 16.0)); 518 size = container.arrange(g2, constraint); 519 assertEquals(10.0, size.width, EPSILON); 520 assertEquals(16.0, size.height, EPSILON); 521 522 container.clear(); 525 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); 526 size = container.arrange(g2, constraint); 527 assertEquals(10.0, size.width, EPSILON); 528 assertEquals(45.6, size.height, EPSILON); 529 530 container.clear(); 533 container.add(new EmptyBlock(7.0, 20.0)); 534 container.add(new EmptyBlock(8.0, 45.6), RectangleEdge.RIGHT); 535 size = container.arrange(g2, constraint); 536 assertEquals(10.0, size.width, EPSILON); 537 assertEquals(45.6, size.height, EPSILON); 538 539 container.clear(); 542 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 543 size = container.arrange(g2, constraint); 544 assertEquals(10.0, size.width, EPSILON); 545 assertEquals(45.6, size.height, EPSILON); 546 547 container.clear(); 550 container.add(new EmptyBlock(10.0, 20.0)); 551 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 552 size = container.arrange(g2, constraint); 553 assertEquals(10.0, size.width, EPSILON); 554 assertEquals(45.6, size.height, EPSILON); 555 556 container.clear(); 559 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); 560 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 561 size = container.arrange(g2, constraint); 562 assertEquals(10.0, size.width, EPSILON); 563 assertEquals(45.6, size.height, EPSILON); 564 565 container.clear(); 568 container.add(new EmptyBlock(10.0, 20.0)); 569 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 570 container.add(new EmptyBlock(5.4, 3.2), RectangleEdge.RIGHT); 571 size = container.arrange(g2, constraint); 572 assertEquals(10.0, size.width, EPSILON); 573 assertEquals(45.6, size.height, EPSILON); 574 575 container.clear(); 578 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 579 size = container.arrange(g2, constraint); 580 assertEquals(10.0, size.width, EPSILON); 581 assertEquals(45.6, size.height, EPSILON); 582 583 container.clear(); 586 container.add(new EmptyBlock(10.0, 20.0)); 587 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 588 size = container.arrange(g2, constraint); 589 assertEquals(10.0, size.width, EPSILON); 590 assertEquals(65.6, size.height, EPSILON); 591 592 container.clear(); 595 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); 596 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 597 size = container.arrange(g2, constraint); 598 assertEquals(10.0, size.width, EPSILON); 599 assertEquals(65.6, size.height, EPSILON); 600 601 container.clear(); 604 container.add(new EmptyBlock(21.0, 12.3)); 605 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); 606 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 607 size = container.arrange(g2, constraint); 608 assertEquals(10.0, size.width, EPSILON); 609 assertEquals(65.6, size.height, EPSILON); 610 611 container.clear(); 614 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); 615 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 616 size = container.arrange(g2, constraint); 617 assertEquals(10.0, size.width, EPSILON); 618 assertEquals(65.6, size.height, EPSILON); 619 620 container.clear(); 623 container.add(new EmptyBlock(21.0, 12.3)); 624 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); 625 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 626 size = container.arrange(g2, constraint); 627 assertEquals(10.0, size.width, EPSILON); 628 assertEquals(65.6, size.height, EPSILON); 629 630 container.clear(); 633 container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); 634 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); 635 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 636 size = container.arrange(g2, constraint); 637 assertEquals(10.0, size.width, EPSILON); 638 assertEquals(65.6, size.height, EPSILON); 639 640 container.clear(); 643 container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); 644 container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); 645 container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); 646 container.add(new EmptyBlock(9.0, 10.0)); 647 size = container.arrange(g2, constraint); 648 assertEquals(10.0, size.width, EPSILON); 649 assertEquals(14.0, size.height, EPSILON); 650 651 container.clear(); 654 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); 655 size = container.arrange(g2, constraint); 656 assertEquals(10.0, size.width, EPSILON); 657 assertEquals(45.6, size.height, EPSILON); 658 659 container.clear(); 662 container.add(new EmptyBlock(10.0, 20.0)); 663 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); 664 size = container.arrange(g2, constraint); 665 assertEquals(10.0, size.width, EPSILON); 666 assertEquals(65.6, size.height, EPSILON); 667 668 container.clear(); 671 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); 672 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); 673 size = container.arrange(g2, constraint); 674 assertEquals(10.0, size.width, EPSILON); 675 assertEquals(65.6, size.height, EPSILON); 676 677 container.clear(); 680 container.add(new EmptyBlock(21.0, 12.3)); 681 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 682 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); 683 size = container.arrange(g2, constraint); 684 assertEquals(10.0, size.width, EPSILON); 685 assertEquals(65.6, size.height, EPSILON); 686 687 container.clear(); 690 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); 691 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); 692 size = container.arrange(g2, constraint); 693 assertEquals(10.0, size.width, EPSILON); 694 assertEquals(65.6, size.height, EPSILON); 695 696 container.clear(); 699 container.add(new EmptyBlock(21.0, 12.3)); 700 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 701 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 702 size = container.arrange(g2, constraint); 703 assertEquals(10.0, size.width, EPSILON); 704 assertEquals(65.6, size.height, EPSILON); 705 706 container.clear(); 709 container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); 710 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 711 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); 712 size = container.arrange(g2, constraint); 713 assertEquals(10.0, size.width, EPSILON); 714 assertEquals(65.6, size.height, EPSILON); 715 716 container.clear(); 719 container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); 720 container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); 721 container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); 722 container.add(new EmptyBlock(9.0, 10.0)); 723 size = container.arrange(g2, constraint); 724 assertEquals(10.0, size.width, EPSILON); 725 assertEquals(12.0, size.height, EPSILON); 726 727 container.clear(); 730 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 731 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 732 size = container.arrange(g2, constraint); 733 assertEquals(10.0, size.width, EPSILON); 734 assertEquals(65.6, size.height, EPSILON); 735 736 container.clear(); 739 container.add(new EmptyBlock(21.0, 12.3)); 740 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 741 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 742 size = container.arrange(g2, constraint); 743 assertEquals(10.0, size.width, EPSILON); 744 assertEquals(77.9, size.height, EPSILON); 745 746 container.clear(); 749 container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); 750 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 751 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 752 size = container.arrange(g2, constraint); 753 assertEquals(10.0, size.width, EPSILON); 754 assertEquals(77.9, size.height, EPSILON); 755 756 container.clear(); 759 container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); 760 container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); 761 container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); 762 container.add(new EmptyBlock(9.0, 10.0)); 763 size = container.arrange(g2, constraint); 764 assertEquals(10.0, size.width, EPSILON); 765 assertEquals(16.0, size.height, EPSILON); 766 767 container.clear(); 770 container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.LEFT); 771 container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); 772 container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); 773 size = container.arrange(g2, constraint); 774 assertEquals(10.0, size.width, EPSILON); 775 assertEquals(77.9, size.height, EPSILON); 776 777 container.clear(); 780 container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); 781 container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); 782 container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); 783 container.add(new EmptyBlock(9.0, 10.0)); 784 size = container.arrange(g2, constraint); 785 assertEquals(10.0, size.width, EPSILON); 786 assertEquals(16.0, size.height, EPSILON); 787 788 container.clear(); 791 container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); 792 container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); 793 container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); 794 container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); 795 size = container.arrange(g2, constraint); 796 assertEquals(10.0, size.width, EPSILON); 797 assertEquals(14.0, size.height, EPSILON); 798 799 container.clear(); 802 container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); 803 container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); 804 container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); 805 container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); 806 container.add(new EmptyBlock(9.0, 10.0)); 807 size = container.arrange(g2, constraint); 808 assertEquals(10.0, size.width, EPSILON); 809 assertEquals(16.0, size.height, EPSILON); 810 811 container.clear(); 814 size = container.arrange(g2, constraint); 815 assertEquals(10.0, size.width, EPSILON); 816 assertEquals(0.0, size.height, EPSILON); 817 818 } 819 } 820 821 | Popular Tags |