}
long nlinesread=0;
String lastread="";
+ private static String GRAPHLINE="GRAPHLINE", COMBINE="COMBINE";
public boolean parseAnnotationFrom(AlignmentI al, BufferedReader in)
throws Exception
{
nlinesread = 0;
ArrayList<Object[]> combineAnnotation_calls = new ArrayList<Object[]>();
+ ArrayList<Object[]> deferredAnnotation_calls = new ArrayList<Object[]>();
boolean modified = false;
String groupRef = null;
Hashtable groupRefRows = new Hashtable();
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});
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;
}
}
((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
(_combine_args[2]==null) ? null : groupRefLookup.get((String)_combine_args[2]) // the reference group, or null
);
}
-
}
return modified;
}
}
}
- 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));
}
}
}
{
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)