X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=afd1d04b56b77879752a0dc649e4c33725009001;hb=61a4ffb7cfd54b95c16bd78c14f4e86d2a7b037e;hp=69af72bf531b12f502007890c8a33353fd0e3b4c;hpb=9f822a04881b453114c051b47e133ac43af23c65;p=jalview.git
diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java
index 69af72b..afd1d04 100644
--- a/src/jalview/gui/AlignFrame.java
+++ b/src/jalview/gui/AlignFrame.java
@@ -30,10 +30,12 @@ import jalview.analysis.ParseProperties;
import jalview.analysis.SequenceIdMatcher;
import jalview.api.AlignViewControllerGuiI;
import jalview.api.AlignViewControllerI;
+import jalview.api.AlignmentViewPanel;
import jalview.api.analysis.ScoreModelI;
import jalview.bin.Cache;
import jalview.commands.CommandI;
import jalview.commands.EditCommand;
+import jalview.commands.EditCommand.Action;
import jalview.commands.OrderCommand;
import jalview.commands.RemoveGapColCommand;
import jalview.commands.RemoveGapsCommand;
@@ -114,6 +116,7 @@ import java.beans.PropertyChangeEvent;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
@@ -279,7 +282,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
/**
- * Make a new AlignFrame from exisiting alignmentPanels
+ * Make a new AlignFrame from existing alignmentPanels
*
* @param ap
* AlignmentPanel
@@ -377,7 +380,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
.getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt
.getKeyCode() <= KeyEvent.VK_NUMPAD9))
&& Character.isDigit(evt.getKeyChar()))
+ {
alignPanel.seqPanel.numberPressed(evt.getKeyChar());
+ }
switch (evt.getKeyCode())
{
@@ -389,32 +394,48 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
case KeyEvent.VK_DOWN:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
moveSelectedSequences(false);
+ }
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(0, 1);
+ }
break;
case KeyEvent.VK_UP:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
moveSelectedSequences(true);
+ }
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(0, -1);
+ }
break;
case KeyEvent.VK_LEFT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
slideSequences(false, alignPanel.seqPanel.getKeyboardNo1());
+ }
else
+ {
alignPanel.seqPanel.moveCursor(-1, 0);
+ }
break;
case KeyEvent.VK_RIGHT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
slideSequences(true, alignPanel.seqPanel.getKeyboardNo1());
+ }
else
+ {
alignPanel.seqPanel.moveCursor(1, 0);
+ }
break;
case KeyEvent.VK_SPACE:
@@ -551,14 +572,18 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
case KeyEvent.VK_LEFT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
viewport.firePropertyChange("alignment", null, viewport
.getAlignment().getSequences());
+ }
break;
case KeyEvent.VK_RIGHT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
viewport.firePropertyChange("alignment", null, viewport
.getAlignment().getSequences());
+ }
break;
}
}
@@ -724,10 +749,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
scaleRight.setVisible(av.wrapAlignment);
annotationPanelMenuItem.setState(av.showAnnotation);
/*
- * Show/hide all annotations only enabled if annotation panel is shown
+ * Show/hide annotations only enabled if annotation panel is shown
*/
- showAllAnnotations.setEnabled(annotationPanelMenuItem.getState());
- hideAllAnnotations.setEnabled(annotationPanelMenuItem.getState());
+ showAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
+ hideAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
+ showAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
+ hideAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
viewBoxesMenuItem.setSelected(av.showBoxes);
viewTextMenuItem.setSelected(av.showText);
showNonconservedMenuItem.setSelected(av.getShowUnconserved());
@@ -818,8 +845,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
if (progressBarHandlers == null || !progressBars.contains(new Long(id)))
{
- throw new Error(
- "call setProgressBar before registering the progress bar's handler.");
+ throw new Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler"));
}
progressBarHandlers.put(new Long(id), handler);
final JPanel progressPanel = (JPanel) progressBars.get(new Long(id));
@@ -835,10 +861,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void actionPerformed(ActionEvent e)
{
handler.cancelActivity(id);
- us.setProgressBar(
- "Cancelled "
- + ((JLabel) progressPanel.getComponent(0))
- .getText(), id);
+ us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", new String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id);
}
});
progressPanel.add(cancel, BorderLayout.EAST);
@@ -1001,7 +1024,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
currentFileFormat, false);
chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Save Alignment to file");
+ chooser.setDialogTitle(MessageManager.getString("label.save_alignment_to_file"));
chooser.setToolTipText(MessageManager.getString("action.save"));
int value = chooser.showSaveDialog(this);
@@ -1240,6 +1263,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
alignPanel.makeEPS(f);
}
+ public void createSVG(File f)
+ {
+ alignPanel.makeSVG(f);
+ }
@Override
public void pageSetup_actionPerformed(ActionEvent e)
{
@@ -1386,7 +1413,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (viewport.historyList.size() > 0)
{
undoMenuItem.setEnabled(true);
- CommandI command = (CommandI) viewport.historyList.peek();
+ CommandI command = viewport.historyList.peek();
undoMenuItem.setText(MessageManager.formatMessage(
"label.undo_command", new String[]
{ command.getDescription() }));
@@ -1401,7 +1428,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
redoMenuItem.setEnabled(true);
- CommandI command = (CommandI) viewport.redoList.peek();
+ CommandI command = viewport.redoList.peek();
redoMenuItem.setText(MessageManager.formatMessage(
"label.redo_command", new String[]
{ command.getDescription() }));
@@ -1462,8 +1489,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
protected void undoMenuItem_actionPerformed(ActionEvent e)
{
if (viewport.historyList.empty())
+ {
return;
- CommandI command = (CommandI) viewport.historyList.pop();
+ }
+ CommandI command = viewport.historyList.pop();
viewport.redoList.push(command);
command.undoCommand(getViewAlignments());
@@ -1502,7 +1531,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
return;
}
- CommandI command = (CommandI) viewport.redoList.pop();
+ CommandI command = viewport.redoList.pop();
viewport.historyList.push(command);
command.doCommand(getViewAlignments());
@@ -1615,37 +1644,53 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
for (int i = 0; i < viewport.getAlignment().getHeight(); i++)
{
if (!sg.contains(viewport.getAlignment().getSequenceAt(i)))
+ {
invertGroup.add(viewport.getAlignment().getSequenceAt(i));
+ }
}
SequenceI[] seqs1 = sg.toArray(new SequenceI[0]);
SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
for (int i = 0; i < invertGroup.size(); i++)
+ {
seqs2[i] = (SequenceI) invertGroup.elementAt(i);
+ }
SlideSequencesCommand ssc;
if (right)
+ {
ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1,
size, viewport.getGapCharacter());
+ }
else
+ {
ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2,
size, viewport.getGapCharacter());
+ }
int groupAdjustment = 0;
if (ssc.getGapsInsertedBegin() && right)
{
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(size, 0);
+ }
else
+ {
groupAdjustment = size;
+ }
}
else if (!ssc.getGapsInsertedBegin() && !right)
{
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(-size, 0);
+ }
else
+ {
groupAdjustment = -size;
+ }
}
if (groupAdjustment != 0)
@@ -1666,7 +1711,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
if (!appendHistoryItem)
+ {
addHistoryItem(ssc);
+ }
repaint();
}
@@ -1946,7 +1993,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
// /////
// ADD HISTORY ITEM
//
- addHistoryItem(new EditCommand("Add sequences", EditCommand.PASTE,
+ addHistoryItem(new EditCommand(
+ MessageManager.getString("label.add_sequences"),
+ Action.PASTE,
sequences, 0, alignment.getWidth(), alignment));
}
// Add any annotations attached to sequences
@@ -2001,7 +2050,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
AlignmentAnnotation sann[] = sequences[i].getAnnotation();
if (sann == null)
+ {
continue;
+ }
for (int avnum = 0; avnum < alview.length; avnum++)
{
if (alview[avnum] != alignment)
@@ -2215,8 +2266,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
/*
* //ADD HISTORY ITEM
*/
- addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, cut,
- sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
+ addHistoryItem(new EditCommand(
+ MessageManager.getString("label.cut_sequences"), Action.CUT,
+ cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
viewport.getAlignment()));
viewport.setSelectionGroup(null);
@@ -2619,7 +2671,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
boolean addFirstIndex = false;
if (viewTitle == null || viewTitle.trim().length() == 0)
{
- viewTitle = "View";
+ viewTitle = MessageManager.getString("action.view");
addFirstIndex = true;
}
else
@@ -3060,8 +3112,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
final boolean setVisible = annotationPanelMenuItem.isSelected();
viewport.setShowAnnotation(setVisible);
alignPanel.setAnnotationVisible(setVisible);
- this.showAllAnnotations.setEnabled(setVisible);
- this.hideAllAnnotations.setEnabled(setVisible);
+ this.showAllSeqAnnotations.setEnabled(setVisible);
+ this.hideAllSeqAnnotations.setEnabled(setVisible);
+ this.showAllAlAnnotations.setEnabled(setVisible);
+ this.hideAllAlAnnotations.setEnabled(setVisible);
}
@Override
@@ -3903,7 +3957,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void addSortByOrderMenuItem(String title,
final AlignmentOrder order)
{
- final JMenuItem item = new JMenuItem("by " + title);
+ final JMenuItem item = new JMenuItem(MessageManager.formatMessage("action.by_title_param", new String[]{title}));
sort.add(item);
item.addActionListener(new java.awt.event.ActionListener()
{
@@ -4132,6 +4186,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
msa = viewport.getAlignmentView(true);
}
+ else if (viewport.getSelectionGroup() != null
+ && viewport.getSelectionGroup().getSize() == 1)
+ {
+ int option = JOptionPane.showConfirmDialog(this,
+ MessageManager.getString("warn.oneseq_msainput_selection"),
+ MessageManager.getString("label.invalid_selection"),
+ JOptionPane.OK_CANCEL_OPTION);
+ if (option == JOptionPane.OK_OPTION)
+ {
+ msa = viewport.getAlignmentView(false);
+ }
+
+ }
else
{
/*
@@ -4353,6 +4420,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
final JMenu analymenu = new JMenu("Analysis");
final JMenu dismenu = new JMenu("Protein Disorder");
+ // final JMenu msawsmenu = new
+ // JMenu(MessageManager.getString("label.alignment"));
+ // final JMenu secstrmenu = new
+ // JMenu(MessageManager.getString("label.secondary_structure_prediction"));
+ // final JMenu seqsrchmenu = new
+ // JMenu(MessageManager.getString("label.sequence_database_search"));
+ // final JMenu analymenu = new
+ // JMenu(MessageManager.getString("label.analysis"));
+ // final JMenu dismenu = new
+ // JMenu(MessageManager.getString("label.protein_disorder"));
// JAL-940 - only show secondary structure prediction services from
// the legacy server
if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
@@ -4619,7 +4696,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void run()
{
final long sttime = System.currentTimeMillis();
- ths.setProgressBar("Searching for sequences from " + fsrc, sttime);
+ ths.setProgressBar(MessageManager.formatMessage("status.searching_for_sequences_from", new String[]{fsrc}), sttime);
try
{
Alignment ds = ths.getViewport().getAlignment().getDataset(); // update
@@ -4637,7 +4714,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (ds.getSequences() == null
|| !ds.getSequences().contains(
sprods[s].getDatasetSequence()))
+ {
ds.addSequence(sprods[s].getDatasetSequence());
+ }
sprods[s].updatePDBIds();
}
Alignment al = new Alignment(sprods);
@@ -4673,7 +4752,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
jalview.bin.Cache.log.error("Error when finding crossreferences",
e);
}
- ths.setProgressBar("Finished searching for sequences from " + fsrc,
+ ths.setProgressBar(MessageManager.formatMessage("status.finished_searching_for_sequences_from", new String[]{fsrc}),
sttime);
}
@@ -4999,7 +5078,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
PDBEntry pe = new AssociatePdbFileWithSeq()
.associatePdbWithSeq((String) fm[0],
- (String) fm[1], toassoc, false);
+ (String) fm[1], toassoc, false,
+ Desktop.instance);
if (pe != null)
{
System.err.println("Associated file : "
@@ -5019,14 +5099,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
"AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false) || JOptionPane
.showConfirmDialog(
this,
- MessageManager
+ ""+MessageManager
.formatMessage(
"label.ignore_unmatched_dropped_files_info",
new String[]
{ Integer.valueOf(
filesnotmatched
.size())
- .toString() }),
+ .toString() })+"",
MessageManager
.getString("label.ignore_unmatched_dropped_files"),
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION))
@@ -5433,9 +5513,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
});
- fetchr.setToolTipText(""
- + JvSwingUtils.wrapTooltip("Retrieve from "
- + src.getDbName()) + "");
+ fetchr.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage("label.fetch_retrieve_from", new String[]{src.getDbName()})));
dfetch.add(fetchr);
comp++;
}
@@ -5468,15 +5546,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
});
- fetchr.setToolTipText(""
- + JvSwingUtils.wrapTooltip("Retrieve from all "
- + otherdb.size() + " sources in "
- + src.getDbSource() + "
First is :"
- + src.getDbName()) + "");
+ fetchr.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage("label.fetch_retrieve_from_all_sources", new String[]{Integer.valueOf(otherdb.size()).toString(), src.getDbSource(), src.getDbName()})));
dfetch.add(fetchr);
comp++;
// and then build the rest of the individual menus
- ifetch = new JMenu("Sources from " + src.getDbSource());
+ ifetch = new JMenu(MessageManager.formatMessage("label.source_from_db_source", new String[]{src.getDbSource()}));
icomp = 0;
String imname = null;
int i = 0;
@@ -5489,7 +5563,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
0, 10) + "..." : dbname;
if (imname == null)
{
- imname = "from '" + sname + "'";
+ imname = MessageManager.formatMessage("label.from_msname", new String[]{sname});
}
fetchr = new JMenuItem(msname);
final DbSourceProxy[] dassrc =
@@ -5516,8 +5590,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
});
fetchr.setToolTipText(""
- + JvSwingUtils.wrapTooltip("Retrieve from "
- + dbname) + "");
+ + MessageManager.formatMessage("label.fetch_retrieve_from", new String[]{dbname}));
ifetch.add(fetchr);
++i;
if (++icomp >= mcomp || i == (otherdb.size()))
@@ -5710,8 +5783,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (!viewport.getSequenceSetId().equals(
alignmentPanel.av.getSequenceSetId()))
{
- throw new Error(
- "Implementation error: cannot show a view from another alignment in an AlignFrame.");
+ throw new Error(MessageManager.getString("error.implementation_error_cannot_show_view_alignment_frame"));
}
if (tabbedPane != null
& alignPanels.indexOf(alignmentPanel) != tabbedPane
@@ -5722,43 +5794,51 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
/**
- * Get a list of unique annotation types for the alignment, optionally
- * restricted to sequence-specific annotations.
+ * Action on selection of menu options to Show or Hide annotations.
+ *
+ * @param visible
+ * @param forSequences
+ * update sequence-related annotations
+ * @param forAlignment
+ * update non-sequence-related annotations
*/
- protected List getAnnotationTypes(boolean sequenceSpecificOnly)
+ @Override
+ protected void setAnnotationsVisibility(boolean visible,
+ boolean forSequences, boolean forAlignment)
{
- // TODO move this to an AlignmentUtils class or similar
- List types = new ArrayList();
for (AlignmentAnnotation aa : alignPanel.getAlignment()
.getAlignmentAnnotation())
{
- if (sequenceSpecificOnly && aa.sequenceRef == null)
+ boolean apply = (aa.sequenceRef == null && forAlignment)
+ || (aa.sequenceRef != null && forSequences);
+ if (apply)
{
- continue;
- }
- String type = aa.label;
- if (!types.contains(type))
- {
- types.add(type);
+ aa.visible = visible;
}
}
- return types;
+ alignPanel.validateAnnotationDimensions(false);
+ alignPanel.alignmentChanged();
}
/**
- * Action on selection of menu option to Show or Hide all annotations.
- *
- * @param visibile
+ * Store selected annotation sort order for the view and repaint.
*/
@Override
- protected void setAllAnnotationsVisibility(boolean visible)
+ protected void sortAnnotations_actionPerformed()
{
- for (AlignmentAnnotation aa : alignPanel.getAlignment()
- .getAlignmentAnnotation())
- {
- aa.visible = visible;
- }
- this.alignPanel.paintAlignment(true);
+ this.alignPanel.av.setSortAnnotationsBy(getAnnotationSortOrder());
+ this.alignPanel.av
+ .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
+ alignPanel.paintAlignment(true);
+ }
+
+ /**
+ *
+ * @return alignment panels in this alignemnt frame
+ */
+ public List getAlignPanels()
+ {
+ return alignPanels == null ? Arrays.asList(alignPanel) : alignPanels;
}
}