You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2009/10/06 14:42:49 UTC

svn commit: r822250 - /incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BackgroundDrawingStrategy.java

Author: joern
Date: Tue Oct  6 12:42:49 2009
New Revision: 822250

URL: http://svn.apache.org/viewvc?rev=822250&view=rev
Log:
UIMA-1600 Background drawing style does not draw correctly if an annotation contains a tab

Modified:
    incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BackgroundDrawingStrategy.java

Modified: incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BackgroundDrawingStrategy.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BackgroundDrawingStrategy.java?rev=822250&r1=822249&r2=822250&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BackgroundDrawingStrategy.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BackgroundDrawingStrategy.java Tue Oct  6 12:42:49 2009
@@ -56,14 +56,14 @@
     	  
         Rectangle bounds = textWidget.getTextBounds(annotationBegin, annotationEnd - 1);
 
-        // Selection in the text widget are drawn before the annotation are drawn,
+        // Selection in the text widget are drawn before the annotations are drawn,
         // to make a selection visible the selection is redrawn over the background
         // rectangle
         //
-        //
         // The annotation background to be drawn is a span which has a begin and end offset.
         // Inside the background are areas (spans) which should not be over drawn. 
-        // That can be visualized like this:
+        // That can be visualized like this (annotation goes from first to last z, an 
+        // X is the selection which should not be overdrawn):
         //
         // zzzzXXXzzzzXXXXzzzXX
         //
@@ -98,7 +98,7 @@
         if (dontOverDrawSpans.size() > 0) {
 	        int zBegin = offset;
 	    	for (Span xSpan : dontOverDrawSpans) {
-	    	  if (xSpan.getLength()> 0 && zBegin < xSpan.getStart()) {
+	    	  if (xSpan.getLength() > 0 && zBegin < xSpan.getStart()) {
 	    		  Rectangle selectionBounds = textWidget.getTextBounds(zBegin, xSpan.getStart() -1);
 	    		  gc.fillRectangle(selectionBounds);
 	    	   }
@@ -123,7 +123,17 @@
 
         gc.setForeground(new Color(gc.getDevice(), 0, 0, 0));
         
-        gc.drawText(textWidget.getText(start, end), bounds.x, bounds.y, true);
+        // Instead of a tab draw textWidget.getTabs() spaces
+        String annotationText = textWidget.getText(start, end);
+        
+        if (annotationText.contains("\t")) {
+        	char replacementSpaces[] = new char[textWidget.getTabs()];
+        	for (int i = 0; i < replacementSpaces.length; i++) {
+        		replacementSpaces[i] = ' ';
+        	}
+        	annotationText = annotationText.replace(new String(new char[]{'\t'}), new String(replacementSpaces));
+        }
+        gc.drawText(annotationText, bounds.x, bounds.y, true);
       } 
       else {
         textWidget.redrawRange(offset, length, true);