Package org.apache.uima.cas.text

Examples of org.apache.uima.cas.text.AnnotationFS


      CAS cas = mInputDocument.getCAS();
     
      AnnotationIndex<AnnotationFS> index = cas.getAnnotationIndex(type);
     
      for (FSIterator<AnnotationFS> it = index.iterator(); it.hasNext(); ) {
        AnnotationFS annotation = it.next();
       
        if (annotation.getType().equals(type)) {
          typeNode.add(new AnnotationTreeNode(mInputDocument, annotation));
        }
      }
    }
View Full Code Here


    if (columnIndex != 0) {
      // ... just return null
      return null;
    }

    AnnotationFS annotation = (AnnotationFS) ((IAdaptable) element).getAdapter(AnnotationFS.class);

    if (annotation != null) {
      if (annotation.getCoveredText() != null)
        return getStringWithoutNewLine(annotation.getCoveredText());
      else
        return "";
    }
   
    Type type = (Type) ((IAdaptable) element).getAdapter(Type.class);
View Full Code Here

    ICasDocument document = editor.getDocument();
   
    CAS documentCAS = document.getCAS();

    AnnotationFS mergedAnnotation = documentCAS.createAnnotation(annotations.getFirst().getType(),
            annotations.getFirst().getBegin(), annotations.getLast().getEnd());

    document.removeFeatureStructures(annotations.toList());
    document.addFeatureStructure(mergedAnnotation);
  }
View Full Code Here

   */
  @Override
  public void run() {
    AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());

    AnnotationFS annotation = annotations.getFirst();

    lowerLeftAnnotationSide(editor.getDocument(), annotation);
  }
View Full Code Here

    // The box drawing strategy could be changed to do the drawing via
    // static methods
    annotationDrawingStyle.draw(annotation, gc, textWidget, offset, length, color);
   
    if (annotation instanceof EclipseAnnotationPeer) {
      AnnotationFS annotationFS = ((EclipseAnnotationPeer) annotation).getAnnotationFS();
     
      Feature feature = annotationFS.getType().getFeatureByBaseName(featureName);
     
      if (feature != null && feature.getRange().isPrimitive()) {
       
        String featureValue = annotationFS.getFeatureValueAsString(feature);
       
        // Annotation can be rendered into multiple lines, always draw
        // the tag in the first line where annotation starts
        if (featureValue != null && annotationFS.getBegin() == offset) {
         
          // Calculate how much overhang on both sides of the annotation for a tag is allowed
          int lineIndex = textWidget.getLineAtOffset(offset);
          int firstCharInLineOffset = textWidget.getOffsetAtLine(lineIndex);
         
View Full Code Here

  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(annotationFS.getCAS().getDocumentText(), 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(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);

            gc.drawLine(bounds.x + bounds.width - 1, bounds.y, bounds.x + bounds.width - 1,
                    bounds.y + bounds.height - 1);
View Full Code Here

   */
  @Override
  public void run() {
    AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());

    AnnotationFS annotation = annotations.getFirst();
   
    wideLeftAnnotationSide(editor.getDocument(), annotation);
  }
View Full Code Here

   
    // TODO: Build first a map, and then pass all annotations at once
    Map annotationsToAdd = new HashMap();
   
    while (mAnnotations.hasNext()) {
      AnnotationFS annotationFS = mAnnotations.next();
      annotationsToAdd.put(new EclipseAnnotationPeer(annotationFS), new Position(
              annotationFS.getBegin(), annotationFS.getEnd() - annotationFS.getBegin()));
    }
   
    ((IAnnotationModelExtension) annotationModel).replaceAnnotations(null, annotationsToAdd);
  }
View Full Code Here

      Collections.sort(selection, new AnnotationComparator());
    } else {
      Map<Integer, AnnotationFS> view = getView(getAnnotationMode());

      AnnotationFS annotation = view.get(getSourceViewer().getTextWidget().getCaretOffset());

      if (annotation == null) {
        annotation = view.get(mCursorPosition - 1);
      }
View Full Code Here

    Iterator<FeatureStructure> fsIter = cas2.getIndexRepository().getAllIndexedFS(referentType2);
    while (fsIter.hasNext()) {
      FeatureStructure fs = fsIter.next();
      view.getIndexRepository().addFS(fs);
    }
    AnnotationFS cas2newAnnot = view.createAnnotation(cas2.getAnnotationType(), 6, 8);
    view.getIndexRepository().addFS(cas2newAnnot);

    // serialize cas2 in delta format
    String deltaxml1 = serialize(cas2, sharedData2, marker);
    System.out.println(deltaxml1);
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.text.AnnotationFS

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.