1 45 46 package org.jfree.chart.labels; 47 48 import java.awt.Font ; 49 import java.awt.Paint ; 50 import java.awt.font.TextAttribute ; 51 import java.io.Serializable ; 52 import java.text.AttributedString ; 53 import java.text.NumberFormat ; 54 55 import org.jfree.data.general.PieDataset; 56 import org.jfree.util.ObjectList; 57 58 67 public class StandardPieSectionLabelGenerator 68 extends AbstractPieItemLabelGenerator 69 implements PieSectionLabelGenerator, Cloneable , Serializable { 70 71 72 private static final long serialVersionUID = 3064190563760203668L; 73 74 75 public static final String DEFAULT_SECTION_LABEL_FORMAT = "{0}"; 76 77 80 private ObjectList attributedLabels; 81 82 87 public StandardPieSectionLabelGenerator() { 88 this(DEFAULT_SECTION_LABEL_FORMAT, NumberFormat.getNumberInstance(), 89 NumberFormat.getPercentInstance()); 90 } 91 92 98 public StandardPieSectionLabelGenerator(String labelFormat) { 99 this(labelFormat, NumberFormat.getNumberInstance(), 100 NumberFormat.getPercentInstance()); 101 } 102 103 113 public StandardPieSectionLabelGenerator(String labelFormat, 114 NumberFormat numberFormat, 115 NumberFormat percentFormat) { 116 117 super(labelFormat, numberFormat, percentFormat); 118 this.attributedLabels = new ObjectList(); 119 120 } 121 122 130 public AttributedString getAttributedLabel(int section) { 131 return (AttributedString ) this.attributedLabels.get(section); 132 } 133 134 140 public void setAttributedLabel(int section, AttributedString label) { 141 this.attributedLabels.set(section, label); 142 } 143 144 152 public String generateSectionLabel(PieDataset dataset, Comparable key) { 153 return super.generateSectionLabel(dataset, key); 154 } 155 156 183 public AttributedString generateAttributedSectionLabel(PieDataset dataset, 184 Comparable key) { 185 return getAttributedLabel(dataset.getIndex(key)); 186 } 187 188 195 public boolean equals(Object obj) { 196 if (obj == this) { 197 return true; 198 } 199 if (!(obj instanceof StandardPieSectionLabelGenerator)) { 200 return false; 201 } 202 if (!super.equals(obj)) { 203 return false; 204 } 205 return true; 206 } 207 208 215 public Object clone() throws CloneNotSupportedException { 216 return super.clone(); 217 } 218 219 } 220 | Popular Tags |