37-1-2

Range range = getRange(); List ticks = new ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); TextAnchor textAnchor; if (edge == RectangleEdge.RIGHT) { textAnchor = TextAnchor.CENTER_LEFT; } else { textAnchor = TextAnchor.CENTER_RIGHT; } if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } double start = Math.floor(calculateLog(getLowerBound())); double end = Math.ceil(calculateLog(getUpperBound())); double current = start; while (current <= end) { double v = calculateValue(current); if (range.contains(v)) { ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), textAnchor, TextAnchor.CENTER, 0.0)); } // add minor ticks (for gridlines) double next = Math.pow(this.base, current + this.tickUnit.getSize()); for (int i = 1; i < this.minorTickCount; i++) { double minorV = v + i * ((next - v) / this.minorTickCount); if (range.contains(minorV)) { ticks.add(new NumberTick(TickType.MINOR, minorV, "", textAnchor, TextAnchor.CENTER, 0.0)); } } current = current + this.tickUnit.getSize(); } return ticks;
Range range = getRange(); List ticks = new ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); TextAnchor textAnchor; if (edge == RectangleEdge.TOP) { textAnchor = TextAnchor.BOTTOM_CENTER; } else { textAnchor = TextAnchor.TOP_CENTER; } if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } double start = Math.floor(calculateLog(getLowerBound())); double end = Math.ceil(calculateLog(getUpperBound())); double current = start; while (current <= end) { double v = calculateValue(current); if (range.contains(v)) { ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), textAnchor, TextAnchor.CENTER, 0.0)); } // add minor ticks (for gridlines) double next = Math.pow(this.base, current + this.tickUnit.getSize()); for (int i = 1; i < this.minorTickCount; i++) { double minorV = v + i * ((next - v) / this.minorTickCount); if (range.contains(minorV)) { ticks.add(new NumberTick(TickType.MINOR, minorV, "", textAnchor, TextAnchor.CENTER, 0.0)); } } current = current + this.tickUnit.getSize(); } return ticks;

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

1

    Range range = getRange();↵

1

    Range range = getRange();↵

2

            List ticks = new ArrayList();↵

2

            List ticks = new ArrayList();↵

3

            Font tickLabelFont = getTickLabelFont();↵

3

            Font tickLabelFont = getTickLabelFont();↵

4

            g2.setFont(tickLabelFont);↵

4

            g2.setFont(tickLabelFont);↵

5

            TextAnchor textAnchor;↵

5

            TextAnchor textAnchor;↵

6

            if (edge == RectangleEdge.RIGHT) {↵

6

            if (edge == RectangleEdge.TOP) {↵

7

                textAnchor = TextAnchor.CENTER_LEFT;↵

7

                textAnchor = TextAnchor.BOTTOM_CENTER;↵

8

            }↵

8

            }↵

9

            else {↵

9

            else {↵

10

                textAnchor = TextAnchor.CENTER_RIGHT;↵

10

                textAnchor = TextAnchor.TOP_CENTER;↵

11

            }↵

11

            }↵

12

            ↵

12

            ↵

13

            if (isAutoTickUnitSelection()) {↵

13

            if (isAutoTickUnitSelection()) {↵

14

                selectAutoTickUnit(g2, dataArea, edge);↵

14

                selectAutoTickUnit(g2, dataArea, edge);↵

15

            }↵

15

            }↵

16

            double start = Math.floor(calculateLog(getLowerBound()));↵

16

            double start = Math.floor(calculateLog(getLowerBound()));↵

17

            double end = Math.ceil(calculateLog(getUpperBound()));↵

17

            double end = Math.ceil(calculateLog(getUpperBound()));↵

18

            double current = start;↵

18

            double current = start;↵

19

            while (current <= end) {↵

19

            while (current <= end) {↵

20

                double v = calculateValue(current);↵

20

                double v = calculateValue(current);↵

21

                if (range.contains(v)) {↵

21

                if (range.contains(v)) {↵

22

                    ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), ↵

22

                    ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), ↵

23

                            textAnchor, TextAnchor.CENTER, 0.0));↵

23

                            textAnchor, TextAnchor.CENTER, 0.0));↵

24

                }↵

24

                }↵

25

                // add minor ticks (for gridlines)↵

25

                // add minor ticks (for gridlines)↵

26

                double next = Math.pow(this.base, current ↵

26

                double next = Math.pow(this.base, current ↵

27

                        + this.tickUnit.getSize());↵

27

                        + this.tickUnit.getSize());↵

