JAL-3383 JAL-3397 JAL-3253-applet IntervalStore options
[jalview.git] / src / jalview / io / vamsas / Sequencefeature.java
index 31d64f5..dab840e 100644 (file)
@@ -232,7 +232,7 @@ public class Sequencefeature extends Rangetype
     if (feature.otherDetails != null)
     {
       Iterator<String> iter = feature.otherDetails.keySet().iterator();
-      Vector props = dsa.getPropertyAsReference();
+      Vector<?> props = dsa.getPropertyAsReference();
       while (iter.hasNext())
       {
         String key = iter.next();
@@ -281,9 +281,40 @@ public class Sequencefeature extends Rangetype
   private SequenceFeature getJalviewSeqFeature(RangeAnnotation dseta)
   {
     int[] se = getBounds(dseta);
-    SequenceFeature sf = new jalview.datamodel.SequenceFeature(
-            dseta.getType(), dseta.getDescription(), dseta.getStatus(),
-            se[0], se[1], dseta.getGroup());
+
+    /*
+     * try to identify feature score
+     */
+    boolean scoreFound = false;
+    float theScore = 0f;
+    String featureType = dseta.getType();
+    if (dseta.getScoreCount() > 0)
+    {
+      @SuppressWarnings("unchecked")
+      Enumeration<Score> scr = dseta.enumerateScore();
+      while (scr.hasMoreElements())
+      {
+        Score score = scr.nextElement();
+        if (score.getName().equals(featureType))
+        {
+          theScore = score.getContent();
+          scoreFound = true;
+        }
+      }
+    }
+
+    SequenceFeature sf = null;
+    if (scoreFound)
+    {
+      sf = new SequenceFeature(featureType, dseta.getDescription(), se[0],
+              se[1], theScore, dseta.getGroup());
+    }
+    else
+    {
+      sf = new SequenceFeature(featureType, dseta.getDescription(), se[0],
+              se[1], dseta.getGroup());
+    }
+    sf.setStatus(dseta.getStatus());
     if (dseta.getLinkCount() > 0)
     {
       Link[] links = dseta.getLink();
@@ -295,25 +326,23 @@ public class Sequencefeature extends Rangetype
     }
     if (dseta.getScoreCount() > 0)
     {
-      Enumeration scr = dseta.enumerateScore();
+      @SuppressWarnings("unchecked")
+      Enumeration<Score> scr = dseta.enumerateScore();
       while (scr.hasMoreElements())
       {
-        Score score = (Score) scr.nextElement();
-        if (score.getName().equals(sf.getType()))
-        {
-          sf.setScore(score.getContent());
-        }
-        else
+        Score score = scr.nextElement();
+        if (!score.getName().equals(sf.getType()))
         {
           sf.setValue(score.getName(), "" + score.getContent());
         }
       }
     }
     // other details
-    Enumeration props = dseta.enumerateProperty();
+    @SuppressWarnings("unchecked")
+    Enumeration<Property> props = dseta.enumerateProperty();
     while (props.hasMoreElements())
     {
-      Property p = (Property) props.nextElement();
+      Property p = props.nextElement();
       Object val = null;
       if (Properties.isValid(p))
       {