1 34 35 package org.krysalis.jcharts.nonAxisChart; 36 37 38 import org.krysalis.jcharts.types.PieLabelType; 39 import org.krysalis.jcharts.chartText.NumericTagGroup; 40 import org.krysalis.jcharts.chartText.TextTagGroup; 41 import org.krysalis.jcharts.chartText.TextTag; 42 import org.krysalis.jcharts.properties.PieChart2DProperties; 43 import org.krysalis.jcharts.chartData.interfaces.IPieChartDataSet; 44 45 import java.awt.font.FontRenderContext ; 46 47 48 54 class PieLabels 55 { 56 private TextTagGroup textTagGroup; 57 58 private float widestLabel; 59 private float widestLabelTimesTwo; 60 private float tallestLabel; 61 private float tallestLabelTimesTwo; 62 63 64 70 PieLabels( PieChart2DProperties properties, 71 IPieChartDataSet iPieChartDataSet, 72 FontRenderContext fontRenderContext ) 73 { 74 if( !properties.getPieLabelType().equals( PieLabelType.NO_LABELS ) ) 76 { 77 if( properties.getPieLabelType().equals( PieLabelType.VALUE_LABELS ) ) 78 { 79 this.textTagGroup = new NumericTagGroup( properties.getValueLabelFont(), 80 fontRenderContext, 81 properties.showValueLabelCurrency(), 82 false, 83 properties.showValueLabelGrouping(), 84 properties.getValueLabelRoundingPowerOfTen() ); 85 86 for( int i = 0; i < iPieChartDataSet.getNumberOfDataItems(); i++ ) 87 { 88 ((NumericTagGroup) this.textTagGroup).addLabel( iPieChartDataSet.getValue( i ) ); 89 } 90 } 91 else 93 { 94 this.textTagGroup = new TextTagGroup( properties.getValueLabelFont(), fontRenderContext ); 95 for( int i = 0; i < iPieChartDataSet.getNumberOfLegendLabels(); i++ ) 96 { 97 this.textTagGroup.addLabel( iPieChartDataSet.getLegendLabel( i ) ); 98 } 99 } 100 101 widestLabel = this.textTagGroup.getWidestLabel(); 102 widestLabelTimesTwo = widestLabel * 2; 103 tallestLabel = this.textTagGroup.getTallestLabel(); 104 tallestLabelTimesTwo = tallestLabel * 2; 105 } 106 107 } 108 109 110 public TextTag getTextTag( int index ) 111 { 112 return this.textTagGroup.getTextTag( index ); 113 } 114 115 116 public float getWidestLabelTimesTwo() 117 { 118 return widestLabelTimesTwo; 119 } 120 121 122 public float getWidestLabel() 123 { 124 return widestLabel; 125 } 126 127 128 public float getTallestLabel() 129 { 130 return tallestLabel; 131 } 132 133 134 public float getTallestLabelTimesTwo() 135 { 136 return tallestLabelTimesTwo; 137 } 138 139 } 140 | Popular Tags |