import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.util.MessageManager;
AlignmentAnnotation[] aa = ap.av.getAlignment()
.getAlignmentAnnotation();
+ boolean fullRepaint = false;
if (evt.getActionCommand().equals(ADDNEW))
{
AlignmentAnnotation newAnnotation = new AlignmentAnnotation(null,
ap.av.getAlignment().addAnnotation(newAnnotation);
ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0);
+ fullRepaint = true;
}
else if (evt.getActionCommand().equals(EDITNAME))
{
+ String name = aa[selectedRow].label;
editLabelDescription(aa[selectedRow]);
- repaint();
+ if (!name.equalsIgnoreCase(aa[selectedRow].label))
+ {
+ fullRepaint = true;
+ }
}
else if (evt.getActionCommand().equals(HIDE))
{
else if (evt.getActionCommand().equals(DELETE))
{
ap.av.getAlignment().deleteAnnotation(aa[selectedRow]);
+ ap.av.getCalcManager().removeWorkerForAnnotation(aa[selectedRow]);
+ fullRepaint = true;
}
else if (evt.getActionCommand().equals(SHOWALL))
{
aa[i].visible = true;
}
}
+ fullRepaint = true;
}
else if (evt.getActionCommand().equals(OUTPUT_TEXT))
{
aa[selectedRow].scaleColLabel = !aa[selectedRow].scaleColLabel;
}
- refresh();
+ refresh(fullRepaint);
}
/**
* Redraw sensibly.
+ *
+ * @adjustHeight if true, try to recalculate panel height for visible
+ * annotations
*/
- protected void refresh()
+ protected void refresh(boolean adjustHeight)
{
- ap.validateAnnotationDimensions(false);
+ ap.validateAnnotationDimensions(adjustHeight);
ap.addNotify();
- ap.repaint();
+ if (adjustHeight)
+ {
+ // sort, repaint, update overview
+ ap.paintAlignment(true);
+ }
+ else
+ {
+ // lightweight repaint
+ ap.repaint();
+ }
}
/**
*/
boolean editLabelDescription(AlignmentAnnotation annotation)
{
+ // TODO i18n
EditNameDialog dialog = new EditNameDialog(annotation.label,
annotation.description, " Annotation Name ",
"Annotation Description ", "Edit Annotation Name/Description",
{
getSelectedRow(evt.getY() - getScrollOffset());
oldY = evt.getY();
- if (!evt.isPopupTrigger())
+ if (evt.isPopupTrigger())
{
- return;
+ showPopupMenu(evt);
}
+ }
+
+ /**
+ * Build and show the Pop-up menu at the right-click mouse position
+ *
+ * @param evt
+ */
+ void showPopupMenu(MouseEvent evt)
+ {
evt.consume();
- // handle popup menu event
final AlignmentAnnotation[] aa = ap.av.getAlignment()
.getAlignmentAnnotation();
// ann.visible = false;
// }
// }
- refresh();
+ refresh(true);
}
});
pop.add(hideType);
{
ap.av.setIgnoreGapsConsensus(cbmi.getState(), ap);
}
+ ap.alignmentChanged();
}
});
pop.add(cbmi);
}
}
pop.show(this, evt.getX(), evt.getY());
-
}
/**
@Override
public void mouseReleased(MouseEvent evt)
{
+ if (evt.isPopupTrigger())
+ {
+ showPopupMenu(evt);
+ return;
+ }
+
int start = selectedRow;
getSelectedRow(evt.getY() - getScrollOffset());
int end = selectedRow;
// todo: make the ap scroll to the selection - not necessary, first
// click highlights/scrolls, second selects
ap.getSeqPanel().ap.getIdPanel().highlightSearchResults(null);
- ap.av.setSelectionGroup(// new SequenceGroup(
- aa[selectedRow].groupRef); // );
+ // process modifiers
+ SequenceGroup sg = ap.av.getSelectionGroup();
+ if (sg == null
+ || sg == aa[selectedRow].groupRef
+ || !(jalview.util.Platform.isControlDown(evt) || evt
+ .isShiftDown()))
+ {
+ if (jalview.util.Platform.isControlDown(evt)
+ || evt.isShiftDown())
+ {
+ // clone a new selection group from the associated group
+ ap.av.setSelectionGroup(new SequenceGroup(
+ aa[selectedRow].groupRef));
+ }
+ else
+ {
+ // set selection to the associated group so it can be edited
+ ap.av.setSelectionGroup(aa[selectedRow].groupRef);
+ }
+ }
+ else
+ {
+ // modify current selection with associated group
+ int remainToAdd = aa[selectedRow].groupRef.getSize();
+ for (SequenceI sgs : aa[selectedRow].groupRef.getSequences())
+ {
+ if (jalview.util.Platform.isControlDown(evt))
+ {
+ sg.addOrRemove(sgs, --remainToAdd == 0);
+ }
+ else
+ {
+ // notionally, we should also add intermediate sequences from
+ // last added sequence ?
+ sg.addSequence(sgs, --remainToAdd == 0);
+ }
+ }
+ }
+
ap.paintAlignment(false);
PaintRefresher.Refresh(ap, ap.av.getSequenceSetId());
ap.av.sendSelection();
// we make a copy rather than edit the current selection if no
// modifiers pressed
// see Enhancement JAL-1557
- if (!(evt.isControlDown() || evt.isShiftDown()))
+ if (!(jalview.util.Platform.isControlDown(evt) || evt
+ .isShiftDown()))
{
sg = new SequenceGroup(sg);
sg.clear();
}
else
{
- if (evt.isControlDown())
+ if (jalview.util.Platform.isControlDown(evt))
{
sg.addOrRemove(aa[selectedRow].sequenceRef, true);
}
sg.addSequence(aa[selectedRow].sequenceRef, false);
}
ap.av.setSelectionGroup(sg);
- ap.av.sendSelection();
ap.paintAlignment(false);
PaintRefresher.Refresh(ap, ap.av.getSequenceSetId());
+ ap.av.sendSelection();
}
}
alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex(
hiddenCols);
}
- String output = new FormatAdapter().formatSequences("Fasta", seqs,
- omitHidden, alignmentStartEnd);
+ String output = new FormatAdapter().formatSequences(FileFormat.Fasta,
+ seqs, omitHidden, alignmentStartEnd);
Toolkit.getDefaultToolkit().getSystemClipboard()
.setContents(new StringSelection(output), Desktop.instance);