1 55 56 package org.jfree.chart.labels; 57 58 import java.io.Serializable ; 59 import java.text.MessageFormat ; 60 import java.text.NumberFormat ; 61 62 import org.jfree.data.general.PieDataset; 63 import org.jfree.util.PublicCloneable; 64 65 74 public class StandardPieItemLabelGenerator extends AbstractPieItemLabelGenerator 75 implements PieToolTipGenerator, 76 PieSectionLabelGenerator, 77 Cloneable , 78 PublicCloneable, 79 Serializable { 80 81 82 private static final long serialVersionUID = 2995304200445733779L; 83 84 85 public static final String DEFAULT_TOOLTIP_FORMAT = "{0}: ({1}, {2})"; 86 87 88 public static final String DEFAULT_SECTION_LABEL_FORMAT = "{0} = {1}"; 89 90 93 public StandardPieItemLabelGenerator() { 94 this( 95 DEFAULT_SECTION_LABEL_FORMAT, 96 NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance() 97 ); 98 } 99 100 105 public StandardPieItemLabelGenerator(String labelFormat) { 106 this( 107 labelFormat, NumberFormat.getNumberInstance(), 108 NumberFormat.getPercentInstance() 109 ); 110 } 111 112 122 public StandardPieItemLabelGenerator(String labelFormat, 123 NumberFormat numberFormat, 124 NumberFormat percentFormat) { 125 126 super(labelFormat, numberFormat, percentFormat); 127 128 } 129 130 138 public String generateSectionLabel(PieDataset dataset, Comparable key) { 139 String result = null; 140 if (dataset != null) { 141 Object [] items = createItemArray(dataset, key); 142 result = MessageFormat.format(getLabelFormat(), items); 143 } 144 return result; 145 } 146 147 155 public String generateToolTip(PieDataset dataset, Comparable key) { 156 return generateSectionLabel(dataset, key); 157 } 158 159 166 public Object clone() throws CloneNotSupportedException { 167 return super.clone(); 168 } 169 170 } 171 | Popular Tags |