Author: joern Date: Mon Nov 7 16:10:04 2011 New Revision: 1198791 URL: http://svn.apache.org/viewvc?rev=1198791&view=rev Log: UIMA-2279 Improved performance of rendering code.
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java?rev=1198791&r1=1198790&r2=1198791&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java Mon Nov 7 16:10:04 2011 @@ -30,15 +30,11 @@ import org.eclipse.swt.graphics.Rectangl public class TokenDrawingStrategy implements IDrawingStrategy { private static final int BRACKET_WIDTH = 5; - private static boolean isWhitespace(StyledText textWidget, int offset) { + private static boolean isWhitespace(String text, int offset) { - String characterString = textWidget.getText(offset, offset); + char character = text.charAt(offset); - if (characterString.trim().length() == 0) { - return true; - } - - return false; + return Character.isWhitespace(character); } public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, @@ -46,7 +42,6 @@ public class TokenDrawingStrategy implem if (length > 0) { if (annotation instanceof EclipseAnnotationPeer) { AnnotationFS annotationFS = ((EclipseAnnotationPeer) annotation).getAnnotationFS(); - if (gc != null) { Rectangle bounds = textWidget.getTextBounds(offset, offset + length - 1); @@ -54,7 +49,7 @@ public class TokenDrawingStrategy implem boolean isDrawOpenBracket = annotationFS.getBegin() == offset; // and no space before offset - if (isDrawOpenBracket && offset > 1 && !isWhitespace(textWidget, offset - 1)) { + if (isDrawOpenBracket && offset > 1 && !isWhitespace(annotationFS.getCAS().getDocumentText(), offset - 1)) { gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x + BRACKET_WIDTH, bounds.y + bounds.height - 1); @@ -66,7 +61,7 @@ public class TokenDrawingStrategy implem boolean isDrawCloseBracket = annotationFS.getEnd() == offset + length; // and no space after offset if (isDrawCloseBracket && offset + length < textWidget.getText().length() - && !isWhitespace(textWidget, offset + length)) { + && !isWhitespace(annotationFS.getCAS().getDocumentText(), offset + length)) { gc.drawLine(bounds.x + bounds.width, bounds.y + bounds.height - 1, bounds.x + bounds.width - BRACKET_WIDTH, bounds.y + bounds.height - 1);