X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPopupMenu.java;h=dcf0209a6a260d3cdfa85a32c1d7238f0fffe86e;hb=b5667f39acdf309cd92881b73edfda591e0acaf4;hp=73d794161ba78018acdfacad75ce4bfe97730b07;hpb=8af8526d7448904c67db19f41e237a0eedd55a74;p=jalview.git
diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java
index 73d7941..dcf0209 100644
--- a/src/jalview/gui/PopupMenu.java
+++ b/src/jalview/gui/PopupMenu.java
@@ -33,15 +33,11 @@ import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.HiddenColumns;
-import jalview.datamodel.HiddenMarkovModel;
import jalview.datamodel.PDBEntry;
-import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.ColourMenuHelper.ColourChangeListener;
-import jalview.hmmer.HMMAlignThread;
-import jalview.hmmer.HMMBuildThread;
import jalview.io.FileFormatI;
import jalview.io.FileFormats;
import jalview.io.FormatAdapter;
@@ -50,9 +46,11 @@ import jalview.schemes.Blosum62ColourScheme;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemes;
import jalview.schemes.PIDColourScheme;
+import jalview.schemes.ResidueColourScheme;
import jalview.util.GroupUrlLink;
import jalview.util.GroupUrlLink.UrlStringTooLongException;
import jalview.util.MessageManager;
+import jalview.util.StringUtils;
import jalview.util.UrlLink;
import java.awt.Color;
@@ -60,6 +58,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.BitSet;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
@@ -70,17 +69,17 @@ import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Vector;
+import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JColorChooser;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
+import javax.swing.JRadioButtonMenuItem;
/**
- * DOCUMENT ME!
- *
- * @author $author$
- * @version $Revision: 1.118 $
+ * The popup menu that is displayed on right-click on a sequence id, or in the
+ * sequence alignment.
*/
public class PopupMenu extends JPopupMenu implements ColourChangeListener
{
@@ -94,6 +93,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
+ protected JRadioButtonMenuItem annotationColour;
+
protected JMenuItem modifyConservation = new JMenuItem();
AlignmentPanel ap;
@@ -160,7 +161,6 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
JMenuItem sequenceFeature = new JMenuItem();
- JMenuItem hmmBuildGroup = new JMenuItem();
JMenuItem textColour = new JMenuItem();
@@ -177,28 +177,215 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
JMenuItem hideInsertions = new JMenuItem();
/**
+ * Constructs a menu with sub-menu items for any hyperlinks for the sequence
+ * and/or features provided. Hyperlinks may include a lookup by sequence id,
+ * or database cross-references, depending on which links are enabled in user
+ * preferences.
+ *
+ * @param seq
+ * @param features
+ * @return
+ */
+ static JMenu buildLinkMenu(final SequenceI seq,
+ List features)
+ {
+ JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
+
+ List nlinks = null;
+ if (seq != null)
+ {
+ nlinks = Preferences.sequenceUrlLinks.getLinksForMenu();
+ UrlLink.sort(nlinks);
+ }
+ else
+ {
+ nlinks = new ArrayList<>();
+ }
+
+ if (features != null)
+ {
+ for (SequenceFeature sf : features)
+ {
+ if (sf.links != null)
+ {
+ for (String link : sf.links)
+ {
+ nlinks.add(link);
+ }
+ }
+ }
+ }
+
+ /*
+ * instantiate the hyperlinklink templates from sequence data;
+ * note the order of the templates is preserved in the map
+ */
+ Map> linkset = new LinkedHashMap<>();
+ for (String link : nlinks)
+ {
+ UrlLink urlLink = null;
+ try
+ {
+ urlLink = new UrlLink(link);
+ } catch (Exception foo)
+ {
+ Cache.log.error("Exception for URLLink '" + link + "'", foo);
+ continue;
+ }
+
+ if (!urlLink.isValid())
+ {
+ Cache.log.error(urlLink.getInvalidMessage());
+ continue;
+ }
+
+ urlLink.createLinksFromSeq(seq, linkset);
+ }
+
+ /*
+ * construct menu items for the hyperlinks (still preserving
+ * the order of the sorted templates)
+ */
+ addUrlLinks(linkMenu, linkset.values());
+
+ return linkMenu;
+ }
+
+ /**
+ * A helper method that builds menu items from the given links, with action
+ * handlers to open the link URL, and adds them to the linkMenu. Each provided
+ * link should be a list whose second item is the menu text, and whose fourth
+ * item is the URL to open when the menu item is selected.
+ *
+ * @param linkMenu
+ * @param linkset
+ */
+ static private void addUrlLinks(JMenu linkMenu,
+ Collection> linkset)
+ {
+ for (List linkstrset : linkset)
+ {
+ final String url = linkstrset.get(3);
+ JMenuItem item = new JMenuItem(linkstrset.get(1));
+ item.setToolTipText(MessageManager
+ .formatMessage("label.open_url_param", new Object[]
+ { url }));
+ item.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ showLink(url);
+ }
+ }).start();
+ }
+ });
+ linkMenu.add(item);
+ }
+ }
+
+ /**
+ * Opens the provided url in the default web browser, or shows an error
+ * message if this fails
+ *
+ * @param url
+ */
+ static void showLink(String url)
+ {
+ try
+ {
+ jalview.util.BrowserLauncher.openURL(url);
+ } catch (Exception ex)
+ {
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.getString("label.web_browser_not_found_unix"),
+ MessageManager.getString("label.web_browser_not_found"),
+ JvOptionPane.WARNING_MESSAGE);
+
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * add a late bound groupURL item to the given linkMenu
+ *
+ * @param linkMenu
+ * @param label
+ * - menu label string
+ * @param urlgenerator
+ * GroupURLLink used to generate URL
+ * @param urlstub
+ * Object array returned from the makeUrlStubs function.
+ */
+ static void addshowLink(JMenu linkMenu, String label,
+ final GroupUrlLink urlgenerator, final Object[] urlstub)
+ {
+ JMenuItem item = new JMenuItem(label);
+ item.setToolTipText(MessageManager
+ .formatMessage("label.open_url_seqs_param", new Object[]
+ { urlgenerator.getUrl_prefix(),
+ urlgenerator.getNumberInvolved(urlstub) }));
+ // TODO: put in info about what is being sent.
+ item.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ new Thread(new Runnable()
+ {
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ showLink(urlgenerator.constructFrom(urlstub));
+ } catch (UrlStringTooLongException e2)
+ {
+ }
+ }
+
+ }).start();
+ }
+ });
+
+ linkMenu.add(item);
+ }
+
+ /**
* Creates a new PopupMenu object.
*
* @param ap
- * DOCUMENT ME!
* @param seq
- * DOCUMENT ME!
+ * @param features
+ * non-positional features (for seq not null), or positional features
+ * at residue (for seq equal to null)
*/
- public PopupMenu(final AlignmentPanel ap, Sequence seq,
- List links)
+ public PopupMenu(final AlignmentPanel ap, SequenceI seq,
+ List features)
{
- this(ap, seq, links, null);
+ this(ap, seq, features, null);
}
/**
+ * Constructor
*
- * @param ap
+ * @param alignPanel
* @param seq
- * @param links
+ * the sequence under the cursor if in the Id panel, null if in the
+ * sequence panel
+ * @param features
+ * non-positional features if in the Id panel, features at the
+ * clicked residue if in the sequence panel
* @param groupLinks
*/
- public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
- List links, List groupLinks)
+ public PopupMenu(final AlignmentPanel alignPanel, final SequenceI seq,
+ List features, List groupLinks)
{
// /////////////////////////////////////////////////////////
// If this is activated from the sequence panel, the user may want to
@@ -206,7 +393,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
//
// If from the IDPanel, we must display the sequence menu
// ////////////////////////////////////////////////////////
- this.ap = ap;
+ this.ap = alignPanel;
sequence = seq;
for (String ff : FileFormats.getInstance().getWritableFormats(true))
@@ -232,6 +419,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
*/
final List selectedSequence = (seq == null
? Collections. emptyList() : Arrays.asList(seq));
+
buildAnnotationTypesMenus(seqShowAnnotationsMenu,
seqHideAnnotationsMenu, selectedSequence);
configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
@@ -240,9 +428,9 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
/*
* And repeat for the current selection group (if there is one):
*/
- final List selectedGroup = (ap.av.getSelectionGroup() == null
+ final List selectedGroup = (alignPanel.av.getSelectionGroup() == null
? Collections. emptyList()
- : ap.av.getSelectionGroup().getSequences());
+ : alignPanel.av.getSelectionGroup().getSequences());
buildAnnotationTypesMenus(groupShowAnnotationsMenu,
groupHideAnnotationsMenu, selectedGroup);
configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
@@ -260,7 +448,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
if (seq != null)
{
sequenceMenu.setText(sequence.getName());
- if (seq == ap.av.getAlignment().getSeqrep())
+ if (seq == alignPanel.av.getAlignment().getSeqrep())
{
makeReferenceSeq.setText(
MessageManager.getString("action.unmark_as_reference"));
@@ -271,7 +459,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
MessageManager.getString("action.set_as_reference"));
}
- if (!ap.av.getAlignment().isNucleotide())
+ if (!alignPanel.av.getAlignment().isNucleotide())
{
remove(rnaStructureMenu);
}
@@ -282,7 +470,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
* add menu items to 2D-render any alignment or sequence secondary
* structure annotation
*/
- AlignmentAnnotation[] aas = ap.av.getAlignment()
+ AlignmentAnnotation[] aas = alignPanel.av.getAlignment()
.getAlignmentAnnotation();
if (aas != null)
{
@@ -295,15 +483,14 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
*/
menuItem = new JMenuItem();
menuItem.setText(MessageManager.formatMessage(
- "label.2d_rna_structure_line",
- new Object[]
- { aa.label }));
+ "label.2d_rna_structure_line", new Object[]
+ { aa.label }));
menuItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- new AppVarna(seq, aa, ap);
+ new AppVarna(seq, aa, alignPanel);
}
});
rnaStructureMenu.add(menuItem);
@@ -324,16 +511,15 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
// TODO: make rnastrucF a bit more nice
menuItem = new JMenuItem();
menuItem.setText(MessageManager.formatMessage(
- "label.2d_rna_sequence_name",
- new Object[]
- { seq.getName() }));
+ "label.2d_rna_sequence_name", new Object[]
+ { seq.getName() }));
menuItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
// TODO: VARNA does'nt print gaps in the sequence
- new AppVarna(seq, aa, ap);
+ new AppVarna(seq, aa, alignPanel);
}
});
rnaStructureMenu.add(menuItem);
@@ -358,41 +544,11 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
});
add(menuItem);
- if (sequence.isHMMConsensusSequence())
- {
- JMenuItem selectHMM = new JCheckBoxMenuItem();
- selectHMM.setText(MessageManager.getString("label.select_hmm"));
- selectHMM.addActionListener(new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- selectHMM_actionPerformed(e);
- }
- });
- add(selectHMM);
-
- JMenuItem hmmAlign = new JCheckBoxMenuItem();
- hmmAlign.setText(MessageManager.getString("label.hmmalign"));
- hmmAlign.addActionListener(new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- hmmAlign_actionPerformed(e);
- }
- });
- add(hmmAlign);
- }
-
- if (ap.av.getSelectionGroup() != null
- && ap.av.getSelectionGroup().getSize() > 1)
+ if (alignPanel.av.getSelectionGroup() != null
+ && alignPanel.av.getSelectionGroup().getSize() > 1)
{
- menuItem = new JMenuItem(
- MessageManager.formatMessage("label.represent_group_with",
- new Object[]
+ menuItem = new JMenuItem(MessageManager
+ .formatMessage("label.represent_group_with", new Object[]
{ seq.getName() }));
menuItem.addActionListener(new ActionListener()
{
@@ -405,12 +561,12 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
sequenceMenu.add(menuItem);
}
- if (ap.av.hasHiddenRows())
+ if (alignPanel.av.hasHiddenRows())
{
- final int index = ap.av.getAlignment().findIndex(seq);
+ final int index = alignPanel.av.getAlignment().findIndex(seq);
- if (ap.av.adjustForHiddenSeqs(index)
- - ap.av.adjustForHiddenSeqs(index - 1) > 1)
+ if (alignPanel.av.adjustForHiddenSeqs(index)
+ - alignPanel.av.adjustForHiddenSeqs(index - 1) > 1)
{
menuItem = new JMenuItem(
MessageManager.getString("action.reveal_sequences"));
@@ -419,10 +575,10 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
@Override
public void actionPerformed(ActionEvent e)
{
- ap.av.showSequence(index);
- if (ap.overviewPanel != null)
+ alignPanel.av.showSequence(index);
+ if (alignPanel.overviewPanel != null)
{
- ap.overviewPanel.updateOverviewImage();
+ alignPanel.overviewPanel.updateOverviewImage();
}
}
});
@@ -430,9 +586,20 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
}
}
- // for the case when no sequences are even visible
- if (ap.av.hasHiddenRows())
+
+ /*
+ * offer 'Reveal All'
+ * - in the IdPanel (seq not null) if any sequence is hidden
+ * - in the IdPanel or SeqPanel if all sequences are hidden (seq is null)
+ */
+ if (alignPanel.av.hasHiddenRows())
{
+ boolean addOption = seq != null;
+ if (!addOption && alignPanel.av.getAlignment().getHeight() == 0)
+ {
+ addOption = true;
+ }
+ if (addOption)
{
menuItem = new JMenuItem(
MessageManager.getString("action.reveal_all"));
@@ -441,21 +608,21 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
@Override
public void actionPerformed(ActionEvent e)
{
- ap.av.showAllHiddenSeqs();
- if (ap.overviewPanel != null)
+ alignPanel.av.showAllHiddenSeqs();
+ if (alignPanel.overviewPanel != null)
{
- ap.overviewPanel.updateOverviewImage();
+ alignPanel.overviewPanel.updateOverviewImage();
}
}
});
-
add(menuItem);
}
}
- SequenceGroup sg = ap.av.getSelectionGroup();
+ SequenceGroup sg = alignPanel.av.getSelectionGroup();
boolean isDefinedGroup = (sg != null)
- ? ap.av.getAlignment().getGroups().contains(sg) : false;
+ ? alignPanel.av.getAlignment().getGroups().contains(sg)
+ : false;
if (sg != null && sg.getSize() > 0)
{
@@ -489,10 +656,11 @@ 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<>();
+ Hashtable reppdb = new Hashtable<>();
+
SequenceI sqass = null;
- for (SequenceI sq : ap.av.getSequenceSelection())
+ for (SequenceI sq : alignPanel.av.getSequenceSelection())
{
Vector pes = sq.getDatasetSequence().getAllPDBEntries();
if (pes != null && pes.size() > 0)
@@ -542,65 +710,118 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
rnaStructureMenu.setVisible(false);
}
- if (links != null && links.size() > 0)
+ addLinks(seq, features);
+
+ if (seq == null)
{
- addFeatureLinks(seq, links);
+ addFeatureDetails(features);
}
}
/**
- * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
+ * Add a link to show feature details for each sequence feature
*
- * @param seq
- * @param links
+ * @param features
*/
- void addFeatureLinks(final SequenceI seq, List links)
+ protected void addFeatureDetails(List features)
{
- JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
- Map> linkset = new LinkedHashMap<>();
+ if (features == null || features.isEmpty())
+ {
+ return;
+ }
+ JMenu details = new JMenu(
+ MessageManager.getString("label.feature_details"));
+ add(details);
- for (String link : links)
+ for (final SequenceFeature sf : features)
{
- UrlLink urlLink = null;
- try
+ int start = sf.getBegin();
+ int end = sf.getEnd();
+ String desc = null;
+ if (start == end)
{
- urlLink = new UrlLink(link);
- } catch (Exception foo)
+ desc = String.format("%s %d", sf.getType(), start);
+ }
+ else
{
- Cache.log.error("Exception for URLLink '" + link + "'", foo);
- continue;
+ desc = String.format("%s %d-%d", sf.getType(), start, end);
}
-
- if (!urlLink.isValid())
+ String tooltip = desc;
+ String description = sf.getDescription();
+ if (description != null)
{
- Cache.log.error(urlLink.getInvalidMessage());
- continue;
+ description = StringUtils.stripHtmlTags(description);
+ if (description.length() > 12)
+ {
+ desc = desc + " " + description.substring(0, 12) + "..";
+ }
+ else
+ {
+ desc = desc + " " + description;
+ }
+ tooltip = tooltip + " " + description;
}
-
- urlLink.createLinksFromSeq(seq, linkset);
+ if (sf.getFeatureGroup() != null)
+ {
+ tooltip = tooltip + (" (" + sf.getFeatureGroup() + ")");
+ }
+ JMenuItem item = new JMenuItem(desc);
+ item.setToolTipText(tooltip);
+ item.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ showFeatureDetails(sf);
+ }
+ });
+ details.add(item);
}
+ }
- addshowLinks(linkMenu, linkset.values());
+ /**
+ * Opens a panel showing a text report of feature dteails
+ *
+ * @param sf
+ */
+ protected void showFeatureDetails(SequenceFeature sf)
+ {
+ CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
+ // it appears Java's CSS does not support border-collaps :-(
+ cap.addStylesheetRule("table { border-collapse: collapse;}");
+ cap.addStylesheetRule("table, td, th {border: 1px solid black;}");
+ cap.setText(sf.getDetailsReport());
- // disable link menu if there are no valid entries
- if (linkMenu.getItemCount() > 0)
- {
- linkMenu.setEnabled(true);
- }
- else
- {
- linkMenu.setEnabled(false);
- }
+ Desktop.addInternalFrame(cap,
+ MessageManager.getString("label.feature_details"), 500, 500);
+ }
- if (sequence != null)
- {
- sequenceMenu.add(linkMenu);
- }
- else
+ /**
+ * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
+ * When seq is not null, these are links for the sequence id, which may be to
+ * external web sites for the sequence accession, and/or links embedded in
+ * non-positional features. When seq is null, only links embedded in the
+ * provided features are added. If no links are found, the menu is not added.
+ *
+ * @param seq
+ * @param features
+ */
+ void addLinks(final SequenceI seq, List features)
+ {
+ JMenu linkMenu = buildLinkMenu(seq, features);
+
+ // only add link menu if it has entries
+ if (linkMenu.getItemCount() > 0)
{
- add(linkMenu);
+ if (sequence != null)
+ {
+ sequenceMenu.add(linkMenu);
+ }
+ else
+ {
+ add(linkMenu);
+ }
}
-
}
/**
@@ -626,7 +847,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
final List all = Arrays
.asList(new String[]
- { MessageManager.getString("label.all") });
+ { MessageManager.getString("label.all") });
addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true,
true);
addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
@@ -855,8 +1076,10 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
int type = urlLink.getGroupURLType() & 3;
// first two bits ofurlLink type bitfield are sequenceids and sequences
// TODO: FUTURE: ensure the groupURL menu structure can be generalised
- addshowLink(linkMenus[type], label + (((type & 1) == 1)
- ? ("(" + (usingNames ? "Names" : ltarget) + ")") : ""),
+ addshowLink(linkMenus[type],
+ label + (((type & 1) == 1)
+ ? ("(" + (usingNames ? "Names" : ltarget) + ")")
+ : ""),
urlLink, urlset);
addMenu = true;
}
@@ -878,99 +1101,6 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
}
- private void addshowLinks(JMenu linkMenu,
- Collection> linkset)
- {
- for (List linkstrset : linkset)
- {
- // split linkstr into label and url
- addshowLink(linkMenu, linkstrset.get(1), linkstrset.get(3));
- }
- }
-
- /**
- * add a show URL menu item to the given linkMenu
- *
- * @param linkMenu
- * @param label
- * - menu label string
- * @param url
- * - url to open
- */
- private void addshowLink(JMenu linkMenu, String label, final String url)
- {
- JMenuItem item = new JMenuItem(label);
- item.setToolTipText(MessageManager.formatMessage("label.open_url_param",
- new Object[]
- { url }));
- item.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- new Thread(new Runnable()
- {
-
- @Override
- public void run()
- {
- showLink(url);
- }
-
- }).start();
- }
- });
-
- linkMenu.add(item);
- }
-
- /**
- * add a late bound groupURL item to the given linkMenu
- *
- * @param linkMenu
- * @param label
- * - menu label string
- * @param urlgenerator
- * GroupURLLink used to generate URL
- * @param urlstub
- * Object array returned from the makeUrlStubs function.
- */
- private void addshowLink(JMenu linkMenu, String label,
- final GroupUrlLink urlgenerator, final Object[] urlstub)
- {
- JMenuItem item = new JMenuItem(label);
- item.setToolTipText(
- MessageManager.formatMessage("label.open_url_seqs_param",
- new Object[]
- { urlgenerator.getUrl_prefix(),
- urlgenerator.getNumberInvolved(urlstub) }));
- // TODO: put in info about what is being sent.
- item.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- new Thread(new Runnable()
- {
-
- @Override
- public void run()
- {
- try
- {
- showLink(urlgenerator.constructFrom(urlstub));
- } catch (UrlStringTooLongException e2)
- {
- }
- }
-
- }).start();
- }
- });
-
- linkMenu.add(item);
- }
-
/**
* DOCUMENT ME!
*
@@ -1167,15 +1297,6 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
sequenceFeature_actionPerformed();
}
});
- hmmBuildGroup.setText(MessageManager.getString("label.group_hmmbuild"));
- hmmBuildGroup.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- hmmBuildGroup_actionPerformed();
- }
- });
jMenu1.setText(MessageManager.getString("label.group"));
pdbStructureDialog.setText(
MessageManager.getString("label.show_pdbstruct_dialog"));
@@ -1285,26 +1406,6 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
jMenu1.add(displayNonconserved);
}
- protected void hmmBuildGroup_actionPerformed()
- {
- new Thread(new HMMBuildThread(ap.alignFrame)).start();
- ap.repaint();
-
- }
-
- protected void selectHMM_actionPerformed(ActionEvent e)
- {
- HiddenMarkovModel hmm = ap.av.getSequenceSelection()[0].getHMM();
- ap.alignFrame.setSelectedHMM(hmm);
- }
-
- protected void hmmAlign_actionPerformed(ActionEvent e)
- {
- ap.alignFrame.setSelectedHMM(this.sequence.getHMM());
- new Thread(new HMMAlignThread(ap.alignFrame, true)).start();
- ap.repaint();
- }
-
/**
* Constructs the entries for the colour menu
*/
@@ -1355,6 +1456,13 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
});
+ annotationColour = new JRadioButtonMenuItem(
+ MessageManager.getString("action.by_annotation"));
+ annotationColour.setName(ResidueColourScheme.ANNOTATION_COLOUR);
+ annotationColour.setEnabled(false);
+ annotationColour.setToolTipText(
+ MessageManager.getString("label.by_annotation_tooltip"));
+
modifyConservation.setText(MessageManager
.getString("label.modify_conservation_threshold"));
modifyConservation.addActionListener(new ActionListener()
@@ -1385,7 +1493,10 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
colourMenu.add(textColour);
colourMenu.addSeparator();
- ColourMenuHelper.addMenuItems(colourMenu, this, sg, false);
+ ButtonGroup bg = ColourMenuHelper.addMenuItems(colourMenu, this, sg,
+ false);
+ bg.add(annotationColour);
+ colourMenu.add(annotationColour);
colourMenu.addSeparator();
colourMenu.add(conservationMenuItem);
@@ -1515,23 +1626,37 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
{
- if (sequence != null)
+ HiddenColumns hidden = ap.av.getAlignment().getHiddenColumns();
+ BitSet inserts = new BitSet();
+
+ boolean markedPopup = false;
+ // mark inserts in current selection
+ if (ap.av.getSelectionGroup() != null)
{
- /* ColumnSelection cs = ap.av.getColumnSelection();
- if (cs == null)
- {
- cs = new ColumnSelection();
- }
- cs.hideInsertionsFor(sequence);
- ap.av.setColumnSelection(cs);*/
+ // mark just the columns in the selection group to be hidden
+ inserts.set(ap.av.getSelectionGroup().getStartRes(),
+ ap.av.getSelectionGroup().getEndRes() + 1); // TODO why +1?
- HiddenColumns hidden = ap.av.getAlignment().getHiddenColumns();
- if (hidden == null)
+ // now clear columns without gaps
+ for (SequenceI sq : ap.av.getSelectionGroup().getSequences())
{
- hidden = new HiddenColumns();
+ if (sq == sequence)
+ {
+ markedPopup = true;
+ }
+ inserts.and(sq.getInsertionsAsBits());
}
- hidden.hideInsertionsFor(sequence);
- ap.av.getAlignment().setHiddenColumns(hidden);
+ hidden.clearAndHideColumns(inserts, ap.av.getSelectionGroup().getStartRes(),
+ ap.av.getSelectionGroup().getEndRes());
+ }
+
+ // now mark for sequence under popup if we haven't already done it
+ else if (!markedPopup && sequence != null)
+ {
+ inserts.or(sequence.getInsertionsAsBits());
+
+ // and set hidden columns accordingly
+ hidden.hideColumns(inserts);
}
refresh();
}
@@ -1552,28 +1677,24 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
StringBuilder contents = new StringBuilder(128);
for (SequenceI seq : sequences)
{
- contents.append(""
- + MessageManager.formatMessage(
- "label.create_sequence_details_report_annotation_for",
- new Object[]
- { seq.getDisplayId(true) })
- + "
");
- new SequenceAnnotationReport(null)
- .createSequenceAnnotationReport(contents, seq, true, true,
- (ap.getSeqPanel().seqCanvas.fr != null)
- ? ap.getSeqPanel().seqCanvas.fr.getMinMax()
- : null);
+ contents.append("
" + MessageManager.formatMessage(
+ "label.create_sequence_details_report_annotation_for",
+ new Object[]
+ { seq.getDisplayId(true) }) + "
");
+ new SequenceAnnotationReport(null).createSequenceAnnotationReport(
+ contents, seq, true, true, ap.getSeqPanel().seqCanvas.fr);
contents.append("
");
}
cap.setText("" + contents.toString() + "");
- Desktop.addInternalFrame(cap, MessageManager.formatMessage(
- "label.sequence_details_for",
- (sequences.length == 1
- ? new Object[]
+ Desktop.addInternalFrame(cap,
+ MessageManager.formatMessage("label.sequence_details_for",
+ (sequences.length == 1 ? new Object[]
{ sequences[0].getDisplayId(true) }
- : new Object[]
- { MessageManager.getString("label.selection") })), 500, 400);
+ : new Object[]
+ { MessageManager
+ .getString("label.selection") })),
+ 500, 400);
}
@@ -1589,7 +1710,9 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
void refresh()
{
ap.updateAnnotation();
- ap.paintAlignment(true);
+ // removed paintAlignment(true) here:
+ // updateAnnotation calls paintAlignment already, so don't need to call
+ // again
PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
}
@@ -1747,8 +1870,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
" " + MessageManager.getString("label.sequence_name")
+ " ",
MessageManager.getString("label.sequence_description") + " ",
- MessageManager
- .getString("label.edit_sequence_name_description"),
+ MessageManager.getString(
+ "label.edit_sequence_name_description"),
ap.alignFrame);
if (!dialog.accept)
@@ -1769,7 +1892,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
sequence.setName(dialog.getName().replace(' ', '_'));
- ap.paintAlignment(false);
+ ap.paintAlignment(false, false);
}
sequence.setDescription(dialog.getDescription());
@@ -1857,22 +1980,6 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
refresh();
}
- public void showLink(String url)
- {
- try
- {
- jalview.util.BrowserLauncher.openURL(url);
- } catch (Exception ex)
- {
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.getString("label.web_browser_not_found_unix"),
- MessageManager.getString("label.web_browser_not_found"),
- JvOptionPane.WARNING_MESSAGE);
-
- ex.printStackTrace();
- }
- }
-
void hideSequences(boolean representGroup)
{
ap.av.hideSequences(sequence, representGroup);
@@ -1933,9 +2040,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
cap.setForInput(null);
- Desktop.addInternalFrame(cap,
- MessageManager.formatMessage("label.alignment_output_command",
- new Object[]
+ Desktop.addInternalFrame(cap, MessageManager
+ .formatMessage("label.alignment_output_command", new Object[]
{ e.getActionCommand() }), 600, 500);
String[] omitHidden = null;
@@ -1973,16 +2079,22 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
if (start <= end)
{
seqs.add(sg.getSequenceAt(i).getDatasetSequence());
- features.add(
- new SequenceFeature(null, null, null, start, end, null));
+ features.add(new SequenceFeature(null, null, start, end, null));
}
}
- if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
- features, true, ap))
+ /*
+ * an entirely gapped region will generate empty lists of sequence / features
+ */
+ if (!seqs.isEmpty())
{
- ap.alignFrame.setShowSeqFeatures(true);
- ap.highlightSearchResults(null);
+ if (ap.getSeqPanel().seqCanvas.getFeatureRenderer()
+ .amendFeatures(seqs, features, true, ap))
+ {
+ ap.alignFrame.setShowSeqFeatures(true);
+ ap.av.setSearchResults(null); // clear highlighting
+ ap.repaint(); // draw new/amended features
+ }
}
}
@@ -2063,7 +2175,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
* switch to the chosen colour scheme (or null for None)
*/
ColourSchemeI colourScheme = ColourSchemes.getInstance()
- .getColourScheme(colourSchemeName, sg,
+ .getColourScheme(colourSchemeName, ap.av, sg,
ap.av.getHiddenRepSequences());
sg.setColourScheme(colourScheme);
if (colourScheme instanceof Blosum62ColourScheme