From: Jim Procter Date: Fri, 23 Jan 2015 13:13:03 +0000 (+0000) Subject: JAL-1551 JAL-962 formatting and code change ripples from changing HiddenColumns ... X-Git-Tag: Jalview_2_9~108^2~9 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c1a4229bd662c4299301ee8827b36096d015c075;p=jalview.git JAL-1551 JAL-962 formatting and code change ripples from changing HiddenColumns & accessor from Vector to List --- diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 691aa17..f4cfc3f 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1685,11 +1685,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { copiedHiddenColumns = new Vector(); int hiddenOffset = viewport.getSelectionGroup().getStartRes(); - for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns() - .size(); i++) + for (int[] region : viewport.getColumnSelection().getHiddenColumns()) { - int[] region = (int[]) viewport.getColumnSelection() - .getHiddenColumns().elementAt(i); copiedHiddenColumns.addElement(new int[] { region[0] - hiddenOffset, region[1] - hiddenOffset }); diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index 3e81664..776443f 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -713,11 +713,8 @@ public class AnnotationLabels extends Panel implements ActionListener, if (av.hasHiddenColumns()) { jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector(); - for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) + for (int[] region : av.getColumnSelection().getHiddenColumns()) { - int[] region = (int[]) av.getColumnSelection().getHiddenColumns() - .elementAt(i); - jalview.appletgui.AlignFrame.copiedHiddenColumns .addElement(new int[] { region[0], region[1] }); diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index 60d89aa..f888e3a 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -20,12 +20,23 @@ */ package jalview.appletgui; -import java.awt.*; -import java.awt.event.*; - -import jalview.datamodel.*; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SequenceGroup; import jalview.util.MessageManager; +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.PopupMenu; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; + public class ScalePanel extends Panel implements MouseMotionListener, MouseListener { @@ -97,7 +108,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, }); pop.add(item); - if (av.getColumnSelection().getHiddenColumns().size() > 1) + if (av.getColumnSelection().hasHiddenColumns()) { item = new MenuItem(MessageManager.getString("action.reveal_all")); item.addActionListener(new ActionListener() @@ -323,10 +334,8 @@ public class ScalePanel extends Panel implements MouseMotionListener, res = av.getColumnSelection().adjustForHiddenColumns(res); reveal = null; - for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) + for (int[] region : av.getColumnSelection().getHiddenColumns()) { - int[] region = (int[]) av.getColumnSelection().getHiddenColumns() - .elementAt(i); if (res + 1 == region[0] || res - 1 == region[1]) { reveal = region; @@ -407,18 +416,18 @@ public class ScalePanel extends Panel implements MouseMotionListener, } gg.drawLine( - (int) (((i - startx - 1) * av.charWidth) + (av.charWidth / 2)), + ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), y + 2, - (int) (((i - startx - 1) * av.charWidth) + (av.charWidth / 2)), + ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), y + (fm.getDescent() * 2)); } else { gg.drawLine( - (int) (((i - startx - 1) * av.charWidth) + (av.charWidth / 2)), + ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), y + fm.getDescent(), - (int) (((i - startx - 1) * av.charWidth) + (av.charWidth / 2)), + ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), y + (fm.getDescent() * 2)); } } diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 53cca3c..81e5dae 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -20,9 +20,16 @@ */ package jalview.appletgui; -import java.awt.*; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.SearchResults; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; -import jalview.datamodel.*; +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Panel; public class SeqCanvas extends Panel { @@ -516,7 +523,8 @@ public class SeqCanvas extends Panel } else { - java.util.Vector regions = av.getColumnSelection().getHiddenColumns(); + java.util.List regions = av.getColumnSelection() + .getHiddenColumns(); int screenY = 0; int blockStart = startRes; @@ -524,7 +532,7 @@ public class SeqCanvas extends Panel for (int i = 0; i < regions.size(); i++) { - int[] region = (int[]) regions.elementAt(i); + int[] region = regions.get(i); int hideStart = region[0]; int hideEnd = region[1]; @@ -646,7 +654,7 @@ public class SeqCanvas extends Panel if ((group == null) && (av.getAlignment().getGroups().size() > 0)) { - group = (SequenceGroup) av.getAlignment().getGroups().get(0); + group = av.getAlignment().getGroups().get(0); groupIndex = 0; } @@ -803,7 +811,7 @@ public class SeqCanvas extends Panel break; } - group = (SequenceGroup) av.getAlignment().getGroups() + group = av.getAlignment().getGroups() .get(groupIndex); } while (groupIndex < av.getAlignment().getGroups().size()); diff --git a/src/jalview/datamodel/CigarArray.java b/src/jalview/datamodel/CigarArray.java index 529891f..a55f676 100644 --- a/src/jalview/datamodel/CigarArray.java +++ b/src/jalview/datamodel/CigarArray.java @@ -20,7 +20,7 @@ */ package jalview.datamodel; -import java.util.Vector; +import java.util.List; public class CigarArray extends CigarBase { @@ -148,25 +148,25 @@ public class CigarArray extends CigarBase * internal constructor function - called by CigarArray(AlignmentI, ...); * * @param alignment - * @param columnSelection + * @param list * - vector of visible regions as returned from * columnSelection.getHiddenColumns() * @param selectionGroup */ private void constructFromAlignment(AlignmentI alignment, - Vector columnSelection, SequenceGroup selectionGroup) + List list, SequenceGroup selectionGroup) { int[] _startend = _calcStartEndBounds(alignment, selectionGroup); int start = _startend[1], end = _startend[2]; // now construct the CigarArray operations - if (columnSelection != null) + if (list != null) { int[] region; int hideStart, hideEnd; int last = start; - for (int j = 0; last < end & j < columnSelection.size(); j++) + for (int j = 0; last < end & j < list.size(); j++) { - region = (int[]) columnSelection.elementAt(j); + region = list.get(j); hideStart = region[0]; hideEnd = region[1]; // edit hidden regions to selection range diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index 97b7c67..f1c6cc4 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -35,7 +35,7 @@ public class ColumnSelection Vector selected = new Vector(); // Vector of int [] {startCol, endCol} - Vector hiddenColumns; + Vector hiddenColumns; /** * Add a column to the selection @@ -208,7 +208,7 @@ public class ColumnSelection int hSize = hiddenColumns.size(); for (int i = 0; i < hSize; i++) { - int[] region = (int[]) hiddenColumns.elementAt(i); + int[] region = hiddenColumns.elementAt(i); if (region[0] > start && start + change > region[1]) { deletedHiddenColumns.add(region); @@ -263,7 +263,7 @@ public class ColumnSelection { for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = (int[]) hiddenColumns.elementAt(i); + int[] region = hiddenColumns.elementAt(i); if (region[0] >= start) { region[0] -= change; @@ -484,7 +484,7 @@ public class ColumnSelection * int * @return Vector */ - public Vector getHiddenColumns() + public List getHiddenColumns() { return hiddenColumns; } @@ -503,7 +503,7 @@ public class ColumnSelection { for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = (int[]) hiddenColumns.elementAt(i); + int[] region = hiddenColumns.elementAt(i); if (result >= region[0]) { result += region[1] - region[0] + 1; @@ -531,7 +531,7 @@ public class ColumnSelection int[] region; do { - region = (int[]) hiddenColumns.elementAt(index++); + region = hiddenColumns.elementAt(index++); if (hiddenColumn > region[1]) { result -= region[1] + 1 - region[0]; @@ -557,7 +557,7 @@ public class ColumnSelection int gaps = 0; do { - int[] region = (int[]) hiddenColumns.elementAt(index); + int[] region = hiddenColumns.elementAt(index); if (hiddenRegion == 0) { return region[0]; @@ -588,7 +588,7 @@ public class ColumnSelection int index = 0; do { - int[] region = (int[]) hiddenColumns.elementAt(index); + int[] region = hiddenColumns.elementAt(index); if (alPos < region[0]) { return region[0]; @@ -616,7 +616,7 @@ public class ColumnSelection int index = hiddenColumns.size() - 1; do { - int[] region = (int[]) hiddenColumns.elementAt(index); + int[] region = hiddenColumns.elementAt(index); if (alPos > region[1]) { return region[1]; @@ -652,7 +652,7 @@ public class ColumnSelection for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = (int[]) hiddenColumns.elementAt(i); + int[] region = hiddenColumns.elementAt(i); if (start <= region[1] && end >= region[0]) { hiddenColumns.removeElementAt(i); @@ -719,7 +719,7 @@ public class ColumnSelection { for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = (int[]) hiddenColumns.elementAt(i); + int[] region = hiddenColumns.elementAt(i); for (int j = region[0]; j < region[1] + 1; j++) { addElement(j); @@ -734,7 +734,7 @@ public class ColumnSelection { for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = (int[]) hiddenColumns.elementAt(i); + int[] region = hiddenColumns.elementAt(i); if (res == region[0]) { for (int j = region[0]; j < region[1] + 1; j++) @@ -758,7 +758,7 @@ public class ColumnSelection { for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = (int[]) hiddenColumns.elementAt(i); + int[] region = hiddenColumns.elementAt(i); if (column >= region[0] && column <= region[1]) { return false; @@ -792,7 +792,7 @@ public class ColumnSelection for (int i = 0, j = copy.hiddenColumns.size(); i < j; i++) { int[] rh, cp; - rh = (int[]) copy.hiddenColumns.elementAt(i); + rh = copy.hiddenColumns.elementAt(i); if (rh != null) { cp = new int[rh.length]; @@ -821,7 +821,7 @@ public class ColumnSelection for (i = 0; i < iSize; i++) { StringBuffer visibleSeq = new StringBuffer(); - Vector regions = getHiddenColumns(); + List regions = getHiddenColumns(); int blockStart = start, blockEnd = end; int[] region; @@ -829,7 +829,7 @@ public class ColumnSelection for (int j = 0; j < regions.size(); j++) { - region = (int[]) regions.elementAt(j); + region = regions.get(j); hideStart = region[0]; hideEnd = region[1]; @@ -886,7 +886,7 @@ public class ColumnSelection if (hiddenColumns != null && hiddenColumns.size() > 0) { Vector visiblecontigs = new Vector(); - Vector regions = getHiddenColumns(); + List regions = getHiddenColumns(); int vstart = start; int[] region; @@ -894,7 +894,7 @@ public class ColumnSelection for (int j = 0; vstart < end && j < regions.size(); j++) { - region = (int[]) regions.elementAt(j); + region = regions.get(j); hideStart = region[0]; hideEnd = region[1]; @@ -972,14 +972,14 @@ public class ColumnSelection // then mangle the alignmentAnnotation annotation array Vector annels = new Vector(); Annotation[] els = null; - Vector regions = getHiddenColumns(); + List regions = getHiddenColumns(); int blockStart = start, blockEnd = end; int[] region; int hideStart, hideEnd, w = 0; for (int j = 0; j < regions.size(); j++) { - region = (int[]) regions.elementAt(j); + region = regions.get(j); hideStart = region[0]; hideEnd = region[1]; diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index b19e54f..235deda 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1767,20 +1767,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return; } - Vector hiddenColumns = null; + ArrayList hiddenColumns = null; if (viewport.hasHiddenColumns()) { - hiddenColumns = new Vector(); + hiddenColumns = new ArrayList(); int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport .getSelectionGroup().getEndRes(); - for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns() - .size(); i++) + for (int[] region : viewport.getColumnSelection().getHiddenColumns()) { - int[] region = (int[]) viewport.getColumnSelection() - .getHiddenColumns().elementAt(i); if (region[0] >= hiddenOffset && region[1] <= hiddenCutoff) { - hiddenColumns.addElement(new int[] + hiddenColumns.add(new int[] { region[0] - hiddenOffset, region[1] - hiddenOffset }); } } @@ -2107,10 +2104,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (Desktop.jalviewClipboard != null && Desktop.jalviewClipboard[2] != null) { - Vector hc = (Vector) Desktop.jalviewClipboard[2]; - for (int i = 0; i < hc.size(); i++) + List hc = (List) Desktop.jalviewClipboard[2]; + for (int[] region : hc) { - int[] region = (int[]) hc.elementAt(i); af.viewport.hideColumns(region[0], region[1]); } } @@ -2167,10 +2163,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (Desktop.jalviewClipboard != null && Desktop.jalviewClipboard[2] != null) { - Vector hc = (Vector) Desktop.jalviewClipboard[2]; - for (int i = 0; i < hc.size(); i++) + List hc = (List) Desktop.jalviewClipboard[2]; + for (int region[] : hc) { - int[] region = (int[]) hc.elementAt(i); af.viewport.hideColumns(region[0], region[1]); } } diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 97499c9..f732a36 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -47,8 +47,8 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; +import java.util.ArrayList; import java.util.Arrays; -import java.util.Vector; import java.util.regex.Pattern; import javax.swing.JCheckBoxMenuItem; @@ -872,16 +872,13 @@ public class AnnotationLabels extends JPanel implements MouseListener, Toolkit.getDefaultToolkit().getSystemClipboard() .setContents(new StringSelection(output), Desktop.instance); - Vector hiddenColumns = null; + ArrayList hiddenColumns = null; if (av.hasHiddenColumns()) { - hiddenColumns = new Vector(); - for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) + hiddenColumns = new ArrayList(); + for (int[] region : av.getColumnSelection().getHiddenColumns()) { - int[] region = (int[]) av.getColumnSelection().getHiddenColumns() - .elementAt(i); - - hiddenColumns.addElement(new int[] + hiddenColumns.add(new int[] { region[0], region[1] }); } } diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index c96b717..9bb27ed 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -1257,8 +1257,8 @@ public class Jalview2XML for (int c = 0; c < av.getColumnSelection().getHiddenColumns() .size(); c++) { - int[] region = (int[]) av.getColumnSelection() - .getHiddenColumns().elementAt(c); + int[] region = av.getColumnSelection() + .getHiddenColumns().get(c); HiddenColumns hc = new HiddenColumns(); hc.setStart(region[0]); hc.setEnd(region[1]); diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 01e4284..32773b9 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -128,7 +128,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, }); pop.add(item); - if (av.getColumnSelection().getHiddenColumns().size() > 1) + if (av.getColumnSelection().hasHiddenColumns()) { item = new JMenuItem( MessageManager.getString("action.reveal_all")); @@ -371,24 +371,21 @@ public class ScalePanel extends JPanel implements MouseMotionListener, reveal = null; if (av.getColumnSelection().getHiddenColumns() != null) { - for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) - { - int[] region = (int[]) av.getColumnSelection().getHiddenColumns() - .elementAt(i); - if (res + 1 == region[0] || res - 1 == region[1]) - { - reveal = region; - ToolTipManager.sharedInstance().registerComponent(this); - this.setToolTipText(MessageManager - .getString("label.reveal_hidden_columns")); - break; - } - else + for (int[] region : av.getColumnSelection().getHiddenColumns()) { - this.setToolTipText(null); + if (res + 1 == region[0] || res - 1 == region[1]) + { + reveal = region; + ToolTipManager.sharedInstance().registerComponent(this); + this.setToolTipText(MessageManager + .getString("label.reveal_hidden_columns")); + break; + } + else + { + this.setToolTipText(null); + } } - - } } repaint(); } diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 4d1546b..5032f69 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -34,6 +34,7 @@ import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.image.BufferedImage; +import java.util.List; import javax.swing.JComponent; @@ -637,7 +638,7 @@ public class SeqCanvas extends JComponent } else { - java.util.Vector regions = av.getColumnSelection().getHiddenColumns(); + List regions = av.getColumnSelection().getHiddenColumns(); int screenY = 0; int blockStart = startRes; @@ -645,7 +646,7 @@ public class SeqCanvas extends JComponent for (int i = 0; regions != null && i < regions.size(); i++) { - int[] region = (int[]) regions.elementAt(i); + int[] region = regions.get(i); int hideStart = region[0]; int hideEnd = region[1];