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;
*/
final List<SequenceI> selectedSequence = (seq == null
? Collections.<SequenceI> emptyList() : Arrays.asList(seq));
+
buildAnnotationTypesMenus(seqShowAnnotationsMenu,
seqHideAnnotationsMenu, selectedSequence);
configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
*/
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
// 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
if (ap.av.getSelectionGroup() != null
&& ap.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()
{
SequenceGroup sg = ap.av.getSelectionGroup();
boolean isDefinedGroup = (sg != null)
- ? ap.av.getAlignment().getGroups().contains(sg) : false;
+ ? ap.av.getAlignment().getGroups().contains(sg)
+ : false;
if (sg != null && sg.getSize() > 0)
{
final List<String> all = Arrays
.asList(new String[]
- { MessageManager.getString("label.all") });
+ { MessageManager.getString("label.all") });
addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true,
true);
addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
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;
}
JMenuItem item = new JMenuItem(label);
item.setToolTipText(MessageManager.formatMessage("label.open_url_param",
new Object[]
- { url }));
+ { url }));
item.addActionListener(new ActionListener()
{
@Override
final GroupUrlLink urlgenerator, final Object[] urlstub)
{
JMenuItem item = new JMenuItem(label);
- item.setToolTipText(
- MessageManager.formatMessage("label.open_url_seqs_param",
- new Object[]
+ item.setToolTipText(MessageManager
+ .formatMessage("label.open_url_seqs_param", new Object[]
{ urlgenerator.getUrl_prefix(),
- urlgenerator.getNumberInvolved(urlstub) }));
+ urlgenerator.getNumberInvolved(urlstub) }));
// TODO: put in info about what is being sent.
item.addActionListener(new ActionListener()
{
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)
- {
- 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);
+
+ // and clear that part of the mask
+ mask.andNot(inserts);
- 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);
}
+ 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();
}
StringBuilder contents = new StringBuilder(128);
for (SequenceI seq : sequences)
{
- 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(contents, seq, true, true,
- (ap.getSeqPanel().seqCanvas.fr != null)
- ? ap.getSeqPanel().seqCanvas.fr.getMinMax()
- : null);
+ 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(
+ contents, seq, true, true,
+ (ap.getSeqPanel().seqCanvas.fr != null)
+ ? ap.getSeqPanel().seqCanvas.fr.getMinMax()
+ : null);
contents.append("</p>");
}
cap.setText("<html>" + contents.toString() + "</html>");
- 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);
}
" " + 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)
{
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;
}
}
- 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.highlightSearchResults(null);
+ }
}
}