X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FPopupMenu.java;h=846ba6447d583209193997b08639755b3da5a850;hb=90ae01c1c1504e0ae42817f78116f1d35b317c47;hp=c94d24dc3298882107d89c1ce06d3a98a70c1d6c;hpb=424f6f03e8fb5e40cceca09fc8ffd72b41e3a9e4;p=jalview.git
diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java
index c94d24d..846ba64 100644
--- a/src/jalview/gui/PopupMenu.java
+++ b/src/jalview/gui/PopupMenu.java
@@ -31,8 +31,8 @@ import jalview.commands.EditCommand.Action;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
-import jalview.datamodel.ColumnSelection;
import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
@@ -43,12 +43,10 @@ import jalview.io.FileFormatI;
import jalview.io.FileFormats;
import jalview.io.FormatAdapter;
import jalview.io.SequenceAnnotationReport;
-import jalview.schemes.AnnotationColourGradient;
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;
@@ -57,7 +55,9 @@ import jalview.util.UrlLink;
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;
@@ -180,7 +180,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
* @param seq
* DOCUMENT ME!
*/
- public PopupMenu(final AlignmentPanel ap, Sequence seq, List links)
+ public PopupMenu(final AlignmentPanel ap, Sequence seq,
+ List links)
{
this(ap, seq, links, null);
}
@@ -225,8 +226,9 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
* 'reference annotations' that may be added to the alignment. First for the
* currently selected sequence (if there is one):
*/
- final List selectedSequence = (seq == null ? Collections
- . emptyList() : Arrays.asList(seq));
+ final List selectedSequence = (seq == null
+ ? Collections. emptyList()
+ : Arrays.asList(seq));
buildAnnotationTypesMenus(seqShowAnnotationsMenu,
seqHideAnnotationsMenu, selectedSequence);
configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
@@ -235,9 +237,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 ? Collections
- . emptyList() : ap.av.getSelectionGroup()
- .getSequences());
+ final List selectedGroup = (ap.av.getSelectionGroup() == null
+ ? Collections. emptyList()
+ : ap.av.getSelectionGroup().getSequences());
buildAnnotationTypesMenus(groupShowAnnotationsMenu,
groupHideAnnotationsMenu, selectedGroup);
configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
@@ -257,13 +259,13 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
sequenceMenu.setText(sequence.getName());
if (seq == ap.av.getAlignment().getSeqrep())
{
- makeReferenceSeq.setText(MessageManager
- .getString("action.unmark_as_reference"));
+ makeReferenceSeq.setText(
+ MessageManager.getString("action.unmark_as_reference"));
}
else
{
- makeReferenceSeq.setText(MessageManager
- .getString("action.set_as_reference"));
+ makeReferenceSeq.setText(
+ MessageManager.getString("action.set_as_reference"));
}
if (!ap.av.getAlignment().isNucleotide())
@@ -290,8 +292,8 @@ 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
@@ -318,8 +320,8 @@ 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
@@ -354,9 +356,9 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
if (ap.av.getSelectionGroup() != null
&& ap.av.getSelectionGroup().getSize() > 1)
{
- menuItem = new JMenuItem(MessageManager.formatMessage(
- "label.represent_group_with",
- new Object[] { seq.getName() }));
+ menuItem = new JMenuItem(MessageManager
+ .formatMessage("label.represent_group_with", new Object[]
+ { seq.getName() }));
menuItem.addActionListener(new ActionListener()
{
@Override
@@ -414,12 +416,12 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
add(menuItem);
}
-
}
SequenceGroup sg = ap.av.getSelectionGroup();
- boolean isDefinedGroup = (sg != null) ? ap.av.getAlignment()
- .getGroups().contains(sg) : false;
+ boolean isDefinedGroup = (sg != null)
+ ? ap.av.getAlignment().getGroups().contains(sg)
+ : false;
if (sg != null && sg.getSize() > 0)
{
@@ -428,6 +430,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
ColourMenuHelper.setColourSelected(colourMenu, sg.getColourScheme());
+ conservationMenuItem.setEnabled(!sg.isNucleotide());
+
if (sg.cs != null)
{
if (sg.cs.conservationApplied())
@@ -451,7 +455,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 : ap.av.getSequenceSelection())
{
@@ -471,9 +476,9 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
if (pdbe.size() > 0)
{
- final PDBEntry[] pe = pdbe.values().toArray(
- new PDBEntry[pdbe.size()]), pr = reppdb.values().toArray(
- new PDBEntry[reppdb.size()]);
+ final PDBEntry[] pe = pdbe.values()
+ .toArray(new PDBEntry[pdbe.size()]),
+ pr = reppdb.values().toArray(new PDBEntry[reppdb.size()]);
final JMenuItem gpdbview, rpdbview;
}
}
@@ -518,7 +523,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
void addFeatureLinks(final SequenceI seq, List links)
{
JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
- Map> linkset = new LinkedHashMap>();
+ Map> linkset = new LinkedHashMap<>();
for (String link : links)
{
@@ -585,9 +590,11 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
showMenu.removeAll();
hideMenu.removeAll();
- final List all = Arrays.asList(new String[] { MessageManager
- .getString("label.all") });
- addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true, true);
+ final List all = Arrays
+ .asList(new String[]
+ { MessageManager.getString("label.all") });
+ addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true,
+ true);
addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
false);
showMenu.addSeparator();
@@ -602,8 +609,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
* the insertion order, which is the order of the annotations on the
* alignment.
*/
- Map>> shownTypes = new LinkedHashMap>>();
- Map>> hiddenTypes = new LinkedHashMap>>();
+ Map>> shownTypes = new LinkedHashMap<>();
+ Map>> hiddenTypes = new LinkedHashMap<>();
AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes, hiddenTypes,
AlignmentAnnotationUtils.asList(annotations), forSequences);
@@ -709,12 +716,12 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
String[][] idandseqs = GroupUrlLink.formStrings(seqs);
- Hashtable commonDbrefs = new Hashtable();
+ Hashtable commonDbrefs = new Hashtable<>();
for (int sq = 0; sq < seqs.length; sq++)
{
- int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
- .findPosition(sg.getEndRes());
+ int start = seqs[sq].findPosition(sg.getStartRes()),
+ end = seqs[sq].findPosition(sg.getEndRes());
// just collect ids from dataset sequence
// TODO: check if IDs collected from selecton group intersects with the
// current selection, too
@@ -741,8 +748,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
if (((String[]) sarray[1])[sq] == null)
{
- if (!dbr[d].hasMap()
- || (dbr[d].getMap().locateMappedRange(start, end) != null))
+ if (!dbr[d].hasMap() || (dbr[d].getMap()
+ .locateMappedRange(start, end) != null))
{
((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
((int[]) sarray[0])[0]++;
@@ -814,9 +821,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;
}
@@ -838,7 +846,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
}
- private void addshowLinks(JMenu linkMenu, Collection> linkset)
+ private void addshowLinks(JMenu linkMenu,
+ Collection> linkset)
{
for (List linkstrset : linkset)
{
@@ -859,8 +868,9 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
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.setToolTipText(MessageManager.formatMessage("label.open_url_param",
+ new Object[]
+ { url }));
item.addActionListener(new ActionListener()
{
@Override
@@ -897,9 +907,9 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
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(),
+ 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()
@@ -947,8 +957,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
});
sequenceMenu.setText(MessageManager.getString("label.sequence"));
- sequenceName.setText(MessageManager
- .getString("label.edit_name_description"));
+ sequenceName.setText(
+ MessageManager.getString("label.edit_name_description"));
sequenceName.addActionListener(new ActionListener()
{
@Override
@@ -957,8 +967,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
sequenceName_actionPerformed();
}
});
- chooseAnnotations.setText(MessageManager
- .getString("action.choose_annotations"));
+ chooseAnnotations
+ .setText(MessageManager.getString("action.choose_annotations"));
chooseAnnotations.addActionListener(new ActionListener()
{
@Override
@@ -967,8 +977,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
chooseAnnotations_actionPerformed(e);
}
});
- sequenceDetails.setText(MessageManager
- .getString("label.sequence_details"));
+ sequenceDetails
+ .setText(MessageManager.getString("label.sequence_details"));
sequenceDetails.addActionListener(new ActionListener()
{
@Override
@@ -977,8 +987,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
sequenceDetails_actionPerformed();
}
});
- sequenceSelDetails.setText(MessageManager
- .getString("label.sequence_details"));
+ sequenceSelDetails
+ .setText(MessageManager.getString("label.sequence_details"));
sequenceSelDetails.addActionListener(new ActionListener()
{
@Override
@@ -998,8 +1008,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
unGroupMenuItem_actionPerformed();
}
});
- createGroupMenuItem.setText(MessageManager
- .getString("action.create_group"));
+ createGroupMenuItem
+ .setText(MessageManager.getString("action.create_group"));
createGroupMenuItem.addActionListener(new ActionListener()
{
@Override
@@ -1047,8 +1057,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
showColourText_actionPerformed();
}
});
- displayNonconserved.setText(MessageManager
- .getString("label.show_non_conserved"));
+ displayNonconserved
+ .setText(MessageManager.getString("label.show_non_conserved"));
displayNonconserved.setState(true);
displayNonconserved.addActionListener(new ActionListener()
{
@@ -1104,18 +1114,18 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
changeCase(e);
}
});
- outputMenu.setText(MessageManager.getString("label.out_to_textbox")
- + "...");
- seqShowAnnotationsMenu.setText(MessageManager
- .getString("label.show_annotations"));
- seqHideAnnotationsMenu.setText(MessageManager
- .getString("label.hide_annotations"));
- groupShowAnnotationsMenu.setText(MessageManager
- .getString("label.show_annotations"));
- groupHideAnnotationsMenu.setText(MessageManager
- .getString("label.hide_annotations"));
- sequenceFeature.setText(MessageManager
- .getString("label.create_sequence_feature"));
+ outputMenu.setText(
+ MessageManager.getString("label.out_to_textbox") + "...");
+ seqShowAnnotationsMenu
+ .setText(MessageManager.getString("label.show_annotations"));
+ seqHideAnnotationsMenu
+ .setText(MessageManager.getString("label.hide_annotations"));
+ groupShowAnnotationsMenu
+ .setText(MessageManager.getString("label.show_annotations"));
+ groupHideAnnotationsMenu
+ .setText(MessageManager.getString("label.hide_annotations"));
+ sequenceFeature.setText(
+ MessageManager.getString("label.create_sequence_feature"));
sequenceFeature.addActionListener(new ActionListener()
{
@Override
@@ -1125,8 +1135,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
});
jMenu1.setText(MessageManager.getString("label.group"));
- pdbStructureDialog.setText(MessageManager
- .getString("label.show_pdbstruct_dialog"));
+ pdbStructureDialog.setText(
+ MessageManager.getString("label.show_pdbstruct_dialog"));
pdbStructureDialog.addActionListener(new ActionListener()
{
@Override
@@ -1141,12 +1151,12 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
});
- rnaStructureMenu.setText(MessageManager
- .getString("label.view_rna_structure"));
+ rnaStructureMenu
+ .setText(MessageManager.getString("label.view_rna_structure"));
// colStructureMenu.setText("Colour By Structure");
- editSequence.setText(MessageManager.getString("label.edit_sequence")
- + "...");
+ editSequence.setText(
+ MessageManager.getString("label.edit_sequence") + "...");
editSequence.addActionListener(new ActionListener()
{
@Override
@@ -1155,8 +1165,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
editSequence_actionPerformed(actionEvent);
}
});
- makeReferenceSeq.setText(MessageManager
- .getString("label.mark_as_representative"));
+ makeReferenceSeq.setText(
+ MessageManager.getString("label.mark_as_representative"));
makeReferenceSeq.addActionListener(new ActionListener()
{
@@ -1167,8 +1177,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
});
- hideInsertions.setText(MessageManager
- .getString("label.hide_insertions"));
+ hideInsertions
+ .setText(MessageManager.getString("label.hide_insertions"));
hideInsertions.addActionListener(new ActionListener()
{
@@ -1178,12 +1188,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
hideInsertions_actionPerformed(e);
}
});
- /*
- * annotationMenuItem.setText("By Annotation");
- * annotationMenuItem.addActionListener(new ActionListener() { public void
- * actionPerformed(ActionEvent actionEvent) {
- * annotationMenuItem_actionPerformed(actionEvent); } });
- */
+
groupMenu.add(sequenceSelDetails);
add(groupMenu);
add(sequenceMenu);
@@ -1237,7 +1242,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
jMenu1.add(outline);
jMenu1.add(displayNonconserved);
}
-
+
/**
* Constructs the entries for the colour menu
*/
@@ -1254,8 +1259,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
});
- abovePIDColour.setText(MessageManager
- .getString("label.above_identity_threshold"));
+ abovePIDColour.setText(
+ MessageManager.getString("label.above_identity_threshold"));
abovePIDColour.addActionListener(new ActionListener()
{
@Override
@@ -1265,8 +1270,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
});
- modifyPID.setText(MessageManager
- .getString("label.modify_identity_threshold"));
+ modifyPID.setText(
+ MessageManager.getString("label.modify_identity_threshold"));
modifyPID.addActionListener(new ActionListener()
{
@Override
@@ -1276,15 +1281,15 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
}
});
- conservationMenuItem.setText(MessageManager
- .getString("action.by_conservation"));
+ conservationMenuItem
+ .setText(MessageManager.getString("action.by_conservation"));
conservationMenuItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- conservationMenuItem_actionPerformed(conservationMenuItem
- .isSelected());
+ conservationMenuItem_actionPerformed(
+ conservationMenuItem.isSelected());
}
});
@@ -1345,8 +1350,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
// int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
// .getName());
// sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
- SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
- .getName());
+ SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup().getName());
SliderPanel.showPIDSlider();
}
}
@@ -1373,11 +1377,11 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
* Temporary store to hold distinct calcId / type pairs for the tooltip.
* Using TreeMap means calcIds are shown in alphabetical order.
*/
- SortedMap tipEntries = new TreeMap();
- final Map> candidates = new LinkedHashMap>();
+ SortedMap tipEntries = new TreeMap<>();
+ final Map> candidates = new LinkedHashMap<>();
AlignmentI al = this.ap.av.getAlignment();
- AlignmentUtils.findAddableReferenceAnnotations(forSequences,
- tipEntries, candidates, al);
+ AlignmentUtils.findAddableReferenceAnnotations(forSequences, tipEntries,
+ candidates, al);
if (!candidates.isEmpty())
{
StringBuilder tooltip = new StringBuilder(64);
@@ -1449,16 +1453,59 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
{
- if (sequence != null)
+
+ HiddenColumns hidden = new HiddenColumns();
+ BitSet inserts = new BitSet(), mask = new BitSet();
+
+ // set mask to preserve existing hidden columns outside selected group
+ if (ap.av.hasHiddenColumns())
+ {
+ ap.av.getAlignment().getHiddenColumns().markHiddenRegions(mask);
+ }
+
+ boolean markedPopup = false;
+ // mark inserts in current selection
+ if (ap.av.getSelectionGroup() != null)
{
- ColumnSelection cs = ap.av.getColumnSelection();
- if (cs == null)
+ // mark just the columns in the selection group to be hidden
+ inserts.set(ap.av.getSelectionGroup().getStartRes(),
+ ap.av.getSelectionGroup().getEndRes() + 1);
+
+ // and clear that part of the mask
+ mask.andNot(inserts);
+
+ // now clear columns without gaps
+ for (SequenceI sq : ap.av.getSelectionGroup().getSequences())
{
- cs = new ColumnSelection();
+ if (sq == sequence)
+ {
+ markedPopup = true;
+ }
+ inserts.and(sq.getInsertionsAsBits());
}
- cs.hideInsertionsFor(sequence);
- ap.av.setColumnSelection(cs);
}
+ else
+ {
+ // initially, mark all columns to be hidden
+ inserts.set(0, ap.av.getAlignment().getWidth());
+
+ // and clear out old hidden regions completely
+ mask.clear();
+ }
+
+ // now mark for sequence under popup if we haven't already done it
+ if (!markedPopup && sequence != null)
+ {
+ inserts.and(sequence.getInsertionsAsBits());
+ }
+
+ // finally, preserve hidden regions outside selection
+ inserts.or(mask);
+
+ // and set hidden columns accordingly
+ hidden.hideMarkedBits(inserts);
+
+ ap.av.getAlignment().setHiddenColumns(hidden);
refresh();
}
@@ -1478,30 +1525,27 @@ 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 != null)
+ ? ap.getSeqPanel().seqCanvas.fr.getMinMax()
+ : null);
contents.append("
");
}
cap.setText("" + contents.toString() + "");
- 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);
+ 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);
}
@@ -1517,7 +1561,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());
}
@@ -1549,8 +1595,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
sg.getStartRes(), sg.getEndRes() + 1));
int threshold = SliderPanel.setPIDSliderSource(ap,
- sg.getGroupColourScheme(), getGroup()
- .getName());
+ sg.getGroupColourScheme(), getGroup().getName());
sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
@@ -1596,9 +1641,9 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
if (selected)
{
// JBPNote: Conservation name shouldn't be i18n translated
- Conservation c = new Conservation("Group", sg.getSequences(ap.av
- .getHiddenRepSequences()), sg.getStartRes(),
- sg.getEndRes() + 1);
+ Conservation c = new Conservation("Group",
+ sg.getSequences(ap.av.getHiddenRepSequences()),
+ sg.getStartRes(), sg.getEndRes() + 1);
c.calculate();
c.verdict(false, ap.av.getConsPercGaps());
@@ -1619,24 +1664,6 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
refresh();
}
- public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
- {
- SequenceGroup sg = getGroup();
- if (sg == null)
- {
- return;
- }
-
- AnnotationColourGradient acg = new AnnotationColourGradient(
- sequence.getAnnotation()[0], null,
- AnnotationColourGradient.NO_THRESHOLD);
-
- acg.setPredefinedColours(true);
- sg.setColourScheme(acg);
-
- refresh();
- }
-
/**
* DOCUMENT ME!
*
@@ -1648,8 +1675,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
SequenceGroup sg = getGroup();
EditNameDialog dialog = new EditNameDialog(sg.getName(),
- sg.getDescription(), " "
- + MessageManager.getString("label.group_name") + " ",
+ sg.getDescription(),
+ " " + MessageManager.getString("label.group_name") + " ",
MessageManager.getString("label.group_description") + " ",
MessageManager.getString("label.edit_group_name_description"),
ap.alignFrame);
@@ -1694,8 +1721,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)
@@ -1707,14 +1734,12 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
{
if (dialog.getName().indexOf(" ") > -1)
{
- JvOptionPane
- .showMessageDialog(
- ap,
- MessageManager
- .getString("label.spaces_converted_to_backslashes"),
- MessageManager
- .getString("label.no_spaces_allowed_sequence_name"),
- JvOptionPane.WARNING_MESSAGE);
+ JvOptionPane.showMessageDialog(ap,
+ MessageManager
+ .getString("label.spaces_converted_to_backslashes"),
+ MessageManager
+ .getString("label.no_spaces_allowed_sequence_name"),
+ JvOptionPane.WARNING_MESSAGE);
}
sequence.setName(dialog.getName().replace(' ', '_'));
@@ -1723,8 +1748,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
sequence.setDescription(dialog.getDescription());
- ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
- .getSequences());
+ ap.av.firePropertyChange("alignment", null,
+ ap.av.getAlignment().getSequences());
}
@@ -1872,8 +1897,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
ap.alignFrame.addHistoryItem(caseCommand);
- ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
- .getSequences());
+ ap.av.firePropertyChange("alignment", null,
+ ap.av.getAlignment().getSequences());
}
}
@@ -1882,9 +1907,9 @@ 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[] { e.getActionCommand() }), 600, 500);
+ Desktop.addInternalFrame(cap, MessageManager
+ .formatMessage("label.alignment_output_command", new Object[]
+ { e.getActionCommand() }), 600, 500);
String[] omitHidden = null;
@@ -1892,8 +1917,10 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
// or we simply trust the user wants
// wysiwig behaviour
- FileFormatI fileFormat = FileFormats.getInstance().forName(e.getActionCommand());
- cap.setText(new FormatAdapter(ap).formatSequences(fileFormat, ap, true));
+ FileFormatI fileFormat = FileFormats.getInstance()
+ .forName(e.getActionCommand());
+ cap.setText(
+ new FormatAdapter(ap).formatSequences(fileFormat, ap, true));
}
public void sequenceFeature_actionPerformed()
@@ -1904,33 +1931,37 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
return;
}
- int rsize = 0, gSize = sg.getSize();
- SequenceI[] rseqs, seqs = new SequenceI[gSize];
- SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
+ List seqs = new ArrayList<>();
+ List features = new ArrayList<>();
+ /*
+ * assemble dataset sequences, and template new sequence features,
+ * for the amend features dialog
+ */
+ int gSize = sg.getSize();
for (int i = 0; i < gSize; i++)
{
int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
int end = sg.findEndRes(sg.getSequenceAt(i));
if (start <= end)
{
- seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
- features[rsize] = new SequenceFeature(null, null, null, start, end,
- "Jalview");
- rsize++;
+ seqs.add(sg.getSequenceAt(i).getDatasetSequence());
+ features.add(new SequenceFeature(null, null, start, end, null));
}
}
- rseqs = new SequenceI[rsize];
- tfeatures = new SequenceFeature[rsize];
- System.arraycopy(seqs, 0, rseqs, 0, rsize);
- System.arraycopy(features, 0, tfeatures, 0, rsize);
- features = tfeatures;
- seqs = rseqs;
- if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
- features, true, ap))
- {
- ap.alignFrame.setShowSeqFeatures(true);
- ap.highlightSearchResults(null);
+
+ /*
+ * an entirely gapped region will generate empty lists of sequence / features
+ */
+ if (!seqs.isEmpty())
+ {
+ 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
+ }
}
}
@@ -1975,8 +2006,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
EditNameDialog dialog = new EditNameDialog(
sequence.getSequenceAsString(sg.getStartRes(),
- sg.getEndRes() + 1), null,
- MessageManager.getString("label.edit_sequence"), null,
+ sg.getEndRes() + 1),
+ null, MessageManager.getString("label.edit_sequence"), null,
MessageManager.getString("label.edit_sequence"),
ap.alignFrame);
@@ -1984,15 +2015,15 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
{
EditCommand editCommand = new EditCommand(
MessageManager.getString("label.edit_sequences"),
- Action.REPLACE, dialog.getName().replace(' ',
- ap.av.getGapCharacter()),
+ 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());
+ ap.av.firePropertyChange("alignment", null,
+ ap.av.getAlignment().getSequences());
}
}
}
@@ -2007,28 +2038,19 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
public void changeColour_actionPerformed(String colourSchemeName)
{
SequenceGroup sg = getGroup();
- if (ResidueColourScheme.USER_DEFINED.equals(colourSchemeName))
- {
- /*
- * open a panel to load or configure a user-defined colour scheme
- */
- new UserDefinedColours(ap, sg);
- }
- else
+ /*
+ * switch to the chosen colour scheme (or null for None)
+ */
+ ColourSchemeI colourScheme = ColourSchemes.getInstance()
+ .getColourScheme(colourSchemeName, sg,
+ ap.av.getHiddenRepSequences());
+ sg.setColourScheme(colourScheme);
+ if (colourScheme instanceof Blosum62ColourScheme
+ || colourScheme instanceof PIDColourScheme)
{
- /*
- * switch to the chosen colour scheme (or null for None)
- */
- ColourSchemeI colourScheme = ColourSchemes.getInstance().getColourScheme(
- colourSchemeName, sg, ap.av.getHiddenRepSequences());
- sg.setColourScheme(colourScheme);
- if (colourScheme instanceof Blosum62ColourScheme
- || colourScheme instanceof PIDColourScheme)
- {
- sg.cs.setConsensus(AAFrequency.calculate(
- sg.getSequences(ap.av.getHiddenRepSequences()),
- sg.getStartRes(), sg.getEndRes() + 1));
- }
+ sg.cs.setConsensus(AAFrequency.calculate(
+ sg.getSequences(ap.av.getHiddenRepSequences()),
+ sg.getStartRes(), sg.getEndRes() + 1));
}
refresh();