import jalview.datamodel.CigarArray;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenSequences;
+import jalview.datamodel.ProfilesI;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
-import jalview.schemes.Blosum62ColourScheme;
+import jalview.renderer.ResidueShader;
+import jalview.renderer.ResidueShaderI;
import jalview.schemes.ColourSchemeI;
-import jalview.schemes.PIDColourScheme;
import jalview.structure.CommandListener;
import jalview.structure.StructureSelectionManager;
import jalview.structure.VamsasSource;
public abstract class AlignmentViewport implements AlignViewportI,
CommandListener, VamsasSource
{
+ protected ViewportPositionProps posProps;
+
protected ViewStyleI viewStyle = new ViewStyle();
/**
return isDataset;
}
- private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
- protected ColumnSelection colSel = new ColumnSelection();
+
+ // protected ColumnSelection colSel = new ColumnSelection();
public boolean autoCalculateConsensus = true;
protected boolean ignoreGapsInConsensusCalculation = false;
- protected ColourSchemeI globalColourScheme = null;
+ protected ResidueShaderI residueShading;
@Override
public void setGlobalColourScheme(ColourSchemeI cs)
// TODO: logic refactored from AlignFrame changeColour -
// TODO: autorecalc stuff should be changed to rely on the worker system
// check to see if we should implement a changeColour(cs) method rather than
- // put th logic in here
+ // put the logic in here
// - means that caller decides if they want to just modify state and defer
// calculation till later or to do all calculations in thread.
// via changecolour
- globalColourScheme = cs;
- boolean recalc = false;
+
+ /*
+ * only instantiate alignment colouring once, thereafter update it;
+ * this means that any conservation or PID threshold settings
+ * persist when the alignment colour scheme is changed
+ */
+ if (residueShading == null)
+ {
+ residueShading = new ResidueShader(viewStyle);
+ }
+ residueShading.setColourScheme(cs);
+
+ // TODO: do threshold and increment belong in ViewStyle or ResidueShader?
+ // ...problem: groups need these, but do not currently have a ViewStyle
+
if (cs != null)
{
- recalc = getConservationSelected();
- if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
- || cs instanceof Blosum62ColourScheme)
+ if (getConservationSelected())
{
- recalc = true;
- cs.setThreshold(viewStyle.getThreshold(),
- ignoreGapsInConsensusCalculation);
+ residueShading.setConservation(hconservation);
}
- else
- {
- cs.setThreshold(0, ignoreGapsInConsensusCalculation);
- }
- if (recalc)
- {
- cs.setConsensus(hconsensus);
- cs.setConservation(hconservation);
- }
- cs.setConservationApplied(getConservationSelected());
- cs.alignmentChanged(alignment, hiddenRepSequences);
+ residueShading.alignmentChanged(alignment, getHiddenRepSequences());
}
+
+ /*
+ * if 'apply colour to all groups' is selected... do so
+ * (but don't transfer any colour threshold settings to groups)
+ */
if (getColourAppliesToAllGroups())
{
for (SequenceGroup sg : getAlignment().getGroups())
{
- if (cs == null)
+ /*
+ * retain any colour thresholds per group while
+ * changing choice of colour scheme (JAL-2386)
+ */
+ sg.setColourScheme(cs);
+ if (cs != null)
{
- sg.cs = null;
- continue;
- }
- sg.cs = cs.applyTo(sg, getHiddenRepSequences());
- sg.setConsPercGaps(ConsPercGaps);
- if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
- || cs instanceof Blosum62ColourScheme)
- {
- sg.cs.setThreshold(viewStyle.getThreshold(),
- isIgnoreGapsConsensus());
- recalc = true;
- }
- else
- {
- sg.cs.setThreshold(0, isIgnoreGapsConsensus());
- }
-
- if (getConservationSelected())
- {
- sg.cs.setConservationApplied(true);
- recalc = true;
- }
- else
- {
- sg.cs.setConservation(null);
- // sg.cs.setThreshold(0, getIgnoreGapsConsensus());
- }
- if (recalc)
- {
- sg.recalcConservation();
- }
- else
- {
- sg.cs.alignmentChanged(sg, hiddenRepSequences);
+ sg.getGroupColourScheme()
+.alignmentChanged(sg,
+ getHiddenRepSequences());
}
}
}
@Override
public ColourSchemeI getGlobalColourScheme()
{
- return globalColourScheme;
+ return residueShading == null ? null : residueShading
+ .getColourScheme();
+ }
+
+ @Override
+ public ResidueShaderI getResidueShading()
+ {
+ return residueShading;
}
protected AlignmentAnnotation consensus;
/**
* results of alignment consensus analysis for visible portion of view
*/
- protected Hashtable[] hconsensus = null;
+ protected ProfilesI hconsensus = null;
/**
* results of cDNA complement consensus visible portion of view
}
@Override
- public void setSequenceConsensusHash(Hashtable[] hconsensus)
+ public void setSequenceConsensusHash(ProfilesI hconsensus)
{
this.hconsensus = hconsensus;
}
}
@Override
- public Hashtable[] getSequenceConsensusHash()
+ public ProfilesI getSequenceConsensusHash()
{
return hconsensus;
}
groupConservation = null;
hconsensus = null;
hcomplementConsensus = null;
- // TODO removed listeners from changeSupport?
+ // colour scheme may hold reference to consensus
+ residueShading = null;
+ // TODO remove listeners from changeSupport?
changeSupport = null;
setAlignment(null);
}
}
/**
- * Set the selection group for this window.
+ * Set the selection group for this window. Also sets the current alignment as
+ * the context for the group, if it does not already have one.
*
* @param sg
* - group holding references to sequences in this alignment view
public void setSelectionGroup(SequenceGroup sg)
{
selectionGroup = sg;
+ if (sg != null && sg.getContext() == null)
+ {
+ sg.setContext(alignment);
+ }
}
public void setHiddenColumns(ColumnSelection colsel)
{
- this.colSel = colsel;
+ posProps.setHiddenColumns(colsel);
+ // this.colSel = colsel;
}
@Override
public ColumnSelection getColumnSelection()
{
- return colSel;
+ return posProps.getColumnSelection();
+ // return colSel;
}
@Override
public void setColumnSelection(ColumnSelection colSel)
{
- this.colSel = colSel;
+ posProps.setColumnSelection(colSel);
+ /*this.colSel = colSel;
if (colSel != null)
{
updateHiddenColumns();
}
- isColSelChanged(true);
+ isColSelChanged(true);*/
}
/**
@Override
public Map<SequenceI, SequenceCollectionI> getHiddenRepSequences()
{
- return hiddenRepSequences;
+ return posProps.getHiddenRepSequences();
}
@Override
public void setHiddenRepSequences(
Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
{
- this.hiddenRepSequences = hiddenRepSequences;
+ posProps.getHiddenRepSequences();
}
@Override
@Override
public boolean hasHiddenColumns()
{
- return colSel != null && colSel.hasHiddenColumns();
+ return posProps.hasHiddenColumns();
+ // return colSel != null && colSel.hasHiddenColumns();
}
public void updateHiddenColumns()
if (ap != null)
{
updateConsensus(ap);
- if (globalColourScheme != null)
+ if (residueShading != null)
{
- globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
+ residueShading.setThreshold(residueShading.getThreshold(),
ignoreGapsInConsensusCalculation);
}
}
}
- private long sgrouphash = -1, colselhash = -1;
+ private long sgrouphash = -1;
/**
* checks current SelectionGroup against record of last hash value, and
*/
public boolean isColSelChanged(boolean b)
{
- int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel.hashCode();
+ return posProps.isColSelChanged(b);
+ /*int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel.hashCode();
if (hc != -1 && hc != colselhash)
{
if (b)
}
return true;
}
- return false;
+ return false;*/
}
@Override
*/
private boolean followHighlight = true;
- // TODO private with getters and setters?
- public int startRes;
+ /*private int startRes;
- public int endRes;
+ private int endRes;
- public int startSeq;
+ private int startSeq;
- public int endSeq;
+ private int endSeq;*/
/**
* Property change listener for changes in alignment
// common hide/show column stuff
+ public void hideColumns(int start, int end)
+ {
+ posProps.hideColumns(start, end);
+ }
+
+ public void showColumn(int col)
+ {
+ posProps.showColumn(col);
+ }
+
+ public void showAllHiddenColumns()
+ {
+ posProps.showAllHiddenColumns();
+ }
+
public void hideSelectedColumns()
{
if (colSel.isEmpty())
isColSelChanged(true);
}
- public void hideColumns(int start, int end)
- {
- if (start == end)
- {
- colSel.hideColumns(start);
- }
- else
- {
- colSel.hideColumns(start, end);
- }
- isColSelChanged(true);
- }
-
- public void showColumn(int col)
- {
- colSel.revealHiddenColumns(col);
- isColSelChanged(true);
- }
- public void showAllHiddenColumns()
- {
- colSel.revealAllHiddenColumns();
- isColSelChanged(true);
- }
// common hide/show seq stuff
public void showAllHiddenSeqs()
{
- if (alignment.getHiddenSequences().getSize() > 0)
- {
- if (selectionGroup == null)
- {
- selectionGroup = new SequenceGroup();
- selectionGroup.setEndRes(alignment.getWidth() - 1);
- }
- List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
- hiddenRepSequences);
- for (SequenceI seq : tmp)
- {
- selectionGroup.addSequence(seq, false);
- setSequenceAnnotationsVisible(seq, true);
- }
+ selectionGroup = posProps.showAllHiddenSeqs(selectionGroup);
- hiddenRepSequences = null;
+ /* if (alignment.getHiddenSequences().getSize() > 0)
+ {
+ if (selectionGroup == null)
+ {
+ selectionGroup = new SequenceGroup();
+ selectionGroup.setEndRes(alignment.getWidth() - 1);
+ }
+ List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
+ hiddenRepSequences);
+ for (SequenceI seq : tmp)
+ {
+ selectionGroup.addSequence(seq, false);
+ setSequenceAnnotationsVisible(seq, true);
+ }
- firePropertyChange("alignment", null, alignment.getSequences());
- // used to set hasHiddenRows/hiddenRepSequences here, after the property
- // changed event
- sendSelection();
- }
+ hiddenRepSequences = null;
+
+ firePropertyChange("alignment", null, alignment.getSequences());
+ // used to set hasHiddenRows/hiddenRepSequences here, after the property
+ // changed event
+ sendSelection();
+ }*/
}
public void showSequence(int index)
{
- List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
+ posProps.showSequence(index, selectionGroup);
+ /*List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
index, hiddenRepSequences);
if (tmp.size() > 0)
{
}
firePropertyChange("alignment", null, alignment.getSequences());
sendSelection();
- }
+ }*/
}
public void hideAllSelectedSeqs()
{
- if (selectionGroup == null || selectionGroup.getSize() < 1)
+ posProps.hideAllSelectedSeqs(selectionGroup);
+ /*if (selectionGroup == null || selectionGroup.getSize() < 1)
{
return;
}
hideSequence(seqs);
- setSelectionGroup(null);
+ setSelectionGroup(null);*/
}
public void hideSequence(SequenceI[] seq)
{
- if (seq != null)
+ posProps.hideSequence(seq);
+ /*if (seq != null)
{
for (int i = 0; i < seq.length; i++)
{
setSequenceAnnotationsVisible(seq[i], false);
}
firePropertyChange("alignment", null, alignment.getSequences());
- }
+ }*/
}
/**
*/
public void hideSequences(SequenceI sequence, boolean representGroup)
{
- if (selectionGroup == null || selectionGroup.getSize() < 1)
+ posProps.hideSequences(sequence, representGroup, selectionGroup);
+ /*if (selectionGroup == null || selectionGroup.getSize() < 1)
{
hideSequence(new SequenceI[] { sequence });
return;
hideSequence(hseqs);
setSelectionGroup(null);
- sendSelection();
+ sendSelection();*/
}
- /**
- * Set visibility for any annotations for the given sequence.
- *
- * @param sequenceI
- */
- protected void setSequenceAnnotationsVisible(SequenceI sequenceI,
- boolean visible)
- {
- AlignmentAnnotation[] anns = alignment.getAlignmentAnnotation();
- if (anns != null)
- {
- for (AlignmentAnnotation ann : anns)
- {
- if (ann.sequenceRef == sequenceI)
- {
- ann.visible = visible;
- }
- }
- }
- }
public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
{
- int sSize = sg.getSize();
+ posProps.hideRepSequences(repSequence, sg);
+ /*int sSize = sg.getSize();
if (sSize < 2)
{
return;
}
sg.setSeqrep(repSequence); // note: not done in 2.7applet
sg.setHidereps(true); // note: not done in 2.7applet
- hideSequence(seqs);
+ hideSequence(seqs);*/
}
*/
public boolean isHiddenRepSequence(SequenceI seq)
{
- return (hiddenRepSequences != null && hiddenRepSequences
- .containsKey(seq));
+ return posProps.isHiddenRepSequence(seq);
+ // return (hiddenRepSequences != null && hiddenRepSequences
+ // .containsKey(seq));
}
/**
*/
public SequenceGroup getRepresentedSequences(SequenceI seq)
{
- return (SequenceGroup) (hiddenRepSequences == null ? null
- : hiddenRepSequences.get(seq));
+ return posProps.getRepresentedSequences(seq);
+ // return (SequenceGroup) (hiddenRepSequences == null ? null
+ // : hiddenRepSequences.get(seq));
}
@Override
public int adjustForHiddenSeqs(int alignmentIndex)
{
- return alignment.getHiddenSequences().adjustForHiddenSeqs(
- alignmentIndex);
+ return posProps.adjustForHiddenSeqs(alignmentIndex);
+ // return alignment.getHiddenSequences().adjustForHiddenSeqs(
+ // alignmentIndex);
}
@Override
public void invertColumnSelection()
{
- colSel.invertColumnSelection(0, alignment.getWidth());
+ posProps.invertColumnSelection();
+ // colSel.invertColumnSelection(0, alignment.getWidth());
}
@Override
@Override
public CigarArray getViewAsCigars(boolean selectedRegionOnly)
{
- return new CigarArray(alignment, colSel,
+ return new CigarArray(alignment, posProps.getColumnSelection(),
(selectedRegionOnly ? selectionGroup : null));
}
public jalview.datamodel.AlignmentView getAlignmentView(
boolean selectedOnly, boolean markGroups)
{
- return new AlignmentView(alignment, colSel, selectionGroup,
- colSel != null && colSel.hasHiddenColumns(), selectedOnly,
+ return new AlignmentView(alignment, posProps.getColumnSelection(),
+ selectionGroup, posProps.hasHiddenColumns(), selectedOnly,
markGroups);
}
}
selection = new String[iSize];
- if (colSel != null && colSel.hasHiddenColumns())
+ if (posProps.hasHiddenColumns())
{
- selection = colSel.getVisibleSequenceStrings(start, end, seqs);
+ selection = posProps.getVisibleSequenceStrings(start, end, seqs);
}
else
{
@Override
public List<int[]> getVisibleRegionBoundaries(int min, int max)
{
- ArrayList<int[]> regions = new ArrayList<int[]>();
- int start = min;
- int end = max;
+ return posProps.getVisibleRegionBoundaries(min, max);
+ /* ArrayList<int[]> regions = new ArrayList<int[]>();
+ int start = min;
+ int end = max;
- do
- {
- if (colSel != null && colSel.hasHiddenColumns())
- {
- if (start == 0)
+ do
{
- start = colSel.adjustForHiddenColumns(start);
- }
-
- end = colSel.getHiddenBoundaryRight(start);
- if (start == end)
- {
- end = max;
- }
- if (end > max)
- {
- end = max;
- }
- }
+ if (colSel != null && colSel.hasHiddenColumns())
+ {
+ if (start == 0)
+ {
+ start = colSel.adjustForHiddenColumns(start);
+ }
+
+ end = colSel.getHiddenBoundaryRight(start);
+ if (start == end)
+ {
+ end = max;
+ }
+ if (end > max)
+ {
+ end = max;
+ }
+ }
- regions.add(new int[] { start, end });
+ regions.add(new int[] { start, end });
- if (colSel != null && colSel.hasHiddenColumns())
- {
- start = colSel.adjustForHiddenColumns(end);
- start = colSel.getHiddenBoundaryLeft(start) + 1;
- }
- } while (end < max);
+ if (posProps.hasHiddenColumns())
+ {
+ start = colSel.adjustForHiddenColumns(end);
+ start = colSel.getHiddenBoundaryLeft(start) + 1;
+ }
+ } while (end < max);
- int[][] startEnd = new int[regions.size()][2];
+ int[][] startEnd = new int[regions.size()][2];
- return regions;
+ return regions;*/
}
@Override
public List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
boolean selectedOnly)
{
- ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
+ return posProps.getVisibleAlignmentAnnotation(selectedOnly,
+ selectionGroup);
+ /*ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
AlignmentAnnotation[] aa;
if ((aa = alignment.getAlignmentAnnotation()) != null)
{
ala.add(clone);
}
}
- return ala;
+ return ala;*/
}
@Override
selectionGroup.setEndRes(alWidth - 1);
}
- resetAllColourSchemes();
+ updateAllColourSchemes();
calculator.restartWorkers();
// alignment.adjustSequenceAnnotations();
}
/**
* reset scope and do calculations for all applied colourschemes on alignment
*/
- void resetAllColourSchemes()
+ void updateAllColourSchemes()
{
- ColourSchemeI cs = globalColourScheme;
- if (cs != null)
+ ResidueShaderI rs = residueShading;
+ if (rs != null)
{
- cs.alignmentChanged(alignment, hiddenRepSequences);
+ rs.alignmentChanged(alignment, posProps.getHiddenRepSequences());
- cs.setConsensus(hconsensus);
- if (cs.conservationApplied())
+ rs.setConsensus(hconsensus);
+ if (rs.conservationApplied())
{
- cs.setConservation(Conservation.calculateConservation("All", 3,
+ rs.setConservation(Conservation.calculateConservation("All",
alignment.getSequences(), 0, alignment.getWidth(), false,
getConsPercGaps(), false));
}
{
if (sg.cs != null)
{
- sg.cs.alignmentChanged(sg, hiddenRepSequences);
+ sg.cs.alignmentChanged(sg, posProps.getHiddenRepSequences());
}
sg.recalcConservation();
}
public void setViewStyle(ViewStyleI settingsForView)
{
viewStyle = new ViewStyle(settingsForView);
+ if (residueShading != null)
+ {
+ residueShading.setConservationApplied(settingsForView
+ .isConservationColourSelected());
+ }
}
@Override
this.followHighlight = b;
}
+ @Override
+ public ViewportPositionProps getPosProps()
+ {
+ return posProps;
+ }
+
+ @Override
public int getStartRes()
{
- return startRes;
+ return posProps.getStartRes();
}
@Override
public int getEndRes()
{
- return endRes;
+ return posProps.getEndRes();
}
+ @Override
public int getStartSeq()
{
- return startSeq;
+ return posProps.getStartSeq();
}
public void setStartRes(int res)
{
- this.startRes = res;
+ posProps.setStartRes(res);
+ // this.startRes = res;
}
public void setStartSeq(int seq)
{
- this.startSeq = seq;
+ posProps.setStartSeq(seq);
+ // this.startSeq = seq;
}
public void setEndRes(int res)
{
- if (res > alignment.getWidth() - 1)
+ posProps.setEndRes(res);
+ /*if (res > alignment.getWidth() - 1)
{
// log.System.out.println(" Corrected res from " + res + " to maximum " +
// (alignment.getWidth()-1));
{
res = 0;
}
- this.endRes = res;
+ this.endRes = res;*/
}
public void setEndSeq(int seq)
{
- if (seq > alignment.getHeight())
+ posProps.setEndSeq(seq);
+ /*if (seq > alignment.getHeight())
{
seq = alignment.getHeight();
}
{
seq = 0;
}
- this.endSeq = seq;
+ this.endSeq = seq;*/
}
+ @Override
public int getEndSeq()
{
- return endSeq;
+ return posProps.getEndSeq();
+ // return endSeq;
}
/**
*/
public void expandColSelection(SequenceGroup sg, boolean wholewidth)
{
- int sgs, sge;
+ if (!this.hasSelectedColumns())
+ {
+ posProps.expandColSelection(sg, wholewidth);
+ }
+ /*int sgs, sge;
if (sg != null && (sgs = sg.getStartRes()) >= 0
&& sg.getStartRes() <= (sge = sg.getEndRes())
&& !this.hasSelectedColumns())
{
colSel.addElement(cspos);
}
- }
+ }*/
}
/**