X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fschemes%2FJalviewColourScheme.java;h=e1fc02d2fe23b3b2cc6f0b864c105445696a11c6;hb=f2a83f0360d406859b80cc798099a9d270461bb3;hp=355ff834585e307ff5e2b83d0121268f0f489c59;hpb=b0cee3aaf7d8873910939f97b6acb217d518968d;p=jalview.git
diff --git a/src/jalview/schemes/JalviewColourScheme.java b/src/jalview/schemes/JalviewColourScheme.java
index 355ff83..e1fc02d 100644
--- a/src/jalview/schemes/JalviewColourScheme.java
+++ b/src/jalview/schemes/JalviewColourScheme.java
@@ -1,173 +1,53 @@
+/*
+ * 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 .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.schemes;
-import jalview.datamodel.AnnotatedCollectionI;
-
-import java.awt.Color;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* An enum with the colour schemes supported by Jalview.
*/
public enum JalviewColourScheme
{
- Clustal("Clustal")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new ClustalxColourScheme(coll, null);
- }
- },
- Blosum62("Blosum62")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new Blosum62ColourScheme();
- }
- },
- PID("% Identity")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new PIDColourScheme();
- }
- },
- Zappo("Zappo")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new ZappoColourScheme();
- }
- },
- Taylor("Taylor")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new TaylorColourScheme();
- }
- },
- Hydrophobic("Hydrophobic")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new HydrophobicColourScheme();
- }
- },
- Helix("Helix Propensity")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new HelixColourScheme();
- }
- },
- Strand("Strand Propensity")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new StrandColourScheme();
- }
- },
- Turn("Turn Propensity")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new TurnColourScheme();
- }
- },
- Buried("Buried Index")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new BuriedColourScheme();
- }
- },
- Nucleotide("Nucleotide")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new NucleotideColourScheme();
- }
- },
- PurinePyrimidine("Purine/Pyrimidine")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new PurinePyrimidineColourScheme();
- }
- },
- TCoffee("T-Coffee Scores")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new TCoffeeColourScheme(coll);
- }
- },
- RNAHelices("RNA Helices")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- return new RNAHelicesColour(coll);
- }
- },
- // RNAInteraction("RNA Interaction type")
- // {
- // @Override
- // public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- // {
- // return new RNAInteractionColourScheme();
- // }
- // },
- UserDefined("User Defined")
- {
- @Override
- public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
- {
- Color[] col = new Color[24];
- for (int i = 0; i < 24; i++)
- {
- col[i] = Color.white;
- }
- return new UserColourScheme("white");
- }
- };
-
- static Map names = new HashMap();
+ /*
+ * the order of declaration is the default order in which
+ * items are added to Colour menus
+ */
+ Clustal("Clustal", ClustalxColourScheme.class),
+ Blosum62("Blosum62", Blosum62ColourScheme.class),
+ PID("% Identity", PIDColourScheme.class),
+ Zappo("Zappo", ZappoColourScheme.class),
+ Taylor("Taylor", TaylorColourScheme.class),
+ Hydrophobic("Hydrophobic", HydrophobicColourScheme.class),
+ Helix("Helix Propensity", HelixColourScheme.class),
+ Strand("Strand Propensity", StrandColourScheme.class),
+ Turn("Turn Propensity", TurnColourScheme.class),
+ Buried("Buried Index", BuriedColourScheme.class),
+ Nucleotide("Nucleotide", NucleotideColourScheme.class),
+ PurinePyrimidine("Purine/Pyrimidine", PurinePyrimidineColourScheme.class),
+ RNAHelices("RNA Helices", RNAHelicesColour.class),
+ TCoffee("T-Coffee Scores", TCoffeeColourScheme.class);
+ // RNAInteraction("RNA Interaction type", RNAInteractionColourScheme.class)
private String name;
- static
- {
- for (JalviewColourScheme scheme : values())
- {
- names.put(scheme.name.toLowerCase(), scheme);
- }
- }
-
- /**
- * Answers the colour scheme with the 'given name', or null if name is invalid
- * or null. The name is not case-sensitive.
- *
- * @param name
- * @return
- */
- public static JalviewColourScheme forName(String name)
- {
- return name == null ? null : names.get(name.toLowerCase());
- }
+ private Class extends ColourSchemeI> myClass;
/**
* Constructor given the name of the colour scheme (as used in Jalview
@@ -176,19 +56,21 @@ public enum JalviewColourScheme
*
* @param s
*/
- JalviewColourScheme(String s)
+ JalviewColourScheme(String s, Class extends ColourSchemeI> cl)
{
name = s;
+ myClass = cl;
}
/**
- * Returns an instance of the colour scheme with which to colour the given
- * data
+ * Returns the class of the colour scheme
*
- * @param coll
* @return
*/
- public abstract ColourSchemeI getColourScheme(AnnotatedCollectionI coll);
+ public Class extends ColourSchemeI> getSchemeClass()
+ {
+ return myClass;
+ }
/**
* Returns the 'official' name of this colour scheme. This is the name that