in CasViewerEclipsePlugin/uimaj-ep-casviewer-core/src/main/java/org/apache/uima/casviewer/core/internal/CASObjectView.java [389:492]
private void processCasView ()
{
if (isProcessed) return;
isProcessed = true;
if (typesHavingAnnotations == null) {
typesHavingAnnotations = new ArrayList<Type> ();
} else {
typesHavingAnnotations.clear();
}
// Clear previous annotations
indexedAnnotationList.clear();
String doc = casView.getDocumentText();
if (doc == null) {
doc = "";
}
preProcessCasView ();
// Iterate over the default annotation index.
// Create a list "annotListPerType" of annotations for EACH type
List<AnnotationObject> annotListPerType = null;// For each type, list of its annotations
FSIterator iter = casView.getAnnotationIndex().iterator(); // Get the default annotation index.
while (iter.isValid())
{
// Get 1 annotation
AnnotationFS fs = (AnnotationFS) iter.get();
iter.moveToNext();
// Get the type of this annotation
Type type = fs.getType();
// PrintAnnotations.printFS((FeatureStructure) fs, mTCAS, 1, System.out);
int begin = fs.getBegin(); // start from 0
int end = fs.getEnd();
// if (begin != end && end == mTCAS.getDocumentText().length()) {
// end--;
// }
if (begin == end) {
// Skip 0-length annotations
// E.g., SourceDocumentInformation
continue;
}
// See this Type before ?
if ( ! typesHavingAnnotations.contains(type) ) {
// New Type for Annotations
// Check that this type should be displayed.
if ((visibleTypes != null && ! typeNamesContains(visibleTypes, type.getName()))
|| typeNamesContains(hiddenTypes, type.getName())) {
continue;
}
typesHavingAnnotations.add(type);
// Map type name -> Type
// typeName2TypeMap.put(type.getName(), type);
// Map type name -> annotation list
annotListPerType = new ArrayList<AnnotationObject>();
typeName2AnnotationsMap.put(type.getName(), annotListPerType);
} else {
// Existing Type. Get existing annotation list
annotListPerType = typeName2AnnotationsMap.get(type.getName());
}
// Select color for the type
// if (tsStyle != null) {
// typeStyle = tsStyle.getTypeStyle(type.getName());
// }
// Create new object for this type's annotation
// Try to reuse AnnotationObject created at somewhere
AnnotationObject newAnnot = createAnnotationObject(fs, begin, end, doc, 50);
annotListPerType.add(newAnnot);
// Sort Annotations (sortedAnnotationList) by BEGIN feature
// AnnotationObject annot;
// boolean done = false;
// Trace.trace("sortedAnnotationList:" + sortedAnnotationList.size());
indexedAnnotationList.add(newAnnot);
// Sorted ? Use order set by AnnotationIndexRepository
// addAnnotationToSortedList(indexedAnnotationList, newAnnot);
// if (type.getName().compareTo("uima.tcas.DocumentAnnotation") != 0 && begin != end) {
// // Trace.trace( type.getName() + "Begin: " + begin + " ; end: " + end);
// StyleRange styleRange = new StyleRange ();
// styleRange.foreground = styledTextDoc.getDisplay().getSystemColor(SWT.COLOR_BLUE);
// styleRange.start = begin;
// styleRange.length= end - begin;
// styledTextDoc.setStyleRange(styleRange);
// }
}
// for (int i=0; i<indexedAnnotationList.size(); ++i) {
// Annot annot = ((Annot) indexedAnnotationList.get(i));
// Trace.trace("annot: " + annot.type.getShortName() + "["
// + annot.begin + " , " + annot.end + "]");
// }
// Trace.trace("annotatedTypes.size(): " + annotatedTypes.size());
// Trace.trace("indexedAnnotationList.size(): " + indexedAnnotationList.size());
} // processAnnotatedTypes