X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FAnnotationFile.java;h=4abd7687a924f842f81624cc777ac0999b56c1fa;hb=4608f763ad15fdb8b093d205985fb3b4d7077471;hp=b3a22df894f169bc408c3bef653c8eb86d691723;hpb=59c3078b53669a38f4e1c1158675691fe60349b3;p=jalview.git diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index b3a22df..4abd768 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -338,12 +338,15 @@ public class AnnotationFile rowprops.append(row.centreColLabels); rowprops.append(newline); } + if (graphLine.length()>0) { + text.append(graphLine.toString()); + graphLine.setLength(0); + } } text.append(newline); text.append(colours.toString()); - text.append(graphLine.toString()); if (graphGroup.size() > 0) { SequenceI oldRefSeq = refSeq; @@ -621,11 +624,13 @@ public class AnnotationFile } long nlinesread=0; String lastread=""; + private static String GRAPHLINE="GRAPHLINE", COMBINE="COMBINE"; public boolean parseAnnotationFrom(AlignmentI al, BufferedReader in) throws Exception { nlinesread = 0; ArrayList combineAnnotation_calls = new ArrayList(); + ArrayList deferredAnnotation_calls = new ArrayList(); boolean modified = false; String groupRef = null; Hashtable groupRefRows = new Hashtable(); @@ -709,7 +714,7 @@ public class AnnotationFile continue; } - else if (token.equalsIgnoreCase("COMBINE")) + else if (token.equalsIgnoreCase(COMBINE)) { // keep a record of current state and resolve groupRef at end combineAnnotation_calls.add(new Object[] { st, refSeq, groupRef}); @@ -722,9 +727,10 @@ public class AnnotationFile modified = true; continue; } - else if (token.equalsIgnoreCase("GRAPHLINE")) + else if (token.equalsIgnoreCase(GRAPHLINE)) { - addLine(al, st); + // resolve at end + deferredAnnotation_calls.add(new Object[] { GRAPHLINE, st, refSeq, groupRef}); modified = true; continue; } @@ -967,6 +973,21 @@ public class AnnotationFile } ((Vector) groupRefRows.get(groupRef)).removeAllElements(); } + // process any deferred attribute settings for each context + for (Object[] _deferred_args : deferredAnnotation_calls) + { + if (_deferred_args[0] == GRAPHLINE) + { + addLine(al, + (StringTokenizer) _deferred_args[1], // st + (SequenceI) _deferred_args[2], // refSeq + (_deferred_args[3] == null) ? null : groupRefLookup + .get((String) _deferred_args[3]) // the reference + // group, or null + ); + } + } + // finally, combine all the annotation rows within each context. /** * number of combine statements in this annotation file. Used to create new groups for combined annotation graphs without disturbing existing ones @@ -980,7 +1001,6 @@ public class AnnotationFile (_combine_args[2]==null) ? null : groupRefLookup.get((String)_combine_args[2]) // the reference group, or null ); } - } return modified; } @@ -1191,19 +1211,26 @@ public class AnnotationFile } } - void addLine(AlignmentI al, StringTokenizer st) + void addLine(AlignmentI al, StringTokenizer st, SequenceI seqRef, SequenceGroup groupRef) { String group = st.nextToken(); AlignmentAnnotation annotation = null, alannot[] = al .getAlignmentAnnotation(); + float value = new Float(st.nextToken()).floatValue(); + String label = st.hasMoreTokens() ? st.nextToken() : null; + java.awt.Color colour = null; + if (st.hasMoreTokens()) + { + UserColourScheme ucs = new UserColourScheme(st.nextToken()); + colour = ucs.findColour('A'); + } if (alannot != null) { for (int i = 0; i < alannot.length; i++) { - if (alannot[i].label.equalsIgnoreCase(group)) + if (alannot[i].label.equalsIgnoreCase(group) && (seqRef==null || alannot[i].sequenceRef==seqRef) && (groupRef==null || alannot[i].groupRef==groupRef)) { - annotation = alannot[i]; - break; + alannot[i].setThreshold(new GraphLine(value, label, colour)); } } } @@ -1211,16 +1238,6 @@ public class AnnotationFile { return; } - float value = new Float(st.nextToken()).floatValue(); - String label = st.hasMoreTokens() ? st.nextToken() : null; - java.awt.Color colour = null; - if (st.hasMoreTokens()) - { - UserColourScheme ucs = new UserColourScheme(st.nextToken()); - colour = ucs.findColour('A'); - } - - annotation.setThreshold(new GraphLine(value, label, colour)); } void addGroup(AlignmentI al, StringTokenizer st)