28

                for (int i = 1; i < this.minorTickCount; i++) {↵

28

                for (int i = 1; i < this.minorTickCount; i++) {↵

29

                    double minorV = v + i * ((next - v) / this.minorTickCount);↵

29

                    double minorV = v + i * ((next - v) / this.minorTickCount);↵

30

                    if (range.contains(minorV)) {↵

30

                    if (range.contains(minorV)) {↵

31

                        ticks.add(new NumberTick(TickType.MINOR, minorV, "", ↵

31

                        ticks.add(new NumberTick(TickType.MINOR, minorV, "", ↵

32

                                textAnchor, TextAnchor.CENTER, 0.0));↵

32

                                textAnchor, TextAnchor.CENTER, 0.0));↵

33

                    }↵

33

                    }↵

34

                }↵

34

                }↵

35

                current = current + this.tickUnit.getSize();↵

35

                current = current + this.tickUnit.getSize();↵

36

            }↵

36

            }↵

37

            return ticks;

37

            return ticks;

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.6
Clones location | Clones are declared in the same class
Number of node comparisons | 131

1. {Refactorable}

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

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

   1

       Range range = getRange();

   1

       Range range = getRange();

   2

       List ticks = new ArrayList();

   2

       List ticks = new ArrayList();

   3

       Font tickLabelFont = getTickLabelFont();

   3

       Font tickLabelFont = getTickLabelFont();

   4

       g2.setFont(tickLabelFont);

   4

       g2.setFont(tickLabelFont);

   5

       TextAnchor textAnchor;

   5

       TextAnchor textAnchor;

   6

       if (edge == RectangleEdge.RIGHT)

   6 | if (edge == RectangleEdge.RIGHT)
   6 | if (edge == RectangleEdge.TOP)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   RIGHT | TOP | VARIABLE_NAME_MISMATCH

   6

       if (edge == RectangleEdge.TOP)

   7

       textAnchor = TextAnchor.CENTER_LEFT;

   7 | textAnchor = TextAnchor.CENTER_LEFT;
   7 | textAnchor = TextAnchor.BOTTOM_CENTER;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   CENTER_LEFT | BOTTOM_CENTER | VARIABLE_NAME_MISMATCH

   7

       textAnchor = TextAnchor.BOTTOM_CENTER;

       else

       else

   8

       textAnchor = TextAnchor.CENTER_RIGHT;

   8 | textAnchor = TextAnchor.CENTER_RIGHT;
   8 | textAnchor = TextAnchor.TOP_CENTER;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   CENTER_RIGHT | TOP_CENTER | VARIABLE_NAME_MISMATCH

   8

       textAnchor = TextAnchor.TOP_CENTER;

   9

       if (isAutoTickUnitSelection())

   9

       if (isAutoTickUnitSelection())

   10

       selectAutoTickUnit(g2, dataArea, edge);

   10

       selectAutoTickUnit(g2, dataArea, edge);

   11

       double start = Math.floor(calculateLog(getLowerBound()));

   11

       double start = Math.floor(calculateLog(getLowerBound()));

   12

       double end = Math.ceil(calculateLog(getUpperBound()));

   12

       double end = Math.ceil(calculateLog(getUpperBound()));

   13

       double current = start;

   13

       double current = start;

   14

       while (current <= end)

   14

       while (current <= end)

   15

       double v = calculateValue(current);

   15

       double v = calculateValue(current);

   16

       if (range.contains(v))

   16

       if (range.contains(v))

   17

       ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), textAnchor, TextAnchor.CENTER, 0.0));

   17

       ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), textAnchor, TextAnchor.CENTER, 0.0));

   18

       double next = Math.pow(this.base, current + this.tickUnit.getSize());

   18

       double next = Math.pow(this.base, current + this.tickUnit.getSize());

   19

       for (int i = 1; i < this.minorTickCount; i++)

   19

       for (int i = 1; i < this.minorTickCount; i++)

   20

       double minorV = v + i * ((next - v) / this.minorTickCount);

   20

       double minorV = v + i * ((next - v) / this.minorTickCount);

   21

       if (range.contains(minorV))

   21

       if (range.contains(minorV))

   22

       ticks.add(new NumberTick(TickType.MINOR, minorV, "", textAnchor, TextAnchor.CENTER, 0.0));

   22

       ticks.add(new NumberTick(TickType.MINOR, minorV, "", textAnchor, TextAnchor.CENTER, 0.0));

   23

       current = current + this.tickUnit.getSize();

   23

       current = current + this.tickUnit.getSize();

   24

       return ticks;

   24

       return ticks;

   Precondition Violations (0)
   Row | Violation
   --- | ---