git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-2939 no need to recalc HMM annotation for show/hide logo
[jalview.git]
/
src
/
jalview
/
schemes
/
ResidueColourScheme.java
diff --git
a/src/jalview/schemes/ResidueColourScheme.java
b/src/jalview/schemes/ResidueColourScheme.java
index
6a2a479
..
2f7a5e0
100755
(executable)
--- a/
src/jalview/schemes/ResidueColourScheme.java
+++ b/
src/jalview/schemes/ResidueColourScheme.java
@@
-20,9
+20,9
@@
*/
package jalview.schemes;
*/
package jalview.schemes;
-import jalview.datamodel.AlignmentI;
import jalview.datamodel.AnnotatedCollectionI;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.AnnotatedCollectionI;
import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import java.awt.Color;
import jalview.datamodel.SequenceI;
import java.awt.Color;
@@
-35,9
+35,17
@@
public abstract class ResidueColourScheme implements ColourSchemeI
{
public static final String NONE = "None";
{
public static final String NONE = "None";
+ /*
+ * default display name for a user defined colour scheme
+ */
public static final String USER_DEFINED = "User Defined";
/*
public static final String USER_DEFINED = "User Defined";
/*
+ * name for (new) "User Defined.." colour scheme menu item
+ */
+ public static final String USER_DEFINED_MENU = "*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
*/
* 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
*/
@@
-54,8
+62,9
@@
public abstract class ResidueColourScheme implements ColourSchemeI
/**
* Creates a new ResidueColourScheme object.
*
/**
* Creates a new ResidueColourScheme object.
*
- * @param final int[] index table into colors (ResidueProperties.naIndex or
- * ResidueProperties.aaIndex)
+ * @param final
+ * int[] index table into colors (ResidueProperties.naIndex or
+ * ResidueProperties.aaIndex)
* @param colors
* colours for symbols in sequences
*/
* @param colors
* colours for symbols in sequences
*/
@@
-84,23
+93,19
@@
public abstract class ResidueColourScheme implements ColourSchemeI
}
/**
}
/**
- * Returns the colour for symbol 'A'. Intended for use in a 'fixed colour'
- * colour scheme (for example a feature colour).
- */
- @Override
- public Color findColour()
- {
- // TODO delete this method in favour of ColorUtils.parseColourString()?
- return findColour('A');
- }
-
- /**
* Find a colour without an index in a sequence
*/
* Find a colour without an index in a sequence
*/
- @Override
public Color findColour(char c)
{
public Color findColour(char c)
{
- return colors == null ? Color.white : colors[symbolIndex[c]];
+ Color colour = Color.white;
+
+ if (colors != null && symbolIndex != null && c < symbolIndex.length
+ && symbolIndex[c] < colors.length)
+ {
+ colour = colors[symbolIndex[c]];
+ }
+
+ return colour;
}
/**
}
/**
@@
-115,18
+120,19
@@
public abstract class ResidueColourScheme implements ColourSchemeI
return findColour(c, j, seq);
}
return findColour(c, j, seq);
}
+ /**
+ * Default implementation looks up the residue colour in a fixed scheme, or
+ * returns White if not found. Override this method for a colour scheme that
+ * depends on the column position or sequence.
+ *
+ * @param c
+ * @param j
+ * @param seq
+ * @return
+ */
protected Color findColour(char c, int j, SequenceI seq)
{
protected Color findColour(char c, int j, SequenceI seq)
{
- Color colour = Color.white;
-
- if (colors != null && symbolIndex != null && c < symbolIndex.length
- && symbolIndex[c] < colors.length)
- {
- colour = colors[symbolIndex[c]];
- }
- // colour = adjustColour(c, j, colour);
-
- return colour;
+ return findColour(c);
}
@Override
}
@Override
@@
-147,30
+153,26
@@
public abstract class ResidueColourScheme implements ColourSchemeI
{
return true;
}
{
return true;
}
-
- /*
- * inspect the data context (alignment) for residue type
- */
- boolean nucleotide = false;
- if (ac instanceof AlignmentI)
+ if (ac == null)
{
{
- nucleotide = ((AlignmentI) ac).isNucleotide();
+ return true;
}
}
- else
+ /*
+ * pop-up menu on selection group before group created
+ * (no alignment context)
+ */
+ // TODO: add nucleotide flag to SequenceGroup?
+ if (ac instanceof SequenceGroup && ac.getContext() == null)
{
{
- AnnotatedCollectionI context = ac.getContext();
- if (context instanceof AlignmentI)
- {
- nucleotide = ((AlignmentI) context).isNucleotide();
- }
- else
- {
- // not sure what's going on, play safe
- return true;
- }
+ return true;
}
/*
}
/*
+ * inspect the data context (alignment) for residue type
+ */
+ boolean nucleotide = ac.isNucleotide();
+
+ /*
* does data type match colour scheme type?
*/
return (nucleotide && isNucleotideSpecific())
* does data type match colour scheme type?
*/
return (nucleotide && isNucleotideSpecific())
@@
-206,4
+208,14
@@
public abstract class ResidueColourScheme implements ColourSchemeI
{
return true;
}
{
return true;
}
+
+ /**
+ * Default method returns false. Override this to return true in colour
+ * schemes that have a colour associated with gap residues.
+ */
+ @Override
+ public boolean hasGapColour()
+ {
+ return false;
+ }
}
}