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 2011/08/12 12:28:19 UTC
svn commit: r1157036 [2/5] - in /uima/sandbox/trunk/TextMarker/uimaj-ep-cev:
./ .settings/ META-INF/ icons/ lib/ schema/ src/ src/main/ src/main/java/
src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/uima/
src/main/java/org/apache/...
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVAnnotationRanges.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVAnnotationRanges.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVAnnotationRanges.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVAnnotationRanges.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,471 @@
+/*
+ * 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.cev.data;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.eclipse.swt.custom.StyleRange;
+
+public class CEVAnnotationRanges {
+
+ private class RangeInfo {
+ private int start;
+
+ private int end;
+
+ private CEVData casData;
+
+ private LinkedList<AnnotationFS> annotations;
+
+ private LinkedList<String> htmlIDs;
+
+ public RangeInfo(int start, int end, CEVData casData) {
+ this.start = start;
+ this.end = end;
+
+ this.casData = casData;
+
+ htmlIDs = new LinkedList<String>();
+
+ annotations = new LinkedList<AnnotationFS>();
+ }
+
+ public int getStart() {
+ return start;
+ }
+
+ public int getEnd() {
+ return end;
+ }
+
+ public void addHtmlID(String id) {
+ htmlIDs.add(id);
+ }
+
+ public LinkedList<String> getHtmlID() {
+ return htmlIDs;
+ }
+
+ public void addAnnotation(AnnotationFS annot) {
+ annotations.addFirst(annot);
+ }
+
+ public void removeAnnotation(AnnotationFS annot) {
+ annotations.remove(annot);
+ }
+
+ public AnnotationFS[] getAnnotations() {
+ return annotations.toArray(new AnnotationFS[annotations.size()]);
+ }
+
+ public AnnotationFS getActiveAnnotation() {
+ for (AnnotationFS a : annotations)
+ if (casData.isChecked(a))
+ return a;
+
+ return null;
+ }
+ }
+
+ public class StyleRangeContainer {
+ private int start;
+
+ private int end;
+
+ private LinkedList<Integer> indices;
+
+ private LinkedList<StyleRange> ranges;
+
+ private HashMap<Type, StyleRange> typeStyleRangeMap;
+
+ protected StyleRangeContainer() {
+ start = Integer.MAX_VALUE;
+ end = Integer.MIN_VALUE;
+
+ indices = new LinkedList<Integer>();
+ ranges = new LinkedList<StyleRange>();
+
+ typeStyleRangeMap = new HashMap<Type, StyleRange>();
+ }
+
+ protected void addRange(int start, int end, AnnotationFS annot) {
+ StyleRange styleRange = null;
+
+ if (typeStyleRangeMap.containsKey(annot.getType()))
+ styleRange = typeStyleRangeMap.get(annot.getType());
+ else {
+ styleRange = new StyleRange();
+ styleRange.foreground = casData.getForegroundColor(annot.getType());
+ styleRange.background = casData.getBackgroundColor(annot.getType());
+ typeStyleRangeMap.put(annot.getType(), styleRange);
+ }
+
+ indices.add(start);
+ indices.add(end - start);
+
+ ranges.add(styleRange);
+ }
+
+ protected void setStart(int start) {
+ this.start = start;
+ }
+
+ protected void setEnd(int end) {
+ this.end = end;
+ }
+
+ public int[] getIndices() {
+ int[] i = new int[indices.size()];
+ int c = 0;
+
+ Iterator<Integer> iter = indices.listIterator();
+
+ while (iter.hasNext())
+ i[c++] = iter.next();
+
+ return i;
+ }
+
+ public StyleRange[] getRanges() {
+ StyleRange[] r = new StyleRange[ranges.size()];
+ int c = 0;
+
+ Iterator<StyleRange> iter = ranges.listIterator();
+
+ while (iter.hasNext())
+ r[c++] = iter.next();
+
+ return r;
+ }
+
+ public int getStart() {
+ return start;
+ }
+
+ public int getEnd() {
+ return end;
+ }
+
+ public int getLength() {
+ return end - start;
+ }
+ }
+
+ public class HtmlIdInfo {
+ private int start;
+
+ private int end;
+
+ private String id;
+
+ public HtmlIdInfo(int start, int end, String id) {
+ this.start = start;
+ this.end = end;
+ this.id = id;
+ }
+
+ public int getStart() {
+ return start;
+ }
+
+ public int getEnd() {
+ return end;
+ }
+
+ public String getId() {
+ return id;
+ }
+ }
+
+ private CEVData casData;
+
+ private ArrayList<RangeInfo> ranges;
+
+ private HashMap<AnnotationFS, LinkedList<RangeInfo>> annotationRangeMap;
+
+ public CEVAnnotationRanges(CEVData casData) {
+ this.casData = casData;
+ ranges = new ArrayList<RangeInfo>();
+ annotationRangeMap = new HashMap<AnnotationFS, LinkedList<RangeInfo>>();
+
+ createAnnotationRanges();
+ }
+
+ private void createAnnotationRanges() {
+ // TODO refactor this method: it's too slow
+
+ Iterator<AnnotationFS> iter = casData.getAnnotationIterator();
+ LinkedList<AnnotationFS> annotations = new LinkedList<AnnotationFS>();
+
+ int[] pos = new int[casData.getAnnotationsCount() * 2];
+
+ int i = 0;
+
+ while (iter.hasNext()) {
+ AnnotationFS annot = iter.next();
+ annotations.add(annot);
+
+ pos[i++] = annot.getBegin();
+ pos[i++] = annot.getEnd();
+ }
+
+ Arrays.sort(pos);
+
+ int s = 0;
+ int e = 1;
+
+ while (e < pos.length) {
+ if (pos[s] == pos[e]) {
+ e++;
+ continue;
+ }
+
+ RangeInfo ri = new RangeInfo(pos[s], pos[e], casData);
+ int count = 0;
+
+ ListIterator<AnnotationFS> listIter = annotations.listIterator();
+
+ while (listIter.hasNext()) {
+ AnnotationFS annot = listIter.next();
+
+ if (annot.getBegin() <= pos[s] && annot.getEnd() >= pos[e]) {
+ ri.addAnnotation(annot);
+ count++;
+
+ if (!annotationRangeMap.containsKey(annot))
+ annotationRangeMap.put(annot, new LinkedList<RangeInfo>());
+
+ annotationRangeMap.get(annot).add(ri);
+ }
+
+ if (annot.getEnd() <= pos[e])
+ listIter.remove();
+ }
+
+ s = e;
+ e += 1;
+
+ if (count > 0)
+ ranges.add(ri);
+ }
+ }
+
+ public void addAnnotation(AnnotationFS annot) {
+ List<RangeInfo> ris = getAnnotationRanges(annot, true);
+ for (RangeInfo each : ris) {
+ each.addAnnotation(annot);
+ }
+ }
+
+ private List<RangeInfo> getAnnotationRanges(AnnotationFS annot, boolean add) {
+ List<RangeInfo> result = new ArrayList<RangeInfo>();
+ boolean beginFound = false;
+ boolean endFound = false;
+ for (RangeInfo each : ranges) {
+
+ if (each.getStart() == annot.getBegin()) {
+ beginFound = true;
+ }
+ if (each.getEnd() == annot.getEnd()) {
+ endFound = true;
+ }
+ if (each.getStart() > annot.getEnd()) {
+ break;
+ }
+ }
+
+ if (!beginFound) {
+ for (RangeInfo each : new ArrayList<RangeInfo>(ranges)) {
+ if (each.getStart() < annot.getBegin() && each.getEnd() > annot.getBegin()) {
+ RangeInfo newLeft = new RangeInfo(each.getStart(), annot.getBegin(), casData);
+ RangeInfo newRight = new RangeInfo(annot.getBegin(), each.getEnd(), casData);
+ int indexOf = ranges.indexOf(each);
+ ranges.remove(indexOf);
+ ranges.add(indexOf, newRight);
+ ranges.add(indexOf, newLeft);
+ }
+ }
+ }
+
+ if (!endFound) {
+ for (RangeInfo each : new ArrayList<RangeInfo>(ranges)) {
+ if (each.getStart() < annot.getEnd() && each.getEnd() > annot.getEnd()) {
+ RangeInfo newLeft = new RangeInfo(each.getStart(), annot.getEnd(), casData);
+ RangeInfo newRight = new RangeInfo(annot.getEnd(), each.getEnd(), casData);
+ int indexOf = ranges.indexOf(each);
+ ranges.remove(indexOf);
+ ranges.add(indexOf, newRight);
+ ranges.add(indexOf, newLeft);
+ }
+ }
+ }
+
+ for (RangeInfo each : ranges) {
+ if (each.getStart() >= annot.getBegin() && each.getEnd() <= annot.getEnd()) {
+ result.add(each);
+ }
+ if (each.getStart() > annot.getEnd()) {
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ public void removeAnnotation(AnnotationFS annot) {
+ List<RangeInfo> ris = getAnnotationRanges(annot, false);
+ for (RangeInfo each : ris) {
+ each.removeAnnotation(annot);
+ }
+ }
+
+ public StyleRangeContainer getAllStyleRanges() {
+ StyleRangeContainer sc = new StyleRangeContainer();
+
+ int start = Integer.MAX_VALUE;
+ int end = Integer.MIN_VALUE;
+
+ boolean ok = false;
+
+ for (RangeInfo r : ranges) {
+ AnnotationFS annot = r.getActiveAnnotation();
+
+ if (annot != null)
+ sc.addRange(r.getStart(), r.getEnd(), annot);
+
+ if (r.getStart() < start)
+ start = r.getStart();
+
+ if (r.getEnd() > end)
+ end = r.getEnd();
+
+ ok = true;
+ }
+
+ if (!ok) {
+ start = 0;
+ end = 0;
+ }
+
+ sc.setStart(start);
+ sc.setEnd(end);
+ return sc;
+ }
+
+ public StyleRangeContainer getStyleRangesForAAnnotation(AnnotationFS annot) {
+ StyleRangeContainer sc = new StyleRangeContainer();
+ int start = Integer.MAX_VALUE;
+ int end = Integer.MIN_VALUE;
+
+ boolean ok = false;
+
+ if (annotationRangeMap.containsKey(annot))
+ for (RangeInfo r : annotationRangeMap.get(annot)) {
+ AnnotationFS a = r.getActiveAnnotation();
+
+ if (a != null)
+ sc.addRange(r.getStart(), r.getEnd(), a);
+
+ if (r.getStart() < start)
+ start = r.getStart();
+
+ if (r.getEnd() > end)
+ end = r.getEnd();
+
+ ok = true;
+ }
+
+ if (!ok) {
+ start = 0;
+ end = 0;
+ }
+
+ sc.setStart(start);
+ sc.setEnd(end);
+ return sc;
+ }
+
+ public Map<String, Type> getAllHtmlIdsAndActiveTypes() {
+ TreeMap<String, Type> map = new TreeMap<String, Type>();
+
+ for (RangeInfo r : ranges) {
+ if (r.getHtmlID().size() > 0) {
+ AnnotationFS a = r.getActiveAnnotation();
+ Type t = null;
+ if (a != null)
+ t = a.getType();
+
+ for (String id : r.getHtmlID())
+ map.put(id, t);
+ }
+ }
+
+ return map;
+ }
+
+ public Map<String, Type> getHtmlIdsAndActiveTypesForAAnnotation(AnnotationFS annot) {
+ TreeMap<String, Type> map = new TreeMap<String, Type>();
+
+ if (annotationRangeMap.containsKey(annot))
+ for (RangeInfo r : annotationRangeMap.get(annot)) {
+ if (r.getHtmlID().size() > 0) {
+ AnnotationFS a = r.getActiveAnnotation();
+ Type t = null;
+ if (a != null)
+ t = a.getType();
+
+ for (String id : r.getHtmlID())
+ map.put(id, t);
+ }
+ }
+
+ return map;
+ }
+
+ public LinkedList<HtmlIdInfo> createHtmlIDs(int start, int end) {
+ LinkedList<HtmlIdInfo> list = new LinkedList<HtmlIdInfo>();
+
+ for (RangeInfo ri : ranges) {
+ if ((ri.getStart() >= start && ri.getEnd() <= end)
+ || (ri.getStart() < start && ri.getEnd() > start)
+ || (ri.getStart() < end && ri.getEnd() > end)) {
+ String id = casData.getNextHtmlID();
+ ri.addHtmlID(id);
+
+ int s = start < ri.getStart() ? ri.getStart() : start;
+ int e = end > ri.getEnd() ? ri.getEnd() : end;
+
+ list.add(new HtmlIdInfo(s, e, id));
+ }
+ }
+
+ return list;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVAnnotationRanges.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVAnnotationRanges.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVData.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVData.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVData.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVData.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,657 @@
+/*
+ * 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.cev.data;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.FSIndex;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.cev.CEVPlugin;
+import org.apache.uima.cev.data.CEVAnnotationRanges.StyleRangeContainer;
+import org.apache.uima.cev.data.tree.CEVAnnotationTreeNode;
+import org.apache.uima.cev.data.tree.CEVTypeOrderedRootTreeNode;
+import org.apache.uima.cev.data.tree.CEVTypeTreeNode;
+import org.apache.uima.cev.data.tree.ICEVAnnotationNode;
+import org.apache.uima.cev.data.tree.ICEVRootTreeNode;
+import org.apache.uima.cev.preferences.CEVPreferenceConstants;
+import org.apache.uima.tools.stylemap.StyleMapEntry;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.PaletteData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+public class CEVData implements ICheckStateListener/* , ProgressListener */{
+
+ private static final int[] COLOR_NR = new int[] { SWT.COLOR_BLUE, SWT.COLOR_CYAN, SWT.COLOR_GRAY,
+ SWT.COLOR_GREEN, SWT.COLOR_MAGENTA, SWT.COLOR_RED, SWT.COLOR_YELLOW, SWT.COLOR_DARK_BLUE,
+ SWT.COLOR_DARK_CYAN, SWT.COLOR_DARK_GRAY, SWT.COLOR_DARK_GREEN, SWT.COLOR_DARK_MAGENTA,
+ SWT.COLOR_DARK_RED, SWT.COLOR_DARK_YELLOW };
+
+ private CAS cas;
+
+ private HashSet<ICEVAnnotationListener> annotListeners;
+
+ private ArrayList<Type> indexedTypes;
+
+ private ArrayList<AnnotationFS> annotations;
+
+ private HashMap<Type, Color> fgColors;
+
+ private HashMap<Type, Color> bgColors;
+
+ private HashMap<Type, Image> icons;
+
+ private HashMap<Type, HashMap<AnnotationFS, Boolean>> annotationState;
+
+ private HashMap<Type, Integer> annotationStateCount;
+
+ public String htmlText;
+
+ public LinkedHashMap<String, int[]> htmlElementPos;
+
+ public String idName;
+
+ public int idCount;
+
+ public CEVAnnotationRanges annotationRanges;
+
+ private Map<String, ICEVDataExtension> extensions;
+
+ public CEVData(CAS cas, Map<String, StyleMapEntry> style) {
+ this.cas = cas;
+
+ extensions = new HashMap<String, ICEVDataExtension>();
+
+ fgColors = new HashMap<Type, Color>();
+ bgColors = new HashMap<Type, Color>();
+
+ icons = new HashMap<Type, Image>();
+
+ annotationState = new HashMap<Type, HashMap<AnnotationFS, Boolean>>();
+ annotationStateCount = new HashMap<Type, Integer>();
+ indexedTypes = new ArrayList<Type>();
+ annotations = new ArrayList<AnnotationFS>();
+ annotListeners = new HashSet<ICEVAnnotationListener>();
+
+ initializeAnnotations(style);
+
+ annotationRanges = new CEVAnnotationRanges(this);
+ }
+
+ public void addExtension(String name, ICEVDataExtension extension) {
+ extensions.put(name, extension);
+ }
+
+ private void initializeAnnotations(Map<String, StyleMapEntry> style) {
+ IPreferenceStore store = CEVPlugin.getDefault().getPreferenceStore();
+ String filter = store.getString(CEVPreferenceConstants.P_ANNOTATION_FILTER);
+
+ int i = 0;
+
+ TypeSystem typeSystem = cas.getTypeSystem();
+ Iterator<Type> tIter = typeSystem.getTypeIterator();
+ while (tIter.hasNext()) {
+ Type t = tIter.next();
+
+ if (!t.getName().matches(filter) && typeSystem.subsumes(cas.getAnnotationType(), t)) {
+ indexedTypes.add(t);
+
+ if (style != null && style.containsKey(t.getName())) {
+ StyleMapEntry se = style.get(t.getName());
+ bgColors.put(t, new Color(Display.getCurrent(), se.getBackground().getRed(), se
+ .getBackground().getGreen(), se.getBackground().getBlue()));
+ fgColors.put(t, new Color(Display.getCurrent(), se.getForeground().getRed(), se
+ .getForeground().getGreen(), se.getForeground().getBlue()));
+ } else {
+ RGB rgb = Display.getCurrent().getSystemColor(COLOR_NR[i++ % COLOR_NR.length]).getRGB();
+ int sum = rgb.blue + rgb.green + rgb.red;
+ int max = Math.max(Math.max(rgb.blue, rgb.green), rgb.red);
+ bgColors.put(t, new Color(Display.getCurrent(), rgb));
+ if (sum < 255 || max < 129) {
+ fgColors.put(
+ t,
+ new Color(Display.getCurrent(), Display.getCurrent()
+ .getSystemColor(SWT.COLOR_WHITE).getRGB()));
+ } else {
+ fgColors.put(
+ t,
+ new Color(Display.getCurrent(), Display.getCurrent()
+ .getSystemColor(SWT.COLOR_BLACK).getRGB()));
+ }
+ }
+
+ annotationState.put(t, new HashMap<AnnotationFS, Boolean>());
+ annotationStateCount.put(t, 0);
+ }
+ }
+
+ Collections.sort(indexedTypes, new Comparator<Type>() {
+ public int compare(Type o1, Type o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+
+ FSIndex anIndex = cas.getAnnotationIndex();
+ FSIterator anIter = anIndex.iterator();
+
+ while (anIter.isValid()) {
+ AnnotationFS annot = (AnnotationFS) anIter.get();
+ if (annotationState.containsKey(annot.getType())) {
+ boolean show = false;
+ if (style != null) {
+ StyleMapEntry se = style.get(annot.getType().getName());
+ if (se != null) {
+ show = se.getChecked();
+ }
+ }
+ annotations.add(annot);
+ annotationState.get(annot.getType()).put(annot, show);
+ if (show) {
+ annotationStateCount.put(annot.getType(), annotationStateCount.get(annot.getType()) + 1);
+ }
+
+ }
+
+ anIter.moveToNext();
+ }
+ }
+
+ public CAS getCAS() {
+ return cas;
+ }
+
+ public String getDocumentText() {
+ return cas.getDocumentText();
+ }
+
+ public String getViewName() {
+ return cas.getViewName();
+ }
+
+ public int getAnnotationsCount() {
+ return annotations.size();
+ }
+
+ public AnnotationFS[] getAnnotations() {
+ return annotations.toArray(new AnnotationFS[annotations.size()]);
+ }
+
+ public Iterator<AnnotationFS> getAnnotationIterator() {
+ return annotations.iterator();
+ }
+
+ public String getHTMLSource() {
+ return htmlText;
+ }
+
+ public Color getForegroundColor(Type type) {
+ return fgColors.get(type);
+ }
+
+ public String getHtmlForegroundColor(Type type) {
+ Color c = fgColors.get(type);
+
+ String rH = Integer.toHexString(c.getRed());
+ if (rH.length() == 1)
+ rH = 0 + rH;
+
+ String gH = Integer.toHexString(c.getGreen());
+ if (gH.length() == 1)
+ gH = 0 + gH;
+
+ String bH = Integer.toHexString(c.getBlue());
+ if (bH.length() == 1)
+ bH = 0 + bH;
+
+ return "#" + rH + gH + bH;
+ }
+
+ public void setForegroundColor(Type type, Color color) {
+ Color oldColor = fgColors.get(type);
+ Image oldIcon = icons.get(type);
+
+ fgColors.put(type, color);
+ icons.put(type, null);
+
+ annotationColorChanged(type);
+
+ if (oldColor != null)
+ oldColor.dispose();
+
+ if (oldIcon != null)
+ oldIcon.dispose();
+ }
+
+ public Color getBackgroundColor(Type type) {
+ return bgColors.get(type);
+ }
+
+ public String getHtmlBackgroundColor(Type type) {
+ Color c = bgColors.get(type);
+
+ String rH = Integer.toHexString(c.getRed());
+ if (rH.length() == 1)
+ rH = 0 + rH;
+
+ String gH = Integer.toHexString(c.getGreen());
+ if (gH.length() == 1)
+ gH = 0 + gH;
+
+ String bH = Integer.toHexString(c.getBlue());
+ if (bH.length() == 1)
+ bH = 0 + bH;
+
+ return "#" + rH + gH + bH;
+ }
+
+ public void setBackgroundColor(Type type, Color color) {
+ Color oldColor = bgColors.get(type);
+ Image oldIcon = icons.get(type);
+
+ bgColors.put(type, color);
+ icons.put(type, null);
+
+ annotationColorChanged(type);
+
+ if (oldColor != null)
+ oldColor.dispose();
+
+ if (oldIcon != null)
+ oldIcon.dispose();
+ }
+
+ public Image getIcon(Type type) {
+
+ if (!icons.containsKey(type) || icons.get(type) == null) {
+ Color fg = getForegroundColor(type);
+ Color bg = getBackgroundColor(type);
+
+ if (fg == null || bg == null) {
+ return null;
+ }
+
+ PaletteData paletteData = new PaletteData(new RGB[] { bg.getRGB(), fg.getRGB() });
+ ImageData imageData = new ImageData(40, 40, 1, paletteData);
+
+ Image image = new Image(Display.getCurrent(), imageData);
+ GC gc = new GC(image);
+ Point p = gc.stringExtent("A");
+
+ gc.dispose();
+ image.dispose();
+
+ imageData = new ImageData(p.x + 4, p.y, 1, paletteData);
+ image = new Image(Display.getCurrent(), imageData);
+ gc = new GC(image);
+
+ gc.setBackground(bg);
+ gc.setForeground(fg);
+
+ gc.setTextAntialias(SWT.ON);
+ gc.drawString("A", 2, 0);
+
+ gc.dispose();
+
+ icons.put(type, image);
+
+ return image;
+ }
+
+ return icons.get(type);
+ }
+
+ public boolean isChecked(AnnotationFS annotation) {
+ if (annotationState.containsKey(annotation.getType())) {
+ HashMap<AnnotationFS, Boolean> map = annotationState.get(annotation.getType());
+ if (map.containsKey(annotation))
+ return map.get(annotation);
+ }
+
+ return false;
+ }
+
+ public boolean isChecked(Type type) {
+ return (annotationState.containsKey(type) && (annotationStateCount.get(type) == annotationState
+ .get(type).size()));
+ }
+
+ public boolean isGrayed(Type type) {
+ return (annotationState.containsKey(type) && (annotationStateCount.get(type) > 0) && (annotationStateCount
+ .get(type) < annotationState.get(type).size()));
+ }
+
+ public String[] getTypeNames() {
+ String[] names = new String[indexedTypes.size()];
+
+ for (int i = 0; i < names.length; i++) {
+ names[i] = indexedTypes.get(i).getName();
+ }
+
+ return names;
+ }
+
+ public Type getTypeByIndex(int index) {
+ if (index >= 0 && index < indexedTypes.size())
+ return indexedTypes.get(index);
+
+ return null;
+ }
+
+ public void removeAnnotation(AnnotationFS annot) {
+ if (annotationState.containsKey(annot.getType())
+ && annotationState.get(annot.getType()).containsKey(annot)) {
+
+ annotationRanges.removeAnnotation(annot);
+ if (annotationState.get(annot.getType()).get(annot)) {
+ annotationState.get(annot.getType()).put(annot, false);
+ annotationStateCount.put(annot.getType(), annotationStateCount.get(annot.getType()) - 1);
+
+ }
+
+ cas.removeFsFromIndexes(annot);
+
+ annotationState.get(annot.getType()).remove(annot);
+
+ annotations.remove(annot);
+
+ annotationStateChanged(annot);
+
+ List<AnnotationFS> annots = new ArrayList<AnnotationFS>();
+ annots.add(annot);
+ for (ICEVAnnotationListener l : annotListeners)
+ l.annotationsRemoved(annots);
+ }
+ }
+
+ public void removeAnnotations(AnnotationFS[] annots) {
+ for (AnnotationFS annot : annots) {
+
+ if (annotationState.containsKey(annot.getType())
+ && annotationState.get(annot.getType()).containsKey(annot)) {
+
+ if (annotationState.get(annot.getType()).get(annot)) {
+ annotationState.get(annot.getType()).put(annot, false);
+ annotationStateCount.put(annot.getType(), annotationStateCount.get(annot.getType()) - 1);
+ annotationStateChanged(annot);
+ }
+
+ cas.removeFsFromIndexes(annot);
+
+ annotationState.get(annot.getType()).remove(annot);
+
+ annotations.remove(annot);
+ annotationRanges.removeAnnotation(annot);
+ }
+ }
+ for (ICEVAnnotationListener l : annotListeners) {
+ l.annotationsRemoved(Arrays.asList(annots));
+ }
+ }
+
+ public void addAnnotation(Type type, int start, int end, boolean update) {
+ AnnotationFS annot = cas.createAnnotation(type, start, end);
+ addAnnotation(annot, update);
+ }
+
+ public void addAnnotation(AnnotationFS annotation, boolean update) {
+ cas.addFsToIndexes(annotation);
+ annotationRanges.addAnnotation(annotation);
+ boolean show = isChecked(annotation.getType());
+ annotationState.get(annotation.getType()).put(annotation, show);
+ annotations.add(annotation);
+ if (show) {
+ annotationStateCount.put(annotation.getType(),
+ annotationStateCount.get(annotation.getType()) + 1);
+ annotationStateChanged(annotation);
+ }
+ if (update) {
+ for (ICEVDataExtension each : extensions.values()) {
+ each.initialize();
+ }
+ }
+ List<AnnotationFS> annots = new ArrayList<AnnotationFS>();
+ annots.add(annotation);
+ for (ICEVAnnotationListener l : annotListeners) {
+ l.annotationsAdded(annots);
+ }
+ }
+
+ public void addAnnotationListener(ICEVAnnotationListener listener) {
+ annotListeners.add(listener);
+ }
+
+ public void removeAnnotationListener(ICEVAnnotationListener listener) {
+ annotListeners.remove(listener);
+ }
+
+ public void annotationStateChanged(Type type) {
+ for (ICEVAnnotationListener l : annotListeners)
+ l.annotationStateChanged(type);
+ }
+
+ public void annotationStateChanged(AnnotationFS annot) {
+ for (ICEVAnnotationListener l : annotListeners)
+ l.annotationStateChanged(annot);
+ }
+
+ public void annotationColorChanged(Type type) {
+ for (ICEVAnnotationListener l : annotListeners)
+ l.colorChanged(type);
+ }
+
+ public ICEVRootTreeNode getTypeOrderedTree(String manualFilter) {
+ CEVTypeOrderedRootTreeNode root = new CEVTypeOrderedRootTreeNode();
+ Iterator<AnnotationFS> iter = getAnnotationIterator();
+ while (iter.hasNext()) {
+ AnnotationFS next = iter.next();
+ if (manualFilter == null || "".equals(manualFilter)
+ || next.getType().getName().indexOf(manualFilter) != -1) {
+ root.insertFS(next);
+ }
+ }
+ root.sort();
+ return root;
+ }
+
+ public ICEVRootTreeNode getAnnotationOrderedTree(String manualFilter) {
+ CEVTypeOrderedRootTreeNode root = new CEVTypeOrderedRootTreeNode();
+
+ Iterator<AnnotationFS> iter = getAnnotationIterator();
+
+ while (iter.hasNext()) {
+ AnnotationFS next = iter.next();
+ if (manualFilter == null || "".equals(manualFilter)
+ || next.getType().getName().indexOf(manualFilter) != -1) {
+ root.insertFS(next);
+ }
+ }
+ root.sort();
+
+ return root;
+ }
+
+ public ICEVRootTreeNode getAnnotationOrderedTree(int pos, String manualFilter) {
+ CEVTypeOrderedRootTreeNode root = new CEVTypeOrderedRootTreeNode();
+
+ Iterator<AnnotationFS> iter = getAnnotationIterator();
+
+ while (iter.hasNext()) {
+ AnnotationFS next = iter.next();
+ if (manualFilter == null || "".equals(manualFilter)
+ || next.getType().getName().indexOf(manualFilter) != -1) {
+ if (next.getBegin() <= pos && next.getEnd() >= pos) {
+ root.insertFS(next);
+ }
+ }
+ }
+
+ root.sort();
+
+ return root;
+ }
+
+ public List<AnnotationFS> getAnnotationsAt(int pos) {
+ List<AnnotationFS> result = new ArrayList<AnnotationFS>();
+ Iterator<AnnotationFS> iter = getAnnotationIterator();
+
+ while (iter.hasNext()) {
+ AnnotationFS next = iter.next();
+ if (next.getBegin() <= pos && next.getEnd() >= pos) {
+ result.add(next);
+ }
+ }
+ return result;
+ }
+
+ public void dispose() {
+ for (Color c : fgColors.values()) {
+ c.dispose();
+ }
+ for (Color c : bgColors.values()) {
+ c.dispose();
+ }
+ for (Image i : icons.values()) {
+ i.dispose();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse
+ * .jface.viewers.CheckStateChangedEvent)
+ */
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ Object element = event.getElement();
+ if (element instanceof CEVAnnotationTreeNode) {
+ AnnotationFS annot = ((CEVAnnotationTreeNode) element).getAnnotation();
+
+ if (annotationState.containsKey(annot.getType())) {
+ HashMap<AnnotationFS, Boolean> map = annotationState.get(annot.getType());
+ if (map.containsKey(annot)) {
+ map.put(annot, event.getChecked());
+
+ int count = annotationStateCount.get(annot.getType());
+
+ if (event.getChecked())
+ count++;
+ else
+ count--;
+
+ annotationStateCount.put(annot.getType(), count);
+ annotationStateChanged(annot);
+ }
+ }
+ } else if (element instanceof CEVTypeTreeNode) {
+ Type type = ((CEVTypeTreeNode) element).getType();
+
+ if (annotationState.containsKey(type)) {
+ HashMap<AnnotationFS, Boolean> map = annotationState.get(type);
+ for (AnnotationFS a : map.keySet())
+ map.put(a, event.getChecked());
+
+ if (event.getChecked())
+ annotationStateCount.put(type, map.size());
+ else
+ annotationStateCount.put(type, 0);
+
+ if (!map.isEmpty())
+ annotationStateChanged(type);
+ }
+ } else if (element instanceof ICEVAnnotationNode) {
+ AnnotationFS annot = ((ICEVAnnotationNode) element).getAnnotation();
+
+ if (annotationState.containsKey(annot.getType())) {
+ HashMap<AnnotationFS, Boolean> map = annotationState.get(annot.getType());
+ if (map.containsKey(annot)) {
+ map.put(annot, event.getChecked());
+ int count = annotationStateCount.get(annot.getType());
+ if (event.getChecked())
+ count++;
+ else
+ count--;
+ annotationStateCount.put(annot.getType(), count);
+ annotationStateChanged(annot);
+ }
+ }
+ }
+ }
+
+ public StyleRangeContainer getAllStyleRanges() {
+ return annotationRanges.getAllStyleRanges();
+ }
+
+ public StyleRangeContainer getStyleRangesForAAnnotation(AnnotationFS annot) {
+ return annotationRanges.getStyleRangesForAAnnotation(annot);
+ }
+
+ public Map<String, Type> getAllHtmlIdsAndActiveTypes() {
+ return annotationRanges.getAllHtmlIdsAndActiveTypes();
+ }
+
+ public Map<String, Type> getHtmlIdsAndActiveTypesForAAnnotation(AnnotationFS annot) {
+ return annotationRanges.getHtmlIdsAndActiveTypesForAAnnotation(annot);
+ }
+
+ public String getNextHtmlID() {
+ return idName + idCount++;
+ }
+
+ public boolean containsHtmlId(String id) {
+ return htmlElementPos.containsKey(id);
+ }
+
+ public int[] getHtmlElementPos(String id) {
+ if (htmlElementPos.containsKey(id))
+ return htmlElementPos.get(id);
+
+ return null;
+ }
+
+ public HashMap<Type, Integer> getAnnotationStateCount() {
+ return annotationStateCount;
+ }
+
+ public HashMap<Type, HashMap<AnnotationFS, Boolean>> getAnnotationState() {
+ return annotationState;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVData.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVData.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVDocument.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVDocument.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVDocument.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVDocument.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,153 @@
+/*
+ * 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.cev.data;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.impl.XmiCasDeserializer;
+import org.apache.uima.cev.CEVPlugin;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceManager;
+import org.apache.uima.resource.metadata.FsIndexDescription;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.tools.stylemap.StyleMapEntry;
+import org.apache.uima.util.CasCreationUtils;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.xml.sax.SAXException;
+
+public class CEVDocument {
+
+ private ArrayList<CEVData> casData;
+
+ private CAS mainCAS;
+
+ private Object descriptor;
+
+ private Map<String, StyleMapEntry> style;
+
+ public CEVDocument(IFile descriptorFile, IFile casFile) throws IllegalArgumentException,
+ IOException, InvalidXMLException, SAXException, ResourceInitializationException {
+
+ casData = new ArrayList<CEVData>();
+
+ descriptor = UIMAFramework.getXMLParser().parse(
+ new XMLInputSource(descriptorFile.getLocation().toFile()));
+
+ mainCAS = null;
+
+ if (descriptor instanceof AnalysisEngineDescription) {
+ mainCAS = CasCreationUtils.createCas((AnalysisEngineDescription) descriptor);
+ } else if (descriptor instanceof TypeSystemDescription) {
+ TypeSystemDescription tsDesc = (TypeSystemDescription) descriptor;
+ ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
+ IProject project = descriptorFile.getProject();
+ IFolder folder = project.getFolder("descriptor");
+ resMgr.setDataPath(folder.getLocation().toPortableString());
+ tsDesc.resolveImports(resMgr);
+ mainCAS = CasCreationUtils.createCas(tsDesc, null, new FsIndexDescription[0]);
+ } else {
+ throw new IllegalArgumentException("Invalid Type System Descriptor");
+ }
+
+ FileInputStream inputStream = null;
+ try {
+ inputStream = new FileInputStream(casFile.getLocation().toFile());
+ XmiCasDeserializer.deserialize(inputStream, mainCAS, true);
+ } finally {
+ if (inputStream != null)
+ inputStream.close();
+ }
+
+ try {
+ String desc = descriptorFile.getFullPath().removeFileExtension().lastSegment();
+ if (desc.toLowerCase().endsWith("typesystem")) {
+ desc = desc.substring(0, desc.length() - 10);
+ }
+ String styleMap = desc.toLowerCase() + "stylemap.xml";
+
+ for (IResource r : descriptorFile.getParent().members())
+ if (r.getType() == IResource.FILE && r.getFullPath().lastSegment().startsWith(desc)
+ && r.getFullPath().lastSegment().toLowerCase().equals(styleMap)) {
+
+ style = StyleMapReader.parseStyleMapDOM(r.getLocation().toOSString());
+ break;
+ }
+
+ } catch (CoreException e) {
+ CEVPlugin.error(e);
+ }
+
+ Iterator viewIter = mainCAS.getViewIterator();
+
+ while (viewIter.hasNext())
+ casData.add(new CEVData((CAS) viewIter.next(), getStyleMap()));
+ }
+
+ public int count() {
+ return casData.size();
+ }
+
+ public CEVData getCASData(int index) throws IndexOutOfBoundsException {
+ return casData.get(index);
+ }
+
+ public CEVData[] getCASData() {
+ return casData.toArray(new CEVData[casData.size()]);
+ }
+
+ public CAS getMainCas() {
+ return mainCAS;
+ }
+
+ public void dispose() {
+ for (CEVData each : casData) {
+ each.dispose();
+ }
+ }
+
+ public CAS createCas() throws ResourceInitializationException, InvalidXMLException {
+ if (descriptor instanceof AnalysisEngineDescription) {
+ return CasCreationUtils.createCas((AnalysisEngineDescription) descriptor);
+ } else if (descriptor instanceof TypeSystemDescription) {
+ TypeSystemDescription tsDesc = (TypeSystemDescription) descriptor;
+ tsDesc.resolveImports();
+ return CasCreationUtils.createCas(tsDesc, null, new FsIndexDescription[0]);
+ } else {
+ throw new IllegalArgumentException("Invalid Type System Descriptor");
+ }
+ }
+
+ public Map<String, StyleMapEntry> getStyleMap() {
+ return style;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVDocument.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/CEVDocument.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationListener.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationListener.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationListener.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationListener.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,38 @@
+/*
+ * 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.cev.data;
+
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+
+public interface ICEVAnnotationListener {
+
+ public void annotationsAdded(List<AnnotationFS> annots);
+
+ public void annotationsRemoved(List<AnnotationFS> annots);
+
+ public void colorChanged(Type type);
+
+ public void annotationStateChanged(Type type);
+
+ public void annotationStateChanged(AnnotationFS annot);
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationListener.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationSelectionListener.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationSelectionListener.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationSelectionListener.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationSelectionListener.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,25 @@
+/*
+ * 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.cev.data;
+
+public interface ICEVAnnotationSelectionListener {
+
+ public void newSelection(int offset);
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationSelectionListener.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVAnnotationSelectionListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVDataExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVDataExtension.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVDataExtension.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVDataExtension.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,26 @@
+/*
+ * 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.cev.data;
+
+public interface ICEVDataExtension {
+
+ void initialize();
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVDataExtension.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/ICEVDataExtension.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/StyleMapReader.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/StyleMapReader.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/StyleMapReader.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/StyleMapReader.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,254 @@
+/*
+ * 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.cev.data;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.uima.cev.CEVPlugin;
+import org.apache.uima.tools.stylemap.StyleMapEntry;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.SAXException;
+
+public class StyleMapReader {
+
+ public static final Map<String, String> COLOR_NAME_MAP;
+
+ static {
+ COLOR_NAME_MAP = new HashMap<String, String>();
+ COLOR_NAME_MAP.put("#000000", "black");
+ COLOR_NAME_MAP.put("#c0c0c0", "silver");
+ COLOR_NAME_MAP.put("#808080", "gray");
+ COLOR_NAME_MAP.put("#ffffff", "white");
+ COLOR_NAME_MAP.put("#800000", "maroon");
+ COLOR_NAME_MAP.put("#ff0000", "red");
+ COLOR_NAME_MAP.put("#800080", "purple");
+ COLOR_NAME_MAP.put("#ff00ff", "fuchsia");
+ COLOR_NAME_MAP.put("#008000", "green");
+ COLOR_NAME_MAP.put("#00ff00", "lime");
+ COLOR_NAME_MAP.put("#808000", "olive");
+ COLOR_NAME_MAP.put("#ffff00", "yellow");
+ COLOR_NAME_MAP.put("#000080", "navy");
+ COLOR_NAME_MAP.put("#0000ff", "blue");
+ COLOR_NAME_MAP.put("#00ffff", "aqua");
+ COLOR_NAME_MAP.put("#000000", "black");
+ COLOR_NAME_MAP.put("#add8e6", "lightblue");
+ COLOR_NAME_MAP.put("#90ee90", "lightgreen");
+ COLOR_NAME_MAP.put("#ffa500", "orange");
+ COLOR_NAME_MAP.put("#ffc0cb", "pink");
+ COLOR_NAME_MAP.put("#fa8072", "salmon");
+ COLOR_NAME_MAP.put("#00ffff", "cyan");
+ COLOR_NAME_MAP.put("#ee82ee", "violet");
+ COLOR_NAME_MAP.put("#d2b48c", "tan");
+ COLOR_NAME_MAP.put("#a52a2a", "brown");
+ COLOR_NAME_MAP.put("#ffffff", "white");
+ COLOR_NAME_MAP.put("#9370db", "mediumpurple");
+
+ COLOR_NAME_MAP.put("black", "#000000");
+ COLOR_NAME_MAP.put("silver", "#c0c0c0");
+ COLOR_NAME_MAP.put("gray", "#808080");
+ COLOR_NAME_MAP.put("white", "#ffffff");
+ COLOR_NAME_MAP.put("maroon", "#800000");
+ COLOR_NAME_MAP.put("red", "#ff0000");
+ COLOR_NAME_MAP.put("purple", "#800080");
+ COLOR_NAME_MAP.put("fuchsia", "#ff00ff");
+ COLOR_NAME_MAP.put("green", "#008000");
+ COLOR_NAME_MAP.put("lime", "#00ff00");
+ COLOR_NAME_MAP.put("olive", "#808000");
+ COLOR_NAME_MAP.put("yellow", "#ffff00");
+ COLOR_NAME_MAP.put("navy", "#000080");
+ COLOR_NAME_MAP.put("blue", "#0000ff");
+ COLOR_NAME_MAP.put("aqua", "#00ffff");
+ COLOR_NAME_MAP.put("black", "#000000");
+ COLOR_NAME_MAP.put("lightblue", "#add8e6");
+ COLOR_NAME_MAP.put("lightgreen", "#90ee90");
+ COLOR_NAME_MAP.put("orange", "#ffa500");
+ COLOR_NAME_MAP.put("pink", "#ffc0cb");
+ COLOR_NAME_MAP.put("salmon", "#fa8072");
+ COLOR_NAME_MAP.put("cyan", "#00ffff");
+ COLOR_NAME_MAP.put("violet", "#ee82ee");
+ COLOR_NAME_MAP.put("tan", "#d2b48c");
+ COLOR_NAME_MAP.put("brown", "#a52a2a");
+ COLOR_NAME_MAP.put("white", "#ffffff");
+ COLOR_NAME_MAP.put("mediumpurple", "#9370db");
+ }
+
+ public static Map<String, StyleMapEntry> parseStyleMapDOM(String styleFileString) {
+ File styleMapFile = new File(styleFileString);
+ Map<String, StyleMapEntry> result = new HashMap<String, StyleMapEntry>();
+ Document parse = null;
+
+ // Einlesen/parsen
+ try {
+ DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ FileInputStream stream = new FileInputStream(styleMapFile);
+ parse = db.parse(stream);
+ stream.close();
+
+ } catch (FileNotFoundException e) {
+ CEVPlugin.error(e);
+ return null;
+
+ } catch (ParserConfigurationException e) {
+ CEVPlugin.error(e);
+ return null;
+
+ } catch (FactoryConfigurationError e) {
+ CEVPlugin.error(e);
+ return null;
+
+ } catch (SAXException e) {
+ CEVPlugin.error(e);
+ return null;
+
+ } catch (IOException e) {
+ CEVPlugin.error(e);
+ return null;
+ }
+
+ final Node root = parse.getDocumentElement();
+ final NodeList nodeList = root.getChildNodes();
+
+ for (int i = 0; i < nodeList.getLength(); ++i) {
+ final Node node = nodeList.item(i);
+ final String nodeName = node.getNodeName();
+ // "rule" node ?
+ if (!nodeName.equals("rule")) { //$NON-NLS-1$
+ continue;
+ }
+
+ // Collect type or pattern, label, and color text style
+ NodeList childrenList = node.getChildNodes();
+ String type = ""; //$NON-NLS-1$
+ String label = ""; //$NON-NLS-1$
+ String colorText = ""; //$NON-NLS-1$
+ for (int j = 0; j < childrenList.getLength(); ++j) {
+ final Node child = childrenList.item(j);
+ final String childName = child.getNodeName();
+
+ if (childName.equals("pattern")) { //$NON-NLS-1$
+ type = getTextValue(child);
+ } else if (childName.equals("label")) { //$NON-NLS-1$
+ label = getTextValue(child);
+ } else if (childName.equals("style")) { //$NON-NLS-1$
+ colorText = getTextValue(child);
+ }
+ }
+
+ StyleMapEntry styleMapEntry = getStyleMapEntry(type, label, colorText);
+ result.put(styleMapEntry.getAnnotationTypeName(), styleMapEntry);
+ }
+ return result;
+ }
+
+ protected static StyleMapEntry getStyleMapEntry(String type, String label, String styleColor) {
+ StyleMapEntry result = new StyleMapEntry();
+ result.setAnnotationTypeName(type);
+ result.setLabel(label);
+ StringTokenizer token = new StringTokenizer(styleColor, ":;");
+ if (!token.hasMoreTokens()) {
+ return null; // No token
+ }
+
+ token.nextToken();
+ String fgString = token.nextToken().toLowerCase().trim();
+ result.setForeground(parseColorForeground(fgString));
+
+ token.nextToken();
+ String bgString = token.nextToken().toLowerCase().trim();
+ result.setBackground(parseColorBackground(bgString));
+
+ boolean checked = false; // default to Checked
+ if (token.hasMoreTokens()) {
+ String ck = token.nextToken();
+ String tf = token.nextToken();
+ if (ck.equals("checked")) {
+ if (tf.equals("false")) {
+ checked = false;
+ } else if (tf.equals("true")) {
+ checked = true;
+ }
+ }
+ }
+ result.setChecked(checked);
+
+ boolean hidden = false;
+ if (token.hasMoreTokens()) {
+ String ck = token.nextToken();
+ String tf = token.nextToken();
+ if (ck.equals("hidden")) {
+ if (tf.equals("true")) {
+ hidden = true;
+ }
+ }
+ }
+ result.setHidden(hidden);
+ return result;
+ }
+
+ private static String getTextValue(final Node node) {
+ final Node first = node.getFirstChild();
+
+ if (first != null) {
+ return ((Text) first).getNodeValue().trim();
+
+ } else {
+ return null;
+ }
+ }
+
+ private static Color parseColorBackground(String color) {
+ if (color.startsWith("#")) {
+ return Color.decode(color);
+ } else {
+ String string = COLOR_NAME_MAP.get(color);
+ if (string != null)
+ return Color.decode(string);
+ else
+ return Color.LIGHT_GRAY;
+ }
+ }
+
+ private static Color parseColorForeground(String color) {
+ if (color.startsWith("#")) {
+ return Color.decode(color);
+ } else {
+ String string = COLOR_NAME_MAP.get(color);
+ if (string != null)
+ return Color.decode(string);
+ else
+ return Color.BLACK;
+ }
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/StyleMapReader.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/StyleMapReader.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAbstractTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAbstractTreeNode.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAbstractTreeNode.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAbstractTreeNode.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,114 @@
+/*
+ * 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.cev.data.tree;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+public abstract class CEVAbstractTreeNode implements ICEVTreeNode {
+
+ private ICEVTreeNode parent;
+
+ private ArrayList<ICEVTreeNode> children;
+
+ public CEVAbstractTreeNode() {
+ this(null);
+ }
+
+ public CEVAbstractTreeNode(ICEVTreeNode parent) {
+ this.parent = parent;
+ children = new ArrayList<ICEVTreeNode>();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#addChild(org.apache.uima.cev.data.tree.
+ * ICEVTreeNode)
+ */
+ public void addChild(ICEVTreeNode child) {
+ children.add(child);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getChildren()
+ */
+ public ICEVTreeNode[] getChildren() {
+ return children.toArray(new ICEVTreeNode[] {});
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getChildrenIterator()
+ */
+ public Iterator<ICEVTreeNode> getChildrenIterator() {
+ return children.iterator();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getParent()
+ */
+ public ICEVTreeNode getParent() {
+ return parent;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#hasChildren()
+ */
+ public boolean hasChildren() {
+ return children.size() > 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getNodes(java.util.LinkedList)
+ */
+ public void getNodes(LinkedList<ICEVTreeNode> list) {
+ Iterator<ICEVTreeNode> iter = getChildrenIterator();
+
+ while (iter.hasNext()) {
+ ICEVTreeNode node = iter.next();
+
+ list.add(node);
+
+ node.getNodes(list);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#sort(java.util.Comparator)
+ */
+ public void sort(Comparator<ICEVTreeNode> cp) {
+ Collections.sort(children, cp);
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAbstractTreeNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAbstractTreeNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedRootTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedRootTreeNode.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedRootTreeNode.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedRootTreeNode.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,112 @@
+/*
+ * 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.cev.data.tree;
+
+import java.util.LinkedList;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+
+public class CEVAnnotationOrderedRootTreeNode extends CEVAnnotationOrderedTreeNode implements
+ ICEVRootTreeNode {
+
+ public CEVAnnotationOrderedRootTreeNode() {
+ super(null, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache..cev.data.tree.CEVAnnotationTreeNode#getName()
+ */
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache..cev.data.tree.CEVAnnotationTreeNode#getType()
+ */
+ @Override
+ public Type getType() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache..cev.data.tree.CEVAnnotationTreeNode#getAnnotation()
+ */
+ @Override
+ public AnnotationFS getAnnotation() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache..cev.data.tree.ICEVRootTreeNode#getNodes()
+ */
+ public LinkedList<ICEVTreeNode> getNodes() {
+ LinkedList<ICEVTreeNode> list = new LinkedList<ICEVTreeNode>();
+
+ getNodes(list);
+
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache..cev.data.tree.ICEVRootTreeNode#getNodes(org.apache.uima.cas.Type)
+ */
+ public LinkedList<ICEVTreeNode> getNodes(Type type) {
+ LinkedList<ICEVTreeNode> list = new LinkedList<ICEVTreeNode>();
+
+ getNodes(list, type);
+
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache..cev.data.tree.ICEVRootTreeNode#getNodes(org.apache.uima.cas.text.AnnotationFS
+ * )
+ */
+ public LinkedList<ICEVTreeNode> getNodes(AnnotationFS annot) {
+ LinkedList<ICEVTreeNode> list = new LinkedList<ICEVTreeNode>();
+
+ getNodes(list, annot);
+
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache..cev.data.tree.ICEVRootTreeNode#sort()
+ */
+ public void sort() {
+ sort(new CEVTreeComparator());
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedRootTreeNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedRootTreeNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedTreeNode.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedTreeNode.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedTreeNode.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,92 @@
+/*
+ * 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.cev.data.tree;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+
+public class CEVAnnotationOrderedTreeNode extends CEVAnnotationTreeNode {
+
+ public CEVAnnotationOrderedTreeNode(ICEVTreeNode parent, AnnotationFS annotation) {
+ super(parent, annotation);
+ }
+
+ public void insertFS(FeatureStructure fs) {
+ boolean processed = false;
+
+ if (!(fs instanceof AnnotationFS))
+ return;
+
+ AnnotationFS annotation = (AnnotationFS) fs;
+ Iterator<ICEVTreeNode> iter = getChildrenIterator();
+
+ while (iter.hasNext()) {
+ CEVAnnotationOrderedTreeNode childNode = (CEVAnnotationOrderedTreeNode) iter.next();
+
+ if (isChild(childNode, annotation)) {
+ childNode.insertFS(annotation);
+ processed = true;
+ }
+ }
+
+ if (!processed) {
+ CEVAnnotationOrderedTreeNode node = new CEVAnnotationOrderedTreeNode(this, annotation);
+ addChild(node);
+ }
+ }
+
+ private boolean isChild(CEVAnnotationOrderedTreeNode node, AnnotationFS annotation) {
+ return (node.getAnnotation().getBegin() < annotation.getBegin() && node.getAnnotation()
+ .getEnd() >= annotation.getEnd())
+ || (node.getAnnotation().getBegin() <= annotation.getBegin() && node.getAnnotation()
+ .getEnd() > annotation.getEnd());
+ }
+
+ public void getNodes(LinkedList<ICEVTreeNode> list, Type type) {
+ Iterator<ICEVTreeNode> iter = getChildrenIterator();
+
+ while (iter.hasNext()) {
+ CEVAnnotationOrderedTreeNode node = (CEVAnnotationOrderedTreeNode) iter.next();
+
+ if (node.getType().equals(type))
+ list.add(node);
+
+ node.getNodes(list, type);
+ }
+ }
+
+ public void getNodes(LinkedList<ICEVTreeNode> list, AnnotationFS annot) {
+ Iterator<ICEVTreeNode> iter = getChildrenIterator();
+
+ while (iter.hasNext()) {
+ CEVAnnotationOrderedTreeNode node = (CEVAnnotationOrderedTreeNode) iter.next();
+
+ if (node.getAnnotation().equals(annot))
+ list.add(node);
+ else if (isChild(node, annot))
+ node.getNodes(list, annot);
+ }
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedTreeNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationOrderedTreeNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationTreeNode.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationTreeNode.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationTreeNode.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.cev.data.tree;
+
+import org.apache.uima.cas.text.AnnotationFS;
+
+
+public class CEVAnnotationTreeNode extends CEVFSTreeNode implements ICEVAnnotationNode {
+
+ public CEVAnnotationTreeNode(AnnotationFS annotation) {
+ super(annotation);
+ }
+
+ public CEVAnnotationTreeNode(ICEVTreeNode parent, AnnotationFS annotation) {
+ super(parent, annotation);
+ }
+
+ public AnnotationFS getAnnotation() {
+ return (AnnotationFS) fs;
+ }
+
+ @Override
+ public String getName() {
+ return getAnnotation().getCoveredText();
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationTreeNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVAnnotationTreeNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFSTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFSTreeNode.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFSTreeNode.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFSTreeNode.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,115 @@
+/*
+ * 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.cev.data.tree;
+
+import org.apache.uima.cas.ArrayFS;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+
+public class CEVFSTreeNode extends CEVAbstractTreeNode {
+
+ protected FeatureStructure fs;
+
+ public CEVFSTreeNode(FeatureStructure thisFS) {
+ super();
+ this.fs = thisFS;
+
+ for (Feature f : thisFS.getType().getFeatures()) {
+ if (f.getRange().isPrimitive()) {
+ addChild(new CEVFeatureTreeNode(this, f, thisFS.getFeatureValueAsString(f)));
+ }
+ }
+
+ }
+
+ public CEVFSTreeNode(ICEVTreeNode parent, FeatureStructure annotation) {
+ super(parent);
+ this.fs = annotation;
+ for (Feature f : annotation.getType().getFeatures()) {
+ addFeatures(this, f, annotation);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getName()
+ */
+ public String getName() {
+ return fs.getType().getShortName();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getType()
+ */
+ public Type getType() {
+ return fs.getType();
+ }
+
+ public void addFeatures(ICEVTreeNode parent, Feature f, FeatureStructure featureStructure) {
+ if (f.getRange().isArray()) {
+ FeatureStructure featureValue = featureStructure.getFeatureValue(f);
+ if (featureValue instanceof ArrayFS) {
+ ArrayFS array = (ArrayFS) featureValue;
+ if (array != null) {
+ String text = "Array" + "[" + array.size() + "]";
+ CEVFeatureTreeNode arrayNode = new CEVFeatureTreeNode(this, f, text);
+ parent.addChild(arrayNode);
+
+ int size = array.size();
+
+ for (int i = 0; i < size; i++) {
+ FeatureStructure fs = array.get(i);
+ if (fs instanceof FeatureStructure) {
+ Type fsType = fs.getType();
+ ICEVTreeNode fsNode;
+ if (fs instanceof AnnotationFS) {
+ AnnotationFS faa = (AnnotationFS) fs;
+ fsNode = new CEVAnnotationTreeNode(arrayNode, faa);
+ } else {
+ fsNode = new CEVTypeTreeNode(arrayNode, fsType);
+ }
+ arrayNode.addChild(fsNode);
+
+ // List<Feature> features = fs.getType().getFeatures();
+ // for (Feature feature : features) {
+ // addFeatures(fsNode, feature, fs);
+ // }
+ }
+ }
+ }
+ }
+ } else if (f.getRange().isPrimitive()) {
+ if ("uima.cas.AnnotationBase:sofa".equals(f.getName())) {
+ } else {
+ parent.addChild(new CEVFeatureTreeNode(this, f, featureStructure.getFeatureValueAsString(f)));
+ }
+ } else if (f.getRange() instanceof Type) {
+ FeatureStructure featureValue = featureStructure.getFeatureValue(f);
+ if (featureValue instanceof AnnotationFS) {
+ parent.addChild(new CEVAnnotationTreeNode(this, ((AnnotationFS) featureValue)));
+ }
+ }
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFSTreeNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFSTreeNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFeatureTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFeatureTreeNode.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFeatureTreeNode.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFeatureTreeNode.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,139 @@
+/*
+ * 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.cev.data.tree;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.Type;
+
+public class CEVFeatureTreeNode implements ICEVTreeNode {
+
+ private ICEVTreeNode parent;
+
+ private Feature f;
+
+ private String value;
+
+ private ArrayList<ICEVTreeNode> children;
+
+ public CEVFeatureTreeNode(ICEVTreeNode parent, Feature f, String value) {
+ this.parent = parent;
+ this.f = f;
+ this.value = value;
+ this.children = new ArrayList<ICEVTreeNode>();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#addChild(org.apache.uima.cev.data
+ * .tree.ICEVTreeNode)
+ */
+ public void addChild(ICEVTreeNode child) {
+ this.children.add(child);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getChildren()
+ */
+ public ICEVTreeNode[] getChildren() {
+ return this.children.toArray(new ICEVTreeNode[] {});
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getChildrenIterator()
+ */
+ public Iterator<ICEVTreeNode> getChildrenIterator() {
+ return this.children.iterator();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getName()
+ */
+ public String getName() {
+ return f.getShortName() + " : " + value;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getNodes(java.util.LinkedList)
+ */
+ public void getNodes(LinkedList<ICEVTreeNode> list) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getParent()
+ */
+ public ICEVTreeNode getParent() {
+ return parent;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getType()
+ */
+ public Type getType() {
+ return f.getRange();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#hasChildren()
+ */
+ public boolean hasChildren() {
+ if (children.size() > 0) {
+ return true;
+ }
+ return false;
+ }
+
+ public Feature getFeature() {
+ return this.f;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#sort(java.util.Comparator)
+ */
+ public void sort(Comparator<ICEVTreeNode> cp) {
+ // nothing to do
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFeatureTreeNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVFeatureTreeNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVTreeComparator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVTreeComparator.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVTreeComparator.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVTreeComparator.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,32 @@
+/*
+ * 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.cev.data.tree;
+
+public class CEVTreeComparator implements java.util.Comparator<ICEVTreeNode> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(ICEVTreeNode o1, ICEVTreeNode o2) {
+ return o1.getName().compareToIgnoreCase(o2.getName());
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVTreeComparator.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVTreeComparator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVTypeOrderedRootTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVTypeOrderedRootTreeNode.java?rev=1157036&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVTypeOrderedRootTreeNode.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-cev/src/main/java/org/apache/uima/cev/data/tree/CEVTypeOrderedRootTreeNode.java Fri Aug 12 10:28:15 2011
@@ -0,0 +1,172 @@
+/*
+ * 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.cev.data.tree;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+
+public class CEVTypeOrderedRootTreeNode extends CEVAbstractTreeNode implements ICEVRootTreeNode {
+
+ public CEVTypeOrderedRootTreeNode() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getName()
+ */
+ public String getName() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVTreeNode#getType()
+ */
+ public Type getType() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVRootTreeNode#insertAnnotation(org.apache.uima.cas.text
+ * .AnnotationFS )
+ */
+ public void insertFS(FeatureStructure fs) {
+ // TODO hotfix for explanation types...
+ if (fs.getType().getShortName().equals("DebugBlockApply")
+ || fs.getType().getShortName().equals("DebugMatchedRuleMatch")
+ || fs.getType().getShortName().equals("DebugFailedRuleMatch")
+ || fs.getType().getShortName().equals("DebugScriptApply")
+ || fs.getType().getShortName().equals("DebugRuleElementMatches")
+ || fs.getType().getShortName().equals("DebugRuleElementMatch")) {
+ return;
+ }
+
+ Iterator<ICEVTreeNode> iter = getChildrenIterator();
+
+ while (iter.hasNext()) {
+ CEVTypeTreeNode typeNode = (CEVTypeTreeNode) iter.next();
+
+ if (typeNode.getType().equals(fs.getType())) {
+ CEVFSTreeNode node = createFSNode(typeNode, fs);
+ typeNode.addChild(node);
+ return;
+ }
+ }
+
+ CEVTypeTreeNode typeNode = new CEVTypeTreeNode(this, fs.getType());
+ addChild(typeNode);
+
+ CEVFSTreeNode node = createFSNode(typeNode, fs);
+ typeNode.addChild(node);
+ }
+
+ private CEVFSTreeNode createFSNode(ICEVTreeNode parent, FeatureStructure fs) {
+ if (fs instanceof AnnotationFS) {
+ return new CEVAnnotationTreeNode(parent, (AnnotationFS) fs);
+ }
+ return new CEVFSTreeNode(parent, fs);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVRootTreeNode#getNodes()
+ */
+ public LinkedList<ICEVTreeNode> getNodes() {
+ LinkedList<ICEVTreeNode> list = new LinkedList<ICEVTreeNode>();
+ getNodes(list);
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVRootTreeNode#getNodes(org.apache.uima.cas.Type)
+ */
+ public LinkedList<ICEVTreeNode> getNodes(Type type) {
+ Iterator<ICEVTreeNode> iter = getChildrenIterator();
+
+ LinkedList<ICEVTreeNode> list = new LinkedList<ICEVTreeNode>();
+
+ while (iter.hasNext()) {
+ CEVTypeTreeNode typeNode = (CEVTypeTreeNode) iter.next();
+
+ if (typeNode.getType().equals(type)) {
+ Iterator<ICEVTreeNode> children = typeNode.getChildrenIterator();
+
+ list.add(typeNode);
+
+ while (children.hasNext())
+ list.add(children.next());
+ }
+ }
+
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.uima.cev.data.tree.ICEVRootTreeNode#getNodes(org.apache.uima.cas.text.AnnotationFS )
+ */
+ public LinkedList<ICEVTreeNode> getNodes(AnnotationFS annot) {
+ Iterator<ICEVTreeNode> iter = getChildrenIterator();
+
+ LinkedList<ICEVTreeNode> list = new LinkedList<ICEVTreeNode>();
+
+ while (iter.hasNext()) {
+ CEVTypeTreeNode typeNode = (CEVTypeTreeNode) iter.next();
+
+ if (typeNode.getType().equals(annot.getType())) {
+ Iterator<ICEVTreeNode> children = typeNode.getChildrenIterator();
+
+ while (children.hasNext()) {
+ CEVAnnotationTreeNode node = (CEVAnnotationTreeNode) children.next();
+
+ if (node.getAnnotation().equals(annot)) {
+ list.add(node);
+ return list;
+ }
+ }
+ }
+ }
+
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.cev.data.tree.ICEVRootTreeNode#sort()
+ */
+ public void sort() {
+ sort(new CEVTreeComparator());
+ }
+}