From 32c056ffe34e60a1fde83bf4061af6e82d41f958 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 25 Jul 2006 15:51:25 +0000 Subject: [PATCH] ColumnSelection moved to datamodel --- src/jalview/appletgui/ScalePanel.java | 1 + src/jalview/datamodel/HiddenSequences.java | 13 +++++++++++++ src/jalview/gui/AlignFrame.java | 2 +- src/jalview/gui/AlignViewport.java | 19 ++++++++++++++++--- src/jalview/gui/IdCanvas.java | 2 +- src/jalview/gui/ScalePanel.java | 6 +++--- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index f8706ae..8688486 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -71,6 +71,7 @@ public class ScalePanel int res = x / av.getCharWidth() + av.getStartRes(); SequenceGroup sg = null; + if (av.getColumnSelection().contains(res)) { av.getColumnSelection().removeElement(res); diff --git a/src/jalview/datamodel/HiddenSequences.java b/src/jalview/datamodel/HiddenSequences.java index ca52083..36c6498 100755 --- a/src/jalview/datamodel/HiddenSequences.java +++ b/src/jalview/datamodel/HiddenSequences.java @@ -36,6 +36,19 @@ public class HiddenSequences return hiddenSequences == null ? 0 : hiddenSequences.size(); } + public int getWidth() + { + Enumeration en = hiddenSequences.elements(); + int width = 0; + while(en.hasMoreElements()) + { + SequenceI seq = (SequenceI)en.nextElement(); + if(seq.getLength()>width) + width = seq.getLength(); + } + return width; + } + public void hideSequence(SequenceI sequence) { if(hiddenSequences==null) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index a52481d..f7fc105 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1415,7 +1415,7 @@ public class AlignFrame public void showAllColumns_actionPerformed(ActionEvent e) { - viewport.getColumnSelection().revealAllHiddenColumns(viewport); + viewport.showAllHiddenColumns(); } public void hideSelSequences_actionPerformed(ActionEvent e) diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 3742259..1970181 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -1123,12 +1123,12 @@ public class AlignViewport public void hideSelectedColumns() { - if (colSel.selected.size() < 1) + if (colSel.size() < 1) return; - while (colSel.selected.size() > 0) + while (colSel.size() > 0) { - int column = ( (Integer) colSel.selected.firstElement()).intValue(); + int column = ( (Integer) colSel.getSelected().firstElement()).intValue(); colSel.hideColumns(column); } setSelectionGroup(null); @@ -1168,6 +1168,19 @@ public class AlignViewport hasHiddenRows = false; } + public void showColumn(int col) + { + colSel.revealHiddenColumns(col); + if(colSel.size()<1) + hasHiddenColumns = false; + } + + public void showAllHiddenColumns() + { + colSel.revealAllHiddenColumns(); + hasHiddenColumns = false; + } + public void showAllHiddenSeqs() { if(alignment.getHiddenSequences().getSize()>0) diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index d35a0f4..7734f9a 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -187,9 +187,9 @@ public class IdCanvas extends JPanel { image = new BufferedImage(getWidth(), imgHeight, BufferedImage.TYPE_INT_RGB); - gg = (Graphics2D) image.getGraphics(); } + gg = (Graphics2D) image.getGraphics(); //Fill in the background gg.setColor(Color.white); gg.fillRect(0, 0, getWidth(), imgHeight); diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 29e338c..3a19916 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -81,7 +81,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList { public void actionPerformed(ActionEvent e) { - av.getColumnSelection().revealHiddenColumns(reveal[0], av); + av.showColumn(reveal[0]); reveal = null; ap.repaint(); if(ap.overviewPanel != null) @@ -90,14 +90,14 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList }); pop.add(item); - if(av.getColumnSelection().hiddenColumns.size()>1) + if(av.getColumnSelection().size()>1) { item = new JMenuItem("Reveal All"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - av.getColumnSelection().revealAllHiddenColumns(av); + av.showAllHiddenColumns(); reveal = null; ap.repaint(); if(ap.overviewPanel != null) -- 1.7.10.2