1 package net.suberic.pooka.gui; 2 import javax.swing.text.WrappedPlainView ; 3 import javax.swing.text.Segment ; 4 import javax.swing.text.Element ; 5 import net.suberic.pooka.MailUtilities; 6 import net.suberic.pooka.Pooka; 7 8 17 public class MailWrappedView extends WrappedPlainView { 18 19 public MailWrappedView(Element elem) { 20 super(elem); 21 } 22 23 public MailWrappedView(Element elem, boolean wordWrap) { 24 super(elem, wordWrap); 25 } 26 27 private int characterLength = 72; 28 29 35 protected int calculateBreakPosition(int p0, int p1) { 36 super.calculateBreakPosition(p0, p1); 37 try { 38 String text = getDocument().getText(p0, p1 - p0); 39 int offset = MailUtilities.getBreakOffset(text, getCharacterLength(), getTabSize()); 40 return p0 + offset; 41 } catch (javax.swing.text.BadLocationException ble) { 42 return p1; 43 } 44 } 45 46 public int getCharacterLength() { 47 try { 48 String wrapLengthString = Pooka.getProperty("Pooka.lineLength"); 49 characterLength = Integer.parseInt(wrapLengthString); 50 } catch (Exception e) { 51 characterLength = 72; 52 } 53 return characterLength; 54 } 55 56 public void setCharacterLength(int newCharacterLength) { 57 characterLength = newCharacterLength; 58 } 59 } 60 61 | Popular Tags |