}
else if (sg.cs instanceof jalview.schemes.AnnotationColourGradient)
{
- groups[i]
- .setColour(ColourSchemeProperty
- .getColourName(((jalview.schemes.AnnotationColourGradient) sg.cs)
- .getBaseColour()));
+ groups[i].setColour("AnnotationColourGradient");
+ groups[i].setAnnotationColours(constructAnnotationColours(
+ (jalview.schemes.AnnotationColourGradient) sg.cs,
+ userColours, jms));
}
else if (sg.cs instanceof jalview.schemes.UserColourScheme)
{
}
else if (av.getGlobalColourScheme() instanceof jalview.schemes.AnnotationColourGradient)
{
- jalview.schemes.AnnotationColourGradient acg = (jalview.schemes.AnnotationColourGradient) av
- .getGlobalColourScheme();
-
- AnnotationColours ac = new AnnotationColours();
- ac.setAboveThreshold(acg.getAboveThreshold());
- ac.setThreshold(acg.getAnnotationThreshold());
- ac.setAnnotation(acg.getAnnotation());
- if (acg.getBaseColour() instanceof jalview.schemes.UserColourScheme)
- {
- ac.setColourScheme(SetUserColourScheme(acg.getBaseColour(),
- userColours, jms));
- }
- else
- {
- ac.setColourScheme(ColourSchemeProperty.getColourName(acg
- .getBaseColour()));
- }
+ AnnotationColours ac = constructAnnotationColours(
+ (jalview.schemes.AnnotationColourGradient) av
+ .getGlobalColourScheme(),
+ userColours, jms);
- ac.setMaxColour(acg.getMaxColour().getRGB());
- ac.setMinColour(acg.getMinColour().getRGB());
- ac.setPerSequence(acg.isSeqAssociated());
- ac.setPredefinedColours(acg.isPredefinedColours());
view.setAnnotationColours(ac);
view.setBgColour("AnnotationColourGradient");
}
return object;
}
- private void storeAlignmentAnnotation(AlignmentAnnotation[] aa, IdentityHashMap groupRefs, AlignmentViewport av, Set<String> calcIdSet, boolean storeDS, SequenceSet vamsasSet)
+ private AnnotationColours constructAnnotationColours(
+ AnnotationColourGradient acg, Vector userColours,
+ JalviewModelSequence jms)
+ {
+ AnnotationColours ac = new AnnotationColours();
+ ac.setAboveThreshold(acg.getAboveThreshold());
+ ac.setThreshold(acg.getAnnotationThreshold());
+ ac.setAnnotation(acg.getAnnotation());
+ if (acg.getBaseColour() instanceof jalview.schemes.UserColourScheme)
+ {
+ ac.setColourScheme(SetUserColourScheme(acg.getBaseColour(),
+ userColours, jms));
+ }
+ else
+ {
+ ac.setColourScheme(ColourSchemeProperty.getColourName(acg
+ .getBaseColour()));
+ }
+
+ ac.setMaxColour(acg.getMaxColour().getRGB());
+ ac.setMinColour(acg.getMinColour().getRGB());
+ ac.setPerSequence(acg.isSeqAssociated());
+ ac.setPredefinedColours(acg.isPredefinedColours());
+ return ac;
+ }
+
+ private void storeAlignmentAnnotation(AlignmentAnnotation[] aa,
+ IdentityHashMap groupRefs, AlignmentViewport av,
+ Set<String> calcIdSet, boolean storeDS, SequenceSet vamsasSet)
{
for (int i = 0; i < aa.length; i++)
if (jms.getJGroupCount() > 0)
{
JGroup[] groups = jms.getJGroup();
-
+ boolean addAnnotSchemeGroup = false;
for (int i = 0; i < groups.length; i++)
{
ColourSchemeI cs = null;
{
cs = GetUserColourScheme(jms, groups[i].getColour());
}
+ else if (groups[i].getColour().equals("AnnotationColourGradient")
+ && groups[i].getAnnotationColours() != null)
+ {
+ addAnnotSchemeGroup = true;
+ cs = null;
+ }
else
{
cs = ColourSchemeProperty.getColour(al, groups[i].getColour());
}
}
al.addGroup(sg);
-
+ if (addAnnotSchemeGroup)
+ {
+ // reconstruct the annotation colourscheme
+ sg.cs = constructAnnotationColour(
+ groups[i].getAnnotationColours(), null, al, jms, false);
+ }
}
}
if (view == null)
}
}
+ /**
+ * indicate that annotation colours are applied across all groups (pre
+ * Jalview 2.8.1 behaviour)
+ */
+ boolean doGroupAnnColour = isVersionStringLaterThan("2.8.1",
+ object.getVersion());
+
AlignmentPanel ap = null;
boolean isnewview = true;
if (viewId != null)
}
else if (view.getBgColour().startsWith("Annotation"))
{
- // int find annotation
- if (af.viewport.getAlignment().getAlignmentAnnotation() != null)
- {
- for (int i = 0; i < af.viewport.getAlignment()
- .getAlignmentAnnotation().length; i++)
- {
- if (af.viewport.getAlignment().getAlignmentAnnotation()[i].label
- .equals(view.getAnnotationColours().getAnnotation()))
- {
- if (af.viewport.getAlignment().getAlignmentAnnotation()[i]
- .getThreshold() == null)
- {
- af.viewport.getAlignment().getAlignmentAnnotation()[i]
- .setThreshold(new jalview.datamodel.GraphLine(view
- .getAnnotationColours().getThreshold(),
- "Threshold", java.awt.Color.black)
+ AnnotationColours viewAnnColour = view.getAnnotationColours();
+ cs = constructAnnotationColour(viewAnnColour, af, al, jms, true);
- );
- }
-
- if (view.getAnnotationColours().getColourScheme()
- .equals("None"))
- {
- cs = new AnnotationColourGradient(af.viewport
- .getAlignment().getAlignmentAnnotation()[i],
- new java.awt.Color(view.getAnnotationColours()
- .getMinColour()), new java.awt.Color(view
- .getAnnotationColours().getMaxColour()),
- view.getAnnotationColours().getAboveThreshold());
- }
- else if (view.getAnnotationColours().getColourScheme()
- .startsWith("ucs"))
- {
- cs = new AnnotationColourGradient(af.viewport
- .getAlignment().getAlignmentAnnotation()[i],
- GetUserColourScheme(jms, view
- .getAnnotationColours().getColourScheme()),
- view.getAnnotationColours().getAboveThreshold());
- }
- else
- {
- cs = new AnnotationColourGradient(af.viewport
- .getAlignment().getAlignmentAnnotation()[i],
- ColourSchemeProperty.getColour(al, view
- .getAnnotationColours().getColourScheme()),
- view.getAnnotationColours().getAboveThreshold());
- }
- if (view.getAnnotationColours().hasPerSequence())
- {
- ((AnnotationColourGradient)cs).setSeqAssociated(view.getAnnotationColours().isPerSequence());
- }
- if (view.getAnnotationColours().hasPredefinedColours())
- {
- ((AnnotationColourGradient)cs).setPredefinedColours(view.getAnnotationColours().isPredefinedColours());
- }
- // Also use these settings for all the groups
- if (al.getGroups() != null)
- {
- for (int g = 0; g < al.getGroups().size(); g++)
- {
- jalview.datamodel.SequenceGroup sg = al.getGroups()
- .get(g);
-
- if (sg.cs == null)
- {
- continue;
- }
-
- /*
- * if
- * (view.getAnnotationColours().getColourScheme().equals("None"
- * )) { sg.cs = new AnnotationColourGradient(
- * af.viewport.getAlignment().getAlignmentAnnotation()[i], new
- * java.awt.Color(view.getAnnotationColours().
- * getMinColour()), new
- * java.awt.Color(view.getAnnotationColours().
- * getMaxColour()),
- * view.getAnnotationColours().getAboveThreshold()); } else
- */
- {
- sg.cs = new AnnotationColourGradient(af.viewport
- .getAlignment().getAlignmentAnnotation()[i],
- sg.cs, view.getAnnotationColours()
- .getAboveThreshold());
- if (cs instanceof AnnotationColourGradient)
- {
- if (view.getAnnotationColours().hasPerSequence())
- {
- ((AnnotationColourGradient)cs).setSeqAssociated(view.getAnnotationColours().isPerSequence());
- }
- if (view.getAnnotationColours().hasPredefinedColours())
- {
- ((AnnotationColourGradient)cs).setPredefinedColours(view.getAnnotationColours().isPredefinedColours());
- }
- }
- }
+ // annpos
- }
- }
-
- break;
- }
-
- }
- }
}
else
{
return af;
}
+ private ColourSchemeI constructAnnotationColour(
+ AnnotationColours viewAnnColour, AlignFrame af, Alignment al,
+ JalviewModelSequence jms, boolean checkGroupAnnColour)
+ {
+ boolean propagateAnnColour = false;
+ ColourSchemeI cs = null;
+ AlignmentI annAlignment = af != null ? af.viewport.getAlignment() : al;
+ if (checkGroupAnnColour && al.getGroups() != null
+ && al.getGroups().size() > 0)
+ {
+ // pre 2.8.1 behaviour
+ // check to see if we should transfer annotation colours
+ propagateAnnColour = true;
+ for (jalview.datamodel.SequenceGroup sg : al.getGroups())
+ {
+ if (sg.cs instanceof AnnotationColourGradient)
+ {
+ propagateAnnColour = false;
+ }
+ }
+ }
+ // int find annotation
+ if (annAlignment.getAlignmentAnnotation() != null)
+ {
+ for (int i = 0; i < annAlignment.getAlignmentAnnotation().length; i++)
+ {
+ if (annAlignment.getAlignmentAnnotation()[i].label
+ .equals(viewAnnColour.getAnnotation()))
+ {
+ if (annAlignment.getAlignmentAnnotation()[i].getThreshold() == null)
+ {
+ annAlignment.getAlignmentAnnotation()[i]
+ .setThreshold(new jalview.datamodel.GraphLine(
+ viewAnnColour.getThreshold(), "Threshold",
+ java.awt.Color.black)
+
+ );
+ }
+
+ if (viewAnnColour.getColourScheme().equals("None"))
+ {
+ cs = new AnnotationColourGradient(
+ annAlignment.getAlignmentAnnotation()[i],
+ new java.awt.Color(viewAnnColour.getMinColour()),
+ new java.awt.Color(viewAnnColour.getMaxColour()),
+ viewAnnColour.getAboveThreshold());
+ }
+ else if (viewAnnColour.getColourScheme().startsWith("ucs"))
+ {
+ cs = new AnnotationColourGradient(
+ annAlignment.getAlignmentAnnotation()[i],
+ GetUserColourScheme(jms,
+ viewAnnColour.getColourScheme()),
+ viewAnnColour.getAboveThreshold());
+ }
+ else
+ {
+ cs = new AnnotationColourGradient(
+ annAlignment.getAlignmentAnnotation()[i],
+ ColourSchemeProperty.getColour(al,
+ viewAnnColour.getColourScheme()),
+ viewAnnColour.getAboveThreshold());
+ }
+ if (viewAnnColour.hasPerSequence())
+ {
+ ((AnnotationColourGradient) cs).setSeqAssociated(viewAnnColour
+ .isPerSequence());
+ }
+ if (viewAnnColour.hasPredefinedColours())
+ {
+ ((AnnotationColourGradient) cs)
+ .setPredefinedColours(viewAnnColour
+ .isPredefinedColours());
+ }
+ if (propagateAnnColour && al.getGroups() != null)
+ {
+ // Also use these settings for all the groups
+ for (int g = 0; g < al.getGroups().size(); g++)
+ {
+ jalview.datamodel.SequenceGroup sg = al.getGroups().get(g);
+
+ if (sg.cs == null)
+ {
+ continue;
+ }
+
+ /*
+ * if (viewAnnColour.getColourScheme().equals("None" )) { sg.cs =
+ * new AnnotationColourGradient(
+ * annAlignment.getAlignmentAnnotation()[i], new
+ * java.awt.Color(viewAnnColour. getMinColour()), new
+ * java.awt.Color(viewAnnColour. getMaxColour()),
+ * viewAnnColour.getAboveThreshold()); } else
+ */
+ {
+ sg.cs = new AnnotationColourGradient(
+ annAlignment.getAlignmentAnnotation()[i], sg.cs,
+ viewAnnColour.getAboveThreshold());
+ if (cs instanceof AnnotationColourGradient)
+ {
+ if (viewAnnColour.hasPerSequence())
+ {
+ ((AnnotationColourGradient) cs)
+ .setSeqAssociated(viewAnnColour.isPerSequence());
+ }
+ if (viewAnnColour.hasPredefinedColours())
+ {
+ ((AnnotationColourGradient) cs)
+ .setPredefinedColours(viewAnnColour
+ .isPredefinedColours());
+ }
+ }
+ }
+
+ }
+ }
+
+ break;
+ }
+
+ }
+ }
+ return cs;
+ }
+
private void reorderAutoannotation(AlignFrame af, Alignment al,
ArrayList<JvAnnotRow> autoAlan)
{