package jalview.schemes;
-import jalview.api.AlignViewportI;
import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
import java.util.LinkedHashMap;
import java.util.Map;
*
* @param name
* name of the colour scheme
- * @param viewport
+ * @param forData
+ * the data to be coloured
+ * @param optional
+ * map from hidden representative sequences to the sequences they
+ * represent
* @return
*/
- public ColourSchemeI getColourScheme(String name, AlignViewportI viewport)
+ public ColourSchemeI getColourScheme(String name,
+ AnnotatedCollectionI forData,
+ Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
{
if (name == null)
{
return null;
}
ColourSchemeI cs = schemes.get(name.toLowerCase());
- return cs == null ? null : cs.getInstance(viewport.getAlignment(),
- viewport.getHiddenRepSequences());
+ return cs == null ? null : cs.getInstance(forData, hiddenRepSequences);
}
/**
- * Returns an instance of the colour scheme with which the given data may be
+ * Returns an instance of the colour scheme with which the given view may be
* coloured
*
* @param name
+ * name of the colour scheme
* @param forData
+ * the data to be coloured
* @return
*/
public ColourSchemeI getColourScheme(String name,
AnnotatedCollectionI forData)
{
- ColourSchemeI cs = schemes.get(name.toLowerCase());
- return cs == null ? null : cs.getInstance(forData, null);
+ return getColourScheme(name, forData, null);
}
/**
{
return schemes.values();
}
+
+ /**
+ * Answers true if there is a scheme with the given name, else false. The test
+ * is not case-sensitive.
+ *
+ * @param name
+ * @return
+ */
+ public boolean nameExists(String name)
+ {
+ if (name == null)
+ {
+ return false;
+ }
+ name = name.toLowerCase();
+ for (ColourSchemeI scheme : getColourSchemes())
+ {
+ if (name.equals(scheme.getSchemeName().toLowerCase()))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
}