public class StandardCategorySeriesLabelGenerator implements CategorySeriesLabelGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 4630760091523940820L; /** The default item label format. */ public static final String DEFAULT_LABEL_FORMAT = "{0}"; /** The format pattern. */ private String formatPattern; /** * Creates a default series label generator (uses * {@link #DEFAULT_LABEL_FORMAT}). */ public StandardCategorySeriesLabelGenerator() { this(DEFAULT_LABEL_FORMAT); } /** * Creates a new series label generator. * * @param format the format pattern (null not permitted). */ public StandardCategorySeriesLabelGenerator(String format) { if (format == null) { throw new IllegalArgumentException("Null 'format' argument."); } this.formatPattern = format; } /** * Generates a label for the specified series. * * @param dataset the dataset (null not permitted). * @param series the series. * * @return A series label. */ public String generateLabel(CategoryDataset dataset, int series) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } String label = MessageFormat.format(this.formatPattern, createItemArray(dataset, series)); return label; } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * * @return The items (never null). */ protected Object[] createItemArray(CategoryDataset dataset, int series) { Object[] result = new Object[1]; result[0] = dataset.getRowKey(series).toString(); return result; } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardCategorySeriesLabelGenerator)) { return false; } StandardCategorySeriesLabelGenerator that = (StandardCategorySeriesLabelGenerator) obj; if (!this.formatPattern.equals(that.formatPattern)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 127; result = HashUtilities.hashCode(result, this.formatPattern); return result;
public class StandardXYSeriesLabelGenerator implements XYSeriesLabelGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 1916017081848400024L; /** The default item label format. */ public static final String DEFAULT_LABEL_FORMAT = "{0}"; /** The format pattern. */ private String formatPattern; /** * Creates a default series label generator (uses * {@link #DEFAULT_LABEL_FORMAT}). */ public StandardXYSeriesLabelGenerator() { this(DEFAULT_LABEL_FORMAT); } /** * Creates a new series label generator. * * @param format the format pattern (null not permitted). */ public StandardXYSeriesLabelGenerator(String format) { if (format == null) { throw new IllegalArgumentException("Null 'format' argument."); } this.formatPattern = format; } /** * Generates a label for the specified series. This label will be * used for the chart legend. * * @param dataset the dataset (null not permitted). * @param series the series. * * @return A series label. */ public String generateLabel(XYDataset dataset, int series) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } String label = MessageFormat.format( this.formatPattern, createItemArray(dataset, series) ); return label; } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * * @return The items (never null). */ protected Object[] createItemArray(XYDataset dataset, int series) { Object[] result = new Object[1]; result[0] = dataset.getSeriesKey(series).toString(); return result; } /** * Returns an independent copy of the generator. This is unnecessary, * because instances are immutable anyway, but we retain this * behaviour for backwards compatibility. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardXYSeriesLabelGenerator)) { return false; } StandardXYSeriesLabelGenerator that = (StandardXYSeriesLabelGenerator) obj; if (!this.formatPattern.equals(that.formatPattern)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 127; result = HashUtilities.hashCode(result, this.formatPattern); return result;
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/labels/StandardCategorySeriesLabelGenerator.java File path: /jfreechart-1.0.10/src/org/jfree/chart/labels/StandardXYSeriesLabelGenerator.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class StandardCategorySeriesLabelGenerator implements 
1
public class StandardXYSeriesLabelGenerator implements 
2
    CategorySeriesLabelGenerator, 
2
XYSeriesLabelGenerator, 
3
Cloneable, PublicCloneable, Serializable {
3
        Cloneable, PublicCloneable, Serializable {
4
    /** For serialization. */
4
    /** For serialization. */
5
    private static final long serialVersionUID = 4630760091523940820L;
5
    private static final long serialVersionUID = 1916017081848400024L;
6
    
6
    
7
    /** The default item label format. */
7
    /** The default item label format. */
8
    public static final String DEFAULT_LABEL_FORMAT = "{0}";
8
    public static final String DEFAULT_LABEL_FORMAT = "{0}";
9
    
9
    
10
    /** The format pattern. */
10
    /** The format pattern. */
11
    private String formatPattern;
11
    private String formatPattern;
12
    /**
12
    /**
13
     * Creates a default series label generator (uses 
13
     * Creates a default series label generator (uses 
14
     * {@link #DEFAULT_LABEL_FORMAT}).
14
     * {@link #DEFAULT_LABEL_FORMAT}).
15
     */
15
     */
16
    public StandardCategorySeriesLabelGenerator() {
16
    public StandardXYSeriesLabelGenerator() {
17
        this(DEFAULT_LABEL_FORMAT);
17
        this(DEFAULT_LABEL_FORMAT);
18
    }
18
    }
19
    
19
    
20
    /**
20
    /**
21
     * Creates a new series label generator.
21
     * Creates a new series label generator.
22
     * 
22
     * 
23
     * @param format  the format pattern (null not permitted).
23
     * @param format  the format pattern (null not permitted).
24
     */
24
     */
