From 1cec732f963ab102c9d8381203df8c8cba2a9ee4 Mon Sep 17 00:00:00 2001 From: hansonr Date: Wed, 24 Jul 2019 07:42:25 +0100 Subject: [PATCH] JAL-3253-applet adds NOMENUBAR, NOSTATUS, NOCALCULATION, SHOWOVERVIEW adds "overview" name for overview panel. --- src/jalview/appletgui/AlignFrame.java | 2 +- src/jalview/bin/ArgsParser.java | 11 +++ src/jalview/bin/Jalview.java | 98 ++++++++++++++++++++------ src/jalview/gui/AlignFrame.java | 19 +++-- src/jalview/gui/AlignViewport.java | 2 +- src/jalview/gui/Desktop.java | 40 ++++++++++- src/jalview/viewmodel/AlignmentViewport.java | 30 ++++++-- 7 files changed, 164 insertions(+), 38 deletions(-) diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index adfb8ca..062dbf8 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -882,7 +882,7 @@ public class AlignFrame extends EmbmenuFrame implements AlignFrameI, } else if (source == autoCalculate) { - viewport.autoCalculateConsensus = autoCalculate.getState(); + viewport.setAutoCalculateConsensusAndConservation(autoCalculate.getState()); } else if (source == sortByTree) { diff --git a/src/jalview/bin/ArgsParser.java b/src/jalview/bin/ArgsParser.java index 45ea206..91c8838 100644 --- a/src/jalview/bin/ArgsParser.java +++ b/src/jalview/bin/ArgsParser.java @@ -35,6 +35,17 @@ import java.util.Vector; public class ArgsParser { + // BH 2019 - new + + public static final String NOCALCULATION = "nocalculation"; + + public static final String NOMENUBAR = "nomenubar"; + + public static final String NOSTATUS = "nostatus"; + + public static final String SHOWOVERVIEW = "showoverview"; + + // public static final String ANNOTATIONS = "annotations"; public static final String COLOUR = "colour"; diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index bb2038e..d9de469 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -146,6 +146,24 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi protected JSFunctionExec jsFunctionExec; + private boolean noCalculation, noMenuBar, noStatus; + + public boolean getStartCalculations() + { + return !noCalculation; + } + + public boolean getAllowMenuBar() + { + return !noMenuBar; + } + + public boolean getShowStatus() + { + return !noStatus; + } + + public static AlignFrame getCurrentAlignFrame() { return getInstance().currentAlignFrame; @@ -255,26 +273,6 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi getInstance().doMain(args); } - /** - * Allow an outside entity to initiate the second half of argument parsing - * (only). - * - * @param args - * @return null is good - */ - @Override - public Object parseArguments(String[] args) - { - - try - { - ArgsParser aparser = new ArgsParser(args); - return parseArguments(aparser, false); - } catch (Throwable t) - { - return t; - } - } private static void logClass(String name) { @@ -553,6 +551,33 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi parseArguments(aparser, true); } + /** + * Allow an outside entity to initiate the second half of argument parsing + * (only). + * + * @param args + * @return null is good + */ + @Override + public Object parseArguments(String[] args) + { + + try + { + ArgsParser aparser = new ArgsParser(args); + return parseArguments(aparser, false); + } catch (Throwable t) + { + return t; + } + } + + /** + * + * @param aparser + * @param isStartup + * @return + */ private Object parseArguments(ArgsParser aparser, boolean isStartup) { boolean isJS = Platform.isJS(); @@ -569,7 +594,6 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi String fileFormat = (isJavaAppletTag ? aparser.getAppletValue("format", null) : null); - FileFormatI format = null; DataSourceType protocol = null; @@ -597,8 +621,11 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi } } + String data; + if (file != null) { + if (!headless) { desktop.setProgressBar( @@ -645,6 +672,32 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi // TODO ? } + if (aparser.contains(ArgsParser.SHOWOVERVIEW)) + { + jalview.bin.Cache.setPropertyNoSave(Preferences.SHOW_OVERVIEW, + "true"); + + System.out.println("CMD [showoverview] executed successfully!"); + } + + 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.NOCALCULATION)) + { + noCalculation = true; + System.out.println("CMD [nocalculation] executed successfully!"); + } + AlignFrame af = new FileLoader(!headless).loadFileWaitTillLoaded(file, protocol, format); if (af == null) @@ -686,7 +739,7 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi // TODO: file2 How to implement file2 for the applet spit screen? - String data = aparser.getValue(ArgsParser.COLOUR, true); + data = aparser.getValue(ArgsParser.COLOUR, true); if (data != null) { data.replaceAll("%20", " "); @@ -2005,4 +2058,5 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi } + } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 3b53f18..d87f0f0 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -353,6 +353,8 @@ public class AlignFrame extends GAlignFrame if (!Jalview.isHeadlessMode()) { progressBar = new ProgressBar(this.statusPanel, this.statusBar); + statusPanel.setVisible(Jalview.getInstance().getShowStatus()); + alignFrameMenuBar.setVisible(Jalview.getInstance().getAllowMenuBar()); } avc = new jalview.controller.AlignViewController(this, viewport, @@ -793,9 +795,12 @@ public class AlignFrame extends GAlignFrame { 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); + } } } @@ -945,7 +950,7 @@ public class AlignFrame extends GAlignFrame 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); @@ -3374,7 +3379,7 @@ public class AlignFrame extends GAlignFrame Desktop.addInternalFrame(frame, MessageManager .formatMessage("label.overview_params", new Object[] { this.getTitle() }), true, frame.getWidth(), frame.getHeight(), - true, true); + true, true, "overview"); frame.pack(); frame.setLayer(JLayeredPane.PALETTE_LAYER); frame.addInternalFrameListener( @@ -3654,8 +3659,8 @@ public class AlignFrame extends GAlignFrame @Override public void autoCalculate_actionPerformed(ActionEvent e) { - viewport.autoCalculateConsensus = autoCalculate.isSelected(); - if (viewport.autoCalculateConsensus) + viewport.setAutoCalculateConsensusAndConservation(autoCalculate.isSelected()); + if (viewport.getAutoCalculateConsensusAndConservation()) { viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 7c3dca0..eb9c180 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -214,7 +214,7 @@ public class AlignViewport extends AlignmentViewport setRightAlignIds(Cache.getDefault(Preferences.RIGHT_ALIGN_IDS, false)); setCentreColumnLabels(Cache.getDefault(Preferences.CENTRE_COLUMN_LABELS, false)); - autoCalculateConsensus = Cache.getDefault(Preferences.AUTO_CALC_CONSENSUS, true); + autoCalculateConsensusAndConservation = Cache.getDefault(Preferences.AUTO_CALC_CONSENSUS, true); setPadGaps(Cache.getDefault(Preferences.PAD_GAPS, true)); setShowNPFeats(Cache.getDefault(Preferences.SHOW_NPFEATS_TOOLTIP, true)); diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 2a972e3..957fb96 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -864,7 +864,7 @@ public class Desktop extends GDesktop final JInternalFrame frame, String title, int w, int h, boolean resizable) { - addInternalFrame(frame, title, true, w, h, resizable, false); + addInternalFrame(frame, title, true, w, h, resizable, false, null); } /** @@ -887,15 +887,51 @@ public class Desktop extends GDesktop * Do not set the default minimum size for frame */ public static synchronized void addInternalFrame( + JInternalFrame frame, String title, boolean makeVisible, int w, + int h, boolean resizable, boolean ignoreMinSize) + { + addInternalFrame(frame, title, makeVisible, w, h, resizable, + ignoreMinSize, null); + } + + /** + * Add an internal frame to the Jalview desktop + * + * @param frame + * Frame to show + * @param title + * Visible Title + * @param makeVisible + * When true, display frame immediately, otherwise, caller must call + * setVisible themselves. + * @param w + * width + * @param h + * height + * @param resizable + * Allow resize + * @param ignoreMinSize + * Do not set the default minimum size for frame + * @param name + * for HTML div embedding + */ + public static synchronized void addInternalFrame( final JInternalFrame frame, String title, boolean makeVisible, - int w, int h, boolean resizable, boolean ignoreMinSize) + int w, int h, boolean resizable, boolean ignoreMinSize, + String name) { + // TODO: allow callers to determine X and Y position of frame (eg. via // bounds object). // TODO: consider fixing method to update entries in the window submenu with // the current window title + if (name != null) + { + frame.setName(Jalview.getAppID(name)); + } + frame.setTitle(title); if (frame.getWidth() < 1 || frame.getHeight() < 1) { diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 536f767..4116c3b 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -605,10 +605,30 @@ public abstract class AlignmentViewport 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(); @@ -824,7 +844,7 @@ public abstract class AlignmentViewport // see note in mantis : issue number 8585 if (alignment.isNucleotide() || (conservation == null && quality == null) - || !autoCalculateConsensus) + || !autoCalculateConsensusAndConservation) { return; } @@ -842,7 +862,7 @@ public abstract class AlignmentViewport public void updateConsensus(final AlignmentViewPanel ap) { // see note in mantis : issue number 8585 - if (consensus == null || !autoCalculateConsensus) + if (consensus == null || !autoCalculateConsensusAndConservation) { return; } @@ -1859,11 +1879,11 @@ public abstract class AlignmentViewport { alignment.padGaps(); } - if (autoCalculateConsensus) + if (autoCalculateConsensusAndConservation) { updateConsensus(ap); } - if (hconsensus != null && autoCalculateConsensus) + if (hconsensus != null && autoCalculateConsensusAndConservation) { updateConservation(ap); } -- 1.7.10.2