Ticket #2465: getHitIndex.patch

File getHitIndex.patch, 1.1 KB (added by diana, 15 years ago)
  • src/main/java/org/sophie2/base/model/text/layout/HotAreaLayout.java

    ### Eclipse Workspace Patch 1.0
    #P org.sophie2.base.model.text
     
    287287                boolean isLast = true; 
    288288                HotLineLayout lastLineLayout = this.lines.get(0); 
    289289                int offset = 0; 
    290                  
    291                 for (int i = 0; i < this.lines.size(); ++i) { 
     290                int i = 0; 
     291                for (; i < this.lines.size(); ++i) { 
    292292                        HotLineLayout lineLayout = this.lines.get(i); 
    293293                        if (lineLayout.getBaseY() > point.getY()) { 
    294294                                isLast = false; 
     
    301301                } 
    302302                 
    303303                assert lastLineLayout != null; 
    304                 offset -= lastLineLayout.getConsumedLength(); 
     304                 
     305                if (i > 0) { 
     306                        offset -= lastLineLayout.getConsumedLength(); 
     307                } 
    305308                 
    306309                int result = lastLineLayout.getHitIndex(point.getX(), isLast) + offset; 
    307310                SophieLog.debug("SimpleAreaLayout.getHitIndex(): " + result); 
    308                  
    309311                return result; 
    310312        } 
    311313