protected List<Rectangle> createHighlightAreas2(String fullText, String clippedText, FontMetrics fm, int xOffset, int yOffset, int height) {
        if (matchPattern == null) {
            return Collections.emptyList();
        }
        Matcher matcher = matchPattern.matcher(clippedText);
        List<Rectangle> highlightAreas = null;
        int startFrom = 0;
        while (startFrom < clippedText.length() && matcher.find(startFrom)) {
            if (highlightAreas == null) {
                highlightAreas = new ArrayList<Rectangle>();
            }
            int start = matcher.start();
            int end = matcher.end();
            if (start == end) {
                // empty matcher will cause infinite loop
                break;
            }
            startFrom = end;
            int highlightx;
            int highlightWidth;
            if (start == 0) {
                // start highlight from the start of the field
                highlightx = xOffset;
            } else {
                // Calculate the width of the unhighlighted text to get the
                // start of the highlighted region.
                String strToStart = clippedText.substring(0, start);
                highlightx = fm.stringWidth(strToStart) + xOffset;
            }
            // Get the width of the highlighted region
            String highlightText = clippedText.substring(start, end);
            highlightWidth = fm.stringWidth(highlightText);
            highlightAreas.add(new Rectangle(highlightx, yOffset, highlightWidth, height));
        }// while ( startFrom < text.length() && matcher.find( startFrom ) )
        if (highlightAreas == null) {
            highlightAreas = Collections.emptyList();
        } else {
            coalesceHighlightAreas(highlightAreas);
        }
        return highlightAreas;
    }
protected List<Rectangle> createHighlightAreas2(String fullText, String clippedText, FontMetrics fm, int xOffset, int yOffset, int height) {
        if (matchPattern == null) {
            return Collections.emptyList();
        }
        Matcher matcher = matchPattern.matcher(clippedText);
        List<Rectangle> highlightAreas = null;
        int startFrom = 0;
        while (startFrom < clippedText.length() && matcher.find(startFrom)) {
            if (highlightAreas == null) {
                highlightAreas = new ArrayList<Rectangle>();
            }
            int start = matcher.start();
            int end = matcher.end();
            if (start == end) {
               
                break;
            }
            startFrom = end;
            int highlightx;
            int highlightWidth;
            if (start == 0) {
               
                highlightx = xOffset;
            } else {
               
               
                String strToStart = clippedText.substring(0, start);
                highlightx = fm.stringWidth(strToStart) + xOffset;
            }
           
            String highlightText = clippedText.substring(start, end);
            highlightWidth = fm.stringWidth(highlightText);
            highlightAreas.add(new Rectangle(highlightx, yOffset, highlightWidth, height));
        
        if (highlightAreas == null) {
            highlightAreas = Collections.emptyList();
        } else {
            coalesceHighlightAreas(highlightAreas);
        }
        return highlightAreas;
    }
protected list<rectangle> createhighlightareas2(string fulltext, string clippedtext, fontmetrics fm, int xoffset, int yoffset, int height) { if (matchpattern == null) { return collections.emptylist(); } matcher matcher = matchpattern.matcher(clippedtext); list<rectangle> highlightareas = null; int startfrom = 0; while (startfrom < clippedtext.length() && matcher.find(startfrom)) { if (highlightareas == null) { highlightareas = new arraylist<rectangle>(); } int start = matcher.start(); int end = matcher.end(); if (start == end) { break; } startfrom = end; int highlightx; int highlightwidth; if (start == 0) { highlightx = xoffset; } else { string strtostart = clippedtext.substring(0, start); highlightx = fm.stringwidth(strtostart) + xoffset; } string highlighttext = clippedtext.substring(start, end); highlightwidth = fm.stringwidth(highlighttext); highlightareas.add(new rectangle(highlightx, yoffset, highlightwidth, height)); if (highlightareas == null) { highlightareas = collections.emptylist(); } else { coalescehighlightareas(highlightareas); } return highlightareas; }