143-1-4

if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Number result = null; // if the dataset implements DomainInfo, life is easy if (dataset instanceof DomainInfo) { DomainInfo info = (DomainInfo) dataset; return new Double(info.getDomainLowerBound(true)); } else { double minimum = Double.POSITIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double value; if (dataset instanceof IntervalXYDataset) { IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; value = intervalXYData.getStartXValue(series, item); } else { value = dataset.getXValue(series, item); } if (!Double.isNaN(value)) { minimum = Math.min(minimum, value); } } } if (minimum == Double.POSITIVE_INFINITY) { result = null; } else { result = new Double(minimum); } } return result;
if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; return new Double(info.getRangeUpperBound(true)); } // hasn't implemented RangeInfo, so we'll have to iterate... else { double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double value; if (dataset instanceof IntervalXYDataset) { IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; value = intervalXYData.getEndYValue(series, item); } else if (dataset instanceof OHLCDataset) { OHLCDataset highLowData = (OHLCDataset) dataset; value = highLowData.getHighValue(series, item); } else { value = dataset.getYValue(series, item); } if (!Double.isNaN(value)) { maximum = Math.max(maximum, value); } } } if (maximum == Double.NEGATIVE_INFINITY) { return null; } else { return new Double(maximum); } }

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/general/DatasetUtilities.java |  | File path: /jfreechart-1.0.10/src/org/jfree/data/general/DatasetUtilities.java
Method name: `Number findMinimumDomainValue(XYDataset)` |  | Method name: `Number findMaximumRangeValue(XYDataset)`
Number of AST nodes: 22 |  | Number of AST nodes: 21

1

    if (dataset == null) {↵

1

    if (dataset ↵

2

                throw new IllegalArgumentException("Null 'dataset' argument.");↵

3

            }↵

4

            Number result = null;↵

5

            // if the dataset implements DomainInfo, life is easy↵

6

            if (dataset instanceof DomainInfo) {↵

2

    instanceof RangeInfo) {↵

7

                DomainInfo info = (DomainInfo) dataset;↵

3

                RangeInfo info = (RangeInfo) dataset;↵

8

                return new Double(info.getDomainLowerBound(true));↵

4

                return new Double(info.getRangeUpperBound(true));↵

9

            }
    ↵

5

            }
    ↵

6

            // hasn't implemented RangeInfo, so we'll have to iterate...
    ↵

10

            else {↵

7

            else  {↵

11

                double minimum = Double.POSITIVE_INFINITY;↵

8

                double maximum = Double.NEGATIVE_INFINITY;↵

12

                int seriesCount = dataset.getSeriesCount();↵

9

                int seriesCount = dataset.getSeriesCount();↵

13

                for (int series = 0; series < seriesCount; series++) {↵

10

                for (int series = 0; series < seriesCount; series++) {↵

14

                    int itemCount = dataset.getItemCount(series);↵

11

                    int itemCount = dataset.getItemCount(series);↵

15

                    for (int item = 0; item < itemCount; item++) {↵

12

                    for (int item = 0; item < itemCount; item++) {↵

16

                        double value;↵

13

                        double value;↵

17

                        if (dataset instanceof IntervalXYDataset) {↵

14

                        if (dataset instanceof IntervalXYDataset) {↵

18

                            IntervalXYDataset intervalXYData↵

15

                            IntervalXYDataset intervalXYData↵

19

                                = (IntervalXYDataset) dataset;↵

16

                                = (IntervalXYDataset) dataset;↵

20

                            value = intervalXYData.getStartX↵

17

                            value = intervalXYData.getEndYValue(series, item);↵

18

                        }↵

19

                        else if (dataset instanceof OHLCDataset) {↵

20

                            OHLCDataset highLowData = (OHLCDataset) dataset;↵

21

    Value(series, item);↵

21

                            value = highLowData.getHighValue(series, item);↵

22

                        }↵

22

                        }↵

23

                        else {↵

23

                        else {↵

24

                            value = dataset.getXValue(series, item);↵

24

                            value = dataset.getYValue(series, item);↵

25

                        }↵

25

                        }↵

26

                        if (!Double.isNaN(value)) {↵

26

                        if (!Double.isNaN(value)) {↵

27

                            minimum = Math.min(minimum, value);↵

27

                            maximum = Math.max(maximum, value);↵

28

                        }↵

28

                        }↵

29

                    }↵

29

                    }↵

30

                }↵

30

                }↵

31

                if (minimum == Double.POSITIVE_INFINITY) {↵

31

                if (maximum == Double.NEGATIVE_INFINITY) {↵

32

                    result = null;↵

32

                    return null;↵

33

                }↵

33

                }↵

34

                else {↵

34

                else {↵

35

                    result = new Double(minimum);↵

35

                    return new Double(maximum);↵

36

                }↵

36

                }↵

37

            }↵

37

            }

38

            return result;

See real code fragment |  | See real code fragment

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