import jalview.datamodel.SequenceI;
import jalview.util.ColorUtils;
import jalview.util.Comparison;
-import jalview.util.MessageManager;
import java.awt.Color;
import java.util.Map;
/**
* Base class for residue-based colour schemes
*/
-public class ResidueColourScheme implements ColourSchemeI
+public abstract class ResidueColourScheme implements ColourSchemeI
{
public static final String NONE = "None";
+ public static final String USER_DEFINED = "User Defined";
+
/*
* lookup up by character value e.g. 'G' to the colors array index
* e.g. if symbolIndex['K'] = 11 then colors[11] is the colour for K
@Override
public Color findColour()
{
+ // TODO delete this method in favour of ColorUtils.parseColourString()?
return findColour('A');
}
{
}
- @Override
- public ColourSchemeI applyTo(AnnotatedCollectionI sg,
- Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
- {
- try
- {
- return getClass().newInstance();
- } catch (Exception q)
- {
- throw new Error(MessageManager.formatMessage(
- "error.implementation_error_cannot_duplicate_colour_scheme",
- new String[] { getClass().getName() }), q);
- }
- }
-
/**
* Answers false if the colour scheme is nucleotide or peptide specific, and
- * the data does not match, else false. Override to modify or extend this test
+ * the data does not match, else true. Override to modify or extend this test
* as required.
*/
@Override
}
/*
- * inspect the data context (alignment dataset) for residue type
+ * inspect the data context (alignment) for residue type
*/
boolean nucleotide = false;
- AnnotatedCollectionI context = ac.getContext();
- if (context != null)
+ if (ac instanceof AlignmentI)
{
+ nucleotide = ((AlignmentI) ac).isNucleotide();
+ }
+ else
+ {
+ AnnotatedCollectionI context = ac.getContext();
if (context instanceof AlignmentI)
{
nucleotide = ((AlignmentI) context).isNucleotide();
return true;
}
}
- else if (ac instanceof AlignmentI)
- {
- nucleotide = ((AlignmentI) ac).isNucleotide();
- }
- else
- {
- return true;
- }
/*
* does data type match colour scheme type?
return false;
}
+ /**
+ * Default method returns true. Override this to return false in colour
+ * schemes that are not determined solely by the sequence symbol.
+ */
@Override
- public String getSchemeName()
+ public boolean isSimple()
{
- return "Residue";
+ return true;
}
}