ap.av.alignment.getWidth()));\r
int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs,\r
getGroup().getName());\r
- if (sg.cs instanceof ResidueColourScheme)\r
- {\r
- ( (ResidueColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
- }\r
- else if (sg.cs instanceof ScoreColourScheme)\r
- {\r
- ( (ScoreColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
- }\r
+\r
+ sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
\r
SliderPanel.showPIDSlider();\r
\r
}\r
else // remove PIDColouring\r
{\r
- ResidueColourScheme rcs = (ResidueColourScheme) sg.cs;\r
- rcs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
- sg.cs = rcs;\r
+ sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
}\r
\r
refresh();\r
\r
c.calculate();\r
c.verdict(false, ap.av.ConsPercGaps);\r
- ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);\r
\r
- sg.cs = ccs;\r
+ sg.cs.setConservation(c);\r
\r
- SliderPanel.setConservationSlider(ap, ccs, sg.getName());\r
+ SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());\r
SliderPanel.showConservationSlider();\r
}\r
else // remove ConservationColouring\r
{\r
- ConservationColourScheme ccs = (ConservationColourScheme) sg.cs;\r
- sg.cs = ccs.cs;\r
+ sg.cs.setConservation(null);\r
}\r
\r
refresh();\r
sg.setEndRes(viewport.alignment.getWidth());\r
viewport.setSelectionGroup(sg);\r
alignPanel.repaint();\r
- PaintRefresher.Refresh(null);\r
+ PaintRefresher.Refresh(null, viewport.alignment);\r
}\r
\r
public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)\r
viewport.setSelectionGroup(null);\r
viewport.getColumnSelection().clear();\r
viewport.setSelectionGroup(null);\r
- PaintRefresher.Refresh(null);\r
+ PaintRefresher.Refresh(null, viewport.alignment);\r
}\r
\r
public void invertSequenceMenuItem_actionPerformed(ActionEvent e)\r
sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);\r
}\r
\r
- PaintRefresher.Refresh(null);\r
+ PaintRefresher.Refresh(null, viewport.alignment);\r
}\r
\r
public void remove2LeftMenuItem_actionPerformed(ActionEvent e)\r
{\r
threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background");\r
\r
- if (cs instanceof ResidueColourScheme)\r
- {\r
- ( (ResidueColourScheme) cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
- }\r
+ cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
\r
viewport.setGlobalColourScheme(cs);\r
}\r
- else if (cs instanceof ResidueColourScheme)\r
+ else\r
{\r
- ( (ResidueColourScheme) cs).setThreshold(0, viewport.getIgnoreGapsConsensus());\r
+ cs.setThreshold(0, viewport.getIgnoreGapsConsensus());\r
}\r
\r
if (viewport.getConservationSelected())\r
{\r
- ConservationColourScheme ccs = null;\r
\r
Alignment al = (Alignment) viewport.alignment;\r
Conservation c = new Conservation("All",\r
c.calculate();\r
c.verdict(false, viewport.ConsPercGaps);\r
\r
- ccs = new ConservationColourScheme(c, cs);\r
+ cs.setConservation(c);\r
\r
// MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
- ccs.setConsensus(viewport.vconsensus);\r
- viewport.setGlobalColourScheme(ccs);\r
+ cs.setConsensus(viewport.vconsensus);\r
+ viewport.setGlobalColourScheme(cs);\r
\r
- SliderPanel.setConservationSlider(alignPanel, ccs, "Background");\r
+ SliderPanel.setConservationSlider(alignPanel, cs, "Background");\r
\r
}\r
else\r
\r
if (viewport.getAbovePIDThreshold())\r
{\r
- if (sg.cs instanceof ResidueColourScheme)\r
- {\r
- ( (ResidueColourScheme) sg.cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
- }\r
+ sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
\r
sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
}\r
viewport.alignment.getWidth() - 1);\r
c.calculate();\r
c.verdict(false, viewport.ConsPercGaps);\r
- ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);\r
\r
// MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
- ccs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
- sg.cs = ccs;\r
+ cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
+ sg.cs = cs;\r
}\r
else\r
{\r
viewport.setAbovePIDThreshold(false);\r
abovePIDThreshold.setState(false);\r
\r
- ColourSchemeI cs = viewport.getGlobalColourScheme();\r
- if (cs instanceof ConservationColourScheme)\r
- {\r
- changeColour( ( (ConservationColourScheme) cs).cs);\r
- }\r
- else\r
- {\r
- changeColour(cs);\r
- }\r
+ changeColour(viewport.getGlobalColourScheme());\r
\r
modifyConservation_actionPerformed(null);\r
}\r
conservationMenuItem.setState(false);\r
viewport.setConservationSelected(false);\r
\r
- ColourSchemeI cs = viewport.getGlobalColourScheme();\r
-\r
- if (cs instanceof ConservationColourScheme)\r
- {\r
- changeColour( ( (ConservationColourScheme) cs).cs);\r
- }\r
- else\r
- {\r
- changeColour(cs);\r
- }\r
+ changeColour(viewport.getGlobalColourScheme());\r
\r
modifyPID_actionPerformed(null);\r
}\r
{\r
ignoreGapsInConsensusCalculation = b;\r
updateConsensus();\r
- if (globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme)\r
+ if (globalColourScheme!=null)\r
{\r
- ( (ResidueColourScheme) globalColourScheme).setThreshold(\r
- ( (ResidueColourScheme) globalColourScheme).getThreshold(),\r
+ globalColourScheme.setThreshold(globalColourScheme.getThreshold(),\r
ignoreGapsInConsensusCalculation);\r
\r
}\r
\r
}\r
\r
- public void setColourScheme()\r
- {\r
- ColourSchemeI cs = av.getGlobalColourScheme();\r
-\r
- if (av.getConservationSelected())\r
- {\r
-\r
- Alignment al = (Alignment) av.getAlignment();\r
- Conservation c = new Conservation("All",\r
- ResidueProperties.propHash, 3,\r
- al.getSequences(), 0,\r
- al.getWidth());\r
-\r
- c.calculate();\r
- c.verdict(false, av.ConsPercGaps);\r
- ConservationColourScheme ccs = new ConservationColourScheme(c, cs);\r
-\r
- av.setGlobalColourScheme(ccs);\r
-\r
- }\r
-\r
- repaint();\r
- }\r
\r
int hextent = 0;\r
int vextent = 0;\r
\r
// Y O Y CLUSTALX\r
ColourSchemeI cs = av.getGlobalColourScheme();\r
- if (cs instanceof ConservationColourScheme)\r
+ if (cs.conservationApplied())\r
{\r
- ConservationColourScheme ccs = (ConservationColourScheme) cs;\r
- if (ccs.cs instanceof ClustalxColourScheme)\r
+ if (cs instanceof ClustalxColourScheme)\r
{\r
jalview.analysis.Conservation c = new jalview.analysis.Conservation\r
("All",\r
c.calculate();\r
c.verdict(false, av.ConsPercGaps);\r
\r
- ClustalxColourScheme cxs = (ClustalxColourScheme) ccs.cs;\r
- cxs.resetClustalX(av.alignment.getSequences(), av.alignment.getWidth());\r
- ccs = new ConservationColourScheme(c, cxs);\r
- av.setGlobalColourScheme(ccs);\r
+ ((ClustalxColourScheme)cs).resetClustalX(av.alignment.getSequences(), av.alignment.getWidth());\r
+ cs.setConservation(c);\r
+ av.setGlobalColourScheme(cs);\r
}\r
}\r
\r
return;\r
}\r
\r
- if (stretchGroup.cs instanceof ConservationColourScheme)\r
- {\r
- ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs;\r
- stretchGroup.cs = ccs;\r
- SliderPanel.setConservationSlider(ap, stretchGroup.cs,\r
- stretchGroup.getName());\r
- }\r
- else\r
+ if(stretchGroup.cs!=null)\r
{\r
+ if (stretchGroup.cs.conservationApplied())\r
+ {\r
+ SliderPanel.setConservationSlider(ap, stretchGroup.cs,\r
+ stretchGroup.getName());\r
+ }\r
+ else\r
+ {\r
SliderPanel.setPIDSliderSource(ap, stretchGroup.cs,\r
stretchGroup.getName());\r
+ }\r
}\r
-\r
changeEndRes = false;\r
changeStartRes = false;\r
stretchGroup = null;\r
String source)\r
{\r
SliderPanel sp = null;\r
- ConservationColourScheme ccs = (ConservationColourScheme) cs;\r
\r
if (conservationSlider == null)\r
{\r
- sp = new SliderPanel(ap, ccs.inc, true, cs);\r
+ sp = new SliderPanel(ap, cs.getConservationInc(), true, cs);\r
conservationSlider = new Frame();\r
conservationSlider.add(sp);\r
}\r
\r
if (forConservation)\r
{\r
- if (toChange instanceof ConservationColourScheme)\r
- {\r
- ( (ConservationColourScheme) toChange).inc = i;\r
- }\r
+ toChange.setConservationInc(i);\r
}\r
else\r
{\r
- ( (ResidueColourScheme) toChange).setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
+ toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
}\r
\r
groupIndex--;\r
false, 0, av.alignment.getWidth());\r
\r
\r
- if (av.getGlobalColourScheme() instanceof ConservationColourScheme)\r
+ if (av.getGlobalColourScheme().conservationApplied())\r
{\r
- ConservationColourScheme ccs = (ConservationColourScheme) av.\r
- getGlobalColourScheme();\r
Conservation c = new Conservation("Group",\r
ResidueProperties.propHash, 3,\r
sg.sequences, sg.getStartRes(),\r
\r
c.calculate();\r
c.verdict(false, av.ConsPercGaps);\r
- ccs = new ConservationColourScheme(c, ccs.cs);\r
+ cs.setConservation(c);\r
\r
- sg.cs = ccs;\r
+ sg.cs = cs;\r
\r
}\r
\r
*/\r
public void recalcConservation()\r
{\r
- if (cs != null)\r
- {\r
- cs.setConsensus(AAFrequency.calculate(sequences, 0, getWidth()));\r
- }\r
+ if(cs == null)\r
+ return;\r
+\r
+ cs.setConsensus(AAFrequency.calculate(sequences, 0, getWidth()));\r
+\r
\r
if (cs instanceof ClustalxColourScheme)\r
{\r
((ClustalxColourScheme) cs).resetClustalX(sequences, getWidth());\r
}\r
\r
- if (cs instanceof ConservationColourScheme)\r
+\r
+ if (cs.conservationApplied())\r
{\r
Conservation c = new Conservation(groupName,\r
ResidueProperties.propHash, 3, sequences, 0, getWidth());\r
c.calculate();\r
c.verdict(false, 25);\r
\r
- ConservationColourScheme ccs = (ConservationColourScheme) cs;\r
- ccs.conserve = c;\r
\r
- if (ccs.cs instanceof ClustalxColourScheme)\r
+ cs.setConservation(c);\r
+\r
+ if (cs instanceof ClustalxColourScheme)\r
{\r
- ((ClustalxColourScheme) ccs.cs).resetClustalX(sequences,\r
+ ((ClustalxColourScheme) cs).resetClustalX(sequences,\r
getWidth());\r
}\r
}\r
* GNU General Public License for more details.\r
*\r
* You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
+ * along with this program; if not, write to the Free Softwarechang\r
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
*/\r
package jalview.gui;\r
{\r
int threshold = 0;\r
\r
- if (viewport.getAbovePIDThreshold())\r
+ if(cs!=null)\r
{\r
- threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,\r
- "Background");\r
-\r
- if (cs instanceof ResidueColourScheme)\r
+ if (viewport.getAbovePIDThreshold())\r
{\r
- ( (ResidueColourScheme) cs).setThreshold(threshold,\r
- viewport.\r
- getIgnoreGapsConsensus());\r
+ threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,\r
+ "Background");\r
+\r
+ cs.setThreshold(threshold,\r
+ viewport.getIgnoreGapsConsensus());\r
+\r
+ viewport.setGlobalColourScheme(cs);\r
}\r
- else if (cs instanceof ScoreColourScheme)\r
+ else\r
{\r
- ( (ScoreColourScheme) cs).setThreshold(threshold,\r
- viewport.getIgnoreGapsConsensus());\r
+ cs.setThreshold(0, viewport.getIgnoreGapsConsensus());\r
}\r
\r
- viewport.setGlobalColourScheme(cs);\r
- }\r
- else if (cs instanceof ResidueColourScheme)\r
- {\r
- ( (ResidueColourScheme) cs).setThreshold(0,\r
- viewport.getIgnoreGapsConsensus());\r
- }\r
-\r
-\r
- if (viewport.getConservationSelected())\r
- {\r
- ConservationColourScheme ccs = null;\r
-\r
- Alignment al = (Alignment) viewport.alignment;\r
- Conservation c = new Conservation("All",\r
- ResidueProperties.propHash, 3,\r
- al.getSequences(), 0,\r
- al.getWidth() - 1);\r
-\r
- c.calculate();\r
- c.verdict(false, viewport.ConsPercGaps);\r
+ if (viewport.getConservationSelected())\r
+ {\r
\r
- ccs = new ConservationColourScheme(c, cs);\r
+ Alignment al = (Alignment) viewport.alignment;\r
+ Conservation c = new Conservation("All",\r
+ ResidueProperties.propHash, 3,\r
+ al.getSequences(), 0,\r
+ al.getWidth() - 1);\r
\r
- ccs.setConsensus(viewport.vconsensus);\r
+ c.calculate();\r
+ c.verdict(false, viewport.ConsPercGaps);\r
\r
- viewport.setGlobalColourScheme(ccs);\r
+ cs.setConservation(c);\r
\r
- ccs.inc = SliderPanel.setConservationSlider(alignPanel, ccs,\r
- "Background");\r
- }\r
- else\r
- {\r
- // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
- if (cs != null)\r
+ cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,\r
+ "Background"));\r
+ }\r
+ else\r
{\r
- cs.setConsensus(viewport.vconsensus);\r
+ cs.setConservation(null);\r
}\r
\r
- viewport.setGlobalColourScheme(cs);\r
+ cs.setConsensus(viewport.vconsensus);\r
}\r
\r
+ viewport.setGlobalColourScheme(cs);\r
+\r
if (viewport.getColourAppliesToAllGroups())\r
{\r
Vector groups = viewport.alignment.getGroups();\r
if (cs == null)\r
{\r
sg.cs = null;\r
+ continue;\r
}\r
- else if (cs instanceof ClustalxColourScheme)\r
+\r
+ if (cs instanceof ClustalxColourScheme)\r
{\r
sg.cs = new ClustalxColourScheme(sg.sequences, sg.getWidth());\r
}\r
\r
if (viewport.getAbovePIDThreshold())\r
{\r
- if (sg.cs instanceof ResidueColourScheme)\r
- {\r
- ( (ResidueColourScheme) sg.cs).setThreshold(threshold,\r
+ sg.cs.setThreshold(threshold,\r
viewport.getIgnoreGapsConsensus());\r
- }\r
\r
sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
sg.getWidth()));\r
}\r
+ else\r
+ sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());\r
+\r
\r
if (viewport.getConservationSelected())\r
{\r
viewport.alignment.getWidth() - 1);\r
c.calculate();\r
c.verdict(false, viewport.ConsPercGaps);\r
-\r
- ConservationColourScheme ccs = new ConservationColourScheme(c,\r
- sg.cs);\r
-\r
- // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
- ccs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
- sg.getWidth()));\r
- sg.cs = ccs;\r
- }\r
- else if (cs != null)\r
- {\r
- // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
- sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
- sg.getWidth()));\r
+ sg.cs.setConservation(c);\r
}\r
+ else\r
+ sg.cs.setConservation(null);\r
}\r
}\r
\r
*/\r
protected void modifyPID_actionPerformed(ActionEvent e)\r
{\r
- if (viewport.getAbovePIDThreshold())\r
+ if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)\r
{\r
SliderPanel.setPIDSliderSource(alignPanel,\r
viewport.getGlobalColourScheme(),\r
*/\r
protected void modifyConservation_actionPerformed(ActionEvent e)\r
{\r
- if (viewport.getConservationSelected())\r
+ if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)\r
{\r
SliderPanel.setConservationSlider(alignPanel,\r
viewport.globalColourScheme,\r
viewport.setAbovePIDThreshold(false);\r
abovePIDThreshold.setSelected(false);\r
\r
- ColourSchemeI cs = viewport.getGlobalColourScheme();\r
-\r
- if (cs instanceof ConservationColourScheme)\r
- {\r
- changeColour( ( (ConservationColourScheme) cs).cs);\r
- }\r
- else\r
- {\r
- changeColour(cs);\r
- }\r
+ changeColour(viewport.getGlobalColourScheme());\r
\r
modifyConservation_actionPerformed(null);\r
}\r
\r
ColourSchemeI cs = viewport.getGlobalColourScheme();\r
\r
- if (cs instanceof ConservationColourScheme)\r
- {\r
- changeColour( ( (ConservationColourScheme) cs).cs);\r
- }\r
- else\r
- {\r
- changeColour(cs);\r
- }\r
+ changeColour(viewport.getGlobalColourScheme());\r
\r
modifyPID_actionPerformed(null);\r
}\r
{\r
ignoreGapsInConsensusCalculation = b;\r
updateConsensus();\r
- if(globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme)\r
+ if(globalColourScheme!=null)\r
{\r
- ((ResidueColourScheme) globalColourScheme).setThreshold(\r
- ((ResidueColourScheme) globalColourScheme).getThreshold(), ignoreGapsInConsensusCalculation);\r
-\r
-\r
+ globalColourScheme.setThreshold(globalColourScheme.getThreshold(), ignoreGapsInConsensusCalculation);\r
}\r
\r
}\r
repaint();\r
}\r
\r
- /**\r
- * DOCUMENT ME!\r
- */\r
- public void setColourScheme()\r
- {\r
- ColourSchemeI cs = av.getGlobalColourScheme();\r
-\r
- if (av.getConservationSelected())\r
- {\r
- Alignment al = (Alignment) av.getAlignment();\r
- Conservation c = new Conservation("All",\r
- ResidueProperties.propHash, 3, al.getSequences(), 0,\r
- al.getWidth());\r
-\r
- c.calculate();\r
- c.verdict(false, av.ConsPercGaps);\r
-\r
- ConservationColourScheme ccs = new ConservationColourScheme(c, cs);\r
-\r
- av.setGlobalColourScheme(ccs);\r
- }\r
-\r
- repaint();\r
- }\r
\r
// return value is true if the scroll is valid\r
public boolean scrollUp(boolean up)\r
groups[i].setEnd(sg.getEndRes());\r
groups[i].setName(sg.getName());\r
\r
- if (sg.cs instanceof ConservationColourScheme)\r
+ if (sg.cs.conservationApplied())\r
{\r
- ConservationColourScheme ccs = (ConservationColourScheme) sg.cs;\r
- groups[i].setConsThreshold(ccs.inc);\r
+ groups[i].setConsThreshold(sg.cs.getConservationInc());\r
\r
- if (ccs.cs instanceof jalview.schemes.UserColourScheme)\r
+ if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
{\r
- groups[i].setColour(SetUserColourScheme(ccs.cs, userColours,\r
+ groups[i].setColour(SetUserColourScheme(sg.cs, userColours,\r
jms));\r
}\r
else\r
sg.cs));\r
}\r
\r
- if (sg.cs instanceof ResidueColourScheme)\r
- {\r
- groups[i].setPidThreshold(((ResidueColourScheme) sg.cs).getThreshold());\r
- }\r
-\r
\r
+ groups[i].setPidThreshold( sg.cs.getThreshold() );\r
\r
groups[i].setOutlineColour(sg.getOutlineColour().getRGB());\r
groups[i].setDisplayBoxes(sg.getDisplayBoxes());\r
\r
ColourSchemeI cs = av.getGlobalColourScheme();\r
\r
- if (cs instanceof ConservationColourScheme)\r
+ if (cs.conservationApplied())\r
{\r
- ConservationColourScheme ccs = (ConservationColourScheme)cs;\r
- view.setConsThreshold(ccs.inc);\r
- if(ccs.cs instanceof jalview.schemes.UserColourScheme)\r
- view.setBgColour(SetUserColourScheme(ccs.cs, userColours, jms));\r
+ view.setConsThreshold(cs.getConservationInc());\r
+ if(cs instanceof jalview.schemes.UserColourScheme)\r
+ view.setBgColour(SetUserColourScheme(cs, userColours, jms));\r
}\r
\r
if (cs instanceof ResidueColourScheme)\r
{\r
- view.setPidThreshold(((ResidueColourScheme) cs).getThreshold());\r
+ view.setPidThreshold( cs.getThreshold() );\r
}\r
\r
view.setConservationSelected(av.getConservationSelected());\r
groups[i].getColour());\r
}\r
\r
- if (cs instanceof ResidueColourScheme)\r
- {\r
- ((ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold(), true);\r
- }\r
+ cs.setThreshold(groups[i].getPidThreshold(), true);\r
}\r
\r
Vector seqs = new Vector();\r
sg.getWidth() - 1);\r
c.calculate();\r
c.verdict(false, 25);\r
- cs = new ConservationColourScheme(c, cs);\r
- sg.cs = cs;\r
+ sg.cs.setConservation(c);\r
}\r
\r
al.addGroup(sg);\r
cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r
}\r
\r
- if (cs instanceof ResidueColourScheme)\r
- {\r
- ((ResidueColourScheme) cs).setThreshold(view.getPidThreshold(), true);\r
- }\r
+ cs.setThreshold(view.getPidThreshold(), true);\r
\r
if(cs!=null)\r
cs.setConsensus(af.viewport.vconsensus);\r
af.changeColour(af.viewport.getGlobalColourScheme());\r
if (view.getConservationSelected())\r
{\r
- ( (ConservationColourScheme) af.viewport.getGlobalColourScheme()).inc = view.getConsThreshold();\r
+ af.viewport.getGlobalColourScheme().setConservationInc(view.getConsThreshold());\r
}\r
\r
af.viewport.setColourAppliesToAllGroups(true);\r
noColourmenuItem.setSelected(true);\r
}\r
\r
- if (sg.cs instanceof ConservationColourScheme)\r
+ if (sg.cs!=null && sg.cs.conservationApplied())\r
{\r
conservationMenuItem.setSelected(true);\r
}\r
int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs,\r
getGroup().getName());\r
\r
- if (sg.cs instanceof ResidueColourScheme)\r
- {\r
- ((ResidueColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
- }\r
- else if (sg.cs instanceof ScoreColourScheme)\r
- {\r
- ((ScoreColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
- }\r
+ sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
\r
SliderPanel.showPIDSlider();\r
}\r
else // remove PIDColouring\r
{\r
- ResidueColourScheme rcs = (ResidueColourScheme) sg.cs;\r
- rcs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
- sg.cs = rcs;\r
+ sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
}\r
\r
refresh();\r
c.calculate();\r
c.verdict(false, ap.av.ConsPercGaps);\r
\r
- ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);\r
-\r
- sg.cs = ccs;\r
+ sg.cs.setConservation(c);\r
\r
- SliderPanel.setConservationSlider(ap, ccs, sg.getName());\r
+ SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());\r
SliderPanel.showConservationSlider();\r
}\r
else // remove ConservationColouring\r
{\r
- ConservationColourScheme ccs = (ConservationColourScheme) sg.cs;\r
- sg.cs = ccs.cs;\r
+ sg.cs.setConservation(null);\r
}\r
\r
refresh();\r
av.getSelectionGroup().recalcConservation();\r
}\r
\r
- if (cs instanceof ConservationColourScheme)\r
+ if (cs.conservationApplied())\r
{\r
- ConservationColourScheme ccs = (ConservationColourScheme) cs;\r
Conservation c = new Conservation("All",\r
ResidueProperties.propHash, 3, av.alignment.getSequences(),\r
0, av.alignment.getWidth() - 1);\r
c.calculate();\r
c.verdict(false, av.ConsPercGaps);\r
\r
- if (ccs.cs instanceof ClustalxColourScheme)\r
+ if (cs instanceof ClustalxColourScheme)\r
{\r
- ClustalxColourScheme cxs = (ClustalxColourScheme) ccs.cs;\r
+ ClustalxColourScheme cxs = (ClustalxColourScheme) cs;\r
cxs.resetClustalX(av.alignment.getSequences(),\r
av.alignment.getWidth());\r
- ccs = new ConservationColourScheme(c, cxs);\r
- av.setGlobalColourScheme(ccs);\r
+ cs.setConservation(c);\r
+ av.setGlobalColourScheme(cs);\r
}\r
else\r
{\r
- ccs = new ConservationColourScheme(c, ccs.cs);\r
- av.setGlobalColourScheme(ccs);\r
+ cs.setConservation(c);\r
+ av.setGlobalColourScheme(cs);\r
}\r
}\r
\r
return;\r
}\r
\r
- if (stretchGroup.cs instanceof ClustalxColourScheme)\r
+ if(stretchGroup.cs!=null)\r
{\r
- ((ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup.sequences,\r
+ if (stretchGroup.cs instanceof ClustalxColourScheme)\r
+ {\r
+ ( (ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup.\r
+ sequences,\r
stretchGroup.getWidth());\r
- }\r
+ }\r
\r
- if (stretchGroup.cs instanceof ConservationColourScheme)\r
- {\r
- ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs;\r
- stretchGroup.cs = ccs;\r
+ if (stretchGroup.cs.conservationApplied())\r
+ {\r
SliderPanel.setConservationSlider(ap, stretchGroup.cs,\r
- stretchGroup.getName());\r
- }\r
- else\r
- {\r
+ stretchGroup.getName());\r
+ }\r
+ else\r
+ {\r
SliderPanel.setPIDSliderSource(ap, stretchGroup.cs,\r
- stretchGroup.getName());\r
+ stretchGroup.getName());\r
+ }\r
}\r
-\r
changeEndRes = false;\r
changeStartRes = false;\r
stretchGroup = null;\r
ColourSchemeI cs, String source)\r
{\r
SliderPanel sp = null;\r
- ConservationColourScheme ccs = (ConservationColourScheme) cs;\r
\r
if (conservationSlider == null)\r
{\r
- sp = new SliderPanel(ap, ccs.inc, true, cs);\r
+ sp = new SliderPanel(ap, cs.getConservationInc(), true, cs);\r
conservationSlider = new JInternalFrame();\r
conservationSlider.setContentPane(sp);\r
conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);\r
{\r
SliderPanel pid = null;\r
\r
- int threshold = 50;\r
-\r
- if (cs instanceof ResidueColourScheme)\r
- {\r
- threshold = (((ResidueColourScheme) cs).getThreshold());\r
- }\r
- else if (cs instanceof ScoreColourScheme)\r
- {\r
- threshold = (((ScoreColourScheme) cs).getThreshold());\r
- }\r
+ int threshold = cs.getThreshold();\r
\r
if (PIDSlider == null)\r
{\r
public void valueChanged(int i)\r
{\r
if (cs == null)\r
- {\r
+ {System.out.println("cs is null");\r
return;\r
}\r
\r
+\r
+\r
ColourSchemeI toChange = null;\r
Vector allGroups = null;\r
int groupIndex = 0;\r
toChange = cs;\r
}\r
\r
+\r
while (groupIndex > -1)\r
{\r
if (allGroups != null)\r
\r
if (forConservation)\r
{\r
- if (toChange instanceof ConservationColourScheme)\r
+ if (toChange.conservationApplied())\r
{\r
- ((ConservationColourScheme) toChange).inc = i;\r
+ toChange.setConservationInc(i);\r
}\r
}\r
else\r
{\r
- ((ResidueColourScheme) toChange).setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
+ toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
}\r
\r
groupIndex--;\r
\r
if (sg.cs != null)\r
{\r
- ((ResidueColourScheme) sg.cs).setThreshold(25, av.getIgnoreGapsConsensus());\r
+ sg.cs.setThreshold(25, av.getIgnoreGapsConsensus());\r
}\r
\r
- if (av.getGlobalColourScheme() instanceof ConservationColourScheme)\r
+ if (av.getGlobalColourScheme().conservationApplied())\r
{\r
- ConservationColourScheme ccs = (ConservationColourScheme) av.getGlobalColourScheme();\r
Conservation c = new Conservation("Group",\r
ResidueProperties.propHash, 3, sg.sequences,\r
sg.getStartRes(), sg.getEndRes());\r
\r
c.calculate();\r
c.verdict(false, av.ConsPercGaps);\r
- ccs = new ConservationColourScheme(c, ccs.cs);\r
-\r
- sg.cs = ccs;\r
+ sg.cs.setConservation(c);\r
}\r
\r
av.alignment.addGroup(sg);\r
char res = s.charAt(0);\r
if ('a' <= res && res <= 'z' )\r
{\r
+ // TO UPPERCASE !!!\r
s = String.valueOf( res -= ('a' - 'A') );\r
}\r
\r
\r
if (max.indexOf(s) > -1)\r
{\r
- return new Color(154, 154, 255);\r
+ currentColour = new Color(154, 154, 255);\r
}\r
else\r
{\r
\r
if (c > 0)\r
{\r
- return new Color(204, 204, 255);\r
+ currentColour = new Color(204, 204, 255);\r
}\r
else\r
{\r
- return Color.white;\r
+ currentColour = Color.white;\r
}\r
}\r
+\r
+ if(conservationColouring)\r
+ applyConservation(j);\r
}\r
else\r
{\r
return Color.white;\r
}\r
+\r
+ return currentColour;\r
}\r
}\r
\r
int i = ( (Integer) ResidueProperties.aaHash.get(s)).intValue();\r
\r
- Color c = Color.white;\r
+ currentColour = Color.white;\r
\r
if (i > 19)\r
{\r
- return c;\r
+ return currentColour;\r
}\r
\r
for (int k = 0; k < ResidueColour[i].conses.length; k++)\r
{\r
if (ResidueColour[i].conses[k].isConserved(cons2, j, size))\r
{\r
- c = ResidueColour[i].c;\r
+ currentColour = ResidueColour[i].c;\r
}\r
}\r
\r
{\r
if (conses[27].isConserved(cons2, j, size))\r
{\r
- c = (Color) colhash.get("PINK");\r
+ currentColour = (Color) colhash.get("PINK");\r
}\r
}\r
\r
- return c;\r
+ if(conservationColouring)\r
+ applyConservation(j);\r
+\r
+ return currentColour;\r
}\r
}\r
\r
*/\r
package jalview.schemes;\r
\r
-import java.util.*;\r
-\r
import java.awt.*;\r
\r
public interface ColourSchemeI\r
\r
public Color findColour(String s, int j);\r
\r
- public void setConsensus(Vector v);\r
+ public void setConsensus(java.util.Vector v);\r
+\r
+ public void setConservation(jalview.analysis.Conservation c);\r
+\r
+ public boolean conservationApplied();\r
+\r
+ public void setConservationInc(int i);\r
+\r
+ public int getConservationInc();\r
+\r
+ public int getThreshold();\r
+\r
+ public void setThreshold(int ct, boolean ignoreGaps);\r
+\r
+\r
}\r
*/\r
public static String getColourName(ColourSchemeI cs)\r
{\r
- if (cs instanceof ConservationColourScheme)\r
- {\r
- cs = ((ConservationColourScheme) cs).cs;\r
- }\r
\r
int index = 12;\r
\r
+++ /dev/null
-/*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
-*/\r
-package jalview.schemes;\r
-\r
-import jalview.analysis.*;\r
-\r
-import java.awt.*;\r
-\r
-import java.util.Vector;\r
-\r
-\r
-/**\r
- * DOCUMENT ME!\r
- *\r
- * @author $author$\r
- * @version $Revision$\r
- */\r
-public class ConservationColourScheme extends ResidueColourScheme\r
-{\r
- /** DOCUMENT ME!! */\r
- public Conservation conserve;\r
-\r
- /** DOCUMENT ME!! */\r
- public ColourSchemeI cs;\r
-\r
- /** DOCUMENT ME!! */\r
- public int inc = 30;\r
-\r
- /**\r
- * Creates a new ConservationColourScheme object.\r
- *\r
- * @param cons DOCUMENT ME!\r
- * @param oldcs DOCUMENT ME!\r
- */\r
- public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs)\r
- {\r
- super();\r
- conserve = cons;\r
- cs = oldcs;\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param consensus DOCUMENT ME!\r
- */\r
- public void setConsensus(Vector consensus)\r
- {\r
- super.setConsensus(consensus);\r
-\r
- if (cs != null)\r
- {\r
- cs.setConsensus(consensus);\r
- }\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param s DOCUMENT ME!\r
- * @param i DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- */\r
- public Color findColour(String s, int i)\r
- {\r
- Color c = Color.white;\r
-\r
- if (cs == null)\r
- {\r
- return c;\r
- }\r
-\r
- char ch = conserve.getConsSequence().getSequence().charAt(i);\r
-\r
- if ((ch == '*') || (ch == '+'))\r
- {\r
- c = cs.findColour(s, i);\r
- }\r
- else\r
- {\r
- int tmp = 10;\r
- int t = 0;\r
-\r
- if (!jalview.util.Comparison.isGap(ch))\r
- {\r
- t = Integer.parseInt(ch + "");\r
- }\r
-\r
- c = cs.findColour(s, i);\r
-\r
- while (tmp >= t)\r
- {\r
- c = lighter(c, inc);\r
- tmp--;\r
- }\r
- }\r
-\r
- return c;\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param c DOCUMENT ME!\r
- * @param inc DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- */\r
- public Color lighter(Color c, int inc)\r
- {\r
- int red = c.getRed();\r
- int blue = c.getBlue();\r
- int green = c.getGreen();\r
-\r
- if (red < (255 - inc))\r
- {\r
- red = red + inc;\r
- }\r
- else\r
- {\r
- red = 255;\r
- }\r
-\r
- if (blue < (255 - inc))\r
- {\r
- blue = blue + inc;\r
- }\r
- else\r
- {\r
- blue = 255;\r
- }\r
-\r
- if (green < (255 - inc))\r
- {\r
- green = green + inc;\r
- }\r
- else\r
- {\r
- green = 255;\r
- }\r
-\r
- return new Color(red, green, blue);\r
- }\r
-}\r
{\r
try\r
{\r
- return colors[((Integer) (ResidueProperties.nucleotideHash.get(n))).intValue()];\r
+ currentColour = colors[((Integer) (ResidueProperties.nucleotideHash.get(n))).intValue()];\r
}\r
catch (Exception ex)\r
{\r
{\r
return Color.white;\r
}\r
+\r
+ if(conservationColouring)\r
+ applyConservation(j);\r
+\r
+ return currentColour;\r
}\r
}\r
return Color.white;\r
}\r
\r
-\r
-\r
- Color c = Color.white;\r
+ currentColour = Color.white;\r
\r
double sc = 0;\r
\r
{\r
if (sc > thresholds[i])\r
{\r
- c = pidColours[i];\r
+ currentColour = pidColours[i];\r
\r
break;\r
}\r
}\r
}\r
\r
- return c;\r
+ if(conservationColouring)\r
+ applyConservation(j);\r
+\r
+ return currentColour;\r
}\r
}\r
*/\r
package jalview.schemes;\r
\r
+import jalview.analysis.*;\r
+\r
import java.awt.*;\r
\r
import java.util.*;\r
*/\r
public class ResidueColourScheme implements ColourSchemeI\r
{\r
+\r
+ boolean conservationColouring = false;\r
+ boolean consensusColouring = false;\r
+\r
Color[] colors;\r
int threshold = 0;\r
\r
/* Set when threshold colouring to either pid_gaps or pid_nogaps*/\r
protected String ignoreGaps = "pid_gaps";\r
\r
- /** DOCUMENT ME!! */\r
- public Hashtable [] consensus;\r
+ /** Consenus as a hashtable array */\r
+ Hashtable [] consensus;\r
+\r
+ /** Conservation string as a char array */\r
+ char [] conservation;\r
+\r
+ /** DOCUMENT ME!! */\r
+ int inc = 30;\r
+\r
+ /**\r
+ * The colour to be calculated, manipulated and returned\r
+ */\r
+ Color currentColour = null;\r
+\r
+\r
\r
/**\r
* Creates a new ResidueColourScheme object.\r
* @param colors DOCUMENT ME!\r
* @param threshold DOCUMENT ME!\r
*/\r
- public ResidueColourScheme(Color[] colors, int threshold)\r
+ public ResidueColourScheme(Color[] colours, int threshold)\r
{\r
- this.colors = colors;\r
+ this.colors = colours;\r
this.threshold = threshold;\r
}\r
\r
}\r
\r
/**\r
- * DOCUMENT ME!\r
- *\r
- * @param consensus DOCUMENT ME!\r
- */\r
- public void setConsensus(Vector vconsensus)\r
- {\r
- int i, iSize=vconsensus.size();\r
- consensus = new Hashtable[iSize];\r
- for(i=0; i<iSize; i++)\r
- consensus[i] = (Hashtable)vconsensus.elementAt(i);\r
- }\r
+ * Find a colour without an index in a sequence\r
+ */\r
+ public Color findColour(String aa)\r
+ {\r
+ return colors[((Integer) (ResidueProperties.aaHash.get(aa))).intValue()];\r
+ }\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param aa DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- */\r
- public Color findColour(String aa)\r
- {\r
- return colors[((Integer) (ResidueProperties.aaHash.get(aa))).intValue()];\r
- }\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param s DOCUMENT ME!\r
- * @param j DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- */\r
- public Color findColour(String s, int j)\r
- {\r
- int index = ((Integer) (ResidueProperties.aaHash.get(s))).intValue();\r
\r
- if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j))\r
- {\r
- return colors[index];\r
- }\r
- else\r
- {\r
- return Color.white;\r
- }\r
- }\r
+ public Color findColour(String s, int j)\r
+ {\r
+\r
+ int index = ((Integer) (ResidueProperties.aaHash.get(s))).intValue();\r
+\r
+ if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j))\r
+ {\r
+ currentColour = colors[index];\r
+ }\r
+ else\r
+ {\r
+ currentColour = Color.white;\r
+ }\r
+\r
+ if(conservationColouring)\r
+ applyConservation(j);\r
+\r
+\r
+ return currentColour;\r
+ }\r
+\r
\r
/**\r
- * DOCUMENT ME!\r
+ * Get the percentage threshold for this colour scheme\r
*\r
- * @return DOCUMENT ME!\r
+ * @return Returns the percentage threshold\r
*/\r
public int getThreshold()\r
{\r
if ((((Integer) consensus[j].get("maxCount")).intValue() != -1) &&\r
consensus[j].contains(s))\r
{\r
- float ratio = ((Float)consensus[j].get(ignoreGaps)).floatValue();\r
-\r
- if (ratio >= threshold)\r
+ if (((Float)consensus[j].get(ignoreGaps)).floatValue() >= threshold)\r
{\r
return true;\r
}\r
\r
return false;\r
}\r
+\r
+\r
+ public boolean conservationApplied()\r
+ {\r
+ return conservationColouring;\r
+ }\r
+\r
+ public void setConservationInc(int i)\r
+ {\r
+ inc = i;\r
+ }\r
+\r
+ public int getConservationInc()\r
+ {\r
+ return inc;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param consensus DOCUMENT ME!\r
+ */\r
+ public void setConsensus(Vector vconsensus)\r
+ {\r
+ int i, iSize=vconsensus.size();\r
+ consensus = new Hashtable[iSize];\r
+ for(i=0; i<iSize; i++)\r
+ consensus[i] = (Hashtable)vconsensus.elementAt(i);\r
+ }\r
+\r
+\r
+ public void setConservation(Conservation cons)\r
+ {\r
+ if(cons==null)\r
+ {\r
+ conservationColouring = false;\r
+ conservation = null;\r
+ }\r
+ else\r
+ {\r
+ conservationColouring = true;\r
+ int i, iSize = cons.getConsSequence().getLength();\r
+ conservation = new char[iSize];\r
+ for (i = 0; i < iSize; i++)\r
+ conservation[i] = cons.getConsSequence().getCharAt(i);\r
+ }\r
+\r
+ }\r
+\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param s DOCUMENT ME!\r
+ * @param i DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ void applyConservation(int i)\r
+ {\r
+ if ((conservation[i] != '*') && (conservation[i] != '+'))\r
+ {\r
+ int tmp = 10;\r
+ int t = 0;\r
+\r
+ if (!jalview.util.Comparison.isGap(conservation[i]))\r
+ {\r
+ t = conservation[i]-'0';\r
+ }\r
+\r
+ while (tmp >= t)\r
+ {\r
+ lighter(inc);\r
+ tmp--;\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param c DOCUMENT ME!\r
+ * @param inc DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ void lighter(int inc)\r
+ {\r
+ int red = currentColour.getRed();\r
+ int blue = currentColour.getBlue();\r
+ int green = currentColour.getGreen();\r
+\r
+ if (red < (255 - inc))\r
+ {\r
+ red = red + inc;\r
+ }\r
+ else\r
+ {\r
+ red = 255;\r
+ }\r
+\r
+ if (blue < (255 - inc))\r
+ {\r
+ blue = blue + inc;\r
+ }\r
+ else\r
+ {\r
+ blue = 255;\r
+ }\r
+\r
+ if (green < (255 - inc))\r
+ {\r
+ green = green + inc;\r
+ }\r
+ else\r
+ {\r
+ green = 255;\r
+ }\r
+\r
+ currentColour = new Color(red, green, blue);\r
+ }\r
+\r
+\r
}\r
this.scores = scores;\r
this.min = min;\r
this.max = max;\r
+\r
+ // Make colours in constructor\r
+ // Why wasn't this done earlier?\r
+ int i, iSize=scores.length;\r
+ colors = new Color[scores.length];\r
+ for (i = 0; i < iSize; i++)\r
+ {\r
+ float red = (float) (scores[i] - (float) min) / (float) (max - min);\r
+\r
+ if (red > 1.0f)\r
+ {\r
+ red = 1.0f;\r
+ }\r
+\r
+ if (red < 0.0f)\r
+ {\r
+ red = 0.0f;\r
+ }\r
+ colors[i] = makeColour(red);\r
+ }\r
}\r
\r
/**\r
}\r
}\r
\r
- float red = (float) (scores[((Integer) ResidueProperties.aaHash.get(s)).intValue()] -\r
- (float) min) / (float) (max - min);\r
-\r
- if (red > 1.0f)\r
- {\r
- red = 1.0f;\r
- }\r
-\r
- if (red < 0.0f)\r
- {\r
- red = 0.0f;\r
- }\r
-\r
char c = s.charAt(0);\r
\r
if (jalview.util.Comparison.isGap((c)))\r
return Color.white;\r
}\r
\r
- // This isn';t great - pool of colours in here?\r
- return makeColour(red);\r
+ currentColour = colors[((Integer) ResidueProperties.aaHash.get(s)).intValue()];\r
+\r
+ if(conservationColouring)\r
+ applyConservation(j);\r
+\r
+ return currentColour;\r
}\r
\r
/**\r