}
return null;
}
+
+ @Override
+ public int[] getVisibleStartAndEndIndex(List<int[]> hiddenCols)
+ {
+ int[] alignmentStartEnd = new int[] { 0, getWidth() - 1 };
+ int startPos = alignmentStartEnd[0];
+ int endPos = alignmentStartEnd[1];
+
+ int[] lowestRange = new int[] { -1, -1 };
+ int[] higestRange = new int[] { -1, -1 };
+
+ for (int[] hiddenCol : hiddenCols)
+ {
+ lowestRange = (hiddenCol[0] <= startPos) ? hiddenCol : lowestRange;
+ higestRange = (hiddenCol[1] >= endPos) ? hiddenCol : higestRange;
+ }
+
+ if (lowestRange[0] == -1 && lowestRange[1] == -1)
+ {
+ startPos = alignmentStartEnd[0];
+ }
+ else
+ {
+ startPos = lowestRange[1] + 1;
+ }
+
+ if (higestRange[0] == -1 && higestRange[1] == -1)
+ {
+ endPos = alignmentStartEnd[1];
+ }
+ else
+ {
+ endPos = higestRange[0] - 1;
+ }
+ return new int[] { startPos, endPos };
+ }
}
* @return
*/
AlignedCodonFrame getMapping(SequenceI mapFrom, SequenceI mapTo);
+
+ /**
+ * Calculate the visible start and end index of an alignment. The result is
+ * returned an int array where: int[0] = startIndex, and int[1] = endIndex.
+ *
+ * @param hiddenCols
+ * @return
+ */
+ public int[] getVisibleStartAndEndIndex(List<int[]> hiddenCols);
}
AlignmentI alignmentToExport = null;
AlignExportSettingI settings = exportSettings;
String[] omitHidden = null;
- int[] alignmentStartEnd = new int[2];
HiddenSequences hiddenSeqs = viewport.getAlignment()
.getHiddenSequences();
alignmentToExport = viewport.getAlignment();
- alignmentStartEnd = new int[] { 0, alignmentToExport.getWidth() - 1 };
boolean hasHiddenSeqs = hiddenSeqs.getSize() > 0;
if (settings == null)
omitHidden = viewport.getViewAsString(false);
}
+ int[] alignmentStartEnd = new int[2];
if (hasHiddenSeqs && settings.isExportHiddenSequences())
{
alignmentToExport = hiddenSeqs.getFullAlignment();
else
{
alignmentToExport = viewport.getAlignment();
- alignmentStartEnd = getStartEnd(alignmentStartEnd, viewport
+ alignmentStartEnd = viewport.getAlignment()
+ .getVisibleStartAndEndIndex(
+ viewport
.getColumnSelection().getHiddenColumns());
}
AlignmentExportData ed = new AlignmentExportData(alignmentToExport,
return ed;
}
- public static int[] getStartEnd(int[] aligmentStartEnd,
- List<int[]> hiddenCols)
- {
- int startPos = aligmentStartEnd[0];
- int endPos = aligmentStartEnd[1];
-
- int[] lowestRange = new int[] { -1, -1 };
- int[] higestRange = new int[] { -1, -1 };
-
- for (int[] hiddenCol : hiddenCols)
- {
- lowestRange = (hiddenCol[0] <= startPos) ? hiddenCol : lowestRange;
- higestRange = (hiddenCol[1] >= endPos) ? hiddenCol : higestRange;
- }
-
- if (lowestRange[0] == -1 && lowestRange[1] == -1)
- {
- startPos = aligmentStartEnd[0];
- }
- else
- {
- startPos = lowestRange[1] + 1;
- }
-
- if (higestRange[0] == -1 && higestRange[1] == -1)
- {
- endPos = aligmentStartEnd[1];
- }
- else
- {
- endPos = higestRange[0] - 1;
- }
-
- // System.out.println("Export range : " + startPos + " - " + endPos);
- return new int[] { startPos, endPos };
- }
-
- public static void main(String[] args)
- {
- ArrayList<int[]> hiddenCols = new ArrayList<int[]>();
- hiddenCols.add(new int[] { 0, 0 });
- hiddenCols.add(new int[] { 6, 9 });
- hiddenCols.add(new int[] { 11, 12 });
- hiddenCols.add(new int[] { 33, 33 });
- hiddenCols.add(new int[] { 50, 50 });
-
- int[] x = getStartEnd(new int[] { 0, 50 }, hiddenCols);
- // System.out.println("Export range : " + x[0] + " - " + x[1]);
- }
/**
* DOCUMENT ME!
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void actionPerformed(ActionEvent evt)
{
AlignmentAnnotation[] aa = ap.av.getAlignment()
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mousePressed(MouseEvent evt)
{
getSelectedRow(evt.getY() - getScrollOffset());
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseReleased(MouseEvent evt)
{
int start = selectedRow;
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseEntered(MouseEvent evt)
{
if (evt.getY() < 10)
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseExited(MouseEvent evt)
{
if (dragEvent == null)
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseDragged(MouseEvent evt)
{
dragEvent = evt;
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseMoved(MouseEvent evt)
{
resizePanel = evt.getY() < 10;
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseClicked(MouseEvent evt)
{
final AlignmentAnnotation[] aa = ap.av.getAlignment()
final AlignmentAnnotation aaa = aa[selectedRow];
cbmi.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
if (aaa.groupRef != null)
aa[selectedRow].groupRef.isShowConsensusHistogram());
chist.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
// TODO: pass on reference
aa[selectedRow].groupRef.isShowSequenceLogo());
cprofl.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
// TODO: pass on reference
aa[selectedRow].groupRef.isNormaliseSequenceLogo());
cproflnorm.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
av.isShowConsensusHistogram());
chist.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
// TODO: pass on reference
av.isShowSequenceLogo());
cprof.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
// TODO: pass on reference
av.isNormaliseSequenceLogo());
cprofnorm.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
// TODO: pass on reference
List<int[]> hiddenCols = av.getColumnSelection().getHiddenColumns();
if (hiddenCols != null)
{
- alignmentStartEnd = AlignFrame.getStartEnd(alignmentStartEnd,
+ alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex(
hiddenCols);
}
String output = new FormatAdapter().formatSequences("Fasta", seqs,
* @param g1
* DOCUMENT ME!
*/
+ @Override
public void paintComponent(Graphics g)
{
import jalview.util.MapList;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
align.addCodonFrame(acf2);
assertTrue(align.getDataset().getCodonFrames().contains(acf));
}
+
+ @Test(groups = "Functional")
+ public void getVisibleStartAndEndIndexTest()
+ {
+ Sequence seq = new Sequence("testSeq", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ AlignmentI align = new Alignment(new SequenceI[] { seq });
+ ArrayList<int[]> hiddenCols = new ArrayList<int[]>();
+
+ int[] startEnd = align.getVisibleStartAndEndIndex(hiddenCols);
+ assertEquals(0, startEnd[0]);
+ assertEquals(25, startEnd[1]);
+
+ hiddenCols.add(new int[] { 0, 0 });
+ startEnd = align.getVisibleStartAndEndIndex(hiddenCols);
+ assertEquals(1, startEnd[0]);
+ assertEquals(25, startEnd[1]);
+
+ hiddenCols.add(new int[] { 6, 9 });
+ hiddenCols.add(new int[] { 11, 12 });
+ startEnd = align.getVisibleStartAndEndIndex(hiddenCols);
+ assertEquals(1, startEnd[0]);
+ assertEquals(25, startEnd[1]);
+
+ hiddenCols.add(new int[] { 24, 25 });
+ startEnd = align.getVisibleStartAndEndIndex(hiddenCols);
+ System.out.println(startEnd[0] + " : " + startEnd[1]);
+ assertEquals(1, startEnd[0]);
+ assertEquals(23, startEnd[1]);
+ }
}