212-1-2

Block block = (Block) blocks.get(i); Size2D size = block.arrange(g2, RectangleConstraint.NONE); if (y + size.height <= height) { itemsInColumn.add(block); block.setBounds( new Rectangle2D.Double(x, y, size.width, size.height) ); y = y + size.height + this.verticalGap; maxWidth = Math.max(maxWidth, size.width); } else { if (itemsInColumn.isEmpty()) { // place in this column (truncated) anyway block.setBounds( new Rectangle2D.Double( x, y, size.width, Math.min(size.height, height - y) ) ); y = 0.0; x = x + size.width + this.horizontalGap; } else { // start new column itemsInColumn.clear(); x = x + maxWidth + this.horizontalGap; y = 0.0; maxWidth = size.width; block.setBounds( new Rectangle2D.Double( x, y, size.width, Math.min(size.height, height) ) ); y = size.height + this.verticalGap; itemsInColumn.add(block); } }
Block block = (Block) blocks.get(i); Size2D size = block.arrange(g2, RectangleConstraint.NONE); if (x + size.width <= width) { itemsInRow.add(block); block.setBounds( new Rectangle2D.Double(x, y, size.width, size.height) ); x = x + size.width + this.horizontalGap; maxHeight = Math.max(maxHeight, size.height); } else { if (itemsInRow.isEmpty()) { // place in this row (truncated) anyway block.setBounds( new Rectangle2D.Double( x, y, Math.min(size.width, width - x), size.height ) ); x = 0.0; y = y + size.height + this.verticalGap; } else { // start new row itemsInRow.clear(); x = 0.0; y = y + maxHeight + this.verticalGap; maxHeight = size.height; block.setBounds( new Rectangle2D.Double( x, y, Math.min(size.width, width), size.height ) ); x = size.width + this.horizontalGap; itemsInRow.add(block); } }

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/block/ColumnArrangement.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/block/FlowArrangement.java
Method name: `Size2D arrangeNF(BlockContainer, Graphics2D, RectangleConstraint)` |  | Method name: `Size2D arrangeFN(BlockContainer, Graphics2D, RectangleConstraint)`
Number of AST nodes: 18 |  | Number of AST nodes: 18

1

    Block block = (Block) blocks.get(i);↵

1

    Block block = (Block) blocks.get(i);↵

2

                Size2D size = block.arrange(g2, RectangleConstraint.NONE);↵

2

                Size2D size = block.arrange(g2, RectangleConstraint.NONE);↵

3

                if (y + size.height <= height) {↵

3

                if (x + size.width <= width) {↵

4

                    itemsInColumn.add(block);↵

4

                    itemsInRow.add(block);↵

5

                    block.setBounds(↵

5

                    block.setBounds(↵

6

                        new Rectangle2D.Double(x, y, size.width, size.height)↵

6

                        new Rectangle2D.Double(x, y, size.width, size.height)↵

7

                    );↵

7

                    );↵

8

                    y = y + size.height + this.verticalGap;↵

8

                    x = x + size.width + this.horizontalGap;↵

9

                    maxWidth = Math.max(maxWidth, size.width);↵

9

                    maxHeight = Math.max(maxHeight, size.height);↵

10

                }↵

10

                }↵

11

                else {↵

11

                else {↵

12

                    if (itemsInColumn.isEmpty()) {↵

12

                    if (itemsInRow.isEmpty()) {↵

13

                        // place in this column (truncated) anyway↵

13

                        // place in this row (truncated) anyway↵

14

                        block.setBounds(↵

14

                        block.setBounds(↵

15

                            new Rectangle2D.Double(↵

15

                            new Rectangle2D.Double(↵

16

                                x, y, size.width, Math.min(size.height, height - y)↵

16

                                x, y, Math.min(size.width, width - x), size.height↵

17

                            )↵

17

                            )↵

18

                        );↵

18

                        );↵

19

                        y = 0.0;↵

19

                        x = 0.0;↵

20

                        x = x + size.width + this.horizontalGap;↵

20

                        y = y + size.height + this.verticalGap;↵

21

                    }↵

21

                    }↵

22

                    else {↵

22

                    else {↵

23

                        // start new column↵

23

                        // start new row↵

24

                        itemsInColumn.clear();↵

24

                        itemsInRow.clear();↵

25

                        x = x + maxWidth + this.horizontalGap;↵

25

                        x = ↵

26

                        y = 0.0↵

26

    0.0;↵

27

    ;↵

27

                        y = y + maxHeight + this.verticalGap;↵

28

                        maxWidth = size.width;↵

28

                        maxHeight = size.height;↵

29

                        block.setBounds(↵

29

                        block.setBounds(↵

30

                            new Rectangle2D.Double(↵

30

                            new Rectangle2D.Double(↵

31

                                x, y, size.width, Math.min(size.height, height)↵

31

                                x, y, Math.min(size.width, width), size.height↵

32

                            )↵

32

                            )↵

33

                        );↵

33

                        );↵

34

                        y = size.height + this.verticalGap;↵

34

                        x = size.width + this.horizontalGap;↵

35

                        itemsInColumn.add(block);↵

35

                        itemsInRow.add(block);↵

36

                    }↵

36

                    }↵

37

                }

37

                }

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.4
Clones location | Clones are in different classes
Number of node comparisons | 151

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 18
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 72.6
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   10

       Block block = (Block)blocks.get(i);

   8

       Block block = (Block)blocks.get(i);

   11

       Size2D size = block.arrange(g2, RectangleConstraint.NONE);

   9

       Size2D size = block.arrange(g2, RectangleConstraint.NONE);

   12

       if (y + size.height <= height)

   12 | if (y + size.height <= height)
   10 | if (x + size.width <= width)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   y | x | VARIABLE_NAME_MISMATCH
   height | width | VARIABLE_NAME_MISMATCH
   height | width | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted

   10

       if (x + size.width <= width)

   13

       itemsInColumn.add(block);

   13 | itemsInColumn.add(block);
   11 | itemsInRow.add(block);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   itemsInColumn | itemsInRow | VARIABLE_NAME_MISMATCH

   11

       itemsInRow.add(block);

   14

       block.setBounds(new Rectangle2D.Double(x, y, size.width, size.height));

   12

       block.setBounds(new Rectangle2D.Double(x, y, size.width, size.height));

   15

       y = y + size.height + this.verticalGap;

   15 | y = y + size.height + this.verticalGap;
   13 | x = x + size.width + this.horizontalGap;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   y | x | VARIABLE_NAME_MISMATCH
   verticalGap | horizontalGap | VARIABLE_NAME_MISMATCH
   y | x | VARIABLE_NAME_MISMATCH
   height | width | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted

   13

       x = x + size.width + this.horizontalGap;

   16

       maxWidth = Math.max(maxWidth, size.width);

   16 | maxWidth = Math.max(maxWidth, size.width);
   14 | maxHeight = Math.max(maxHeight, size.height);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   maxWidth | maxHeight | VARIABLE_NAME_MISMATCH
   maxWidth | maxHeight | VARIABLE_NAME_MISMATCH
   width | height | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted

   14

       maxHeight = Math.max(maxHeight, size.height);

       else

       else

   17

       if (itemsInColumn.isEmpty())

   17 | if (itemsInColumn.isEmpty())
   15 | if (itemsInRow.isEmpty())

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   itemsInColumn | itemsInRow | VARIABLE_NAME_MISMATCH

   15

       if (itemsInRow.isEmpty())

   18

       block.setBounds(new Rectangle2D.Double(x, y, size.width, Math.min(size.height, height - y)));

   18 | block.setBounds(new Rectangle2D.Double(x, y, size.width, Math.min(size.height, height - y)));
   16 | block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width - x), size.height));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   size.width | Math.min(size.width,width - x) | TYPE_COMPATIBLE_REPLACEMENT
   Math.min(size.height,height - y) | size.height | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression Math.min(size.width,width - x) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression Math.min(size.height,height - y) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted

   16

       block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width - x), size.height));

   19

       y = 0.0;

   19 | y = 0.0;
   18 | y = y + size.height + this.verticalGap;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   0.0 | y + size.height + this.verticalGap | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression y + size.height + this.verticalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted

   18

       y = y + size.height + this.verticalGap;

   20

       x = x + size.width + this.horizontalGap;

   20 | x = x + size.width + this.horizontalGap;
   17 | x = 0.0;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   x + size.width + this.horizontalGap | 0.0 | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression x + size.width + this.horizontalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted

   17

       x = 0.0;

       else

       else

   21

       itemsInColumn.clear();

   21 | itemsInColumn.clear();
   19 | itemsInRow.clear();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   itemsInColumn | itemsInRow | VARIABLE_NAME_MISMATCH

   19

       itemsInRow.clear();

   22

       x = x + maxWidth + this.horizontalGap;

   22 | x = x + maxWidth + this.horizontalGap;
   20 | x = 0.0;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   x + maxWidth + this.horizontalGap | 0.0 | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression x + maxWidth + this.horizontalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted

   20

       x = 0.0;

   23

       y = 0.0;

   23 | y = 0.0;
   21 | y = y + maxHeight + this.verticalGap;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   0.0 | y + maxHeight + this.verticalGap | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression y + maxHeight + this.verticalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted

   21

       y = y + maxHeight + this.verticalGap;

   24

       maxWidth = size.width;

   24 | maxWidth = size.width;
   24 | x = size.width + this.horizontalGap;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   maxWidth | x | VARIABLE_NAME_MISMATCH
   size.width | size.width + this.horizontalGap | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression size.width + this.horizontalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted

   24

       x = size.width + this.horizontalGap;

   25

       block.setBounds(new Rectangle2D.Double(x, y, size.width, Math.min(size.height, height)));

   25 | block.setBounds(new Rectangle2D.Double(x, y, size.width, Math.min(size.height, height)));
   23 | block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width), size.height));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   size.width | Math.min(size.width,width) | TYPE_COMPATIBLE_REPLACEMENT
   Math.min(size.height,height) | size.height | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression Math.min(size.width,width) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression Math.min(size.height,height) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted

   23

       block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width), size.height));

   26

       y = size.height + this.verticalGap;

   26 | y = size.height + this.verticalGap;
   22 | maxHeight = size.height;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   y | maxHeight | VARIABLE_NAME_MISMATCH
   size.height + this.verticalGap | size.height | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression size.height + this.verticalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted

   22

       maxHeight = size.height;

   27

       itemsInColumn.add(block);

   27 | itemsInColumn.add(block);
   25 | itemsInRow.add(block);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   itemsInColumn | itemsInRow | VARIABLE_NAME_MISMATCH

   25

       itemsInRow.add(block);

   Precondition Violations (23)
   Row | Violation
   --- | ---
   1 | Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
   8 | Expression Math.min(size.width,width - x) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   9 | Expression Math.min(size.height,height - y) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   10 | Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
   11 | Expression y + size.height + this.verticalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
   12 | Expression x + size.width + this.horizontalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
   13 | Expression x + maxWidth + this.horizontalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
   14 | Expression y + maxHeight + this.verticalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
   15 | Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
   16 | Expression size.width + this.horizontalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
   17 | Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
   18 | Expression Math.min(size.width,width) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   19 | Expression Math.min(size.height,height) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   20 | Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
   21 | Expression size.height + this.verticalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
   22 | Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
   23 | Clone fragment #1 returns variables maxWidth, x, y , while Clone fragment #2 returns variables maxHeight, y, x