251-1-2

double tickLabelWidth = estimateMaximumTickLabelWidth( g2, getTickUnit() ); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double unit1Width = lengthToJava2D(unit1.getSize(), dataArea, edge); // then extrapolate... double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit(guess); double unit2Width = lengthToJava2D(unit2.getSize(), dataArea, edge); tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2); if (tickLabelWidth > unit2Width) { unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, false, false);
double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit()); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double unit1Width = exponentLengthToJava2D(unit1.getSize(), dataArea, edge); // then extrapolate... double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit(guess); double unit2Width = exponentLengthToJava2D(unit2.getSize(), dataArea, edge); tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2); if (tickLabelWidth > unit2Width) { unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, false, false);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/axis/NumberAxis.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/axis/LogAxis.java
Method name: `void selectHorizontalAutoTickUnit(Graphics2D, Rectangle2D, RectangleEdge)` |  | Method name: `void selectHorizontalAutoTickUnit(Graphics2D, Rectangle2D, RectangleEdge)`
Number of AST nodes: 11 |  | Number of AST nodes: 11

1

    double tickLabelWidth = estimateMaximumTickLabelWidth(↵

1

    double tickLabelWidth = estimateMaximumTickLabelWidth(g2, ↵

2

                g2, getTickUnit()↵

2

                    getTickUnit()↵

3

            );↵

3

    );↵

4

            // start with the current tick unit...↵

4

            // start with the current tick unit...↵

5

            TickUnitSource tickUnits = getStandardTickUnits();↵

5

            TickUnitSource tickUnits = getStandardTickUnits();↵

6

            TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit());↵

6

            TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit());↵

7

            double unit1Width = lengthToJava2D(unit1.getSize(), dataArea, ↵

7

            double unit1Width = exponentLengthToJava2D(unit1.getSize(), dataArea, ↵

8

    edge);↵

8

                    edge);↵

9

            // then extrapolate...↵

9

            // then extrapolate...↵

10

            double guess = (tickLabelWidth / unit1Width) * unit1.getSize();↵

10

            double guess = (tickLabelWidth / unit1Width) * unit1.getSize();↵

11

            NumberTickUnit unit2↵

11

            NumberTickUnit unit2↵

12

                = (NumberTickUnit) ↵

12

     = (NumberTickUnit) ↵

13

    tickUnits.getCeilingTickUnit(guess);↵

13

                    tickUnits.getCeilingTickUnit(guess);↵

14

            double unit2Width = lengthToJava2D(unit2.getSize(), dataArea, ↵

14

            double unit2Width = exponentLengthToJava2D(unit2.getSize(), dataArea, ↵

15

    edge);↵

15

                    edge);↵

16

            tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2);↵

16

            tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2);↵

17

            if (tickLabelWidth > unit2Width) {↵

17

            if (tickLabelWidth > unit2Width) {↵

18

                unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2);↵

18

                unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2);↵

19

            }↵

19

            }↵

20

            setTickUnit(unit2, false, false);

20

            setTickUnit(unit2, false, false);

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.1
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 85

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 11
   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) | 3.3
   Clone type | Type 2

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

   1

       double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit());

   1

       double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit());

   2

       TickUnitSource tickUnits = getStandardTickUnits();

   2

       TickUnitSource tickUnits = getStandardTickUnits();

   3

       TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit());

   3

       TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit());

   4

       double unit1Width = lengthToJava2D(unit1.getSize(), dataArea, edge);

   4 | double unit1Width = lengthToJava2D(unit1.getSize(), dataArea, edge);
   4 | double unit1Width = exponentLengthToJava2D(unit1.getSize(), dataArea, edge);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   lengthToJava2D | exponentLengthToJava2D | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression lengthToJava2D(unit1.getSize(),dataArea,edge) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression exponentLengthToJava2D(unit1.getSize(),dataArea,edge) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   4

       double unit1Width = exponentLengthToJava2D(unit1.getSize(), dataArea, edge);

   5

       double guess = (tickLabelWidth / unit1Width) * unit1.getSize();

   5

       double guess = (tickLabelWidth / unit1Width) * unit1.getSize();

   6

       NumberTickUnit unit2 = (NumberTickUnit)tickUnits.getCeilingTickUnit(guess);

   6

       NumberTickUnit unit2 = (NumberTickUnit)tickUnits.getCeilingTickUnit(guess);

   7

       double unit2Width = lengthToJava2D(unit2.getSize(), dataArea, edge);

   7 | double unit2Width = lengthToJava2D(unit2.getSize(), dataArea, edge);
   7 | double unit2Width = exponentLengthToJava2D(unit2.getSize(), dataArea, edge);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   lengthToJava2D | exponentLengthToJava2D | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression lengthToJava2D(unit2.getSize(),dataArea,edge) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression exponentLengthToJava2D(unit2.getSize(),dataArea,edge) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   7

       double unit2Width = exponentLengthToJava2D(unit2.getSize(), dataArea, edge);

   8

       tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2);

   8

       tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2);

   9

       if (tickLabelWidth > unit2Width)

   9

       if (tickLabelWidth > unit2Width)

   10

       unit2 = (NumberTickUnit)tickUnits.getLargerTickUnit(unit2);

   10

       unit2 = (NumberTickUnit)tickUnits.getLargerTickUnit(unit2);

   11

       setTickUnit(unit2, false, false);

   11

       setTickUnit(unit2, false, false);

   Precondition Violations (4)
   Row | Violation
   --- | ---
   1 | Expression lengthToJava2D(unit1.getSize(),dataArea,edge) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression exponentLengthToJava2D(unit1.getSize(),dataArea,edge) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression lengthToJava2D(unit2.getSize(),dataArea,edge) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression exponentLengthToJava2D(unit2.getSize(),dataArea,edge) cannot be parameterized, because it has dependencies to/from statements that will be extracted