/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
* Copyright (C) 2014 The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.gui;
}
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 = constructAnnotationColours(
+ (jalview.schemes.AnnotationColourGradient) av
+ .getGlobalColourScheme(),
+ userColours, 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());
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 (object.getJalviewModelSequence().getViewportCount() > 0)
{
af = _af;
- if (object.getJalviewModelSequence().getViewportCount() > 1
- && af.viewport.gatherViewsHere)
+ if (af.viewport.gatherViewsHere)
{
gatherToThisFrame.put(af.viewport.getSequenceSetId(), af);
}
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)
// and finally return.
return af;
}
- Vector<AppJmol> newStructureViewers=null;
+
+ /**
+ *
+ * @param supported - minimum version we are comparing against
+ * @param version - version of data being processsed.
+ * @return true if version is development/null or evaluates to the same or
+ * later X.Y.Z (where X,Y,Z are like [0-9]+b?[0-9]*)
+ */
+ private boolean isVersionStringLaterThan(String supported, String version)
+ {
+ if (version == null || version.equalsIgnoreCase("DEVELOPMENT BUILD")
+ || version.equalsIgnoreCase("Test") || version.equalsIgnoreCase("AUTOMATED BUILD"))
+ {
+ System.err.println("Assuming project file with "
+ + (version == null ? "null" : version)
+ + " is compatible with Jalview version " + supported);
+ return true;
+ }
+ else
+ {
+ StringTokenizer currentV = new StringTokenizer(supported, "."), fileV = new StringTokenizer(
+ version, ".");
+ while (currentV.hasMoreTokens() && fileV.hasMoreTokens())
+ {
+ // convert b to decimal to catch bugfix releases within a series
+ String curT = currentV.nextToken().toLowerCase().replace('b', '.');
+ String fileT = fileV.nextToken().toLowerCase().replace('b', '.');
+ try
+ {
+ if (Float.valueOf(curT) > Float.valueOf(fileT))
+ {
+ // current version is newer than the version that wrote the file
+ return false;
+ }
+ } catch (NumberFormatException nfe)
+ {
+ System.err
+ .println("** WARNING: Version comparison failed for tokens ("
+ + curT
+ + ") and ("
+ + fileT
+ + ")\n** Current: '"
+ + supported + "' and Version: '" + version + "'");
+ }
+ }
+ if (currentV.hasMoreElements())
+ {
+ // fileV has no minor version but identical series to current
+ return false;
+ }
+ }
+ return true;
+ }
+
+ Vector<AppJmol> newStructureViewers = null;
+
protected void addNewStructureViewer(AppJmol sview)
{
if (newStructureViewers != 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);
+ // annpos
- 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());
- }
- }
- }
-
- }
- }
-
- 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)
{