1 39 40 package org.krysalis.jcharts.chartData.processors; 41 42 43 import org.krysalis.jcharts.chartText.TextTag; 44 45 import java.awt.*; 46 import java.awt.font.FontRenderContext ; 47 import java.util.ArrayList ; 48 49 50 54 public class TextProcessor 55 { 56 private float widestLabel = Float.MIN_VALUE; 57 private float tallestLabel = Float.MIN_VALUE; 58 private float totalLabelWidths = 0.0f; 59 60 private ArrayList textTags; 61 62 63 67 public TextProcessor() 68 { 69 this.textTags = new ArrayList ( 30 ); 70 } 71 72 73 79 public void addLabel( String label, Font font, FontRenderContext fontRenderContext ) 80 { 81 TextTag textTag= new TextTag( label, font, fontRenderContext ); 82 this.textTags.add( textTag ); 83 84 this.widestLabel = Math.max( textTag.getWidth(), this.widestLabel ); 85 this.totalLabelWidths += textTag.getWidth(); 86 87 this.tallestLabel = Math.max( textTag.getHeight(), this.tallestLabel ); 88 } 89 90 91 96 public int size() 97 { 98 return this.textTags.size(); 99 } 100 101 102 139 public float getWidestLabel() 140 { 141 return this.widestLabel; 142 } 143 144 145 149 public float getTallestLabel() 150 { 151 return this.tallestLabel; 152 } 153 154 155 159 public float getTotalLabelWidths() 160 { 161 return this.totalLabelWidths; 162 } 163 164 165 170 public TextTag getTextTag( int index ) 171 { 172 return (TextTag) this.textTags.get( index ); 173 } 174 } 175 | Popular Tags |