25
    public StandardCategorySeriesLabelGenerator(String format) {
25
    public StandardXYSeriesLabelGenerator(String format) {
26
        if (format == null) {
26
        if (format == null) {
27
            throw new IllegalArgumentException("Null 'format' argument.");
27
            throw new IllegalArgumentException("Null 'format' argument.");
28
        }
28
        }
29
        this.formatPattern = format;
29
        this.formatPattern = format;
30
    }
30
    }
31
    /**
31
    /**
32
     * Generates a label for the specified series.
32
     * Generates a label for the specified series.  This label will be
33
     * used for the chart legend.
33
     * 
34
     * 
34
     * @param dataset  the dataset (null not permitted).
35
     * @param dataset  the dataset (null not permitted).
35
     * @param series  the series.
36
     * @param series  the series.
36
     * 
37
     * 
37
     * @return A series label.
38
     * @return A series label.
38
     */
39
     */
39
    public String generateLabel(CategoryDataset dataset, int series) {
40
    public String generateLabel(XYDataset dataset, int series) {
40
        if (dataset == null) {
41
        if (dataset == null) {
41
            throw new IllegalArgumentException("Null 'dataset' argument.");
42
            throw new IllegalArgumentException("Null 'dataset' argument.");
42
        }
43
        }
43
        String label = MessageFormat.format(
44
        String label = MessageFormat.format(
44
this.formatPattern, 
45
            this.formatPattern, 
45
                createItemArray(dataset, series)
46
createItemArray(dataset, series)
46
);
47
        );
47
        return label;
48
        return label;
48
    }
49
    }
49
    /**
50
    /**
50
     * Creates the array of items that can be passed to the 
51
     * Creates the array of items that can be passed to the 
51
     * {@link MessageFormat} class for creating labels.
52
     * {@link MessageFormat} class for creating labels.
52
     *
53
     *
53
     * @param dataset  the dataset (null not permitted).
54
     * @param dataset  the dataset (null not permitted).
54
     * @param series  the series (zero-based index).
55
     * @param series  the series (zero-based index).
55
     *
56
     *
56
     * @return The items (never null).
57
     * @return The items (never null).
57
     */
58
     */
58
    protected Object[] createItemArray(CategoryDataset dataset, int series) {
59
    protected Object[] createItemArray(XYDataset dataset, int series) {
59
        Object[] result = new Object[1];
60
        Object[] result = new Object[1];
60
        result[0] = dataset.getRowKey(series).toString();
61
        result[0] = dataset.getSeriesKey(series).toString();
61
        return result;
62
        return result;
62
    }
63
    }
63
    /**
64
    /**
64
     * Returns an independent copy of the generator.
65
     * Returns an independent copy of the generator.  This is unnecessary, 
66
     * because instances are immutable anyway, but we retain this 
67
     * behaviour for backwards compatibility.
65
     * 
68
     * 
66
     * @return A clone.
69
     * @return A clone.
67
     * 
70
     * 
68
     * @throws CloneNotSupportedException if cloning is not supported.
71
     * @throws CloneNotSupportedException if cloning is not supported.
69
     */
72
     */
70
    public Object clone() throws CloneNotSupportedException { 
73
    public Object clone() throws CloneNotSupportedException { 
71
        return super.clone();
74
        return super.clone();
72
    }
75
    }
73
    
76
    
74
    /**
77
    /**
75
     * Tests this object for equality with an arbitrary object.
78
     * Tests this object for equality with an arbitrary object.
76
     *
79
     *
77
     * @param obj  the other object (null permitted).
80
     * @param obj  the other object (null permitted).
78
     *
81
     *
79
     * @return A boolean.
82
     * @return A boolean.
80
     */
83
     */
81
    public boolean equals(Object obj) {
84
    public boolean equals(Object obj) {
82
        if (obj == this) {
85
        if (obj == this) {
83
            return true;
86
            return true;
84
        }
87
        }
85
        if (!(obj instanceof StandardCategorySeriesLabelGenerator)) {
88
        if (!(obj instanceof StandardXYSeriesLabelGenerator)) {
86
            return false;
89
            return false;
87
        }
90
        }
88
        StandardCategorySeriesLabelGenerator that 
91
        StandardXYSeriesLabelGenerator that 
89
                = (StandardCategorySeriesLabelGenerator) obj;
92
                = (StandardXYSeriesLabelGenerator) obj;
90
        if (!this.formatPattern.equals(that.formatPattern)) {
93
        if (!this.formatPattern.equals(that.formatPattern)) {
91
            return false;
94
            return false;
92
        }
95
        }
93
        return true;
96
        return true;
94
    }
97
    }
95
    
98
    
96
    /**
99
    /**
97
     * Returns a hash code for this instance.
100
     * Returns a hash code for this instance.
98
     * 
101
     * 
99
     * @return A hash code.
102
     * @return A hash code.
100
     */
103
     */
101
    public int hashCode() {
104
    public int hashCode() {
102
        int result = 127;
105
        int result = 127;
103
        result = HashUtilities.hashCode(result, this.formatPattern);
106
        result = HashUtilities.hashCode(result, this.formatPattern);
104
        return result;
107
        return result;
105
    
108
    
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0