From: kiramt Date: Tue, 6 Jun 2017 14:56:04 +0000 (+0100) Subject: JAL-2591 Removed getHiddenRegions()==null checks which are always false X-Git-Tag: Release_2_10_3b1~183^2~17 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0af3213cac54f10113b6fa2cbfb4523dae61b5b7;p=jalview.git JAL-2591 Removed getHiddenRegions()==null checks which are always false --- diff --git a/src/jalview/appletgui/AnnotationColumnChooser.java b/src/jalview/appletgui/AnnotationColumnChooser.java index 60775d3..0a4748c 100644 --- a/src/jalview/appletgui/AnnotationColumnChooser.java +++ b/src/jalview/appletgui/AnnotationColumnChooser.java @@ -142,7 +142,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements } setOldHiddenColumns(av.getAlignment().getHiddenColumns()); adjusting = true; - Vector list = new Vector(); + Vector list = new Vector<>(); int index = 1; for (int i = 0; i < anns.length; i++) { @@ -298,7 +298,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements HiddenColumns oldHidden = av .getAnnotationColumnSelectionState() .getOldHiddenColumns(); - if (oldHidden != null && oldHidden.getHiddenRegions() != null + if (oldHidden != null && !oldHidden.getHiddenRegions().isEmpty()) { for (Iterator itr = oldHidden.getHiddenRegions() diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 4aa205e..a72bbaa 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -937,7 +937,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, List findFeaturesAtRes(SequenceI sequence, int res) { - List result = new ArrayList(); + List result = new ArrayList<>(); SequenceFeature[] features = sequence.getSequenceFeatures(); if (features != null) { @@ -1501,7 +1501,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, { if (links == null) { - links = new Vector(); + links = new Vector<>(); } for (int j = 0; j < sf.links.size(); j++) { @@ -1926,8 +1926,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, } if (copycolsel && av.hasHiddenColumns() - && (av.getColumnSelection() == null || av.getAlignment() - .getHiddenColumns().getHiddenRegions() == null)) + && (av.getColumnSelection() == null)) { System.err.println("Bad things"); } diff --git a/src/jalview/gui/AnnotationColumnChooser.java b/src/jalview/gui/AnnotationColumnChooser.java index 9c2a1b9..5122f29 100644 --- a/src/jalview/gui/AnnotationColumnChooser.java +++ b/src/jalview/gui/AnnotationColumnChooser.java @@ -244,7 +244,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements HiddenColumns oldHidden = av .getAnnotationColumnSelectionState() .getOldHiddenColumns(); - if (oldHidden != null && oldHidden.getHiddenRegions() != null + if (oldHidden != null && !oldHidden.getHiddenRegions().isEmpty()) { for (Iterator itr = oldHidden.getHiddenRegions() @@ -727,7 +727,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements private static final String FILTER_BY_ANN_CACHE_KEY = "CACHE.SELECT_FILTER_BY_ANNOT"; - public JvCacheableInputBox searchBox = new JvCacheableInputBox( + public JvCacheableInputBox searchBox = new JvCacheableInputBox<>( FILTER_BY_ANN_CACHE_KEY); public SearchPanel(AnnotationColumnChooser aColChooser) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index dee921e..1675bf0 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -180,13 +180,13 @@ public class Jalview2XML * Map of reconstructed AlignFrame objects that appear to have come from * SplitFrame objects (have a dna/protein complement view). */ - private Map splitFrameCandidates = new HashMap(); + private Map splitFrameCandidates = new HashMap<>(); /* * Map from displayed rna structure models to their saved session state jar * entry names */ - private Map rnaSessions = new HashMap(); + private Map rnaSessions = new HashMap<>(); /** * create/return unique hash string for sq @@ -247,19 +247,19 @@ public class Jalview2XML { if (seqsToIds == null) { - seqsToIds = new IdentityHashMap(); + seqsToIds = new IdentityHashMap<>(); } if (seqRefIds == null) { - seqRefIds = new HashMap(); + seqRefIds = new HashMap<>(); } if (incompleteSeqs == null) { - incompleteSeqs = new HashMap(); + incompleteSeqs = new HashMap<>(); } if (frefedSequence == null) { - frefedSequence = new ArrayList(); + frefedSequence = new ArrayList<>(); } } @@ -458,9 +458,9 @@ public class Jalview2XML * This maintains a map of viewports, the key being the seqSetId. Important to * set historyItem and redoList for multiple views */ - Map viewportsAdded = new HashMap(); + Map viewportsAdded = new HashMap<>(); - Map annotationIds = new HashMap(); + Map annotationIds = new HashMap<>(); String uniqueSetSuffix = ""; @@ -536,7 +536,7 @@ public class Jalview2XML */ private void saveAllFrames(List frames, JarOutputStream jout) { - Hashtable dsses = new Hashtable(); + Hashtable dsses = new Hashtable<>(); /* * ensure cached data is clear before starting @@ -551,8 +551,8 @@ public class Jalview2XML // NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS // ////////////////////////////////////////////////// - List shortNames = new ArrayList(); - List viewIds = new ArrayList(); + List shortNames = new ArrayList<>(); + List viewIds = new ArrayList<>(); // REVERSE ORDER for (int i = frames.size() - 1; i > -1; i--) @@ -662,7 +662,7 @@ public class Jalview2XML { FileOutputStream fos = new FileOutputStream(jarFile); JarOutputStream jout = new JarOutputStream(fos); - List frames = new ArrayList(); + List frames = new ArrayList<>(); // resolve splitframes if (af.getViewport().getCodingComplement() != null) @@ -748,12 +748,12 @@ public class Jalview2XML { if (viewIds == null) { - viewIds = new ArrayList(); + viewIds = new ArrayList<>(); } initSeqRefs(); - List userColours = new ArrayList(); + List userColours = new ArrayList<>(); AlignViewport av = ap.av; ViewportRanges vpRanges = av.getRanges(); @@ -807,9 +807,9 @@ public class Jalview2XML } JSeq jseq; - Set calcIdSet = new HashSet(); + Set calcIdSet = new HashSet<>(); // record the set of vamsas sequence XML POJO we create. - HashMap vamsasSetIds = new HashMap(); + HashMap vamsasSetIds = new HashMap<>(); // SAVE SEQUENCES for (final SequenceI jds : rjal.getSequences()) { @@ -986,7 +986,7 @@ public class Jalview2XML pdb.setFile(matchedFile); // entry.getFile()); if (pdbfiles == null) { - pdbfiles = new ArrayList(); + pdbfiles = new ArrayList<>(); } if (!pdbfiles.contains(pdbId)) @@ -1135,7 +1135,7 @@ public class Jalview2XML /** * store forward refs from an annotationRow to any groups */ - IdentityHashMap groupRefs = new IdentityHashMap(); + IdentityHashMap groupRefs = new IdentityHashMap<>(); if (storeDS) { for (SequenceI sq : jal.getSequences()) @@ -1349,7 +1349,7 @@ public class Jalview2XML .getFeatureRenderer().getRenderOrder() .toArray(new String[0]); - Vector settingsAdded = new Vector(); + Vector settingsAdded = new Vector<>(); if (renderOrder != null) { for (String featureType : renderOrder) @@ -1392,7 +1392,7 @@ public class Jalview2XML // is groups actually supposed to be a map here ? Iterator en = ap.getSeqPanel().seqCanvas .getFeatureRenderer().getFeatureGroups().iterator(); - Vector groupsAdded = new Vector(); + Vector groupsAdded = new Vector<>(); while (en.hasNext()) { String grp = en.next(); @@ -1415,7 +1415,7 @@ public class Jalview2XML { jalview.datamodel.HiddenColumns hidden = av.getAlignment() .getHiddenColumns(); - if (hidden == null || hidden.getHiddenRegions() == null) + if (hidden == null) { warn("REPORT BUG: avoided null columnselection bug (DMAM reported). Please contact Jim about this."); } @@ -2290,7 +2290,7 @@ public class Jalview2XML try { // create list to store references for any new Jmol viewers created - newStructureViewers = new Vector(); + newStructureViewers = new Vector<>(); // UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING // Workaround is to make sure caller implements the JarInputStreamProvider // interface @@ -2383,8 +2383,8 @@ public class Jalview2XML initSeqRefs(); } AlignFrame af = null, _af = null; - IdentityHashMap importedDatasets = new IdentityHashMap(); - Map gatherToThisFrame = new HashMap(); + IdentityHashMap importedDatasets = new IdentityHashMap<>(); + Map gatherToThisFrame = new HashMap<>(); final String file = jprovider.getFilename(); try { @@ -2525,9 +2525,9 @@ public class Jalview2XML */ protected void restoreSplitFrames() { - List gatherTo = new ArrayList(); - List addedToSplitFrames = new ArrayList(); - Map dna = new HashMap(); + List gatherTo = new ArrayList<>(); + List addedToSplitFrames = new ArrayList<>(); + Map dna = new HashMap<>(); /* * Identify the DNA alignments @@ -2669,7 +2669,7 @@ public class Jalview2XML errorMessage = null; } - Map alreadyLoadedPDB = new HashMap(); + Map alreadyLoadedPDB = new HashMap<>(); /** * when set, local views will be updated from view stored in JalviewXML @@ -2840,7 +2840,7 @@ public class Jalview2XML List hiddenSeqs = null; - List tmpseqs = new ArrayList(); + List tmpseqs = new ArrayList<>(); boolean multipleView = false; SequenceI referenceseqForView = null; @@ -2908,7 +2908,7 @@ public class Jalview2XML { if (hiddenSeqs == null) { - hiddenSeqs = new ArrayList(); + hiddenSeqs = new ArrayList<>(); } hiddenSeqs.add(tmpSeq); @@ -3116,12 +3116,12 @@ public class Jalview2XML // //////////////////////////////// // LOAD ANNOTATIONS - List autoAlan = new ArrayList(); + List autoAlan = new ArrayList<>(); /* * store any annotations which forward reference a group's ID */ - Map> groupAnnotRefs = new Hashtable>(); + Map> groupAnnotRefs = new Hashtable<>(); if (vamsasSet.getAnnotationCount() > 0) { @@ -3276,7 +3276,7 @@ public class Jalview2XML .get(an[i].getGroupRef()); if (aal == null) { - aal = new ArrayList(); + aal = new ArrayList<>(); groupAnnotRefs.put(an[i].getGroupRef(), aal); } aal.add(jaa); @@ -3366,7 +3366,7 @@ public class Jalview2XML } int pidThreshold = jGroup.getPidThreshold(); - Vector seqs = new Vector(); + Vector seqs = new Vector<>(); for (int s = 0; s < jGroup.getSeqCount(); s++) { @@ -3759,7 +3759,7 @@ public class Jalview2XML * Run through all PDB ids on the alignment, and collect mappings between * distinct view ids and all sequences referring to that view. */ - Map structureViewers = new LinkedHashMap(); + Map structureViewers = new LinkedHashMap<>(); for (int i = 0; i < jseqs.length; i++) { @@ -3957,8 +3957,8 @@ public class Jalview2XML Set> fileData = data.getFileData() .entrySet(); - List pdbs = new ArrayList(); - List allseqs = new ArrayList(); + List pdbs = new ArrayList<>(); + List allseqs = new ArrayList<>(); for (Entry pdb : fileData) { String filePath = pdb.getValue().getFilePath(); @@ -4014,9 +4014,9 @@ public class Jalview2XML getViewerJarEntryName(svattrib.getViewId())); } - List pdbfilenames = new ArrayList(); - List seqmaps = new ArrayList(); - List pdbids = new ArrayList(); + List pdbfilenames = new ArrayList<>(); + List seqmaps = new ArrayList<>(); + List pdbids = new ArrayList<>(); StringBuilder newFileLoc = new StringBuilder(64); int cp = 0, ncp, ecp; Map oldFiles = svattrib.getFileData(); @@ -4577,8 +4577,8 @@ public class Jalview2XML af.viewport.setFeaturesDisplayed(fdi = new FeaturesDisplayed()); String[] renderOrder = new String[jms.getFeatureSettings() .getSettingCount()]; - Map featureColours = new Hashtable(); - Map featureOrder = new Hashtable(); + Map featureColours = new Hashtable<>(); + Map featureOrder = new Hashtable<>(); for (int fs = 0; fs < jms.getFeatureSettings().getSettingCount(); fs++) { @@ -4637,7 +4637,7 @@ public class Jalview2XML fdi.setVisible(setting.getType()); } } - Map fgtable = new Hashtable(); + Map fgtable = new Hashtable<>(); for (int gs = 0; gs < jms.getFeatureSettings().getGroupCount(); gs++) { Group grp = jms.getFeatureSettings().getGroup(gs); @@ -4830,7 +4830,7 @@ public class Jalview2XML String[] magicNames = new String[] { "Consensus", "Quality", "Conservation" }; JvAnnotRow nullAnnot = new JvAnnotRow(-1, null); - Hashtable visan = new Hashtable(); + Hashtable visan = new Hashtable<>(); for (String nm : magicNames) { visan.put(nm, nullAnnot); @@ -4842,11 +4842,11 @@ public class Jalview2XML + auan.template.getCalcId()), auan); } int hSize = al.getAlignmentAnnotation().length; - List reorder = new ArrayList(); + List reorder = new ArrayList<>(); // work through any autoCalculated annotation already on the view // removing it if it should be placed in a different location on the // annotation panel. - List remains = new ArrayList(visan.keySet()); + List remains = new ArrayList<>(visan.keySet()); for (int h = 0; h < hSize; h++) { jalview.datamodel.AlignmentAnnotation jalan = al @@ -5174,7 +5174,7 @@ public class Jalview2XML { if (datasetIds == null) { - datasetIds = new Hashtable(); + datasetIds = new Hashtable<>(); return null; } if (datasetIds.containsKey(datasetId)) @@ -5188,7 +5188,7 @@ public class Jalview2XML { if (datasetIds == null) { - datasetIds = new Hashtable(); + datasetIds = new Hashtable<>(); } datasetIds.put(datasetId, dataset); } @@ -5211,7 +5211,7 @@ public class Jalview2XML // make a new datasetId and record it if (dataset2Ids == null) { - dataset2Ids = new IdentityHashMap(); + dataset2Ids = new IdentityHashMap<>(); } else { @@ -5490,11 +5490,11 @@ public class Jalview2XML // register sequence object so the XML parser can recover it. if (seqRefIds == null) { - seqRefIds = new HashMap(); + seqRefIds = new HashMap<>(); } if (seqsToIds == null) { - seqsToIds = new IdentityHashMap(); + seqsToIds = new IdentityHashMap<>(); } seqRefIds.put(jv2vobj.get(jvobj).toString(), (SequenceI) jvobj); seqsToIds.put((SequenceI) jvobj, id); diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index cb19539..8a24937 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -403,20 +403,17 @@ public class ScalePanel extends JPanel implements MouseMotionListener, res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res); - if (av.getAlignment().getHiddenColumns().getHiddenRegions() != null) + for (int[] region : av.getAlignment().getHiddenColumns() + .getHiddenRegions()) { - for (int[] region : av.getAlignment().getHiddenColumns() - .getHiddenRegions()) + if (res + 1 == region[0] || res - 1 == region[1]) { - if (res + 1 == region[0] || res - 1 == region[1]) - { - reveal = region; - ToolTipManager.sharedInstance().registerComponent(this); - this.setToolTipText(MessageManager - .getString("label.reveal_hidden_columns")); - repaint(); - return; - } + reveal = region; + ToolTipManager.sharedInstance().registerComponent(this); + this.setToolTipText( + MessageManager.getString("label.reveal_hidden_columns")); + repaint(); + return; } } } @@ -499,7 +496,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, gg.setColor(Color.blue); int res; - if (av.getShowHiddenMarkers() && hidden.getHiddenRegions() != null) + if (av.getShowHiddenMarkers()) { for (int i = 0; i < hidden.getHiddenRegions() .size(); i++) diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index c6c2deb..7651eb4 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -2145,8 +2145,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (copycolsel && av.hasHiddenColumns() - && (av.getAlignment().getHiddenColumns() == null || av - .getAlignment().getHiddenColumns().getHiddenRegions() == null)) + && (av.getAlignment().getHiddenColumns() == null)) { System.err.println("Bad things"); } diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 60cee46..107cdd4 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -1159,7 +1159,7 @@ public abstract class AlignmentViewport implements AlignViewportI, @Override public boolean hasHiddenColumns() { - return colSel != null + return alignment.getHiddenColumns() != null && alignment.getHiddenColumns().hasHiddenColumns(); }