private String doFormat(String text, int minLineLength, int maxLineLength)
private String doFormat(String text, int maxLineLength)
	private String doFormat(String text, int minLineLength,		int maxLineLength)	{		StringBuffer buf = new StringBuffer();		StringBuffer word = new StringBuffer();		int lineLength = 0;		boolean newline = false;		boolean newlineIgnore = false;		// remove spaces from start of text		boolean space = true;		char[] chars = text.toCharArray();		for(int i = 0; i < chars.length; i++)		{			char c = chars[i];			lineLength++;			switch(c)			{			case '\n':				buf.append(word);						word.setLength(0);				if(newlineIgnore)					break;				if(newline)				{					// already seen a newline.					// start a new paragraph					buf.append("\n\n");					newline = false;					newlineIgnore = true;					lineLength = 0;					break;				}				if(lineLength > maxLineLength ||					lineLength < minLineLength)				{					buf.append(c);					newline = false;					newlineIgnore = false;					lineLength = 0;					break;				}				newline = true;				newlineIgnore = false;				space = true;				buf.append(' ');				break;			case ' ':				// multiple spaces are ignored				if(space)					break;				// append word				buf.append(word);				word.setLength(0);				space = true;				buf.append(' ');				break;			default:				space = newline = newlineIgnore = false;				word.append(c);				// do word wrap				if(lineLength > maxLineLength)				{					buf.append('\n');					// remove all spaces from start					// of next line					space = true;					lineLength = 0;				}				break;			}		}		buf.append(word);		return buf.toString();	}