if ( maxSize > 0 )
al.add( ss ); }  i = j + 1;  } while ( j != -1 && j < s.length( ) );   if ( maxSize > 0 ) { TextLayout tl = new TextLayout( ( (SwtDisplayServer) ids ).getDevice( ) ); tl.setFont( getFont( ) ); tl.setWidth( (int) maxSize );  List nal = new ArrayList( );  for ( Iterator itr = al.iterator( ); itr.hasNext( ); ) { String ns = (String) itr.next( );  tl.setText( ns );  int[] offsets = tl.getLineOffsets( ); String ss;  for ( i = 1; i < offsets.length; i++ )
	private String[] splitOnBreaks( String s, double maxSize )	{		final ArrayList al = new ArrayList( );		if ( maxSize > 0 )		{			gc.setFont( getFont( ) );		}		int i = 0, j;		do		{			j = s.indexOf( '\n', i );			if ( j == -1 )			{				j = s.length( );			}			String ss = s.substring( i, j ).trim( );			if ( ss != null && ss.length( ) > 0 )			{				// check max size.				if ( maxSize > 0 )				{					Point size = gc.textExtent( ss );					if ( size.x > maxSize )					{						// try fuzzy match first						int estCount = (int) ( maxSize / size.x ) * ss.length( );						if ( estCount < 1 )						{							estCount = ss.length( );						}						String fs;						Point fsize;						int curPos = 0;						while ( ss.length( ) > 0 )						{							fs = ss.substring( 0, Math.min( estCount,									ss.length( ) ) );							fsize = gc.textExtent( fs );							if ( fsize.x <= maxSize )							{								al.add( fs );								curPos = fs.length( );							}							else							{								boolean matched = false;								// decrease the count and test again.								int curCount = Math.min( estCount - 1,										ss.length( ) );								while ( curCount > 1 )								{									fs = ss.substring( 0, curCount );									fsize = gc.textExtent( fs );									if ( fsize.x <= maxSize )									{										al.add( fs );										curPos = fs.length( );										matched = true;										break;									}									else									{										curCount--;									}								}								if ( !matched )								{									al.add( fs );									curPos = fs.length( );								}							}							ss = ss.substring( curPos );							curPos = 0;						}					}					else					{						al.add( ss );					}				}				else				{					al.add( ss );				}			}			i = j + 1;		} while ( j != -1 && j < s.length( ) );		final int n = al.size( );		if ( n == 1 || n == 0 )		{			return null;		}		final String[] sa = new String[n];		for ( i = 0; i < al.size( ); i++ )		{			sa[i] = (String) al.get( i );		}		return sa;	}