*/
package jalview.gui;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetEvent;
+import java.awt.dnd.DropTargetListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.print.PageFormat;
+import java.awt.print.PrinterJob;
+import java.beans.PropertyChangeEvent;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Deque;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Vector;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComponent;
+import javax.swing.JEditorPane;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+
+import ext.vamsas.ServiceHandle;
import jalview.analysis.AlignmentSorter;
import jalview.analysis.AlignmentUtils;
import jalview.analysis.CrossRef;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureSettingsControllerI;
+import jalview.api.FeatureSettingsModelI;
import jalview.api.SplitContainerI;
import jalview.api.ViewStyleI;
import jalview.api.analysis.SimilarityParamsI;
import jalview.ws.jws2.jabaws2.Jws2Instance;
import jalview.ws.seqfetcher.DbSourceProxy;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Rectangle;
-import java.awt.Toolkit;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.DataFlavor;
-import java.awt.datatransfer.StringSelection;
-import java.awt.datatransfer.Transferable;
-import java.awt.dnd.DnDConstants;
-import java.awt.dnd.DropTargetDragEvent;
-import java.awt.dnd.DropTargetDropEvent;
-import java.awt.dnd.DropTargetEvent;
-import java.awt.dnd.DropTargetListener;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusAdapter;
-import java.awt.event.FocusEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
-import java.awt.print.PageFormat;
-import java.awt.print.PrinterJob;
-import java.beans.PropertyChangeEvent;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Deque;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Vector;
-
-import javax.swing.ButtonGroup;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JComponent;
-import javax.swing.JEditorPane;
-import javax.swing.JInternalFrame;
-import javax.swing.JLabel;
-import javax.swing.JLayeredPane;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.SwingUtilities;
-
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision$
*/
+@SuppressWarnings("serial")
public class AlignFrame extends GAlignFrame implements DropTargetListener,
IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener
{
*/
void init()
{
-// setBackground(Color.white); // BH 2019
-
+ // setBackground(Color.white); // BH 2019
+
if (!Jalview.isHeadlessMode())
{
progressBar = new ProgressBar(this.statusPanel, this.statusBar);
});
buildColourMenu();
- if (Desktop.desktop != null)
+ if (Desktop.getDesktopPane() != null)
{
this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
- /**
- * BH 2018 ignore service listeners
- *
- * @j2sNative
- *
- */
+ if (!Platform.isJS())
{
addServiceListeners();
}
private void addServiceListeners()
{
final java.beans.PropertyChangeListener thisListener;
- Desktop.instance.addJalviewPropertyChangeListener("services",
+ Desktop.getInstance().addJalviewPropertyChangeListener("services",
thisListener = new java.beans.PropertyChangeListener()
{
@Override
javax.swing.event.InternalFrameEvent evt)
{
// System.out.println("deregistering discoverer listener");
- Desktop.instance.removeJalviewPropertyChangeListener("services",
- thisListener);
+ Desktop.getInstance().removeJalviewPropertyChangeListener(
+ "services", thisListener);
closeMenuItem_actionPerformed(true);
- };
+ }
});
// Finally, build the menu once to get current service state
new Thread(new Runnable()
@Override
public void setStatus(String text)
{
- // BH note: If text width and height are 0, then the layout manager
- // will dispense of it and change the frame height.
- // In JavaScript, we use \u00A0 -- unicode "non-breaking space"
- // which is the unicode encoding of
-
statusBar.setText(text == null || text.isEmpty() ? " " : text);
}
@Override
public void addFromFile_actionPerformed(ActionEvent e)
{
- Desktop.instance.inputLocalFileMenuItem_actionPerformed(viewport);
+ Desktop.getInstance().inputLocalFileMenuItem_actionPerformed(viewport);
}
@Override
// file is reloaded.
if (FileFormat.Jalview.equals(currentFileFormat))
{
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
for (int i = 0; i < frames.length; i++)
{
if (frames[i] instanceof AlignFrame && frames[i] != this
try
{
frames[i].setSelected(true);
- Desktop.instance.closeAssociatedWindows();
+ Desktop.getInstance().closeAssociatedWindows();
} catch (java.beans.PropertyVetoException ex)
{
}
}
}
- Desktop.instance.closeAssociatedWindows();
+ Desktop.getInstance().closeAssociatedWindows();
FileLoader loader = new FileLoader();
DataSourceType protocol = fileName.startsWith("http:")
@Override
public void addFromText_actionPerformed(ActionEvent e)
{
- Desktop.instance
+ Desktop.getInstance()
.inputTextboxMenuItem_actionPerformed(viewport.getAlignPanel());
}
@Override
public void addFromURL_actionPerformed(ActionEvent e)
{
- Desktop.instance.inputURLMenuItem_actionPerformed(viewport);
+ Desktop.getInstance().inputURLMenuItem_actionPerformed(viewport);
}
@Override
// todo is this (2005) test now obsolete - value is never null?
while (currentFileFormat == null)
{
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
MessageManager
.getString("label.select_file_format_before_saving"),
MessageManager.getString("label.file_format_not_specified"),
*/
public void saveAlignment(String file, FileFormatI format)
{
- lastSaveSuccessful = false;
+ lastSaveSuccessful = true;
lastFilenameSaved = file;
lastFormatSaved = format;
String shortName = title;
if (shortName.indexOf(File.separatorChar) > -1)
{
- shortName = shortName.substring(
- shortName.lastIndexOf(File.separatorChar) + 1);
+ shortName = shortName
+ .substring(shortName.lastIndexOf(File.separatorChar) + 1);
}
- lastSaveSuccessful = new Jalview2XML().saveAlignment(this, file, shortName);
-
+ lastSaveSuccessful = new Jalview2XML().saveAlignment(this, file,
+ shortName);
+
statusBar.setText(MessageManager.formatMessage(
"label.successfully_saved_to_file_in_format", new Object[]
{ fileName, format }));
-
+
return;
}
else
{
// create backupfiles object and get new temp filename destination
- BackupFiles backupfiles = new BackupFiles(file);
+ boolean doBackup = BackupFiles.getEnabled();
+ BackupFiles backupfiles = doBackup ? new BackupFiles(file) : null;
try
{
- PrintWriter out = new PrintWriter(
- new FileWriter(backupfiles.getTempFilePath()));
+ String tempFilePath = doBackup ? backupfiles.getTempFilePath()
+ : file;
+ PrintWriter out = new PrintWriter(new FileWriter(tempFilePath));
out.print(output);
out.close();
AlignFrame.this.setTitle(file);
statusBar.setText(MessageManager.formatMessage(
- "label.successfully_saved_to_file_in_format", new Object[]
- { fileName, format.getName() }));
+ "label.successfully_saved_to_file_in_format",
+ new Object[]
+ { fileName, format.getName() }));
+ lastSaveSuccessful = true;
} catch (Exception ex)
{
lastSaveSuccessful = false;
ex.printStackTrace();
}
- backupfiles.setWriteSuccess(lastSaveSuccessful);
- // do the backup file roll and rename the temp file to actual file
- lastSaveSuccessful = backupfiles.rollBackupsAndRenameTempFile();
+ if (doBackup)
+ {
+ backupfiles.setWriteSuccess(lastSaveSuccessful);
+ // do the backup file roll and rename the temp file to actual file
+ lastSaveSuccessful = backupfiles.rollBackupsAndRenameTempFile();
+ }
}
}
};
bjs.exportHTML(null);
}
- public void createImageMap(File file, String image)
- {
- alignPanel.makePNGImageMap(file, image);
- }
-
/**
* Creates a PNG image of the alignment and writes it to the given file. If
* the file is null, the user is prompted to choose a file.
final JalviewFileChooser chooser = new JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle(
- MessageManager.getString("label.load_jalview_annotations"));
- chooser.setToolTipText(
- MessageManager.getString("label.load_jalview_annotations"));
+ String tooltip = MessageManager
+ .getString("label.load_jalview_annotations");
+ chooser.setDialogTitle(tooltip);
+ chooser.setToolTipText(tooltip);
chooser.setResponseHandler(0, new Runnable()
{
@Override
closeView(alignPanel);
}
}
-
if (closeAllTabs)
{
+ if (featureSettings != null && featureSettings.isOpen())
+ {
+ featureSettings.close();
+ featureSettings = null;
+ }
/*
* this will raise an INTERNAL_FRAME_CLOSED event and this method will
* be called recursively, with the frame now in 'closed' state
try
{
- jalview.gui.Desktop.internalCopy = true;
+ Desktop.getInstance().internalCopy = true;
// Its really worth setting the clipboard contents
// to empty before setting the large StringSelection!!
Toolkit.getDefaultToolkit().getSystemClipboard()
.setContents(new StringSelection(""), null);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,
- Desktop.instance);
+ Desktop.getInstance());
} catch (OutOfMemoryError er)
{
new OOMWarning("copying region", er);
hiddenCutoff, hiddenOffset);
}
- Desktop.jalviewClipboard = new Object[] { seqs,
+ Desktop.getInstance().jalviewClipboard = new Object[] { seqs,
viewport.getAlignment().getDataset(), hiddenColumns };
setStatus(MessageManager.formatMessage(
"label.copied_sequences_to_clipboard", new Object[]
void paste(boolean newAlignment)
{
boolean externalPaste = true;
+ Desktop d = Desktop.getInstance();
try
{
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
boolean annotationAdded = false;
AlignmentI alignment = null;
- if (Desktop.jalviewClipboard != null)
+ if (d.jalviewClipboard != null)
{
// The clipboard was filled from within Jalview, we must use the
// sequences
// And dataset from the copied alignment
- SequenceI[] newseq = (SequenceI[]) Desktop.jalviewClipboard[0];
+ SequenceI[] newseq = (SequenceI[]) d.jalviewClipboard[0];
// be doubly sure that we create *new* sequence objects.
sequences = new SequenceI[newseq.length];
for (int i = 0; i < newseq.length; i++)
if (newAlignment)
{
- if (Desktop.jalviewClipboard != null)
+ if (d.jalviewClipboard != null)
{
// dataset is inherited
- alignment.setDataset((Alignment) Desktop.jalviewClipboard[1]);
+ alignment.setDataset((Alignment) d.jalviewClipboard[1]);
}
else
{
alignment = viewport.getAlignment();
alwidth = alignment.getWidth() + 1;
// decide if we need to import sequences from an existing dataset
- boolean importDs = Desktop.jalviewClipboard != null
- && Desktop.jalviewClipboard[1] != alignment.getDataset();
+ boolean importDs = d.jalviewClipboard != null
+ && d.jalviewClipboard[1] != alignment.getDataset();
// importDs==true instructs us to copy over new dataset sequences from
// an existing alignment
- Vector newDs = (importDs) ? new Vector() : null; // used to create
+ Vector<SequenceI> newDs = (importDs) ? new Vector<>() : null; // used to
+ // create
// minimum dataset set
for (int i = 0; i < sequences.length; i++)
newGraphGroups.add(q, null);
}
newGraphGroups.set(newann.graphGroup,
- new Integer(++fgroup));
+ Integer.valueOf(++fgroup));
}
newann.graphGroup = newGraphGroups.get(newann.graphGroup)
.intValue();
newGraphGroups.add(q, null);
}
newGraphGroups.set(newann.graphGroup,
- new Integer(++fgroup));
+ Integer.valueOf(++fgroup));
}
newann.graphGroup = newGraphGroups.get(newann.graphGroup)
.intValue();
{
// propagate alignment changed.
- viewport.getRanges().setEndSeq(alignment.getHeight());
+ viewport.getRanges().setEndSeq(alignment.getHeight() - 1);
if (annotationAdded)
{
// Duplicate sequence annotation in all views.
DEFAULT_HEIGHT);
String newtitle = new String("Copied sequences");
- if (Desktop.jalviewClipboard != null
- && Desktop.jalviewClipboard[2] != null)
+ if (d.jalviewClipboard != null && d.jalviewClipboard[2] != null)
{
- HiddenColumns hc = (HiddenColumns) Desktop.jalviewClipboard[2];
+ HiddenColumns hc = (HiddenColumns) d.jalviewClipboard[2];
af.viewport.setHiddenColumns(hc);
}
AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH,
DEFAULT_HEIGHT);
String newtitle = new String("Flanking alignment");
-
- if (Desktop.jalviewClipboard != null
- && Desktop.jalviewClipboard[2] != null)
+ Desktop d = Desktop.getInstance();
+ if (d.jalviewClipboard != null && d.jalviewClipboard[2] != null)
{
- HiddenColumns hc = (HiddenColumns) Desktop.jalviewClipboard[2];
+ HiddenColumns hc = (HiddenColumns) d.jalviewClipboard[2];
af.viewport.setHiddenColumns(hc);
}
return;
}
- Runnable okAction = new Runnable()
- {
- @Override
- public void run()
- {
- SequenceI[] cut = sg.getSequences()
- .toArray(new SequenceI[sg.getSize()]);
-
- addHistoryItem(new EditCommand(
- MessageManager.getString("label.cut_sequences"), Action.CUT,
- cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
- viewport.getAlignment()));
-
- viewport.setSelectionGroup(null);
- viewport.sendSelection();
- viewport.getAlignment().deleteGroup(sg);
-
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
- if (viewport.getAlignment().getHeight() < 1)
- {
- try
- {
- AlignFrame.this.setClosed(true);
- } catch (Exception ex)
- {
- }
- }
- }};
+ Runnable okAction = new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ SequenceI[] cut = sg.getSequences()
+ .toArray(new SequenceI[sg.getSize()]);
+
+ addHistoryItem(new EditCommand(
+ MessageManager.getString("label.cut_sequences"), Action.CUT,
+ cut, sg.getStartRes(),
+ sg.getEndRes() - sg.getStartRes() + 1,
+ viewport.getAlignment()));
+
+ viewport.setSelectionGroup(null);
+ viewport.sendSelection();
+ viewport.getAlignment().deleteGroup(sg);
+
+ viewport.firePropertyChange("alignment", null,
+ viewport.getAlignment().getSequences());
+ if (viewport.getAlignment().getHeight() < 1)
+ {
+ try
+ {
+ AlignFrame.this.setClosed(true);
+ } catch (Exception ex)
+ {
+ }
+ }
+ }
+ };
/*
* If the cut affects all sequences, prompt for confirmation
*/
- boolean wholeHeight = sg.getSize() == viewport.getAlignment().getHeight();
+ boolean wholeHeight = sg.getSize() == viewport.getAlignment()
+ .getHeight();
boolean wholeWidth = (((sg.getEndRes() - sg.getStartRes())
+ 1) == viewport.getAlignment().getWidth()) ? true : false;
- if (wholeHeight && wholeWidth)
- {
- JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop);
- dialog.setResponseHandler(0, okAction); // 0 = OK_OPTION
- Object[] options = new Object[] { MessageManager.getString("action.ok"),
- MessageManager.getString("action.cancel") };
- dialog.showDialog(MessageManager.getString("warn.delete_all"),
- MessageManager.getString("label.delete_all"),
- JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
- options, options[0]);
- } else
- {
- okAction.run();
- }
+ if (wholeHeight && wholeWidth)
+ {
+ JvOptionPane dialog = JvOptionPane
+ .newOptionDialog(Desktop.getDesktopPane());
+ dialog.setResponseHandler(0, okAction); // 0 = OK_OPTION
+ Object[] options = new Object[] {
+ MessageManager.getString("action.ok"),
+ MessageManager.getString("action.cancel") };
+ dialog.showDialog(MessageManager.getString("warn.delete_all"),
+ MessageManager.getString("label.delete_all"),
+ JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
+ options, options[0]);
+ }
+ else
+ {
+ okAction.run();
+ }
}
/**
column, viewport.getAlignment());
}
- setStatus(MessageManager
- .formatMessage("label.removed_columns", new String[]
+ setStatus(MessageManager.formatMessage("label.removed_columns",
+ new String[]
{ Integer.valueOf(trimRegion.getSize()).toString() }));
addHistoryItem(trimRegion);
addHistoryItem(removeGapCols);
- setStatus(MessageManager
- .formatMessage("label.removed_empty_columns", new Object[]
+ setStatus(MessageManager.formatMessage("label.removed_empty_columns",
+ new Object[]
{ Integer.valueOf(removeGapCols.getSize()).toString() }));
// This is to maintain viewport position on first residue
if (viewport.getViewName() == null)
{
- viewport.setViewName(MessageManager
- .getString("label.view_name_original"));
+ viewport.setViewName(
+ MessageManager.getString("label.view_name_original"));
}
/*
@Override
public void gatherViews_actionPerformed(ActionEvent e)
{
- Desktop.instance.gatherViews(this);
+ Desktop.getInstance().gatherViews(this);
}
/**
* @param toggleSeqs
* @param toggleCols
*/
- private void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
+ protected void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
{
boolean hide = false;
protected void scaleAbove_actionPerformed(ActionEvent e)
{
viewport.setScaleAboveWrapped(scaleAbove.isSelected());
- // TODO: do we actually need to update overview for scale above change ?
+ alignPanel.updateLayout();
alignPanel.paintAlignment(true, false);
}
protected void scaleLeft_actionPerformed(ActionEvent e)
{
viewport.setScaleLeftWrapped(scaleLeft.isSelected());
+ alignPanel.updateLayout();
alignPanel.paintAlignment(true, false);
}
protected void scaleRight_actionPerformed(ActionEvent e)
{
viewport.setScaleRightWrapped(scaleRight.isSelected());
+ alignPanel.updateLayout();
alignPanel.paintAlignment(true, false);
}
@Override
public void featureSettings_actionPerformed(ActionEvent e)
{
+ showFeatureSettingsUI();
+ }
+
+ @Override
+ public FeatureSettingsControllerI showFeatureSettingsUI()
+ {
if (featureSettings != null)
{
- featureSettings.close();
+ featureSettings.closeOldSettings();
featureSettings = null;
}
if (!showSeqFeatures.isSelected())
showSeqFeatures_actionPerformed(null);
}
featureSettings = new FeatureSettings(this);
+ return featureSettings;
}
/**
JLabel textLabel = new JLabel();
textLabel.setText(content);
textLabel.setBackground(Color.WHITE);
-
+
pane = new JPanel(new BorderLayout());
((JPanel) pane).setOpaque(true);
pane.setBackground(Color.WHITE);
((JPanel) pane).add(textLabel, BorderLayout.NORTH);
}
else
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
{
JEditorPane editPane = new JEditorPane("text/html", "");
editPane.setEditable(false);
}
JInternalFrame frame = new JInternalFrame();
- final OverviewPanel overview = new OverviewPanel(alignPanel);
+
+ // BH 2019.07.26 we allow for an embedded
+ // undecorated overview with defined size
+ frame.setName(Platform.getAppID("overview"));
+ //
+ Dimension dim = Platform.getDimIfEmbedded(frame, -1, -1);
+ if (dim != null && dim.width == 0)
+ {
+ dim = null; // hidden, not embedded
+ }
+ OverviewPanel overview = new OverviewPanel(alignPanel, dim);
+
frame.setContentPane(overview);
+ if (dim == null)
+ {
+ dim = new Dimension();
+ // was frame.getSize(), but that is 0,0 at this point;
+ }
+ else
+ {
+ // we are imbedding, and so we have an undecorated frame
+ // and we can set the the frame dimensions accordingly.
+ }
+ // allowing for unresizable option using, style="resize:none"
+ boolean resizable = (Platform.getEmbeddedAttribute(frame,
+ "resize") != "none");
Desktop.addInternalFrame(frame, MessageManager
.formatMessage("label.overview_params", new Object[]
- { this.getTitle() }), true, frame.getWidth(), frame.getHeight(),
- true, true);
+ { this.getTitle() }), true, dim.width, dim.height, resizable,
+ true);
frame.pack();
frame.setLayer(JLayeredPane.PALETTE_LAYER);
frame.addInternalFrameListener(
{
overview.dispose();
alignPanel.setOverviewPanel(null);
- };
+ }
});
if (getKeyListeners().length > 0)
{
* otherwise set the chosen colour scheme (or null for 'None')
*/
ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(name,
- viewport,
- viewport.getAlignment(), viewport.getHiddenRepSequences());
+ viewport, viewport.getAlignment(),
+ viewport.getHiddenRepSequences());
changeColour(cs);
}
{
if (_s.getLength() < sg.getEndRes())
{
- JvOptionPane.showMessageDialog(Desktop.desktop,
+ JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
MessageManager.getString(
"label.selected_region_to_tree_may_only_contain_residues_or_gaps"),
MessageManager.getString(
frameTitle += this.title;
- Desktop.addInternalFrame(tp, frameTitle, 600, 500);
+ Dimension dim = Platform.getDimIfEmbedded(tp, 600, 500);
+ Desktop.addInternalFrame(tp, frameTitle, dim.width, dim.height);
}
/**
{
sortByAnnotScore.removeAll();
// almost certainly a quicker way to do this - but we keep it simple
- Hashtable scoreSorts = new Hashtable();
+ Hashtable<String, String> scoreSorts = new Hashtable<>();
AlignmentAnnotation aann[];
for (SequenceI sqa : viewport.getAlignment().getSequences())
{
}
}
}
- Enumeration labels = scoreSorts.keys();
+ Enumeration<String> labels = scoreSorts.keys();
while (labels.hasMoreElements())
{
- addSortByAnnotScoreMenuItem(sortByAnnotScore,
- (String) labels.nextElement());
+ addSortByAnnotScoreMenuItem(sortByAnnotScore, labels.nextElement());
}
sortByAnnotScore.setVisible(scoreSorts.size() > 0);
scoreSorts.clear();
chooser.setToolTipText(
MessageManager.getString("label.load_tree_file"));
- chooser.setResponseHandler(0,new Runnable()
+ chooser.setResponseHandler(0, new Runnable()
{
@Override
public void run()
viewport.setCurrentTree(showNewickTree(fin, filePath).getTree());
} catch (Exception ex)
{
- JvOptionPane.showMessageDialog(Desktop.desktop, ex.getMessage(),
+ JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
+ ex.getMessage(),
MessageManager
.getString("label.problem_reading_tree_file"),
JvOptionPane.WARNING_MESSAGE);
}
if (fin != null && fin.hasWarningMessage())
{
- JvOptionPane.showMessageDialog(Desktop.desktop,
+ JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
fin.getWarningMessage(),
MessageManager.getString(
"label.possible_problem_with_tree_file"),
if (nf.getTree() != null)
{
tp = new TreePanel(alignPanel, nf, treeTitle, input);
-
- tp.setSize(w, h);
+ Dimension dim = Platform.getDimIfEmbedded(tp, -1, -1);
+ if (dim == null)
+ {
+ dim = new Dimension(w, h);
+ }
+ else
+ {
+ // no offset, either
+ x = 0;
+ }
+ tp.setSize(dim.width, dim.height);
if (x > 0 && y > 0)
{
tp.setLocation(x, y);
}
- Desktop.addInternalFrame(tp, treeTitle, w, h);
+ Desktop.addInternalFrame(tp, treeTitle, dim.width, dim.height);
}
} catch (Exception ex)
{
final JMenu dismenu = new JMenu("Protein Disorder");
// JAL-940 - only show secondary structure prediction services from
// the legacy server
+ Hashtable<String, Vector<ServiceHandle>> ds = Discoverer
+ .getServices();
+
if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
// &&
- Discoverer.services != null && (Discoverer.services.size() > 0))
+ ds != null && (ds.size() > 0))
{
// TODO: refactor to allow list of AbstractName/Handler bindings to
// be
// No MSAWS used any more:
// Vector msaws = null; // (Vector)
// Discoverer.services.get("MsaWS");
- Vector secstrpr = (Vector) Discoverer.services
- .get("SecStrPred");
+ Vector<ServiceHandle> secstrpr = ds.get("SecStrPred");
if (secstrpr != null)
{
// Add any secondary structure prediction services
for (int i = 0, j = secstrpr.size(); i < j; i++)
{
- final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) secstrpr
- .get(i);
+ final ext.vamsas.ServiceHandle sh = secstrpr.get(i);
jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
.getServiceClient(sh);
int p = secstrmenu.getItemCount();
boolean new_sspred = false;
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
- Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
+ Jws2Discoverer jws2servs = Jws2Discoverer.getInstance();
if (jws2servs != null)
{
if (jws2servs.hasServices())
*
* @param webService
*/
- private void build_urlServiceMenu(JMenu webService)
+ protected void build_urlServiceMenu(JMenu webService)
{
// TODO: remove this code when 2.7 is released
// DEBUG - alignmentView
final String errorTitle = MessageManager
.getString("label.implementation_error")
+ MessageManager.getString("label.translation_failed");
- JvOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
- JvOptionPane.ERROR_MESSAGE);
+ JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msg,
+ errorTitle, JvOptionPane.ERROR_MESSAGE);
return;
}
if (al == null || al.getHeight() == 0)
"label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation");
final String errorTitle = MessageManager
.getString("label.translation_failed");
- JvOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
- JvOptionPane.WARNING_MESSAGE);
+ JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msg,
+ errorTitle, JvOptionPane.WARNING_MESSAGE);
}
else
{
if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
{
final SequenceI[] seqs = viewport.getSelectionAsNewSequence();
- viewport.openSplitFrame(af, new Alignment(seqs));
+ AlignViewport.openSplitFrame(this, af, new Alignment(seqs));
}
else
{
evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Transferable t = evt.getTransferable();
- final AlignFrame thisaf = this;
final List<Object> files = new ArrayList<>();
List<DataSourceType> protocols = new ArrayList<>();
try
{
Desktop.transferFromDropTarget(files, protocols, evt, t);
+ if (files.size() > 0)
+ {
+ new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ loadDroppedFiles(files, protocols, evt, t);
+ }
+ }).start();
+ }
} catch (Exception e)
{
e.printStackTrace();
}
- if (files != null)
+ }
+
+ protected void loadDroppedFiles(List<Object> files,
+ List<DataSourceType> protocols, DropTargetDropEvent evt,
+ Transferable t)
+ {
+ try
{
- new Thread(new Runnable()
+ // check to see if any of these files have names matching sequences
+ // in
+ // the alignment
+ SequenceIdMatcher idm = new SequenceIdMatcher(
+ viewport.getAlignment().getSequencesArray());
+ /**
+ * Object[] { String,SequenceI}
+ */
+ ArrayList<Object[]> filesmatched = new ArrayList<>();
+ ArrayList<Object> filesnotmatched = new ArrayList<>();
+ for (int i = 0; i < files.size(); i++)
{
- @Override
- public void run()
+ // BH 2018
+ Object file = files.get(i);
+ String fileName = file.toString();
+ String pdbfn = "";
+ DataSourceType protocol = (file instanceof File
+ ? DataSourceType.FILE
+ : FormatAdapter.checkProtocol(fileName));
+ if (protocol == DataSourceType.FILE)
{
- try
+ File fl;
+ if (file instanceof File)
+ {
+ fl = (File) file;
+ Platform.cacheFileData(fl);
+ }
+ else
{
- // check to see if any of these files have names matching sequences
- // in
- // the alignment
- SequenceIdMatcher idm = new SequenceIdMatcher(
- viewport.getAlignment().getSequencesArray());
- /**
- * Object[] { String,SequenceI}
- */
- ArrayList<Object[]> filesmatched = new ArrayList<>();
- ArrayList<Object> filesnotmatched = new ArrayList<>();
- for (int i = 0; i < files.size(); i++)
+ fl = new File(fileName);
+ }
+ pdbfn = fl.getName();
+ }
+ else if (protocol == DataSourceType.URL)
+ {
+ URL url = new URL(fileName);
+ pdbfn = url.getFile();
+ }
+ if (pdbfn.length() > 0)
+ {
+ // attempt to find a match in the alignment
+ SequenceI[] mtch = idm.findAllIdMatches(pdbfn);
+ int l = 0, c = pdbfn.indexOf(".");
+ while (mtch == null && c != -1)
+ {
+ do
{
- // BH 2018
- Object file = files.get(i);
- String fileName = file.toString();
- String pdbfn = "";
- DataSourceType protocol = (file instanceof File
- ? DataSourceType.FILE
- : FormatAdapter.checkProtocol(fileName));
- if (protocol == DataSourceType.FILE)
- {
- File fl = (file instanceof File ? (File) file
- : new File(fileName));
- pdbfn = fl.getName();
- }
- else if (protocol == DataSourceType.URL)
- {
- URL url = new URL(fileName);
- pdbfn = url.getFile();
- }
- if (pdbfn.length() > 0)
- {
- // attempt to find a match in the alignment
- SequenceI[] mtch = idm.findAllIdMatches(pdbfn);
- int l = 0, c = pdbfn.indexOf(".");
- while (mtch == null && c != -1)
- {
- do
- {
- l = c;
- } while ((c = pdbfn.indexOf(".", l)) > l);
- if (l > -1)
- {
- pdbfn = pdbfn.substring(0, l);
- }
- mtch = idm.findAllIdMatches(pdbfn);
- }
- if (mtch != null)
- {
- FileFormatI type;
- try
- {
- type = new IdentifyFile().identify(file, protocol);
- } catch (Exception ex)
- {
- type = null;
- }
- if (type != null && type.isStructureFile())
- {
- filesmatched.add(new Object[] { file, protocol, mtch });
- continue;
- }
- }
- // File wasn't named like one of the sequences or wasn't a PDB
- // file.
- filesnotmatched.add(file);
- }
+ l = c;
+ } while ((c = pdbfn.indexOf(".", l)) > l);
+ if (l > -1)
+ {
+ pdbfn = pdbfn.substring(0, l);
}
- int assocfiles = 0;
- if (filesmatched.size() > 0)
+ mtch = idm.findAllIdMatches(pdbfn);
+ }
+ if (mtch != null)
+ {
+ FileFormatI type;
+ try
{
- boolean autoAssociate = Cache
- .getDefault("AUTOASSOCIATE_PDBANDSEQS", false);
- if (!autoAssociate)
- {
- String msg = MessageManager.formatMessage(
- "label.automatically_associate_structure_files_with_sequences_same_name",
- new Object[]
- { Integer.valueOf(filesmatched.size())
- .toString() });
- String ttl = MessageManager.getString(
- "label.automatically_associate_structure_files_by_name");
- int choice = JvOptionPane.showConfirmDialog(thisaf, msg,
- ttl, JvOptionPane.YES_NO_OPTION);
- autoAssociate = choice == JvOptionPane.YES_OPTION;
- }
- if (autoAssociate)
- {
- for (Object[] fm : filesmatched)
- {
- // try and associate
- // TODO: may want to set a standard ID naming formalism for
- // associating PDB files which have no IDs.
- for (SequenceI toassoc : (SequenceI[]) fm[2])
- {
- PDBEntry pe = new AssociatePdbFileWithSeq()
- .associatePdbWithSeq(fm[0].toString(),
- (DataSourceType) fm[1], toassoc, false,
- Desktop.instance);
- if (pe != null)
- {
- System.err.println("Associated file : "
- + (fm[0].toString()) + " with "
- + toassoc.getDisplayId(true));
- assocfiles++;
- }
- }
- // TODO: do we need to update overview ? only if features are
- // shown I guess
- alignPanel.paintAlignment(true, false);
- }
- }
- else
- {
- /*
- * add declined structures as sequences
- */
- for (Object[] o : filesmatched)
- {
- filesnotmatched.add(o[0]);
- }
- }
+ type = new IdentifyFile().identify(file, protocol);
+ } catch (Exception ex)
+ {
+ type = null;
}
- if (filesnotmatched.size() > 0)
+ if (type != null && type.isStructureFile())
{
- if (assocfiles > 0 && (Cache.getDefault(
- "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false)
- || JvOptionPane.showConfirmDialog(thisaf,
- "<html>" + MessageManager.formatMessage(
- "label.ignore_unmatched_dropped_files_info",
- new Object[]
- { Integer.valueOf(
- filesnotmatched.size())
- .toString() })
- + "</html>",
- MessageManager.getString(
- "label.ignore_unmatched_dropped_files"),
- JvOptionPane.YES_NO_OPTION) == JvOptionPane.YES_OPTION))
- {
- return;
- }
- for (Object fn : filesnotmatched)
+ filesmatched.add(new Object[] { file, protocol, mtch });
+ continue;
+ }
+ }
+ // File wasn't named like one of the sequences or wasn't a PDB
+ // file.
+ filesnotmatched.add(file);
+ }
+ }
+ int assocfiles = 0;
+ if (filesmatched.size() > 0)
+ {
+ boolean autoAssociate = Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS",
+ false);
+ if (!autoAssociate)
+ {
+ String msg = MessageManager.formatMessage(
+ "label.automatically_associate_structure_files_with_sequences_same_name",
+ new Object[]
+ { Integer.valueOf(filesmatched.size()).toString() });
+ String ttl = MessageManager.getString(
+ "label.automatically_associate_structure_files_by_name");
+ int choice = JvOptionPane.showConfirmDialog(this, msg, ttl,
+ JvOptionPane.YES_NO_OPTION);
+ autoAssociate = choice == JvOptionPane.YES_OPTION;
+ }
+ if (autoAssociate)
+ {
+ for (Object[] fm : filesmatched)
+ {
+ // try and associate
+ // TODO: may want to set a standard ID naming formalism for
+ // associating PDB files which have no IDs.
+ for (SequenceI toassoc : (SequenceI[]) fm[2])
+ {
+ PDBEntry pe = new AssociatePdbFileWithSeq()
+ .associatePdbWithSeq(fm[0].toString(),
+ (DataSourceType) fm[1], toassoc, false,
+ Desktop.getInstance());
+ if (pe != null)
{
- loadJalviewDataFile(fn, null, null, null);
+ System.err.println("Associated file : " + (fm[0].toString())
+ + " with " + toassoc.getDisplayId(true));
+ assocfiles++;
}
-
}
- } catch (Exception ex)
+ // TODO: do we need to update overview ? only if features are
+ // shown I guess
+ alignPanel.paintAlignment(true, false);
+ }
+ }
+ else
+ {
+ /*
+ * add declined structures as sequences
+ */
+ for (Object[] o : filesmatched)
{
- ex.printStackTrace();
+ filesnotmatched.add(o[0]);
}
}
- }).start();
+ }
+ if (filesnotmatched.size() > 0)
+ {
+ if (assocfiles > 0 && (Cache
+ .getDefault("AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false)
+ || JvOptionPane.showConfirmDialog(this,
+ "<html>" + MessageManager.formatMessage(
+ "label.ignore_unmatched_dropped_files_info",
+ new Object[]
+ { Integer.valueOf(filesnotmatched.size())
+ .toString() })
+ + "</html>",
+ MessageManager.getString(
+ "label.ignore_unmatched_dropped_files"),
+ JvOptionPane.YES_NO_OPTION) == JvOptionPane.YES_OPTION))
+ {
+ return;
+ }
+ for (Object fn : filesnotmatched)
+ {
+ loadJalviewDataFile(fn, null, null, null);
+ }
+
+ }
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
}
}
{
// some problem - if no warning its probable that the ID matching
// process didn't work
- JvOptionPane.showMessageDialog(Desktop.desktop,
+ JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
tcf.getWarningMessage() == null
? MessageManager.getString(
"label.check_file_matches_sequence_ids_alignment")
{
if (parseFeaturesFile(file, sourceType))
{
- alignPanel.paintAlignment(true, true);
+ SplitFrame splitFrame = (SplitFrame) getSplitViewContainer();
+ if (splitFrame != null)
+ {
+ splitFrame.repaint();
+ }
+ else
+ {
+ alignPanel.paintAlignment(true, true);
+ }
}
}
else
}
if (isAnnotation)
{
-
- alignPanel.adjustAnnotationHeight();
- viewport.updateSequenceIdColours();
- buildSortByAnnotationScoresMenu();
- alignPanel.paintAlignment(true, true);
+ updateForAnnotations();
}
} catch (Exception ex)
{
+ (format != null
? "(parsing as '" + format + "' file)"
: ""),
- oom, Desktop.desktop);
+ oom, Desktop.getDesktopPane());
+ }
+ }
+
+ /**
+ * Do all updates necessary after an annotation file such as jnet. Also called
+ * from Jalview.loadAppletParams for "annotations", "jnetFile"
+ */
+
+ public void updateForAnnotations()
+ {
+ alignPanel.adjustAnnotationHeight();
+ viewport.updateSequenceIdColours();
+ buildSortByAnnotationScoresMenu();
+ alignPanel.paintAlignment(true, true);
+ }
+
+ /**
+ * Change the display state for the given feature groups -- Added by BH from
+ * JalviewLite
+ *
+ * @param groups
+ * list of group strings
+ * @param state
+ * visible or invisible
+ */
+ public void setFeatureGroupState(String[] groups, boolean state)
+ {
+ jalview.api.FeatureRenderer fr = null;
+ viewport.setShowSequenceFeatures(true);
+ if (alignPanel != null
+ && (fr = alignPanel.getFeatureRenderer()) != null)
+ {
+
+ fr.setGroupVisibility(Arrays.asList(groups), state);
+ alignPanel.getSeqPanel().seqCanvas.repaint();
+ if (alignPanel.overviewPanel != null)
+ {
+ alignPanel.overviewPanel.updateOverviewImage();
+ }
}
}
viewport = alignPanel.av;
avc.setViewportAndAlignmentPanel(viewport, alignPanel);
setMenusFromViewport(viewport);
+ if (featureSettings != null && featureSettings.isOpen()
+ && featureSettings.fr.getViewport() != viewport)
+ {
+ if (viewport.isShowSequenceFeatures())
+ {
+ // refresh the featureSettings to reflect UI change
+ showFeatureSettingsUI();
+ }
+ else
+ {
+ // close feature settings for this view.
+ featureSettings.close();
+ }
+ }
+
}
/*
trimrs.setSelected(trimrs.isSelected());
Cache.setProperty(DBRefFetcher.TRIM_RETRIEVED_SEQUENCES,
Boolean.valueOf(trimrs.isSelected()).toString());
- };
+ }
});
rfetch.add(trimrs);
JMenuItem fetchr = new JMenuItem(
@Override
public void finished()
{
+
+ for (FeatureSettingsModelI srcSettings : dbRefFetcher
+ .getFeatureSettingsModels())
+ {
+
+ alignPanel.av.mergeFeaturesStyle(srcSettings);
+ }
AlignFrame.this.setMenusForViewport();
}
});
@Override
public void finished()
{
+ FeatureSettingsModelI srcSettings = dassource[0]
+ .getFeatureColourScheme();
+ alignPanel.av.mergeFeaturesStyle(
+ srcSettings);
AlignFrame.this.setMenusForViewport();
}
});
} catch (Exception ex)
{
System.err.println((ex.toString()));
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
MessageManager.getString("label.couldnt_run_groovy_script"),
MessageManager.getString("label.groovy_support_failed"),
JvOptionPane.ERROR_MESSAGE);
Cache.setProperty("LAST_DIRECTORY", choice);
SequenceI[] seqs = viewport.getAlignment().getSequencesArray();
new VCFLoader(choice).loadVCF(seqs, us);
- };
+ }
});
chooser.showOpenDialog(null);
}
+ private Rectangle lastFeatureSettingsBounds = null;
+
+ @Override
+ public void setFeatureSettingsGeometry(Rectangle bounds)
+ {
+ lastFeatureSettingsBounds = bounds;
+ }
+
+ @Override
+ public Rectangle getFeatureSettingsGeometry()
+ {
+ return lastFeatureSettingsBounds;
+ }
+
+ public void scrollTo(int row, int column)
+ {
+ alignPanel.getSeqPanel().scrollTo(row, column);
+ }
+
+ public void scrollToRow(int row)
+ {
+ alignPanel.getSeqPanel().scrollToRow(row);
+ }
+
+ public void scrollToColumn(int column)
+ {
+ alignPanel.getSeqPanel().scrollToColumn(column);
+ }
+
+ /**
+ * BH 2019 from JalviewLite
+ *
+ * get sequence feature groups that are hidden or shown
+ *
+ * @param visible
+ * true is visible
+ * @return list
+ */
+ public String[] getFeatureGroupsOfState(boolean visible)
+ {
+ jalview.api.FeatureRenderer fr = null;
+ if (alignPanel != null
+ && (fr = alignPanel.getFeatureRenderer()) != null)
+ {
+ List<String> gps = fr.getGroups(visible);
+ String[] _gps = gps.toArray(new String[gps.size()]);
+ return _gps;
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return list of feature groups on the view
+ */
+ public String[] getFeatureGroups()
+ {
+ jalview.api.FeatureRenderer fr = null;
+ if (alignPanel != null
+ && (fr = alignPanel.getFeatureRenderer()) != null)
+ {
+ List<String> gps = fr.getFeatureGroups();
+ String[] _gps = gps.toArray(new String[gps.size()]);
+ return _gps;
+ }
+ return null;
+ }
+
+ public void select(SequenceGroup sel, ColumnSelection csel,
+ HiddenColumns hidden)
+ {
+ alignPanel.getSeqPanel().selection(sel, csel, hidden, null);
+ }
+
}
class PrintThread extends Thread