You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2007/07/08 04:56:29 UTC

svn commit: r554305 - in /incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor: core/model/dotcorpus/AnnotationStyle.java editor/annotation/DrawingStyle.java editor/annotation/TextColorDrawingStrategy.java

Author: schor
Date: Sat Jul  7 19:56:28 2007
New Revision: 554305

URL: http://svn.apache.org/viewvc?view=rev&rev=554305
Log:
[UIMA-485] updated 2 files, added one new one.  For the new
one (TextColorDrawingStrategy) I also added the Apache
License -it was missing in the patch.

Added:
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/TextColorDrawingStrategy.java
Modified:
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyle.java
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/DrawingStyle.java

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyle.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyle.java?view=diff&rev=554305&r1=554304&r2=554305
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyle.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyle.java Sat Jul  7 19:56:28 2007
@@ -30,6 +30,9 @@
    * The styles that can be used to draw an annotation.
    */
   public enum Style {
+    
+    TEXT_COLOR,
+    
     /**
      * The squiggles style.
      */

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/DrawingStyle.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/DrawingStyle.java?view=diff&rev=554305&r1=554304&r2=554305
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/DrawingStyle.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/DrawingStyle.java Sat Jul  7 19:56:28 2007
@@ -25,6 +25,9 @@
  * An enumertation of all available {@link IDrawingStrategy}.
  */
 public enum DrawingStyle {
+  
+  TEXT_COLOR(new TextColorDrawingStrategy()),
+  
   /**
    * The squiggles {@link IDrawingStrategy}.
    */

Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/TextColorDrawingStrategy.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/TextColorDrawingStrategy.java?view=auto&rev=554305
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/TextColorDrawingStrategy.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/TextColorDrawingStrategy.java Sat Jul  7 19:56:28 2007
@@ -0,0 +1,59 @@
+/**
+ * 
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.annotation;
+
+import org.apache.uima.cas.text.AnnotationFS;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+
+/**
+ */
+public class TextColorDrawingStrategy implements IDrawingStrategy {
+
+  public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) {
+    if (length > 0) {
+      if ((annotation instanceof EclipseAnnotationPeer)) {
+        AnnotationFS annotationFS = ((EclipseAnnotationPeer) annotation).getAnnotationFS();
+
+        if (gc != null) {
+          
+          int start = offset;
+          int end = offset + length - 1;
+          
+          Rectangle bounds = textWidget.getTextBounds(start, end);
+
+          gc.setForeground(color);
+          
+          gc.drawText(textWidget.getText(start, end), bounds.x, bounds.y, true);
+          
+        } else {
+          textWidget.redrawRange(offset, length, true);
+        }
+      }
+    }
+  }
+}
\ No newline at end of file