You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by tw...@apache.org on 2007/01/12 15:00:46 UTC

svn commit: r495575 - in /incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view: FSNode.java MainFrame.java StringFsPopupEventAdapter.java

Author: twgoetz
Date: Fri Jan 12 06:00:45 2007
New Revision: 495575

URL: http://svn.apache.org/viewvc?view=rev&rev=495575
Log:
Jira UIMA-178: comments added.

https://issues.apache.org/jira/browse/UIMA-178

Modified:
    incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/FSNode.java
    incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/MainFrame.java
    incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/StringFsPopupEventAdapter.java

Modified: incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/FSNode.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/FSNode.java?view=diff&rev=495575&r1=495574&r2=495575
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/FSNode.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/FSNode.java Fri Jan 12 06:00:45 2007
@@ -27,7 +27,6 @@
 import org.apache.uima.cas.impl.CASImpl;
 import org.apache.uima.cas.impl.FeatureImpl;
 import org.apache.uima.cas.impl.LowLevelCAS;
-import org.apache.uima.cas.impl.CASImpl;
 import org.apache.uima.cas.text.AnnotationFS;
 
 class FSNode extends FSTreeNode {
@@ -68,6 +67,7 @@
 
   private final boolean isArrayElem;
   
+  // Remember if we're displaying a shortened string.
   private boolean isShortenedString = false;
 
   FSNode(FSTreeModel fSTreeModel, int nodeClass, long addr, Feature feat) {
@@ -217,10 +217,18 @@
     return "<i>" + this.feat.getShortName() + "</i>";
   }
   
+  /**
+   * 
+   * @return if this is a string node displaying a shortened string
+   */
   boolean isShortenedString() {
     return this.isShortenedString;
   }
   
+  /**
+   * 
+   * @return for string nodes, return the string value (so it can be displayed seperately
+   */
   String getFullString() {
     if (getNodeClass() != STRING_FS) {
       return null;
@@ -253,7 +261,9 @@
           return getNullString();
         }
         String s = cas.getStringForCode((int) this.addr);
+        // Check if we need to shorten the string for display purposes
         String s1 = shortenString(s);
+        // Remember if string is shortened
         this.isShortenedString = (s != s1);
         return "\"" + escapeLt(s1) + "\"";
       }

Modified: incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/MainFrame.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/MainFrame.java?view=diff&rev=495575&r1=495574&r2=495575
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/MainFrame.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/MainFrame.java Fri Jan 12 06:00:45 2007
@@ -133,7 +133,6 @@
 import org.apache.uima.cas.impl.XCASDeserializer;
 import org.apache.uima.cas.impl.XCASSerializer;
 import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.cas.text.TCAS;
 import org.apache.uima.internal.util.FileUtils;
 import org.apache.uima.internal.util.TimeSpan;
 import org.apache.uima.internal.util.Timer;
@@ -360,13 +359,13 @@
         boolean isAnnotation = true;
         if (userObject instanceof IndexTreeNode) {
           IndexTreeNode iNode = (IndexTreeNode) userObject;
-          if (!iNode.getName().equals(TCAS.STD_ANNOTATION_INDEX)) {
+          if (!iNode.getName().equals(CAS.STD_ANNOTATION_INDEX)) {
             isAnnotation = false;
           }
           annotTitle = iNode.getType().getName();
         } else if (userObject instanceof TypeTreeNode) {
           TypeTreeNode tNode = (TypeTreeNode) userObject;
-          if (!tNode.getLabel().equals(TCAS.STD_ANNOTATION_INDEX)) {
+          if (!tNode.getLabel().equals(CAS.STD_ANNOTATION_INDEX)) {
             isAnnotation = false;
           }
           annotTitle = tNode.getType().getName();
@@ -474,7 +473,7 @@
         return;
       }
       MainFrame.this.indexLabel = label;
-      MainFrame.this.isAnnotIndex = label.equals(TCAS.STD_ANNOTATION_INDEX);
+      MainFrame.this.isAnnotIndex = label.equals(CAS.STD_ANNOTATION_INDEX);
       MainFrame.this.index = MainFrame.this.cas.getIndexRepository().getIndex(label, type);
       updateFSTree(label, MainFrame.this.index);
       MainFrame.this.allAnnotViewerItem.setEnabled(((CASImpl) MainFrame.this.cas)
@@ -2556,7 +2555,7 @@
     Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
     defaultStyle = StyleContext.getDefaultStyleContext().addStyle("defaultAnnot", defaultStyle);
     StyleConstants.setBackground(defaultStyle, selectionColor);
-    this.styleMap.put(TCAS.TYPE_NAME_ANNOTATION, defaultStyle);
+    this.styleMap.put(CAS.TYPE_NAME_ANNOTATION, defaultStyle);
     this.textPopup = new JPopupMenu();
     this.fsTree.addFocusListener(new TreeFocusHandler(this.fsTree));
     this.indexTree.addFocusListener(new TreeFocusHandler(this.indexTree));
@@ -2689,7 +2688,7 @@
   private void setLanguage() {
     if (this.language != null) {
       Feature langFeat = this.cas.getTypeSystem().getFeatureByFullName(
-              TCAS.FEATURE_FULL_NAME_LANGUAGE);
+              CAS.FEATURE_FULL_NAME_LANGUAGE);
       AnnotationFS doc = this.cas.getDocumentAnnotation();
       if (doc != null) {
         doc.setStringValue(langFeat, this.language);
@@ -3013,7 +3012,7 @@
   }
 
   private void loadColorPreferences(File file) throws IOException {
-    Style parent = (Style) this.styleMap.get(TCAS.TYPE_NAME_ANNOTATION);
+    Style parent = (Style) this.styleMap.get(CAS.TYPE_NAME_ANNOTATION);
     StyleContext sc = StyleContext.getDefaultStyleContext();
     Properties prefs1 = new Properties();
     FileInputStream in = new FileInputStream(file);

Modified: incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/StringFsPopupEventAdapter.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/StringFsPopupEventAdapter.java?view=diff&rev=495575&r1=495574&r2=495575
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/StringFsPopupEventAdapter.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/annot_view/StringFsPopupEventAdapter.java Fri Jan 12 06:00:45 2007
@@ -1,3 +1,22 @@
+/*
+ * 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.tools.annot_view;
 
 import java.awt.event.ActionEvent;
@@ -13,8 +32,16 @@
 import javax.swing.JTree;
 import javax.swing.tree.TreePath;
 
+/**
+ * Pop-up event adapter for string valued features in the FS display.  Displays a pop-up for string
+ * values that were shortened for display purposes.  Users can display long strings in a separate
+ * window.
+ */
 public class StringFsPopupEventAdapter extends MouseAdapter {
 
+  /**
+   * ActionListener for the pop-up menu.  Just shows text in a separate text window.
+   */
   private static class ShowStringHandler implements ActionListener {
 
     private String string;
@@ -25,6 +52,7 @@
     }
 
     public void actionPerformed(ActionEvent e) {
+      // Show string in a new window.
       JFrame frame = new JFrame("Full string value");
       JTextArea textArea = new JTextArea(this.string);
       textArea.setEditable(false);
@@ -49,15 +77,20 @@
   }
 
   private void showPopupMaybe(MouseEvent e) {
+    // Mouse event is pop-up trigger?
     if (e.isPopupTrigger()) {
       Object o = e.getSource();
+      // Event was triggered over the tree?
       if (o instanceof javax.swing.JTree) {
 	JTree tree = (JTree) o;
 	TreePath path = tree.getPathForLocation(e.getX(), e.getY());
+	// Get the node in the tree model where context click occurred.
 	Object leafComponent = path.getLastPathComponent();
 	if (leafComponent instanceof FSNode) {
 	  FSNode node = (FSNode) leafComponent;
+	  // FSNode is a string node and was shortened?
 	  if (node.getNodeClass() == FSNode.STRING_FS && node.isShortenedString()) {
+	    // Show pop-up
 	    JPopupMenu menu = new JPopupMenu();
 	    JMenuItem showStringItem = new JMenuItem("Show full string");
 	    showStringItem.addActionListener(new ShowStringHandler(node.getFullString()));