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;
{
residueShading.setConservation(hconservation);
}
- residueShading.alignmentChanged(alignment, hiddenRepSequences);
+ residueShading.alignmentChanged(alignment, getHiddenRepSequences());
}
/*
if (cs != null)
{
sg.getGroupColourScheme()
- .alignmentChanged(sg, hiddenRepSequences);
+.alignmentChanged(sg,
+ getHiddenRepSequences());
}
}
}
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()
}
- 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;
- private int startRes;
+ /*private int startRes;
private int endRes;
private int startSeq;
- private 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);
+
+ /* 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);
+ }
- hiddenRepSequences = null;
+ hiddenRepSequences = null;
- firePropertyChange("alignment", null, alignment.getSequences());
- // used to set hasHiddenRows/hiddenRepSequences here, after the property
- // changed event
- sendSelection();
- }
+ 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;
-
- do
- {
- if (colSel != null && colSel.hasHiddenColumns())
- {
- if (start == 0)
- {
- start = colSel.adjustForHiddenColumns(start);
- }
+ return posProps.getVisibleRegionBoundaries(min, max);
+ /* ArrayList<int[]> regions = new ArrayList<int[]>();
+ int start = min;
+ int end = max;
- end = colSel.getHiddenBoundaryRight(start);
- if (start == end)
+ do
{
- 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
ResidueShaderI rs = residueShading;
if (rs != null)
{
- rs.alignmentChanged(alignment, hiddenRepSequences);
+ rs.alignmentChanged(alignment, posProps.getHiddenRepSequences());
rs.setConsensus(hconsensus);
if (rs.conservationApplied())
{
if (sg.cs != null)
{
- sg.cs.alignmentChanged(sg, hiddenRepSequences);
+ sg.cs.alignmentChanged(sg, posProps.getHiddenRepSequences());
}
sg.recalcConservation();
}
}
@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);
}
- }
+ }*/
}
/**