X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPopupMenu.java;h=6903034f1ca18d5f08e7adff8fb5b85e9040b3b6;hb=70a6730dba4ab0af6906fd8f874fe853c02efef0;hp=2a7fb9f9c06e84dd0f695f04c3f0fcfe7f6ee86f;hpb=65740880573a48adc758bec3939ece9d9ae104dd;p=jalview.git diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 2a7fb9f..6903034 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -20,6 +20,8 @@ */ package jalview.gui; +import java.util.Locale; + import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; @@ -54,7 +56,7 @@ import jalview.analysis.AlignmentAnnotationUtils; import jalview.analysis.AlignmentUtils; import jalview.analysis.Conservation; import jalview.api.AlignViewportI; -import jalview.bin.Cache; +import jalview.bin.Console; import jalview.commands.ChangeCaseCommand; import jalview.commands.EditCommand; import jalview.commands.EditCommand.Action; @@ -228,13 +230,13 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener urlLink = new UrlLink(link); } catch (Exception foo) { - Cache.log.error("Exception for URLLink '" + link + "'", foo); + Console.error("Exception for URLLink '" + link + "'", foo); continue; } if (!urlLink.isValid()) { - Cache.log.error(urlLink.getInvalidMessage()); + Console.error(urlLink.getInvalidMessage()); continue; } @@ -357,14 +359,15 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener } /** - * Constructor for a PopupMenu for a click in the alignment panel (on a residue) + * Constructor for a PopupMenu for a click in the alignment panel (on a + * residue) * * @param ap - * the panel in which the mouse is clicked + * the panel in which the mouse is clicked * @param seq - * the sequence under the mouse + * the sequence under the mouse * @throws NullPointerException - * if seq is null + * if seq is null */ public PopupMenu(final AlignmentPanel ap, SequenceI seq, int column) { @@ -375,13 +378,13 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener * Constructor for a PopupMenu for a click in the sequence id panel * * @param alignPanel - * the panel in which the mouse is clicked + * the panel in which the mouse is clicked * @param seq - * the sequence under the mouse click + * the sequence under the mouse click * @param groupLinks - * templates for sequence external links + * templates for sequence external links * @throws NullPointerException - * if seq is null + * if seq is null */ public PopupMenu(final AlignmentPanel alignPanel, final SequenceI seq, List groupLinks) @@ -397,11 +400,10 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener * @param alignPanel * @param seq * @param column - * aligned column position (0...) + * aligned column position (0...) * @param groupLinks */ - private PopupMenu(boolean fromIdPanel, - final AlignmentPanel alignPanel, + private PopupMenu(boolean fromIdPanel, final AlignmentPanel alignPanel, final SequenceI seq, final int column, List groupLinks) { Objects.requireNonNull(seq); @@ -441,9 +443,10 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener /* * And repeat for the current selection group (if there is one): */ - final List selectedGroup = (alignPanel.av.getSelectionGroup() == null - ? Collections. emptyList() - : alignPanel.av.getSelectionGroup().getSequences()); + final List selectedGroup = (alignPanel.av + .getSelectionGroup() == null + ? Collections. emptyList() + : alignPanel.av.getSelectionGroup().getSequences()); buildAnnotationTypesMenus(groupShowAnnotationsMenu, groupHideAnnotationsMenu, selectedGroup); configureReferenceAnnotationsMenu(groupAddReferenceAnnotations, @@ -669,7 +672,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener buildGroupURLMenu(sg, groupLinks); } // Add a 'show all structures' for the current selection - Hashtable pdbe = new Hashtable<>(), reppdb = new Hashtable<>(); + Hashtable pdbe = new Hashtable<>(), + reppdb = new Hashtable<>(); SequenceI sqass = null; for (SequenceI sq : alignPanel.av.getSequenceSelection()) @@ -706,7 +710,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener { createGroupMenuItem.setVisible(true); unGroupMenuItem.setVisible(false); - editGroupMenu.setText(MessageManager.getString("action.edit_new_group")); + editGroupMenu + .setText(MessageManager.getString("action.edit_new_group")); } else { @@ -733,8 +738,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener *
  • positional feature links (alignment panel popup menu)
  • *
  • feature details links (alignment panel popup menu)
  • * - * If this panel is also showed complementary (CDS/protein) features, then links - * to their feature details are also added. + * If this panel is also showed complementary (CDS/protein) features, then + * links to their feature details are also added. * * @param seq * @param column @@ -837,10 +842,14 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener /* * show local rather than linked feature coordinates */ - int[] beginRange = mf.getMappedPositions(start, start); - start = beginRange[0]; - int[] endRange = mf.getMappedPositions(end, end); - end = endRange[endRange.length - 1]; + int[] localRange = mf.getMappedPositions(start, end); + if (localRange == null) + { + // e.g. variant extending to stop codon so not mappable + return; + } + start = localRange[0]; + end = localRange[localRange.length - 1]; } StringBuilder desc = new StringBuilder(); desc.append(sf.getType()).append(" ").append(String.valueOf(start)); @@ -1125,7 +1134,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener for (int d = 0; d < nd; d++) { DBRefEntry e = dbr.get(d); - String src = e.getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase(); + String src = e.getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase(Locale.ROOT); Object[] sarray = commonDbrefs.get(src); if (sarray == null) { @@ -1138,8 +1147,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener if (((String[]) sarray[1])[sq] == null) { - if (!e.hasMap() || (e.getMap() - .locateMappedRange(start, end) != null)) + if (!e.hasMap() + || (e.getMap().locateMappedRange(start, end) != null)) { ((String[]) sarray[1])[sq] = e.getAccessionId(); ((int[]) sarray[0])[0]++; @@ -1159,19 +1168,19 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener urlLink = new GroupUrlLink(link); } catch (Exception foo) { - Cache.log.error("Exception for GroupURLLink '" + link + "'", foo); + Console.error("Exception for GroupURLLink '" + link + "'", foo); continue; } if (!urlLink.isValid()) { - Cache.log.error(urlLink.getInvalidMessage()); + Console.error(urlLink.getInvalidMessage()); continue; } final String label = urlLink.getLabel(); boolean usingNames = false; // Now see which parts of the group apply for this URL String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget()); - Object[] idset = commonDbrefs.get(ltarget.toUpperCase()); + Object[] idset = commonDbrefs.get(ltarget.toUpperCase(Locale.ROOT)); String[] seqstr, ids; // input to makeUrl if (idset != null) { @@ -1778,7 +1787,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener } inserts.and(sq.getInsertionsAsBits()); } - hidden.clearAndHideColumns(inserts, ap.av.getSelectionGroup().getStartRes(), + hidden.clearAndHideColumns(inserts, + ap.av.getSelectionGroup().getStartRes(), ap.av.getSelectionGroup().getEndRes()); } @@ -1807,7 +1817,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener contents.append("

    " + MessageManager.formatMessage( "label.create_sequence_details_report_annotation_for", new Object[] - { seq.getDisplayId(true) }) + "

    "); + { seq.getDisplayId(true) }) + "

    \n

    "); new SequenceAnnotationReport(false).createSequenceAnnotationReport( contents, seq, true, true, ap.getSeqPanel().seqCanvas.fr); contents.append("

    "); @@ -2008,8 +2018,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener /** * Shows a dialog where the sequence name and description may be edited. If a - * name containing spaces is entered, these are converted to underscores, with a - * warning message. + * name containing spaces is entered, these are converted to underscores, with + * a warning message. */ void sequenceName_actionPerformed() { @@ -2017,10 +2027,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener sequence.getDescription(), MessageManager.getString("label.sequence_name"), MessageManager.getString("label.sequence_description")); - dialog.showDialog(ap.alignFrame, - MessageManager.getString( - "label.edit_sequence_name_description"), - new Runnable() + dialog.showDialog(ap.alignFrame, MessageManager.getString( + "label.edit_sequence_name_description"), new Runnable() { @Override public void run() @@ -2072,8 +2080,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener */ protected void outline_actionPerformed() { - String title = MessageManager - .getString("label.select_outline_colour"); + String title = MessageManager.getString("label.select_outline_colour"); ColourChooserListener listener = new ColourChooserListener() { @Override @@ -2083,8 +2090,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener refresh(); } }; - JalviewColourChooser.showColourChooser(Desktop.getDesktop(), - title, Color.BLUE, listener); + JalviewColourChooser.showColourChooser(Desktop.getDesktop(), title, + Color.BLUE, listener); } /**