*/
package jalview.gui;
+import java.awt.BorderLayout;
+import java.awt.Color;
+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;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.Vector;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JScrollPane;
+
import jalview.analysis.AAFrequency;
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;
import jalview.util.UrlLink;
import jalview.viewmodel.seqfeatures.FeatureRendererModel;
-import java.awt.BorderLayout;
-import java.awt.Color;
-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;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.Vector;
-
-import javax.swing.ButtonGroup;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JInternalFrame;
-import javax.swing.JLabel;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.JScrollPane;
-
/**
* The popup menu that is displayed on right-click on a sequence id, or in the
* sequence alignment.
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;
}
}
/**
- * 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)
{
* 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<String> groupLinks)
* @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<String> groupLinks)
{
Objects.requireNonNull(seq);
/*
* And repeat for the current selection group (if there is one):
*/
- final List<SequenceI> selectedGroup = (alignPanel.av.getSelectionGroup() == null
- ? Collections.<SequenceI> emptyList()
- : alignPanel.av.getSelectionGroup().getSequences());
+ final List<SequenceI> selectedGroup = (alignPanel.av
+ .getSelectionGroup() == null
+ ? Collections.<SequenceI> emptyList()
+ : alignPanel.av.getSelectionGroup().getSequences());
buildAnnotationTypesMenus(groupShowAnnotationsMenu,
groupHideAnnotationsMenu, selectedGroup);
configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
buildGroupURLMenu(sg, groupLinks);
}
// Add a 'show all structures' for the current selection
- Hashtable<String, PDBEntry> pdbe = new Hashtable<>(), reppdb = new Hashtable<>();
+ Hashtable<String, PDBEntry> pdbe = new Hashtable<>(),
+ reppdb = new Hashtable<>();
SequenceI sqass = null;
for (SequenceI sq : alignPanel.av.getSequenceSelection())
{
createGroupMenuItem.setVisible(true);
unGroupMenuItem.setVisible(false);
- editGroupMenu.setText(MessageManager.getString("action.edit_new_group"));
+ editGroupMenu
+ .setText(MessageManager.getString("action.edit_new_group"));
}
else
{
* <li>positional feature links (alignment panel popup menu)</li>
* <li>feature details links (alignment panel popup menu)</li>
* </ul>
- * 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
}
/**
- * Add a link to show feature details for each sequence feature
+ * Add a menu item to show feature details for each sequence feature. Any
+ * linked 'virtual' features (CDS/protein) are also optionally found and
+ * included.
*
* @param features
- * @param column
* @param seq
+ * @param column
*/
protected void addFeatureDetails(List<SequenceFeature> features,
- SequenceI seq, int column)
+ final SequenceI seq, final int column)
{
/*
* add features in CDS/protein complement at the corresponding
String name = seq.getName();
for (final SequenceFeature sf : features)
{
- addFeatureDetailsMenuItem(details, name, sf);
+ addFeatureDetailsMenuItem(details, name, sf, null);
}
if (mf != null)
{
- name = mf.fromSeq == seq ? mf.mapping.getTo().getName()
- : mf.fromSeq.getName();
for (final SequenceFeature sf : mf.features)
{
- addFeatureDetailsMenuItem(details, name, sf);
+ addFeatureDetailsMenuItem(details, name, sf, mf);
}
}
}
/**
- * A helper method to add one menu item whose action is to show details for one
- * feature. The menu text includes feature description, but this may be
+ * A helper method to add one menu item whose action is to show details for
+ * one feature. The menu text includes feature description, but this may be
* truncated.
*
* @param details
* @param seqName
* @param sf
+ * @param mf
*/
void addFeatureDetailsMenuItem(JMenu details, final String seqName,
- final SequenceFeature sf)
+ final SequenceFeature sf, MappedFeatures mf)
{
int start = sf.getBegin();
int end = sf.getEnd();
+ if (mf != null)
+ {
+ /*
+ * show local rather than linked feature coordinates
+ */
+ 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));
if (start != end)
{
- desc.append("-").append(String.valueOf(end));
+ desc.append(sf.isContactFeature() ? ":" : "-");
+ desc.append(String.valueOf(end));
}
String description = sf.getDescription();
if (description != null)
@Override
public void actionPerformed(ActionEvent e)
{
- showFeatureDetails(seqName, sf);
+ showFeatureDetails(sf, seqName, mf);
}
});
details.add(item);
}
/**
- * Opens a panel showing a text report of feature dteails
- *
- * @param seqName
+ * Opens a panel showing a text report of feature details
*
* @param sf
+ * @param seqName
+ * @param mf
*/
- protected void showFeatureDetails(String seqName, SequenceFeature sf)
+ protected void showFeatureDetails(SequenceFeature sf, String seqName,
+ MappedFeatures mf)
{
JInternalFrame details;
if (Platform.isJS())
{
details = new JInternalFrame();
+ details.setFrameIcon(null);
JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(true);
panel.setBackground(Color.white);
// TODO JAL-3026 set style of table correctly for feature details
JLabel reprt = new JLabel(MessageManager
.formatMessage("label.html_content", new Object[]
- { sf.getDetailsReport(seqName) }));
+ { sf.getDetailsReport(seqName, mf) }));
reprt.setBackground(Color.WHITE);
reprt.setOpaque(true);
panel.add(reprt, BorderLayout.CENTER);
*/
{
CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
- // it appears Java's CSS does not support border-collaps :-(
+ // it appears Java's CSS does not support border-collapse :-(
cap.addStylesheetRule("table { border-collapse: collapse;}");
cap.addStylesheetRule("table, td, th {border: 1px solid black;}");
- cap.setText(sf.getDetailsReport(seqName));
+ cap.setText(sf.getDetailsReport(seqName, mf));
details = cap;
}
Desktop.addInternalFrame(details,
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)
{
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]++;
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)
{
protected void addReferenceAnnotations_actionPerformed(
Map<SequenceI, List<AlignmentAnnotation>> candidates)
{
- final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup();
final AlignmentI alignment = this.ap.getAlignment();
AlignmentUtils.addReferenceAnnotations(candidates, alignment,
- selectionGroup);
+ null);
refresh();
}
}
inserts.and(sq.getInsertionsAsBits());
}
- hidden.clearAndHideColumns(inserts, ap.av.getSelectionGroup().getStartRes(),
+ hidden.clearAndHideColumns(inserts,
+ ap.av.getSelectionGroup().getStartRes(),
ap.av.getSelectionGroup().getEndRes());
}
contents.append("<p><h2>" + MessageManager.formatMessage(
"label.create_sequence_details_report_annotation_for",
new Object[]
- { seq.getDisplayId(true) }) + "</h2></p><p>");
- new SequenceAnnotationReport(null).createSequenceAnnotationReport(
+ { seq.getDisplayId(true) }) + "</h2></p>\n<p>");
+ new SequenceAnnotationReport(false).createSequenceAnnotationReport(
contents, seq, true, true, ap.getSeqPanel().seqCanvas.fr);
contents.append("</p>");
}
pane.setBackground(Color.WHITE);
pane.add(textLabel, BorderLayout.NORTH);
frame = new JInternalFrame();
+ frame.setFrameIcon(null);
frame.getContentPane().add(new JScrollPane(pane));
}
else
MessageManager.getString("label.group_description"));
dialog.showDialog(ap.alignFrame,
MessageManager.getString("label.edit_group_name_description"),
- new Runnable()
- {
- @Override
- public void run()
- {
- sg.setName(dialog.getName());
- sg.setDescription(dialog.getDescription());
- refresh();
- }
+ () -> {
+ sg.setName(dialog.getName());
+ sg.setDescription(dialog.getDescription());
+ refresh();
});
}
/**
* 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()
{
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()
- {
- @Override
- public void run()
+ dialog.showDialog(ap.alignFrame, MessageManager
+ .getString("label.edit_sequence_name_description"), () -> {
+ if (dialog.getName() != null)
{
- if (dialog.getName() != null)
+ if (dialog.getName().indexOf(" ") > -1)
{
- if (dialog.getName().indexOf(" ") > -1)
- {
- JvOptionPane.showMessageDialog(ap,
- MessageManager.getString(
- "label.spaces_converted_to_underscores"),
- MessageManager.getString(
- "label.no_spaces_allowed_sequence_name"),
- JvOptionPane.WARNING_MESSAGE);
- }
- sequence.setName(dialog.getName().replace(' ', '_'));
- ap.paintAlignment(false, false);
+ String ok = MessageManager.getString("action.ok");
+ String cancel = MessageManager.getString("action.cancel");
+ String message = MessageManager.getString(
+ "label.spaces_converted_to_underscores");
+ String title = MessageManager.getString(
+ "label.no_spaces_allowed_sequence_name");
+ Object[] options = new Object[] { ok, cancel };
+
+ JvOptionPane.frameDialog(message, title,
+ JvOptionPane.WARNING_MESSAGE, null, null, null,
+ false);
}
- sequence.setDescription(dialog.getDescription());
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
+ sequence.setName(dialog.getName().replace(' ', '_'));
+ ap.paintAlignment(false, false);
}
+ sequence.setDescription(dialog.getDescription());
+ ap.av.firePropertyChange("alignment", null,
+ ap.av.getAlignment().getSequences());
});
}
*/
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
refresh();
}
};
- JalviewColourChooser.showColourChooser(Desktop.getDesktop(),
- title, Color.BLUE, listener);
+ JalviewColourChooser.showColourChooser(Desktop.getDesktop(), title,
+ Color.BLUE, listener);
}
/**
String[] omitHidden = null;
- System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
+ jalview.bin.Console.outPrintln("PROMPT USER HERE"); // TODO: decide if a prompt happens
// or we simply trust the user wants
// wysiwig behaviour
seq.getSequenceAsString(sg.getStartRes(), sg.getEndRes() + 1),
null, MessageManager.getString("label.edit_sequence"), null);
dialog.showDialog(ap.alignFrame,
- MessageManager.getString("label.edit_sequence"),
- new Runnable()
- {
- @Override
- public void run()
- {
- EditCommand editCommand = new EditCommand(
- MessageManager.getString("label.edit_sequences"),
- Action.REPLACE,
- dialog.getName().replace(' ',
- ap.av.getGapCharacter()),
- sg.getSequencesAsArray(
- ap.av.getHiddenRepSequences()),
- sg.getStartRes(), sg.getEndRes() + 1,
- ap.av.getAlignment());
- ap.alignFrame.addHistoryItem(editCommand);
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
- }
+ MessageManager.getString("label.edit_sequence"), () -> {
+ EditCommand editCommand = new EditCommand(
+ MessageManager.getString("label.edit_sequences"),
+ Action.REPLACE,
+ dialog.getName().replace(' ',
+ ap.av.getGapCharacter()),
+ sg.getSequencesAsArray(
+ ap.av.getHiddenRepSequences()),
+ sg.getStartRes(), sg.getEndRes() + 1,
+ ap.av.getAlignment());
+ ap.alignFrame.addHistoryItem(editCommand);
+ ap.av.firePropertyChange("alignment", null,
+ ap.av.getAlignment().getSequences());
});
}
}