You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by mb...@apache.org on 2007/07/16 13:41:13 UTC
svn commit: r556592 - in
/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor:
core/model/dotcorpus/AnnotationStyle.java editor/annotation/DrawingStyle.java
editor/annotation/TokenDrawingStrategy.java
Author: mbaessler
Date: Mon Jul 16 04:41:06 2007
New Revision: 556592
URL: http://svn.apache.org/viewvc?view=rev&rev=556592
Log:
UIMA-497
applied patch UIMA-497-2.patch
JIRA ticket https://issues.apache.org/jira/browse/UIMA-497
Added:
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.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=556592&r1=556591&r2=556592
==============================================================================
--- 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 Mon Jul 16 04:41:06 2007
@@ -34,6 +34,8 @@
TEXT_COLOR,
+ TOKEN,
+
/**
* 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=556592&r1=556591&r2=556592
==============================================================================
--- 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 Mon Jul 16 04:41:06 2007
@@ -28,6 +28,8 @@
TEXT_COLOR(new TextColorDrawingStrategy()),
+ TOKEN(new TokenDrawingStrategy()),
+
/**
* The squiggles {@link IDrawingStrategy}.
*/
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java?view=auto&rev=556592
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java Mon Jul 16 04:41:06 2007
@@ -0,0 +1,85 @@
+/*
+ * 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 TokenDrawingStrategy implements IDrawingStrategy {
+ private static final int BRACKET_WIDTH = 5;
+
+ private static boolean isWhitespace(StyledText textWidget, int offset) {
+
+ String characterString = textWidget.getText(offset, offset);
+
+ if (characterString.trim().length() == 0) {
+ return true;
+ }
+
+ return false;
+ }
+
+ 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) {
+ Rectangle bounds = textWidget.getTextBounds(offset, offset + length - 1);
+
+ gc.setForeground(color);
+
+ boolean isDrawOpenBracket = annotationFS.getBegin() == offset;
+ // and no space before offset
+ if (isDrawOpenBracket && offset > 1 && !isWhitespace(textWidget, offset - 1)) {
+ gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x + BRACKET_WIDTH, bounds.y
+ + bounds.height - 1);
+
+ gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
+
+ gc.drawLine(bounds.x, bounds.y, bounds.x + BRACKET_WIDTH, bounds.y);
+ }
+
+ boolean isDrawCloseBracket = annotationFS.getEnd() == offset + length;
+ // and no space after offset
+ if (isDrawCloseBracket && offset + length <= textWidget.getText().length()
+ && !isWhitespace(textWidget, offset + length)) {
+ gc.drawLine(bounds.x + bounds.width, bounds.y + bounds.height - 1, bounds.x
+ + bounds.width - BRACKET_WIDTH, bounds.y + bounds.height - 1);
+
+ gc.drawLine(bounds.x + bounds.width - 1, bounds.y, bounds.x + bounds.width - 1,
+ bounds.y + bounds.height - 1);
+
+ gc.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width - BRACKET_WIDTH,
+ bounds.y);
+ }
+ } else {
+ textWidget.redrawRange(offset, length, true);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file