JAL-3127 Colour sequences by ID - need to check that group colours are properly propa...
authorJim Procter <jprocter@issues.jalview.org>
Tue, 9 Oct 2018 12:31:19 +0000 (13:31 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 9 Oct 2018 12:31:19 +0000 (13:31 +0100)
src/jalview/schemes/IdColourScheme.java [new file with mode: 0644]
src/jalview/schemes/JalviewColourScheme.java

diff --git a/src/jalview/schemes/IdColourScheme.java b/src/jalview/schemes/IdColourScheme.java
new file mode 100644 (file)
index 0000000..a96ac0f
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ 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.
+ *  
+ * 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/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.schemes;
+
+import jalview.api.AlignViewportI;
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+
+import java.awt.Color;
+import java.util.Map;
+
+public class IdColourScheme implements ColourSchemeI
+{
+  AlignViewportI view = null;
+
+  AnnotatedCollectionI coll = null;
+
+  public IdColourScheme()
+  {
+
+  }
+  public IdColourScheme(AlignViewportI view, AnnotatedCollectionI coll)
+  {
+    this.view = view;
+    this.coll = coll;
+  }
+
+
+  @Override
+  public String getSchemeName()
+  {
+    return JalviewColourScheme.IdColour.toString();
+  }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AlignViewportI view,
+          AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new IdColourScheme(view, coll);
+  }
+
+  @Override
+  public void alignmentChanged(AnnotatedCollectionI alignment,
+          Map<SequenceI, SequenceCollectionI> hiddenReps)
+  {
+  }
+
+  @Override
+  public Color findColour(char symbol, int position, SequenceI seq,
+          String consensusResidue, float pid)
+  {
+    return (view == null) ? Color.WHITE
+            : ((coll instanceof SequenceGroup)
+                    ? ((SequenceGroup) coll).idColour
+                    : view.getSequenceColour(seq));
+  }
+
+  @Override
+  public boolean hasGapColour()
+  {
+    return false;
+  }
+
+  @Override
+  public boolean isApplicableTo(AnnotatedCollectionI ac)
+  {
+    return true;
+  }
+
+  @Override
+  public boolean isSimple()
+  {
+    // this is really a sequence colour
+    return true;
+  }
+}
index e1fc02d..4422d72 100644 (file)
@@ -42,7 +42,8 @@ public enum JalviewColourScheme
   Nucleotide("Nucleotide", NucleotideColourScheme.class),
   PurinePyrimidine("Purine/Pyrimidine", PurinePyrimidineColourScheme.class),
   RNAHelices("RNA Helices", RNAHelicesColour.class),
-  TCoffee("T-Coffee Scores", TCoffeeColourScheme.class);
+  TCoffee("T-Coffee Scores", TCoffeeColourScheme.class),
+  IdColour("Sequence IDs", IdColourScheme.class);
   // RNAInteraction("RNA Interaction type", RNAInteractionColourScheme.class)
 
   private String name;