import jalview.api.AlignmentViewPanel;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
-import jalview.schemes.ColourSchemeI;
+import jalview.gui.AlignmentPanel;
import jalview.structures.models.AAStructureBindingModel;
public interface JalviewStructureDisplayI
void closeViewer(boolean closeExternalViewer);
/**
- * apply a colourscheme to the structures in the viewer
- *
- * @param colourScheme
- */
- void setJalviewColourScheme(ColourSchemeI colourScheme);
-
- /**
*
* @return true if all background sequence/structure binding threads have
* completed for this viewer instance
*/
void raiseViewer();
+ /**
+ * Answers true if the argument is a view used as the basis for structure
+ * colouring
+ *
+ * @param o
+ * @return
+ */
+ boolean isUsedForColourBy(Object o);
+
}
import jalview.io.FileParse;
import jalview.io.StructureFile;
import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.ColourSchemeI;
import jalview.schemes.HelixColourScheme;
import jalview.schemes.HydrophobicColourScheme;
import jalview.schemes.PurinePyrimidineColourScheme;
import jalview.schemes.UserColourScheme;
import jalview.schemes.ZappoColourScheme;
import jalview.structure.StructureSelectionManager;
+import jalview.structures.models.AAStructureBindingModel.ColourBy;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
jmb = new AppletJmolBinding(this, ap.getStructureSelectionManager(),
new PDBEntry[]
{ pdbentry }, new SequenceI[][] { seq }, protocol);
- jmb.setColourBySequence(true);
+ jmb.setColourBy(ColourBy.Sequence);
if (pdbentry.getId() == null || pdbentry.getId().length() < 1)
{
if (protocol == DataSourceType.PASTE)
else if (evt.getSource() == zappo)
{
setEnabled(zappo);
- jmb.setJalviewColourScheme(new ZappoColourScheme());
+ setColourScheme(new ZappoColourScheme());
}
else if (evt.getSource() == taylor)
{
setEnabled(taylor);
- jmb.setJalviewColourScheme(new TaylorColourScheme());
+ setColourScheme(new TaylorColourScheme());
}
else if (evt.getSource() == hydro)
{
setEnabled(hydro);
- jmb.setJalviewColourScheme(new HydrophobicColourScheme());
+ setColourScheme(new HydrophobicColourScheme());
}
else if (evt.getSource() == helix)
{
setEnabled(helix);
- jmb.setJalviewColourScheme(new HelixColourScheme());
+ setColourScheme(new HelixColourScheme());
}
else if (evt.getSource() == strand)
{
setEnabled(strand);
- jmb.setJalviewColourScheme(new StrandColourScheme());
+ setColourScheme(new StrandColourScheme());
}
else if (evt.getSource() == turn)
{
setEnabled(turn);
- jmb.setJalviewColourScheme(new TurnColourScheme());
+ setColourScheme(new TurnColourScheme());
}
else if (evt.getSource() == buried)
{
setEnabled(buried);
- jmb.setJalviewColourScheme(new BuriedColourScheme());
+ setColourScheme(new BuriedColourScheme());
}
else if (evt.getSource() == purinepyrimidine)
{
- jmb.setJalviewColourScheme(new PurinePyrimidineColourScheme());
+ setColourScheme(new PurinePyrimidineColourScheme());
}
else if (evt.getSource() == user)
{
}
}
- /**
+ private void setColourScheme(ColourSchemeI cs)
+ {
+ jmb.setJalviewColourScheme(cs, ap);
+ }
+
+/**
* tick or untick the seqColour menu entry or jmoColour entry depending upon
* if it was selected or not.
*
{
jmolColour.setState(itm == jmolColour);
seqColour.setState(itm == seqColour);
- jmb.setColourBySequence(itm == seqColour);
+ jmb.setColourBy(itm == seqColour ? ColourBy.Sequence : ColourBy.Viewer);
}
@Override
if (evt.getSource() == jmolColour)
{
setEnabled(jmolColour);
- jmb.setColourBySequence(false);
+ jmb.setColourBy(ColourBy.Viewer);
}
else if (evt.getSource() == seqColour)
{
*/
public void setJalviewColourScheme(UserColourScheme ucs)
{
- jmb.setJalviewColourScheme(ucs);
+ setColourScheme(ucs);
}
public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
}
@Override
- public jalview.api.SequenceRenderer getSequenceRenderer(
- AlignmentViewPanel alignment)
- {
- return new SequenceRenderer(((AlignmentPanel) alignment).av);
- }
-
- @Override
public void sendConsoleEcho(String strEcho)
{
if (appletJmolBinding.scriptWindow == null)
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureRenderer;
-import jalview.api.SequenceRenderer;
+import jalview.api.SequenceRendererI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
@Override
public void colourByChain()
{
- colourBySequence = false;
+ super.colourByChain();
// TODO: colour by chain should colour each chain distinctly across all
// visible models
// TODO: http://issues.jalview.org/browse/JAL-628
@Override
public void colourByCharge()
{
- colourBySequence = false;
+ super.colourByCharge();
evalStateCommand("select *;color white;select ASP,GLU;color red;"
+ "select LYS,ARG;color blue;select CYS;color yellow");
}
*/
@Override
protected StructureMappingcommandSet[] getColourBySequenceCommands(
- String[] files, SequenceRenderer sr, AlignmentViewPanel viewPanel)
+ String[] files, SequenceRendererI sr, AlignmentViewPanel viewPanel)
{
return JmolCommands.getColourBySequenceCommand(getSsm(), files,
getSequence(), sr, viewPanel);
}
@Override
- public void setJalviewColourScheme(ColourSchemeI cs)
+ public void setSimpleColourScheme(ColourSchemeI cs)
{
- colourBySequence = false;
-
- if (cs == null)
- {
- return;
- }
-
jmolHistory(false);
StringBuilder command = new StringBuilder(128);
command.append("select *;color white;");
- List<String> residueSet = ResidueProperties.getResidues(isNucleotide(),
- false);
- for (String resName : residueSet)
- {
- char res = resName.length() == 3
- ? ResidueProperties.getSingleCharacterCode(resName)
- : resName.charAt(0);
- Color col = cs.findColour(res, 0, null, null, 0f);
- command.append("select " + resName + ";color[" + col.getRed() + ","
- + col.getGreen() + "," + col.getBlue() + "];");
- }
+ if (cs != null)
+ {
+ List<String> residueSet = ResidueProperties.getResidues(isNucleotide(), false);
+ for (String resName : residueSet)
+ {
+ char res = resName.length() == 3 ? ResidueProperties.getSingleCharacterCode(resName)
+ : resName.charAt(0);
+ Color col = cs.findColour(res);
+ command.append("select " + resName + ";color[" + col.getRed() + "," + col.getGreen() + ","
+ + col.getBlue() + "];");
+ }
+ }
evalStateCommand(command.toString());
jmolHistory(true);
package jalview.ext.rbvi.chimera;
import jalview.api.AlignmentViewPanel;
-import jalview.api.SequenceRenderer;
+import jalview.api.SequenceRendererI;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
@Override
public void colourByChain()
{
- colourBySequence = false;
+ super.colourByChain();
sendAsynchronousCommand("rainbow chain", COLOURING_CHIMERA);
}
@Override
public void colourByCharge()
{
- colourBySequence = false;
+ super.colourByCharge();
String command = "color white;color red ::ASP;color red ::GLU;color blue ::LYS;color blue ::ARG;color yellow ::CYS";
sendAsynchronousCommand(command, COLOURING_CHIMERA);
}
*/
@Override
protected StructureMappingcommandSet[] getColourBySequenceCommands(
- String[] files, SequenceRenderer sr, AlignmentViewPanel viewPanel)
+ String[] files, SequenceRendererI sr, AlignmentViewPanel viewPanel)
{
return ChimeraCommands.getColourBySequenceCommand(getSsm(), files,
getSequence(), sr, viewPanel);
}
@Override
- public void setJalviewColourScheme(ColourSchemeI cs)
+ public void setSimpleColourScheme(ColourSchemeI cs)
{
- colourBySequence = false;
-
- if (cs == null)
- {
- return;
- }
-
// Chimera expects RBG values in the range 0-1
final double normalise = 255D;
viewerCommandHistory(false);
char res = resName.length() == 3
? ResidueProperties.getSingleCharacterCode(resName)
: resName.charAt(0);
- Color col = cs.findColour(res, 0, null, null, 0f);
+ Color col = cs == null ? Color.WHITE : cs.findColour(res);
command.append("color " + col.getRed() / normalise + ","
+ col.getGreen() / normalise + "," + col.getBlue() / normalise
+ " ::" + resName + ";");
import jalview.datamodel.SequenceI;
import jalview.gui.StructureViewer.ViewerType;
import jalview.structures.models.AAStructureBindingModel;
+import jalview.structures.models.AAStructureBindingModel.ColourBy;
import jalview.util.BrowserLauncher;
import jalview.util.MessageManager;
import jalview.util.Platform;
initMenus();
if (leaveColouringToJmol || !usetoColour)
{
- jmb.setColourBySequence(false);
+ jmb.setColourBy(ColourBy.Viewer);
seqColour.setSelected(false);
viewerColour.setSelected(true);
}
else if (usetoColour)
{
useAlignmentPanelForColourbyseq(ap);
- jmb.setColourBySequence(true);
+ jmb.setColourBy(ColourBy.Sequence);
seqColour.setSelected(true);
viewerColour.setSelected(false);
}
alignAddedStructures = alignAdded;
useAlignmentPanelForSuperposition(ap);
- jmb.setColourBySequence(true);
+ jmb.setColourBy(ColourBy.Sequence);
setSize(400, 400); // probably should be a configurable/dynamic default here
initMenus();
addingStructures = false;
package jalview.gui;
import jalview.api.AlignmentViewPanel;
+import jalview.api.SequenceRendererI;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.datamodel.PDBEntry;
}
@Override
- public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment)
- {
- return new SequenceRenderer(((AlignmentPanel) alignment).av);
- }
-
- @Override
public void sendConsoleEcho(String strEcho)
{
if (console != null)
}
@Override
- public void updateColours(Object source)
- {
- AlignmentPanel ap = (AlignmentPanel) source;
- // ignore events from panels not used to colour this view
- if (!appJmolWindow.isUsedforcolourby(ap))
- {
- return;
- }
- if (!isLoadingFromArchive())
- {
- colourBySequence(ap);
- }
- }
-
- @Override
public void notifyScriptTermination(String strStatus, int msWalltime)
{
// todo - script termination doesn't happen ?
@Override
public void selectionChanged(BS arg0)
{
- // TODO Auto-generated method stub
-
}
@Override
public void refreshPdbEntries()
{
- // TODO Auto-generated method stub
-
}
@Override
@Override
public Map<String, Object> getJSpecViewProperty(String arg0)
{
- // TODO Auto-generated method stub
return null;
}
import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.structures.models.AAStructureBindingModel;
+import jalview.structures.models.AAStructureBindingModel.ColourBy;
import jalview.util.BrowserLauncher;
import jalview.util.MessageManager;
import jalview.util.Platform;
{
useAlignmentPanelForSuperposition(ap);
}
- jmb.setColourBySequence(true);
+ jmb.setColourBy(ColourBy.Sequence);
setSize(myWidth, myHeight);
initMenus();
openNewChimera(alignPanel, pdbArray, seqsArray);
if (colourByChimera)
{
- jmb.setColourBySequence(false);
+ jmb.setColourBy(ColourBy.Viewer);
seqColour.setSelected(false);
viewerColour.setSelected(true);
}
else if (colourBySequence)
{
- jmb.setColourBySequence(true);
+ jmb.setColourBy(ColourBy.Sequence);
seqColour.setSelected(true);
viewerColour.setSelected(false);
}
state.setHeight(viewFrame.getHeight());
final String viewId = viewFrame.getViewId();
state.setViewId(viewId);
- state.setAlignwithAlignPanel(viewFrame.isUsedforaligment(ap));
- state.setColourwithAlignPanel(viewFrame.isUsedforcolourby(ap));
+ state.setAlignwithAlignPanel(viewFrame.isUsedForAligment(ap));
+ state.setColourwithAlignPanel(viewFrame.isUsedForColourBy(ap));
state.setColourByJmol(viewFrame.isColouredByViewer());
state.setType(viewFrame.getViewerType().toString());
pdb.addStructureState(state);
}
@Override
- public jalview.api.SequenceRenderer getSequenceRenderer(
- AlignmentViewPanel alignment)
- {
- return new SequenceRenderer(((AlignmentPanel) alignment).av);
- }
-
- @Override
public void refreshGUI()
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
}
@Override
- public void updateColours(Object source)
- {
- AlignmentPanel ap = (AlignmentPanel) source;
- // ignore events from panels not used to colour this view
- if (!cvf.isUsedforcolourby(ap))
- {
- return;
- }
- if (!isLoadingFromArchive())
- {
- colourBySequence(ap);
- }
- }
-
- @Override
public void releaseReferences(Object svl)
{
}
@Override
- protected void releaseUIResources()
- {
- }
-
- @Override
public void refreshPdbEntries()
{
}
private BufferedImage lastMiniMe = null;
- // Can set different properties in this seqCanvas than
- // main visible SeqCanvas
- private SequenceRenderer sr;
-
private jalview.renderer.seqfeatures.FeatureRenderer fr;
private OverviewDimensions od;
av = alignvp;
progressPanel = pp;
- sr = new SequenceRenderer(av);
- sr.renderGaps = false;
fr = new jalview.renderer.seqfeatures.FeatureRenderer(av);
boolean useLegacy = Cache.getDefault(Preferences.USE_LEGACY_GAP, false);
int charWidth = av.getCharWidth();
g.setFont(av.getFont());
- seqRdr.prepare(g, av.isRenderGaps());
+ seqRdr.setGraphics(g);
SequenceI nextSeq;
// / First draw the sequences
// ///////////////////////////
+ boolean drawGaps = av.isRenderGaps();
for (int i = startSeq; i <= endSeq; i++)
{
nextSeq = av.getAlignment().getSequenceAt(i);
// empty
continue;
}
- seqRdr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq),
- startRes, endRes, offset + ((i - startSeq) * charHeight));
+ seqRdr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq),
+ startRes, endRes, offset + ((i - startSeq) * charHeight), drawGaps);
if (av.isShowSequenceFeatures())
{
import jalview.datamodel.SequenceI;
import jalview.renderer.ResidueColourFinder;
import jalview.renderer.seqfeatures.FeatureColourFinder;
+import jalview.schemes.ColourSchemeI;
+import jalview.util.Comparison;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
-public class SequenceRenderer implements jalview.api.SequenceRenderer
+public class SequenceRenderer implements jalview.api.SequenceRendererI
{
final static int CHAR_TO_UPPER = 'A' - 'a';
- AlignViewportI av;
+ private AlignViewportI av;
- FontMetrics fm;
+ private FontMetrics fm;
- boolean renderGaps = true;
+ private SequenceGroup[] allGroups = null;
- SequenceGroup[] allGroups = null;
+ private Graphics graphics;
- // Color resBoxColour;
+ private boolean monospacedFont;
- Graphics graphics;
-
- boolean monospacedFont;
-
- ResidueColourFinder resColourFinder;
+ private ResidueColourFinder resColourFinder;
/**
* Creates a new SequenceRenderer object
}
/**
- * DOCUMENT ME!
+ * Constructor given a choice of colour scheme. May be used to find colours
+ * for a structure that has a viewport colour scheme other than 'by sequence'
*
- * @param b
- * DOCUMENT ME!
+ * @param cs
+ */
+ public SequenceRenderer(AlignViewportI viewport, ColourSchemeI cs)
+ {
+ this.av = viewport;
+ resColourFinder = new ResidueColourFinder(viewport, cs);
+ }
+
+/**
+ * Sets the Graphics context to draw on, and also guesses whether we are using a monospaced font
+ *
+ * @param g
*/
- public void prepare(Graphics g, boolean renderGaps)
+ public void setGraphics(Graphics g)
{
graphics = g;
fm = g.getFontMetrics();
monospacedFont = (dwidth == fm.getStringBounds("|", g).getWidth()
&& av.getCharWidth() == dwidth);
-
- this.renderGaps = renderGaps;
}
/**
}
/**
- * DOCUMENT ME!
+ * Draws the sequence (box colour and residues) over the given range, at the
+ * specified y-offset on the Graphics context
*
- * @param g
- * DOCUMENT ME!
* @param seq
- * DOCUMENT ME!
- * @param sg
- * DOCUMENT ME!
+ * @param sg groups (if any) that the sequence is a member of (may have
+ * distinct group colouring)
* @param start
- * DOCUMENT ME!
* @param end
- * DOCUMENT ME!
- * @param x1
- * DOCUMENT ME!
* @param y1
- * DOCUMENT ME!
- * @param width
- * DOCUMENT ME!
- * @param height
- * DOCUMENT ME!
+ * @param drawGaps
*/
public void drawSequence(SequenceI seq, SequenceGroup[] sg, int start,
- int end, int y1)
+ int end, int y1, boolean drawGaps)
{
allGroups = sg;
if (av.isValidCharWidth())
{
- drawText(seq, start, end, y1);
+ drawText(seq, start, end, y1, drawGaps);
}
}
/**
- * DOCUMENT ME!
+ * Draws box colours on the given sequence residue range, at the specified
+ * y-offset on the Graphics context
*
* @param seq
- * DOCUMENT ME!
* @param start
- * DOCUMENT ME!
* @param end
- * DOCUMENT ME!
- * @param x1
- * DOCUMENT ME!
* @param y1
- * DOCUMENT ME!
- * @param width
- * DOCUMENT ME!
- * @param height
- * DOCUMENT ME!
*/
public synchronized void drawBoxes(SequenceI seq, int start, int end,
int y1)
}
/**
- * DOCUMENT ME!
+ * Draws residue letters on the given sequence residue range, at the specified
+ * y-offset on the Graphics context
*
* @param seq
- * DOCUMENT ME!
* @param start
- * DOCUMENT ME!
* @param end
- * DOCUMENT ME!
- * @param x1
- * DOCUMENT ME!
* @param y1
- * DOCUMENT ME!
- * @param width
- * DOCUMENT ME!
- * @param height
- * DOCUMENT ME!
+ * @param drawGaps
*/
- public void drawText(SequenceI seq, int start, int end, int y1)
+ public void drawText(SequenceI seq, int start, int end, int y1, boolean drawGaps)
{
y1 += av.getCharHeight() - av.getCharHeight() / 5; // height/5 replaces pady
int charOffset = 0;
getboxColour = false;
s = seq.getCharAt(i);
- if (!renderGaps && jalview.util.Comparison.isGap(s))
+ if (!drawGaps && Comparison.isGap(s))
{
continue;
}
{
// todo - use sequence group consensus
s = getDisplayChar(srep, i, s, '.', currentSequenceGroup);
-
}
-
}
else
{
if (!isarep && av.getShowUnconserved())
{
s = getDisplayChar(srep, i, s, '.', null);
-
}
-
}
charOffset = (av.getCharWidth() - fm.charWidth(s)) / 2;
graphics.drawString(String.valueOf(s),
charOffset + av.getCharWidth() * (i - start), y1);
-
}
}
}
import jalview.schemes.ColourSchemes;
import jalview.structure.StructureMapping;
import jalview.structures.models.AAStructureBindingModel;
+import jalview.structures.models.AAStructureBindingModel.ColourBy;
import jalview.util.MessageManager;
import java.awt.Color;
return _aps.contains(ap2.av.getSequenceSetId());
}
- public boolean isUsedforaligment(AlignmentPanel ap2)
+ public boolean isUsedForAligment(AlignmentPanel ap2)
{
return (_alignwith != null) && _alignwith.contains(ap2);
}
- public boolean isUsedforcolourby(AlignmentPanel ap2)
+ public boolean isUsedForColourBy(Object o)
{
- return (_colourwith != null) && _colourwith.contains(ap2);
+ return (_colourwith != null) && _colourwith.contains(o);
}
/**
boolean enableColourBySeq)
{
useAlignmentPanelForColourbyseq(nap);
- getBinding().setColourBySequence(enableColourBySeq);
seqColour.setSelected(enableColourBySeq);
viewerColour.setSelected(!enableColourBySeq);
+
+ getBinding().setColourBy(enableColourBySeq ? ColourBy.Sequence : ColourBy.Viewer);
}
public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)
AlignmentI al = getAlignmentPanel().av.getAlignment();
ColourSchemeI cs = ColourSchemes.getInstance()
.getColourScheme(colourSchemeName, al, null);
- getBinding().setJalviewColourScheme(cs);
+ getBinding().setJalviewColourScheme(cs, getAlignmentPanel());
}
/**
colourMenu.removeAll();
AlignmentI al = getAlignmentPanel().av.getAlignment();
+ colourMenu.addSeparator();
+
/*
* add colour by sequence, by chain, by charge and cysteine
*/
colourMenu.add(chargeColour);
chargeColour.setEnabled(!al.isNucleotide());
- /*
- * add all 'simple' (per-residue) colour schemes registered to Jalview
- */
+ /*
+ * add all colour schemes registered to Jalview
+ */
ButtonGroup itemGroup = ColourMenuHelper.addMenuItems(colourMenu, this,
- al, true);
+ al);
/*
* add 'colour by viewer' (menu item text is set in subclasses)
buildColourMenu();
}
- @Override
- public void setJalviewColourScheme(ColourSchemeI cs)
- {
- getBinding().setJalviewColourScheme(cs);
- }
-
/**
* Sends commands to the structure viewer to superimpose structures based on
* currently associated alignments. May optionally return an error message for
if (viewerColour.isSelected())
{
// disable automatic sequence colouring.
- getBinding().setColourBySequence(false);
+ getBinding().setColourBy(ColourBy.Viewer);
}
}
public void seqColour_actionPerformed(ActionEvent actionEvent)
{
AAStructureBindingModel binding = getBinding();
- binding.setColourBySequence(seqColour.isSelected());
+ boolean colourBySequence = seqColour.isSelected();
if (_colourwith == null)
{
_colourwith = new Vector<>();
}
- if (binding.isColourBySequence())
+ if (colourBySequence)
{
if (!binding.isLoadingFromArchive())
{
*/
package jalview.renderer;
+import jalview.api.AlignViewportI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.renderer.seqfeatures.FeatureColourFinder;
+import jalview.schemes.ColourSchemeI;
import java.awt.Color;
public class ResidueColourFinder
{
+ private ResidueShaderI shader;
+
public ResidueColourFinder()
{
}
- /**
+ public ResidueColourFinder(AlignViewportI viewport, ColourSchemeI cs)
+ {
+ shader = new ResidueShader(cs);
+ // TODO what if consensus is still calculating - or changes?
+ shader.setConsensus(viewport.getSequenceConsensusHash());
+ }
+
+/**
* Get the colour of a residue in a sequence
*
* @param showBoxes
* FeatureColourFinder for the viewport
* @return colour of the residue
*/
- public Color getResidueColour(boolean showBoxes, ResidueShaderI shader,
+ public Color getResidueColour(boolean showBoxes, ResidueShaderI colourScheme,
SequenceGroup[] allGroups,
final SequenceI seq, int position, FeatureColourFinder finder)
{
- Color col = getResidueBoxColour(showBoxes, shader, allGroups, seq,
+ /*
+ * override alignment colour scheme if one set on construction of this
+ */
+ if (shader != null)
+ {
+ colourScheme = shader;
+ }
+ Color col = getResidueBoxColour(showBoxes, colourScheme, allGroups, seq,
position);
// if there's a FeatureColourFinder we might override the residue colour
*/
public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
{
- Color resBoxColour = Color.white;
- if (shader.getColourScheme() != null)
- {
- resBoxColour = shader.findColour(seq.getCharAt(i), i, seq);
- }
- return resBoxColour;
+ return shader.findColour(seq.getCharAt(i), i, seq);
}
}
package jalview.structures.models;
import jalview.api.AlignmentViewPanel;
-import jalview.api.SequenceRenderer;
+import jalview.api.SequenceRendererI;
import jalview.api.StructureSelectionManagerProvider;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.SequenceRenderer;
import jalview.io.DataSourceType;
import jalview.schemes.ColourSchemeI;
import jalview.structure.AtomSpec;
extends SequenceStructureBindingModel
implements StructureListener, StructureSelectionManagerProvider
{
+ public enum ColourBy
+ {
+ Sequence, Chain, ChargeAndCysteine, Jalview, Viewer
+ }
+
+ /*
+ * selected colour menu option
+ */
+ private ColourBy colourBy = ColourBy.Sequence;
+ /*
+ * selected colour scheme, if a Jalview colour scheme is selected
+ */
+ private ColourSchemeI colourScheme;
+
private StructureSelectionManager ssm;
/*
* datasource protocol for access to PDBEntrylatest
*/
DataSourceType protocol = null;
-
- protected boolean colourBySequence = true;
-
+
private boolean nucleotide;
private boolean finishedInit = false;
}
+ public void setColourBy(ColourBy option)
+ {
+ colourBy = option;
+ }
+
public boolean isColourBySequence()
{
- return colourBySequence;
+ return colourBy == ColourBy.Sequence;
}
-
- public void setColourBySequence(boolean colourBySequence)
+
+ protected boolean isJalviewColourScheme()
{
- this.colourBySequence = colourBySequence;
+ return colourBy == ColourBy.Jalview;
}
protected void addSequenceAndChain(int pe, SequenceI[] seq,
return null;
}
- public abstract void setJalviewColourScheme(ColourSchemeI cs);
+ /**
+ * Sets the selected colour scheme, possibly with reference to the given
+ * alignment view
+ *
+ * @param cs
+ * @param ap
+ */
+ public void setJalviewColourScheme(ColourSchemeI cs, AlignmentViewPanel ap)
+ {
+ colourBy = ColourBy.Jalview;
+ colourScheme = cs;
+
+ if (cs == null || cs.isSimple())
+ {
+ setSimpleColourScheme(cs);
+ }
+ else
+ {
+ colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport(), cs));
+ }
+ }
/**
+ * Sets a colour scheme which is determined solely by the residue at each
+ * position
+ *
+ * @param cs
+ */
+ protected abstract void setSimpleColourScheme(ColourSchemeI cs);
+
+ /**
* Constructs and sends a command to align structures against a reference
* structure, based on one or more sequence alignments. May optionally return
* an error or warning message for the alignment command.
public abstract void setBackgroundColour(Color col);
protected abstract StructureMappingcommandSet[] getColourBySequenceCommands(
- String[] files, SequenceRenderer sr, AlignmentViewPanel avp);
-
- /**
- * returns the current sequenceRenderer that should be used to colour the
- * structures
- *
- * @param alignment
- *
- * @return
- */
- public abstract SequenceRenderer getSequenceRenderer(
- AlignmentViewPanel alignment);
+ String[] files, SequenceRendererI sr, AlignmentViewPanel avp);
protected abstract void colourBySequence(
StructureMappingcommandSet[] colourBySequenceCommands);
- public abstract void colourByChain();
+ public void colourByChain()
+ {
+ colourBy = ColourBy.Chain;
+ }
+
+ public void colourByCharge()
+ {
+ colourBy = ColourBy.ChargeAndCysteine;
+ }
- public abstract void colourByCharge();
+ public void colourBySequence(AlignmentViewPanel alignmentv)
+ {
+ colourBySequence(alignmentv, alignmentv.getSequenceRenderer());
+ }
/**
- * colour any structures associated with sequences in the given alignment
- * using the getFeatureRenderer() and getSequenceRenderer() renderers but only
- * if colourBySequence is enabled.
+ * Colours any structures associated with sequences in the given alignment view
+ * using the getFeatureRenderer() and getSequenceRenderer() renderers
*/
- public void colourBySequence(AlignmentViewPanel alignmentv)
+ public void colourBySequence(AlignmentViewPanel alignmentv, SequenceRendererI sr)
{
- if (!colourBySequence || !isLoadingFinished())
+ if (!isLoadingFinished())
{
return;
}
}
String[] files = getStructureFiles();
- SequenceRenderer sr = getSequenceRenderer(alignmentv);
-
StructureMappingcommandSet[] colourBySequenceCommands = getColourBySequenceCommands(
files, sr, alignmentv);
colourBySequence(colourBySequenceCommands);
public abstract jalview.api.FeatureRenderer getFeatureRenderer(
AlignmentViewPanel alignment);
+
+@Override
+public void updateColours(Object source) {
+ AlignmentPanel ap = (AlignmentPanel) source;
+
+ /*
+ * ignore events from panels not used to colour this view
+ */
+ if (!getViewer().isUsedForColourBy(ap))
+ {
+ return;
+ }
+
+ /*
+ * no need to update colours if structure colouring is not
+ * viewport dependent
+ */
+ if (!isColourBySequence() && !isJalviewColourScheme())
+ {
+ return;
+ }
+ if (colourScheme == null || colourScheme.isSimple())
+ {
+ return;
+ }
+
+ if (!isLoadingFromArchive())
+ {
+ if (isColourBySequence())
+ {
+ colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport()));
+ }
+ else
+ {
+ colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport(), colourScheme));
+ }
+ }
+ }
}
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureRenderer;
-import jalview.api.SequenceRenderer;
+import jalview.api.SequenceRendererI;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenColumns;
@Override
public void updateColours(Object source)
{
- // TODO Auto-generated method stub
-
}
@Override
public void releaseReferences(Object svl)
{
- // TODO Auto-generated method stub
-
}
@Override
public String[] getStructureFiles()
{
- // TODO Auto-generated method stub
return null;
}
public String superposeStructures(AlignmentI[] alignments,
int[] structureIndices, HiddenColumns[] hiddenCols)
{
- // TODO Auto-generated method stub
return null;
}
@Override
- public void setJalviewColourScheme(ColourSchemeI cs)
+ public void setSimpleColourScheme(ColourSchemeI cs)
{
- // TODO Auto-generated method stub
-
}
@Override
public void setBackgroundColour(Color col)
{
- // TODO Auto-generated method stub
}
@Override
public void highlightAtoms(List<AtomSpec> atoms)
{
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment)
- {
- // TODO Auto-generated method stub
- return null;
}
@Override
public FeatureRenderer getFeatureRenderer(AlignmentViewPanel alignment)
{
- // TODO Auto-generated method stub
return null;
}
@Override
protected StructureMappingcommandSet[] getColourBySequenceCommands(
- String[] files, SequenceRenderer sr, AlignmentViewPanel avp)
+ String[] files, SequenceRendererI sr, AlignmentViewPanel avp)
{
- // TODO Auto-generated method stub
return null;
}
@Override
public List<String> getChainNames()
{
- // TODO Auto-generated method stub
return null;
}
protected void colourBySequence(
StructureMappingcommandSet[] colourBySequenceCommands)
{
- // TODO Auto-generated method stub
-
}
@Override
public void colourByCharge()
{
- // TODO Auto-generated method stub
-
}
@Override
public void colourByChain()
{
- // TODO Auto-generated method stub
-
}
};
String[][] chains = binder.getChains();
}
@Override
- public void setJalviewColourScheme(ColourSchemeI cs)
+ public void setSimpleColourScheme(ColourSchemeI cs)
{
}
@Override
protected StructureMappingcommandSet[] getColourBySequenceCommands(
- String[] files, SequenceRenderer sr, AlignmentViewPanel avp)
- {
- return null;
- }
-
- @Override
- public SequenceRenderer getSequenceRenderer(
- AlignmentViewPanel alignment)
+ String[] files, SequenceRendererI sr, AlignmentViewPanel avp)
{
return null;
}