From af4abf989c69bbfaa30a25eff93133867bbce6c8 Mon Sep 17 00:00:00 2001 From: kiramt Date: Mon, 15 Jan 2018 10:11:10 +0000 Subject: [PATCH] JAL-2759 Comments and renaming for has(Many)HiddenColumns after review --- src/jalview/appletgui/ScalePanel.java | 2 +- src/jalview/datamodel/HiddenColumns.java | 7 +++++-- src/jalview/gui/ScalePanel.java | 2 +- test/jalview/datamodel/HiddenColumnsTest.java | 10 +++++----- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index def9451..4e44888 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -174,7 +174,7 @@ public class ScalePanel extends Panel }); pop.add(item); - if (av.getAlignment().getHiddenColumns().hasManyHiddenColumns()) + if (av.getAlignment().getHiddenColumns().hasMultiHiddenColumnRegions()) { item = new MenuItem(MessageManager.getString("action.reveal_all")); item.addActionListener(new ActionListener() diff --git a/src/jalview/datamodel/HiddenColumns.java b/src/jalview/datamodel/HiddenColumns.java index e047ef4..8716a67 100644 --- a/src/jalview/datamodel/HiddenColumns.java +++ b/src/jalview/datamodel/HiddenColumns.java @@ -1219,6 +1219,9 @@ public class HiddenColumns try { LOCK.readLock().lock(); + + // we don't use getSize()>0 here because it has to iterate over + // the full hiddenColumns collection and so will be much slower return hiddenColumns != null && hiddenColumns.size() > 0; } finally { @@ -1228,9 +1231,9 @@ public class HiddenColumns /** * - * @return true if there are more than one set of columns hidden + * @return true if there is more than one hidden column region */ - public boolean hasManyHiddenColumns() + public boolean hasMultiHiddenColumnRegions() { try { diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 2310866..799eac2 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -175,7 +175,7 @@ public class ScalePanel extends JPanel }); pop.add(item); - if (av.getAlignment().getHiddenColumns().hasManyHiddenColumns()) + if (av.getAlignment().getHiddenColumns().hasMultiHiddenColumnRegions()) { item = new JMenuItem(MessageManager.getString("action.reveal_all")); item.addActionListener(new ActionListener() diff --git a/test/jalview/datamodel/HiddenColumnsTest.java b/test/jalview/datamodel/HiddenColumnsTest.java index 54a244b..edd68b2 100644 --- a/test/jalview/datamodel/HiddenColumnsTest.java +++ b/test/jalview/datamodel/HiddenColumnsTest.java @@ -988,20 +988,20 @@ public class HiddenColumnsTest { HiddenColumns h = new HiddenColumns(); - // new HiddenColumns2 has no hidden cols - assertFalse(h.hasManyHiddenColumns()); + // h has no hidden cols + assertFalse(h.hasMultiHiddenColumnRegions()); // one set of columns hidden, returns false h.hideColumns(5, 10); - assertFalse(h.hasManyHiddenColumns()); + assertFalse(h.hasMultiHiddenColumnRegions()); // two sets hidden, returns true h.hideColumns(15, 17); - assertTrue(h.hasManyHiddenColumns()); + assertTrue(h.hasMultiHiddenColumnRegions()); // back to one block, asserts false h.hideColumns(11, 14); - assertFalse(h.hasManyHiddenColumns()); + assertFalse(h.hasMultiHiddenColumnRegions()); } @Test(groups = "Functional") -- 1.7.10.2