ap.alignFrame.addHistoryItem(editCommand);
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
+ ap.av.notifyAlignment();
}
}
}
ap.alignFrame.addHistoryItem(caseCommand);
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
+ ap.av.notifyAlignment();
}
}
}
else if (source == autoCalculate)
{
- viewport.autoCalculateConsensus = autoCalculate.getState();
+ viewport.setAutoCalculateConsensusAndConservation(autoCalculate.getState());
}
else if (source == sortByTree)
{
// viewport.getColumnSelection().getHiddenColumns()
// != null;
updateEditMenuBar();
- originalSource.firePropertyChange("alignment", null,
- originalSource.getAlignment().getSequences());
+ originalSource.notifyAlignment();
}
/**
// != null;
updateEditMenuBar();
- originalSource.firePropertyChange("alignment", null,
- originalSource.getAlignment().getSequences());
+ originalSource.notifyAlignment();
}
AlignmentViewport getOriginatingSource(CommandI command)
viewport.getRanges().setEndSeq(viewport.getAlignment().getHeight() - 1); // BH
// 2019.04.18
viewport.getAlignment().getWidth();
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.notifyAlignment();
}
viewport.setSelectionGroup(null);
viewport.getAlignment().deleteGroup(sg);
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.notifyAlignment();
if (viewport.getAlignment().getHeight() < 1)
{
}
}
- viewport.firePropertyChange("alignment", null, al.getSequences());
+ viewport.notifyAlignment();
}
}
// if (viewport.hasHiddenColumns)
// viewport.getColumnSelection().compensateForEdits(shifts);
ranges.setStartRes(seq.findIndex(startRes) - 1);
- viewport.firePropertyChange("alignment", null, al.getSequences());
+ viewport.notifyAlignment();
}
ranges.setStartRes(seq.findIndex(startRes) - 1);
- viewport.firePropertyChange("alignment", null, al.getSequences());
+ viewport.notifyAlignment();
}
if (mappedCommand != null)
{
mappedCommand.doCommand(null);
- firePropertyChange("alignment", null, getAlignment().getSequences());
+ notifyAlignment();
// ap.scalePanelHolder.repaint();
// ap.repaint();
ap.alignFrame.addHistoryItem(cut);
PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true);
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
+ ap.av.notifyAlignment();
}
}
{
ap.av.getHistoryList().remove(command);
ap.alignFrame.updateEditMenuBar();
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
+ ap.av.notifyAlignment();
}
ap.paintAlignment(true, true);
if (editCommand != null && editCommand.getSize() > 0)
{
ap.alignFrame.addHistoryItem(editCommand);
- av.firePropertyChange("alignment", null,
- av.getAlignment().getSequences());
+ av.notifyAlignment();
}
startseq = -1;
ap.updateAnnotation();
if (av.getCodingComplement() != null)
{
- ((AlignmentViewport) av.getCodingComplement()).firePropertyChange(
- "alignment", null, ap.av.getAlignment().getSequences());
+ ((AlignmentViewport) av.getCodingComplement()).notifyAlignment();
+ // Technically, the property change is not the same because av is not necessarily getCodingComplement(),
+ // but this is the appletgui, so I am not going to worry about it. BH
+ //.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences());
}
}
Cache.loadProperties(usrPropsFile); // must do this before
+ boolean allowServices = true;
+
if (isJS)
{
j2sAppletID = Platform.getAppID(null);
// anything else!
final String jabawsUrl = aparser.getValue(ArgsParser.JABAWS);
- if (jabawsUrl != null)
+ allowServices = !("none".equals(jabawsUrl));
+ if (allowServices && jabawsUrl != null)
{
try
{
* @j2sIgnore
*/
{
- desktop.startServiceDiscovery();
+ if (allowServices)
+ desktop.startServiceDiscovery();
if (!aparser.contains("nousagestats"))
{
startUsageStats(desktop);
}
/**
- * Parse all command-line String[] arguments as well as all JavaScript-derived parameters from Info.
+ * Parse all command-line String[] arguments as well as all JavaScript-derived
+ * parameters from Info.
*
- * We allow for this method to be run from JavaScript. Basically allowing simple scripting.
+ * We allow for this method to be run from JavaScript. Basically allowing
+ * simple scripting.
*
* @param aparser
* @param isStartup
System.exit(1);
}
+ setDisplayParameters(aparser);
+
// time to open a file.
long progress = -1;
// Finally, deal with the remaining input data.
AlignFrame af = null;
- if (file != null)
+ JalviewJSApp jsApp = (isJS ? new JalviewJSApp(this, aparser) : null);
+
+ if (file == null)
+ {
+ if (isJS)
+ {
+ // JalviewJS allows sequence1 sequence2 ....
+
+ }
+ else if (!headless && Cache.getDefault("SHOW_STARTUP_FILE", true))
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+
+ // We'll only open the default file if the desktop is visible.
+ // And the user
+ // ////////////////////
+
+ file = Cache.getDefault("STARTUP_FILE",
+ Cache.getDefault("www.jalview.org",
+ "http://www.jalview.org")
+ + "/examples/exampleFile_2_7.jar");
+ if (file.equals(
+ "http://www.jalview.org/examples/exampleFile_2_3.jar"))
+ {
+ // hardwire upgrade of the startup file
+ file.replace("_2_3.jar", "_2_7.jar");
+ // and remove the stale setting
+ Cache.removeProperty("STARTUP_FILE");
+ }
+
+ protocol = DataSourceType.FILE;
+
+ if (file.indexOf("http:") > -1)
+ {
+ protocol = DataSourceType.URL;
+ }
+
+ if (file.endsWith(".jar"))
+ {
+ format = FileFormat.Jalview;
+ }
+ else
+ {
+ try
+ {
+ format = new IdentifyFile().identify(file, protocol);
+ } catch (FileFormatException e)
+ {
+ // TODO what?
+ }
+ }
+ af = fileLoader.LoadFileWaitTillLoaded(file, protocol, format);
+ }
+ }
+ else
{
if (!headless)
{
}
}
}
+
String fileFormat = (isJS
? (String) aparser.getAppletValue("format", null, true)
: null);
// TODO ?
}
- if (aparser.contains(ArgsParser.NOMENUBAR))
- {
- noMenuBar = true;
- System.out.println("CMD [nomenu] executed successfully!");
- }
-
- if (aparser.contains(ArgsParser.NOSTATUS))
- {
- noStatus = true;
- System.out.println("CMD [nostatus] executed successfully!");
- }
-
- if (aparser.contains(ArgsParser.NOANNOTATION)
- || aparser.contains(ArgsParser.NOANNOTATION2))
- {
- noAnnotation = true;
- System.out.println("CMD no-annotation executed successfully!");
- }
- if (aparser.contains(ArgsParser.NOCALCULATION))
- {
- noCalculation = true;
- System.out.println("CMD [nocalculation] executed successfully!");
- }
-
af = new FileLoader(!headless).LoadFileWaitTillLoaded(file, protocol,
format);
if (af == null)
{
- System.out.println("error");
+ System.out.println("jalview error - AlignFrame was not created");
}
else
{
}
setCurrentAlignFrame(af);
- String data = aparser.getValue(ArgsParser.COLOUR, true);
- if (data != null)
- {
- data.replaceAll("%20", " ");
-
- ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
- af.getViewport(), af.getViewport().getAlignment(), data);
-
- if (cs != null)
- {
- System.out.println(
- "CMD [-color " + data + "] executed successfully!");
- }
- af.changeColour(cs);
- }
-
- // Must maintain ability to use the groups flag
- data = aparser.getValue(ArgsParser.GROUPS, true);
- if (data != null)
- {
- af.parseFeaturesFile(data,
- AppletFormatAdapter.checkProtocol(data));
- // System.out.println("Added " + data);
- System.out.println(
- "CMD groups[-" + data + "] executed successfully!");
- }
- data = aparser.getValue(ArgsParser.FEATURES, true);
- if (data != null)
- {
- af.parseFeaturesFile(data,
- AppletFormatAdapter.checkProtocol(data));
- // System.out.println("Added " + data);
- System.out.println(
- "CMD [-features " + data + "] executed successfully!");
- }
- data = aparser.getValue(ArgsParser.ANNOTATIONS, true);
- if (data != null)
- {
- af.loadJalviewDataFile(data, null, null, null);
- // System.out.println("Added " + data);
- System.out.println(
- "CMD [-annotations " + data + "] executed successfully!");
- }
-
- // JavaScript feature
-
- if (aparser.contains(ArgsParser.SHOWOVERVIEW))
- {
- af.overviewMenuItem_actionPerformed(null);
- System.out.println("CMD [showoverview] executed successfully!");
- }
-
- // set or clear the sortbytree flag.
- if (aparser.contains(ArgsParser.SORTBYTREE))
- {
- af.getViewport().setSortByTree(true);
- if (af.getViewport().getSortByTree())
- {
- System.out.println("CMD [-sortbytree] executed successfully!");
- }
- }
-
- boolean doUpdateAnnotation = false;
- /**
- * we do this earlier in JalviewJS because of a complication with
- * SHOWOVERVIEW
- *
- * For now, just fixing this in JalviewJS.
- *
- *
- * @j2sIgnore
- *
- */
- {
- if (aparser.contains(ArgsParser.NOANNOTATION)
- || aparser.contains(ArgsParser.NOANNOTATION2))
- {
- af.getViewport().setShowAnnotation(false);
- if (!af.getViewport().isShowAnnotation())
- {
- doUpdateAnnotation = true;
- System.out
- .println("CMD no-annotation executed successfully!");
- }
- }
- }
-
- if (aparser.contains(ArgsParser.NOSORTBYTREE))
- {
- af.getViewport().setSortByTree(false);
- if (!af.getViewport().getSortByTree())
- {
- doUpdateAnnotation = true;
- System.out
- .println("CMD [-nosortbytree] executed successfully!");
- }
- }
- if (doUpdateAnnotation)
- { // BH 2019.07.24
- af.setMenusForViewport();
- af.alignPanel.updateLayout();
- }
-
- data = aparser.getValue(ArgsParser.TREE, true);
- if (data != null)
- {
- try
- {
- NewickFile nf = new NewickFile(data,
- AppletFormatAdapter.checkProtocol(data));
- af.getViewport()
- .setCurrentTree(af.showNewickTree(nf, data).getTree());
- System.out.println(
- "CMD [-tree " + data + "] executed successfully!");
- } catch (IOException ex)
- {
- System.err.println("Couldn't add tree " + data);
- ex.printStackTrace(System.err);
- }
- }
- // TODO - load PDB structure(s) to alignment JAL-629
- // (associate with identical sequence in alignment, or a specified
- // sequence)
-
+ setFrameDependentProperties(aparser, af);
+
if (isJS)
{
- new JalviewJSApp(this, aparser, af);
+ jsApp.initFromParams(af);
}
else
/**
+ "] executed successfully!");
groovyscript = null;
}
- createOutputFiles(aparser, af, format);
- }
- }
- }
- else
- {
- if (!isJS && !headless && Cache.getDefault("SHOW_STARTUP_FILE", true))
- /**
- * Java only
- *
- * @j2sIgnore
- */
- {
-
- // We'll only open the default file if the desktop is visible.
- // And the user
- // ////////////////////
-
- file = Cache.getDefault("STARTUP_FILE",
- Cache.getDefault("www.jalview.org",
- "http://www.jalview.org")
- + "/examples/exampleFile_2_7.jar");
- if (file.equals(
- "http://www.jalview.org/examples/exampleFile_2_3.jar"))
- {
- // hardwire upgrade of the startup file
- file.replace("_2_3.jar", "_2_7.jar");
- // and remove the stale setting
- Cache.removeProperty("STARTUP_FILE");
- }
-
- protocol = DataSourceType.FILE;
-
- if (file.indexOf("http:") > -1)
- {
- protocol = DataSourceType.URL;
}
-
- if (file.endsWith(".jar"))
- {
- format = FileFormat.Jalview;
+ if (!isJS || !isStartup) {
+ createOutputFiles(aparser, format);
}
- else
- {
- try
- {
- format = new IdentifyFile().identify(file, protocol);
- } catch (FileFormatException e)
- {
- // TODO what?
- }
- }
-
- af = fileLoader.LoadFileWaitTillLoaded(file, protocol, format);
-
}
}
// extract groovy arguments before anything else.
}
desktop.setInBatchMode(false);
}
-
+
+ if (jsApp != null) {
+ jsApp.callInitCallback();
+ }
}
+ /**
+ * Set general display parameters irrespective of file loading or headlessness.
+ *
+ * @param aparser
+ */
+ private void setDisplayParameters(ArgsParser aparser)
+ {
+ if (aparser.contains(ArgsParser.NOMENUBAR))
+ {
+ noMenuBar = true;
+ System.out.println("CMD [nomenu] executed successfully!");
+ }
+
+ if (aparser.contains(ArgsParser.NOSTATUS))
+ {
+ noStatus = true;
+ System.out.println("CMD [nostatus] executed successfully!");
+ }
+
+ if (aparser.contains(ArgsParser.NOANNOTATION)
+ || aparser.contains(ArgsParser.NOANNOTATION2))
+ {
+ noAnnotation = true;
+ System.out.println("CMD no-annotation executed successfully!");
+ }
+ if (aparser.contains(ArgsParser.NOCALCULATION))
+ {
+ noCalculation = true;
+ System.out.println("CMD [nocalculation] executed successfully!");
+ }
+ }
+
+
+ private void setFrameDependentProperties(ArgsParser aparser,
+ AlignFrame af)
+ {
+ String data = aparser.getValue(ArgsParser.COLOUR, true);
+ if (data != null)
+ {
+ data.replaceAll("%20", " ");
+
+ ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
+ af.getViewport(), af.getViewport().getAlignment(), data);
+
+ if (cs != null)
+ {
+ System.out.println(
+ "CMD [-color " + data + "] executed successfully!");
+ }
+ af.changeColour(cs);
+ }
+
+ // Must maintain ability to use the groups flag
+ data = aparser.getValue(ArgsParser.GROUPS, true);
+ if (data != null)
+ {
+ af.parseFeaturesFile(data,
+ AppletFormatAdapter.checkProtocol(data));
+ // System.out.println("Added " + data);
+ System.out.println(
+ "CMD groups[-" + data + "] executed successfully!");
+ }
+ data = aparser.getValue(ArgsParser.FEATURES, true);
+ if (data != null)
+ {
+ af.parseFeaturesFile(data,
+ AppletFormatAdapter.checkProtocol(data));
+ // System.out.println("Added " + data);
+ System.out.println(
+ "CMD [-features " + data + "] executed successfully!");
+ }
+ data = aparser.getValue(ArgsParser.ANNOTATIONS, true);
+ if (data != null)
+ {
+ af.loadJalviewDataFile(data, null, null, null);
+ // System.out.println("Added " + data);
+ System.out.println(
+ "CMD [-annotations " + data + "] executed successfully!");
+ }
+
+ // JavaScript feature
+
+ if (aparser.contains(ArgsParser.SHOWOVERVIEW))
+ {
+ af.overviewMenuItem_actionPerformed(null);
+ System.out.println("CMD [showoverview] executed successfully!");
+ }
+
+ // set or clear the sortbytree flag.
+ if (aparser.contains(ArgsParser.SORTBYTREE))
+ {
+ af.getViewport().setSortByTree(true);
+ if (af.getViewport().getSortByTree())
+ {
+ System.out.println("CMD [-sortbytree] executed successfully!");
+ }
+ }
+
+ boolean doUpdateAnnotation = false;
+ /**
+ * we do this earlier in JalviewJS because of a complication with
+ * SHOWOVERVIEW
+ *
+ * For now, just fixing this in JalviewJS.
+ *
+ *
+ * @j2sIgnore
+ *
+ */
+ {
+ if (noAnnotation)
+ {
+ af.getViewport().setShowAnnotation(false);
+ if (!af.getViewport().isShowAnnotation())
+ {
+ doUpdateAnnotation = true;
+ }
+ }
+ }
+
+ if (aparser.contains(ArgsParser.NOSORTBYTREE))
+ {
+ af.getViewport().setSortByTree(false);
+ if (!af.getViewport().getSortByTree())
+ {
+ doUpdateAnnotation = true;
+ System.out
+ .println("CMD [-nosortbytree] executed successfully!");
+ }
+ }
+ if (doUpdateAnnotation)
+ { // BH 2019.07.24
+ af.setMenusForViewport();
+ af.alignPanel.updateLayout();
+ }
+
+ data = aparser.getValue(ArgsParser.TREE, true);
+ if (data != null)
+ {
+ try
+ {
+ NewickFile nf = new NewickFile(data,
+ AppletFormatAdapter.checkProtocol(data));
+ af.getViewport()
+ .setCurrentTree(af.showNewickTree(nf, data).getTree());
+ System.out.println(
+ "CMD [-tree " + data + "] executed successfully!");
+ } catch (IOException ex)
+ {
+ System.err.println("Couldn't add tree " + data);
+ ex.printStackTrace(System.err);
+ }
+ }
+ // TODO - load PDB structure(s) to alignment JAL-629
+ // (associate with identical sequence in alignment, or a specified
+ // sequence)
+
+ }
/**
* Writes an output file for each format (if any) specified in the
* corresponding alignment image output.
*
* @param aparser
- * @param af
* @param format
*/
- private void createOutputFiles(ArgsParser aparser, AlignFrame af,
+ private void createOutputFiles(ArgsParser aparser,
FileFormatI format)
{
+ AlignFrame af = currentAlignFrame;
while (aparser.getSize() >= 2)
{
String outputFormat = aparser.nextValue();
// System.out.println("Jalview worker " + worker.getClass().getSimpleName()
// + " " + status);
}
-
+
+
+ private static boolean isInteractive = true;
+
+ public static boolean isInteractive()
+ {
+ return isInteractive;
+ }
+
+ public static void setInteractive(boolean tf)
+ {
+ isInteractive = tf;
+ }
+
}
import java.util.StringTokenizer;
import java.util.Vector;
+import javax.swing.SwingUtilities;
+
import jalview.api.JalviewJSApi;
import jalview.api.StructureSelectionManagerProvider;
import jalview.datamodel.Alignment;
}
- public JalviewJSApp(Jalview jalview, ArgsParser aparser, AlignFrame alf)
+ public JalviewJSApp(Jalview jalview, ArgsParser aparser)
{
Platform.setAppClass(this);
this.jalview = jalview;
this.aparser = aparser;
- initFromParams(alf);
- callInitCallback();
}
@Override
Object initjscallback = getParameterAsObject("oninit");
if (initjscallback != null)
{
- try
- {
- doSendCallback(initjscallback, new Object[0]);
- } catch (Exception e)
- {
- System.err.println("Exception when executing _oninit callback '"
- + initjscallback + "'.");
- e.printStackTrace();
- }
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ doSendCallback(initjscallback, new Object[] {this});
+ } catch (Exception e)
+ {
+ System.err.println("Exception when executing _oninit callback '"
+ + initjscallback + "'.");
+ e.printStackTrace();
+ }
+ }
+
+ });
}
}
*
* @param alf
*/
- private void initFromParams(AlignFrame alf)
+ void initFromParams(AlignFrame alf)
{
String sep = getParameter("separator");
if (sep != null && sep.length() > 0)
*/
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.ws.jws2.jabaws2.Jws2Instance;
import jalview.ws.seqfetcher.DbSourceProxy;
+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;
+
/**
* DOCUMENT ME!
*
{
public static int frameCount;
-
+
public static final int DEFAULT_WIDTH = 700;
public static final int DEFAULT_HEIGHT = 500;
public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns, int width,
int height, String sequenceSetId, String viewId)
{
-
+
id = (++frameCount);
-
+
setSize(width, height);
if (al.getDataset() == null)
viewport = new AlignViewport(al, hiddenColumns, sequenceSetId, viewId);
- alignPanel = new AlignmentPanel(this, viewport);
-
- addAlignmentPanel(alignPanel, true);
+ // JalviewJS needs to distinguish a new panel from an old one in init()
+ // alignPanel = new AlignmentPanel(this, viewport);
+ // addAlignmentPanel(alignPanel, true);
init();
}
{
viewport.hideSequence(hiddenSeqs);
}
- alignPanel = new AlignmentPanel(this, viewport);
- addAlignmentPanel(alignPanel, true);
+ // alignPanel = new AlignmentPanel(this, viewport);
+ // addAlignmentPanel(alignPanel, true);
init();
}
{
viewport = ap.av;
alignPanel = ap;
- addAlignmentPanel(ap, false);
+ // addAlignmentPanel(ap, false);
init();
}
* initalise the alignframe from the underlying viewport data and the
* configurations
*/
+
void init()
{
+
+ boolean newPanel = (alignPanel == null);
+ viewport.setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
+ if (newPanel)
+ {
+ if (Platform.isJS())
+ {
+ // need to set this up front if NOANNOTATION is
+ // used in conjunction with SHOWOVERVIEW.
+
+ // I have not determined if this is appropriate for
+ // Jalview/Java, as it means we are setting this flag
+ // for all subsequent AlignFrames. For now, at least,
+ // I am setting it to be JalviewJS-only.
+
+ boolean showAnnotation = Jalview.getInstance().getShowAnnotation();
+ viewport.setShowAnnotation(showAnnotation);
+ }
+ alignPanel = new AlignmentPanel(this, viewport);
+ }
+ addAlignmentPanel(alignPanel, newPanel);
+
// setBackground(Color.white); // BH 2019
if (!Jalview.isHeadlessMode())
{
progressBar = new ProgressBar(this.statusPanel, this.statusBar);
+ // JalviewJS options
+ statusPanel.setVisible(Jalview.getInstance().getShowStatus());
+ alignFrameMenuBar.setVisible(Jalview.getInstance().getAllowMenuBar());
}
avc = new jalview.controller.AlignViewController(this, viewport,
// modifyPID.setEnabled(false);
}
- String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT",
+ String sortby = jalview.bin.Cache.getDefault(Preferences.SORT_ALIGNMENT,
"No sort");
if (sortby.equals("Id"))
sortPairwiseMenuItem_actionPerformed(null);
}
- this.alignPanel.av
- .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
+ // BH see above
+ //
+ // this.alignPanel.av
+ // .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
setMenusFromViewport(viewport);
buildSortByAnnotationScoresMenu();
wrapMenuItem_actionPerformed(null);
}
- if (jalview.bin.Cache.getDefault("SHOW_OVERVIEW", false))
+ if (jalview.bin.Cache.getDefault(Preferences.SHOW_OVERVIEW, false))
{
this.overviewMenuItem_actionPerformed(null);
}
}
addFocusListener(new FocusAdapter()
{
+
@Override
public void focusGained(FocusEvent e)
{
* @param format
* format of file
*/
+
public void setFileName(String file, FileFormatI format)
{
fileName = file;
*
* @param file
*/
+
public void setFileObject(File file)
{
this.fileObject = file;
* Add a KeyListener with handlers for various KeyPressed and KeyReleased
* events
*/
+
void addKeyListener()
{
addKeyListener(new KeyAdapter()
{
+
@Override
public void keyPressed(KeyEvent evt)
{
switch (evt.getKeyCode())
{
- case 27: // escape key
+ case KeyEvent.VK_ESCAPE: // escape key
+ // alignPanel.deselectAllSequences();
alignPanel.deselectAllSequences();
break;
case KeyEvent.VK_LEFT:
if (evt.isAltDown() || !viewport.cursorMode)
{
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.notifyAlignment();
}
break;
case KeyEvent.VK_RIGHT:
if (evt.isAltDown() || !viewport.cursorMode)
{
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.notifyAlignment();
}
break;
}
{
ap.av.getAlignment().padGaps();
}
- ap.av.updateConservation(ap);
- ap.av.updateConsensus(ap);
- ap.av.updateStrucConsensus(ap);
+ if (Jalview.getInstance().getStartCalculations())
+ {
+ ap.av.updateConservation(ap);
+ ap.av.updateConsensus(ap);
+ ap.av.updateStrucConsensus(ap);
+ }
}
}
Desktop.getInstance().addJalviewPropertyChangeListener("services",
thisListener = new java.beans.PropertyChangeListener()
{
+
@Override
public void propertyChange(PropertyChangeEvent evt)
{
});
addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
{
+
@Override
public void internalFrameClosed(
javax.swing.event.InternalFrameEvent evt)
// Finally, build the menu once to get current service state
new Thread(new Runnable()
{
+
@Override
public void run()
{
* Configure menu items that vary according to whether the alignment is
* nucleotide or protein
*/
+
public void setGUINucleotide()
{
AlignmentI al = getViewport().getAlignment();
* operation that affects the data in the current view (selection changed,
* etc) to update the menus to reflect the new state.
*/
+
@Override
public void setMenusForViewport()
{
* @param av
* AlignViewport
*/
+
public void setMenusFromViewport(AlignViewport av)
{
padGapsMenuitem.setSelected(av.isPadGaps());
scaleLeft.setVisible(av.getWrapAlignment());
scaleRight.setVisible(av.getWrapAlignment());
annotationPanelMenuItem.setState(av.isShowAnnotation());
- /*
- * Show/hide annotations only enabled if annotation panel is shown
- */
- showAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
- hideAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
- showAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
- hideAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
+ // Show/hide annotations only enabled if annotation panel is shown
+ syncAnnotationMenuItems(av.isShowAnnotation());
viewBoxesMenuItem.setSelected(av.getShowBoxes());
viewTextMenuItem.setSelected(av.getShowText());
showNonconservedMenuItem.setSelected(av.getShowUnconserved());
applyToAllGroups.setState(av.getColourAppliesToAllGroups());
showNpFeatsMenuitem.setSelected(av.isShowNPFeats());
showDbRefsMenuitem.setSelected(av.isShowDBRefs());
- autoCalculate.setSelected(av.autoCalculateConsensus);
+ autoCalculate
+ .setSelected(av.getAutoCalculateConsensusAndConservation());
sortByTree.setSelected(av.sortByTree);
listenToViewSelections.setSelected(av.followSelection);
*
* @param b
*/
+
public void setGroovyEnabled(boolean b)
{
runGroovy.setEnabled(b);
*
* @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
*/
+
@Override
public void setProgressBar(String message, long id)
{
*
* @return true if any progress bars are still active
*/
+
@Override
public boolean operationInProgress()
{
* will cause the status bar to be hidden, with possibly undesirable flicker
* of the screen layout.
*/
+
@Override
public void setStatus(String text)
{
/*
* Added so Castor Mapping file can obtain Jalview Version
*/
+
public String getVersion()
{
return jalview.bin.Cache.getProperty("VERSION");
@Override
public void reload_actionPerformed(ActionEvent e)
{
- if (fileName != null)
+ if (fileName == null)
+ {
+ return;
+ }
+ // TODO: JAL-1108 - ensure all associated frames are closed regardless of
+ // originating file's format
+ // TODO: work out how to recover feature settings for correct view(s) when
+ // file is reloaded.
+ if (FileFormat.Jalview.equals(currentFileFormat))
{
- // TODO: JAL-1108 - ensure all associated frames are closed regardless of
- // originating file's format
- // TODO: work out how to recover feature settings for correct view(s) when
- // file is reloaded.
- if (FileFormat.Jalview.equals(currentFileFormat))
+ JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
+ for (int i = 0; i < frames.length; i++)
{
- JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
- for (int i = 0; i < frames.length; i++)
+ if (frames[i] instanceof AlignFrame && frames[i] != this
+ && ((AlignFrame) frames[i]).fileName != null
+ && ((AlignFrame) frames[i]).fileName.equals(fileName))
{
- if (frames[i] instanceof AlignFrame && frames[i] != this
- && ((AlignFrame) frames[i]).fileName != null
- && ((AlignFrame) frames[i]).fileName.equals(fileName))
+ try
+ {
+ frames[i].setSelected(true);
+ Desktop.getInstance().closeAssociatedWindows();
+ } catch (java.beans.PropertyVetoException ex)
{
- try
- {
- frames[i].setSelected(true);
- Desktop.getInstance().closeAssociatedWindows();
- } catch (java.beans.PropertyVetoException ex)
- {
- }
}
-
}
- Desktop.getInstance().closeAssociatedWindows();
- FileLoader loader = new FileLoader();
- DataSourceType protocol = fileName.startsWith("http:")
- ? DataSourceType.URL
- : DataSourceType.FILE;
- loader.LoadFile(viewport, fileName, protocol, currentFileFormat);
}
- else
- {
- Rectangle bounds = this.getBounds();
+ Desktop.getInstance().closeAssociatedWindows();
- FileLoader loader = new FileLoader();
+ FileLoader loader = new FileLoader();
+ DataSourceType protocol = fileName.startsWith("http:")
+ ? DataSourceType.URL
+ : DataSourceType.FILE;
+ loader.LoadFile(viewport, fileName, protocol, currentFileFormat);
+ }
+ else
+ {
+ Rectangle bounds = this.getBounds();
- AlignFrame newframe = null;
+ FileLoader loader = new FileLoader();
- if (fileObject == null)
- {
+ AlignFrame newframe = null;
- DataSourceType protocol = (fileName.startsWith("http:")
- ? DataSourceType.URL
- : DataSourceType.FILE);
- newframe = loader.LoadFileWaitTillLoaded(fileName, protocol,
- currentFileFormat);
- }
- else
- {
- newframe = loader.LoadFileWaitTillLoaded(fileObject,
- DataSourceType.FILE, currentFileFormat);
- }
+ if (fileObject == null)
+ {
- newframe.setBounds(bounds);
- if (featureSettings != null && featureSettings.isShowing())
+ DataSourceType protocol = (fileName.startsWith("http:")
+ ? DataSourceType.URL
+ : DataSourceType.FILE);
+ newframe = loader.LoadFileWaitTillLoaded(fileName, protocol,
+ currentFileFormat);
+ }
+ else
+ {
+ newframe = loader.LoadFileWaitTillLoaded(fileObject,
+ DataSourceType.FILE, currentFileFormat);
+ }
+
+ newframe.setBounds(bounds);
+ if (featureSettings != null && featureSettings.isShowing())
+ {
+ final Rectangle fspos = featureSettings.frame.getBounds();
+ // TODO: need a 'show feature settings' function that takes bounds -
+ // need to refactor Desktop.addFrame
+ newframe.featureSettings_actionPerformed(null);
+ final FeatureSettings nfs = newframe.featureSettings;
+ SwingUtilities.invokeLater(new Runnable()
{
- final Rectangle fspos = featureSettings.frame.getBounds();
- // TODO: need a 'show feature settings' function that takes bounds -
- // need to refactor Desktop.addFrame
- newframe.featureSettings_actionPerformed(null);
- final FeatureSettings nfs = newframe.featureSettings;
- SwingUtilities.invokeLater(new Runnable()
+
+ @Override
+ public void run()
{
- @Override
- public void run()
- {
- nfs.frame.setBounds(fspos);
- }
- });
- this.featureSettings.close();
- this.featureSettings = null;
- }
- this.closeMenuItem_actionPerformed(true);
+ nfs.frame.setBounds(fspos);
+ }
+ });
+ this.featureSettings.close();
+ this.featureSettings = null;
}
+ this.closeMenuItem_actionPerformed(true);
}
+
}
@Override
* Saves the alignment to a file with a name chosen by the user, if necessary
* warning if a file would be overwritten
*/
+
@Override
public void saveAs_actionPerformed()
{
*
* @return true if last call to saveAlignment(file, format) was successful.
*/
+
public boolean isSaveAlignmentSuccessful()
{
* @param file
* @param format
*/
+
public void saveAlignment(String file, FileFormatI format)
{
lastSaveSuccessful = true;
AlignExportSettingsI options = new AlignExportSettingsAdapter(false);
Runnable cancelAction = new Runnable()
{
+
@Override
public void run()
{
};
Runnable outputAction = new Runnable()
{
+
@Override
public void run()
{
*
* @param fileFormatName
*/
+
@Override
protected void outputText_actionPerformed(String fileFormatName)
{
AlignExportSettingsI options = new AlignExportSettingsAdapter(false);
Runnable outputAction = new Runnable()
{
+
@Override
public void run()
{
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void htmlMenuItem_actionPerformed(ActionEvent e)
{
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.
*
* @param f
*/
+
@Override
public void createPNG(File f)
{
*
* @param f
*/
+
@Override
public void createEPS(File f)
{
*
* @param f
*/
+
@Override
public void createSVG(File f)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void printMenuItem_actionPerformed(ActionEvent e)
{
chooser.setToolTipText(tooltip);
chooser.setResponseHandler(0, new Runnable()
{
+
@Override
public void run()
{
*
* @param closeAllTabs
*/
+
@Override
public void closeMenuItem_actionPerformed(boolean closeAllTabs)
{
*
* @param panelToClose
*/
+
public void closeView(AlignmentPanel panelToClose)
{
int index = tabbedPane.getSelectedIndex();
/**
* DOCUMENT ME!
*/
+
void updateEditMenuBar()
{
*
* @return alignment objects for all views
*/
+
AlignmentI[] getViewAlignments()
{
if (alignPanels != null)
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void undoMenuItem_actionPerformed(ActionEvent e)
{
// && viewport.getColumnSelection().getHiddenColumns() != null &&
// viewport.getColumnSelection()
// .getHiddenColumns().size() > 0);
- originalSource.firePropertyChange("alignment", null,
- originalSource.getAlignment().getSequences());
+ originalSource.notifyAlignment();
+
}
}
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void redoMenuItem_actionPerformed(ActionEvent e)
{
// && viewport.getColumnSelection().getHiddenColumns() != null &&
// viewport.getColumnSelection()
// .getHiddenColumns().size() > 0);
- originalSource.firePropertyChange("alignment", null,
- originalSource.getAlignment().getSequences());
+ originalSource.notifyAlignment();
+
}
}
* @param up
* DOCUMENT ME!
*/
+
public void moveSelectedSequences(boolean up)
{
SequenceGroup sg = viewport.getSelectionGroup();
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void copy_actionPerformed()
{
StringSelection ss = new StringSelection(output);
+ Desktop d = Desktop.getInstance();
try
{
- Desktop.getInstance().internalCopy = true;
+ d.internalCopy = true;
// Its really worth setting the clipboard contents
// to empty before setting the large StringSelection!!
Toolkit.getDefaultToolkit().getSystemClipboard()
hiddenCutoff, hiddenOffset);
}
- Desktop.getInstance().jalviewClipboard = new Object[] { seqs,
+ d.jalviewClipboard = new Object[] { seqs,
viewport.getAlignment().getDataset(), hiddenColumns };
setStatus(MessageManager.formatMessage(
"label.copied_sequences_to_clipboard", new Object[]
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void pasteNew_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void pasteThis_actionPerformed(ActionEvent e)
{
* @param newAlignment
* true to paste to a new alignment, otherwise add to this.
*/
+
void paste(boolean newAlignment)
{
boolean externalPaste = true;
- Desktop d = Desktop.getInstance();
try
{
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
boolean annotationAdded = false;
AlignmentI alignment = null;
+ Desktop d = Desktop.getInstance();
+
if (d.jalviewClipboard != null)
{
// The clipboard was filled from within Jalview, we must use the
}
buildSortByAnnotationScoresMenu();
}
- viewport.firePropertyChange("alignment", null,
- alignment.getSequences());
+ viewport.notifyAlignment();
if (alignPanels != null)
{
for (AlignmentPanel ap : alignPanels)
/**
* Action Cut (delete and copy) the selected region
*/
+
@Override
protected void cut_actionPerformed()
{
/**
* Performs menu option to Delete the currently selected region
*/
+
@Override
protected void delete_actionPerformed()
{
Runnable okAction = new Runnable()
{
+
@Override
public void run()
{
viewport.sendSelection();
viewport.getAlignment().deleteGroup(sg);
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.notifyAlignment();
+
if (viewport.getAlignment().getHeight() < 1)
{
try
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void deleteGroups_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void remove2RightMenuItem_actionPerformed(ActionEvent e)
{
}
}
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.notifyAlignment();
+
}
}
* @param e
* DOCUMENT ME!
*/
+
@Override
public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
{
// if (viewport.hasHiddenColumns)
// viewport.getColumnSelection().compensateForEdits(shifts);
ranges.setStartRes(seq.findIndex(startRes) - 1);
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.notifyAlignment();
+
}
* @param e
* DOCUMENT ME!
*/
+
@Override
public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
{
viewport.getAlignment()));
viewport.getRanges().setStartRes(seq.findIndex(startRes) - 1);
-
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.notifyAlignment();
}
* @param e
* DOCUMENT ME!
*/
+
@Override
public void padGapsMenuitem_actionPerformed(ActionEvent e)
{
viewport.setPadGaps(padGapsMenuitem.isSelected());
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.notifyAlignment();
+
}
/**
* @param e
* DOCUMENT ME!
*/
+
@Override
public void findMenuItem_actionPerformed(ActionEvent e)
{
/**
* Create a new view of the current alignment.
*/
+
@Override
public void newView_actionPerformed(ActionEvent e)
{
* if true then duplicate all annnotation, groups and settings
* @return new alignment panel, already displayed.
*/
+
public AlignmentPanel newView(String viewTitle, boolean copyAnnotation)
{
/*
* @param viewTitle
* @return
*/
+
protected String getNewViewName(String viewTitle)
{
int index = Desktop.getViewCount(viewport.getSequenceSetId());
* @param comps
* @return
*/
+
protected List<String> getExistingViewNames(List<Component> comps)
{
List<String> existingNames = new ArrayList<>();
/**
* Explode tabbed views into separate windows.
*/
+
@Override
public void expandViews_actionPerformed(ActionEvent e)
{
/**
* Gather views in separate windows back into a tabbed presentation.
*/
+
@Override
public void gatherViews_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void font_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void seqLimit_actionPerformed(ActionEvent e)
{
*
* @see jalview.jbgui.GAlignFrame#followHighlight_actionPerformed()
*/
+
@Override
protected void followHighlight_actionPerformed()
{
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void colourTextMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void wrapMenuItem_actionPerformed(ActionEvent e)
{
* @param toggleSeqs
* @param toggleCols
*/
+
protected void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
{
* jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.
* event.ActionEvent)
*/
+
@Override
public void hideAllButSelection_actionPerformed(ActionEvent e)
{
* jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event
* .ActionEvent)
*/
+
@Override
public void hideAllSelection_actionPerformed(ActionEvent e)
{
* jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.
* ActionEvent)
*/
+
@Override
public void showAllhidden_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void scaleAbove_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void scaleLeft_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void scaleRight_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void viewTextMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
{
* @param evt
* DOCUMENT ME!
*/
+
@Override
public void showSeqFeatures_actionPerformed(ActionEvent evt)
{
*
* @param e
*/
+
@Override
public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
{
final boolean setVisible = annotationPanelMenuItem.isSelected();
viewport.setShowAnnotation(setVisible);
- this.showAllSeqAnnotations.setEnabled(setVisible);
- this.hideAllSeqAnnotations.setEnabled(setVisible);
- this.showAllAlAnnotations.setEnabled(setVisible);
- this.hideAllAlAnnotations.setEnabled(setVisible);
+ syncAnnotationMenuItems(setVisible);
alignPanel.updateLayout();
+ repaint();
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run()
+ {
+ alignPanel.updateScrollBarsFromRanges();
+ }
+
+ });
+ }
+
+ private void syncAnnotationMenuItems(boolean setVisible)
+ {
+ showAllSeqAnnotations.setEnabled(setVisible);
+ hideAllSeqAnnotations.setEnabled(setVisible);
+ showAllAlAnnotations.setEnabled(setVisible);
+ hideAllAlAnnotations.setEnabled(setVisible);
}
@Override
* @param e
* DOCUMENT ME!
*/
+
@Override
public void overviewMenuItem_actionPerformed(ActionEvent e)
{
"resize") != "none");
Desktop.addInternalFrame(frame, MessageManager
.formatMessage("label.overview_params", new Object[]
- { this.getTitle() }), Desktop.FRAME_MAKE_VISIBLE, dim.width, dim.height, resizable,
- Desktop.FRAME_ALLOW_ANY_SIZE);
+ { this.getTitle() }), Desktop.FRAME_MAKE_VISIBLE, dim.width,
+ dim.height, resizable, Desktop.FRAME_ALLOW_ANY_SIZE);
frame.pack();
frame.setLayer(JLayeredPane.PALETTE_LAYER);
frame.addInternalFrameListener(
new javax.swing.event.InternalFrameAdapter()
{
+
@Override
public void internalFrameClosed(
javax.swing.event.InternalFrameEvent evt)
* CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation
* ()[0])); }
*/
+
@Override
public void annotationColour_actionPerformed()
{
*
* @param selected
*/
+
@Override
public void applyToAllGroups_actionPerformed(boolean selected)
{
* @param name
* the name (not the menu item label!) of the colour scheme
*/
+
@Override
public void changeColour_actionPerformed(String name)
{
*
* @param cs
*/
+
@Override
public void changeColour(ColourSchemeI cs)
{
/**
* Show the PID threshold slider panel
*/
+
@Override
protected void modifyPID_actionPerformed()
{
/**
* Show the Conservation slider panel
*/
+
@Override
protected void modifyConservation_actionPerformed()
{
/**
* Action on selecting or deselecting (Colour) By Conservation
*/
+
@Override
public void conservationMenuItem_actionPerformed(boolean selected)
{
/**
* Action on selecting or deselecting (Colour) Above PID Threshold
*/
+
@Override
public void abovePIDThreshold_actionPerformed(boolean selected)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void sortIDMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void sortLengthMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void sortGroupMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
{
* @param e
* DOCUMENT ME!
*/
+
@Override
public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
{
@Override
public void autoCalculate_actionPerformed(ActionEvent e)
{
- viewport.autoCalculateConsensus = autoCalculate.isSelected();
- if (viewport.autoCalculateConsensus)
+ viewport.setAutoCalculateConsensusAndConservation(
+ autoCalculate.isSelected());
+ if (viewport.getAutoCalculateConsensusAndConservation())
+ // ??
+ // viewport.autoCalculateConsensus = autoCalculate.isSelected();
+ // if (viewport.autoCalculateConsensus)
{
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.notifyAlignment();
}
}
* @param options
* parameters for the distance or similarity calculation
*/
+
void newTreePanel(String type, String modelName,
SimilarityParamsI options)
{
* @param order
* DOCUMENT ME!
*/
+
public void addSortByOrderMenuItem(String title,
final AlignmentOrder order)
{
sort.add(item);
item.addActionListener(new java.awt.event.ActionListener()
{
+
@Override
public void actionPerformed(ActionEvent e)
{
* the label used to retrieve scores for each sequence on the
* alignment
*/
+
public void addSortByAnnotScoreMenuItem(JMenu sort,
final String scoreLabel)
{
sort.add(item);
item.addActionListener(new java.awt.event.ActionListener()
{
+
@Override
public void actionPerformed(ActionEvent e)
{
* rebuilding in subsequence calls.
*
*/
+
@Override
public void buildSortByAnnotationScoresMenu()
{
* closed, and adjust the tree leaf to sequence mapping when the alignment is
* modified.
*/
+
@Override
public void buildTreeSortMenu()
{
final JMenuItem item = new JMenuItem(tp.getTitle());
item.addActionListener(new java.awt.event.ActionListener()
{
+
@Override
public void actionPerformed(ActionEvent e)
{
* be submitted for multiple alignment.
*
*/
+
public jalview.datamodel.AlignmentView gatherSequencesForAlignment()
{
// Now, check we have enough sequences
* region or the whole alignment. (where the first sequence in the set is the
* one that the prediction will be for).
*/
+
public AlignmentView gatherSeqOrMsaForSecStrPrediction()
{
AlignmentView seqs = null;
* @param e
* DOCUMENT ME!
*/
+
@Override
protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
{
chooser.setResponseHandler(0, new Runnable()
{
+
@Override
public void run()
{
* position
* @return TreePanel handle
*/
+
public TreePanel showNewickTree(NewickFile nf, String treeTitle,
AlignmentView input, int w, int h, int x, int y)
{
* Generates menu items and listener event actions for web service clients
*
*/
+
public void BuildWebServiceMenu()
{
while (buildingMenu)
buildingMenu = true;
new Thread(new Runnable()
{
+
@Override
public void run()
{
// JAL-940 - only show secondary structure prediction services from
// the legacy server
Hashtable<String, Vector<ServiceHandle>> ds = Discoverer
- .getServices();
-
+ .getInstance().getServices();
if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
// &&
ds != null && (ds.size() > 0))
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+
@Override
public void run()
{
webService.add(me.webServiceNoServices);
}
// TODO: move into separate menu builder class.
- boolean new_sspred = false;
+ // boolean new_sspred = false;
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
Jws2Discoverer jws2servs = Jws2Discoverer.getInstance();
*
* @param webService
*/
+
protected void build_urlServiceMenu(JMenu webService)
{
// TODO: remove this code when 2.7 is released
* JMenuItem testAlView = new JMenuItem("Test AlignmentView"); final
* AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
*
- * @Override public void actionPerformed(ActionEvent e) {
+ * public void actionPerformed(ActionEvent e) {
* jalview.datamodel.AlignmentView
* .testSelectionViews(af.viewport.getAlignment(),
* af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
*
* @return true if Show Cross-references menu should be enabled
*/
+
public boolean canShowProducts()
{
SequenceI[] seqs = viewport.getAlignment().getSequencesArray();
JMenuItem xtype = new JMenuItem(source);
xtype.addActionListener(new ActionListener()
{
+
@Override
public void actionPerformed(ActionEvent e)
{
* @param source
* the database to show cross-references for
*/
+
protected void showProductsFor(final SequenceI[] sel, final boolean _odna,
final String source)
{
* Construct and display a new frame containing the translation of this
* frame's DNA sequences to their aligned protein (amino acid) equivalents.
*/
+
@Override
public void showTranslation_actionPerformed(GeneticCodeI codeTable)
{
*
* @param format
*/
+
public void setFileFormat(FileFormatI format)
{
this.currentFileFormat = format;
* access mode of file (see jalview.io.AlignFile)
* @return true if features file was parsed correctly.
*/
+
public boolean parseFeaturesFile(Object file, DataSourceType sourceType)
{
// BH 2018
return avc.parseFeaturesFile(file, sourceType,
- Cache.getDefault("RELAXEDSEQIDMATCHING", false));
+ Cache.getDefault(Preferences.RELAXEDSEQIDMATCHING, false));
}
{
new Thread(new Runnable()
{
+
@Override
public void run()
{
int assocfiles = 0;
if (filesmatched.size() > 0)
{
- boolean autoAssociate = Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS",
- false);
+ boolean autoAssociate = Cache
+ .getDefault(Preferences.AUTOASSOCIATE_PDBANDSEQS, false);
if (!autoAssociate)
{
String msg = MessageManager.formatMessage(
// 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());
+ PDBEntry pe = AssociatePdbFileWithSeq.associatePdbWithSeq(
+ fm[0].toString(), (DataSourceType) fm[1], toassoc,
+ false);
if (pe != null)
{
System.err.println("Associated file : " + (fm[0].toString())
* @param file
* either a filename or a URL string.
*/
+
public void loadJalviewDataFile(Object file, DataSourceType sourceType,
FileFormatI format, SequenceI assocSeq)
{
* @param state
* visible or invisible
*/
+
public void setFeatureGroupState(String[] groups, boolean state)
{
jalview.api.FeatureRenderer fr = null;
* Method invoked by the ChangeListener on the tabbed pane, in other words
* when a different tabbed pane is selected by the user or programmatically.
*/
+
@Override
public void tabSelectionChanged(int index)
{
/**
* On right mouse click on view tab, prompt for and set new view name.
*/
+
@Override
public void tabbedPane_mousePressed(MouseEvent e)
{
/**
* Open the dialog for regex description parsing.
*/
+
@Override
protected void extractScores_actionPerformed(ActionEvent e)
{
* jalview.jbgui.GAlignFrame#showDbRefs_actionPerformed(java.awt.event.ActionEvent
* )
*/
+
@Override
protected void showDbRefs_actionPerformed(ActionEvent e)
{
* @seejalview.jbgui.GAlignFrame#showNpFeats_actionPerformed(java.awt.event.
* ActionEvent)
*/
+
@Override
protected void showNpFeats_actionPerformed(ActionEvent e)
{
*
* @param av
*/
+
public boolean closeView(AlignViewportI av)
{
if (viewport == av)
Cache.getDefault(DBRefFetcher.TRIM_RETRIEVED_SEQUENCES, true));
trimrs.addActionListener(new ActionListener()
{
+
@Override
public void actionPerformed(ActionEvent e)
{
{
new Thread(new Runnable()
{
+
@Override
public void run()
{
alignPanel.alignFrame.featureSettings, isNucleotide);
dbRefFetcher.addListener(new FetchFinishedListenerI()
{
+
@Override
public void finished()
{
rfetch.add(fetchr);
new Thread(new Runnable()
{
+
@Override
public void run()
{
- final jalview.ws.SequenceFetcher sf = jalview.gui.SequenceFetcher
- .getSequenceFetcherSingleton();
+ // ??
+ // final jalview.ws.SequenceFetcher sf = jalview.gui.SequenceFetcher
+ // .getSequenceFetcherSingleton();
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+
@Override
public void run()
{
+ jalview.ws.SequenceFetcher sf = jalview.ws.SequenceFetcher
+ .getInstance();
String[] dbclasses = sf.getNonAlignmentSources();
List<DbSourceProxy> otherdb;
JMenu dfetch = new JMenu();
}
if (otherdb.size() == 1)
{
- final DbSourceProxy[] dassource = otherdb
- .toArray(new DbSourceProxy[0]);
DbSourceProxy src = otherdb.get(0);
+ DbSourceProxy[] dassource = new DbSourceProxy[] { src };
fetchr = new JMenuItem(src.getDbSource());
fetchr.addActionListener(new ActionListener()
{
dbRefFetcher
.addListener(new FetchFinishedListenerI()
{
+
@Override
public void finished()
{
{ src.getDbSource() }));
fetchr.addActionListener(new ActionListener()
{
+
@Override
public void actionPerformed(ActionEvent e)
{
dbRefFetcher
.addListener(new FetchFinishedListenerI()
{
+
@Override
public void finished()
{
dbRefFetcher
.addListener(new FetchFinishedListenerI()
{
+
@Override
public void finished()
{
/**
* Left justify the whole alignment.
*/
+
@Override
protected void justifyLeftMenuItem_actionPerformed(ActionEvent e)
{
- AlignmentI al = viewport.getAlignment();
- al.justify(false);
- viewport.firePropertyChange("alignment", null, al);
+ viewport.getAlignment().justify(false);
+ viewport.notifyAlignment();
}
/**
* Right justify the whole alignment.
*/
+
@Override
protected void justifyRightMenuItem_actionPerformed(ActionEvent e)
{
- AlignmentI al = viewport.getAlignment();
- al.justify(true);
- viewport.firePropertyChange("alignment", null, al);
+ viewport.getAlignment().justify(true);
+ viewport.notifyAlignment();
}
@Override
* jalview.jbgui.GAlignFrame#showUnconservedMenuItem_actionPerformed(java.
* awt.event.ActionEvent)
*/
+
@Override
protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
{
* jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event
* .ActionEvent)
*/
+
@Override
protected void showGroupConsensus_actionPerformed(ActionEvent e)
{
* jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt
* .event.ActionEvent)
*/
+
@Override
protected void showGroupConservation_actionPerformed(ActionEvent e)
{
* jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
* .event.ActionEvent)
*/
+
@Override
protected void showConsensusHistogram_actionPerformed(ActionEvent e)
{
* jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
* .event.ActionEvent)
*/
+
@Override
protected void showSequenceLogo_actionPerformed(ActionEvent e)
{
* jalview.jbgui.GAlignFrame#makeGrpsFromSelection_actionPerformed(java.awt
* .event.ActionEvent)
*/
+
@Override
protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
{
*
* @param alignmentPanel
*/
+
public void setDisplayedView(AlignmentPanel alignmentPanel)
{
if (!viewport.getSequenceSetId()
* @param forAlignment
* update non-sequence-related annotations
*/
+
@Override
protected void setAnnotationsVisibility(boolean visible,
boolean forSequences, boolean forAlignment)
/**
* Store selected annotation sort order for the view and repaint.
*/
+
@Override
protected void sortAnnotations_actionPerformed()
{
*
* @return alignment panels in this alignment frame
*/
+
public List<? extends AlignmentViewPanel> getAlignPanels()
{
// alignPanels is never null
* Open a new alignment window, with the cDNA associated with this (protein)
* alignment, aligned as is the protein.
*/
+
protected void viewAsCdna_actionPerformed()
{
// TODO no longer a menu action - refactor as required
*
* @param show
*/
+
@Override
protected void showComplement_actionPerformed(boolean show)
{
* Generate the reverse (optionally complemented) of the selected sequences,
* and add them to the alignment
*/
+
@Override
protected void showReverse_actionPerformed(boolean complement)
{
* AlignFrame is set as currentAlignFrame in Desktop, to allow the script to
* be targeted at this alignment.
*/
+
@Override
protected void runGroovy_actionPerformed()
{
* @param columnsContaining
* @return
*/
+
public boolean hideFeatureColumns(String featureType,
boolean columnsContaining)
{
* Rebuilds the Colour menu, including any user-defined colours which have
* been loaded either on startup or during the session
*/
+
public void buildColourMenu()
{
colourMenu.removeAll();
* Open a dialog (if not already open) that allows the user to select and
* calculate PCA or Tree analysis
*/
+
protected void openTreePcaDialog()
{
if (alignPanel.getCalculationDialog() == null)
final AlignFrame us = this;
chooser.setResponseHandler(0, new Runnable()
{
+
@Override
public void run()
{
* true is visible
* @return list
*/
+
public String[] getFeatureGroupsOfState(boolean visible)
{
jalview.api.FeatureRenderer fr = null;
*
* @return list of feature groups on the view
*/
+
public String[] getFeatureGroups()
{
jalview.api.FeatureRenderer fr = null;
alignPanel.getSeqPanel().selection(sel, csel, hidden, null);
}
-
public int getID()
{
return id;
}
-}
-
-class PrintThread extends Thread
-{
- AlignmentPanel ap;
-
- public PrintThread(AlignmentPanel ap)
- {
- this.ap = ap;
- }
-
- static PageFormat pf;
-
- @Override
- public void run()
+ static class PrintThread extends Thread
{
- PrinterJob printJob = PrinterJob.getPrinterJob();
+ AlignmentPanel ap;
- if (pf != null)
- {
- printJob.setPrintable(ap, pf);
- }
- else
+ public PrintThread(AlignmentPanel ap)
{
- printJob.setPrintable(ap);
+ this.ap = ap;
}
- if (printJob.printDialog())
+ static PageFormat pf;
+
+ @Override
+ public void run()
{
- try
+ PrinterJob printJob = PrinterJob.getPrinterJob();
+
+ if (pf != null)
{
- printJob.print();
- } catch (Exception PrintException)
+ printJob.setPrintable(ap, pf);
+ }
+ else
{
- PrintException.printStackTrace();
+ printJob.setPrintable(ap);
+ }
+
+ if (printJob.printDialog())
+ {
+ try
+ {
+ printJob.print();
+ } catch (Exception PrintException)
+ {
+ PrintException.printStackTrace();
+ }
}
}
}
}
+
setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
- autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
+ autoCalculateConsensusAndConservation = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
setPadGaps(Cache.getDefault("PAD_GAPS", true));
setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
}
ranges.setEndSeq(getAlignment().getHeight() - 1); // BH 2019.04.18
- firePropertyChange("alignment", null, getAlignment().getSequences());
+ notifyAlignment();
+
}
/**
{
this.viewName = viewName;
}
+
}
*/
package jalview.gui;
-import jalview.analysis.AnnotationSorter;
-import jalview.api.AlignViewportI;
-import jalview.api.AlignmentViewPanel;
-import jalview.bin.Cache;
-import jalview.bin.Jalview;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.HiddenColumns;
-import jalview.datamodel.SearchResultsI;
-import jalview.datamodel.SequenceFeature;
-import jalview.datamodel.SequenceGroup;
-import jalview.datamodel.SequenceI;
-import jalview.gui.ImageExporter.ImageWriterI;
-import jalview.io.HTMLOutput;
-import jalview.jbgui.GAlignmentPanel;
-import jalview.math.AlignmentDimension;
-import jalview.schemes.ResidueProperties;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.Comparison;
-import jalview.util.ImageMaker;
-import jalview.util.MessageManager;
-import jalview.viewmodel.ViewportListenerI;
-import jalview.viewmodel.ViewportRanges;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
-import java.util.ArrayList;
import java.util.List;
import javax.swing.SwingUtilities;
+import jalview.analysis.AnnotationSorter;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.SearchResultsI;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.gui.ImageExporter.ImageWriterI;
+import jalview.io.HTMLOutput;
+import jalview.jbgui.GAlignmentPanel;
+import jalview.math.AlignmentDimension;
+import jalview.schemes.ResidueProperties;
+import jalview.structure.StructureSelectionManager;
+import jalview.util.Comparison;
+import jalview.util.ImageMaker;
+import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
+
/**
* DOCUMENT ME!
*
*/
public AlignmentPanel(AlignFrame af, final AlignViewport av)
{
-// setBackground(Color.white); // BH 2019
+ // setBackground(Color.white); // BH 2019
alignFrame = af;
this.av = av;
setSeqPanel(new SeqPanel(av, this));
ranges.setViewportWidth(widthInRes);
ranges.setViewportHeight(heightInSeq);
}
+ repaint();
}
});
@Override
public void propertyChange(PropertyChangeEvent evt)
{
- if (evt.getPropertyName().equals("alignment"))
- {
+ switch (evt.getPropertyName()) {
+ case AlignmentViewport.PROPERTY_SEQUENCE:
+ updateScrollBarsFromRanges();
+ if (annotationPanel != null)
+ annotationPanel.paintImmediately(0, 0, getWidth(), getHeight());
+ break;
+ case AlignmentViewport.PROPERTY_ALIGNMENT:
+ updateScrollBarsFromRanges();
PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
alignmentChanged();
+ break;
}
}
};
int oldWidth = av.getIdWidth();
// calculate sensible default width when no preference is available
- Dimension r = null;
+ Dimension d = null;
if (av.getIdWidth() < 0)
{
- int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
- int idWidth = Math.min(afwidth - 200, 2 * afwidth / 3);
- int maxwidth = Math.max(IdwidthAdjuster.MIN_ID_WIDTH, idWidth);
- r = calculateIdWidth(maxwidth);
- av.setIdWidth(r.width);
+ int maxWidth = getMaxWidth();
+ d = calculateIdWidth(maxWidth);
+ av.setIdWidth(d.width);
}
else
{
- r = new Dimension();
- r.width = av.getIdWidth();
- r.height = 0;
+ d = new Dimension();
+ d.width = av.getIdWidth();
+ d.height = 0;
}
/*
* fudge: if desired width has changed, update layout
* (see also paintComponent - updates layout on a repaint)
*/
- if (r.width != oldWidth)
+ if (d.width != oldWidth)
{
- idPanelHolder.setPreferredSize(r);
+ idPanelHolder.setPreferredSize(d);
validate();
}
- return r;
+ return d;
+ }
+
+ public int getMaxWidth()
+ {
+ int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
+ int idWidth = Math.min(afwidth - 200, 2 * afwidth / 3);
+ return Math.max(IdwidthAdjuster.MIN_ID_WIDTH, idWidth);
}
/**
* @return Dimension giving the maximum width of the alignment label panel
* that should be used.
*/
- protected Dimension calculateIdWidth(int maxwidth)
+ public Dimension calculateIdWidth(int maxwidth)
{
- Container c = new Container();
-
+ Container c = this;// new Container();
FontMetrics fm = c.getFontMetrics(
new Font(av.font.getName(), Font.ITALIC, av.font.getSize()));
int i = 0;
int idWidth = 0;
+ boolean withSuffix = av.getShowJVSuffix();
+
while ((i < al.getHeight()) && (al.getSequenceAt(i) != null))
{
SequenceI s = al.getSequenceAt(i);
- String id = s.getDisplayId(av.getShowJVSuffix());
+ String id = s.getDisplayId(withSuffix);
int stringWidth = fm.stringWidth(id);
idWidth = Math.max(idWidth, stringWidth);
i++;
/*
* Scroll down to make end of search results visible
*/
- setScrollValues(ranges.getStartRes(), starts + seqIndex - ends
- + 1);
+ setScrollValues(ranges.getStartRes(), starts + seqIndex - ends + 1);
}
/*
* Else results are already visible - no need to scroll
Dimension e = idPanel.getSize();
alabels.setSize(new Dimension(e.width, annotationHeight));
-
annotationSpaceFillerHolder.setPreferredSize(new Dimension(
annotationSpaceFillerHolder.getWidth(), annotationHeight));
annotationScroller.validate();
*/
public void updateLayout()
{
+ ViewportRanges ranges = av.getRanges();
fontChanged();
setAnnotationVisible(av.isShowAnnotation());
boolean wrap = av.getWrapAlignment();
- ViewportRanges ranges = av.getRanges();
ranges.setStartSeq(0);
scalePanelHolder.setVisible(!wrap);
hscroll.setVisible(!wrap);
x = 0;
}
- // update the scroll values
- hscroll.setValues(x, hextent, 0, width);
- vscroll.setValues(y, vextent, 0, height);
+ updateRanges(x, y);
+ updateScrollBars(x, y, width, height);
}
}
+ private void updateScrollBars(int x, int y, int width, int height)
+ {
+ hscroll.setValues(x, hextent, 0, width);
+ vscroll.setValues(y, vextent, 0, height);
+ }
+
/**
* Respond to adjustment event when horizontal or vertical scrollbar is
* changed
return;
}
- ViewportRanges ranges = av.getRanges();
-
if (evt.getSource() == hscroll)
{
+ if (!updateRanges(hscroll.getValue(), Integer.MIN_VALUE))
+ return;
+ }
+ else if (evt.getSource() == vscroll)
+ {
+ if (!updateRanges(Integer.MIN_VALUE, vscroll.getValue()))
+ return;
+ }
+ repaint();
+ }
+
+ private boolean updateRanges(int x, int y)
+ {
+ ViewportRanges ranges = av.getRanges();
+ boolean isChanged = false;
+ if (x != Integer.MIN_VALUE)
+ {
int oldX = ranges.getStartRes();
int oldwidth = ranges.getViewportWidth();
- int x = hscroll.getValue();
int width = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
// if we're scrolling to the position we're already at, stop
// this prevents infinite recursion of events when the scroll/viewport
// ranges values are the same
- if ((x == oldX) && (width == oldwidth))
+ if (width > 0 && (x != oldX || width != oldwidth))
{
- return;
+ ranges.setViewportStartAndWidth(x, width);
+ isChanged = true;
}
- ranges.setViewportStartAndWidth(x, width);
}
- else if (evt.getSource() == vscroll)
+ if (y != Integer.MIN_VALUE)
{
int oldY = ranges.getStartSeq();
int oldheight = ranges.getViewportHeight();
- int y = vscroll.getValue();
int height = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight();
// if we're scrolling to the position we're already at, stop
// this prevents infinite recursion of events when the scroll/viewport
// ranges values are the same
- if ((y == oldY) && (height == oldheight))
+ if (height > 0 && (y != oldY || height != oldheight))
{
- return;
+ ranges.setViewportStartAndHeight(y, height);
+ isChanged = true;
}
- ranges.setViewportStartAndHeight(y, height);
}
- repaint();
+ return isChanged;
}
/**
av.isShowAutocalculatedAbove());
sorter.sort(getAlignment().getAlignmentAnnotation(),
av.getSortAnnotationsBy());
- repaint();
if (updateStructures)
{
}
if (updateOverview)
{
+ alignFrame.repaint();
if (overviewPanel != null)
{
overviewPanel.updateOverviewImage();
}
+ } else {
+ repaint();
}
}
* though I still think this call should be elsewhere.
*/
ViewportRanges ranges = av.getRanges();
- setScrollValues(ranges.getStartRes(), ranges.getStartSeq());
+ // setScrollValues(ranges.getStartRes(), ranges.getStartSeq());
super.paintComponent(g);
}
* single graphics context), then reset to (0, scale height)
*/
alignmentGraphics.translate(alignmentGraphicsOffset, scaleHeight);
- getSeqPanel().seqCanvas.drawPanelForPrinting(alignmentGraphics, startRes,
- endRes, startSeq, endSeq - 1);
+ getSeqPanel().seqCanvas.drawPanelForPrinting(alignmentGraphics,
+ startRes, endRes, startSeq, endSeq - 1);
alignmentGraphics.translate(-alignmentGraphicsOffset, 0);
if (av.isShowAnnotation() && (endSeq == alignmentHeight))
*
* @throws PrinterException
*/
- public int printWrappedAlignment(int pageWidth, int pageHeight, int pageNumber,
- Graphics g) throws PrinterException
+ public int printWrappedAlignment(int pageWidth, int pageHeight,
+ int pageNumber, Graphics g) throws PrinterException
{
getSeqPanel().seqCanvas.calculateWrappedGeometry();
int annotationHeight = 0;
g.translate(idWidth, 0);
- getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g, pageWidth - idWidth,
- totalHeight, 0);
+ getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g,
+ pageWidth - idWidth, totalHeight, 0);
if ((pageNumber * pageHeight) < totalHeight)
{
String triplet = null;
if (av.getAlignment().isNucleotide())
{
- triplet = ResidueProperties.nucleotideName.get(seq
- .getCharAt(column) + "");
+ triplet = ResidueProperties.nucleotideName
+ .get(seq.getCharAt(column) + "");
}
else
{
- triplet = ResidueProperties.aa2Triplet.get(seq.getCharAt(column)
- + "");
+ triplet = ResidueProperties.aa2Triplet
+ .get(seq.getCharAt(column) + "");
}
if (triplet == null)
text.append("<area shape=\"rect\" coords=\"")
.append((idWidth + column * av.getCharWidth()))
.append(",").append(sy).append(",")
- .append((idWidth + (column + 1) * av.getCharWidth()))
+ .append((idWidth
+ + (column + 1) * av.getCharWidth()))
.append(",").append((av.getCharHeight() + sy))
.append("\"").append(" onMouseOver=\"toolTip('")
.append(seqPos).append(" ").append(triplet);
}
if (!Comparison.isGap(seq.getCharAt(column)))
{
- List<SequenceFeature> features = seq.findFeatures(column, column);
+ List<SequenceFeature> features = seq.findFeatures(column,
+ column);
for (SequenceFeature sf : features)
{
if (sf.isContactFeature())
public void propertyChange(PropertyChangeEvent evt)
{
// update this panel's scroll values based on the new viewport ranges values
- ViewportRanges ranges = av.getRanges();
- int x = ranges.getStartRes();
- int y = ranges.getStartSeq();
- setScrollValues(x, y);
+ updateScrollBarsFromRanges();
// now update any complementary alignment (its viewport ranges object
// is different so does not get automatically updated)
}
}
+ void updateScrollBarsFromRanges()
+ {
+ ViewportRanges ranges = av.getRanges();
+ setScrollValues(ranges.getStartRes(), ranges.getStartSeq());
+ }
+
/**
* Set the reference to the PCA/Tree chooser dialog for this panel. This
* reference should be nulled when the dialog is closed.
PaintRefresher.Refresh(this, av.getSequenceSetId());
}
- public void selectSequences(List<SequenceI> seqs)
+ public void selectSequences(List<SequenceI> seqs)
{
SequenceGroup sg = new SequenceGroup(seqs);
sg.setEndRes(av.getAlignment().getWidth() - 1);
g.setColor(Color.white);
g.fillRect(0, 0, visibleRect.width, visibleRect.height);
+ ViewportRanges ranges = av.getRanges();
+
+
+
if (image != null)
{
// BH 2018 optimizing generation of new Rectangle().
if (fastPaint || (visibleRect.width != (clipBounds = g.getClipBounds(clipBounds)).width)
|| (visibleRect.height != clipBounds.height))
{
-
-
g.drawImage(image, 0, 0, this);
fastPaint = false;
return;
}
}
- imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes()
+
+ imgWidth = (ranges.getEndRes() - ranges.getStartRes()
+ 1) * av.getCharWidth();
+
if (imgWidth < 1)
{
+ fastPaint = false;
return;
}
Graphics2D gg;
gg = (Graphics2D) image.getGraphics();
}
-
- drawComponent(gg, av.getRanges().getStartRes(),
+
+ drawComponent(gg, ranges.getStartRes(),
av.getRanges().getEndRes() + 1);
gg.dispose();
imageFresh = false;
}
/**
- * set true to enable redraw timing debug output on stderr
- */
- private final boolean debugRedraw = false;
-
- /**
* non-Thread safe repaint
*
* @param horizontal
int sr = av.getRanges().getStartRes();
int er = av.getRanges().getEndRes() + 1;
int transX = 0;
+
+ if (er == sr + 1) {
+ fastPaint = false;
+ return;
+ }
Graphics2D gg = (Graphics2D) image.getGraphics();
*/
package jalview.gui;
-import jalview.api.StructureSelectionManagerProvider;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
import jalview.io.StructureFile;
-import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
-import javax.swing.JOptionPane;
-
/**
- * GUI related routines for associating PDB files with sequences
+ * GUI related routines for associating PDB files with sequences. A single
+ * static method.
*
* @author JimP
*
public class AssociatePdbFileWithSeq
{
+ private AssociatePdbFileWithSeq()
+ {
+ // inaccessible
+ }
+
/**
- * assocate the given PDB file with
+ * Associate the given PDB file name or URL with a sequence. Do not map
+ * mouse-over events.
*
- * @param choice
+ * @param fileName
+ * or URL
+ * @param type
+ * will be DataType.FILE or DataType.URL
* @param sequence
+ * to associate
+ * @param prompt
+ * true if the user should be asked what to do if the specified file
+ * does not seem to contain PDB information (StructureChooser only)
+ * @return null if file is not found
*/
- public PDBEntry associatePdbWithSeq(String choice, DataSourceType file,
- SequenceI sequence, boolean prompt,
- StructureSelectionManagerProvider ssmp)
+ public static PDBEntry associatePdbWithSeq(String fileName,
+ DataSourceType type, SequenceI sequence, boolean prompt)
{
PDBEntry entry = new PDBEntry();
StructureFile pdbfile = null;
- pdbfile = StructureSelectionManager.getStructureSelectionManager(ssmp)
+ pdbfile = Desktop.getStructureSelectionManager()
.setMapping(false, new SequenceI[]
- { sequence }, null, choice, file);
+ { sequence }, null, fileName, type);
if (pdbfile == null)
{
// stacktrace already thrown so just return
return null;
}
- if (pdbfile.getId() == null)
- {
- String reply = null;
-
- if (prompt)
- {
- reply = JvOptionPane.showInternalInputDialog(Desktop.getDesktopPane(),
- MessageManager
- .getString("label.couldnt_find_pdb_id_in_file"),
- MessageManager.getString("label.no_pdb_id_in_file"),
- JvOptionPane.QUESTION_MESSAGE);
- }
- if (reply == null)
- {
- return null;
- }
-
- entry.setId(reply);
- }
- else
+ String id = pdbfile.getId();
+ if (id == null && (id = (prompt
+ ? JvOptionPane.showInternalInputDialog(Desktop.getDesktopPane(),
+ MessageManager
+ .getString("label.couldnt_find_pdb_id_in_file"),
+ MessageManager.getString("label.no_pdb_id_in_file"),
+ JvOptionPane.QUESTION_MESSAGE)
+ : null)) == null)
{
- entry.setId(pdbfile.getId());
+ return null;
}
+ entry.setId(id);
entry.setType(PDBEntry.Type.FILE);
-
- if (pdbfile != null)
- {
- entry.setFile(choice);
- sequence.getDatasetSequence().addPDBId(entry);
- StructureSelectionManager.getStructureSelectionManager(ssmp)
- .registerPDBEntry(entry);
- }
+ entry.setFile(fileName);
+ sequence.getDatasetSequence().addPDBId(entry);
+ Desktop.getStructureSelectionManager()
+ .registerPDBEntry(entry);
return entry;
}
}
experimentalFeatures.setSelected(showExperimental());
- checkURLLinks();
+ if (Jalview.isInteractive())
+ {
+ // disabled for SeqCanvasTest
+ checkURLLinks();
- // Spawn a thread that shows the splashscreen
+ checkURLLinks();
- SwingUtilities.invokeLater(new Runnable()
- {
- @Override
- public void run()
- {
- new SplashScreen(true);
- }
- });
+ // Spawn a thread that shows the splashscreen
- // Thread off a new instance of the file chooser - this reduces the time
- // it
- // takes to open it later on.
- new Thread(new Runnable()
- {
- @Override
- public void run()
+ SwingUtilities.invokeLater(new Runnable()
{
- Cache.log.debug("Filechooser init thread started.");
- String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
- JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"),
- fileFormat);
- Cache.log.debug("Filechooser init thread finished.");
- }
- }).start();
- // Add the service change listener
- changeSupport.addJalviewPropertyChangeListener("services",
- new PropertyChangeListener()
- {
+ @Override
+ public void run()
+ {
+ new SplashScreen(true);
+ }
+ });
- @Override
- public void propertyChange(PropertyChangeEvent evt)
+ // Thread off a new instance of the file chooser - this reduces the
+ // time
+ // it
+ // takes to open it later on.
+ new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ Cache.log.debug("Filechooser init thread started.");
+ String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
+ JalviewFileChooser.forRead(
+ Cache.getProperty("LAST_DIRECTORY"), fileFormat);
+ Cache.log.debug("Filechooser init thread finished.");
+ }
+ }).start();
+ // Add the service change listener
+ changeSupport.addJalviewPropertyChangeListener("services",
+ new PropertyChangeListener()
{
- Cache.log.debug("Firing service changed event for "
- + evt.getNewValue());
- JalviewServicesChanged(evt);
- }
- });
- }
-
- this.setDropTarget(new java.awt.dnd.DropTarget(desktopPane, this));
- this.addWindowListener(new WindowAdapter()
- {
- @Override
- public void windowClosing(WindowEvent evt)
- {
- quit();
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ Cache.log.debug("Firing service changed event for "
+ + evt.getNewValue());
+ JalviewServicesChanged(evt);
+ }
+ });
}
- });
- MouseAdapter ma;
- this.addMouseListener(ma = new MouseAdapter()
- {
- @Override
- public void mousePressed(MouseEvent evt)
+ this.setDropTarget(new java.awt.dnd.DropTarget(desktopPane, this));
+
+ this.addWindowListener(new WindowAdapter()
{
- if (evt.isPopupTrigger()) // Mac
+ @Override
+ public void windowClosing(WindowEvent evt)
{
- showPasteMenu(evt.getX(), evt.getY());
+ quit();
}
- }
+ });
- @Override
- public void mouseReleased(MouseEvent evt)
+ MouseAdapter ma;
+ this.addMouseListener(ma = new MouseAdapter()
{
- if (evt.isPopupTrigger()) // Windows
+ @Override
+ public void mousePressed(MouseEvent evt)
{
- showPasteMenu(evt.getX(), evt.getY());
+ if (evt.isPopupTrigger()) // Mac
+ {
+ showPasteMenu(evt.getX(), evt.getY());
+ }
}
- }
- });
- desktopPane.addMouseListener(ma);
+
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
+ {
+ showPasteMenu(evt.getX(), evt.getY());
+ }
+ }
+ });
+ desktopPane.addMouseListener(ma);
+ }
} catch (Throwable t)
{
t.printStackTrace();
ap.paintAlignment(false, false);
}
sequence.setDescription(dialog.getDescription());
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
+ ap.av.notifyAlignment();
}
});
}
startEnd, caseChange);
ap.alignFrame.addHistoryItem(caseCommand);
+ ap.av.notifyAlignment();
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
}
}
sg.getStartRes(), sg.getEndRes() + 1,
ap.av.getAlignment());
ap.alignFrame.addHistoryItem(editCommand);
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
+ ap.av.notifyAlignment();
}
});
}
ap.alignFrame.addHistoryItem(cut);
PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true);
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
+ ap.av.notifyAlignment();
}
}
{
command.undoCommand(af.getViewAlignments());
ap.av.getHistoryList().remove(command);
- ap.av.firePropertyChange("alignment", null,
- ap.av.getAlignment().getSequences());
+ ap.av.notifyAlignment();
af.updateEditMenuBar();
}
{
av.showColumn(hiddenRange[0]);
reveal = null;
- ap.updateLayout();
- ap.paintAlignment(true, true);
- av.sendSelection();
+ updatePanel();
}
});
pop.add(item);
{
av.showAllHiddenColumns();
reveal = null;
- ap.updateLayout();
- ap.paintAlignment(true, true);
- av.sendSelection();
+ updatePanel();
}
});
pop.add(item);
{
av.setSelectionGroup(null);
}
-
- ap.updateLayout();
- ap.paintAlignment(true, true);
- av.sendSelection();
+ updatePanel();
}
});
pop.add(item);
return pop;
}
+ protected void updatePanel()
+ {
+ ap.updateLayout();
+ ap.paintAlignment(true, true);
+ ap.updateScrollBarsFromRanges();
+ av.sendSelection();
+ }
+
/**
* Handles left mouse button press
*
if (editCommand != null && editCommand.getSize() > 0)
{
ap.alignFrame.addHistoryItem(editCommand);
- av.firePropertyChange("alignment", null,
- av.getAlignment().getSequences());
+ ap.av.notifyAlignment();
}
} finally
{
{
selectedSequence = userSelectedSeq;
}
- PDBEntry fileEntry = new AssociatePdbFileWithSeq()
- .associatePdbWithSeq(selectedPdbFileName,
- DataSourceType.FILE, selectedSequence, true,
- Desktop.getInstance());
+ PDBEntry fileEntry = AssociatePdbFileWithSeq.associatePdbWithSeq(selectedPdbFileName,
+ DataSourceType.FILE, selectedSequence, true);
sViewer = StructureViewer.launchStructureViewer(ap, new PDBEntry[] { fileEntry },
new SequenceI[]
{ selectedSequence }, superimpose, theViewer,
{
final PropertyChangeListener listener = new PropertyChangeListener()
{
+ @SuppressWarnings("unchecked")
@Override
public void propertyChange(PropertyChangeEvent evt)
{
- if (evt.getPropertyName().equals("alignment"))
- {
+ switch (evt.getPropertyName()) {
+ case AlignmentViewport.PROPERTY_ALIGNMENT:
if (tree == null)
{
System.out.println("tree is null");
{
System.out.println(
"new alignment sequences vector value is null");
+ return;
}
tree.updatePlaceHolders((List<SequenceI>) evt.getNewValue());
treeCanvas.nameHash.clear(); // reset the mapping between canvas
// rectangles and leafnodes
repaint();
+ break;
}
}
};
public abstract class AlignmentViewport
implements AlignViewportI, CommandListener, VamsasSource
{
+ public static final String PROPERTY_ALIGNMENT = "alignment";
+ public static final String PROPERTY_SEQUENCE = "sequence";
+
protected ViewportRanges ranges;
protected ViewStyleI viewStyle = new ViewStyle();
protected ColumnSelection colSel = new ColumnSelection();
- public boolean autoCalculateConsensus = true;
+ protected boolean autoCalculateConsensusAndConservation = true;
+
+ public boolean getAutoCalculateConsensusAndConservation()
+ { // BH 2019.07.24
+ return autoCalculateConsensusAndConservation;
+ }
+
+ public void setAutoCalculateConsensusAndConservation(boolean b)
+ {
+ autoCalculateConsensusAndConservation = b;
+ }
protected boolean autoCalculateStrucConsensus = true;
+ public boolean getAutoCalculateStrucConsensus()
+ { // BH 2019.07.24
+ return autoCalculateStrucConsensus;
+ }
+
+ public void setAutoCalculateStrucConsensus(boolean b)
+ {
+ autoCalculateStrucConsensus = b;
+ }
+
+
protected boolean ignoreGapsInConsensusCalculation = false;
protected ResidueShaderI residueShading = new ResidueShader();
// see note in mantis : issue number 8585
if (alignment.isNucleotide()
|| (conservation == null && quality == null)
- || !autoCalculateConsensus)
+ || !autoCalculateConsensusAndConservation)
{
return;
}
public void updateConsensus(final AlignmentViewPanel ap)
{
// see note in mantis : issue number 8585
- if (consensus == null || !autoCalculateConsensus)
+ if (consensus == null || !autoCalculateConsensusAndConservation)
{
return;
}
* checks current colsel against record of last hash value, and optionally
* updates record.
*
- * @param b
+ * @param updateHash
* update the record of last hash value
* @return true if colsel changed since last call (when b is true)
*/
- public boolean isColSelChanged(boolean b)
+ public boolean isColSelChanged(boolean updateHash)
{
int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel.hashCode();
if (hc != -1 && hc != colselhash)
{
- if (b)
+ if (updateHash)
{
colselhash = hc;
}
return true;
}
+ notifySequence();
return false;
}
}
}
- /**
- * Property change listener for changes in alignment
- *
- * @param prop
- * DOCUMENT ME!
- * @param oldvalue
- * DOCUMENT ME!
- * @param newvalue
- * DOCUMENT ME!
- */
- public void firePropertyChange(String prop, Object oldvalue,
- Object newvalue)
- {
- changeSupport.firePropertyChange(prop, oldvalue, newvalue);
- }
-
// common hide/show column stuff
public void hideSelectedColumns()
ranges.setStartEndSeq(startSeq, endSeq + tmp.size());
- firePropertyChange("alignment", null, alignment.getSequences());
// used to set hasHiddenRows/hiddenRepSequences here, after the property
// changed event
+ notifySequence();
sendSelection();
}
}
+
public void showSequence(int index)
{
int startSeq = ranges.getStartSeq();
}
ranges.setStartEndSeq(startSeq, endSeq + tmp.size());
-
- firePropertyChange("alignment", null, alignment.getSequences());
+ notifyAlignment();
sendSelection();
}
}
setSequenceAnnotationsVisible(seq[i], false);
}
ranges.setStartSeq(startSeq);
- firePropertyChange("alignment", null, alignment.getSequences());
+ notifyAlignment();
}
}
{
alignment.padGaps();
}
- if (autoCalculateConsensus)
+ if (autoCalculateConsensusAndConservation)
{
updateConsensus(ap);
}
- if (hconsensus != null && autoCalculateConsensus)
+ if (hconsensus != null && autoCalculateConsensusAndConservation)
{
updateConservation(ap);
}
codingComplement.setUpdateStructures(needToUpdateStructureViews);
}
}
+
+
+ /**
+ * Notify TreePanel and AlignmentPanel of some sort of alignment change.
+ */
+ public void notifyAlignment()
+ {
+ changeSupport.firePropertyChange(PROPERTY_ALIGNMENT, null, alignment.getSequences());
+ }
+
+ /**
+ * Notify AlignmentPanel of a sequence column selection or visibility changes.
+ */
+ public void notifySequence()
+ {
+ changeSupport.firePropertyChange(PROPERTY_SEQUENCE, null, null);
+ }
+
}
int[] oldvalues = updateStartEndRes(start, end);
int oldstartres = oldvalues[0];
int oldendres = oldvalues[1];
+
+ if (oldstartres == startRes && oldendres == endRes)
+ {
+ return; // BH 2019.07.27 standard check for no changes
+ }
+ // "STARTRES" is a misnomer here -- really "STARTORENDRES"
+ // note that this could be "no change" if the range is just being expanded
changeSupport.firePropertyChange(STARTRES, oldstartres, startRes);
if (oldstartres == startRes)
{
+ // only caught in ViewportRangesTest
+ // No listener cares about this
+ // "ENDRES" is a misnomer here -- really "ENDONLYRES"
+ // BH 2019.07.27 adds end change check
+ // fire only if only the end is changed
// event won't be fired if start positions are same
// fire an event for the end positions in case they changed
- changeSupport.firePropertyChange(ENDRES, oldendres, endRes);
+ changeSupport.firePropertyChange(ENDRES, oldendres, endRes);
}
}
return maxScroll;
}
+
+
+ @Override
+ public String toString() {
+ return "[ViewportRange " + startSeq + "-" + endSeq + ", "+ startRes + "-" + endRes + "]";
+ }
}
import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
import jalview.io.FileLoader;
+import jalview.util.Platform;
import jalview.viewmodel.ViewportRanges;
public class AlignmentPanelTest
@BeforeMethod(alwaysRun = true)
public void setUp() throws InvocationTargetException, InterruptedException
{
- Jalview.main(new String[] { "-nonews", "-props",
- "test/jalview/testProps.jvprops" });
+ Jalview.main(new String[] { "-nonews",
+ "-props", "test/jalview/testProps.jvprops",
+ "-jabaws", "none"});
Cache.setPropertyNoSave("SHOW_IDENTITY",
Boolean.TRUE.toString());
af.alignPanel.setScrollValues(-1, 5);
// setting -ve x value does not change residue
+ // no update necessary now
assertEquals(ranges.getEndRes(), oldres);
af.alignPanel.setScrollValues(0, 5);
-
+ // no update necessary now
// setting 0 as x value does not change residue
+ // no update necessary now
assertEquals(ranges.getEndRes(), oldres);
af.alignPanel.setScrollValues(5, 5);
// setting x value to 5 extends endRes by 5 residues
+ System.out.println(ranges);
+ // no update necessary now
assertEquals(ranges.getEndRes(), oldres + 5);
// scroll to position after hidden columns sets endres to oldres (width) +
// position
- int scrollpos = 60;
+
+ int scrollpos = 53; // was 60, but this is too high to allow full scrolling
+ // in Windows
af.getViewport().hideColumns(30, 50);
af.alignPanel.setScrollValues(scrollpos, 5);
+ // no update necessary now
assertEquals(ranges.getEndRes(), oldres + scrollpos);
// scroll to position within hidden columns, still sets endres to oldres +
af.getViewport().showAllHiddenColumns();
af.getViewport().hideColumns(30, 50);
af.alignPanel.setScrollValues(scrollpos, 5);
+ // no update necessary now
assertEquals(ranges.getEndRes(), oldres + scrollpos);
// scroll to position within <width> distance of the end of the alignment
scrollpos = 130;
af.getViewport().showAllHiddenColumns();
af.alignPanel.setScrollValues(scrollpos, 5);
- assertEquals(ranges.getEndRes(), af.getViewport()
- .getAlignment().getWidth() - 1);
+ // no update necessary now
+ assertEquals(ranges.getEndRes(),
+ af.getViewport().getAlignment().getWidth() - 1);
// now hide some columns, and scroll to position within <width>
// distance of the end of the alignment
// columns
af.getViewport().hideColumns(30, 50);
af.alignPanel.setScrollValues(scrollpos, 5);
- assertEquals(ranges.getEndRes(), af.getViewport()
- .getAlignment().getWidth() - 1 - 21); // 21 is the number of hidden
- // columns
+ // no update necessary now
+ assertEquals(ranges.getEndRes(),
+ af.getViewport().getAlignment().getWidth() - 1 - 21); // 21 is the
+ // number of
+ // hidden
+ // columns
}
/**
* note 4 pixels padding are added to the longest sequence name width
*/
av.setIdWidth(-1); // force recalculation
+
d = af.alignPanel.calculateIdWidth();
- assertEquals(d.width, 166); // 4 + pixel width of "Q93Z60_ARATH/1-118"
+ assertEquals(d.width, Platform.isWin() ? 172 : 166); // 4 + pixel width of "Q93Z60_ARATH/1-118"
assertEquals(d.height, 12);
assertEquals(d.width, av.getIdWidth());
}
* note 4 pixels 'padding' are added to the longest seq name/annotation label
*/
Dimension d = af.alignPanel.calculateIdWidth(2000);
- assertEquals(d.width, 166); // 4 + pixel width of "Q93Z60_ARATH/1-118"
+ assertEquals(d.width, Platform.isWin() ? 172 : 166); // 4 + pixel width of "Q93Z60_ARATH/1-118"
assertEquals(d.height, 12); // fixed value (not used?)
assertEquals(av.getIdWidth(), 18); // not changed by this method
*/
SequenceI seq = af.viewport.getAlignment()
.findSequenceMatch("Q93Z60_ARATH")[0];
- seq.setName(seq.getName() + "MMMMM");
+ String orig = seq.getName();
+ seq.setName(orig + "MMMMM");
d = af.alignPanel.calculateIdWidth(2000);
- assertEquals(d.width, 211); // 4 + pixel width of "Q93Z60_ARATHMMMMM/1-118"
+ assertEquals(d.width, Platform.isWin() ? 219 : 211); // 4 + pixel width of "Q93Z60_ARATHMMMMM/1-118"
assertEquals(d.height, 12);
assertEquals(av.getIdWidth(), 18); // unchanged
+ // for next test:
+ seq.setName(orig);
/*
* make the longest annotation name even longer
FontMetrics fmfor = af.alignPanel
.getFontMetrics(af.alignPanel.getAlabels().getFont());
// Assumption ID_WIDTH_PADDING == 4
+ // AH! But with those added MMMM above, this was NOT the longest label!
int expwidth = 4 + fmfor.stringWidth(aa.label);
d = af.alignPanel.calculateIdWidth(2000);
- assertEquals(d.width, expwidth); // 228 == ID_WIDTH_PADDING + pixel width of "THIS IS A VERY LONG LABEL INDEED"
+ assertEquals(d.width, expwidth); // 191 == ID_WIDTH_PADDING + pixel width of "THIS IS A VERY LONG LABEL INDEED"
assertEquals(d.height, 12);
/*
* override with maxwidth
* note the 4 pixels padding is added to this value
*/
- d = af.alignPanel.calculateIdWidth(213);
- assertEquals(d.width, 217);
+ // BH but we have to be under the max width
+ d = af.alignPanel.calculateIdWidth(180);
+ assertEquals(d.width, 184);
assertEquals(d.height, 12);
}
*/
int w = af.alignPanel.getVisibleIdWidth(true);
assertEquals(w, af.alignPanel.getIdPanel().getWidth());
- assertEquals(w, 115);
+ assertEquals(w, Platform.isWin() ? 112 : 115);
/*
* width for offscreen rendering is the same
* preference for auto id width overrides fixed width
*/
Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.TRUE.toString());
- assertEquals(115, af.alignPanel.getVisibleIdWidth(false));
+ assertEquals(Platform.isWin() ? 106 : 115, af.alignPanel.getVisibleIdWidth(false));
}
}
PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
- String text = ((JTextArea) PA.getValue(testee, "textarea")).getText();
+ String text = ((JTextArea) PA.getValue(testee, "textarea")).getText().replace("\r\n", "\n");
String expected = "Score = 80.0\n" + "Length of alignment = 4\n"
+ "Sequence FER1_PEA/29-32 (Sequence length = 7)\n"
+ "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)\n\n"
PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
- String text = ((JTextArea) PA.getValue(testee, "textarea")).getText();
+ String text = ((JTextArea) PA.getValue(testee, "textarea")).getText().replace("\r\n", "\n");
String expected = "Score = 80.0\n" + "Length of alignment = 4\n"
+ "Sequence FER1_PEA/29-32 (Sequence length = 7)\n"
+ "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)\n\n"
import static org.testng.Assert.assertEquals;
import jalview.bin.Cache;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
import jalview.io.DataSourceType;
import jalview.io.FileLoader;
import jalview.util.Platform;
+import jalview.viewmodel.ViewportRanges;
import java.awt.Font;
import java.awt.FontMetrics;
@BeforeClass(alwaysRun = true)
public void setUp()
{
+ Jalview.setInteractive(false);
Cache.initLogger();
}
av.setFont(new Font("SansSerif", Font.PLAIN, 14), true);
int charHeight = av.getCharHeight();
int charWidth = av.getCharWidth();
- assertEquals(charHeight, Platform.isMac() ? 17 : 19);
- assertEquals(charWidth, Platform.isMac() ? 12 : 11);
+ assertEquals(charHeight, !Platform.isWin() ? 17 : 19);
+ assertEquals(charWidth, !Platform.isWin() ? 12 : 11);
/*
* first with scales above, left, right
FontMetrics fm = testee.getFontMetrics(av.getFont());
int labelWidth = fm.stringWidth("000") + charWidth;
assertEquals(labelWidth,
- Platform.isMac() ? 3 * 9 + charWidth : 3 * 8 + charWidth);
+ !Platform.isWin() ? 3 * 9 + charWidth : 3 * 8 + charWidth);
/*
* width 400 pixels leaves (400 - 2*labelWidth) for residue columns
canvasWidth += 2;
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth,
canvasHeight);
- assertEquals(wrappedWidth, Platform.isMac() ? 24 : 25); // 2px not enough
+ assertEquals(wrappedWidth, !Platform.isWin() ? 24 : 25); // 2px not enough
canvasWidth += 1;
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth,
canvasHeight);
int charHeight = av.getCharHeight();
int charWidth = av.getCharWidth();
- assertEquals(charHeight, Platform.isMac() ? 17 : 19);
- assertEquals(charWidth, Platform.isMac() ? 12 : 11);
+ assertEquals(charHeight, !Platform.isWin() ? 17 : 19);
+ assertEquals(charWidth, !Platform.isWin() ? 12 : 11);
SeqCanvas testee = af.alignPanel.getSeqPanel().seqCanvas;
FontMetrics fm = testee.getFontMetrics(av.getFont());
int labelWidth = fm.stringWidth("000") + charWidth;
assertEquals(labelWidth,
- Platform.isMac() ? 3 * 9 + charWidth : 3 * 8 + charWidth);
+ !Platform.isWin() ? 3 * 9 + charWidth : 3 * 8 + charWidth);
int annotationHeight = testee.getAnnotationHeight();
AlignmentI al = av.getAlignment();
assertEquals(al.getWidth(), 157);
assertEquals(al.getHeight(), 15);
- av.getRanges().setStartEndSeq(0, 3);
+
+ ViewportRanges ranges = av.getRanges();
+ ranges.setStartEndSeq(0, 3);
+ System.out.println(ranges);
av.setShowAnnotation(false);
av.setScaleAboveWrapped(true);
+ System.out.println(ranges);
SeqCanvas testee = af.alignPanel.getSeqPanel().seqCanvas;
av.setWrapAlignment(true);
+ System.out.println(ranges);
av.setFont(new Font("SansSerif", Font.PLAIN, 14), true);
int charHeight = av.getCharHeight();
int charWidth = av.getCharWidth();
+ System.out.println(ranges);
// Windows h=19, w=11.
- assertEquals(charHeight, Platform.isMac() ? 17 : 19);
- assertEquals(charWidth, Platform.isMac() ? 12 : 11);
-
+ assertEquals(charHeight, !Platform.isWin() ? 17 : 19);
+ assertEquals(charWidth, !Platform.isWin() ? 12 : 11);
+ System.out.println(ranges);
+
int canvasWidth = 400;
int canvasHeight = 300;
testee.calculateWrappedGeometry(canvasWidth, canvasHeight);
-
- assertEquals(av.getRanges().getEndSeq(), 3); // unchanged
+ System.out.println(ranges);
+ assertEquals(ranges.getEndSeq(), 3); // unchanged
int repeatingHeight = (int) PA.getValue(testee,
"wrappedRepeatHeightPx");
int h = charHeight * (2 + al.getHeight());