1 16 17 package com.lowagie.text.pdf.hyphenation; 18 19 24 public class Hyphenation { 25 26 private int[] hyphenPoints; 27 private String word; 28 29 32 private int len; 33 34 38 Hyphenation(String word, int[] points) { 39 this.word = word; 40 hyphenPoints = points; 41 len = points.length; 42 } 43 44 47 public int length() { 48 return len; 49 } 50 51 54 public String getPreHyphenText(int index) { 55 return word.substring(0, hyphenPoints[index]); 56 } 57 58 61 public String getPostHyphenText(int index) { 62 return word.substring(hyphenPoints[index]); 63 } 64 65 68 public int[] getHyphenationPoints() { 69 return hyphenPoints; 70 } 71 72 public String toString() { 73 StringBuffer str = new StringBuffer (); 74 int start = 0; 75 for (int i = 0; i < len; i++) { 76 str.append(word.substring(start, hyphenPoints[i])).append('-'); 77 start = hyphenPoints[i]; 78 } 79 str.append(word.substring(start)); 80 return str.toString(); 81 } 82 83 } 84 | Popular Tags |