Merge branch 'bug/JAL-4214_system_freeze_when_opening_file_using_gui_in_linux' into...
authorBen Soares <b.soares@dundee.ac.uk>
Fri, 18 Aug 2023 14:33:53 +0000 (15:33 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Fri, 18 Aug 2023 14:33:53 +0000 (15:33 +0100)
304 files changed:
build.gradle
examples/argfiles/test_fab41.txt
examples/argfiles/test_fab41_nostructureviewers.txt [new file with mode: 0644]
examples/testdata/7WKP-rna1.xml [new file with mode: 0644]
getdown/lib/FJVL_VERSION
getdown/lib/JVL_VERSION
getdown/lib/getdown-core.jar
getdown/lib/getdown-launcher-local.jar
getdown/lib/getdown-launcher.jar
getdown/src/getdown/ant/pom.xml
getdown/src/getdown/core/pom.xml
getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java
getdown/src/getdown/core/src/main/java/jalview/util/LaunchUtils.java
getdown/src/getdown/launcher/pom.xml
getdown/src/getdown/mvn_cmd
getdown/src/getdown/pom.xml
gradle.properties
help/help/html/features/clarguments-basic.html
help/help/html/features/clarguments-reference.html
help/help/html/features/clarguments.html
help/help/html/privacy.html
help/help/icons/jalview_docs_logo.png [new file with mode: 0644]
help/markdown/releases/release-2_11_2_7.md [new file with mode: 0644]
help/markdown/releases/release-2_11_3_0.md
help/markdown/whatsnew/whatsnew-2_11_2_7.md [new file with mode: 0644]
help/markdown/whatsnew/whatsnew-2_11_3_0.md
j11lib/JGoogleAnalytics_0.3.jar [deleted file]
j11lib/flatlaf-3.0.jar [deleted file]
j11lib/flatlaf-3.1.1.jar [deleted file]
j11lib/flatlaf-3.2.jar [new file with mode: 0644]
j11lib/flatlaf-extras-3.0.jar [deleted file]
j11lib/flatlaf-extras-3.2.jar [moved from j11lib/flatlaf-extras-3.1.1.jar with 52% similarity]
j11lib/getdown-core.jar
j8lib/JGoogleAnalytics_0.3.jar [deleted file]
j8lib/flatlaf-3.1.1.jar [deleted file]
j8lib/flatlaf-3.2.jar [new file with mode: 0644]
j8lib/flatlaf-extras-3.2.jar [moved from j8lib/flatlaf-extras-3.1.1.jar with 52% similarity]
j8lib/getdown-core.jar
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/analysis/AAFrequency.java
src/jalview/analysis/AlignSeq.java
src/jalview/analysis/AlignmentSorter.java
src/jalview/analysis/AlignmentUtils.java
src/jalview/analysis/AverageDistanceEngine.java
src/jalview/analysis/Conservation.java
src/jalview/analysis/CrossRef.java
src/jalview/analysis/Dna.java
src/jalview/analysis/GeneticCodes.java
src/jalview/analysis/Grouping.java
src/jalview/analysis/ParseProperties.java
src/jalview/analysis/Rna.java
src/jalview/analysis/SeqsetUtils.java
src/jalview/analysis/StructureFrequency.java
src/jalview/analysis/TreeEngine.java
src/jalview/analysis/TreeModel.java
src/jalview/analysis/scoremodels/FeatureDistanceModel.java
src/jalview/analysis/scoremodels/ScoreMatrix.java
src/jalview/analysis/scoremodels/ScoreModels.java
src/jalview/analytics/Plausible.java [moved from src/jalview/analytics/GoogleAnalytics4.java with 55% similarity]
src/jalview/api/RotatableCanvasI.java
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/appletgui/AlignmentPanel.java
src/jalview/appletgui/AppletJmol.java
src/jalview/appletgui/ExtJmol.java
src/jalview/appletgui/PCAPanel.java
src/jalview/appletgui/PairwiseAlignPanel.java
src/jalview/appletgui/RedundancyPanel.java
src/jalview/appletgui/RotatableCanvas.java
src/jalview/appletgui/SeqPanel.java
src/jalview/appletgui/TreePanel.java
src/jalview/bin/Cache.java
src/jalview/bin/Commands.java
src/jalview/bin/Console.java
src/jalview/bin/GetMemory.java
src/jalview/bin/HiDPISetting.java
src/jalview/bin/Jalview.java
src/jalview/bin/JalviewLite.java
src/jalview/bin/JalviewLiteURLRetrieve.java
src/jalview/bin/JalviewTaskbar.java
src/jalview/bin/Launcher.java
src/jalview/bin/MemorySetting.java
src/jalview/bin/argparser/Arg.java
src/jalview/bin/argparser/ArgParser.java
src/jalview/bin/argparser/BootstrapArgs.java
src/jalview/commands/EditCommand.java
src/jalview/datamodel/AlignedCodonFrame.java
src/jalview/datamodel/AlignmentAnnotation.java
src/jalview/datamodel/AlignmentView.java
src/jalview/datamodel/ContactListImpl.java
src/jalview/datamodel/ContactMatrixI.java
src/jalview/datamodel/DBRefSource.java
src/jalview/datamodel/GroupSet.java
src/jalview/datamodel/HiddenSequences.java
src/jalview/datamodel/SearchResults.java
src/jalview/datamodel/Sequence.java
src/jalview/datamodel/SequenceGroup.java
src/jalview/datamodel/features/FeatureMatcher.java
src/jalview/datamodel/features/FeatureMatcherSet.java
src/jalview/datamodel/features/FeatureStore.java
src/jalview/datamodel/features/SequenceFeatures.java
src/jalview/ext/ensembl/EnsemblGene.java
src/jalview/ext/ensembl/EnsemblLookup.java
src/jalview/ext/ensembl/EnsemblMap.java
src/jalview/ext/ensembl/EnsemblRestClient.java
src/jalview/ext/ensembl/EnsemblSeqProxy.java
src/jalview/ext/htsjdk/HtsContigDb.java
src/jalview/ext/jmol/JalviewJmolBinding.java
src/jalview/ext/jmol/JmolParser.java
src/jalview/ext/paradise/Annotate3D.java
src/jalview/ext/pymol/PymolManager.java
src/jalview/ext/rbvi/chimera/ChimeraListener.java
src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java
src/jalview/fts/core/FTSDataColumnPreferences.java
src/jalview/fts/service/alphafold/AlphafoldRestClient.java
src/jalview/fts/service/pdb/PDBFTSRestClient.java
src/jalview/fts/service/threedbeacons/TDBeaconsFTSPanel.java
src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java
src/jalview/fts/service/uniprot/UniProtFTSRestClient.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/AnnotationPanel.java
src/jalview/gui/AppJmol.java
src/jalview/gui/AppVarna.java
src/jalview/gui/AppVarnaBinding.java
src/jalview/gui/BlogReader.java
src/jalview/gui/ChimeraViewFrame.java
src/jalview/gui/ColourMenuHelper.java
src/jalview/gui/Console.java
src/jalview/gui/CrossRefAction.java
src/jalview/gui/Desktop.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/FeatureTypeSettings.java
src/jalview/gui/Help.java
src/jalview/gui/IdCanvas.java
src/jalview/gui/IdwidthAdjuster.java
src/jalview/gui/ImageExporter.java
src/jalview/gui/JDatabaseTree.java
src/jalview/gui/JvOptionPane.java
src/jalview/gui/OptsAndParamsPage.java
src/jalview/gui/PaintRefresher.java
src/jalview/gui/PairwiseAlignPanel.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/ProgressBar.java
src/jalview/gui/PymolBindingModel.java
src/jalview/gui/RedundancyPanel.java
src/jalview/gui/RestInputParamEditDialog.java
src/jalview/gui/RestServiceEditorPane.java
src/jalview/gui/SeqCanvas.java
src/jalview/gui/SeqCanvas.java.broken
src/jalview/gui/SeqPanel.java
src/jalview/gui/SequenceFetcher.java
src/jalview/gui/SplashScreen.java
src/jalview/gui/StructureChooser.java
src/jalview/gui/StructureViewer.java
src/jalview/gui/StructureViewerBase.java
src/jalview/gui/TreeCanvas.java
src/jalview/gui/TreePanel.java
src/jalview/gui/VamsasApplication.java
src/jalview/gui/WebserviceInfo.java
src/jalview/gui/WsJobParameters.java
src/jalview/gui/structurechooser/PDBStructureChooserQuerySource.java
src/jalview/gui/structurechooser/StructureChooserQuerySource.java
src/jalview/gui/structurechooser/TDBResultAnalyser.java
src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java
src/jalview/httpserver/AbstractRequestHandler.java
src/jalview/httpserver/HttpServer.java
src/jalview/io/AnnotationFile.java
src/jalview/io/AppletFormatAdapter.java
src/jalview/io/BackupFilenameFilter.java
src/jalview/io/BioJsHTMLOutput.java
src/jalview/io/ClustalFile.java
src/jalview/io/FeaturesFile.java
src/jalview/io/FileFormats.java
src/jalview/io/FileLoader.java
src/jalview/io/FileParse.java
src/jalview/io/HTMLOutput.java
src/jalview/io/HtmlSvgOutput.java
src/jalview/io/JPredFile.java
src/jalview/io/JSONFile.java
src/jalview/io/JalviewFileChooser.java
src/jalview/io/JalviewFileView.java
src/jalview/io/MSFfile.java
src/jalview/io/NewickFile.java
src/jalview/io/PIRFile.java
src/jalview/io/PfamFile.java
src/jalview/io/PhylipFile.java
src/jalview/io/RnamlFile.java
src/jalview/io/SequenceAnnotationReport.java
src/jalview/io/SimpleBlastFile.java
src/jalview/io/StockholmFile.java
src/jalview/io/StructureFile.java
src/jalview/io/TCoffeeScoreFile.java
src/jalview/io/VamsasAppDatastore.java
src/jalview/io/WSWUBlastClient.java
src/jalview/io/cache/JvCacheableInputBox.java
src/jalview/io/gff/ExonerateHelper.java
src/jalview/io/gff/Gff3Helper.java
src/jalview/io/gff/GffHelperBase.java
src/jalview/io/gff/SequenceOntologyLite.java
src/jalview/io/packed/JalviewDataset.java
src/jalview/io/packed/ParsePackedSet.java
src/jalview/io/vamsas/Sequencemapping.java
src/jalview/io/vamsas/Tree.java
src/jalview/io/vcf/VCFLoader.java
src/jalview/javascript/JSFunctionExec.java
src/jalview/javascript/JsSelectionSender.java
src/jalview/javascript/MouseOverListener.java
src/jalview/javascript/MouseOverStructureListener.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/jbgui/GAlignmentPanel.java
src/jalview/jbgui/GDesktop.java
src/jalview/jbgui/GStructureChooser.java
src/jalview/log/JLogger.java
src/jalview/math/Matrix.java
src/jalview/math/RotatableMatrix.java
src/jalview/project/Jalview2XML.java
src/jalview/renderer/AnnotationRenderer.java
src/jalview/renderer/ContactMapRenderer.java
src/jalview/rest/RestHandler.java
src/jalview/schemes/ColourSchemeLoader.java
src/jalview/schemes/ColourSchemes.java
src/jalview/schemes/Consensus.java
src/jalview/schemes/CovariationColourScheme.java
src/jalview/schemes/FeatureColour.java
src/jalview/schemes/RNAHelicesColour.java
src/jalview/schemes/ResidueProperties.java
src/jalview/schemes/UserColourScheme.java
src/jalview/structure/StructureSelectionManager.java
src/jalview/structures/models/AAStructureBindingModel.java
src/jalview/urls/IdentifiersUrlProvider.java
src/jalview/urls/UrlProvider.java
src/jalview/util/AWTConsole.java
src/jalview/util/ChannelProperties.java
src/jalview/util/ColorUtils.java
src/jalview/util/DBRefUtils.java
src/jalview/util/GroupUrlLink.java
src/jalview/util/HttpUtils.java
src/jalview/util/LaunchUtils.java
src/jalview/util/Log4j.java
src/jalview/util/Platform.java
src/jalview/util/StringUtils.java
src/jalview/util/UrlLink.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/viewmodel/ViewportRanges.java
src/jalview/viewmodel/styles/ViewStyle.java
src/jalview/workers/AlignCalcManager.java
src/jalview/workers/AlignmentAnnotationFactory.java
src/jalview/workers/ConsensusThread.java
src/jalview/ws/AWSThread.java
src/jalview/ws/DBRefFetcher.java
src/jalview/ws/JobStateSummary.java
src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java
src/jalview/ws/dbsources/EBIAlfaFold.java
src/jalview/ws/dbsources/EbiFileRetrievedProxy.java
src/jalview/ws/dbsources/EmblXmlSource.java
src/jalview/ws/dbsources/Pdb.java
src/jalview/ws/ebi/EBIFetchClient.java
src/jalview/ws/jws1/Annotate3D.java
src/jalview/ws/jws1/Discoverer.java
src/jalview/ws/jws1/JPredThread.java
src/jalview/ws/jws1/MsaWSThread.java
src/jalview/ws/jws1/SeqSearchWSThread.java
src/jalview/ws/jws2/AbstractJabaCalcWorker.java
src/jalview/ws/jws2/JabaParamStore.java
src/jalview/ws/jws2/JabaWsServerQuery.java
src/jalview/ws/jws2/JabawsCalcWorker.java
src/jalview/ws/jws2/JabawsMsaInterfaceAlignCalcWorker.java
src/jalview/ws/jws2/Jws2Discoverer.java
src/jalview/ws/jws2/MsaWSThread.java
src/jalview/ws/jws2/ParameterUtils.java
src/jalview/ws/jws2/jabaws2/Jws2Instance.java
src/jalview/ws/rest/InputType.java
src/jalview/ws/rest/RestClient.java
src/jalview/ws/rest/RestJobThread.java
src/jalview/ws/seqfetcher/ASequenceFetcher.java
src/jalview/ws/sifts/SiftsClient.java
src/jalview/ws/utils/UrlDownloadClient.java
test/files/annotation_label_width/sample.a2m [new file with mode: 0644]
test/files/annotation_label_width/test_fab41_nostructureviewers.txt [new file with mode: 0644]
test/jalview/analysis/AverageDistanceEngineTest.java
test/jalview/analysis/TestAlignSeq.java
test/jalview/bin/CommandLineOperations.java
test/jalview/bin/CommandLineOperationsNG.java
test/jalview/bin/CommandsTest.java
test/jalview/bin/test1-3.fa [new file with mode: 0644]
test/jalview/bin/uniref50-output.blc [new file with mode: 0644]
test/jalview/bin/uniref50-output.fa [new file with mode: 0644]
test/jalview/datamodel/PAEContactMatrixTest.java
test/jalview/datamodel/SequenceTest.java
test/jalview/gui/AnnotationLabelsTest2.java [new file with mode: 0644]
test/jalview/io/RNAMLfileTest.java
test/jalview/io/cache/JvCacheableInputBoxTest.java
test/jalview/project/Jalview2xmlTests.java
test/jalview/ws/sifts/SiftsClientTest.java
utils/biotools/Jalview.json [new file with mode: 0644]
utils/biotools/README.md [new file with mode: 0644]
utils/conda/jalview.sh [new file with mode: 0755]
utils/getdown/bin/jalview.sh
utils/install4j/install4j10_template.install4j

index a47a7fd..c4ed582 100644 (file)
@@ -1834,6 +1834,10 @@ tasks.withType(Test).matching {t -> t.getName().startsWith("testTask")}.all { te
     info.events = [ TestLogEvent.FAILED ]
   }
 
+  if (OperatingSystem.current().isMacOsX()) {
+    testTask.systemProperty "apple.awt.UIElement", "true"
+    testTask.environment "JAVA_TOOL_OPTIONS", "-Dapple.awt.UIElement=true"
+  }
 
 
   ignoreFailures = true // Always try to run all tests for all modules
@@ -4256,7 +4260,7 @@ task jalviewjsLaunchTest {
   def stdout
   def stderr
   doFirst {
-    def timeoutms = Integer.valueOf(jalviewjs_chromium_timeout) * 1000
+    def timeoutms = Integer.valueOf(jalviewjs_chromium_overall_timeout) * 1000
     
     def binary = file(chromiumBinary)
     if (!binary.exists()) {
@@ -4299,6 +4303,7 @@ task jalviewjsLaunchTest {
             errorOutput = execStderr
             executable(chromiumBinary)
             args(execArgs)
+            println "COMMAND: '"+commandLine.join(" ")+"'"
           }
           executor.shutdownNow()
         }
@@ -4316,7 +4321,7 @@ task jalviewjsLaunchTest {
             executor.shutdownNow()
           }
           // if no change in stderr for 10s then also end
-          if (noChangeIterations >= 10) {
+          if (noChangeIterations >= jalviewjs_chromium_idle_timeout) {
             executor.shutdownNow()
           }
           if (stderrString.length() == noChangeBytes) {
index e6f7627..b7f0d45 100644 (file)
@@ -10,4 +10,4 @@
 --paematrix=[label=pAE R4-M5]./examples/test_fab41.result/test_fab41_unrelaxed_rank_4_model_5_scores.json
 --structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_5_model_1.pdb
 --paematrix=[label=pAE R5-M1]./examples/test_fab41.result/test_fab41_unrelaxed_rank_5_model_1_scores.json
---image=output1.html
+--image=[textrenderer=text]output1.html
diff --git a/examples/argfiles/test_fab41_nostructureviewers.txt b/examples/argfiles/test_fab41_nostructureviewers.txt
new file mode 100644 (file)
index 0000000..ab52cdf
--- /dev/null
@@ -0,0 +1,14 @@
+--open=./examples/test_fab41.result/sample.a2m
+--colour=gecos:flower
+--gui
+--structure=[structureviewer=none]./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb
+--paematrix=[label=pAE R1-M3]./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json
+--structure=[structureviewer=none]./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb
+--paematrix=[label=pAE R2-M4]./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4_scores.json
+--structure=[structureviewer=none]./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb
+--paematrix=[label=pAE R3-M2]./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2_scores.json
+--structure=[structureviewer=none]./examples/test_fab41.result/test_fab41_unrelaxed_rank_4_model_5.pdb
+--paematrix=[label=pAE R4-M5]./examples/test_fab41.result/test_fab41_unrelaxed_rank_4_model_5_scores.json
+--structure=[structureviewer=none]./examples/test_fab41.result/test_fab41_unrelaxed_rank_5_model_1.pdb
+--paematrix=[label=pAE R5-M1]./examples/test_fab41.result/test_fab41_unrelaxed_rank_5_model_1_scores.json
+--image=[textrenderer=text]output1.html
diff --git a/examples/testdata/7WKP-rna1.xml b/examples/testdata/7WKP-rna1.xml
new file mode 100644 (file)
index 0000000..2703212
--- /dev/null
@@ -0,0 +1,491 @@
+<?xml version="1.0"?>
+<!DOCTYPE rnaml SYSTEM "rnaml.dtd">
+
+<rnaml version="1.0">
+
+   <molecule id="1">
+      <sequence>
+         <numbering-system id="1" used-in-file="false">
+            <numbering-range>
+               <start>1</start>
+               <end>20</end>
+            </numbering-range>
+         </numbering-system>
+         <numbering-table length="20" comment="sequence number in pdb file">
+            1    2    3    4    5    6    7    8    9   10 
+           11   12   13   14   15   16   17   18   19   20 
+         
+         </numbering-table>
+         <seq-data>
+            GUUAGCAGCC GCAUAGGCUG 
+         </seq-data>
+         <seq-annotation comment="?">
+            <segment>
+               <seg-name>LOOP1</seg-name>
+               <base-id-5p><base-id><position>12</position></base-id></base-id-5p>
+               <base-id-3p><base-id><position>14</position></base-id></base-id-3p>
+            </segment>
+         </seq-annotation>
+      </sequence>
+      <structure>
+         <model id="?">
+            <model-info>
+               <method>Crystallography ?</method>
+               <resolution>? Angstroms</resolution>
+            </model-info>
+            <base>
+               <position>1</position>
+               <base-type>G</base-type>
+               <atom serial="1">
+                  <atom-type> P  </atom-type>
+                     <coordinates>7.232 28.529 -12.305</coordinates>
+               </atom>
+               <atom serial="9">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>4.752 23.963 -11.820</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>2</position>
+               <base-type>U</base-type>
+               <atom serial="24">
+                  <atom-type> P  </atom-type>
+                     <coordinates>3.868 23.252 -12.962</coordinates>
+               </atom>
+               <atom serial="32">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>0.983 18.432 -13.409</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>3</position>
+               <base-type>U</base-type>
+               <atom serial="44">
+                  <atom-type> P  </atom-type>
+                     <coordinates>1.438 17.540 -14.670</coordinates>
+               </atom>
+               <atom serial="52">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-1.417 16.962 -19.633</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>4</position>
+               <base-type>A</base-type>
+               <atom serial="64">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-2.710 16.020 -19.430</coordinates>
+               </atom>
+               <atom serial="72">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-7.138 19.555 -19.112</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>5</position>
+               <base-type>G</base-type>
+               <atom serial="86">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-7.829 20.393 -20.298</coordinates>
+               </atom>
+               <atom serial="94">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-11.316 24.166 -18.659</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>6</position>
+               <base-type>C</base-type>
+               <atom serial="109">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-12.021 24.790 -19.958</coordinates>
+               </atom>
+               <atom serial="117">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-14.686 21.023 -22.223</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>7</position>
+               <base-type>A</base-type>
+               <atom serial="129">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-16.102 21.690 -22.577</coordinates>
+               </atom>
+               <atom serial="137">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-20.284 18.901 -22.582</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>8</position>
+               <base-type>G</base-type>
+               <atom serial="151">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-21.555 19.844 -22.854</coordinates>
+               </atom>
+               <atom serial="159">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-26.285 20.028 -19.599</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>9</position>
+               <base-type>C</base-type>
+               <atom serial="174">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-27.355 21.190 -19.880</coordinates>
+               </atom>
+               <atom serial="182">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-30.900 21.877 -16.104</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>10</position>
+               <base-type>C</base-type>
+               <atom serial="194">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-31.737 23.147 -16.621</coordinates>
+               </atom>
+               <atom serial="202">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-33.685 26.755 -13.690</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>11</position>
+               <base-type>G</base-type>
+               <atom serial="214">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-34.360 27.602 -14.877</coordinates>
+               </atom>
+               <atom serial="222">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-34.025 32.801 -15.050</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>12</position>
+               <base-type>C</base-type>
+               <atom serial="237">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-35.037 32.875 -16.296</coordinates>
+               </atom>
+               <atom serial="245">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-31.850 33.486 -20.341</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>13</position>
+               <base-type>A</base-type>
+               <atom serial="257">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-30.767 32.411 -19.837</coordinates>
+               </atom>
+               <atom serial="265">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-25.756 33.919 -20.714</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>14</position>
+               <base-type>U</base-type>
+               <atom serial="279">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-24.465 33.135 -20.171</coordinates>
+               </atom>
+               <atom serial="287">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-21.219 37.107 -19.013</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>15</position>
+               <base-type>A</base-type>
+               <atom serial="299">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-22.129 38.268 -18.376</coordinates>
+               </atom>
+               <atom serial="307">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-20.542 37.656 -12.798</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>16</position>
+               <base-type>G</base-type>
+               <atom serial="321">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-19.666 36.373 -12.391</coordinates>
+               </atom>
+               <atom serial="329">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-21.101 34.091 -7.803</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>17</position>
+               <base-type>G</base-type>
+               <atom serial="344">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-20.251 32.728 -7.687</coordinates>
+               </atom>
+               <atom serial="352">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-22.951 28.722 -5.266</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>18</position>
+               <base-type>C</base-type>
+               <atom serial="367">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-21.797 27.634 -5.014</coordinates>
+               </atom>
+               <atom serial="375">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-23.692 22.611 -5.084</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>19</position>
+               <base-type>U</base-type>
+               <atom serial="387">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-22.583 21.449 -4.989</coordinates>
+               </atom>
+               <atom serial="395">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-22.919 16.822 -7.040</coordinates>
+               </atom>
+            </base>
+            <base>
+               <position>20</position>
+               <base-type>G</base-type>
+               <atom serial="407">
+                  <atom-type> P  </atom-type>
+                     <coordinates>-21.585 16.199 -6.397</coordinates>
+               </atom>
+               <atom serial="415">
+                  <atom-type> O3'</atom-type>
+                     <coordinates>-18.522 13.024 -10.277</coordinates>
+               </atom>
+            </base>
+            <str-annotation>
+               <base-pair comment="?">
+                  <base-id-5p>
+                     <base-id><position>1</position></base-id>
+                  </base-id-5p>
+                  <base-id-3p>
+                     <base-id><position>2</position></base-id>
+                  </base-id-3p>
+                  <edge-5p>S</edge-5p>
+                  <edge-3p>H</edge-3p>
+                  <bond-orientation>c</bond-orientation>
+               </base-pair>
+               <base-pair comment="?">
+                  <base-id-5p>
+                     <base-id><position>6</position></base-id>
+                  </base-id-5p>
+                  <base-id-3p>
+                     <base-id><position>20</position></base-id>
+                  </base-id-3p>
+                  <edge-5p>+</edge-5p>
+                  <edge-3p>+</edge-3p>
+                  <bond-orientation>c</bond-orientation>
+               </base-pair>
+               <base-pair comment="?">
+                  <base-id-5p>
+                     <base-id><position>7</position></base-id>
+                  </base-id-5p>
+                  <base-id-3p>
+                     <base-id><position>19</position></base-id>
+                  </base-id-3p>
+                  <edge-5p>-</edge-5p>
+                  <edge-3p>-</edge-3p>
+                  <bond-orientation>c</bond-orientation>
+               </base-pair>
+               <base-pair comment="?">
+                  <base-id-5p>
+                     <base-id><position>8</position></base-id>
+                  </base-id-5p>
+                  <base-id-3p>
+                     <base-id><position>18</position></base-id>
+                  </base-id-3p>
+                  <edge-5p>+</edge-5p>
+                  <edge-3p>+</edge-3p>
+                  <bond-orientation>c</bond-orientation>
+               </base-pair>
+               <base-pair comment="?">
+                  <base-id-5p>
+                     <base-id><position>9</position></base-id>
+                  </base-id-5p>
+                  <base-id-3p>
+                     <base-id><position>17</position></base-id>
+                  </base-id-3p>
+                  <edge-5p>+</edge-5p>
+                  <edge-3p>+</edge-3p>
+                  <bond-orientation>c</bond-orientation>
+               </base-pair>
+               <base-pair comment="?">
+                  <base-id-5p>
+                     <base-id><position>10</position></base-id>
+                  </base-id-5p>
+                  <base-id-3p>
+                     <base-id><position>16</position></base-id>
+                  </base-id-3p>
+                  <edge-5p>+</edge-5p>
+                  <edge-3p>+</edge-3p>
+                  <bond-orientation>c</bond-orientation>
+               </base-pair>
+               <base-pair comment="?">
+                  <base-id-5p>
+                     <base-id><position>11</position></base-id>
+                  </base-id-5p>
+                  <base-id-3p>
+                     <base-id><position>15</position></base-id>
+                  </base-id-3p>
+                  <edge-5p>S</edge-5p>
+                  <edge-3p>H</edge-3p>
+                  <bond-orientation>t</bond-orientation>
+               </base-pair>
+               <base-pair comment="?">
+                  <base-id-5p>
+                     <base-id><position>3</position></base-id>
+                  </base-id-5p>
+                  <base-id-3p>
+                     <base-id><position>4</position></base-id>
+                  </base-id-3p>
+                  <edge-5p>!</edge-5p>
+                  <edge-3p>!</edge-3p>
+                  <bond-orientation>!</bond-orientation>
+               </base-pair>
+               <base-pair comment="?">
+                  <base-id-5p>
+                     <base-id><position>14</position></base-id>
+                  </base-id-5p>
+                  <base-id-3p>
+                     <base-id><position>15</position></base-id>
+                  </base-id-3p>
+                  <edge-5p>!</edge-5p>
+                  <edge-3p>!</edge-3p>
+                  <bond-orientation>!</bond-orientation>
+               </base-pair>
+               <helix id="H1">
+                  <base-id-5p>
+                     <base-id><position>6</position></base-id>
+                  </base-id-5p>
+                  <base-id-3p>
+                     <base-id><position>20</position></base-id>
+                  </base-id-3p>
+                  <length>6</length>
+               </helix>
+               <single-strand>
+                  <segment>
+                     <seg-name>SG1</seg-name>
+                     <base-id-5p><base-id><position>1</position></base-id></base-id-5p>
+                     <base-id-3p><base-id><position>5</position></base-id></base-id-3p>
+                  </segment>
+               </single-strand>
+               <single-strand>
+                  <segment>
+                     <seg-name>SG2</seg-name>
+                     <base-id-5p><base-id><position>12</position></base-id></base-id-5p>
+                     <base-id-3p><base-id><position>14</position></base-id></base-id-3p>
+                  </segment>
+               </single-strand>
+            </str-annotation>
+            <secondary-structure-display comment="x,y coodinates">
+               <ss-base-coord>
+                  <base-id><position>1</position></base-id>
+                  <coordinates>133.930 0.000</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>2</position></base-id>
+                  <coordinates>133.930 33.482</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>3</position></base-id>
+                  <coordinates>133.930 66.965</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>4</position></base-id>
+                  <coordinates>133.930 100.447</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>5</position></base-id>
+                  <coordinates>133.930 133.930</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>6</position></base-id>
+                  <coordinates>133.930 167.412</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>7</position></base-id>
+                  <coordinates>133.930 223.216</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>8</position></base-id>
+                  <coordinates>133.930 279.021</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>9</position></base-id>
+                  <coordinates>133.930 334.825</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>10</position></base-id>
+                  <coordinates>133.930 390.629</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>11</position></base-id>
+                  <coordinates>133.930 446.433</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>12</position></base-id>
+                  <coordinates>128.630 516.439</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>13</position></base-id>
+                  <coordinates>66.965 550.000</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>14</position></base-id>
+                  <coordinates>5.300 516.439</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>15</position></base-id>
+                  <coordinates>0.000 446.433</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>16</position></base-id>
+                  <coordinates>0.000 390.629</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>17</position></base-id>
+                  <coordinates>0.000 334.825</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>18</position></base-id>
+                  <coordinates>0.000 279.021</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>19</position></base-id>
+                  <coordinates>0.000 223.216</coordinates>
+               </ss-base-coord>
+               <ss-base-coord>
+                  <base-id><position>20</position></base-id>
+                  <coordinates>0.000 167.412</coordinates>
+               </ss-base-coord>
+            </secondary-structure-display>
+         </model>
+      </structure>
+   </molecule>
+
+
+   <interactions>
+            <str-annotation>
+            </str-annotation>
+   </interactions>
+</rnaml>
index 35bd812..25d39f4 100644 (file)
@@ -1 +1 @@
-1.8.3-1.2.14_FJVL
+1.8.3-1.3.0_FJVL
index 0a14c3b..12110b2 100644 (file)
@@ -1 +1 @@
-1.8.3-1.2.14_JVL
+1.8.3-1.3.0_JVL
index 7c99c93..fb8f1bc 100644 (file)
Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ
index c6901ae..c74dcc5 100644 (file)
Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ
index 24e3eb2..e1f1726 100644 (file)
Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ
index b0c54e2..d8bb7e9 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.threerings.getdown</groupId>
     <artifactId>getdown</artifactId>
-    <version>1.8.3-1.2.14_FJVL</version>
+    <version>1.8.3-1.3.0_FJVL</version>
   </parent>
 
   <artifactId>getdown-ant</artifactId>
index 5dd429d..6126686 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.threerings.getdown</groupId>
     <artifactId>getdown</artifactId>
-    <version>1.8.3-1.2.14_FJVL</version>
+    <version>1.8.3-1.3.0_FJVL</version>
   </parent>
 
   <artifactId>getdown-core</artifactId>
index 0781a11..1faaa28 100644 (file)
@@ -17,6 +17,8 @@ import javax.xml.bind.DatatypeConverter;
 
 import java.security.MessageDigest;
 
+import jalview.util.LaunchUtils;
+
 import static com.threerings.getdown.Log.log;
 
 /**
@@ -88,6 +90,7 @@ public class LaunchUtil
         return getJVMPath(appdir, false);
     }
 
+    private static String jvmPath = null;
     /**
      * Reconstructs the path to the JVM used to launch this process.
      *
@@ -95,22 +98,27 @@ public class LaunchUtil
      */
     public static String getJVMPath (File appdir, boolean windebug)
     {
-        // first look in our application directory for an installed VM
-        String vmpath = checkJVMPath(new File(appdir, LOCAL_JAVA_DIR).getAbsolutePath(), windebug);
-        if (vmpath == null && isMacOS()) {
-                       vmpath = checkJVMPath(new File(appdir, LOCAL_JAVA_DIR + "/Contents/Home").getAbsolutePath(), windebug);
+        if (jvmPath != null) {
+          return jvmPath;
         }
+        
+        // first look in our application directory for an installed VM
+        final String appDir = isMacOS() ?
+                        (new File(appdir, LOCAL_JAVA_DIR).getAbsolutePath()) + "/Contents/Home"
+                        : new File(appdir, LOCAL_JAVA_DIR).getAbsolutePath();
+
+        String javaBin = LaunchUtils.findJavaBin(appDir, windebug, false);
 
         // then fall back to the VM in which we're already running
-        if (vmpath == null) {
-            vmpath = checkJVMPath(System.getProperty("java.home"), windebug);
+        if (javaBin == null) {
+            javaBin = LaunchUtils.findJavaBin(System.getProperty("java.home"), windebug, false);
         }
 
         // then throw up our hands and hope for the best
-        if (vmpath == null) {
+        if (javaBin == null) {
+            javaBin = LaunchUtils.findJavaBin(null, windebug, true);
             log.warning("Unable to find java [appdir=" + appdir +
                         ", java.home=" + System.getProperty("java.home") + "]!");
-            vmpath = "java";
         }
 
         // Oddly, the Mac OS X specific java flag -Xdock:name will only work if java is launched
@@ -120,15 +128,16 @@ public class LaunchUtil
         if (isMacOS()) {
             try {
                 File localVM = new File("/usr/bin/java").getCanonicalFile();
-                if (localVM.equals(new File(vmpath).getCanonicalFile())) {
-                    vmpath = "/usr/bin/java";
+                if (localVM.equals(new File(javaBin).getCanonicalFile())) {
+                    javaBin = "/usr/bin/java";
                 }
             } catch (IOException ioe) {
                 log.warning("Failed to check Mac OS canonical VM path.", ioe);
             }
         }
 
-        return vmpath;
+        jvmPath = javaBin;
+        return jvmPath;
     }
 
     private static String _getMD5FileChecksum (File file) {
index ee3b2c6..784eb5a 100644 (file)
@@ -32,6 +32,16 @@ import java.util.Properties;
 public class LaunchUtils
 {
 
+  // setting these is LaunchUtils so don't need to import Platform
+  public final static boolean isMac = System.getProperty("os.name")
+          .indexOf("Mac") > -1;
+
+  public final static boolean isWindows = System.getProperty("os.name")
+          .indexOf("Win") > -1;
+
+  private static boolean isJS = /** @j2sNative true || */
+          false;
+
   public static void loadChannelProps(File dir)
   {
     ChannelProperties.loadProps(dir);
@@ -81,7 +91,11 @@ public class LaunchUtils
 
   public static int getJavaCompileVersion()
   {
-    if (JAVA_COMPILE_VERSION > 0)
+    if (LaunchUtils.isJS)
+    {
+      return -1;
+    }
+    else if (JAVA_COMPILE_VERSION > 0)
     {
       return JAVA_COMPILE_VERSION;
     }
@@ -125,7 +139,11 @@ public class LaunchUtils
 
   public static int getJavaVersion()
   {
-    if (JAVA_VERSION > 0)
+    if (LaunchUtils.isJS)
+    {
+      return -1;
+    }
+    else if (JAVA_VERSION > 0)
     {
       return JAVA_VERSION;
     }
@@ -153,6 +171,10 @@ public class LaunchUtils
 
   public static boolean checkJavaVersion()
   {
+    if (LaunchUtils.isJS)
+    {
+      return true;
+    }
     String buildDetails = "jar:".concat(LaunchUtils.class
             .getProtectionDomain().getCodeSource().getLocation().toString()
             .concat("!" + "/.build_properties"));
@@ -174,4 +196,88 @@ public class LaunchUtils
 
     return true;
   }
+
+  public static String findJavaBin(boolean winConsole)
+  {
+    return findJavaBin(System.getProperty("java.home"), winConsole, true);
+  }
+
+  /*
+   * Returns a string path to the most likely java binary wanted to run this
+   * installation of Jalview.
+   * 
+   * @param  winConsole  whether to use java.exe (console) in preference to javaw.exe
+   *                     (only affects Windows).
+   * @param  javaHome    Try this javaHome dir (defaults to the running java.home).
+   * @param  generic     Return a generic java command if not found.
+   */
+  public static String findJavaBin(String javaHome, boolean winConsole,
+          boolean generic)
+  {
+    String javaBin = null;
+    final String javaExe = winConsole ? "java.exe" : "javaw.exe";
+    final String java = "java";
+
+    if (javaHome != null)
+    {
+      // property "channel.app_name" is set by install4j when launching getdown
+      String propertyAppName = System.getProperty("channel.app_name");
+      final String appName = (propertyAppName != null
+              && propertyAppName.length() > 0) ? propertyAppName
+                      : ChannelProperties.getProperty("app_name");
+
+      final String javaBinDir = javaHome + File.separator + "bin"
+              + File.separator;
+
+      // appName and "Jalview" will not point to javaw.exe or java.exe but in
+      // this case that's okay because the taskbar display name problem doesn't
+      // manifest in Windows. See JAL-3820, JAL-4189.
+      for (String name : new String[] { appName, "Jalview", java, javaExe })
+      {
+        if (LaunchUtils.checkJVMSymlink(javaBinDir + name, winConsole))
+        {
+          javaBin = javaBinDir + name;
+          break;
+        }
+      }
+    }
+
+    if (javaBin == null && generic)
+    {
+      javaBin = LaunchUtils.isWindows ? javaExe : java;
+    }
+
+    return javaBin;
+  }
+
+  /*
+   * checkJVMSymlink returns true if the path in testBin *is* a java binary, or
+   * points to a java binary.
+   * @param  testBin     The binary or symbolic link to check
+   * @param  winConsole  whether we are in/want a Windows console (only relevant for Windows,
+   *                     determines whether we use java.exe or javaw.exe)
+   */
+  private static boolean checkJVMSymlink(String testBin, boolean winConsole)
+  {
+    File testBinFile = new File(testBin);
+    if (!testBinFile.exists())
+    {
+      return false;
+    }
+    File targetFile = null;
+    try
+    {
+      targetFile = testBinFile.getCanonicalFile();
+    } catch (IOException e)
+    {
+      return false;
+    }
+    final String javaExe = winConsole ? "java.exe" : "javaw.exe";
+    if (targetFile != null && ("java".equals(targetFile.getName())
+            || javaExe.equals(targetFile.getName())))
+    {
+      return true;
+    }
+    return false;
+  }
 }
index ea3b6ef..4374899 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.threerings.getdown</groupId>
     <artifactId>getdown</artifactId>
-    <version>1.8.3-1.2.14_FJVL</version>
+    <version>1.8.3-1.3.0_FJVL</version>
   </parent>
 
   <artifactId>getdown-launcher</artifactId>
index b30194f..ba092a7 100755 (executable)
@@ -3,7 +3,7 @@
 if [ x$JVLVERSION != x ]; then
   export VERSION=$JVLVERSION
 else
-  export VERSION=1.8.3-1.2.14_JVL
+  export VERSION=1.8.3-1.3.0_JVL
 fi
 
 if [ x${VERSION%_JVL} = x$VERSION ]; then
index ef8c811..51e9514 100644 (file)
@@ -10,7 +10,7 @@
   <groupId>com.threerings.getdown</groupId>
   <artifactId>getdown</artifactId>
   <packaging>pom</packaging>
-  <version>1.8.3-1.2.14_FJVL</version>
+  <version>1.8.3-1.3.0_FJVL</version>
 
   <name>getdown</name>
   <description>An application installer and updater.</description>
index 75231f3..547304f 100644 (file)
@@ -201,7 +201,7 @@ jalviewjs_j2s_alt_file_property_config = j2s.config.altfileproperty
 # for developing in Eclipse as IDE, set this to automatically copy current swingjs/net.sf.j2s.core.jar to your dropins dir
 jalviewjs_eclipseIDE_auto_copy_j2s_plugin = false
 # Override this in a local.properties file
-jalviewjs_eclipse_root = ~/buildtools/eclipse/jee-2019-09
+jalviewjs_eclipse_root = ~/buildtools/eclipse/latest
 
 jalviewjs_eclipse_dropins_dir = utils/jalviewjs/eclipse/dropins
 jalviewjs_swingjs_zip = swingjs/SwingJS-site.zip
@@ -264,7 +264,8 @@ jalviewjs_j2s_closure_stdout = j2s-closure.out
 jalviewjs_chromium_binary = ~/buildtools/chromium/chrome
 jalviewjs_macos_chromium_binary = /Applications/Chromium.app/Contents/MacOS/Chromium
 jalviewjs_chromium_user_dir = chromium
-jalviewjs_chromium_timeout = 30
+jalviewjs_chromium_idle_timeout = 10
+jalviewjs_chromium_overall_timeout = 40
 jalviewjs_chromium_profile_name = BUILD
 jalviewjs_stderr_launch = utils/jalviewjs/chromium_test/jalview_bin_Jalview-stderr.html
 jalviewjs_desktop_init_string = JALVIEWJS: CREATED DESKTOP
index 7a87602..7eb2294 100644 (file)
   <code>phylip</code> (<code>phy</code>),
   <br/>
   <code>jalview</code> (<code>jvp, jar</code>).
+  </p>
   <p>
   For example, to open a FASTA file, append another FASTA file and then save the concatenation as a Stockholm file, do
   <pre>
   </p>
 
   <p>
-  <em>Important!</em> If you use <code>--output</code> or any other argument that outputs a file, then it will be assumed you want to run Jalview in headless mode (as if you had specified <code>--headless</code>).  To use Jalview with <code>--output</code> and not assume headless mode, use the <code>--gui</code> or <code>--noheadless</code> argument (the order doesn't matter).
+  <em>Important!</em> If you use <code>--output</code> or any other argument that outputs a file, then it will be assumed you want to run Jalview in headless mode (as if you had specified <code>--headless</code>).  To use Jalview with <code>--output</code> and not assume headless mode, use the <code>--gui</code> argument (the order doesn't matter).
+  </p>
+
+  <p>
+  If you would like to output an alignment file directly to standard output (often referred to as STDOUT), then use the filename <code>-</code> (a single hyphen).  In this case any messages that would normally appear on STDOUT will be diverted to STDERR to avoid invalidating the output file.
+  </p>
+  <p>
+  For example, to open a Stockholm file and pipe it to another command as a Block file, do
+  <pre>
+  jalview --open alignment1.stk --output - --format blc | another_command
+  </pre>
+  or equivalently
+  <pre>
+  jalview alignment1.stk --output=[format=blc]- | another_command
+  </pre>
   </p>
 
   <h3><a name="format"></a><code>--format</code></h3>
index dd0bd52..60951d8 100644 (file)
     <tr valign="top"><td><code>&#8209;&#8209;help&#8209;all</code></td><td>Help for all arguments</td></tr>
 
     <tr valign="top">
-    <td><code>&#8209;&#8209;headless / &#8209;&#8209;noheadless</code></td>
-    <td>Run Jalview in headless (/ or not in headless) mode.  In headless mode, no GUI interface will be created and Jalview will quit after all arguments have been processed.
+    <td><code>&#8209;&#8209;headless</code></td>
+    <td>Run Jalview in headless mode.  In headless mode, no GUI interface will be created and Jalview will quit after all arguments have been processed.
     <br/>
-    If you use a command line argument to specify an output file of some kind (<code>--output</code>, <code>--image</code> or <code>--structureimage</code>) then <strong>headless mode will be assumed</strong>.  If you don't want this behaviour use <code>--noheadless</code> or <code>--gui</code>.
+    If you use a command line argument to specify an output file of some kind (<code>--output</code>, <code>--image</code> or <code>--structureimage</code>) then <strong>headless mode will be assumed</strong>.  If you don't want this behaviour use <code>--gui</code>.
     </td>
     </tr>
 
     <code>phylip</code> (<code>phy</code>),
     <br/>
     <code>jalview</code> (<code>jvp, jar</code>).
+    <br/>
+    To output directly to STDOUT (console output) use the filename <code>-</code> (a single hyphen).  In this case all STDOUT messages will instead go to STDERR.  If no <code>format</code> is supplied then Fasta will be assumed.
     </td>
     <td><code>format=<em>name</em></code></td>
     <td align="center">&#x2713;</td>
index b763a81..7c2e9d5 100644 (file)
   <strong>If you specify an argument for an output file</strong> (one or more of <code>--output</code>, <code>--image</code> or <code>--structureimage</code>) then it will be assumed that you wish to <strong>run in headless mode</strong>.
   </p>
   <p>
-  You can force Jalview to run in graphical mode using the <code>--gui</code> or <code>--noheadless</code> arguments.
+  You can force Jalview to run in graphical mode using the <code>--gui</code> argument.
   </p>
 
   <p>
index 9ad61b5..8704ce8 100644 (file)
   <p>Usage data is collected from the logs of various web services
     that the Jalview Desktop contacts through its normal operation.
     These are described below:</p>
-  <ul>
-    <li><em>HTTP logs on the Jalview website</em><br> We
-      record IP addresses of machines which access the web site, either
-      via the browser when downloading the application, or when the
-      Jalview Desktop user interface is launched.<br> <br>
-      <ul>
-        <li><i>The Jalview Getdown Launcher</i> (Since 2.11.0) examines release
-          channels every time Jalview launches to determine if a new
-          release is available.</li>
-        <li><i>The questionnaire web service at
-            www.jalview.org/cgi-bin/questionnaire.pl is checked and a
-            unique cookie for the current questionnaire is stored in the
-            Jalview properties file.</i></li>
-        <li><i>The Jalview web services stack is contacted to
-            retrieve the currently available web services. All
-            interactions with the public Jalview web services are
-            logged, but we delete all job data (input data and results)
-            after about two weeks.</i></li>
-      </ul> <br></li>
-    <li><em>Google Analytics</em><br> Since Jalview 2.4.0b2,
-      the Jalview Desktop records usage data with Google Analytics via
-      the <a href="http://code.google.com/p/jgoogleanalytics/">JGoogleAnalytics</a>
-      class.<br> The Google Analytics logs for Jalview version 2.4
-      only record the fact that the application was started, but in the
-      future, we will use this mechanism to improve the Desktop user
-      interface, by tracking which parts of the user interface are being
-      used most often.</li>
-  </ul>
-  </p>
+       <ul>
+               <li><em>HTTP logs on the Jalview website</em><br> We record
+                       IP addresses of machines which access the web site, either via the
+                       browser when downloading the application, or when the Jalview Desktop
+                       user interface is launched.<br> <br>
+                       <ul>
+                               <li><i>The Jalview Getdown Launcher</i> (Since 2.11.0) examines
+                                       release channels every time Jalview launches to determine if a new
+                                       release is available.</li>
+                               <li><i>The questionnaire web service at
+                                               www.jalview.org/cgi-bin/questionnaire.pl is checked and a unique
+                                               cookie for the current questionnaire is stored in the Jalview
+                                               properties file.</i></li>
+                               <li><i>The Jalview web services stack is contacted to
+                                               retrieve the currently available web services. All interactions
+                                               with the public Jalview web services are logged, but we delete all
+                                               job data (input data and results) after about two weeks.</i></li>
+                       </ul> <br></li>
+               <li><em>Usage Analytics</em><br> Since Jalview 2.11.2.7, the
+                       Jalview Desktop records usage data with a self-hosted instance of the
+                       analytics stack <a href="https://plausible.io">Plausible.io</a> via a
+                       custom GPLv3 client developed by Ben Soares. Prior to this, Jalview
+                       versions as far back as 2.4 recorded application launches via <a
+                       href="http://code.google.com/p/jgoogleanalytics/">JGoogleAnalytics</a>
+                       .<br> Usage logs for Jalview record the fact that the
+                       application was started, and details about the OS, installed Jalview
+                       launcher (if any) and java version used. In the future, we will use
+                       this mechanism to improve the Desktop user interface, by tracking
+                       which parts of the user interface are being used most often.</li>
+       </ul>
   <p>
     <strong>Stopping Jalview from calling home</strong><br> If you
     run Jalview in 'headless mode' via the command line, then the
diff --git a/help/help/icons/jalview_docs_logo.png b/help/help/icons/jalview_docs_logo.png
new file mode 100644 (file)
index 0000000..21f5386
Binary files /dev/null and b/help/help/icons/jalview_docs_logo.png differ
diff --git a/help/markdown/releases/release-2_11_2_7.md b/help/markdown/releases/release-2_11_2_7.md
new file mode 100644 (file)
index 0000000..361d39a
--- /dev/null
@@ -0,0 +1,12 @@
+---
+version: 2.11.2.7
+date: 2023-06-30
+channel: "release"
+---
+
+## New Features
+- <!-- JAL-4001 --> Jalview now reports usage statistics via Plausible.io
+
+## Issues Resolved
+- <!-- JAL-4116 --> PDB structures slow to view when Jalview Java console is open
+- <!-- JAL-4216 --> chains in PDB or mmCIF files with negative RESNUMs not correctly parsed
index 1309483..206bbba 100644 (file)
@@ -1,6 +1,6 @@
 ---
 version: 2.11.3.0
-date: 2023-06-07
+date: 2023-07-19
 channel: "release"
 ---
 
@@ -20,6 +20,9 @@ channel: "release"
 - <!-- JAL-4089 --> Use selected columns for superposition
 - <!-- JAL-4086 --> Highlight aligned positions on all associated structures when mousing over a column
 
+- <!-- JAL-4221 --> sequence descriptions are updated from database reference sources if not already defined
+
+
 ### Improved support for working with computationally determined models
 
 - <!-- JAL-3895 --> Alphafold red/orange/yellow/green colourscheme for structures
@@ -35,6 +38,8 @@ channel: "release"
 - <!-- JAL-3858 --> Import and display alphafold alignment uncertainty matrices from JSON
 - <!-- JAL-4134,JAL-4158 --> Column-wise alignment groups and selections and interactive tree viewer for PAE matrices
 - <!-- JAL-4124 --> Store/Restore PAE data and visualisation settings from Jalview Project
+- <!-- JAL-4083 --> Multiple residue sidechain highlighting in structure viewers from PAE mouseovers
+
 
 ### Jalview on the command line
 
@@ -44,6 +49,21 @@ channel: "release"
 ### Other improvements
 
 - <!-- JAL-3119 --> Name of alignment and view included in overview window's title
+- <!-- JAL-4213 --> "add reference annotation" add all positions in reference annotation tracks, not just positions in the currently highlighted columns/selection range
+- <!-- JAL-4119 --> EMBL-EBI SIFTS file downloads now use split directories
+
+- <!-- JAL-4195,JAL-4194,JAL-4193 --> sensible responses from the CLI when things go wrong during image export
+Add a command line option to set Jalview properties for this session only
+Add a command line option to suppress opening the startup file for this session
+
+
+JAL-4187        Powershell launcher script fails when given no arguments with the old ArgsParser
+
+known issue ? <!-- JAL-4127    --> 'Reload' for a jalview project results in all windows being duplicated
+
+
+- <!-- JAL-3830 --> Command-line wrapper script for macOS bundle, linux and Windows installations (bash, powershell and .bat wrappers)
+- <!-- JAL-3820 --> In Linux desktops' task-managers, the grouped Jalview windows get a generic name
 
 ## Still in progress (delete on release)
 
@@ -55,6 +75,7 @@ channel: "release"
 
 - <!-- JAL-4167 --> Create separate gradle test task for some tests
 - <!-- JAL-4111 --> Allow gradle build to create suffixed DEVELOP-... builds with channel appbase
+- <!-- JAL-4243 --> Jalview bio.tools description maintained under jalview's git repo and bundled with source release
 
 ## Issues Resolved
 - <!-- JAL-2961 --> Jmol view not always centred on structures when multiple structures are viewed
@@ -75,3 +96,12 @@ channel: "release"
 - <!-- JAL-4150 --> Sequences copied to clipboard from within Jalview cannot be pasted via the desktop's popup menu to a new alignment window
 - <!-- JAL-2528, JAL-1713 --> Overview window is saved in project file, and state of 'show hidden regions' is preserved.
 - <!-- JAL-4153 --> JvCacheableInputBoxTest flaky on build server
+
+## New Known defects
+- <!-- JAL-4178 --> Cannot cancel structure view open action once it has been started via the structure chooser dialog
+- <!-- JAL-4142 --> Example project's multiple views do not open in distinct locations when eXpand views is used to show them all separately
+- <!-- JAL-4165 --> Missing last letter when copying consensus sequence from alignment if first column is hidden
+
+
+
+
diff --git a/help/markdown/whatsnew/whatsnew-2_11_2_7.md b/help/markdown/whatsnew/whatsnew-2_11_2_7.md
new file mode 100644 (file)
index 0000000..f884134
--- /dev/null
@@ -0,0 +1,5 @@
+Jalview 2.11.2.7 is a minor patch release - it includes patches affecting efficiency when importing structures and a small revision to the import processing of structures with negative residue numbering. 
+
+With this release, Jalview usage statistics are now collected by a jalview.org hosted instance of the open source privacy-preserving analytics stack, Plausible.io. 
+
+
index 59495d5..ec82f83 100644 (file)
@@ -1,5 +1,7 @@
 The 2.11.3 series includes support for in-depth exploration of predicted alignment error matrices from AlphaFold in the context of multiple alignments, along with support for standard colourschemes for shading models according to their pLDDT.
 
+We're launching this release at ISMB 2023 - come find us !
+
 It also introduces new support for native ARM-based OSX architectures, and a few other goodies!
 
 
diff --git a/j11lib/JGoogleAnalytics_0.3.jar b/j11lib/JGoogleAnalytics_0.3.jar
deleted file mode 100644 (file)
index 0dbc98c..0000000
Binary files a/j11lib/JGoogleAnalytics_0.3.jar and /dev/null differ
diff --git a/j11lib/flatlaf-3.0.jar b/j11lib/flatlaf-3.0.jar
deleted file mode 100644 (file)
index 75d90d3..0000000
Binary files a/j11lib/flatlaf-3.0.jar and /dev/null differ
diff --git a/j11lib/flatlaf-3.1.1.jar b/j11lib/flatlaf-3.1.1.jar
deleted file mode 100644 (file)
index 2b13cdd..0000000
Binary files a/j11lib/flatlaf-3.1.1.jar and /dev/null differ
diff --git a/j11lib/flatlaf-3.2.jar b/j11lib/flatlaf-3.2.jar
new file mode 100644 (file)
index 0000000..450c1e8
Binary files /dev/null and b/j11lib/flatlaf-3.2.jar differ
diff --git a/j11lib/flatlaf-extras-3.0.jar b/j11lib/flatlaf-extras-3.0.jar
deleted file mode 100644 (file)
index 1f6bbc3..0000000
Binary files a/j11lib/flatlaf-extras-3.0.jar and /dev/null differ
similarity index 52%
rename from j11lib/flatlaf-extras-3.1.1.jar
rename to j11lib/flatlaf-extras-3.2.jar
index 9d91bd0..ccdbf94 100644 (file)
Binary files a/j11lib/flatlaf-extras-3.1.1.jar and b/j11lib/flatlaf-extras-3.2.jar differ
index 7c99c93..fb8f1bc 100644 (file)
Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ
diff --git a/j8lib/JGoogleAnalytics_0.3.jar b/j8lib/JGoogleAnalytics_0.3.jar
deleted file mode 100644 (file)
index 0dbc98c..0000000
Binary files a/j8lib/JGoogleAnalytics_0.3.jar and /dev/null differ
diff --git a/j8lib/flatlaf-3.1.1.jar b/j8lib/flatlaf-3.1.1.jar
deleted file mode 100644 (file)
index 2b13cdd..0000000
Binary files a/j8lib/flatlaf-3.1.1.jar and /dev/null differ
diff --git a/j8lib/flatlaf-3.2.jar b/j8lib/flatlaf-3.2.jar
new file mode 100644 (file)
index 0000000..450c1e8
Binary files /dev/null and b/j8lib/flatlaf-3.2.jar differ
similarity index 52%
rename from j8lib/flatlaf-extras-3.1.1.jar
rename to j8lib/flatlaf-extras-3.2.jar
index 9d91bd0..ccdbf94 100644 (file)
Binary files a/j8lib/flatlaf-extras-3.1.1.jar and b/j8lib/flatlaf-extras-3.2.jar differ
index 7c99c93..fb8f1bc 100644 (file)
Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ
index 7f5746e..45ed727 100644 (file)
@@ -363,6 +363,7 @@ label.sequences_from = Sequences from {0}
 label.successfully_loaded_file  = Successfully loaded file {0}
 label.successfully_loaded_matrix  = Successfully loaded score matrix {0}
 label.successfully_saved_to_file_in_format = Successfully saved to file: {0} in {1} format.
+label.successfully_printed_to_stdout_in_format = Successfully printed to STDOUT in {0} format.
 label.copied_sequences_to_clipboard = Copied {0} sequences to clipboard.
 label.check_file_matches_sequence_ids_alignment = Check that the file matches sequence IDs in the alignment.
 label.problem_reading_tcoffee_score_file = Problem reading T-COFFEE score file
@@ -1452,8 +1453,8 @@ label.choose_tempfac_type = Choose Temperature Factor type
 label.interpret_tempfac_as = Interpret Temperature Factor as
 label.add_pae_matrix_file = Add PAE matrix file
 label.nothing_selected = Nothing selected
-prompt.google_analytics_title = Jalview Usage Statistics
-prompt.google_analytics = Do you want to help make Jalview better by enabling the collection of usage statistics with Google Analytics?\nYou can enable or disable usage tracking in the preferences.
+prompt.analytics_title = Jalview Usage Statistics
+prompt.analytics = Do you want to help make Jalview better by enabling the collection of usage statistics with Plausible analytics?\nYou can enable or disable usage tracking in the preferences.
 label.working_ellipsis = Working ... 
 action.show_groups_on_matrix = Show groups on matrix
 action.show_groups_on_matrix_tooltip = When enabled, clusters defined on the matrix's associated tree or below the assigned threshold are shown as different colours on the matrix annotation row
index a4594dc..5dd8b3d 100644 (file)
@@ -326,6 +326,7 @@ label.sequences_from = Secuencias de {0}
 label.successfully_loaded_file  = Fichero cargado exitosamente {0}
 label.successfully_loaded_matrix  = Matriz cargada exitosamente {0}
 label.successfully_saved_to_file_in_format = Guardado exitosamente en el fichero: {0} en formato {1}.
+label.successfully_printed_to_stdout_in_format = Impresso exitosamente al STDOUT en formato {0}.
 label.copied_sequences_to_clipboard = Copiadas {0} secuencias en el portapapeles.
 label.check_file_matches_sequence_ids_alignment = Comprobar que el fichero coincide con el ID de la secuencia en el alineamiento.
 label.problem_reading_tcoffee_score_file = Problema de lectura del fichero de puntuaciones T-COFFEE
@@ -1434,5 +1435,5 @@ label.tftype_default = Default
 label.tftype_plddt = pLDDT
 label.add_pae_matrix_file = Añadir un fichero de matriz PAE
 label.nothing_selected = Nada seleccionado
-prompt.google_analytics_title = Jalview Estadísticas de Uso
-prompt.google_analytics = ¿Quiere ayudar a mejorar Jalview habilitando la recopilación de estadísticas de uso con Google Analytics?\nPuede habilitar o deshabilitar el seguimiento de uso en las preferencias.
+prompt.analytics_title = Jalview Estadísticas de Uso
+prompt.analytics = ¿Quiere ayudar a mejorar Jalview habilitando la recopilación de estadísticas de uso con análisis Plausible?\nPuede habilitar o deshabilitar el seguimiento de uso en las preferencias.
index b1505d6..6967885 100755 (executable)
@@ -147,7 +147,7 @@ public class AAFrequency
       {
         if (sequences[row] == null)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "WARNING: Consensus skipping null sequence - possible race condition.");
           continue;
         }
@@ -188,7 +188,7 @@ public class AAFrequency
     }
     return new Profiles(result);
     // long elapsed = System.currentTimeMillis() - now;
-    // System.out.println(elapsed);
+    // jalview.bin.Console.outPrintln(elapsed);
   }
 
   /**
@@ -285,7 +285,7 @@ public class AAFrequency
               ' ', value);
     }
     // long elapsed = System.currentTimeMillis() - now;
-    // System.out.println(-elapsed);
+    // jalview.bin.Console.outPrintln(-elapsed);
   }
 
   /**
index 65fd110..e1d5669 100755 (executable)
@@ -826,7 +826,7 @@ public class AlignSeq
       }
     }
 
-    System.out.println(max + " " + min);
+    jalview.bin.Console.outPrintln(max + " " + min);
 
     for (int i = 0; i < n; i++)
     {
@@ -835,12 +835,12 @@ public class AlignSeq
         int x = psize * i;
         int y = psize * j;
 
-        // System.out.println(mat[i][j]);
+        // jalview.bin.Console.outPrintln(mat[i][j]);
         float score = (float) (mat[i][j] - min) / (float) (max - min);
         g.setColor(new Color(score, 0, 0));
         g.fillRect(x, y, psize, psize);
 
-        // System.out.println(x + " " + y + " " + score);
+        // jalview.bin.Console.outPrintln(x + " " + y + " " + score);
       }
     }
   }
@@ -890,7 +890,8 @@ public class AlignSeq
         pdbpos++;
       }
 
-      if (allowmismatch || c1 == c2)
+      // ignore case differences
+      if (allowmismatch || (c1 == c2) || (Math.abs(c2-c1)==('a'-'A')))
       {
         // extend mapping interval
         if (lp1 + 1 != alignpos || lp2 + 1 != pdbpos)
@@ -982,7 +983,7 @@ public class AlignSeq
             bestm = msq;
           }
         }
-        // System.out.println("Best Score for " + (matches.size() + 1) + " :"
+        // jalview.bin.Console.outPrintln("Best Score for " + (matches.size() + 1) + " :"
         // + bestscore);
         matches.add(bestm);
         aligns.add(bestaseq);
index b02d49c..b037336 100755 (executable)
@@ -453,7 +453,7 @@ public class AlignmentSorter
 
       if (tmp.size() != nSeq)
       {
-        System.err.println("WARNING: tmp.size()=" + tmp.size() + " != nseq="
+        jalview.bin.Console.errPrintln("WARNING: tmp.size()=" + tmp.size() + " != nseq="
                 + nSeq
                 + " in getOrderByTree - tree contains sequences not in alignment");
       }
@@ -714,7 +714,7 @@ public class AlignmentSorter
       String msg = String.format(
               "Implementation Error - sortByFeature method must be either '%s' or '%s'",
               FEATURE_SCORE, FEATURE_DENSITY);
-      System.err.println(msg);
+      jalview.bin.Console.errPrintln(msg);
       return;
     }
 
@@ -832,7 +832,7 @@ public class AlignmentSorter
           {
             // int nf = (feats[i] == null) ? 0
             // : ((SequenceFeature[]) feats[i]).length;
-            // // System.err.println("Sorting on Score: seq " +
+            // // jalview.bin.Console.errPrintln("Sorting on Score: seq " +
             // seqs[i].getName()
             // + " Feats: " + nf + " Score : " + scores[i]);
           }
@@ -847,7 +847,7 @@ public class AlignmentSorter
         int featureCount = feats[i] == null ? 0
                 : ((SequenceFeature[]) feats[i]).length;
         scores[i] = featureCount;
-        // System.err.println("Sorting on Density: seq "+seqs[i].getName()+
+        // jalview.bin.Console.errPrintln("Sorting on Density: seq "+seqs[i].getName()+
         // " Feats: "+featureCount+" Score : "+scores[i]);
       }
       QuickSort.sortByDouble(scores, seqs, sortByFeatureAscending);
index 1158c53..f470dc6 100644 (file)
@@ -547,7 +547,7 @@ public class AlignmentUtils
       if (translated == null || !(aaRes == translated.charAt(0)))
       {
         // debug
-        // System.out.println(("Mismatch at " + i + "/" + aaResidue + ": "
+        // jalview.bin.Console.outPrintln(("Mismatch at " + i + "/" + aaResidue + ": "
         // + codon + "(" + translated + ") != " + aaRes));
         return false;
       }
@@ -698,7 +698,7 @@ public class AlignmentUtils
          * unmapped position; treat like a gap
          */
         sourceGapMappedLength += ratio;
-        // System.err.println("Can't align: no codon mapping to residue "
+        // jalview.bin.Console.errPrintln("Can't align: no codon mapping to residue "
         // + sourceDsPos + "(" + sourceChar + ")");
         // return;
         continue;
@@ -883,7 +883,7 @@ public class AlignmentUtils
   {
     if (protein.isNucleotide() || !dna.isNucleotide())
     {
-      System.err.println("Wrong alignment type in alignProteinAsDna");
+      jalview.bin.Console.errPrintln("Wrong alignment type in alignProteinAsDna");
       return 0;
     }
     List<SequenceI> unmappedProtein = new ArrayList<>();
@@ -908,7 +908,7 @@ public class AlignmentUtils
   {
     if (protein.isNucleotide() || !dna.isNucleotide())
     {
-      System.err.println("Wrong alignment type in alignProteinAsDna");
+      jalview.bin.Console.errPrintln("Wrong alignment type in alignProteinAsDna");
       return 0;
     }
     // todo: implement this
@@ -988,7 +988,7 @@ public class AlignmentUtils
                           .getLength() == mappedFromLength - 1);
           if (cdsLength != mappedToLength && !addStopCodon)
           {
-            System.err.println(String.format(
+            jalview.bin.Console.errPrintln(String.format(
                     "Can't align cds as protein (length mismatch %d/%d): %s",
                     cdsLength, mappedToLength, cdsSeq.getName()));
           }
@@ -1162,7 +1162,7 @@ public class AlignmentUtils
         AlignedCodon codon = sequenceCodon.getValue();
         if (codon.peptideCol > 1)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Problem mapping protein with >1 unmapped start positions: "
                           + seq.getName());
         }
@@ -1512,7 +1512,7 @@ public class AlignmentUtils
    * @param alignment
    *          the alignment to add them to
    * @param selectionGroup
-   *          current selection group (or null if none)
+   *          current selection group - may be null, if provided then any added annotation will be trimmed to just those columns in the selection group
    */
   public static void addReferenceAnnotations(
           Map<SequenceI, List<AlignmentAnnotation>> annotations,
@@ -1536,7 +1536,7 @@ public class AlignmentUtils
    * @param seq
    * @param ann
    * @param selectionGroup
-   *          - may be null
+   *          current selection group - may be null, if provided then any added annotation will be trimmed to just those columns in the selection group
    * @return annotation added to {@code seq and {@code alignment}
    */
   public static AlignmentAnnotation addReferenceAnnotationTo(
@@ -2770,7 +2770,7 @@ public class AlignmentUtils
                 fromRange[i + 1]);
         if (range == null)
         {
-          System.err.println("Error in mapping " + seqMap + " from "
+          jalview.bin.Console.errPrintln("Error in mapping " + seqMap + " from "
                   + fromSeq.getName());
           return false;
         }
index f4d69d5..d81dd44 100644 (file)
@@ -44,29 +44,31 @@ public class AverageDistanceEngine extends TreeEngine
 
   AlignmentAnnotation aa;
 
+  // 0 - normalised dot product
+  // 1 - L1 - ie (abs(v_1-v_2)/dim(v))
+  // L1 is more rational - since can reason about value of difference,
+  // normalised dot product might give cleaner clusters, but more difficult to
+  // understand.
+
+  int mode = 1;
+
   /**
    * compute cosine distance matrix for a given contact matrix and create a
    * UPGMA tree
-   * 
    * @param cm
+   * @param cosineOrDifference false - dot product : true - L1
    */
   public AverageDistanceEngine(AlignmentViewport av, AlignmentAnnotation aa,
-          ContactMatrixI cm)
+          ContactMatrixI cm, boolean cosineOrDifference)
   {
     this.av = av;
     this.aa = aa;
     this.cm = cm;
+    mode = (cosineOrDifference) ? 1 :0; 
     calculate(cm);
 
   }
 
-  // 0 - normalised dot product
-  // 1 - L1 - ie (abs(v_1-v_2)/dim(v))
-  // L1 is more rational - since can reason about value of difference,
-  // normalised dot product might give cleaner clusters, but more difficult to
-  // understand.
-
-  int mode = 1;
 
   public void calculate(ContactMatrixI cm)
   {
index cbc4dca..5bb0b09 100755 (executable)
@@ -243,13 +243,13 @@ public class Conservation
       }
       else
       {
-        System.out.println("SEQUENCE HAS BEEN DELETED!!!");
+        jalview.bin.Console.outPrintln("SEQUENCE HAS BEEN DELETED!!!");
       }
     }
     else
     {
       // JBPNote INFO level debug
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "ERROR: calcSeqNum called with out of range sequence index for Alignment\n");
     }
   }
@@ -711,7 +711,7 @@ public class Conservation
       // tmp = ((max - tmp) * (size - cons2[j][23])) / size;
       tmp = ((max - tmp) * (size - cons2GapCounts[j])) / size;
 
-      // System.out.println(tmp+ " " + j);
+      // jalview.bin.Console.outPrintln(tmp+ " " + j);
       quality.setElementAt(Double.valueOf(tmp), j);
 
       if (tmp > newmax)
index 9b90ca5..41582b4 100644 (file)
@@ -293,7 +293,7 @@ public class CrossRef
             if (matchInDataset != null && xref.getMap().getTo() != null
                     && matchInDataset != xref.getMap().getTo())
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "Implementation problem (reopen JAL-2154): CrossRef.findInDataset seems to have recovered a different sequence than the one explicitly mapped for xref."
                               + "Found:" + matchInDataset + "\nExpected:"
                               + xref.getMap().getTo() + "\nFor xref:"
@@ -424,7 +424,7 @@ public class CrossRef
       retrieved = sftch.getSequences(sourceRefs, !fromDna);
     } catch (Exception e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Problem whilst retrieving cross references for Sequence : "
                       + seq.getName());
       e.printStackTrace();
@@ -607,7 +607,7 @@ public class CrossRef
                 String msg = "Mapping updated from " + ms.getName()
                         + " to retrieved crossreference "
                         + matched.getName();
-                System.out.println(msg);
+                jalview.bin.Console.outPrintln(msg);
 
                 List<DBRefEntry> toRefs = map.getTo().getDBRefs();
                 if (toRefs != null)
@@ -662,7 +662,7 @@ public class CrossRef
               cf.addMap(retrievedSequence, map.getTo(), map.getMap());
             } catch (Exception e)
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "Exception when consolidating Mapped sequence set...");
               e.printStackTrace(System.err);
             }
@@ -1029,7 +1029,7 @@ public class CrossRef
     }
     if (dataset.getSequences() == null)
     {
-      System.err.println("Empty dataset sequence set - NO VECTOR");
+      jalview.bin.Console.errPrintln("Empty dataset sequence set - NO VECTOR");
       return false;
     }
     List<SequenceI> ds = dataset.getSequences();
@@ -1041,7 +1041,7 @@ public class CrossRef
         {
           if (nxt.getDatasetSequence() != null)
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Implementation warning: CrossRef initialised with a dataset alignment with non-dataset sequences in it! ("
                             + nxt.getDisplayId(true) + " has ds reference "
                             + nxt.getDatasetSequence().getDisplayId(true)
index 5dcf212..aa71eb7 100644 (file)
@@ -653,7 +653,7 @@ public class Dna
       if (rf != 0)
       {
         final String errMsg = "trimming contigs for incomplete terminal codon.";
-        System.err.println(errMsg);
+        jalview.bin.Console.errPrintln(errMsg);
         // map and trim contigs to ORF region
         vc = scontigs.length - 1;
         lastnpos = vismapping.shift(lastnpos); // place npos in context of
index 133cb3a..4c826b2 100644 (file)
@@ -140,7 +140,7 @@ public final class GeneticCodes
       InputStream is = getClass().getResourceAsStream(fileName);
       if (is == null)
       {
-        System.err.println("Resource file not found: " + fileName);
+        jalview.bin.Console.errPrintln("Resource file not found: " + fileName);
         return;
       }
       BufferedReader dataIn = new BufferedReader(new InputStreamReader(is));
@@ -166,7 +166,7 @@ public final class GeneticCodes
     }
     if (codeTables.isEmpty())
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "No genetic code tables loaded, check format of file "
                       + fileName);
     }
@@ -190,7 +190,7 @@ public final class GeneticCodes
       InputStream is = getClass().getResourceAsStream(fileName);
       if (is == null)
       {
-        System.err.println("Resource file not found: " + fileName);
+        jalview.bin.Console.errPrintln("Resource file not found: " + fileName);
         return;
       }
       BufferedReader dataIn = new BufferedReader(new InputStreamReader(is));
@@ -208,7 +208,7 @@ public final class GeneticCodes
           }
           else
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Unexpected data in " + fileName + ": " + line);
           }
         }
index 066814e..def5d5a 100644 (file)
@@ -269,7 +269,7 @@ public class Grouping
      * seqs.length) { for (int i = 0; i < seqs.length; i++) { if (!hasScore[i])
      * { scores[i] = (max + i); } else { int nf=(feats[i]==null) ? 0
      * :((SequenceFeature[]) feats[i]).length;
-     * System.err.println("Sorting on Score: seq "+seqs[i].getName()+
+     * jalview.bin.Console.errPrintln("Sorting on Score: seq "+seqs[i].getName()+
      * " Feats: "+nf+" Score : "+scores[i]); } } }
      * 
      * jalview.util.QuickSort.sort(scores, seqs); } else if
@@ -280,7 +280,7 @@ public class Grouping
      * (int i=0;i<seqs.length; i++) { double nf; scores[i] =
      * (0.05+fr*i)+(nf=((feats[i]==null) ? 0.0 :1.0*((SequenceFeature[])
      * feats[i]).length));
-     * System.err.println("Sorting on Density: seq "+seqs[i].getName()+
+     * jalview.bin.Console.errPrintln("Sorting on Density: seq "+seqs[i].getName()+
      * " Feats: "+nf+" Score : "+scores[i]); }
      * jalview.util.QuickSort.sort(scores, seqs); } else { if
      * (method==FEATURE_LABEL) { throw new Error("Not yet implemented."); } } if
index 4b68d93..94b7b99 100644 (file)
@@ -145,7 +145,7 @@ public class ParseProperties
                   ScoreNames[cols] + ((reps > 0) ? "_" + reps : ""),
                   ScoreDescriptions[cols], null);
           an.setScore(score);
-          System.out.println(seqs[i].getName() + " score: '"
+          jalview.bin.Console.outPrintln(seqs[i].getName() + " score: '"
                   + ScoreNames[cols] + "' = " + score); // DEBUG
           an.setSequenceRef(seqs[i]);
           seqs[i].addAlignmentAnnotation(an);
index 9649240..911ee04 100644 (file)
@@ -421,8 +421,8 @@ public class Rna
       final int open = basePair.getBP5();
       final int close = basePair.getBP3();
 
-      // System.out.println("open " + open + " close " + close);
-      // System.out.println("lastclose " + lastclose + " lastopen " + lastopen);
+      // jalview.bin.Console.outPrintln("open " + open + " close " + close);
+      // jalview.bin.Console.outPrintln("lastclose " + lastclose + " lastopen " + lastopen);
 
       // we're moving from right to left based on closing pair
       /*
@@ -441,7 +441,7 @@ public class Rna
       {
         int popen = bps.get(j).getBP5();
 
-        // System.out.println("j " + j + " popen " + popen + " lastopen "
+        // jalview.bin.Console.outPrintln("j " + j + " popen " + popen + " lastopen "
         // +lastopen + " open " + open);
         if ((popen < lastopen) && (popen > open))
         {
index fdca89d..837462f 100755 (executable)
@@ -129,7 +129,7 @@ public class SeqsetUtils
     {
       if (sfeatures != null)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Implementation error: setting dataset sequence for a sequence which has sequence features.\n\tDataset sequence features will not be visible.");
       }
       sq.setDatasetSequence(seqds);
@@ -244,7 +244,7 @@ public class SeqsetUtils
         {
           if (!quiet)
           {
-            System.err.println("Can't find '" + ((String) key)
+            jalview.bin.Console.errPrintln("Can't find '" + ((String) key)
                     + "' in uniquified alignment");
           }
         }
@@ -252,7 +252,7 @@ public class SeqsetUtils
     }
     if (unmatched.size() > 0 && !quiet)
     {
-      System.err.println("Did not find matches for :");
+      jalview.bin.Console.errPrintln("Did not find matches for :");
       for (Enumeration i = unmatched.elements(); i
               .hasMoreElements(); System.out
                       .println(((SequenceI) i.nextElement()).getName()))
index c04df6c..3f5099b 100644 (file)
@@ -148,7 +148,7 @@ public class StructureFrequency
           {
             if (sequences[j] == null)
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "WARNING: Consensus skipping null sequence - possible race condition.");
               continue;
             }
index daf7836..a7cbc25 100644 (file)
@@ -214,7 +214,7 @@ public abstract class TreeEngine
   {
     // if (_lycount<_lylimit)
     // {
-    // System.err.println("Warning: depth of _recount greater than number of
+    // jalview.bin.Console.errPrintln("Warning: depth of _recount greater than number of
     // nodes.");
     // }
     if (nd == null)
index 0e57a58..90fe089 100644 (file)
@@ -353,13 +353,13 @@ public class TreeModel
 
     if ((nd.left() == null) && (nd.right() == null))
     {
-      System.out.println("Leaf = " + ((SequenceI) nd.element()).getName());
-      System.out.println("Dist " + nd.dist);
-      System.out.println("Boot " + nd.getBootstrap());
+      jalview.bin.Console.outPrintln("Leaf = " + ((SequenceI) nd.element()).getName());
+      jalview.bin.Console.outPrintln("Dist " + nd.dist);
+      jalview.bin.Console.outPrintln("Boot " + nd.getBootstrap());
     }
     else
     {
-      System.out.println("Dist " + nd.dist);
+      jalview.bin.Console.outPrintln("Dist " + nd.dist);
       printNode((BinaryNode) nd.left());
       printNode((BinaryNode) nd.right());
     }
@@ -480,10 +480,10 @@ public class TreeModel
     }
     else
     {
-      System.out.println(" name = " + ((SequenceI) nd.element()).getName());
+      jalview.bin.Console.outPrintln(" name = " + ((SequenceI) nd.element()).getName());
     }
 
-    System.out.println(
+    jalview.bin.Console.outPrintln(
             " dist = " + nd.dist + " " + nd.count + " " + nd.height);
   }
 
@@ -513,7 +513,7 @@ public class TreeModel
   {
     // if (_lycount<_lylimit)
     // {
-    // System.err.println("Warning: depth of _recount greater than number of
+    // jalview.bin.Console.errPrintln("Warning: depth of _recount greater than number of
     // nodes.");
     // }
     if (nd == null)
index 9c2f6d1..bcc0855 100644 (file)
@@ -63,7 +63,7 @@ public class FeatureDistanceModel extends DistanceScoreModel
       return instance;
     } catch (InstantiationException | IllegalAccessException e)
     {
-      System.err.println("Error in " + getClass().getName()
+      jalview.bin.Console.errPrintln("Error in " + getClass().getName()
               + ".getInstance(): " + e.getMessage());
       return null;
     } catch (ReflectiveOperationException roe)
index b206339..aa841ac 100644 (file)
@@ -331,12 +331,12 @@ public class ScoreMatrix extends SimilarityScoreModel
   {
     if (c >= symbolIndex.length)
     {
-      System.err.println(String.format(BAD_ASCII_ERROR, c));
+      jalview.bin.Console.errPrintln(String.format(BAD_ASCII_ERROR, c));
       return 0;
     }
     if (d >= symbolIndex.length)
     {
-      System.err.println(String.format(BAD_ASCII_ERROR, d));
+      jalview.bin.Console.errPrintln(String.format(BAD_ASCII_ERROR, d));
       return 0;
     }
 
index ebc9a26..d0f21bd 100644 (file)
@@ -105,7 +105,7 @@ public class ScoreModels
       return sm;
     } catch (IOException e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Error reading " + resourcePath + ": " + e.getMessage());
     }
     return null;
@@ -143,7 +143,7 @@ public class ScoreModels
     ScoreModelI sm2 = models.get(sm.getName());
     if (sm2 != null)
     {
-      System.err.println("Warning: replacing score model " + sm2.getName());
+      jalview.bin.Console.errPrintln("Warning: replacing score model " + sm2.getName());
     }
     models.put(sm.getName(), sm);
   }
similarity index 55%
rename from src/jalview/analytics/GoogleAnalytics4.java
rename to src/jalview/analytics/Plausible.java
index ba8a920..ab2de77 100644 (file)
@@ -1,8 +1,31 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.analytics;
 
+import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
+import java.lang.invoke.MethodHandles;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -17,75 +40,94 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
-import java.util.UUID;
 
 import jalview.bin.Cache;
 import jalview.bin.Console;
 import jalview.util.ChannelProperties;
+import jalview.util.HttpUtils;
 
-public class GoogleAnalytics4
+public class Plausible
 {
+  private static final String USER_AGENT;
+
   private static final String JALVIEW_ID = "Jalview Desktop";
 
-  private static final String SESSION_ID = new Random().toString();
+  private static final String DOMAIN = "jalview.org";
 
-  private static final String MEASUREMENT_ID = "G-6TMPHMXEQ0";
+  private static final String CONFIG_API_BASE_URL = "https://www.jalview.org/services/config/analytics/url";
 
-  private static final String API_SECRET = "Qb9NSbqkRDqizG6j2BBJ2g";
+  private static final String DEFAULT_API_BASE_URL = "https://analytics.jalview.org/api/event";
 
-  // This will generate a different CLIENT_ID each time the application is
-  // launched. Do we want to store it in .jalview_properties?
-  private static final String CLIENT_ID = UUID.randomUUID().toString();
+  private static final String API_BASE_URL;
 
-  private static final String BASE_URL = "https://www.google-analytics.com/mp/collect";
+  private static final String clientId;
 
-  private static final String DESKTOP_EVENT = "desktop_event";
+  public static final String APPLICATION_BASE_URL = "desktop://localhost";
 
   private List<Map.Entry<String, String>> queryStringValues;
 
   private List<Map.Entry<String, Object>> jsonObject;
 
-  private List<Event> events;
-
   private List<Map.Entry<String, String>> cookieValues;
 
   private static boolean ENABLED = false;
 
-  private static GoogleAnalytics4 instance = null;
+  private static boolean DEBUG = true;
 
-  private static final Map<String, String> defaultParams;
+  private static Plausible instance = null;
+
+  private static final Map<String, String> defaultProps;
 
   static
   {
-    defaultParams = new HashMap<>();
-    defaultParams.put("app_name",
+    defaultProps = new HashMap<>();
+    defaultProps.put("app_name",
             ChannelProperties.getProperty("app_name") + " Desktop");
-    defaultParams.put("version", Cache.getProperty("VERSION"));
-    defaultParams.put("build_date",
+    defaultProps.put("version", Cache.getProperty("VERSION"));
+    defaultProps.put("build_date",
             Cache.getDefault("BUILD_DATE", "unknown"));
-    defaultParams.put("java_version", System.getProperty("java.version"));
+    defaultProps.put("java_version", System.getProperty("java.version"));
     String val = System.getProperty("sys.install4jVersion");
     if (val != null)
     {
-      defaultParams.put("install4j_version", val);
+      defaultProps.put("install4j_version", val);
     }
     val = System.getProperty("installer_template_version");
     if (val != null)
     {
-      defaultParams.put("install4j_template_version", val);
+      defaultProps.put("install4j_template_version", val);
     }
     val = System.getProperty("launcher_version");
     if (val != null)
     {
-      defaultParams.put("launcher_version", val);
+      defaultProps.put("launcher_version", val);
     }
-    defaultParams.put("java_arch",
+    defaultProps.put("java_arch",
             System.getProperty("os.arch") + " "
                     + System.getProperty("os.name") + " "
                     + System.getProperty("os.version"));
+    defaultProps.put("os", System.getProperty("os.name"));
+    defaultProps.put("os_version", System.getProperty("os.version"));
+    defaultProps.put("os_arch", System.getProperty("os.arch"));
+    String installation = Cache.applicationProperties
+            .getProperty("INSTALLATION");
+    if (installation != null)
+    {
+      defaultProps.put("installation", installation);
+    }
+
+    // ascertain the API_BASE_URL
+    API_BASE_URL = getAPIBaseURL();
+
+    // random clientId to make User-Agent unique (to register analytic)
+    clientId = String.format("%08x", new Random().nextInt());
+
+    USER_AGENT = HttpUtils.getUserAgent(
+            MethodHandles.lookup().lookupClass().getCanonicalName() + " "
+                    + clientId);
   }
 
-  private GoogleAnalytics4()
+  private Plausible()
   {
     this.resetLists();
   }
@@ -95,72 +137,79 @@ public class GoogleAnalytics4
     ENABLED = b;
   }
 
-  public void sendAnalytics(String eventName, String... paramsStrings)
+  public void sendEvent(String eventName, String urlString,
+          String... propsStrings)
   {
-    sendAnalytics(eventName, false, paramsStrings);
+    sendEvent(eventName, urlString, false, propsStrings);
   }
 
   /**
    * The simplest way to send an analytic event.
    * 
    * @param eventName
-   *          The event name. To emulate a webpage view use "page_view" and set
-   *          a "page_location" parameter. See
-   *          https://developers.google.com/analytics/devguides/collection/ga4/events?client_type=gtag
-   * @param sendDefaultParams
-   *          Flag whether to add the default params about the application.
-   * @param paramsStrings
+   *          The event name. To emulate a webpage view use "pageview" and set a
+   *          "url" key/value. See https://plausible.io/docs/events-api
+   * @param sendDefaultProps
+   *          Flag whether to add the default props about the application.
+   * @param propsStrings
    *          Optional multiple Strings in key, value pairs (there should be an
-   *          even number of paramsStrings) to be set as parameters of the
-   *          event. To emulate a webpage view use "page_location" as the URL in
-   *          a "page_view" event.
+   *          even number of propsStrings) to be set as property of the event.
+   *          To emulate a webpage view set "url" as the URL in a "pageview"
+   *          event.
    */
-  public void sendAnalytics(String eventName, boolean sendDefaultParams,
-          String... paramsStrings)
+  public void sendEvent(String eventName, String urlString,
+          boolean sendDefaultProps, String... propsStrings)
   {
     // clear out old lists
     this.resetLists();
 
     if (!ENABLED)
     {
-      Console.debug("GoogleAnalytics4 not enabled.");
+      Console.debug("Plausible not enabled.");
       return;
     }
-    Map<String, String> params = new HashMap<>();
-    params.put("event_category", DESKTOP_EVENT);
-    params.put("event_label", eventName);
+    Map<String, String> props = new HashMap<>();
 
     // add these to all events from this application instance
-    if (sendDefaultParams)
+    if (sendDefaultProps)
     {
-      params.putAll(defaultParams);
+      props.putAll(defaultProps);
     }
 
-    // add (and overwrite with) the passed in params
-    if (paramsStrings != null && paramsStrings.length > 0)
+    // add (and overwrite with) the passed in props
+    if (propsStrings != null && propsStrings.length > 0)
     {
-      if (paramsStrings.length % 2 != 0)
+      if (propsStrings.length % 2 != 0)
       {
         Console.warn(
-                "Cannot addEvent with odd number of paramsStrings.  Ignoring the last one.");
+                "Cannot addEvent with odd number of propsStrings.  Ignoring the last one.");
       }
-      for (int i = 0; i < paramsStrings.length - 1; i += 2)
+      for (int i = 0; i < propsStrings.length - 1; i += 2)
       {
-        String key = paramsStrings[i];
-        String value = paramsStrings[i + 1];
-        params.put(key, value);
+        String key = propsStrings[i];
+        String value = propsStrings[i + 1];
+        props.put(key, value);
       }
     }
 
-    addEvent(eventName, params);
-    addQueryStringValue("measurement_id", MEASUREMENT_ID);
-    addQueryStringValue("api_secret", API_SECRET);
-    addJsonValue("client_id", CLIENT_ID);
-    addJsonValues("events", Event.toObjectList(events));
+    addJsonValue("domain", DOMAIN);
+    addJsonValue("name", eventName);
+    StringBuilder eventUrlSb = new StringBuilder(APPLICATION_BASE_URL);
+    if (!APPLICATION_BASE_URL.endsWith("/") && !urlString.startsWith("/"))
+    {
+      eventUrlSb.append("/");
+    }
+    eventUrlSb.append(urlString);
+    addJsonValue("url", eventUrlSb.toString());
+    addJsonObject("props", props);
     StringBuilder urlSb = new StringBuilder();
-    urlSb.append(BASE_URL);
-    urlSb.append('?');
-    urlSb.append(buildQueryString());
+    urlSb.append(API_BASE_URL);
+    String qs = buildQueryString();
+    if (qs != null && qs.length() > 0)
+    {
+      urlSb.append('?');
+      urlSb.append(qs);
+    }
     try
     {
       URL url = new URL(urlSb.toString());
@@ -171,15 +220,21 @@ public class GoogleAnalytics4
 
       String jsonString = buildJson();
 
-      Console.debug("GA4: HTTP Request is: '" + urlSb.toString() + "'");
-      Console.debug("GA4: POSTed JSON is:\n" + jsonString);
+      Console.debug(
+              "Plausible: HTTP Request is: '" + urlSb.toString() + "'");
+      if (DEBUG)
+      {
+        Console.debug("Plausible: User-Agent is: '" + USER_AGENT + "'");
+      }
+      Console.debug("Plausible: POSTed JSON is:\n" + jsonString);
 
       byte[] jsonBytes = jsonString.getBytes(StandardCharsets.UTF_8);
       int jsonLength = jsonBytes.length;
 
       httpURLConnection.setFixedLengthStreamingMode(jsonLength);
       httpURLConnection.setRequestProperty("Content-Type",
-              "application/json; charset=UTF-8");
+              "application/json");
+      httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
       httpURLConnection.connect();
       try (OutputStream os = httpURLConnection.getOutputStream())
       {
@@ -187,50 +242,63 @@ public class GoogleAnalytics4
       }
       int responseCode = httpURLConnection.getResponseCode();
       String responseMessage = httpURLConnection.getResponseMessage();
+
       if (responseCode < 200 || responseCode > 299)
       {
-        Console.warn("GoogleAnalytics4 connection failed: '" + responseCode
-                + " " + responseMessage + "'");
+        Console.warn("Plausible connection failed: '" + responseCode + " "
+                + responseMessage + "'");
       }
       else
       {
-        Console.debug("GoogleAnalytics4 connection succeeded: '"
-                + responseCode + " " + responseMessage + "'");
+        Console.debug("Plausible connection succeeded: '" + responseCode
+                + " " + responseMessage + "'");
+      }
+
+      if (DEBUG)
+      {
+        BufferedReader br = new BufferedReader(new InputStreamReader(
+                (httpURLConnection.getInputStream())));
+        StringBuilder sb = new StringBuilder();
+        String response;
+        while ((response = br.readLine()) != null)
+        {
+          sb.append(response);
+        }
+        String body = sb.toString();
+        Console.debug("Plausible response content:\n" + body);
       }
     } catch (MalformedURLException e)
     {
       Console.debug(
-              "Somehow the GoogleAnalytics4 BASE_URL and queryString is malformed.",
+              "Somehow the Plausible BASE_URL and queryString is malformed: '"
+                      + urlSb.toString() + "'",
               e);
       return;
     } catch (IOException e)
     {
-      Console.debug("Connection to GoogleAnalytics4 BASE_URL '" + BASE_URL
+      Console.debug("Connection to Plausible BASE_URL '" + API_BASE_URL
               + "' failed.", e);
     } catch (ClassCastException e)
     {
       Console.debug(
-              "Couldn't cast URLConnection to HttpURLConnection in GoogleAnalytics4.",
+              "Couldn't cast URLConnection to HttpURLConnection in Plausible.",
               e);
     }
   }
 
-  public void addEvent(String name, Map<String, String> params)
+  private void addJsonObject(String key, Map<String, String> map)
   {
-    Event event = new Event(name);
-    if (params != null && params.size() > 0)
+    List<Map.Entry<String, ? extends Object>> list = new ArrayList<>();
+    for (String k : map.keySet())
     {
-      for (String key : params.keySet())
-      {
-        String value = params.get(key);
-        event.addParam(key, value);
-      }
+      list.add(stringEntry(k, map.get(k)));
     }
-    events.add(event);
+    addJsonObject(key, list);
+
   }
 
   private void addJsonObject(String key,
-          List<Map.Entry<String, Object>> object)
+          List<Map.Entry<String, ? extends Object>> object)
   {
     jsonObject.add(objectEntry(key, object));
   }
@@ -268,16 +336,15 @@ public class GoogleAnalytics4
   private void resetLists()
   {
     jsonObject = new ArrayList<>();
-    events = new ArrayList<Event>();
     queryStringValues = new ArrayList<>();
     cookieValues = new ArrayList<>();
   }
 
-  public static GoogleAnalytics4 getInstance()
+  public static Plausible getInstance()
   {
     if (instance == null)
     {
-      instance = new GoogleAnalytics4();
+      instance = new Plausible();
     }
     return instance;
   }
@@ -480,52 +547,56 @@ public class GoogleAnalytics4
   {
     return new AbstractMap.SimpleEntry<String, String>(s, v);
   }
-}
-
-class Event
-{
-  private String name;
 
-  private List<Map.Entry<String, String>> params;
-
-  @SafeVarargs
-  public Event(String name, Map.Entry<String, String>... paramEntries)
+  private static String getAPIBaseURL()
   {
-    this.name = name;
-    this.params = new ArrayList<Map.Entry<String, String>>();
-    for (Map.Entry<String, String> paramEntry : paramEntries)
+    try
     {
-      if (paramEntry == null)
+      URL url = new URL(CONFIG_API_BASE_URL);
+      URLConnection urlConnection = url.openConnection();
+      HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
+      httpURLConnection.setRequestMethod("GET");
+      httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
+      httpURLConnection.setConnectTimeout(5000);
+      httpURLConnection.setReadTimeout(3000);
+      httpURLConnection.connect();
+      int responseCode = httpURLConnection.getResponseCode();
+      String responseMessage = httpURLConnection.getResponseMessage();
+
+      if (responseCode < 200 || responseCode > 299)
       {
-        continue;
+        Console.warn("Config URL connection to '" + CONFIG_API_BASE_URL
+                + "' failed: '" + responseCode + " " + responseMessage
+                + "'");
       }
-      params.add(paramEntry);
-    }
-  }
 
-  public void addParam(String param, String value)
-  {
-    params.add(GoogleAnalytics4.stringEntry(param, value));
-  }
+      BufferedReader br = new BufferedReader(
+              new InputStreamReader((httpURLConnection.getInputStream())));
+      StringBuilder sb = new StringBuilder();
+      String response;
+      while ((response = br.readLine()) != null)
+      {
+        sb.append(response);
+      }
+      if (sb.length() > 7 && sb.substring(0, 5).equals("https"))
+      {
+        return sb.toString();
+      }
 
-  protected List<Map.Entry<String, Object>> toObject()
-  {
-    List<Map.Entry<String, Object>> object = new ArrayList<>();
-    object.add(GoogleAnalytics4.objectEntry("name", (Object) name));
-    if (params.size() > 0)
+    } catch (MalformedURLException e)
     {
-      object.add(GoogleAnalytics4.objectEntry("params", (Object) params));
-    }
-    return object;
-  }
-
-  protected static List<Object> toObjectList(List<Event> events)
-  {
-    List<Object> eventObjectList = new ArrayList<>();
-    for (Event event : events)
+      Console.debug("Somehow the config URL is malformed: '"
+              + CONFIG_API_BASE_URL + "'", e);
+    } catch (IOException e)
     {
-      eventObjectList.add((Object) event.toObject());
+      Console.debug("Connection to Plausible BASE_URL '" + API_BASE_URL
+              + "' failed.", e);
+    } catch (ClassCastException e)
+    {
+      Console.debug(
+              "Couldn't cast URLConnection to HttpURLConnection in Plausible.",
+              e);
     }
-    return eventObjectList;
+    return DEFAULT_API_BASE_URL;
   }
 }
index c6eb6de..1646d89 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
index b860a36..413b0d4 100644 (file)
@@ -393,14 +393,14 @@ public class APopupMenu extends java.awt.PopupMenu
         urlLink = new UrlLink(link);
       } catch (Exception foo)
       {
-        System.err.println("Exception for URLLink '" + link + "': "
+        jalview.bin.Console.errPrintln("Exception for URLLink '" + link + "': "
                 + foo.getMessage());
         continue;
       }
 
       if (!urlLink.isValid())
       {
-        System.err.println(urlLink.getInvalidMessage());
+        jalview.bin.Console.errPrintln(urlLink.getInvalidMessage());
         continue;
       }
 
index 0159bc7..4b858e1 100644 (file)
@@ -1577,7 +1577,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     /*
      * When we finally deprecate 1.1 compatibility, we can start to use
      * URLEncoder.encode(url,"UTF-8") and then we'll need this catch: catch
-     * (UnsupportedEncodingException ex) { System.err.println("WARNING -
+     * (UnsupportedEncodingException ex) { jalview.bin.Console.errPrintln("WARNING -
      * IMPLEMENTATION ERROR - UNSUPPORTED ENCODING EXCEPTION FOR "+url);
      * ex.printStackTrace(); }
      */
@@ -1586,7 +1586,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       url = viewport.applet.getCodeBase() + url;
     } catch (UnsupportedEncodingException ex)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "WARNING = IMPLEMENTATION ERROR - UNSUPPORTED ENCODING EXCEPTION FOR "
                       + url);
       ex.printStackTrace();
@@ -2975,7 +2975,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
     if (viewport.applet.debug)
     {
-      System.err.println("Sorting " + alorder.getOrder().size()
+      jalview.bin.Console.errPrintln("Sorting " + alorder.getOrder().size()
               + " in alignment '" + getTitle() + "'");
     }
     AlignmentSorter.sortBy(viewport.getAlignment(), alorder);
@@ -3061,7 +3061,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   {
     if (viewport.applet == null)
     {
-      System.out.println("Not running as applet - no browser available.");
+      jalview.bin.Console.outPrintln("Not running as applet - no browser available.");
     }
     else
     {
@@ -3977,12 +3977,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       viewer = (Viewer) jmolviewer;
     } catch (ClassCastException ex)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Unsupported viewer object :" + jmolviewer.getClass());
     }
     if (viewer == null)
     {
-      System.err.println("Can't use this object as a structure viewer:"
+      jalview.bin.Console.errPrintln("Can't use this object as a structure viewer:"
               + jmolviewer.getClass());
       return null;
     }
@@ -4127,7 +4127,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     chains = (String[]) sqch[1];
     if (seqs == null || seqs.length == 0)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to.");
     }
     if (protocol == null)
@@ -4142,7 +4142,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       }
       if (protocol == null)
       {
-        System.err.println("Couldn't work out protocol to open structure: "
+        jalview.bin.Console.errPrintln("Couldn't work out protocol to open structure: "
                 + pdb.getId());
         return;
       }
@@ -4154,7 +4154,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
               .setMapping(seqs, chains, pdb.getFile(), protocol,
                       null) == null)
       {
-        System.err.println("Failed to map " + pdb.getFile() + " ("
+        jalview.bin.Console.errPrintln("Failed to map " + pdb.getFile() + " ("
                 + protocol + ") to any sequences");
       }
       return;
@@ -4176,7 +4176,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       }
       if (ajm != null)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Incremental adding and aligning structure to existing Jmol view not yet implemented.");
         // try and add the pdb structure
         // ajm.addS
@@ -4201,7 +4201,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
           SequenceI[][] seqs, String[][] chains, String[] protocols)
   {
     // TODO Auto-generated method stub
-    System.err.println("Aligned Structure View: Not yet implemented.");
+    jalview.bin.Console.errPrintln("Aligned Structure View: Not yet implemented.");
   }
 
   /**
@@ -4258,9 +4258,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     if (!file.isValid())
     {
       // TODO: raise dialog for gui
-      System.err.println("Problems parsing T-Coffee scores: "
+      jalview.bin.Console.errPrintln("Problems parsing T-Coffee scores: "
               + file.getWarningMessage());
-      System.err.println("Origin was:\n" + source);
+      jalview.bin.Console.errPrintln("Origin was:\n" + source);
       return false;
     }
 
@@ -4273,7 +4273,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
                     || aln.getWidth() != file.getWidth()))
     {
       // TODO: raise a dialog box here rather than bomb out.
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "The scores matrix does not match the alignment dimensions");
 
     }
@@ -4289,10 +4289,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     }
     else
     {
-      System.err.println("Problems resolving T-Coffee scores:");
+      jalview.bin.Console.errPrintln("Problems resolving T-Coffee scores:");
       if (file.getWarningMessage() != null)
       {
-        System.err.println(file.getWarningMessage());
+        jalview.bin.Console.errPrintln(file.getWarningMessage());
       }
     }
     return false;
index d64cd75..c1de259 100644 (file)
@@ -77,14 +77,14 @@ public class AlignViewport extends AlignmentViewport
         }
         if (widthScale <= 1.0)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Invalid alignment character width scaling factor ("
                           + widthScale + "). Ignoring.");
           widthScale = 1;
         }
         if (JalviewLite.debug)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Alignment character width scaling factor is now "
                           + widthScale);
         }
@@ -100,14 +100,14 @@ public class AlignViewport extends AlignmentViewport
         }
         if (heightScale <= 1.0)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Invalid alignment character height scaling factor ("
                           + heightScale + "). Ignoring.");
           heightScale = 1;
         }
         if (JalviewLite.debug)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Alignment character height scaling factor is now "
                           + heightScale);
         }
index fd75296..71ddcef 100644 (file)
@@ -363,7 +363,7 @@ public class AlignmentPanel extends Panel
       {
         if (JalviewLite.debug)
         {// DEBUG
-          System.out.println(
+          jalview.bin.Console.outPrintln(
                   "DEBUG: scroll didn't happen - results not within alignment : "
                           + seq.getStart() + "," + seq.getEnd());
         }
@@ -373,7 +373,7 @@ public class AlignmentPanel extends Panel
       {
         // DEBUG
         /*
-         * System.out.println("DEBUG: scroll: start=" + r[0] +
+         * jalview.bin.Console.outPrintln("DEBUG: scroll: start=" + r[0] +
          * " av.getStartRes()=" + av.getStartRes() + " end=" + r[1] +
          * " seq.end=" + seq.getEnd() + " av.getEndRes()=" + av.getEndRes() +
          * " hextent=" + hextent);
@@ -555,7 +555,7 @@ public class AlignmentPanel extends Panel
     // this is called after loading new annotation onto alignment
     if (alignFrame.getSize().height == 0)
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "adjustAnnotationHeight frame size zero NEEDS FIXING");
     }
     fontChanged();
@@ -693,7 +693,7 @@ public class AlignmentPanel extends Panel
 
       if ((hextent + x) > width)
       {
-        System.err.println("hextent was " + hextent + " and x was " + x);
+        jalview.bin.Console.errPrintln("hextent was " + hextent + " and x was " + x);
 
         x = width - hextent;
       }
@@ -710,7 +710,7 @@ public class AlignmentPanel extends Panel
 
       if (x < 0)
       {
-        System.err.println("x was " + x);
+        jalview.bin.Console.errPrintln("x was " + x);
         x = 0;
       }
 
@@ -1111,7 +1111,7 @@ public class AlignmentPanel extends Panel
   public void raiseOOMWarning(String string, OutOfMemoryError error)
   {
     // TODO: JAL-960
-    System.err.println("Out of memory whilst '" + string + "'");
+    jalview.bin.Console.errPrintln("Out of memory whilst '" + string + "'");
     error.printStackTrace();
   }
 
index b0722c0..cca9aff 100644 (file)
@@ -275,7 +275,7 @@ public class AppletJmol extends EmbmenuFrame implements
               "-applet", scriptWindow, null);
     } catch (Exception e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Couldn't create a jmol viewer. Args to allocate viewer were:\nDocumentBase="
                       + ap.av.applet.getDocumentBase() + "\nCodebase="
                       + ap.av.applet.getCodeBase());
@@ -320,7 +320,7 @@ public class AppletJmol extends EmbmenuFrame implements
           {
             if (jalview.bin.JalviewLite.debug)
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "AppletJmol:Trying to reuse existing PDBfile IO parser.");
             }
             // re-use the one we opened earlier
@@ -330,7 +330,7 @@ public class AppletJmol extends EmbmenuFrame implements
           {
             if (jalview.bin.JalviewLite.debug)
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "AppletJmol:Creating new PDBfile IO parser.");
             }
             FileParse fp = new FileParse(pdbentry.getFile(), protocol);
@@ -355,7 +355,7 @@ public class AppletJmol extends EmbmenuFrame implements
         } catch (Exception e)
         {
           // give up!
-          System.err.println("Couldn't access pdbentry id="
+          jalview.bin.Console.errPrintln("Couldn't access pdbentry id="
                   + pdbentry.getId() + " and file=" + pdbentry.getFile()
                   + " using protocol=" + protocol);
           e.printStackTrace();
@@ -433,7 +433,7 @@ public class AppletJmol extends EmbmenuFrame implements
       } catch (OutOfMemoryError ex)
       {
         frame.dispose();
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Out of memory when trying to create dialog box with sequence-structure mapping.");
         return;
       }
index 47f9df0..e2b8f23 100644 (file)
@@ -154,7 +154,7 @@ public class ExtJmol extends JalviewJmolBinding
   {
     // This never gets called because we haven't overriden the associated Jmol's
     // console
-    System.err.println(
+    jalview.bin.Console.errPrintln(
             "WARNING: unexpected call to ExtJmol's showConsole method. (showConsole="
                     + show);
   }
index 7c0dfa9..7730210 100644 (file)
@@ -145,7 +145,7 @@ public class PCAPanel extends EmbmenuFrame
       top = pcaModel.getTop();
     } catch (OutOfMemoryError x)
     {
-      System.err.println("Out of memory when calculating PCA.");
+      jalview.bin.Console.errPrintln("Out of memory when calculating PCA.");
       return;
     }
     calcSettings.setEnabled(true);
index bc775c6..566aad9 100644 (file)
@@ -102,7 +102,7 @@ public class PairwiseAlignPanel extends Panel implements ActionListener
 
     if (count > 2)
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "Pairwise alignment scaled similarity score matrix\n");
 
       for (int i = 0; i < count; i++)
@@ -111,7 +111,7 @@ public class PairwiseAlignPanel extends Panel implements ActionListener
                 ("" + i) + " " + seqs[i].getName());
       }
 
-      System.out.println("\n");
+      jalview.bin.Console.outPrintln("\n");
 
       for (int i = 0; i < count; i++)
       {
@@ -122,7 +122,7 @@ public class PairwiseAlignPanel extends Panel implements ActionListener
         }
       }
 
-      System.out.println("\n");
+      jalview.bin.Console.outPrintln("\n");
     }
   }
 
index bd36b0d..a5b652f 100644 (file)
@@ -148,7 +148,7 @@ public class RedundancyPanel extends SliderPanel
 
     validate();
     sliderValueChanged();
-    // System.out.println("blob done "+ (System.currentTimeMillis()-start));
+    // jalview.bin.Console.outPrintln("blob done "+ (System.currentTimeMillis()-start));
   }
 
   void sliderValueChanged()
index a870ca4..87266b4 100755 (executable)
@@ -145,7 +145,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
 
     scale = findScale();
 
-    // System.out.println("Scale factor = " + scale);
+    // jalview.bin.Console.outPrintln("Scale factor = " + scale);
 
     addMouseListener(this);
     addKeyListener(this);
@@ -301,7 +301,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
 
         scale = findScale();
 
-        // System.out.println("New scale = " + scale);
+        // jalview.bin.Console.outPrintln("New scale = " + scale);
         img = createImage(getSize().width, getSize().height);
         ig = img.getGraphics();
 
@@ -427,7 +427,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
     }
     else if (evt.getKeyChar() == 's')
     {
-      System.err.println("DEBUG: Rectangle selection"); // log.debug
+      jalview.bin.Console.errPrintln("DEBUG: Rectangle selection"); // log.debug
       if (rectx2 != -1 && recty2 != -1)
       {
         rectSelect(rectx1, recty1, rectx2, recty2);
index 70366e4..c573612 100644 (file)
@@ -772,7 +772,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
   @Override
   public void updateColours(SequenceI seq, int index)
   {
-    System.out.println("update the seqPanel colours");
+    jalview.bin.Console.outPrintln("update the seqPanel colours");
     // repaint();
   }
 
@@ -1817,7 +1817,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       {
         if (av.getAlignment() == null)
         {
-          System.out.println("Selection message: alignviewport av SeqSetId="
+          jalview.bin.Console.outPrintln("Selection message: alignviewport av SeqSetId="
                   + av.getSequenceSetId() + " ViewId=" + av.getViewId()
                   + " 's alignment is NULL! returning immediatly.");
           return;
@@ -1869,7 +1869,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     if (copycolsel && av.hasHiddenColumns()
             && (av.getColumnSelection() == null))
     {
-      System.err.println("Bad things");
+      jalview.bin.Console.errPrintln("Bad things");
     }
     if (repaint)
     {
index 671fee1..0316e0b 100644 (file)
@@ -166,7 +166,7 @@ public class TreePanel extends EmbmenuFrame
     }
     else
     {
-      System.out.println("Original Tree Data not available");
+      jalview.bin.Console.outPrintln("Original Tree Data not available");
     }
   }
 
index fc9ddda..3750d9d 100755 (executable)
@@ -43,6 +43,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
@@ -52,7 +53,7 @@ import java.util.TreeSet;
 import javax.swing.LookAndFeel;
 import javax.swing.UIManager;
 
-import jalview.analytics.GoogleAnalytics4;
+import jalview.analytics.Plausible;
 import jalview.datamodel.PDBEntry;
 import jalview.gui.Preferences;
 import jalview.gui.UserDefinedColours;
@@ -128,7 +129,7 @@ import jalview.ws.sifts.SiftsSettings;
  * service</li>
  * <li>QUESTIONNAIRE last questionnaire:responder id string from questionnaire
  * service</li>
- * <li>USAGESTATS (false - user prompted) Enable google analytics tracker for
+ * <li>USAGESTATS (false - user prompted) Enable analytics tracker for
  * collecting usage statistics</li>
  * <li>SHOW_OVERVIEW boolean for overview window display</li>
  * <li>ANTI_ALIAS boolean for smooth fonts</li>
@@ -406,9 +407,9 @@ public class Cache
           fis = new URL(propertiesFile).openStream();
           if (!Jalview.quiet())
           {
-            System.out.println(
+            jalview.bin.Console.outPrintln(
                     "Loading jalview properties from : " + propertiesFile);
-            System.out.println(
+            jalview.bin.Console.outPrintln(
                     "Disabling Jalview writing to user's local properties file.");
           }
           propsAreReadOnly = true;
@@ -439,7 +440,8 @@ public class Cache
       } catch (Exception ex)
       {
         if (!Jalview.quiet())
-          System.out.println("Error reading properties file: " + ex);
+          jalview.bin.Console
+                  .outPrintln("Error reading properties file: " + ex);
       }
     }
 
@@ -496,7 +498,8 @@ public class Cache
     } catch (Exception ex)
     {
       if (!Jalview.quiet())
-        System.out.println("Error reading author details: " + ex);
+        jalview.bin.Console
+                .outPrintln("Error reading author details: " + ex);
       authorDetails = null;
     }
     if (authorDetails == null)
@@ -582,10 +585,10 @@ public class Cache
             {
               if (!Jalview.quiet())
               {
-                System.out.println(
+                jalview.bin.Console.outPrintln(
                         "Non-fatal exception when checking version at "
                                 + remoteBuildPropertiesUrl + ":");
-                System.out.println(ex);
+                jalview.bin.Console.printStackTrace(ex);
               }
               remoteVersion = getProperty("VERSION");
             }
@@ -635,7 +638,7 @@ public class Cache
         url = Cache.class.getResource(resourcePath).toString();
       } catch (Exception ex)
       {
-        System.err.println("Failed to resolve resource " + resourcePath
+        jalview.bin.Console.errPrintln("Failed to resolve resource " + resourcePath
                 + ": " + ex.getMessage());
       }
     }
@@ -686,7 +689,8 @@ public class Cache
     } catch (Exception ex)
     {
       if (!Jalview.quiet())
-        System.out.println("Error reading build details: " + ex);
+        jalview.bin.Console
+                .outPrintln("Error reading build details: " + ex);
       applicationProperties.remove("VERSION");
     }
     String codeVersion = getProperty("VERSION");
@@ -706,8 +710,9 @@ public class Cache
     new BuildDetails(codeVersion, null, codeInstallation);
     if (printVersion && reportVersion)
     {
-      System.out.println(ChannelProperties.getProperty("app_name")
-              + " version: " + codeVersion + codeInstallation);
+      jalview.bin.Console
+              .outPrintln(ChannelProperties.getProperty("app_name")
+                      + " version: " + codeVersion + codeInstallation);
     }
   }
 
@@ -783,8 +788,8 @@ public class Cache
       } catch (NumberFormatException e)
       {
         if (!Jalview.quiet())
-          System.out.println("Error parsing int property '" + property
-                  + "' with value '" + string + "'");
+          jalview.bin.Console.outPrintln("Error parsing int property '"
+                  + property + "' with value '" + string + "'");
       }
     }
 
@@ -834,7 +839,7 @@ public class Cache
     } catch (Exception ex)
     {
       if (!Jalview.quiet())
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "Error setting property: " + key + " " + obj + "\n" + ex);
     }
     return oldValue;
@@ -866,7 +871,7 @@ public class Cache
       } catch (Exception ex)
       {
         if (!Jalview.quiet())
-          System.out.println("Error saving properties: " + ex);
+          jalview.bin.Console.outPrintln("Error saving properties: " + ex);
       }
     }
   }
@@ -954,146 +959,41 @@ public class Cache
   }
 
   /**
-   * GA tracker object - actually JGoogleAnalyticsTracker null if tracking not
-   * enabled.
+   * Initialise the tracker if it is not done already.
    */
-  protected static Object tracker = null;
-
-  protected static Class trackerfocus = null;
-
-  protected static Class jgoogleanalyticstracker = null;
-
-  private static boolean useGA4 = true;
-
-  /**
-   * Initialise the google tracker if it is not done already.
-   */
-  public static void initGoogleTracker()
+  public static void initAnalytics()
   {
-    if (useGA4)
-    {
-      GoogleAnalytics4.setEnabled(true);
+    Plausible.setEnabled(true);
 
-      String appName = ChannelProperties.getProperty("app_name")
-              + " Desktop";
-      String version = Cache.getProperty("VERSION") + "_"
-              + Cache.getDefault("BUILD_DATE", "unknown");
-      String path;
-      /* we don't want to encode ':' as "%3A" for backward compatibility with the UA setup
-      try
-      {
-        path = "/" + String.join("/", URLEncoder.encode(appName, "UTF-8"),
-                URLEncoder.encode(version, "UTF-8"),
-                URLEncoder.encode(APPLICATION_STARTED, "UTF-8"));
-      } catch (UnsupportedEncodingException e)
-      {
-      */
-      path = ("/" + String.join("/", appName, version, APPLICATION_STARTED))
-              .replace(' ', '+');
-      /*
-      }
-      */
-      GoogleAnalytics4 ga4 = GoogleAnalytics4.getInstance();
-
-      // This will add a page_view similar to the old UA analytics.
-      // We probably want to get rid of this once the application_launch event
-      // is being processed properly.
-      ga4.sendAnalytics("page_view", "page_location", path, "page_title",
-              APPLICATION_STARTED);
-
-      // This will send a new "application_launch" event with parameters
-      // including the old-style "path", the channel name and version
-      ga4.sendAnalytics("application_launch", true, "page_location", path);
-    }
-    else
+    String appName = ChannelProperties.getProperty("app_name") + " Desktop";
+    String version = Cache.getProperty("VERSION") + "_"
+            + Cache.getDefault("BUILD_DATE", "unknown");
+    String path;
+    /* we don't want to encode ':' as "%3A" for backward compatibility with the UA setup
+    try
     {
-      if (tracker == null)
-      {
-        if (jgoogleanalyticstracker == null)
-        {
-          // try to get the tracker class
-          try
-          {
-            jgoogleanalyticstracker = Cache.class.getClassLoader()
-                    .loadClass(
-                            "com.boxysystems.jgoogleanalytics.JGoogleAnalyticsTracker");
-            trackerfocus = Cache.class.getClassLoader().loadClass(
-                    "com.boxysystems.jgoogleanalytics.FocusPoint");
-          } catch (Exception e)
-          {
-            Console.debug(
-                    "com.boxysystems.jgoogleanalytics package is not present - tracking not enabled.");
-            tracker = null;
-            jgoogleanalyticstracker = null;
-            trackerfocus = null;
-            return;
-          }
-        }
-        // now initialise tracker
-        Exception re = null, ex = null;
-        Error err = null;
-        String vrs = "No Version Accessible";
-        try
-        {
-          // Google analytics tracking code for Library Finder
-          tracker = jgoogleanalyticstracker
-                  .getConstructor(new Class[]
-                  { String.class, String.class, String.class })
-                  .newInstance(new Object[]
-                  { ChannelProperties.getProperty("app_name") + " Desktop",
-                      (vrs = Cache.getProperty("VERSION") + "_"
-                              + Cache.getDefault("BUILD_DATE", "unknown")),
-                      "UA-9060947-1" });
-          jgoogleanalyticstracker
-                  .getMethod("trackAsynchronously", new Class[]
-                  { trackerfocus })
-                  .invoke(tracker, new Object[]
-                  { trackerfocus
-                          .getConstructor(new Class[]
-                          { String.class })
-                          .newInstance(new Object[]
-                          { APPLICATION_STARTED }) });
-        } catch (RuntimeException e)
-        {
-          re = e;
-        } catch (Exception e)
-        {
-          ex = e;
-        } catch (Error e)
-        {
-          err = e;
-        }
-        if (re != null || ex != null || err != null)
-        {
-          if (re != null)
-          {
-            Console.debug("Caught runtime exception in googletracker init:",
-                    re);
-          }
-          if (ex != null)
-          {
-            Console.warn(
-                    "Failed to initialise GoogleTracker for Jalview Desktop with version "
-                            + vrs,
-                    ex);
-          }
-          if (err != null)
-          {
-            Console.error(
-                    "Whilst initing GoogleTracker for Jalview Desktop version "
-                            + vrs,
-                    err);
-          }
-        }
-        else
-        {
-          Console.debug("Successfully initialised tracker.");
-        }
-      }
+      path = "/" + String.join("/", URLEncoder.encode(appName, "UTF-8"),
+              URLEncoder.encode(version, "UTF-8"),
+              URLEncoder.encode(APPLICATION_STARTED, "UTF-8"));
+    } catch (UnsupportedEncodingException e)
+    {
+    */
+    List<String> pathParts = new ArrayList<>();
+    pathParts.add(appName);
+    pathParts.add(version);
+    pathParts.add(APPLICATION_STARTED);
+    path = ("/" + String.join("/", pathParts)).replace(' ', '+');
+    /*
     }
+    */
+    Plausible plausible = Plausible.getInstance();
+
+    // This will send a new "application_launch" event with parameters
+    // including the old-style "path", the channel name and version
+    plausible.sendEvent("application_launch", path, true);
   }
 
-  private static final String APPLICATION_STARTED = "Application Started.";
+  private static final String APPLICATION_STARTED = "Application Started";
 
   /**
    * get the user's default colour if available
@@ -1161,7 +1061,7 @@ public class Cache
         return date_format.parse(val);
       } catch (Exception ex)
       {
-        System.err.println("Invalid or corrupt date in property '"
+        jalview.bin.Console.errPrintln("Invalid or corrupt date in property '"
                 + propertyName + "' : value was '" + val + "'");
       }
     }
@@ -1185,7 +1085,7 @@ public class Cache
         return Integer.valueOf(val);
       } catch (NumberFormatException x)
       {
-        System.err.println("Invalid integer in property '" + property
+        jalview.bin.Console.errPrintln("Invalid integer in property '" + property
                 + "' (value was '" + val + "')");
       }
     }
@@ -1250,7 +1150,8 @@ public class Cache
       } catch (Exception ex)
       {
         if (!Jalview.quiet())
-          System.out.println("Error loading User ColourFile\n" + ex);
+          jalview.bin.Console
+                  .outPrintln("Error loading User ColourFile\n" + ex);
       }
     }
     if (!files.equals(coloursFound.toString()))
@@ -1756,7 +1657,7 @@ public class Cache
       return null;
     if (!file.exists())
     {
-      System.err.println("Could not load bootstrap preferences file '"
+      jalview.bin.Console.errPrintln("Could not load bootstrap preferences file '"
               + filename + "'");
       return null;
     }
@@ -1773,11 +1674,11 @@ public class Cache
       }
     } catch (FileNotFoundException e)
     {
-      System.err.println("Could not find bootstrap preferences file '"
+      jalview.bin.Console.errPrintln("Could not find bootstrap preferences file '"
               + file.getAbsolutePath() + "'");
     } catch (IOException e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "IOException when loading bootstrap preferences file '"
                       + file.getAbsolutePath() + "'");
     }
index 7f493e0..63247a7 100644 (file)
@@ -6,7 +6,6 @@ import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -103,16 +102,20 @@ public class Commands
         theseArgsWereParsed &= processLinked(id);
         processGroovyScript(id);
         boolean processLinkedOkay = theseArgsWereParsed;
-        
+
         // wait around until alignFrame isn't busy
-        AlignFrame af=afMap.get(id);
-        while (af!=null && af.getViewport().isCalcInProgress())
+        AlignFrame af = afMap.get(id);
+        while (af != null && af.getViewport().isCalcInProgress())
         {
-          try {
+          try
+          {
             Thread.sleep(25);
-          } catch (Exception q) {};
+          } catch (Exception q)
+          {
+          }
+          ;
         }
-        
+
         theseArgsWereParsed &= processImages(id);
         if (processLinkedOkay)
           theseArgsWereParsed &= processOutput(id);
@@ -162,13 +165,9 @@ public class Commands
     if (avm == null)
       return true;
 
-    /*
-     * // script to execute after all loading is completed one way or another String
-     * groovyscript = m.get(Arg.GROOVY) == null ? null :
-     * m.get(Arg.GROOVY).getValue(); String file = m.get(Arg.OPEN) == null ? null :
-     * m.get(Arg.OPEN).getValue(); String data = null; FileFormatI format = null;
-     * DataSourceType protocol = null;
-     */
+    // set wrap scope here so it can be applied after structures are opened
+    boolean wrap = false;
+
     if (avm.containsArg(Arg.APPEND) || avm.containsArg(Arg.OPEN))
     {
       commandArgsProvided = true;
@@ -252,23 +251,22 @@ public class Commands
           af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol,
                   format);
 
-          // wrap alignment?
-          boolean wrap = ArgParser.getFromSubValArgOrPref(avm, Arg.WRAP, sv,
-                  null, "WRAP_ALIGNMENT", false);
-          af.getCurrentView().setWrapAlignment(wrap);
-
           // colour alignment?
           String colour = ArgParser.getFromSubValArgOrPref(avm, av,
                   Arg.COLOUR, sv, null, "DEFAULT_COLOUR_PROT", "");
           if ("" != colour)
           {
             ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
-                    af.getViewport(), af.getViewport().getAlignment(), colour);
-            
-            if (cs==null && !"None".equals(colour))
+                    af.getViewport(), af.getViewport().getAlignment(),
+                    colour);
+
+            if (cs == null && !"None".equals(colour))
+            {
+              Console.warn(
+                      "Couldn't parse '" + colour + "' as a colourscheme.");
+            }
+            else
             {
-              Console.warn("Couldn't parse '"+colour+"' as a colourscheme.");
-            } else {
               af.changeColour(cs);
             }
             Jalview.testoutput(argParser, Arg.COLOUR, "zappo", colour);
@@ -357,6 +355,12 @@ public class Commands
                     false, false);
           }
 
+          // wrap alignment? do this last for formatting reasons
+          wrap = ArgParser.getFromSubValArgOrPref(avm, Arg.WRAP, sv, null,
+                  "WRAP_ALIGNMENT", false);
+          // af.setWrapFormat(wrap) is applied after structures are opened for
+          // annotation reasons
+
           // store the AlignFrame for this id
           afMap.put(id, af);
 
@@ -548,20 +552,7 @@ public class Commands
           String sViewer = ArgParser.getFromSubValArgOrPref(avm,
                   Arg.STRUCTUREVIEWER, Position.AFTER, av, subVals, null,
                   null, "jmol");
-          ViewerType viewerType = null;
-          if (!"none".equals(sViewer))
-          {
-            for (ViewerType v : EnumSet.allOf(ViewerType.class))
-            {
-              String name = v.name().toLowerCase(Locale.ROOT)
-                      .replaceAll(" ", "");
-              if (sViewer.equals(name))
-              {
-                viewerType = v;
-                break;
-              }
-            }
-          }
+          ViewerType viewerType = ViewerType.getFromString(sViewer);
 
           // TODO use ssFromStructure
           StructureViewer sv = StructureChooser
@@ -569,22 +560,36 @@ public class Commands
                           structureFilepath, tft, paeFilepath, false,
                           ssFromStructure, false, viewerType);
 
-          if (sv==null)
+          if (sv == null)
           {
             Console.error("Failed to import and open structure view.");
             continue;
           }
-          while (sv.isBusy())
+          try
           {
-            try {
+            long tries = 1000;
+            while (sv.isBusy() && tries > 0)
+            {
               Thread.sleep(25);
+              if (sv.isBusy())
+              {
+                tries--;
+                Console.debug(
+                        "Waiting for viewer for " + structureFilepath);
+              }
             }
-            catch (Exception x)
+            if (tries == 0 && sv.isBusy())
             {
-              
+              Console.warn(
+                      "Gave up waiting for structure viewer to load. Something may have gone wrong.");
             }
+          } catch (Exception x)
+          {
+            Console.warn("Exception whilst waiting for structure viewer "
+                    + structureFilepath, x);
           }
-
+          Console.debug(
+                  "Successfully opened viewer for " + structureFilepath);
           String structureImageFilename = ArgParser.getValueFromSubValOrArg(
                   avm, av, Arg.STRUCTUREIMAGE, subVals);
           if (sv != null && structureImageFilename != null)
@@ -624,12 +629,13 @@ public class Commands
             }
             BitmapImageSizing userBis = ImageMaker
                     .parseScaleWidthHeightStrings(scale, width, height);
+            // TODO MAKE THIS VIEWER INDEPENDENT!!
             switch (StructureViewer.getViewerType())
             {
             case JMOL:
               try
               {
-                Thread.sleep(1000);
+                Thread.sleep(1000); // WHY ???
               } catch (InterruptedException e)
               {
                 // TODO Auto-generated catch block
@@ -640,13 +646,18 @@ public class Commands
               if (sview instanceof AppJmol)
               {
                 AppJmol jmol = (AppJmol) sview;
-                try { 
+                try
+                {
+                  Console.debug("Rendering image to " + structureImageFile);
                   jmol.makePDBImage(structureImageFile, imageType, renderer,
-                        userBis);
-                }
-                catch (ImageOutputException ioexc)
+                          userBis);
+                  Console.debug("Finished Rendering image to "
+                          + structureImageFile);
+
+                } catch (ImageOutputException ioexc)
                 {
-                  Console.warn("Unexpected error whilst exporting image to "+structureImageFile,ioexc);
+                  Console.warn("Unexpected error whilst exporting image to "
+                          + structureImageFile, ioexc);
                 }
 
               }
@@ -661,6 +672,15 @@ public class Commands
       }
     }
 
+    if (wrap)
+    {
+      AlignFrame af = afMap.get(id);
+      if (af != null)
+      {
+        af.setWrapFormat(wrap, true);
+      }
+    }
+
     /*
     boolean doShading = avm.getBoolean(Arg.TEMPFAC_SHADING);
     if (doShading)
@@ -756,57 +776,60 @@ public class Commands
         Cache.setProperty("EXPORT_EMBBED_BIOJSON", "false");
 
         Console.info("Writing " + file);
-        try {
-        switch (type)
+        try
         {
-
-        case "svg":
-          Console.debug("Outputting type '" + type + "' to " + fileName);
-          af.createSVG(file, renderer);
-          break;
-
-        case "png":
-          Console.debug("Outputting type '" + type + "' to " + fileName);
-          af.createPNG(file, null, userBis);
-          break;
-
-        case "html":
-          Console.debug("Outputting type '" + type + "' to " + fileName);
-          HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
-          htmlSVG.exportHTML(fileName, renderer);
-          break;
-
-        case "biojs":
-          Console.debug("Creating BioJS MSA Viwer HTML file: " + fileName);
-          try
-          {
-            BioJsHTMLOutput.refreshVersionInfo(
-                    BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
-          } catch (URISyntaxException e)
+          switch (type)
           {
-            e.printStackTrace();
+
+          case "svg":
+            Console.debug("Outputting type '" + type + "' to " + fileName);
+            af.createSVG(file, renderer);
+            break;
+
+          case "png":
+            Console.debug("Outputting type '" + type + "' to " + fileName);
+            af.createPNG(file, null, userBis);
+            break;
+
+          case "html":
+            Console.debug("Outputting type '" + type + "' to " + fileName);
+            HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
+            htmlSVG.exportHTML(fileName, renderer);
+            break;
+
+          case "biojs":
+            Console.debug(
+                    "Creating BioJS MSA Viwer HTML file: " + fileName);
+            try
+            {
+              BioJsHTMLOutput.refreshVersionInfo(
+                      BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
+            } catch (URISyntaxException e)
+            {
+              e.printStackTrace();
+            }
+            BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
+            bjs.exportHTML(fileName);
+            break;
+
+          case "eps":
+            Console.debug("Creating EPS file: " + fileName);
+            af.createEPS(file, name);
+            break;
+
+          case "imagemap":
+            Console.debug("Creating ImageMap file: " + fileName);
+            af.createImageMap(file, name);
+            break;
+
+          default:
+            Console.warn(Arg.IMAGE.argString() + " type '" + type
+                    + "' not known. Ignoring");
+            break;
           }
-          BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
-          bjs.exportHTML(fileName);
-          break;
-
-        case "eps":
-          Console.debug("Creating EPS file: " + fileName);
-          af.createEPS(file, name);
-          break;
-
-        case "imagemap":
-          Console.debug("Creating ImageMap file: " + fileName);
-          af.createImageMap(file, name);
-          break;
-
-        default:
-          Console.warn(Arg.IMAGE.argString() + " type '" + type
-                  + "' not known. Ignoring");
-          break;
-        }
-        } catch (Exception ioex) {
-          Console.warn("Unexpected error during export",ioex);
+        } catch (Exception ioex)
+        {
+          Console.warn("Unexpected error during export", ioex);
         }
       }
     }
@@ -831,6 +854,7 @@ public class Commands
         String val = av.getValue();
         SubVals subVals = av.getSubVals();
         String fileName = subVals.getContent();
+        boolean stdout = ArgParser.STDOUTFILENAME.equals(fileName);
         File file = new File(fileName);
         boolean overwrite = ArgParser.getFromSubValArgOrPref(avm,
                 Arg.OVERWRITE, subVals, null, "OVERWRITE_OUTPUT", false);
@@ -843,7 +867,7 @@ public class Commands
                 !Platform.isHeadless());
 
         // if backups is not true then --overwrite must be specified
-        if (file.exists() && !(overwrite || backups))
+        if (file.exists() && !(overwrite || backups || stdout))
         {
           Console.error("Won't overwrite file '" + fileName + "' without "
                   + Arg.OVERWRITE.argString() + " or "
@@ -881,23 +905,30 @@ public class Commands
         }
         if (ff == null)
         {
-          StringBuilder validSB = new StringBuilder();
-          for (String f : validFormats)
-          {
-            if (validSB.length() > 0)
-              validSB.append(", ");
-            validSB.append(f);
-            FileFormatI tff = ffs.forName(f);
-            validSB.append(" (");
-            validSB.append(tff.getExtensions());
-            validSB.append(")");
+          if (stdout)
+          {
+            ff = FileFormat.Fasta;
           }
+          else
+          {
+            StringBuilder validSB = new StringBuilder();
+            for (String f : validFormats)
+            {
+              if (validSB.length() > 0)
+                validSB.append(", ");
+              validSB.append(f);
+              FileFormatI tff = ffs.forName(f);
+              validSB.append(" (");
+              validSB.append(tff.getExtensions());
+              validSB.append(")");
+            }
 
-          Jalview.exit("No valid format specified for "
-                  + Arg.OUTPUT.argString() + ". Valid formats are "
-                  + validSB.toString() + ".", 1);
-          // this return really shouldn't happen
-          return false;
+            Jalview.exit("No valid format specified for "
+                    + Arg.OUTPUT.argString() + ". Valid formats are "
+                    + validSB.toString() + ".", 1);
+            // this return really shouldn't happen
+            return false;
+          }
         }
 
         String savedBackupsPreference = Cache
@@ -908,7 +939,7 @@ public class Commands
 
         Console.info("Writing " + fileName);
 
-        af.saveAlignment(fileName, ff);
+        af.saveAlignment(fileName, ff, stdout);
         Console.debug("Returning backups to " + savedBackupsPreference);
         if (savedBackupsPreference != null)
           Cache.applicationProperties.put(BackupFiles.ENABLED,
index 30fd530..c42d519 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.bin;
 
+import java.io.PrintStream;
 import java.util.Locale;
 
 import jalview.log.JLogger;
@@ -43,8 +44,8 @@ public class Console
     }
     else
     {
-      System.out.println(message);
-      t.printStackTrace();
+      outPrintln(message);
+      Console.printStackTrace(t);
     }
 
   }
@@ -57,7 +58,7 @@ public class Console
     }
     else
     {
-      System.out.println(message);
+      outPrintln(message);
     }
 
   }
@@ -70,8 +71,8 @@ public class Console
     }
     else
     {
-      System.out.println(message);
-      t.printStackTrace();
+      outPrintln(message);
+      Console.printStackTrace(t);
     }
   }
 
@@ -83,7 +84,7 @@ public class Console
     }
     else
     {
-      System.out.println(message);
+      outPrintln(message);
     }
 
   }
@@ -96,8 +97,8 @@ public class Console
     }
     else
     {
-      System.out.println(message);
-      t.printStackTrace();
+      outPrintln(message);
+      Console.printStackTrace(t);
     }
 
   }
@@ -110,7 +111,7 @@ public class Console
     }
     else
     {
-      System.out.println(message);
+      outPrintln(message);
     }
 
   }
@@ -123,7 +124,7 @@ public class Console
     }
     else
     {
-      System.out.println(message);
+      outPrintln(message);
     }
   }
 
@@ -135,8 +136,8 @@ public class Console
     }
     else
     {
-      System.out.println(message);
-      t.printStackTrace();
+      outPrintln(message);
+      Console.printStackTrace(t);
     }
 
   }
@@ -149,7 +150,7 @@ public class Console
     }
     else
     {
-      System.err.println(message);
+      jalview.bin.Console.errPrintln(message);
     }
 
   }
@@ -162,8 +163,8 @@ public class Console
     }
     else
     {
-      System.err.println(message);
-      t.printStackTrace(System.err);
+      jalview.bin.Console.errPrintln(message);
+      Console.printStackTrace(t);
     }
 
   }
@@ -176,7 +177,7 @@ public class Console
     }
     else
     {
-      System.err.println(message);
+      jalview.bin.Console.errPrintln(message);
     }
 
   }
@@ -189,8 +190,8 @@ public class Console
     }
     else
     {
-      System.err.println(message);
-      t.printStackTrace(System.err);
+      jalview.bin.Console.errPrintln(message);
+      Console.printStackTrace(t);
     }
 
   }
@@ -253,7 +254,7 @@ public class Console
       {
         if (!Jalview.quiet())
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Setting initial log level to " + logLevel.name());
         }
         Log4j.init(logLevel);
@@ -267,8 +268,9 @@ public class Console
       log = JLoggerLog4j.getLogger(Cache.JALVIEW_LOGGER_NAME, logLevel);
     } catch (NoClassDefFoundError e)
     {
-      System.err.println("Could not initialise the logger framework");
-      e.printStackTrace();
+      jalview.bin.Console
+              .errPrintln("Could not initialise the logger framework");
+      Console.printStackTrace(e);
     }
 
     // Test message
@@ -306,6 +308,86 @@ public class Console
     }
   }
 
+  public static void outPrint()
+  {
+    outPrint("");
+  }
+
+  public static void outPrintln()
+  {
+    outPrintln("");
+  }
+
+  public static void outPrint(Object message)
+  {
+    outPrintMessage(message, false, false);
+  }
+
+  public static void outPrint(Object message, boolean forceStdout)
+  {
+    outPrintMessage(message, false, forceStdout);
+  }
+
+  public static void outPrintln(Object message)
+  {
+    outPrintMessage(message, true, false);
+  }
+
+  public static PrintStream outputStream(boolean forceStdout)
+  {
+    // send message to stderr if an output file to stdout is expected
+    if (!forceStdout && Jalview.getInstance() != null
+            && Jalview.getInstance().bootstrapArgs != null
+            && Jalview.getInstance().bootstrapArgs.outputToStdout())
+    {
+      return System.err;
+    }
+    else
+    {
+      return System.out;
+    }
+  }
+
+  public static void outPrintMessage(Object message, boolean newline,
+          boolean forceStdout)
+  {
+    PrintStream ps = outputStream(forceStdout);
+    if (newline)
+    {
+      ps.println(message);
+    }
+    else
+    {
+      ps.print(message);
+    }
+  }
+
+  public static void errPrint()
+  {
+    errPrint("");
+  }
+
+  public static void errPrintln()
+  {
+    errPrintln("");
+  }
+
+  public static void errPrint(Object message)
+  {
+    System.err.print(message);
+  }
+
+  public static void errPrintln(Object message)
+  {
+    System.err.println(message);
+  }
+
+  public static void printStackTrace(Throwable t)
+  {
+    // send message to stderr if output to stdout is expected
+    t.printStackTrace(System.err);
+  }
+
   public final static String LOGGING_TEST_MESSAGE = "Logging to STDERR";
 
-}
+}
\ No newline at end of file
index b01dfb8..5332704 100644 (file)
@@ -61,7 +61,7 @@ class GetMemory
     } catch (NoClassDefFoundError e)
     {
       // com.sun.management.OperatingSystemMXBean doesn't exist in this JVM
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "No com.sun.management.OperatingSystemMXBean: cannot get total physical memory size");
     }
 
index 2bce673..e14c032 100644 (file)
@@ -20,9 +20,8 @@
  */
 package jalview.bin;
 
-import java.util.Locale;
-
 import java.awt.HeadlessException;
+import java.util.Locale;
 
 public class HiDPISetting
 {
@@ -117,8 +116,9 @@ public class HiDPISetting
         }
       } catch (NumberFormatException e)
       {
-        System.err.println(setHiDPIScalePropertyName + " property give ("
-                + setHiDPIScaleProperty + ") but not parseable as integer");
+        jalview.bin.Console.errPrintln(setHiDPIScalePropertyName
+                + " property give (" + setHiDPIScaleProperty
+                + ") but not parseable as integer");
       }
     }
     if (setHiDPI && setHiDPIScale > 0)
@@ -135,8 +135,8 @@ public class HiDPISetting
       try
       {
         int existingPropertyVal = Integer.parseInt(existingProperty);
-        System.out.println("Existing " + scalePropertyName + " is "
-                + existingPropertyVal);
+        jalview.bin.Console.outPrintln("Existing " + scalePropertyName
+                + " is " + existingPropertyVal);
         if (existingPropertyVal > 1)
         {
           setHiDPIScale(existingPropertyVal);
@@ -144,8 +144,9 @@ public class HiDPISetting
         }
       } catch (NumberFormatException e)
       {
-        System.out.println("Could not convert property " + scalePropertyName
-                + " vale '" + existingProperty + "' to number");
+        jalview.bin.Console.outPrintln(
+                "Could not convert property " + scalePropertyName
+                        + " vale '" + existingProperty + "' to number");
       }
     }
 
@@ -159,7 +160,11 @@ public class HiDPISetting
       dpi = screenInfo.getScreenResolution();
     } catch (HeadlessException e)
     {
-      System.err.println("Cannot get screen resolution: " + e.getMessage());
+      if (isLinux)
+      {
+        jalview.bin.Console.errPrintln(
+                "Cannot get screen resolution: " + e.getMessage());
+      }
     }
 
     // try and get screen size height and width
@@ -171,8 +176,12 @@ public class HiDPISetting
       mindimension = Math.min(height, width);
     } catch (HeadlessException e)
     {
-      System.err.println(
-              "Cannot get screen size height and width:" + e.getMessage());
+      if (isLinux)
+      {
+        jalview.bin.Console
+                .errPrintln("Cannot get screen size height and width:"
+                        + e.getMessage());
+      }
     }
 
     // attempt at a formula for scaling based on screen dpi and mindimension.
index 3a733f3..810d835 100755 (executable)
@@ -274,7 +274,7 @@ public class Jalview
      * 
      */
     {
-      System.out.println("not in js");
+      Console.outPrintln("not in js");
     }
 
     // BH - for event debugging in JavaScript (Java mode only)
@@ -383,29 +383,30 @@ public class Jalview
       }.start();
     }
 
-    if (!quiet() || bootstrapArgs.contains(Arg.VERSION))
+    if (!quiet() || !bootstrapArgs.outputToStdout()
+            || bootstrapArgs.contains(Arg.VERSION))
     {
-      System.out.println(
+      Console.outPrintln(
               "Java version: " + System.getProperty("java.version"));
-      System.out.println("Java home: " + System.getProperty("java.home"));
-      System.out.println("Java arch: " + System.getProperty("os.arch") + " "
+      Console.outPrintln("Java home: " + System.getProperty("java.home"));
+      Console.outPrintln("Java arch: " + System.getProperty("os.arch") + " "
               + System.getProperty("os.name") + " "
               + System.getProperty("os.version"));
 
       String val = System.getProperty("sys.install4jVersion");
       if (val != null)
       {
-        System.out.println("Install4j version: " + val);
+        Console.outPrintln("Install4j version: " + val);
       }
       val = System.getProperty("installer_template_version");
       if (val != null)
       {
-        System.out.println("Install4j template version: " + val);
+        Console.outPrintln("Install4j template version: " + val);
       }
       val = System.getProperty("launcher_version");
       if (val != null)
       {
-        System.out.println("Launcher version: " + val);
+        Console.outPrintln("Launcher version: " + val);
       }
     }
 
@@ -463,6 +464,7 @@ public class Jalview
     // register SIGTERM listener
     Runtime.getRuntime().addShutdownHook(new Thread()
     {
+      @Override
       public void run()
       {
         Console.debug("Running shutdown hook");
@@ -509,7 +511,7 @@ public class Jalview
     Cache.loadProperties(usrPropsFile);
     if (usrPropsFile != null)
     {
-      System.out.println(
+      Console.outPrintln(
               "CMD [-props " + usrPropsFile + "] executed successfully!");
       testoutput(bootstrapArgs, Arg.PROPS,
               "test/jalview/bin/testProps.jvprops", usrPropsFile);
@@ -541,7 +543,7 @@ public class Jalview
       {
         List<Map.Entry<Type, String>> helpArgs = bootstrapArgs
                 .getList(Arg.HELP);
-        System.out.println(Arg.usage(helpArgs.stream().map(e -> e.getKey())
+        Console.outPrintln(Arg.usage(helpArgs.stream().map(e -> e.getKey())
                 .collect(Collectors.toList())));
         Jalview.exit(null, 0);
       }
@@ -551,7 +553,7 @@ public class Jalview
          * Now using new usage statement.
         showUsage();
         */
-        System.out.println(Arg.usage());
+        Console.outPrintln(Arg.usage());
         Jalview.exit(null, 0);
       }
 
@@ -581,13 +583,13 @@ public class Jalview
         try
         {
           Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
-          System.out.println(
+          Console.outPrintln(
                   "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
           testoutput(bootstrapArgs, Arg.JABAWS,
                   "http://www.compbio.dundee.ac.uk/jabaws", jabawsUrl);
         } catch (MalformedURLException e)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Invalid jabaws parameter: " + jabawsUrl + " ignored");
         }
       }
@@ -617,7 +619,8 @@ public class Jalview
       }
       else
       {
-        System.out.println("Executing setprop argument: " + setprop);
+        jalview.bin.Console
+                .errPrintln("Executing setprop argument: " + setprop);
         if (Platform.isJS())
         {
           Cache.setProperty(setprop.substring(0, p),
@@ -633,8 +636,7 @@ public class Jalview
     {
       headless = true;
     }
-    System.setProperty("http.agent",
-            "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
+    System.setProperty("http.agent", HttpUtils.getUserAgent());
 
     try
     {
@@ -750,7 +752,7 @@ public class Jalview
         }
         else
         {
-          System.out.println("CMD [-nousagestats] executed successfully!");
+          Console.outPrintln("CMD [-nousagestats] executed successfully!");
           testoutput(argparser, Arg.NOUSAGESTATS);
         }
 
@@ -766,7 +768,7 @@ public class Jalview
             // questionnaire
             Console.debug("Starting questionnaire url at " + url);
             desktop.checkForQuestionnaire(url);
-            System.out.println("CMD questionnaire[-" + url
+            Console.outPrintln("CMD questionnaire[-" + url
                     + "] executed successfully!");
           }
           else
@@ -787,8 +789,8 @@ public class Jalview
         }
         else
         {
-          System.out
-                  .println("CMD [-noquestionnaire] executed successfully!");
+          Console.outPrintln(
+                  "CMD [-noquestionnaire] executed successfully!");
           testoutput(argparser, Arg.QUESTIONNAIRE);
         }
 
@@ -810,6 +812,7 @@ public class Jalview
     // Run Commands from cli
     cmds = new Commands(argparser, headlessArg);
     boolean commandsSuccess = cmds.argsWereParsed();
+
     if (commandsSuccess)
     {
       if (headlessArg)
@@ -877,7 +880,7 @@ public class Jalview
                         .getString("status.processing_commandline_args"),
                 progress = System.currentTimeMillis());
       }
-      System.out.println("CMD [-open " + file + "] executed successfully!");
+      Console.outPrintln("CMD [-open " + file + "] executed successfully!");
 
       if (!Platform.isJS())
       /**
@@ -914,7 +917,7 @@ public class Jalview
               format);
       if (af == null)
       {
-        System.out.println("error");
+        Console.outPrintln("error");
       }
       else
       {
@@ -929,7 +932,7 @@ public class Jalview
 
           if (cs != null)
           {
-            System.out.println(
+            Console.outPrintln(
                     "CMD [-colour " + data + "] executed successfully!");
           }
           af.changeColour(cs);
@@ -941,8 +944,8 @@ public class Jalview
         {
           af.parseFeaturesFile(data,
                   AppletFormatAdapter.checkProtocol(data));
-          // System.out.println("Added " + data);
-          System.out.println(
+          // Console.outPrintln("Added " + data);
+          Console.outPrintln(
                   "CMD groups[-" + data + "]  executed successfully!");
         }
         data = aparser.getValue("features", true);
@@ -950,8 +953,8 @@ public class Jalview
         {
           af.parseFeaturesFile(data,
                   AppletFormatAdapter.checkProtocol(data));
-          // System.out.println("Added " + data);
-          System.out.println(
+          // Console.outPrintln("Added " + data);
+          Console.outPrintln(
                   "CMD [-features " + data + "]  executed successfully!");
         }
 
@@ -959,8 +962,8 @@ public class Jalview
         if (data != null)
         {
           af.loadJalviewDataFile(data, null, null, null);
-          // System.out.println("Added " + data);
-          System.out.println(
+          // Console.outPrintln("Added " + data);
+          Console.outPrintln(
                   "CMD [-annotations " + data + "] executed successfully!");
         }
         // set or clear the sortbytree flag.
@@ -969,7 +972,7 @@ public class Jalview
           af.getViewport().setSortByTree(true);
           if (af.getViewport().getSortByTree())
           {
-            System.out.println("CMD [-sortbytree] executed successfully!");
+            Console.outPrintln("CMD [-sortbytree] executed successfully!");
           }
         }
         if (aparser.contains("no-annotation"))
@@ -977,7 +980,7 @@ public class Jalview
           af.getViewport().setShowAnnotation(false);
           if (!af.getViewport().isShowAnnotation())
           {
-            System.out.println("CMD no-annotation executed successfully!");
+            Console.outPrintln("CMD no-annotation executed successfully!");
           }
         }
         if (aparser.contains("nosortbytree"))
@@ -985,8 +988,8 @@ public class Jalview
           af.getViewport().setSortByTree(false);
           if (!af.getViewport().getSortByTree())
           {
-            System.out
-                    .println("CMD [-nosortbytree] executed successfully!");
+            Console.outPrintln(
+                    "CMD [-nosortbytree] executed successfully!");
           }
         }
         data = aparser.getValue("tree", true);
@@ -994,7 +997,7 @@ public class Jalview
         {
           try
           {
-            System.out.println(
+            Console.outPrintln(
                     "CMD [-tree " + data + "] executed successfully!");
             NewickFile nf = new NewickFile(data,
                     AppletFormatAdapter.checkProtocol(data));
@@ -1002,7 +1005,7 @@ public class Jalview
                     .setCurrentTree(af.showNewickTree(nf, data).getTree());
           } catch (IOException ex)
           {
-            System.err.println("Couldn't add tree " + data);
+            jalview.bin.Console.errPrintln("Couldn't add tree " + data);
             ex.printStackTrace(System.err);
           }
         }
@@ -1011,9 +1014,9 @@ public class Jalview
         {
           // Execute the groovy script after we've done all the rendering stuff
           // and before any images or figures are generated.
-          System.out.println("Executing script " + groovyscript);
+          Console.outPrintln("Executing script " + groovyscript);
           executeGroovyScript(groovyscript, af);
-          System.out.println("CMD groovy[" + groovyscript
+          Console.outPrintln("CMD groovy[" + groovyscript
                   + "] executed successfully!");
           groovyscript = null;
         }
@@ -1027,14 +1030,14 @@ public class Jalview
 
             if (outputFormat.equalsIgnoreCase("png"))
             {
-              System.out.println("Creating PNG image: " + file);
+              Console.outPrintln("Creating PNG image: " + file);
               af.createPNG(new File(file));
               imageName = (new File(file)).getName();
               continue;
             }
             else if (outputFormat.equalsIgnoreCase("svg"))
             {
-              System.out.println("Creating SVG image: " + file);
+              Console.outPrintln("Creating SVG image: " + file);
               File imageFile = new File(file);
               imageName = imageFile.getName();
               af.createSVG(imageFile);
@@ -1046,7 +1049,7 @@ public class Jalview
               imageName = imageFile.getName();
               HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
 
-              System.out.println("Creating HTML image: " + file);
+              Console.outPrintln("Creating HTML image: " + file);
               htmlSVG.exportHTML(file);
               continue;
             }
@@ -1054,7 +1057,8 @@ public class Jalview
             {
               if (file == null)
               {
-                System.err.println("The output html file must not be null");
+                jalview.bin.Console.errPrintln(
+                        "The output html file must not be null");
                 return;
               }
               try
@@ -1066,21 +1070,21 @@ public class Jalview
                 e.printStackTrace();
               }
               BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
-              System.out.println(
+              Console.outPrintln(
                       "Creating BioJS MSA Viwer HTML file: " + file);
               bjs.exportHTML(file);
               continue;
             }
             else if (outputFormat.equalsIgnoreCase("imgMap"))
             {
-              System.out.println("Creating image map: " + file);
+              Console.outPrintln("Creating image map: " + file);
               af.createImageMap(new File(file), imageName);
               continue;
             }
             else if (outputFormat.equalsIgnoreCase("eps"))
             {
               File outputFile = new File(file);
-              System.out.println(
+              Console.outPrintln(
                       "Creating EPS file: " + outputFile.getAbsolutePath());
               af.createEPS(outputFile);
               continue;
@@ -1092,14 +1096,14 @@ public class Jalview
               outFormat = FileFormats.getInstance().forName(outputFormat);
             } catch (Exception formatP)
             {
-              System.out.println("Couldn't parse " + outFormat
+              Console.outPrintln("Couldn't parse " + outFormat
                       + " as a valid Jalview format string.");
             }
             if (outFormat != null)
             {
               if (!outFormat.isWritable())
               {
-                System.out.println(
+                Console.outPrintln(
                         "This version of Jalview does not support alignment export as "
                                 + outputFormat);
               }
@@ -1108,19 +1112,19 @@ public class Jalview
                 af.saveAlignment(file, outFormat);
                 if (af.isSaveAlignmentSuccessful())
                 {
-                  System.out.println("Written alignment in "
+                  Console.outPrintln("Written alignment in "
                           + outFormat.getName() + " format to " + file);
                 }
                 else
                 {
-                  System.out.println("Error writing file " + file + " in "
+                  Console.outPrintln("Error writing file " + file + " in "
                           + outFormat.getName() + " format!!");
                 }
               }
             }
           } catch (ImageOutputException ioexc)
           {
-            System.out.println(
+            Console.outPrintln(
                     "Unexpected error whilst exporting image to " + file);
             ioexc.printStackTrace();
           }
@@ -1129,7 +1133,7 @@ public class Jalview
 
         while (aparser.getSize() > 0)
         {
-          System.out.println("Unknown arg: " + aparser.nextValue());
+          Console.outPrintln("Unknown arg: " + aparser.nextValue());
         }
       }
     }
@@ -1197,12 +1201,12 @@ public class Jalview
     {
       if (Cache.groovyJarsPresent())
       {
-        System.out.println("Executing script " + groovyscript);
+        Console.outPrintln("Executing script " + groovyscript);
         executeGroovyScript(groovyscript, startUpAlframe);
       }
       else
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
                         + groovyscript);
       }
@@ -1497,7 +1501,7 @@ public class Jalview
       UIManager.put("TabbedPane.tabType", "card");
       UIManager.put("TabbedPane.showTabSeparators", true);
       UIManager.put("TabbedPane.showContentSeparator", true);
-      UIManager.put("TabbedPane.tabSeparatorsFullHeight", true);
+      // UIManager.put("TabbedPane.tabSeparatorsFullHeight", true);
       UIManager.put("TabbedPane.tabsOverlapBorder", true);
       UIManager.put("TabbedPane.hasFullBorder", true);
       UIManager.put("TabbedPane.tabLayoutPolicy", "scroll");
@@ -1547,7 +1551,7 @@ public class Jalview
   /*
   private static void showUsage()
   {
-    System.out.println(
+    jalview.bin.Console.outPrintln(
             "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
                     + "-nodisplay\tRun Jalview without User Interface.\n"
                     + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
@@ -1573,7 +1577,7 @@ public class Jalview
                     + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
                     + "-noquestionnaire\tTurn off questionnaire check.\n"
                     + "-nonews\tTurn off check for Jalview news.\n"
-                    + "-nousagestats\tTurn off google analytics tracking for this session.\n"
+                    + "-nousagestats\tTurn off analytics tracking for this session.\n"
                     + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
                     // +
                     // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
@@ -1596,16 +1600,15 @@ public class Jalview
      */
     PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
             "USAGESTATS",
-            MessageManager.getString("prompt.google_analytics_title"),
-            MessageManager.getString("prompt.google_analytics"),
+            MessageManager.getString("prompt.plausible_analytics_title"),
+            MessageManager.getString("prompt.plausible_analytics"),
             new Runnable()
             {
               @Override
               public void run()
               {
-                Console.debug(
-                        "Initialising googletracker for usage stats.");
-                Cache.initGoogleTracker();
+                Console.debug("Initialising analytics for usage stats.");
+                Cache.initAnalytics();
                 Console.debug("Tracking enabled.");
               }
             }, new Runnable()
@@ -1613,7 +1616,7 @@ public class Jalview
               @Override
               public void run()
               {
-                Console.debug("Not enabling Google Tracking.");
+                Console.debug("Not enabling analytics.");
               }
             }, null, true);
     desktop.addDialogThread(prompter);
@@ -1659,9 +1662,10 @@ public class Jalview
 
       } catch (Exception ex)
       {
-        System.err.println("Failed to read from STDIN into tempfile "
-                + ((tfile == null) ? "(tempfile wasn't created)"
-                        : tfile.toString()));
+        jalview.bin.Console
+                .errPrintln("Failed to read from STDIN into tempfile "
+                        + ((tfile == null) ? "(tempfile wasn't created)"
+                                : tfile.toString()));
         ex.printStackTrace();
         return;
       }
@@ -1670,7 +1674,7 @@ public class Jalview
         sfile = tfile.toURI().toURL();
       } catch (Exception x)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
                         + tfile.toURI());
         x.printStackTrace();
@@ -1687,17 +1691,20 @@ public class Jalview
         tfile = new File(groovyscript);
         if (!tfile.exists())
         {
-          System.err.println("File '" + groovyscript + "' does not exist.");
+          jalview.bin.Console.errPrintln(
+                  "File '" + groovyscript + "' does not exist.");
           return;
         }
         if (!tfile.canRead())
         {
-          System.err.println("File '" + groovyscript + "' cannot be read.");
+          jalview.bin.Console.errPrintln(
+                  "File '" + groovyscript + "' cannot be read.");
           return;
         }
         if (tfile.length() < 1)
         {
-          System.err.println("File '" + groovyscript + "' is empty.");
+          jalview.bin.Console
+                  .errPrintln("File '" + groovyscript + "' is empty.");
           return;
         }
         try
@@ -1705,7 +1712,7 @@ public class Jalview
           sfile = tfile.getAbsoluteFile().toURI().toURL();
         } catch (Exception ex)
         {
-          System.err.println("Failed to create a file URL for "
+          jalview.bin.Console.errPrintln("Failed to create a file URL for "
                   + tfile.getAbsoluteFile());
           return;
         }
@@ -1730,8 +1737,9 @@ public class Jalview
       }
     } catch (Exception e)
     {
-      System.err.println("Exception Whilst trying to execute file " + sfile
-              + " as a groovy script.");
+      jalview.bin.Console
+              .errPrintln("Exception Whilst trying to execute file " + sfile
+                      + " as a groovy script.");
       e.printStackTrace(System.err);
 
     }
@@ -1787,11 +1795,11 @@ public class Jalview
       {
         if (exitcode == 0)
         {
-          System.out.println(message);
+          Console.outPrintln(message);
         }
         else
         {
-          System.err.println(message);
+          jalview.bin.Console.errPrintln(message);
         }
       }
     }
@@ -1883,7 +1891,7 @@ public class Jalview
     if (yes && ((s1 == null && s2 == null)
             || (s1 != null && s1.equals(s2))))
     {
-      System.out.println("[TESTOUTPUT] arg " + a.argString() + "='" + s1
+      Console.outPrintln("[TESTOUTPUT] arg " + a.argString() + "='" + s1
               + "' was set");
     }
   }
@@ -1941,6 +1949,6 @@ public class Jalview
     {
       message = a.argString() + (yes ? " was set" : " was not set");
     }
-    System.out.println("[TESTOUTPUT] arg " + message);
+    Console.outPrintln("[TESTOUTPUT] arg " + message);
   }
 }
index 7d66f6d..e8be95f 100644 (file)
@@ -292,7 +292,7 @@ public class JalviewLite extends Applet
     {
       if (debug)
       {
-        System.err.println("Selecting region using separator string '"
+        jalview.bin.Console.errPrintln("Selecting region using separator string '"
                 + separator + "'");
       }
     }
@@ -344,7 +344,7 @@ public class JalviewLite extends Applet
             from--;
           } catch (NumberFormatException ex)
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "ERROR: Couldn't parse first integer in range element column selection string '"
                             + cl + "' - format is 'from-to'");
             return;
@@ -355,7 +355,7 @@ public class JalviewLite extends Applet
             to--;
           } catch (NumberFormatException ex)
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "ERROR: Couldn't parse second integer in range element column selection string '"
                             + cl + "' - format is 'from-to'");
             return;
@@ -396,13 +396,13 @@ public class JalviewLite extends Applet
             }
             if (debug)
             {
-              System.err.println("Range '" + cl + "' deparsed as [" + from
+              jalview.bin.Console.errPrintln("Range '" + cl + "' deparsed as [" + from
                       + "," + to + "]");
             }
           }
           else
           {
-            System.err.println("ERROR: Invalid Range '" + cl
+            jalview.bin.Console.errPrintln("ERROR: Invalid Range '" + cl
                     + "' deparsed as [" + from + "," + to + "]");
           }
         }
@@ -422,7 +422,7 @@ public class JalviewLite extends Applet
             }
             else
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "ERROR: Couldn't parse integer from point selection element of column selection string '"
                               + cl + "'");
               return;
@@ -451,13 +451,13 @@ public class JalviewLite extends Applet
             csel.addElement(r);
             if (debug)
             {
-              System.err.println("Point selection '" + cl
+              jalview.bin.Console.errPrintln("Point selection '" + cl
                       + "' deparsed as [" + r + "]");
             }
           }
           else
           {
-            System.err.println("ERROR: Invalid Point selection '" + cl
+            jalview.bin.Console.errPrintln("ERROR: Invalid Point selection '" + cl
                     + "' deparsed as [" + r + "]");
           }
         }
@@ -940,7 +940,7 @@ public class JalviewLite extends Applet
       listener = listener.trim();
       if (listener.length() == 0)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "jalview Javascript error: Ignoring empty function for mouseover listener.");
         return;
       }
@@ -952,11 +952,11 @@ public class JalviewLite extends Applet
             .addStructureViewerListener(mol);
     if (debug)
     {
-      System.err.println("Added a mouseover listener for "
+      jalview.bin.Console.errPrintln("Added a mouseover listener for "
               + ((af == null) ? "All frames"
                       : "Just views for "
                               + af.getAlignViewport().getSequenceSetId()));
-      System.err.println("There are now " + javascriptListeners.size()
+      jalview.bin.Console.errPrintln("There are now " + javascriptListeners.size()
               + " listeners in total.");
     }
   }
@@ -987,7 +987,7 @@ public class JalviewLite extends Applet
       listener = listener.trim();
       if (listener.length() == 0)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "jalview Javascript error: Ignoring empty function for selection listener.");
         return;
       }
@@ -999,11 +999,11 @@ public class JalviewLite extends Applet
             .addSelectionListener(mol);
     if (debug)
     {
-      System.err.println("Added a selection listener for "
+      jalview.bin.Console.errPrintln("Added a selection listener for "
               + ((af == null) ? "All frames"
                       : "Just views for "
                               + af.getAlignViewport().getSequenceSetId()));
-      System.err.println("There are now " + javascriptListeners.size()
+      jalview.bin.Console.errPrintln("There are now " + javascriptListeners.size()
               + " listeners in total.");
     }
   }
@@ -1027,7 +1027,7 @@ public class JalviewLite extends Applet
       listener = listener.trim();
       if (listener.length() == 0)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "jalview Javascript error: Ignoring empty function for selection listener.");
         return;
       }
@@ -1039,9 +1039,9 @@ public class JalviewLite extends Applet
             .addStructureViewerListener(mol);
     if (debug)
     {
-      System.err.println("Added a javascript structure viewer listener '"
+      jalview.bin.Console.errPrintln("Added a javascript structure viewer listener '"
               + listener + "'");
-      System.err.println("There are now " + javascriptListeners.size()
+      jalview.bin.Console.errPrintln("There are now " + javascriptListeners.size()
               + " listeners in total.");
     }
   }
@@ -1087,7 +1087,7 @@ public class JalviewLite extends Applet
         rprt = debug;
         if (debug)
         {
-          System.err.println("Removed listener '" + listener + "'");
+          jalview.bin.Console.errPrintln("Removed listener '" + listener + "'");
         }
       }
       else
@@ -1097,7 +1097,7 @@ public class JalviewLite extends Applet
     }
     if (rprt)
     {
-      System.err.println("There are now " + javascriptListeners.size()
+      jalview.bin.Console.errPrintln("There are now " + javascriptListeners.size()
               + " listeners in total.");
     }
   }
@@ -1105,14 +1105,14 @@ public class JalviewLite extends Applet
   @Override
   public void stop()
   {
-    System.err.println("Applet " + getName() + " stop().");
+    jalview.bin.Console.errPrintln("Applet " + getName() + " stop().");
     tidyUp();
   }
 
   @Override
   public void destroy()
   {
-    System.err.println("Applet " + getName() + " destroy().");
+    jalview.bin.Console.errPrintln("Applet " + getName() + " destroy().");
     tidyUp();
   }
 
@@ -1189,7 +1189,7 @@ public class JalviewLite extends Applet
           }
         } catch (NumberFormatException e)
         {
-          System.err.println("Ignoring invalid residue number string '"
+          jalview.bin.Console.errPrintln("Ignoring invalid residue number string '"
                   + pdbResNum + "'");
         }
 
@@ -1220,7 +1220,7 @@ public class JalviewLite extends Applet
 
         } catch (Exception ex)
         {
-          System.err.println("Couldn't parse integer arguments (topRow='"
+          jalview.bin.Console.errPrintln("Couldn't parse integer arguments (topRow='"
                   + topRow + "' and leftHandColumn='" + leftHandColumn
                   + "')");
           ex.printStackTrace();
@@ -1251,7 +1251,7 @@ public class JalviewLite extends Applet
 
         } catch (Exception ex)
         {
-          System.err.println("Couldn't parse integer arguments (topRow='"
+          jalview.bin.Console.errPrintln("Couldn't parse integer arguments (topRow='"
                   + topRow + "')");
           ex.printStackTrace();
         }
@@ -1283,7 +1283,7 @@ public class JalviewLite extends Applet
 
         } catch (Exception ex)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Couldn't parse integer arguments (leftHandColumn='"
                           + leftHandColumn + "')");
           ex.printStackTrace();
@@ -1415,18 +1415,18 @@ public class JalviewLite extends Applet
     {
       if (debug)
       {
-        System.err.println("Applet context is '"
+        jalview.bin.Console.errPrintln("Applet context is '"
                 + getAppletContext().getClass().toString() + "'");
       }
       JSObject scriptObject = JSObject.getWindow(this);
       if (debug && scriptObject != null)
       {
-        System.err.println("Applet has Javascript callback support.");
+        jalview.bin.Console.errPrintln("Applet has Javascript callback support.");
       }
 
     } catch (Exception ex)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Warning: No JalviewLite javascript callbacks available.");
       if (debug)
       {
@@ -1436,9 +1436,9 @@ public class JalviewLite extends Applet
 
     if (debug)
     {
-      System.err.println("JalviewLite Version " + getVersion());
-      System.err.println("Build Date : " + getBuildDate());
-      System.err.println("Installation : " + getInstallation());
+      jalview.bin.Console.errPrintln("JalviewLite Version " + getVersion());
+      jalview.bin.Console.errPrintln("Build Date : " + getBuildDate());
+      jalview.bin.Console.errPrintln("Installation : " + getInstallation());
     }
     String externalsviewer = getParameter("externalstructureviewer");
     if (externalsviewer != null)
@@ -1465,7 +1465,7 @@ public class JalviewLite extends Applet
         separator = sep;
         if (debug)
         {
-          System.err.println("Separator set to '" + separator + "'");
+          jalview.bin.Console.errPrintln("Separator set to '" + separator + "'");
         }
       }
       else
@@ -1573,7 +1573,7 @@ public class JalviewLite extends Applet
     {
       if (tries > 0)
       {
-        System.err.println("LiveConnect request thread going to sleep.");
+        jalview.bin.Console.errPrintln("LiveConnect request thread going to sleep.");
       }
       try
       {
@@ -1584,7 +1584,7 @@ public class JalviewLite extends Applet
       ;
       if (tries++ > 0)
       {
-        System.err.println("LiveConnect request thread woken up.");
+        jalview.bin.Console.errPrintln("LiveConnect request thread woken up.");
       }
       try
       {
@@ -1595,7 +1595,7 @@ public class JalviewLite extends Applet
         }
       } catch (Exception jsex)
       {
-        System.err.println("Attempt " + tries
+        jalview.bin.Console.errPrintln("Attempt " + tries
                 + " to access LiveConnect javascript failed.");
       }
     }
@@ -1632,14 +1632,14 @@ public class JalviewLite extends Applet
                   "Calling oninit callback '" + initjscallback + "'.");
         } catch (Exception e)
         {
-          System.err.println("Exception when executing _oninit callback '"
+          jalview.bin.Console.errPrintln("Exception when executing _oninit callback '"
                   + initjscallback + "'.");
           e.printStackTrace();
         }
       }
       else
       {
-        System.err.println("Not executing _oninit callback '"
+        jalview.bin.Console.errPrintln("Not executing _oninit callback '"
                 + initjscallback + "' - no scripting allowed.");
       }
     }
@@ -1700,7 +1700,7 @@ public class JalviewLite extends Applet
           ((AlignFrame) frame).viewport.applet.currentAlignFrame = (AlignFrame) frame;
           if (debug)
           {
-            System.err.println("Activated window " + frame);
+            jalview.bin.Console.errPrintln("Activated window " + frame);
           }
         }
         // be good.
@@ -1715,7 +1715,7 @@ public class JalviewLite extends Applet
        * 
        * public void windowDeactivated(WindowEvent e) { if (currentAlignFrame ==
        * frame) { currentAlignFrame = null; if (debug) {
-       * System.err.println("Deactivated window "+frame); } }
+       * jalview.bin.Console.errPrintln("Deactivated window "+frame); } }
        * super.windowDeactivated(e); }
        */
     });
@@ -1801,7 +1801,7 @@ public class JalviewLite extends Applet
           }
           if (!jmolAvailable)
           {
-            System.out.println(
+            jalview.bin.Console.outPrintln(
                     "Jmol not available - Using mc_view for structures");
           }
         } catch (java.lang.ClassNotFoundException ex)
@@ -1813,7 +1813,7 @@ public class JalviewLite extends Applet
         jmolAvailable = false;
         if (debug)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Skipping Jmol check. Will use mc_view (probably)");
         }
       }
@@ -1844,7 +1844,7 @@ public class JalviewLite extends Applet
     {
       if (JalviewLite.debug)
       {
-        System.err.println(msg);
+        jalview.bin.Console.errPrintln(msg);
       }
     }
 
@@ -1884,7 +1884,7 @@ public class JalviewLite extends Applet
       {
         if (debug)
         {
-          System.err.println("Prepended document base '" + documentBase
+          jalview.bin.Console.errPrintln("Prepended document base '" + documentBase
                   + "' to make: '" + withDocBase + "'");
         }
         protocol = DataSourceType.URL;
@@ -1903,7 +1903,7 @@ public class JalviewLite extends Applet
         protocol = DataSourceType.URL;
         if (debug)
         {
-          System.err.println("Prepended codebase '" + codeBase
+          jalview.bin.Console.errPrintln("Prepended codebase '" + codeBase
                   + "' to make: '" + withCodeBase + "'");
         }
         return withCodeBase;
@@ -2010,7 +2010,7 @@ public class JalviewLite extends Applet
                   + " as "
                   + (al1.isNucleotide() ? "protein product" : "cDNA")
                   + " for " + af.getTitle();
-          System.err.println(msg);
+          jalview.bin.Console.errPrintln(msg);
         }
       }
 
@@ -2084,7 +2084,7 @@ public class JalviewLite extends Applet
             dbgMsg(">>>Dump finished.");
           } catch (Exception e)
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Exception when trying to dump the content of the file parameter.");
             e.printStackTrace();
           }
@@ -2214,7 +2214,7 @@ public class JalviewLite extends Applet
                 {
                   // this may not really be a problem but we give a warning
                   // anyway
-                  System.err.println(
+                  jalview.bin.Console.errPrintln(
                           "Warning: Possible input parsing error: Null sequence for attachment of PDB (sequence "
                                   + i + ")");
                 }
@@ -2320,7 +2320,7 @@ public class JalviewLite extends Applet
         }
         else
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Annotations were not added from annotation file '"
                           + param + "'");
         }
@@ -2392,13 +2392,13 @@ public class JalviewLite extends Applet
         {
           if (debug)
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Attempting to load T-COFFEE score file from the scoreFile parameter");
           }
           result = alignFrame.loadScoreFile(sScoreFile);
           if (!result)
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Failed to parse T-COFFEE parameter as a valid score file ('"
                             + sScoreFile + "')");
           }
@@ -2469,13 +2469,13 @@ public class JalviewLite extends Applet
         boolean rtn = (getClass().getResourceAsStream("/" + f) != null);
         if (debug)
         {
-          System.err.println("Resource '" + f + "' was "
+          jalview.bin.Console.errPrintln("Resource '" + f + "' was "
                   + (rtn ? "" : "not ") + "located by classloader.");
         }
         return rtn;
       } catch (Exception ex)
       {
-        System.out.println("Exception checking resources: " + f + " " + ex);
+        jalview.bin.Console.outPrintln("Exception checking resources: " + f + " " + ex);
         return false;
       }
     }
@@ -2496,7 +2496,7 @@ public class JalviewLite extends Applet
     {
       return initialAlignFrame;
     }
-    System.err.println(
+    jalview.bin.Console.errPrintln(
             "Implementation error: Jalview Applet API cannot work out which AlignFrame to use.");
     return null;
   }
@@ -2564,18 +2564,18 @@ public class JalviewLite extends Applet
       jv.removeAllElements();
       if (debug)
       {
-        System.err.println("Array from '" + separator
+        jalview.bin.Console.errPrintln("Array from '" + separator
                 + "' separated List:\n" + v.length);
         for (int i = 0; i < v.length; i++)
         {
-          System.err.println("item " + i + " '" + v[i] + "'");
+          jalview.bin.Console.errPrintln("item " + i + " '" + v[i] + "'");
         }
       }
       return v;
     }
     if (debug)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Empty Array from '" + separator + "' separated List");
     }
     return null;
@@ -2620,13 +2620,13 @@ public class JalviewLite extends Applet
       {
         System.err
                 .println("Returning '" + separator + "' separated List:\n");
-        System.err.println(v);
+        jalview.bin.Console.errPrintln(v);
       }
       return v.toString();
     }
     if (debug)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Returning empty '" + separator + "' separated List\n");
     }
     return "" + separator;
@@ -2745,7 +2745,7 @@ public class JalviewLite extends Applet
     this.separator = separator;
     if (debug)
     {
-      System.err.println("Default Separator now: '" + separator + "'");
+      jalview.bin.Console.errPrintln("Default Separator now: '" + separator + "'");
     }
   }
 
@@ -2901,7 +2901,7 @@ public class JalviewLite extends Applet
     Color col = ColorUtils.parseColourString(colprop);
     if (col == null)
     {
-      System.err.println("Couldn't parse '" + colprop + "' as a colour for "
+      jalview.bin.Console.errPrintln("Couldn't parse '" + colprop + "' as a colour for "
               + colparam);
     }
     return (col == null) ? defcolour : col;
@@ -2971,7 +2971,7 @@ public class JalviewLite extends Applet
     }
     if (debug)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "resolveUrlForLocalOrAbsolute returning " + resolvedPath);
     }
     return resolvedPath;
@@ -3000,7 +3000,7 @@ public class JalviewLite extends Applet
                         : getDocumentBase());
         if (debug)
         {
-          System.err.println("Show url (prepended " + prepend
+          jalview.bin.Console.errPrintln("Show url (prepended " + prepend
                   + " - toggle resolvetocodebase if code/docbase resolution is wrong): "
                   + url);
         }
@@ -3009,7 +3009,7 @@ public class JalviewLite extends Applet
       {
         if (debug)
         {
-          System.err.println("Show url: " + url);
+          jalview.bin.Console.errPrintln("Show url: " + url);
         }
       }
       if (url.indexOf("javascript:") == 0)
index f2ffda5..d38892a 100644 (file)
@@ -64,7 +64,7 @@ public class JalviewLiteURLRetrieve extends Applet
     DataSourceType protocol = null;
     try
     {
-      System.out.println("Loading thread started with:\n>>file\n" + file
+      jalview.bin.Console.outPrintln("Loading thread started with:\n>>file\n" + file
               + ">>endfile");
       // This might throw a security exception in certain browsers
       // Netscape Communicator for instance.
@@ -77,7 +77,7 @@ public class JalviewLiteURLRetrieve extends Applet
           rtn = true;
           is.close();
         }
-        System.err.println("Resource '" + file + "' was "
+        jalview.bin.Console.errPrintln("Resource '" + file + "' was "
                 + (rtn ? "" : "not") + " located by classloader.");
         if (rtn)
         {
@@ -86,7 +86,7 @@ public class JalviewLiteURLRetrieve extends Applet
 
       } catch (Exception ex)
       {
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "Exception checking resources: " + file + " " + ex);
       }
       if (file.indexOf("://") > -1)
@@ -99,7 +99,7 @@ public class JalviewLiteURLRetrieve extends Applet
         protocol = DataSourceType.FILE;
       }
 
-      System.out.println("Trying to get contents of resource:");
+      jalview.bin.Console.outPrintln("Trying to get contents of resource:");
       FileParse fp = new FileParse(file, protocol);
       if (fp.isValid())
       {
@@ -112,7 +112,7 @@ public class JalviewLiteURLRetrieve extends Applet
       }
       else
       {
-        System.out.println("Resource at " + file
+        jalview.bin.Console.outPrintln("Resource at " + file
                 + " cannot be read with protocol==" + protocol);
         return;
       }
@@ -121,11 +121,11 @@ public class JalviewLiteURLRetrieve extends Applet
       if (format == null)
       {
         format = new IdentifyFile().identify(file, protocol);
-        System.out.println("Format is " + format);
+        jalview.bin.Console.outPrintln("Format is " + format);
       }
       else
       {
-        System.out.println("User specified Format is " + format);
+        jalview.bin.Console.outPrintln("User specified Format is " + format);
       }
       AlignmentI al = null;
       try
@@ -133,17 +133,17 @@ public class JalviewLiteURLRetrieve extends Applet
         al = new AppletFormatAdapter().readFile(file, protocol, format);
       } catch (java.io.IOException ex)
       {
-        System.err.println("Failed to open the file.");
+        jalview.bin.Console.errPrintln("Failed to open the file.");
         ex.printStackTrace();
       }
       if (al != null)
       {
-        System.out.println(new AppletFormatAdapter()
+        jalview.bin.Console.outPrintln(new AppletFormatAdapter()
                 .formatSequences(FileFormat.Fasta, al, false));
       }
     } catch (Exception e)
     {
-      System.err.println("bailing out : Unexpected exception:");
+      jalview.bin.Console.errPrintln("bailing out : Unexpected exception:");
       e.printStackTrace();
     }
   }
index c7ababa..e04c04f 100644 (file)
@@ -46,7 +46,7 @@ public class JalviewTaskbar
         }
         else
         {
-          System.out.println("Unable to setIconImage()");
+          Console.outPrintln("Unable to setIconImage()");
         }
       }
     }
index 9ddfa0d..e1415be 100644 (file)
@@ -50,28 +50,7 @@ public class Launcher
 {
   private final static String startClass = "jalview.bin.Jalview";
 
-  private static boolean checkJVMSymlink(String testBin)
-  {
-    File testBinFile = new File(testBin);
-    if (!testBinFile.exists())
-    {
-      return false;
-    }
-    File targetFile = null;
-    try
-    {
-      targetFile = testBinFile.getCanonicalFile();
-    } catch (IOException e)
-    {
-      return false;
-    }
-    if (targetFile != null && ("java".equals(targetFile.getName())
-            || "java.exe".equals(targetFile.getName())))
-    {
-      return true;
-    }
-    return false;
-  }
+  private final static String headlessProperty = "java.awt.headless";
 
   /**
    * main method for jalview.bin.Launcher. This restarts the same JRE's JVM with
@@ -85,57 +64,27 @@ public class Launcher
   {
     if (!LaunchUtils.checkJavaVersion())
     {
-      System.err.println("WARNING - The Java version being used (Java "
-              + LaunchUtils.getJavaVersion()
-              + ") may lead to problems. This installation of Jalview should be used with Java "
-              + LaunchUtils.getJavaCompileVersion() + ".");
-    }
-    final String appName = ChannelProperties.getProperty("app_name");
-    final String javaBinDir = System.getProperty("java.home")
-            + File.separator + "bin" + File.separator;
-    String javaBin = null;
-    if (javaBin == null && checkJVMSymlink(javaBinDir + appName))
-    {
-      javaBin = javaBinDir + appName;
-    }
-    if (javaBin == null && checkJVMSymlink(javaBinDir + "Jalview"))
-    {
-      javaBin = javaBinDir + "Jalview";
-    }
-    if (javaBin == null && checkJVMSymlink(javaBinDir + "java"))
-    {
-      javaBin = javaBinDir + "java";
-    }
-    if (javaBin == null)
-    {
-      javaBin = "java";
-    }
-
-    List<String> command = new ArrayList<>();
-    command.add(javaBin);
-
-    String memSetting = null;
-
-    boolean isAMac = System.getProperty("os.name").indexOf("Mac") > -1;
-
-    for (String jvmArg : ManagementFactory.getRuntimeMXBean()
-            .getInputArguments())
-    {
-      command.add(jvmArg);
+      jalview.bin.Console
+              .errPrintln("WARNING - The Java version being used (Java "
+                      + LaunchUtils.getJavaVersion()
+                      + ") may lead to problems. This installation of Jalview should be used with Java "
+                      + LaunchUtils.getJavaCompileVersion() + ".");
     }
-    command.add("-cp");
-    command.add(ManagementFactory.getRuntimeMXBean().getClassPath());
 
     String jvmmempc = null;
     String jvmmemmax = null;
     boolean debug = false;
     boolean wait = true;
     boolean quiet = false;
+    boolean headless = false;
+    boolean gui = false;
+    boolean stdout = false;
     // must set --debug before --launcher...
     boolean launcherstop = false;
     boolean launcherprint = false;
     boolean launcherwait = false;
     ArrayList<String> arguments = new ArrayList<>();
+    String previousArg = null;
     for (String arg : args)
     {
       if (arg.equals("--debug"))
@@ -146,6 +95,19 @@ public class Launcher
       {
         quiet = true;
       }
+      if (arg.equals("--headless"))
+      {
+        headless = true;
+      }
+      if (arg.equals("--gui"))
+      {
+        gui = true;
+      }
+      if (arg.equals("--output=-")
+              || (arg.equals("-") && "--output".equals(previousArg)))
+      {
+        stdout = true;
+      }
       if (debug && arg.equals("--launcherprint"))
       {
         launcherprint = true;
@@ -163,6 +125,7 @@ public class Launcher
       {
         wait = false;
       }
+      previousArg = arg;
       // Don't add the --launcher... args to Jalview launch
       if (arg.startsWith("--launcher"))
       {
@@ -203,6 +166,29 @@ public class Launcher
         arguments.add(arg);
       }
     }
+    if (gui)
+    {
+      // --gui takes precedence over --headless
+      headless = false;
+    }
+
+    final String appName = ChannelProperties.getProperty("app_name");
+
+    // if we're using jalview.bin.Launcher we always assume a console is in use
+    final String javaBin = LaunchUtils.findJavaBin(true);
+
+    List<String> command = new ArrayList<>();
+    command.add(javaBin);
+
+    String memSetting = null;
+
+    for (String jvmArg : ManagementFactory.getRuntimeMXBean()
+            .getInputArguments())
+    {
+      command.add(jvmArg);
+    }
+    command.add("-cp");
+    command.add(ManagementFactory.getRuntimeMXBean().getClassPath());
 
     // use saved preferences if no cmdline args
     boolean useCustomisedSettings = LaunchUtils
@@ -225,6 +211,7 @@ public class Launcher
     boolean memSet = false;
     boolean dockIcon = false;
     boolean dockName = false;
+    boolean headlessProp = false;
     for (int i = 0; i < command.size(); i++)
     {
       String arg = command.get(i);
@@ -245,6 +232,10 @@ public class Launcher
       {
         dockName = true;
       }
+      else if (arg.startsWith("-D" + headlessProperty + "="))
+      {
+        headlessProp = true;
+      }
     }
 
     if (!memSet)
@@ -259,7 +250,7 @@ public class Launcher
       }
     }
 
-    if (isAMac)
+    if (LaunchUtils.isMac)
     {
       if (!dockIcon)
       {
@@ -280,11 +271,16 @@ public class Launcher
                 + appName);
       }
     }
+    if (headless && !headlessProp)
+    {
+      System.setProperty(headlessProperty, "true");
+      command.add("-D" + headlessProperty + "=true");
+    }
 
     String scalePropertyArg = HiDPISetting.getScalePropertyArg();
     if (scalePropertyArg != null)
     {
-      sysout(debug, quiet, "Running " + startClass + " with scale setting "
+      syserr(debug, quiet, "Running " + startClass + " with scale setting "
               + scalePropertyArg);
       command.add(scalePropertyArg);
     }
@@ -297,10 +293,10 @@ public class Launcher
     if ((Boolean.parseBoolean(System.getProperty("launcherprint", "false"))
             || launcherprint))
     {
-      sysout(debug, quiet,
+      syserr(debug, quiet,
               "LAUNCHER COMMAND: " + String.join(" ", builder.command()));
     }
-    sysout(debug, quiet,
+    syserr(debug, quiet,
             "Running " + startClass + " with "
                     + (memSetting == null ? "no memory setting"
                             : ("memory setting " + memSetting)));
@@ -308,7 +304,7 @@ public class Launcher
     if (Boolean.parseBoolean(System.getProperty("launcherstop", "false"))
             || (debug && launcherstop))
     {
-      sysout(debug, quiet,
+      syserr(debug, quiet,
               "System property 'launcherstop' is set and not 'false'. Exiting.");
       System.exit(0);
     }
@@ -318,22 +314,23 @@ public class Launcher
       Process process = builder.start();
       if (wait || launcherwait)
       {
-        sysout(debug, quiet, "Launching application process");
+        syserr(debug, quiet, "Launching application process");
         process.waitFor();
       }
       else
       {
         int waitInt = 0;
-        sysout(debug, quiet,
+        syserr(debug, quiet,
                 "Wait time for application process is " + waitInt + "ms");
         process.waitFor(waitInt, TimeUnit.MILLISECONDS);
       }
-      sysout(debug, quiet, "Launcher process ending");
+      syserr(debug, quiet, "Launcher process ending");
     } catch (IOException e)
     {
       if (e.getMessage().toLowerCase(Locale.ROOT).contains("memory"))
       {
-        System.err.println("Caught a memory exception: " + e.getMessage());
+        jalview.bin.Console
+                .errPrintln("Caught a memory exception: " + e.getMessage());
         // Probably the "Cannot allocate memory" error, try without the memory
         // setting
         ArrayList<String> commandNoMem = new ArrayList<>();
@@ -346,7 +343,7 @@ public class Launcher
         }
         final ProcessBuilder builderNoMem = new ProcessBuilder(
                 commandNoMem);
-        System.err.println("Command without memory setting: "
+        jalview.bin.Console.errPrintln("Command without memory setting: "
                 + String.join(" ", builderNoMem.command()));
         try
         {
@@ -368,11 +365,11 @@ public class Launcher
     }
   }
 
-  private static void sysout(boolean debug, boolean quiet, String message)
+  private static void syserr(boolean debug, boolean quiet, String message)
   {
     if (debug && !quiet)
     {
-      System.out.println("LAUNCHERDEBUG - " + message);
+      jalview.bin.Console.errPrintln("LAUNCHERDEBUG - " + message);
     }
   }
 
index bb545cb..7458d55 100644 (file)
@@ -354,7 +354,7 @@ public class MemorySetting
     else
     {
       // number too big for a Long. Limit to Long.MAX_VALUE
-      System.out.println("Memory parsing of '" + memString
+      jalview.bin.Console.outPrintln("Memory parsing of '" + memString
               + "' produces number too big.  Limiting to Long.MAX_VALUE="
               + Long.MAX_VALUE);
       return Long.MAX_VALUE;
@@ -395,7 +395,7 @@ public class MemorySetting
     ADJUSTMENT_MESSAGE = reason;
     if (!quiet)
     {
-      System.out.println(reason);
+      jalview.bin.Console.outPrintln(reason);
     }
   }
 
index 2f25978..7882d7b 100644 (file)
@@ -29,8 +29,8 @@ public enum Arg
           Opt.UNARY, Opt.BOOTSTRAP),
   HEADLESS(Type.CONFIG,
           "Run Jalview in headless mode. No GUI interface will be created and Jalview will quit after all arguments have been processed. "
-                  + "Headless mode is assumed if an output file is to be generated, this can be overridden with --noheadless or --gui.",
-          Opt.BOOLEAN, Opt.BOOTSTRAP),
+                  + "Headless mode is assumed if an output file is to be generated, this can be overridden with --gui.",
+          Opt.UNARY, Opt.BOOTSTRAP),
   GUI(Type.CONFIG,
           "Do not run Jalview in headless mode.  This overrides the assumption of headless mode when an output file is to be generated.",
           Opt.UNARY, Opt.BOOTSTRAP),
@@ -93,11 +93,10 @@ public enum Arg
                   + "turn-propensity,\n" + "buried-index,\n"
                   + "nucleotide,\n" + "nucleotide-ambiguity,\n"
                   + "purine-pyrimidine,\n" + "rna-helices,\n"
-                  + "t-coffee-scores,\n" + "sequence-id.\n"
-                  +"\n"
+                  + "t-coffee-scores,\n" + "sequence-id.\n" + "\n"
                   + "Names of user defined colourschemes will also work,\n"
-                 +"and jalview colourscheme specifications like\n"
-                  +"--colour=\"D,E=red; K,R,H=0022FF; C,c=yellow\"",
+                  + "and jalview colourscheme specifications like\n"
+                  + "--colour=\"D,E=red; K,R,H=0022FF; C,c=yellow\"",
           Opt.STRING, Opt.LINKED, Opt.ALLOWALL),
   FEATURES(Type.OPENING, "Add a feature file or URL to the open alignment.",
           Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS),
@@ -200,7 +199,7 @@ public enum Arg
                   + "clustal (aln),\n" + "phylip (phy),\n"
                   + "jalview (jvp, jar).",
           Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS, Opt.ALLOWALL,
-          Opt.REQUIREINPUT, Opt.OUTPUTFILE, Opt.PRIMARY),
+          Opt.REQUIREINPUT, Opt.OUTPUTFILE, Opt.STDOUT, Opt.PRIMARY),
   FORMAT(Type.OUTPUT,
           "Sets the format for the preceding --output file. Valid formats are:\n"
                   + "fasta,\n" + "pfam,\n" + "stockholm,\n" + "pir,\n"
@@ -384,6 +383,11 @@ public enum Arg
      */
     OUTPUTFILE("output file --headless will be assumed unless --gui used"),
     /*
+     * A STDOUT Arg can take an output filename that can be '-' to mean print to STDOUT.
+     */
+    STDOUT("allows the output filename '" + ArgParser.STDOUTFILENAME
+            + "' to mean output to STDOUT"),
+    /*
      * A STORED Arg resets and creates a new set of "opened" linkedIds
      */
     STORED(null),
index 907b1fa..3862375 100644 (file)
@@ -50,6 +50,8 @@ public class ArgParser
 
   public static final char EQUALS = '=';
 
+  public static final String STDOUTFILENAME = "-";
+
   protected static final String NEGATESTRING = "no";
 
   /**
@@ -209,12 +211,15 @@ public class ArgParser
   public ArgParser(String[] args, boolean initsubstitutions,
           BootstrapArgs bsa)
   {
-    // Make a mutable new ArrayList so that shell globbing parser works.
-    // (When shell file globbing is used, there are a sequence of non-Arg
-    // arguments (which are the expanded globbed filenames) that need to be
-    // consumed by the --append/--argfile/etc Arg which is most easily done by
-    // removing these filenames from the list one at a time. This can't be done
-    // with an ArrayList made with only Arrays.asList(String[] args). )
+    /*
+     *  Make a mutable new ArrayList so that shell globbing parser works.
+     * (When shell file globbing is used, there are a sequence of non-Arg
+     * arguments (which are the expanded globbed filenames) that need to be
+     * consumed by the --append/--argfile/etc Arg which is most easily done
+     * by removing these filenames from the list one at a time. This can't be
+     * done with an ArrayList made with only Arrays.asList(String[] args) as
+     * that is not mutable. )
+     */
     this(new ArrayList<>(Arrays.asList(args)), initsubstitutions, false,
             bsa);
   }
@@ -260,27 +265,30 @@ public class ArgParser
           boolean allowPrivate)
   {
     this.substitutions = initsubstitutions;
-    boolean openEachInitialFilenames = true;
-    for (int i = 0; i < args.size(); i++)
-    {
-      String arg = args.get(i);
 
-      // If the first arguments do not start with "--" or "-" or is not "open"
-      // and` is a filename that exists it is probably a file/list of files to
-      // open so we fake an Arg.OPEN argument and when adding files only add the
-      // single arg[i] and increment the defaultLinkedIdCounter so that each of
-      // these files is opened separately.
-      if (openEachInitialFilenames && !arg.startsWith(DOUBLEDASH)
-              && !arg.startsWith("-") && !arg.equals("open")
-              && (new File(arg).exists()
-                      || HttpUtils.startsWithHttpOrHttps(arg)))
-      {
-        arg = Arg.OPEN.argString();
-      }
-      else
+    /*
+     *  If the first argument does not start with "--" or "-" or is not "open",
+     *  and is a filename that exists or a URL, it is probably a file/list of
+     *  files to open so we insert an Arg.OPEN argument before it. This will
+     *  mean the list of files at the start of the arguments are all opened
+     *  separately.
+     */
+    if (args.size() > 0)
+    {
+      String arg0 = args.get(0);
+      if (arg0 != null
+              && (!arg0.startsWith(DOUBLEDASH) && !arg0.startsWith("-")
+                      && !arg0.equals("open") && (new File(arg0).exists()
+                              || HttpUtils.startsWithHttpOrHttps(arg0))))
       {
-        openEachInitialFilenames = false;
+        // insert "--open" at the start
+        args.add(0, Arg.OPEN.argString());
       }
+    }
+
+    for (int i = 0; i < args.size(); i++)
+    {
+      String arg = args.get(i);
 
       // look for double-dash, e.g. --arg
       if (arg.startsWith(DOUBLEDASH))
@@ -431,7 +439,7 @@ public class ArgParser
           {
             // There is no "=" so value is next arg or args (possibly shell
             // glob-expanded)
-            if ((openEachInitialFilenames ? i : i + 1) >= args.size())
+            if (i + 1 >= args.size())
             {
               // no value to take for arg, which wants a value
               Console.error("Argument '" + a.getName()
@@ -446,8 +454,7 @@ public class ArgParser
             {
               // if this is the first argument with a file list at the start of
               // the args we add filenames from index i instead of i+1
-              globVals = getShellGlobbedFilenameValues(a, args,
-                      openEachInitialFilenames ? i : i + 1);
+              globVals = getShellGlobbedFilenameValues(a, args, i + 1);
             }
             else
             {
index 4b7b180..ec62bcd 100644 (file)
@@ -28,6 +28,8 @@ public class BootstrapArgs
 
   private Set<Type> argsTypes = new HashSet<>();
 
+  private boolean outputToStdout = false;
+
   public static BootstrapArgs getBootstrapArgs(String[] args)
   {
     List<String> argList = new ArrayList<>(Arrays.asList(args));
@@ -53,7 +55,7 @@ public class BootstrapArgs
     {
       if (argFiles.contains(inArgFile))
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Looped argfiles detected: '" + inArgFile.getPath() + "'");
         return;
       }
@@ -127,11 +129,6 @@ public class BootstrapArgs
           }
         }
 
-        if (ArgParser.argMap.containsKey(argName) && val == null)
-        {
-          val = "true";
-        }
-
         Arg a = ArgParser.argMap.get(argName);
 
         if (a != null)
@@ -152,7 +149,27 @@ public class BootstrapArgs
 
         if (a == null || !a.hasOption(Opt.BOOTSTRAP))
         {
-          // not a valid bootstrap arg
+          // not a bootstrap arg
+
+          // make a check for an output going to stdout
+          if (a != null && a.hasOption(Opt.OUTPUTFILE)
+                  && a.hasOption(Opt.STDOUT))
+          {
+            if (val == null && i + 1 < args.size())
+            {
+              val = args.get(i + 1);
+            }
+            if (val.startsWith("[") && val.indexOf(']') > 0)
+            {
+              val = val.substring(val.indexOf(']') + 1);
+            }
+
+            if (ArgParser.STDOUTFILENAME.equals(val))
+            {
+              this.outputToStdout = true;
+            }
+          }
+
           continue;
         }
 
@@ -188,6 +205,11 @@ public class BootstrapArgs
         }
         else
         {
+          if (val == null)
+          {
+            val = "true";
+          }
+
           add(a, type, val);
         }
       }
@@ -362,7 +384,7 @@ public class BootstrapArgs
     }
     else if (this.contains(Arg.HEADLESS))
     {
-      // --headless, --noheadless specified => use value
+      // --headless has been specified on the command line => headless
       isHeadless = this.getBoolean(Arg.HEADLESS);
     }
     else if (this.argsHaveOption(Opt.OUTPUTFILE))
@@ -373,4 +395,9 @@ public class BootstrapArgs
     }
     return isHeadless;
   }
+
+  public boolean outputToStdout()
+  {
+    return this.outputToStdout;
+  }
 }
index 62ef660..c15bbf8 100644 (file)
@@ -473,7 +473,7 @@ public class EditCommand implements CommandI
     {
       command.seqs[s].insertCharAt(command.position, command.number,
               command.gapChar);
-      // System.out.println("pos: "+command.position+" number:
+      // jalview.bin.Console.outPrintln("pos: "+command.position+" number:
       // "+command.number);
     }
 
@@ -486,7 +486,7 @@ public class EditCommand implements CommandI
   //
   // for (int s = 0; s < command.seqs.length; s++)
   // {
-  // System.out.println("pos: "+command.position+" number: "+command.number);
+  // jalview.bin.Console.outPrintln("pos: "+command.position+" number: "+command.number);
   // command.seqs[s].insertCharAt(command.position, command.number,'A');
   // }
   //
@@ -1433,7 +1433,7 @@ public class EditCommand implements CommandI
           }
           else
           {
-            System.err.println("Can't undo edit action " + action);
+            jalview.bin.Console.errPrintln("Can't undo edit action " + action);
             // throw new IllegalStateException("Can't undo edit action " +
             // action);
           }
index f5154ec..cb74a66 100644 (file)
@@ -707,7 +707,7 @@ public class AlignedCodonFrame
             ds.setSequenceFeatures(dna.getSequenceFeatures());
             // dnaSeqs[i] = ds;
             ssm.fromSeq = ds;
-            System.out.println("Realised mapped sequence " + ds.getName());
+            jalview.bin.Console.outPrintln("Realised mapped sequence " + ds.getName());
           }
         }
       }
index de98c64..7e6b904 100755 (executable)
@@ -126,7 +126,7 @@ public class AlignmentAnnotation
       invalidrnastruc = -1;
     } catch (WUSSParseException px)
     {
-      // DEBUG System.out.println(px);
+      // DEBUG jalview.bin.Console.outPrintln(px);
       invalidrnastruc = px.getProblemPos();
     }
     if (invalidrnastruc > -1)
@@ -142,7 +142,7 @@ public class AlignmentAnnotation
       scaleColLabel = true;
       _markRnaHelices();
     }
-    // System.out.println("featuregroup " + _rnasecstr[0].getFeatureGroup());
+    // jalview.bin.Console.outPrintln("featuregroup " + _rnasecstr[0].getFeatureGroup());
 
   }
 
@@ -156,10 +156,10 @@ public class AlignmentAnnotation
     {
 
       /*
-       * System.out.println(this.annotation._rnasecstr[x] + " Begin" +
+       * jalview.bin.Console.outPrintln(this.annotation._rnasecstr[x] + " Begin" +
        * this.annotation._rnasecstr[x].getBegin());
        */
-      // System.out.println(this.annotation._rnasecstr[x].getFeatureGroup());
+      // jalview.bin.Console.outPrintln(this.annotation._rnasecstr[x].getFeatureGroup());
       int val = 0;
       try
       {
@@ -386,7 +386,7 @@ public class AlignmentAnnotation
     char firstChar = 0;
     for (int i = 0; i < annotations.length; i++)
     {
-      // DEBUG System.out.println(i + ": " + annotations[i]);
+      // DEBUG jalview.bin.Console.outPrintln(i + ": " + annotations[i]);
       if (annotations[i] == null)
       {
         continue;
@@ -394,14 +394,14 @@ public class AlignmentAnnotation
       if (annotations[i].secondaryStructure == 'H'
               || annotations[i].secondaryStructure == 'E')
       {
-        // DEBUG System.out.println( "/H|E/ '" +
+        // DEBUG jalview.bin.Console.outPrintln( "/H|E/ '" +
         // annotations[i].secondaryStructure + "'");
         hasIcons |= true;
       }
       else
       // Check for RNA secondary structure
       {
-        // DEBUG System.out.println( "/else/ '" +
+        // DEBUG jalview.bin.Console.outPrintln( "/else/ '" +
         // annotations[i].secondaryStructure + "'");
         // TODO: 2.8.2 should this ss symbol validation check be a function in
         // RNA/ResidueProperties ?
@@ -446,7 +446,7 @@ public class AlignmentAnnotation
         }
       }
 
-      // System.out.println("displaychar " + annotations[i].displayCharacter);
+      // jalview.bin.Console.outPrintln("displaychar " + annotations[i].displayCharacter);
 
       if (annotations[i].displayCharacter == null
               || annotations[i].displayCharacter.length() == 0)
index e6604d1..6ab71c7 100644 (file)
@@ -1128,11 +1128,11 @@ public class AlignmentView
   public static void testSelectionViews(AlignmentI alignment,
           HiddenColumns hidden, SequenceGroup selection)
   {
-    System.out.println("Testing standard view creation:\n");
+    jalview.bin.Console.outPrintln("Testing standard view creation:\n");
     AlignmentView view = null;
     try
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "View with no hidden columns, no limit to selection, no groups to be collected:");
       view = new AlignmentView(alignment, hidden, selection, false, false,
               false);
@@ -1141,12 +1141,12 @@ public class AlignmentView
     } catch (Exception e)
     {
       e.printStackTrace();
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Failed to generate alignment with selection but no groups marked.");
     }
     try
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "View with no hidden columns, no limit to selection, and all groups to be collected:");
       view = new AlignmentView(alignment, hidden, selection, false, false,
               true);
@@ -1154,12 +1154,12 @@ public class AlignmentView
     } catch (Exception e)
     {
       e.printStackTrace();
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Failed to generate alignment with selection marked but no groups marked.");
     }
     try
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "View with no hidden columns, limited to selection and no groups to be collected:");
       view = new AlignmentView(alignment, hidden, selection, false, true,
               false);
@@ -1167,12 +1167,12 @@ public class AlignmentView
     } catch (Exception e)
     {
       e.printStackTrace();
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Failed to generate alignment with selection restricted but no groups marked.");
     }
     try
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "View with no hidden columns, limited to selection, and all groups to be collected:");
       view = new AlignmentView(alignment, hidden, selection, false, true,
               true);
@@ -1180,12 +1180,12 @@ public class AlignmentView
     } catch (Exception e)
     {
       e.printStackTrace();
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Failed to generate alignment with selection restricted and groups marked.");
     }
     try
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "View *with* hidden columns, no limit to selection, no groups to be collected:");
       view = new AlignmentView(alignment, hidden, selection, true, false,
               false);
@@ -1193,12 +1193,12 @@ public class AlignmentView
     } catch (Exception e)
     {
       e.printStackTrace();
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Failed to generate alignment with selection but no groups marked.");
     }
     try
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "View *with* hidden columns, no limit to selection, and all groups to be collected:");
       view = new AlignmentView(alignment, hidden, selection, true, false,
               true);
@@ -1206,12 +1206,12 @@ public class AlignmentView
     } catch (Exception e)
     {
       e.printStackTrace();
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Failed to generate alignment with selection marked but no groups marked.");
     }
     try
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "View *with* hidden columns, limited to selection and no groups to be collected:");
       view = new AlignmentView(alignment, hidden, selection, true, true,
               false);
@@ -1219,12 +1219,12 @@ public class AlignmentView
     } catch (Exception e)
     {
       e.printStackTrace();
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Failed to generate alignment with selection restricted but no groups marked.");
     }
     try
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "View *with* hidden columns, limited to selection, and all groups to be collected:");
       view = new AlignmentView(alignment, hidden, selection, true, true,
               true);
@@ -1232,7 +1232,7 @@ public class AlignmentView
     } catch (Exception e)
     {
       e.printStackTrace();
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Failed to generate alignment with selection restricted and groups marked.");
     }
 
index 69dcf71..bb31c5d 100644 (file)
@@ -55,9 +55,9 @@ public class ContactListImpl implements ContactListI
     {
       from_column = 0;
     }
-    if (to_column > getContactHeight())
+    if (to_column >= getContactHeight())
     {
-      to_column = getContactHeight();
+      to_column = getContactHeight()-1;
     }
     ContactRange cr = new ContactRange();
     cr.setFrom_column(from_column);
index 1d20987..925025f 100644 (file)
@@ -5,6 +5,9 @@ import java.util.Arrays;
 import java.util.BitSet;
 import java.util.List;
 
+import jalview.util.ColorUtils;
+import jalview.ws.datamodel.MappableContactMatrixI;
+
 public interface ContactMatrixI
 {
 
@@ -122,4 +125,79 @@ public interface ContactMatrixI
   }
 
   void setGroupSet(GroupSet makeGroups);
+
+  default void randomlyReColourGroups() {
+    if (hasGroupSet())
+    {
+      GroupSetI groups = getGroupSet();
+      for (BitSet group:groups.getGroups())
+      {
+        groups.setColorForGroup(group, ColorUtils.getARandomColor());
+      }
+    }
+  }
+
+  default void transferGroupColorsTo(AlignmentAnnotation aa)
+  {
+    if (hasGroupSet())
+    {
+      GroupSetI groups = getGroupSet();
+      // stash colors in linked annotation row.
+      // doesn't work yet. TESTS!
+      int sstart = aa.sequenceRef != null ? aa.sequenceRef.getStart() - 1
+              : 0;
+      Annotation ae;
+      Color gpcol = null;
+      int[] seqpos = null;
+      for (BitSet gp : groups.getGroups())
+      {
+        gpcol = groups.getColourForGroup(gp);
+        for (int p = gp.nextSetBit(0); p >= 0
+                && p < Integer.MAX_VALUE; p = gp.nextSetBit(p + 1))
+        {
+          if (this instanceof MappableContactMatrixI)
+          {
+            MappableContactMatrixI mcm = (MappableContactMatrixI) this;
+            seqpos = mcm.getMappedPositionsFor(aa.sequenceRef, p);
+            if (seqpos == null)
+            {
+              // no mapping for this column.
+              continue;
+            }
+            // TODO: handle ranges...
+            ae = aa.getAnnotationForPosition(seqpos[0]);
+          }
+          else
+          {
+            ae = aa.getAnnotationForPosition(p + sstart);
+          }
+          if (ae != null)
+          {
+            ae.colour = gpcol.brighter().darker();
+          }
+        }
+      }
+    }
+  }
+  
+  /**
+   * look up the colour for a column in the associated contact matrix 
+   * @return Color.white or assigned colour
+   */
+  default Color getGroupColorForPosition(int column)
+  {
+    if (hasGroupSet())
+    {
+      GroupSetI groups = getGroupSet();
+      for (BitSet gp:groups.getGroups())
+      {
+        if (gp.get(column))
+        {
+          return groups.getColourForGroup(gp);
+        }
+      }
+    }
+    return Color.white;
+  }
+  
 }
index f384b1e..3b1757b 100755 (executable)
@@ -154,6 +154,11 @@ public class DBRefSource
 
   public static boolean isPrimaryCandidate(String ucversion)
   {
+    if (ucversion==null)
+    {
+      // Null/empty version is not a real reference ?
+      return false;
+    }
     // tricky - this test really needs to search the sequence's set of dbrefs to
     // see if there is a primary reference that derived this reference.
     for (int i = allSources.length; --i >= 0;)
index c7a73b7..db38e7b 100644 (file)
@@ -145,30 +145,59 @@ public class GroupSet implements GroupSetI
     return treeType;
   }
 
-  public static GroupSet makeGroups(ContactMatrixI matrix, float thresh,
+  public static GroupSet makeGroups(ContactMatrixI matrix, boolean autoCut)
+  {
+    return makeGroups(matrix, autoCut, 0, autoCut);
+  }
+  public static GroupSet makeGroups(ContactMatrixI matrix, boolean auto, float thresh,
           boolean abs)
   {
     AverageDistanceEngine clusterer = new AverageDistanceEngine(null, null,
-            matrix);
+            matrix, true);
     double height = clusterer.findHeight(clusterer.getTopNode());
+    Console.debug("Column tree height: " + height);
     String newick = new jalview.io.NewickFile(clusterer.getTopNode(), false,
             true).print();
     String treeType = "UPGMA";
     Console.trace("Newick string\n" + newick);
 
     List<BinaryNode> nodegroups;
-    if (abs ? height > thresh : 0 < thresh && thresh < 1)
+    float cut = -1f;
+    if (auto)
     {
-      float cut = abs ? (float) (thresh / height) : thresh;
-      Console.debug("Threshold " + cut + " for height=" + height);
-
-      nodegroups = clusterer.groupNodes(cut);
+      double rootw = 0;
+      int p = 2;
+      BinaryNode bn = clusterer.getTopNode();
+      while (p-- > 0 & bn.left() != null)
+      {
+        if (bn.left() != null)
+        {
+          bn = bn.left();
+        }
+        if (bn.left() != null)
+        {
+          rootw = bn.height;
+        }
+      }
+      thresh = Math.max((float) (rootw / height) - 0.01f, 0);
+      cut = thresh;
+      nodegroups = clusterer.groupNodes(thresh);
     }
     else
     {
-      nodegroups = new ArrayList<BinaryNode>();
-      nodegroups.add(clusterer.getTopNode());
+      if (abs ? (height > thresh) : (0 < thresh && thresh < 1))
+      {
+        cut = abs ? thresh : (float) (thresh * height);
+        Console.debug("Threshold " + cut + " for height=" + height);
+        nodegroups = clusterer.groupNodes(cut);
+      }
+      else
+      {
+        nodegroups = new ArrayList<BinaryNode>();
+        nodegroups.add(clusterer.getTopNode());
+      }
     }
+    
     List<BitSet> groups = new ArrayList<>();
     for (BinaryNode root : nodegroups)
     {
@@ -179,7 +208,8 @@ public class GroupSet implements GroupSetI
       }
       groups.add(gpset);
     }
-    GroupSet grps = new GroupSet(abs, thresh, groups, treeType, newick);
+    GroupSet grps = new GroupSet(abs, (cut == -1f) ? thresh : cut, groups,
+            treeType, newick);
     return grps;
   }
 
index b5efeb4..e2ef318 100755 (executable)
@@ -159,7 +159,7 @@ public class HiddenSequences
 
     if (alignmentIndex < 0 || hiddenSequences[alignmentIndex] != null)
     {
-      System.out.println("ERROR!!!!!!!!!!!");
+      jalview.bin.Console.outPrintln("ERROR!!!!!!!!!!!");
       return;
     }
 
@@ -239,7 +239,7 @@ public class HiddenSequences
           }
           else
           {
-            System.out.println(
+            jalview.bin.Console.outPrintln(
                     seq.getName() + " has been deleted whilst hidden");
           }
         }
index 909a0fe..8d6cbb1 100755 (executable)
@@ -269,7 +269,7 @@ public class SearchResults implements SearchResultsI
         else
         {
           // debug
-          // System.err.println("Outwith bounds!" + matchStart+">"+end +" or "
+          // jalview.bin.Console.errPrintln("Outwith bounds!" + matchStart+">"+end +" or "
           // + matchEnd+"<"+start);
         }
       }
index 32d295a..7a5d5bc 100755 (executable)
@@ -174,7 +174,7 @@ public class Sequence extends ASequence implements SequenceI
   {
     if (name == null)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "POSSIBLE IMPLEMENTATION ERROR: null sequence name passed to constructor.");
       name = "";
     }
@@ -387,7 +387,7 @@ public class Sequence extends ASequence implements SequenceI
   {
     if (sf.getType() == null)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "SequenceFeature type may not be null: " + sf.toString());
       return false;
     }
@@ -1754,6 +1754,13 @@ public class Sequence extends ASequence implements SequenceI
       transferAnnotation(entry.getDatasetSequence(), mp);
       return;
     }
+    // transfer from entry to sequence
+    // if entry has a description and sequence doesn't, then transfer
+    if (entry.getDescription()!=null && (description==null || description.trim().length()==0))
+    {
+      description = entry.getDescription();
+    }
+    
     // transfer any new features from entry onto sequence
     if (entry.getSequenceFeatures() != null)
     {
index 326793d..9837104 100755 (executable)
@@ -644,7 +644,7 @@ public class SequenceGroup implements AnnotatedCollectionI
     } catch (java.lang.OutOfMemoryError err)
     {
       // TODO: catch OOM
-      System.out.println("Out of memory loading groups: " + err);
+      jalview.bin.Console.outPrintln("Out of memory loading groups: " + err);
     }
     return upd;
   }
index 65cba0d..124909c 100644 (file)
@@ -147,7 +147,7 @@ public class FeatureMatcher implements FeatureMatcherI
       int nextQuotePos = descriptor.indexOf(QUOTE, 1);
       if (nextQuotePos == -1)
       {
-        System.err.println(invalidFormat);
+        jalview.bin.Console.errPrintln(invalidFormat);
         return null;
       }
       firstField = descriptor.substring(1, nextQuotePos);
@@ -159,7 +159,7 @@ public class FeatureMatcher implements FeatureMatcherI
       int nextSpacePos = descriptor.indexOf(SPACE);
       if (nextSpacePos == -1)
       {
-        System.err.println(invalidFormat);
+        jalview.bin.Console.errPrintln(invalidFormat);
         return null;
       }
       firstField = descriptor.substring(0, nextSpacePos);
@@ -193,7 +193,7 @@ public class FeatureMatcher implements FeatureMatcherI
       cond = Condition.fromString(leftToParse);
       if (cond == null || cond.needsAPattern())
       {
-        System.err.println(invalidFormat);
+        jalview.bin.Console.errPrintln(invalidFormat);
         return null;
       }
     }
@@ -214,7 +214,7 @@ public class FeatureMatcher implements FeatureMatcherI
         else
         {
           // unbalanced quote
-          System.err.println(invalidFormat);
+          jalview.bin.Console.errPrintln(invalidFormat);
           return null;
         }
       }
index a5efe5d..eae3664 100644 (file)
@@ -93,7 +93,7 @@ public class FeatureMatcherSet implements FeatureMatcherSetI
         if (spacePos == -1)
         {
           // trailing junk after a match condition
-          System.err.println(invalid);
+          jalview.bin.Console.errPrintln(invalid);
           return null;
         }
         String conjunction = leftToParse.substring(0, spacePos);
@@ -109,7 +109,7 @@ public class FeatureMatcherSet implements FeatureMatcherSetI
         else
         {
           // not an AND or an OR - invalid
-          System.err.println(invalid);
+          jalview.bin.Console.errPrintln(invalid);
           return null;
         }
       }
@@ -123,7 +123,7 @@ public class FeatureMatcherSet implements FeatureMatcherSetI
         int closePos = leftToParse.indexOf(CLOSE_BRACKET);
         if (closePos == -1)
         {
-          System.err.println(invalid);
+          jalview.bin.Console.errPrintln(invalid);
           return null;
         }
         nextCondition = leftToParse.substring(1, closePos);
@@ -137,7 +137,7 @@ public class FeatureMatcherSet implements FeatureMatcherSetI
       FeatureMatcher fm = FeatureMatcher.fromString(nextCondition);
       if (fm == null)
       {
-        System.err.println(invalid);
+        jalview.bin.Console.errPrintln(invalid);
         return null;
       }
       try
@@ -154,7 +154,7 @@ public class FeatureMatcherSet implements FeatureMatcherSetI
       } catch (IllegalStateException e)
       {
         // thrown if OR and AND are mixed
-        System.err.println(invalid);
+        jalview.bin.Console.errPrintln(invalid);
         return null;
       }
 
index eb5688c..c19d782 100644 (file)
@@ -401,7 +401,7 @@ public class FeatureStore
       SequenceFeature sf = contactFeatureEnds.get(index);
       if (!sf.isContactFeature())
       {
-        System.err.println("Error! non-contact feature type " + sf.getType()
+        jalview.bin.Console.errPrintln("Error! non-contact feature type " + sf.getType()
                 + " in contact features list");
         index++;
         continue;
@@ -454,7 +454,7 @@ public class FeatureStore
       SequenceFeature sf = contactFeatureStarts.get(index);
       if (!sf.isContactFeature())
       {
-        System.err.println("Error! non-contact feature " + sf.toString()
+        jalview.bin.Console.errPrintln("Error! non-contact feature " + sf.toString()
                 + " in contact features list");
         index++;
         continue;
index 905fd8b..ed4474e 100644 (file)
@@ -88,7 +88,7 @@ public class SequenceFeatures implements SequenceFeaturesI
     String type = sf.getType();
     if (type == null)
     {
-      System.err.println("Feature type may not be null: " + sf.toString());
+      jalview.bin.Console.errPrintln("Feature type may not be null: " + sf.toString());
       return false;
     }
 
index 75a7154..391fd6f 100644 (file)
@@ -226,7 +226,7 @@ public class EnsemblGene extends EnsemblSeqProxy
         return true;
       } catch (NumberFormatException e)
       {
-        System.err.println("Bad integers in description " + description);
+        jalview.bin.Console.errPrintln("Bad integers in description " + description);
       }
     }
     return false;
index 0813ba8..e188986 100644 (file)
@@ -222,7 +222,7 @@ public class EnsemblLookup extends EnsemblRestClient
               ids, -1, MODE_MAP, null);
     } catch (IOException | ParseException e)
     {
-      System.err.println("Error parsing " + identifier + " lookup response "
+      jalview.bin.Console.errPrintln("Error parsing " + identifier + " lookup response "
               + e.getMessage());
       return null;
     }
index f2ab195..1fd9a23 100644 (file)
@@ -157,7 +157,7 @@ public class EnsemblMap extends EnsemblRestClient
       return (parseAssemblyMappingResponse(url));
     } catch (Throwable t)
     {
-      System.out.println("Error calling " + url + ": " + t.getMessage());
+      jalview.bin.Console.outPrintln("Error calling " + url + ": " + t.getMessage());
       return null;
     }
   }
@@ -265,7 +265,7 @@ public class EnsemblMap extends EnsemblRestClient
       return null;
     } catch (Throwable t)
     {
-      System.out.println("Error calling " + url + ": " + t.getMessage());
+      jalview.bin.Console.outPrintln("Error calling " + url + ": " + t.getMessage());
       return null;
     }
   }
@@ -342,7 +342,7 @@ public class EnsemblMap extends EnsemblRestClient
         String ass = mapped.get("assembly_name").toString();
         if (assembly != null && !assembly.equals(ass))
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "EnsemblMap found multiple assemblies - can't resolve");
           return null;
         }
@@ -350,7 +350,7 @@ public class EnsemblMap extends EnsemblRestClient
         String chr = mapped.get("seq_region_name").toString();
         if (chromosome != null && !chromosome.equals(chr))
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "EnsemblMap found multiple chromosomes - can't resolve");
           return null;
         }
index 4a5544e..540fc98 100644 (file)
@@ -211,7 +211,7 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher
       return pingString != null;
     } catch (Throwable t)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Error connecting to " + pingUrl + ": " + t.getMessage());
     } finally
     {
@@ -313,7 +313,7 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher
        * note: a GET request for an invalid id returns an error code e.g. 415
        * but POST request returns 200 and an empty Fasta response 
        */
-      System.err.println("Response code " + responseCode);// + " for " + url);
+      jalview.bin.Console.errPrintln("Response code " + responseCode);// + " for " + url);
       return null;
     }
 
@@ -338,7 +338,7 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher
   protected HttpURLConnection tryConnection(URL url, List<String> ids,
           int readTimeout) throws IOException, ProtocolException
   {
-    // System.out.println(System.currentTimeMillis() + " " + url);
+    // jalview.bin.Console.outPrintln(System.currentTimeMillis() + " " + url);
 
     HttpURLConnection connection = (HttpURLConnection) url.openConnection();
 
@@ -387,14 +387,14 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher
         int retrySecs = Integer.valueOf(retryDelay);
         if (retrySecs > 0 && retrySecs < 10)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Ensembl REST service rate limit exceeded, waiting "
                           + retryDelay + " seconds before retrying");
           Thread.sleep(1000 * retrySecs);
         }
       } catch (NumberFormatException | InterruptedException e)
       {
-        System.err.println("Error handling Retry-After: " + e.getMessage());
+        jalview.bin.Console.errPrintln("Error handling Retry-After: " + e.getMessage());
       }
     }
   }
@@ -566,7 +566,7 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher
         }
       } catch (NumberFormatException e)
       {
-        System.err.println("Error in REST version: " + e.toString());
+        jalview.bin.Console.errPrintln("Error in REST version: " + e.toString());
       }
 
       /*
@@ -578,14 +578,14 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher
               expected) == 1;
       if (laterVersion)
       {
-        System.err.println(String.format(
+        jalview.bin.Console.errPrintln(String.format(
                 "EnsemblRestClient expected %s REST version %s but found %s, see %s",
                 getDbSource(), expected, version, REST_CHANGE_LOG));
       }
       info.restVersion = version;
     } catch (Throwable t)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Error checking Ensembl REST version: " + t.getMessage());
     }
   }
@@ -617,7 +617,7 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher
       domainData.get(getDomain()).dataVersion = versions.get(0).toString();
     } catch (Throwable e)
     {// could be IOException | ParseException e) {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Error checking Ensembl data version: " + e.getMessage());
     }
   }
index 56eda5e..949c52e 100644 (file)
@@ -155,7 +155,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
         String msg = "Aborting ID retrieval after " + v
                 + " chunks. Unexpected problem (" + r.getLocalizedMessage()
                 + ")";
-        System.err.println(msg);
+        jalview.bin.Console.errPrintln(msg);
         r.printStackTrace();
         break;
       }
@@ -240,7 +240,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
       }
     } catch (IOException e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Error transferring Ensembl features: " + e.getMessage());
     }
     // Platform.timeCheck("ESP.addfeat done", Platform.TIME_MARK);
@@ -265,12 +265,12 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
     String accId = querySeq.getName();
     try
     {
-      System.out.println("Adding protein product for " + accId);
+      jalview.bin.Console.outPrintln("Adding protein product for " + accId);
       AlignmentI protein = new EnsemblProtein(getDomain())
               .getSequenceRecords(accId);
       if (protein == null || protein.getHeight() == 0)
       {
-        System.out.println("No protein product found for " + accId);
+        jalview.bin.Console.outPrintln("No protein product found for " + accId);
         return;
       }
       SequenceI proteinSeq = protein.getSequenceAt(0);
@@ -382,7 +382,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
       seq.addDBRef(xrefs.get(i));
     }
 
-    // System.out.println("primaries are " + seq.getPrimaryDBRefs().toString());
+    // jalview.bin.Console.outPrintln("primaries are " + seq.getPrimaryDBRefs().toString());
     /*
      * and add a reference to itself
      */
@@ -430,7 +430,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
 
     if (seqs.size() != ids.size())
     {
-      System.out.println(String.format(
+      jalview.bin.Console.outPrintln(String.format(
               "Only retrieved %d sequences for %d query strings",
               seqs.size(), ids.size()));
     }
@@ -508,7 +508,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
       result.add(sequence);
     } catch (ParseException | IOException e)
     {
-      System.err.println("Error processing JSON response: " + e.toString());
+      jalview.bin.Console.errPrintln("Error processing JSON response: " + e.toString());
       // ignore
     }
     // Platform.timeCheck("ENS seqproxy2", Platform.TIME_MARK);
@@ -659,7 +659,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
 
     if (regions.isEmpty())
     {
-      System.out.println("Failed to identify target sequence for " + accId
+      jalview.bin.Console.outPrintln("Failed to identify target sequence for " + accId
               + " from genomic features");
       return null;
     }
@@ -829,7 +829,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
 
     boolean result = transferFeatures(sfs, targetSequence, mapping,
             accessionId);
-    // System.out.println("transferFeatures (" + (sfs.size()) + " --> "
+    // jalview.bin.Console.outPrintln("transferFeatures (" + (sfs.size()) + " --> "
     // + targetSequence.getFeatures().getFeatureCount(true) + ") to "
     // + targetSequence.getName() + " took "
     // + (System.currentTimeMillis() - start) + "ms");
index 9a985b6..8cce87a 100644 (file)
@@ -261,7 +261,7 @@ public class HtsContigDb
   {
     if (!isValid() || !refFile.isIndexed())
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Cannot read contig as file is invalid or not indexed");
       return null;
     }
index 21a19ae..870db65 100644 (file)
@@ -163,21 +163,21 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
   public void createImage(String file, String type, int quality)
   {
-    System.out.println("JMOL CREATE IMAGE");
+    jalview.bin.Console.outPrintln("JMOL CREATE IMAGE");
   }
 
   @Override
   public String createImage(String fileName, String type,
           Object textOrBytes, int quality)
   {
-    System.out.println("JMOL CREATE IMAGE");
+    jalview.bin.Console.outPrintln("JMOL CREATE IMAGE");
     return null;
   }
 
   @Override
   public String eval(String strEval)
   {
-    // System.out.println(strEval);
+    // jalview.bin.Console.outPrintln(strEval);
     // "# 'eval' is implemented only for the applet.";
     return null;
   }
@@ -476,7 +476,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     lastMessage = strInfo;
     if (data != null)
     {
-      System.err.println("Ignoring additional hover info: " + data
+      jalview.bin.Console.errPrintln("Ignoring additional hover info: " + data
               + " (other info: '" + strInfo + "' pos " + atomIndex + ")");
     }
     mouseOverStructure(atomIndex, strInfo);
@@ -497,7 +497,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
      */
     if (strData != null)
     {
-      System.err.println("Ignoring additional pick data string " + strData);
+      jalview.bin.Console.errPrintln("Ignoring additional pick data string " + strData);
     }
     int chainSeparator = strInfo.indexOf(":");
     int p = 0;
@@ -599,7 +599,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
                 (data == null) ? ((String) null) : (String) data[1]);
         break;
       case ERROR:
-        // System.err.println("Ignoring error callback.");
+        // jalview.bin.Console.errPrintln("Ignoring error callback.");
         break;
       case SYNC:
       case RESIZE:
@@ -609,13 +609,13 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
       case CLICK:
       default:
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Unhandled callback " + type + " " + data[1].toString());
         break;
       }
     } catch (Exception e)
     {
-      System.err.println("Squashed Jmol callback handler error:");
+      jalview.bin.Console.errPrintln("Squashed Jmol callback handler error:");
       e.printStackTrace();
     }
   }
@@ -864,7 +864,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   public void setCallbackFunction(String callbackType,
           String callbackFunction)
   {
-    System.err.println("Ignoring set-callback request to associate "
+    jalview.bin.Console.errPrintln("Ignoring set-callback request to associate "
             + callbackType + " with function " + callbackFunction);
 
   }
@@ -938,7 +938,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
           String buttonsToShow)
   {
 
-    System.err.println("Allocating Jmol Viewer: " + commandOptions);
+    jalview.bin.Console.errPrintln("Allocating Jmol Viewer: " + commandOptions);
 
     if (commandOptions == null)
     {
@@ -956,7 +956,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
       console = createJmolConsole(consolePanel, buttonsToShow);
     } catch (Throwable e)
     {
-      System.err.println("Could not create Jmol application console. "
+      jalview.bin.Console.errPrintln("Could not create Jmol application console. "
               + e.getMessage());
       e.printStackTrace();
     }
index c64dac1..0ca2ba8 100644 (file)
@@ -338,7 +338,7 @@ public class JmolParser extends StructureFile implements JmolStatusListener
       }
     } catch (OutOfMemoryError er)
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "OUT OF MEMORY LOADING TRANSFORMING JMOL MODEL TO JALVIEW MODEL");
       throw new IOException(MessageManager
               .getString("exception.outofmemory_loading_mmcif_file"));
@@ -391,7 +391,7 @@ public class JmolParser extends StructureFile implements JmolStatusListener
           org.jmol.modelset.Atom prevAtom,
           HashMap<String, org.jmol.modelset.Atom> chainTerMap)
   {
-    // System.out.println("Atom: " + curAtom.getAtomNumber()
+    // jalview.bin.Console.outPrintln("Atom: " + curAtom.getAtomNumber()
     // + " Last atom index " + curAtom.group.lastAtomIndex);
     if (chainTerMap == null || prevAtom == null)
     {
@@ -488,7 +488,7 @@ public class JmolParser extends StructureFile implements JmolStatusListener
   {
     int length = sq.getLength();
     boolean ssFound = false;
-    Annotation asecstr[] = new Annotation[length + firstResNum - 1];
+    Annotation asecstr[] = new Annotation[length + (firstResNum-sq.getStart())];
     for (int p = 0; p < length; p++)
     {
       if (secstr[p] >= 'A' && secstr[p] <= 'z')
index de1d90c..3817ee9 100644 (file)
@@ -229,7 +229,7 @@ class RvalsIterator implements Iterator, AutoCloseable
 
     if (sval == null)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "DEVELOPER WARNING: Annotate3d didn't return a '2D' tag in its response. Consider checking output of server. Response was :"
                       + val.toString());
 
index 7dfdb0c..ddc8d84 100644 (file)
@@ -158,7 +158,7 @@ public class PymolManager
           boolean getReply)
   {
     String postBody = getPostRequest(command);
-    // System.out.println(postBody);// debug
+    // jalview.bin.Console.outPrintln(postBody);// debug
     String rpcUrl = "http://127.0.0.1:" + this.pymolXmlRpcPort;
     PrintWriter out = null;
     BufferedReader in = null;
index 40b0ff0..af31b78 100644 (file)
@@ -126,12 +126,12 @@ public class ChimeraListener extends AbstractRequestHandler
       }
       else if (message.startsWith(MODEL_CHANGED))
       {
-        System.err.println(message);
+        jalview.bin.Console.errPrintln(message);
         processModelChanged(message.substring(MODEL_CHANGED.length()));
       }
       else
       {
-        System.err.println("Unexpected chimeraNotification: " + message);
+        jalview.bin.Console.errPrintln("Unexpected chimeraNotification: " + message);
       }
     }
   }
@@ -143,7 +143,7 @@ public class ChimeraListener extends AbstractRequestHandler
    */
   protected void processModelChanged(String message)
   {
-    // System.out.println(message + " (not implemented in Jalview)");
+    // jalview.bin.Console.outPrintln(message + " (not implemented in Jalview)");
   }
 
   /**
index aebfede..a292e88 100644 (file)
@@ -207,7 +207,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
       startListening(chimeraListener.getUri());
     } catch (BindException e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Failed to start Chimera listener: " + e.getMessage());
     }
   }
@@ -568,7 +568,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
 
   private void log(String message)
   {
-    System.err.println("## Chimera log: " + message);
+    jalview.bin.Console.errPrintln("## Chimera log: " + message);
   }
 
   /**
@@ -627,7 +627,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
       executeCommand(false, null, command);
     } catch (IOException e)
     {
-      System.err.println("Sending commands to Chimera via file failed with "
+      jalview.bin.Console.errPrintln("Sending commands to Chimera via file failed with "
               + e.getMessage());
     }
   }
index 0971235..86b8c7d 100644 (file)
@@ -94,7 +94,7 @@ public class FTSDataColumnPreferences extends JScrollPane
     int x = 0;
     for (FTSDataColumnI field : allFTSDataColumns)
     {
-      // System.out.println("allFTSDataColumns==" + allFTSDataColumns);
+      // jalview.bin.Console.outPrintln("allFTSDataColumns==" + allFTSDataColumns);
       if (field.getName().equalsIgnoreCase("all"))
       {
         continue;
@@ -106,7 +106,7 @@ public class FTSDataColumnPreferences extends JScrollPane
         data[x++] = new Object[] { ftsRestClient
                 .getAllDefaultDisplayedFTSDataColumns().contains(field),
             field.getName(), field.getGroup() };
-        // System.out.println(" PUIS " + field.getName() + " ET AUSSI " +
+        // jalview.bin.Console.outPrintln(" PUIS " + field.getName() + " ET AUSSI " +
         // field.getGroup() + "X = " + x);
         break;
       case STRUCTURE_CHOOSER:
index 7e95dd2..a631902 100644 (file)
@@ -118,7 +118,7 @@ public class AlphafoldRestClient
           } catch (Exception e)
           {
             e.printStackTrace();
-            System.out.println("offending value:" + fieldData);
+            jalview.bin.Console.outPrintln("offending value:" + fieldData);
           }
         }
       }
index 796bc0e..5619075 100644 (file)
@@ -175,7 +175,7 @@ public class PDBFTSRestClient extends FTSRestClient
 
       URI uri = webResource.getURI();
 
-      System.out.println(uri);
+      jalview.bin.Console.outPrintln(uri);
       ClientResponse clientResponse = null;
       int responseStatus = -1;
       // Get the JSON string from the response object or directly from the
@@ -183,7 +183,7 @@ public class PDBFTSRestClient extends FTSRestClient
       Map<String, Object> jsonObj = null;
       String responseString = null;
 
-      System.out.println("query >>>>>>> " + pdbRestRequest.toString());
+      jalview.bin.Console.outPrintln("query >>>>>>> " + pdbRestRequest.toString());
 
       if (!isMocked())
       {
@@ -413,10 +413,10 @@ public class PDBFTSRestClient extends FTSRestClient
 
     for (FTSDataColumnI field : diplayFields)
     {
-      // System.out.println("Field " + field);
+      // jalview.bin.Console.outPrintln("Field " + field);
       String fieldData = (pdbJsonDoc.get(field.getCode()) == null) ? ""
               : pdbJsonDoc.get(field.getCode()).toString();
-      // System.out.println("Field Data : " + fieldData);
+      // jalview.bin.Console.outPrintln("Field Data : " + fieldData);
       if (field.isPrimaryKeyColumn())
       {
         primaryKey = fieldData;
@@ -440,7 +440,7 @@ public class PDBFTSRestClient extends FTSRestClient
         } catch (Exception e)
         {
           e.printStackTrace();
-          System.out.println("offending value:" + fieldData);
+          jalview.bin.Console.outPrintln("offending value:" + fieldData);
         }
       }
     }
index 253de42..dfb39cb 100644 (file)
@@ -277,7 +277,7 @@ public class TDBeaconsFTSPanel extends GFTSPanel
   @Override
   protected void showHelp()
   {
-    System.out.println("No help implemented yet.");
+    jalview.bin.Console.outPrintln("No help implemented yet.");
 
   }
 
index d7f534e..c275bda 100644 (file)
@@ -101,7 +101,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
       webResource = client.resource(DEFAULT_THREEDBEACONS_DOMAIN + query);
 
       URI uri = webResource.getURI();
-      System.out.println(uri.toString());
+      jalview.bin.Console.outPrintln(uri.toString());
 
       // Execute the REST request
       ClientResponse clientResponse;
@@ -269,7 +269,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
       String fieldData = (tdbJsonStructure.get(field.getCode()) == null)
               ? " "
               : tdbJsonStructure.get(field.getCode()).toString();
-      // System.out.println("Field : " + field + " Data : " + fieldData);
+      // jalview.bin.Console.outPrintln("Field : " + field + " Data : " + fieldData);
       if (field.isPrimaryKeyColumn())
       {
         primaryKey = fieldData;
@@ -293,7 +293,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
         } catch (Exception e)
         {
           // e.printStackTrace();
-          System.out.println("offending value:" + fieldData + fieldData);
+          jalview.bin.Console.outPrintln("offending value:" + fieldData + fieldData);
         }
       }
     }
index 1827293..df48c0d 100644 (file)
@@ -219,7 +219,7 @@ public class UniProtFTSRestClient extends FTSRestClient
               .getEntity(String.class);
       // Make redundant objects eligible for garbage collection to conserve
       // memory
-      // System.out.println(">>>>> response : "
+      // jalview.bin.Console.outPrintln(">>>>> response : "
       // + uniProtTabDelimittedResponseString);
       if (clientResponse.getStatus() != 200)
       {
@@ -307,7 +307,7 @@ public class UniProtFTSRestClient extends FTSRestClient
           firstRow = false;
           continue;
         }
-        // System.out.println(dataRow);
+        // jalview.bin.Console.outPrintln(dataRow);
         result.add(getFTSData(dataRow, uniprotRestRequest));
       }
       searchResult.setNumberOfItemsFound(xTotalResults);
@@ -389,7 +389,7 @@ public class UniProtFTSRestClient extends FTSRestClient
           } catch (Exception e)
           {
             e.printStackTrace();
-            System.out.println("offending value:" + fieldData);
+            jalview.bin.Console.outPrintln("offending value:" + fieldData);
           }
         }
       } catch (Exception e)
index ab705c2..217175e 100644 (file)
@@ -49,6 +49,7 @@ import java.beans.PropertyChangeEvent;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.net.URL;
 import java.util.ArrayList;
@@ -157,7 +158,6 @@ import jalview.viewmodel.AlignmentViewport;
 import jalview.viewmodel.ViewportRanges;
 import jalview.ws.DBRefFetcher;
 import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
-import jalview.ws.datamodel.alphafold.PAEContactMatrix;
 import jalview.ws.jws1.Discoverer;
 import jalview.ws.jws2.Jws2Discoverer;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
@@ -624,12 +624,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         // if (viewport.cursorMode)
         // {
         // alignPanel.seqPanel.insertNucAtCursor(false,"A");
-        // //System.out.println("A");
+        // //jalview.bin.Console.outPrintln("A");
         // }
         // break;
         /*
          * case KeyEvent.VK_CLOSE_BRACKET: if (viewport.cursorMode) {
-         * System.out.println("closing bracket"); } break;
+         * jalview.bin.Console.outPrintln("closing bracket"); } break;
          */
         case KeyEvent.VK_DELETE:
         case KeyEvent.VK_BACK_SPACE:
@@ -830,7 +830,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               @Override
               public void propertyChange(PropertyChangeEvent evt)
               {
-                // // System.out.println("Discoverer property change.");
+                // // jalview.bin.Console.outPrintln("Discoverer property
+                // change.");
                 // if (evt.getPropertyName().equals("services"))
                 {
                   SwingUtilities.invokeLater(new Runnable()
@@ -839,7 +840,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                     @Override
                     public void run()
                     {
-                      System.err.println(
+                      jalview.bin.Console.errPrintln(
                               "Rebuild WS Menu for service change");
                       BuildWebServiceMenu();
                     }
@@ -854,7 +855,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       public void internalFrameClosed(
               javax.swing.event.InternalFrameEvent evt)
       {
-        // System.out.println("deregistering discoverer listener");
+        // jalview.bin.Console.outPrintln("deregistering discoverer listener");
         Desktop.instance.removeJalviewPropertyChangeListener("services",
                 thisListener);
         closeMenuItem_actionPerformed(true);
@@ -1251,8 +1252,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   public void saveAlignment(String file, FileFormatI format)
   {
+    saveAlignment(file, format, false);
+  }
+
+  public void saveAlignment(String file, FileFormatI format, boolean stdout)
+  {
     lastSaveSuccessful = true;
-    lastFilenameSaved = file;
+    if (!stdout)
+    {
+      lastFilenameSaved = file;
+    }
     lastFormatSaved = format;
 
     if (FileFormat.Jalview.equals(format))
@@ -1263,6 +1272,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         shortName = shortName
                 .substring(shortName.lastIndexOf(File.separatorChar) + 1);
       }
+      // TODO deal with stdout=true
       lastSaveSuccessful = new Jalview2XML().saveAlignment(this, file,
               shortName);
 
@@ -1298,7 +1308,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       else
       {
         // create backupfiles object and get new temp filename destination
-        boolean doBackup = BackupFiles.getEnabled();
+        boolean doBackup = BackupFiles.getEnabled() && !stdout;
         BackupFiles backupfiles = null;
         if (doBackup)
         {
@@ -1310,7 +1320,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           String tempFilePath = doBackup ? backupfiles.getTempFilePath()
                   : file;
           Console.trace("ALIGNFRAME setting PrintWriter");
-          PrintWriter out = new PrintWriter(new FileWriter(tempFilePath));
+          PrintWriter out = stdout
+                  ? new PrintWriter(new OutputStreamWriter(System.out))
+                  : new PrintWriter(new FileWriter(tempFilePath));
 
           if (backupfiles != null)
           {
@@ -1319,13 +1331,28 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           }
 
           out.print(output);
-          Console.trace("ALIGNFRAME about to close file");
-          out.close();
-          Console.trace("ALIGNFRAME closed file");
-          AlignFrame.this.setTitle(file);
-          statusBar.setText(MessageManager.formatMessage(
-                  "label.successfully_saved_to_file_in_format", new Object[]
-                  { fileName, format.getName() }));
+          out.flush();
+          if (!stdout)
+          {
+            Console.trace("ALIGNFRAME about to close file");
+            out.close();
+            Console.trace("ALIGNFRAME closed file");
+          }
+          AlignFrame.this.setTitle(stdout ? "STDOUT" : file);
+          if (stdout)
+          {
+            statusBar.setText(MessageManager.formatMessage(
+                    "label.successfully_printed_to_stdout_in_format",
+                    new Object[]
+                    { format.getName() }));
+          }
+          else
+          {
+            statusBar.setText(MessageManager.formatMessage(
+                    "label.successfully_saved_to_file_in_format",
+                    new Object[]
+                    { fileName, format.getName() }));
+          }
           lastSaveSuccessful = true;
         } catch (IOException e)
         {
@@ -1456,9 +1483,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   protected void htmlMenuItem_actionPerformed(ActionEvent e)
   {
     HtmlSvgOutput htmlSVG = new HtmlSvgOutput(alignPanel);
-    try {
+    try
+    {
       htmlSVG.exportHTML(null);
-    } catch (ImageOutputException x) {
+    } catch (ImageOutputException x)
+    {
       // report problem to console and raise dialog
     }
   }
@@ -1467,51 +1496,64 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   public void bioJSMenuItem_actionPerformed(ActionEvent e)
   {
     BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel);
-    try {
-    bjs.exportHTML(null);
-  } catch (ImageOutputException x) {
-    // report problem to console and raise dialog
-  }
+    try
+    {
+      bjs.exportHTML(null);
+    } catch (ImageOutputException x)
+    {
+      // report problem to console and raise dialog
+    }
   }
 
   public void createImageMap(File file, String image)
   {
-    try {
-    alignPanel.makePNGImageMap(file, image);
-    } catch (ImageOutputException x) {
+    try
+    {
+      alignPanel.makePNGImageMap(file, image);
+    } catch (ImageOutputException x)
+    {
       // report problem to console and raise dialog
     }
   }
 
   @Override
-  public void createPNG_actionPerformed(ActionEvent e) {
-    try{
+  public void createPNG_actionPerformed(ActionEvent e)
+  {
+    try
+    {
       createPNG(null);
     } catch (ImageOutputException ioex)
     {
       // raise dialog, and report via console
     }
   }
+
   @Override
-  public void createEPS_actionPerformed(ActionEvent e) {
-    try{
+  public void createEPS_actionPerformed(ActionEvent e)
+  {
+    try
+    {
       createEPS(null);
     } catch (ImageOutputException ioex)
     {
       // raise dialog, and report via console
     }
-    
+
   }
+
   @Override
-  public void createSVG_actionPerformed(ActionEvent e) {
-    try{
+  public void createSVG_actionPerformed(ActionEvent e)
+  {
+    try
+    {
       createSVG(null);
     } catch (ImageOutputException ioex)
     {
       // raise dialog, and report via console
     }
-    
+
   }
+
   /**
    * 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.
@@ -1523,7 +1565,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     createPNG(f, null, BitmapImageSizing.nullBitmapImageSizing());
   }
 
-  public void createPNG(File f, String renderer, BitmapImageSizing userBis) throws ImageOutputException
+  public void createPNG(File f, String renderer, BitmapImageSizing userBis)
+          throws ImageOutputException
   {
     alignPanel.makeAlignmentImage(TYPE.PNG, f, renderer, userBis);
   }
@@ -1534,7 +1577,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    * 
    * @param f
    */
-  public void createEPS(File f)  throws ImageOutputException
+  public void createEPS(File f) throws ImageOutputException
   {
     createEPS(f, null);
   }
@@ -1550,7 +1593,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    * 
    * @param f
    */
-  public void createSVG(File f)  throws ImageOutputException
+  public void createSVG(File f) throws ImageOutputException
   {
     createSVG(f, null);
   }
@@ -2341,12 +2384,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             // annotation was duplicated earlier
             alignment.addAnnotation(sequences[i].getAnnotation()[a]);
             // take care of contact matrix too
-            ContactMatrixI cm=sequences[i].getContactMatrixFor(sequences[i].getAnnotation()[a]);
-            if (cm!=null)
+            ContactMatrixI cm = sequences[i]
+                    .getContactMatrixFor(sequences[i].getAnnotation()[a]);
+            if (cm != null)
             {
-              alignment.addContactListFor(sequences[i].getAnnotation()[a], cm);
+              alignment.addContactListFor(sequences[i].getAnnotation()[a],
+                      cm);
             }
-            
+
             alignment.setAnnotationIndex(sequences[i].getAnnotation()[a],
                     a);
           }
@@ -2454,7 +2499,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     } catch (Exception ex)
     {
       ex.printStackTrace();
-      System.out.println("Exception whilst pasting: " + ex);
+      jalview.bin.Console.outPrintln("Exception whilst pasting: " + ex);
       // could be anything being pasted in here
     }
 
@@ -2502,7 +2547,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     } catch (Exception ex)
     {
       ex.printStackTrace();
-      System.out.println("Exception whilst pasting: " + ex);
+      jalview.bin.Console.outPrintln("Exception whilst pasting: " + ex);
       // could be anything being pasted in here
     } catch (OutOfMemoryError oom)
     {
@@ -3138,11 +3183,20 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   public void wrapMenuItem_actionPerformed(ActionEvent e)
   {
-    scaleAbove.setVisible(wrapMenuItem.isSelected());
-    scaleLeft.setVisible(wrapMenuItem.isSelected());
-    scaleRight.setVisible(wrapMenuItem.isSelected());
-    viewport.setWrapAlignment(wrapMenuItem.isSelected());
+    setWrapFormat(wrapMenuItem.isSelected(), false);
+  }
+
+  public void setWrapFormat(boolean b, boolean setMenuItem)
+  {
+    scaleAbove.setVisible(b);
+    scaleLeft.setVisible(b);
+    scaleRight.setVisible(b);
+    viewport.setWrapAlignment(b);
     alignPanel.updateLayout();
+    if (setMenuItem)
+    {
+      wrapMenuItem.setSelected(b);
+    }
   }
 
   @Override
@@ -4239,8 +4293,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     return tp;
   }
 
-  public void showContactMapTree(AlignmentAnnotation aa,
-          ContactMatrixI cm)
+  public void showContactMapTree(AlignmentAnnotation aa, ContactMatrixI cm)
   {
     int x = 4, y = 5;
     int w = 400, h = 500;
@@ -4249,10 +4302,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     {
       NewickFile fin = new NewickFile(
               new FileParse(cm.getNewick(), DataSourceType.PASTE));
-      String title = cm.getAnnotLabel() + " " + cm.getTreeMethod() + " tree"
-              + aa.sequenceRef != null
+      String title = aa.label + " " + cm.getTreeMethod() + " tree"
+              + (aa.sequenceRef != null
                       ? (" for " + aa.sequenceRef.getDisplayId(false))
-                      : "";
+                      : "");
 
       showColumnWiseTree(fin, aa, title, w, h, x, y);
     } catch (Throwable xx)
@@ -4272,7 +4325,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       {
         return null;
       }
-      TreePanel tp = new TreePanel(alignPanel, nf, aa, title);
+      TreePanel tp = new TreePanel(alignPanel, nf, aa, treeTitle);
 
       tp.setSize(w, h);
 
@@ -4281,7 +4334,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         tp.setLocation(x, y);
       }
 
-      Desktop.addInternalFrame(tp, title, w, h);
+      Desktop.addInternalFrame(tp, treeTitle, w, h);
       return tp;
     } catch (Throwable xx)
     {
@@ -4303,7 +4356,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     {
       try
       {
-        System.err.println("Waiting for building menu to finish.");
+        jalview.bin.Console
+                .errPrintln("Waiting for building menu to finish.");
         Thread.sleep(10);
       } catch (Exception e)
       {
@@ -4319,7 +4373,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         final List<JMenuItem> legacyItems = new ArrayList<>();
         try
         {
-          // System.err.println("Building ws menu again "
+          // jalview.bin.Console.errPrintln("Building ws menu again "
           // + Thread.currentThread());
           // TODO: add support for context dependent disabling of services based
           // on
@@ -4857,7 +4911,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                                     Desktop.instance);
                     if (pe != null)
                     {
-                      System.err.println("Associated file : "
+                      jalview.bin.Console.errPrintln("Associated file : "
                               + (fm[0].toString()) + " with "
                               + toassoc.getDisplayId(true));
                       assocfiles++;
@@ -5890,7 +5944,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               viewport.getAlignment()));
     } catch (Exception ex)
     {
-      System.err.println(ex.getMessage());
+      jalview.bin.Console.errPrintln(ex.getMessage());
       return;
     }
   }
@@ -5912,7 +5966,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         console.runScript();
       } catch (Exception ex)
       {
-        System.err.println((ex.toString()));
+        jalview.bin.Console.errPrintln((ex.toString()));
         JvOptionPane.showInternalMessageDialog(Desktop.desktop,
                 MessageManager.getString("label.couldnt_run_groovy_script"),
                 MessageManager.getString("label.groovy_support_failed"),
@@ -5921,7 +5975,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
     else
     {
-      System.err.println("Can't run Groovy script as console not found");
+      jalview.bin.Console
+              .errPrintln("Can't run Groovy script as console not found");
     }
   }
 
index 5613f16..ef9e575 100644 (file)
@@ -45,7 +45,6 @@ import jalview.bin.Console;
 import jalview.commands.CommandI;
 import jalview.datamodel.AlignedCodonFrame;
 import jalview.datamodel.Alignment;
-import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.ContactMatrixI;
index 3dfb510..ee71483 100644 (file)
@@ -50,6 +50,7 @@ import jalview.api.AlignmentViewPanel;
 import jalview.bin.Cache;
 import jalview.bin.Console;
 import jalview.bin.Jalview;
+import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.SearchResultsI;
@@ -269,10 +270,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     Dimension r = 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);
+      r = calculateDefaultAlignmentIdWidth();
       av.setIdWidth(r.width);
     }
     else
@@ -294,6 +292,14 @@ public class AlignmentPanel extends GAlignmentPanel implements
     return r;
   }
 
+  public Dimension calculateDefaultAlignmentIdWidth()
+  {
+    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);
+    return calculateIdWidth(-1, false, false);
+  }
+
   /**
    * Calculate the width of the alignment labels based on the displayed names
    * and any bounds on label width set in preferences.
@@ -305,6 +311,12 @@ public class AlignmentPanel extends GAlignmentPanel implements
    */
   protected Dimension calculateIdWidth(int maxwidth)
   {
+    return calculateIdWidth(maxwidth, true, false);
+  }
+
+  public Dimension calculateIdWidth(int maxwidth,
+          boolean includeAnnotations, boolean visibleOnly)
+  {
     Container c = new Container();
 
     FontMetrics fm = c.getFontMetrics(
@@ -324,18 +336,29 @@ public class AlignmentPanel extends GAlignmentPanel implements
     }
 
     // Also check annotation label widths
-    i = 0;
-
-    if (al.getAlignmentAnnotation() != null)
+    if (includeAnnotations && al.getAlignmentAnnotation() != null)
     {
-      fm = c.getFontMetrics(getAlabels().getFont());
-
-      while (i < al.getAlignmentAnnotation().length)
+      if (Jalview.isHeadlessMode())
       {
-        String label = al.getAlignmentAnnotation()[i].label;
-        int stringWidth = fm.stringWidth(label);
+        AnnotationLabels aal = this.getAlabels();
+        int stringWidth = aal.drawLabels(null, false, idWidth, false, fm);
         idWidth = Math.max(idWidth, stringWidth);
-        i++;
+      }
+      else
+      {
+        fm = c.getFontMetrics(getAlabels().getFont());
+
+        for (i = 0; i < al.getAlignmentAnnotation().length; i++)
+        {
+          AlignmentAnnotation aa = al.getAlignmentAnnotation()[i];
+          if (visibleOnly && !aa.visible)
+          {
+            continue;
+          }
+          String label = aa.label;
+          int stringWidth = fm.stringWidth(label);
+          idWidth = Math.max(idWidth, stringWidth);
+        }
       }
     }
 
@@ -543,7 +566,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     // this is called after loading new annotation onto alignment
     if (alignFrame.getHeight() == 0)
     {
-      System.out.println("NEEDS FIXING");
+      jalview.bin.Console.outPrintln("NEEDS FIXING");
     }
     validateAnnotationDimensions(true);
     addNotify();
@@ -567,21 +590,29 @@ public class AlignmentPanel extends GAlignmentPanel implements
     // not be called directly by programs.
     // I note that addNotify() is called in several areas of Jalview.
 
-    int annotationHeight = getAnnotationPanel().adjustPanelHeight();
-    annotationHeight = getAnnotationPanel()
-            .adjustForAlignFrame(adjustPanelHeight, annotationHeight);
+    AnnotationPanel ap = getAnnotationPanel();
+    int annotationHeight = ap.adjustPanelHeight();
+    annotationHeight = ap.adjustForAlignFrame(adjustPanelHeight,
+            annotationHeight);
 
     hscroll.addNotify();
-    annotationScroller.setPreferredSize(
-            new Dimension(annotationScroller.getWidth(), annotationHeight));
-
     Dimension e = idPanel.getSize();
-    alabels.setSize(new Dimension(e.width, annotationHeight));
+    int idWidth = e.width;
+    boolean manuallyAdjusted = this.getIdPanel().getIdCanvas()
+            .manuallyAdjusted();
+    annotationScroller.setPreferredSize(new Dimension(
+            manuallyAdjusted ? idWidth : annotationScroller.getWidth(),
+            annotationHeight));
+
+    alabels.setPreferredSize(new Dimension(idWidth, annotationHeight));
 
     annotationSpaceFillerHolder.setPreferredSize(new Dimension(
-            annotationSpaceFillerHolder.getWidth(), annotationHeight));
+            manuallyAdjusted ? idWidth
+                    : annotationSpaceFillerHolder.getWidth(),
+            annotationHeight));
     annotationScroller.validate();
     annotationScroller.addNotify();
+    ap.validate();
   }
 
   /**
@@ -597,9 +628,10 @@ public class AlignmentPanel extends GAlignmentPanel implements
     boolean wrap = av.getWrapAlignment();
     ViewportRanges ranges = av.getRanges();
     ranges.setStartSeq(0);
-    scalePanelHolder.setVisible(!wrap);
+    // scalePanelHolder.setVisible(!wrap);
     hscroll.setVisible(!wrap);
-    idwidthAdjuster.setVisible(!wrap);
+    // Allow idPanel width adjustment in wrap mode
+    idwidthAdjuster.setVisible(true);
 
     if (wrap)
     {
@@ -633,7 +665,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
       }
     }
 
-    idSpaceFillerPanel1.setVisible(!wrap);
+    // idSpaceFillerPanel1.setVisible(!wrap);
 
     repaint();
   }
@@ -854,10 +886,27 @@ public class AlignmentPanel extends GAlignmentPanel implements
   public void paintComponent(Graphics g)
   {
     invalidate(); // needed so that the id width adjuster works correctly
-
     Dimension d = getIdPanel().getIdCanvas().getPreferredSize();
-    idPanelHolder.setPreferredSize(d);
-    hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));
+    int idWidth = d.width;
+
+    // check wrapped alignment as at least 1 residue width
+    if (av.getWrapAlignment())
+    {
+      SeqCanvas sc = this.getSeqPanel().seqCanvas;
+      if (sc != null && sc.getWidth() < sc.getMinimumWrappedCanvasWidth())
+      {
+        // need to make some adjustments
+        idWidth -= (sc.getMinimumWrappedCanvasWidth() - sc.getWidth());
+        av.setIdWidth(idWidth);
+        av.getAlignPanel().getIdPanel().getIdCanvas()
+                .setManuallyAdjusted(true);
+
+        validateAnnotationDimensions(false);
+      }
+    }
+
+    idPanelHolder.setPreferredSize(new Dimension(idWidth, d.height));
+    hscrollFillerPanel.setPreferredSize(new Dimension(idWidth, 12));
 
     validate(); // needed so that the id width adjuster works correctly
 
@@ -1172,10 +1221,12 @@ public class AlignmentPanel extends GAlignmentPanel implements
     }
 
     int w = getIdPanel().getWidth();
+    w = this.calculateIdWidth(-1, true, true).width;
     return (w > 0 ? w : calculateIdWidth().width);
   }
 
-  void makeAlignmentImage(ImageMaker.TYPE type, File file, String renderer) throws ImageOutputException
+  void makeAlignmentImage(ImageMaker.TYPE type, File file, String renderer)
+          throws ImageOutputException
   {
     makeAlignmentImage(type, file, renderer,
             BitmapImageSizing.nullBitmapImageSizing());
@@ -1196,6 +1247,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     final int borderBottomOffset = 5;
 
     AlignmentDimension aDimension = getAlignmentDimension();
+
     // todo use a lambda function in place of callback here?
     ImageWriterI writer = new ImageWriterI()
     {
@@ -1266,7 +1318,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
   }
 
-  public void makePNGImageMap(File imgMapFile, String imageName) throws ImageOutputException
+  public void makePNGImageMap(File imgMapFile, String imageName)
+          throws ImageOutputException
   {
     // /////ONLY WORKS WITH NON WRAPPED ALIGNMENTS
     // ////////////////////////////////////////////
@@ -1391,7 +1444,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
       } catch (Exception ex)
       {
-        throw new ImageOutputException("couldn't write ImageMap due to unexpected error",ex);
+        throw new ImageOutputException(
+                "couldn't write ImageMap due to unexpected error", ex);
       }
     } // /////////END OF IMAGE MAP
 
@@ -1407,8 +1461,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
   {
     int seqPanelWidth = getSeqPanel().seqCanvas.getWidth();
 
-    if (System.getProperty("java.awt.headless") != null
-            && System.getProperty("java.awt.headless").equals("true"))
+    if (Jalview.isHeadlessMode())
     {
       seqPanelWidth = alignFrame.getWidth() - getVisibleIdWidth()
               - vscroll.getPreferredSize().width
index 6b82a37..20e1b1b 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.gui;
 
+import java.awt.Canvas;
 import java.awt.Color;
 import java.awt.Cursor;
 import java.awt.Dimension;
@@ -50,6 +51,8 @@ import javax.swing.ToolTipManager;
 
 import jalview.analysis.AlignSeq;
 import jalview.analysis.AlignmentUtils;
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
@@ -85,7 +88,7 @@ public class AnnotationLabels extends JPanel
   /**
    * height in pixels for allowing height adjuster to be active
    */
-  private static int HEIGHT_ADJUSTER_HEIGHT = 10;
+  public static int HEIGHT_ADJUSTER_HEIGHT = 10;
 
   private static final Font font = new Font("Arial", Font.PLAIN, 11);
 
@@ -113,6 +116,8 @@ public class AnnotationLabels extends JPanel
   private static final String COPYCONS_SEQ = MessageManager
           .getString("label.copy_consensus_sequence");
 
+  private static final String ADJUST_ANNOTATION_LABELS_WIDTH_PREF = "ADJUST_ANNOTATION_LABELS_WIDTH";
+
   private final boolean debugRedraw = false;
 
   private AlignmentPanel ap;
@@ -131,6 +136,10 @@ public class AnnotationLabels extends JPanel
 
   private boolean resizePanel = false;
 
+  private int annotationIdWidth = -1;
+
+  public static final String RESIZE_MARGINS_MARK_PREF = "RESIZE_MARGINS_MARK";
+
   /**
    * Creates a new AnnotationLabels object
    * 
@@ -138,7 +147,6 @@ public class AnnotationLabels extends JPanel
    */
   public AnnotationLabels(AlignmentPanel ap)
   {
-
     this.ap = ap;
     av = ap.av;
     ToolTipManager.sharedInstance().registerComponent(this);
@@ -418,65 +426,74 @@ public class AnnotationLabels extends JPanel
         pop.add(consclipbrd);
       }
 
-      addColourOrFilterByOptions(ap,aa[selectedRow],pop);
-      
+      addColourOrFilterByOptions(ap, aa[selectedRow], pop);
+
       if (aa[selectedRow].graph == AlignmentAnnotation.CONTACT_MAP)
       {
-        addContactMatrixOptions(ap,aa[selectedRow],pop);
-          // Set/adjust threshold for grouping ?
-          // colour alignment by this [type]
-          // select/hide columns by this row
-          
-        }
+        addContactMatrixOptions(ap, aa[selectedRow], pop);
+        // Set/adjust threshold for grouping ?
+        // colour alignment by this [type]
+        // select/hide columns by this row
+
       }
-    
+    }
+
     pop.show(this, evt.getX(), evt.getY());
   }
 
   static void addColourOrFilterByOptions(final AlignmentPanel ap,
-          final AlignmentAnnotation alignmentAnnotation, final JPopupMenu pop)
+          final AlignmentAnnotation alignmentAnnotation,
+          final JPopupMenu pop)
   {
     JMenuItem item;
-    item = new JMenuItem(MessageManager.getString("label.colour_by_annotation"));
+    item = new JMenuItem(
+            MessageManager.getString("label.colour_by_annotation"));
     item.addActionListener(new ActionListener()
     {
-      
+
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        AnnotationColourChooser.displayFor(ap.av, ap,alignmentAnnotation,false);
+        AnnotationColourChooser.displayFor(ap.av, ap, alignmentAnnotation,
+                false);
       };
     });
     pop.add(item);
-    if (alignmentAnnotation.sequenceRef!=null)
+    if (alignmentAnnotation.sequenceRef != null)
     {
-      item = new JMenuItem(MessageManager.getString("label.colour_by_annotation")+" ("+MessageManager.getString("label.per_seq")+")");
+      item = new JMenuItem(
+              MessageManager.getString("label.colour_by_annotation") + " ("
+                      + MessageManager.getString("label.per_seq") + ")");
       item.addActionListener(new ActionListener()
       {
         @Override
         public void actionPerformed(ActionEvent e)
         {
-          AnnotationColourChooser.displayFor(ap.av, ap,alignmentAnnotation,true);
+          AnnotationColourChooser.displayFor(ap.av, ap, alignmentAnnotation,
+                  true);
         };
       });
       pop.add(item);
     }
-    item = new JMenuItem(MessageManager.getString("action.select_by_annotation"));
+    item = new JMenuItem(
+            MessageManager.getString("action.select_by_annotation"));
     item.addActionListener(new ActionListener()
     {
-      
+
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        AnnotationColumnChooser.displayFor(ap.av,ap,alignmentAnnotation);
+        AnnotationColumnChooser.displayFor(ap.av, ap, alignmentAnnotation);
       };
     });
     pop.add(item);
   }
+
   static void addContactMatrixOptions(final AlignmentPanel ap,
-          final AlignmentAnnotation alignmentAnnotation, final JPopupMenu pop)
+          final AlignmentAnnotation alignmentAnnotation,
+          final JPopupMenu pop)
   {
-    
+
     final ContactMatrixI cm = ap.av.getContactMatrix(alignmentAnnotation);
     JMenuItem item;
     if (cm != null)
@@ -485,10 +502,13 @@ public class AnnotationLabels extends JPanel
 
       if (cm.hasGroups())
       {
-        JCheckBoxMenuItem chitem = new JCheckBoxMenuItem(MessageManager.getString("action.show_groups_on_matrix"));
-        chitem.setToolTipText(MessageManager.getString("action.show_groups_on_matrix_tooltip"));
-        boolean showGroups = alignmentAnnotation.isShowGroupsForContactMatrix();
-        final AlignmentAnnotation sel_row=alignmentAnnotation;
+        JCheckBoxMenuItem chitem = new JCheckBoxMenuItem(
+                MessageManager.getString("action.show_groups_on_matrix"));
+        chitem.setToolTipText(MessageManager
+                .getString("action.show_groups_on_matrix_tooltip"));
+        boolean showGroups = alignmentAnnotation
+                .isShowGroupsForContactMatrix();
+        final AlignmentAnnotation sel_row = alignmentAnnotation;
         chitem.setState(showGroups);
         chitem.addActionListener(new ActionListener()
         {
@@ -497,16 +517,20 @@ public class AnnotationLabels extends JPanel
           public void actionPerformed(ActionEvent e)
           {
             sel_row.setShowGroupsForContactMatrix(chitem.getState());
-            ap.getAnnotationPanel()
-            .paint(ap.getAnnotationPanel().getGraphics());
+            // so any annotation colour changes are propagated - though they
+            // probably won't be unless the annotation row colours are removed
+            // too!
+            ap.alignmentChanged();
           }
         });
         pop.add(chitem);
       }
       if (cm.hasTree())
       {
-        item = new JMenuItem(MessageManager.getString("action.show_tree_for_matrix"));
-        item.setToolTipText(MessageManager.getString("action.show_tree_for_matrix_tooltip"));
+        item = new JMenuItem(
+                MessageManager.getString("action.show_tree_for_matrix"));
+        item.setToolTipText(MessageManager
+                .getString("action.show_tree_for_matrix_tooltip"));
         item.addActionListener(new ActionListener()
         {
 
@@ -522,8 +546,10 @@ public class AnnotationLabels extends JPanel
       }
       else
       {
-        item = new JMenuItem(MessageManager.getString("action.cluster_matrix"));
-        item.setToolTipText(MessageManager.getString("action.cluster_matrix_tooltip"));
+        item = new JMenuItem(
+                MessageManager.getString("action.cluster_matrix"));
+        item.setToolTipText(
+                MessageManager.getString("action.cluster_matrix_tooltip"));
         item.addActionListener(new ActionListener()
         {
           @Override
@@ -535,8 +561,15 @@ public class AnnotationLabels extends JPanel
               public void run()
               {
                 final long progBar;
-                ap.alignFrame.setProgressBar(MessageManager.formatMessage("action.clustering_matrix_for",cm.getAnnotDescr(),5f), progBar = System.currentTimeMillis());
-                cm.setGroupSet(GroupSet.makeGroups(cm, 5f, true));
+                ap.alignFrame.setProgressBar(
+                        MessageManager.formatMessage(
+                                "action.clustering_matrix_for",
+                                cm.getAnnotDescr(), 5f),
+                        progBar = System.currentTimeMillis());
+                cm.setGroupSet(GroupSet.makeGroups(cm, true));
+                cm.randomlyReColourGroups();
+                cm.transferGroupColorsTo(alignmentAnnotation);
+                ap.alignmentChanged();
                 ap.alignFrame.showContactMapTree(alignmentAnnotation, cm);
                 ap.alignFrame.setProgressBar(null, progBar);
               }
@@ -1136,7 +1169,6 @@ public class AnnotationLabels extends JPanel
     }
 
     drawComponent(g2, true, width);
-
   }
 
   /**
@@ -1166,32 +1198,146 @@ public class AnnotationLabels extends JPanel
    * @param width
    *          Width for scaling labels
    */
-  public void drawComponent(Graphics g, boolean clip, int width)
+  public void drawComponent(Graphics g, boolean clip, int givenWidth)
   {
-    if (av.getFont().getSize() < 10)
+    int width = givenWidth;
+    IdwidthAdjuster iwa = null;
+    if (ap != null)
     {
-      g.setFont(font);
+      iwa = ap.idwidthAdjuster;
+      if ((Cache.getDefault(ADJUST_ANNOTATION_LABELS_WIDTH_PREF, true)
+              || Jalview.isHeadlessMode()))
+      {
+        Graphics2D g2d = (Graphics2D) g;
+        Graphics dummy = g2d.create();
+        int newAnnotationIdWidth = drawLabels(dummy, clip, width, false,
+                null);
+        dummy.dispose();
+        Dimension d = ap.calculateDefaultAlignmentIdWidth();
+        int alignmentIdWidth = d.width;
+        if (iwa != null && !iwa.manuallyAdjusted())
+        {
+          // If no manual adjustment to ID column with has been made then adjust
+          // width match widest of alignment or annotation id widths
+          boolean allowShrink = Cache.getDefault("ALLOW_SHRINK_ID_WIDTH",
+                  false);
+          width = Math.max(alignmentIdWidth, newAnnotationIdWidth);
+          if (clip && width < givenWidth && !allowShrink)
+          {
+            width = givenWidth;
+          }
+        }
+        else if (newAnnotationIdWidth != annotationIdWidth
+                && newAnnotationIdWidth > givenWidth
+                && newAnnotationIdWidth > alignmentIdWidth)
+        {
+          // otherwise if the annotation id width has become larger than the
+          // current id width, increase
+          width = newAnnotationIdWidth;
+          annotationIdWidth = newAnnotationIdWidth;
+        }
+        // set the width if it's changed
+        if (width != ap.av.getIdWidth())
+        {
+          iwa.setWidth(width);
+        }
+      }
     }
     else
     {
-      g.setFont(av.getFont());
+      int newAnnotationIdWidth = drawLabels(g, clip, width, false, null);
+      width = Math.max(newAnnotationIdWidth, givenWidth);
+    }
+    drawLabels(g, clip, width, true, null);
+  }
+
+  /**
+   * Render the full set of annotation Labels for the alignment at the given
+   * cursor. If actuallyDraw is false or g is null then no actual drawing will
+   * occur, but the widest label width will be returned. If g is null then
+   * fmetrics must be supplied.
+   * 
+   * Returns the width of the annotation labels.
+   * 
+   * @param g
+   *          Graphics2D instance (needed for font scaling)
+   * @param clip
+   *          - true indicates that only current visible area needs to be
+   *          rendered
+   * @param width
+   *          Width for scaling labels
+   * @param fmetrics
+   *          FontMetrics if Graphics object g is null
+   */
+  public int drawLabels(Graphics g0, boolean clip, int width,
+          boolean actuallyDraw, FontMetrics fmetrics)
+  {
+    if (clip)
+    {
+      clip = Cache.getDefault("MOVE_SEQUENCE_ID_WITH_VISIBLE_ANNOTATIONS",
+              true);
+    }
+    Graphics g = null;
+    // create a dummy Graphics object if not drawing and one is supplied
+    if (g0 != null)
+    {
+      if (!actuallyDraw)
+      {
+        Graphics2D g2d = (Graphics2D) g0;
+        g = g2d.create();
+      }
+      else
+      {
+        g = g0;
+      }
     }
+    int actualWidth = 0;
+    if (g != null)
+    {
+      if (av.getFont().getSize() < 10)
+      {
+        g.setFont(font);
+      }
+      else
+      {
+        g.setFont(av.getFont());
+      }
+    }
+
+    FontMetrics fm = fmetrics == null ? g.getFontMetrics(g.getFont())
+            : fmetrics;
+    if (actuallyDraw)
+    {
+      g.setColor(Color.white);
+      g.fillRect(0, 0, getWidth(), getHeight());
+
+      if (!Cache.getDefault(RESIZE_MARGINS_MARK_PREF, false)
+              && !av.getWrapAlignment())
+      {
+        g.setColor(Color.LIGHT_GRAY);
+        g.drawLine(0, HEIGHT_ADJUSTER_HEIGHT / 4, HEIGHT_ADJUSTER_WIDTH / 4,
+                HEIGHT_ADJUSTER_HEIGHT / 4);
+        g.drawLine(0, 3 * HEIGHT_ADJUSTER_HEIGHT / 4,
+                HEIGHT_ADJUSTER_WIDTH / 4, 3 * HEIGHT_ADJUSTER_HEIGHT / 4);
 
-    FontMetrics fm = g.getFontMetrics(g.getFont());
-    g.setColor(Color.white);
-    g.fillRect(0, 0, getWidth(), getHeight());
+      }
+    }
 
-    g.translate(0, getScrollOffset());
-    g.setColor(Color.black);
+    if (actuallyDraw)
+    {
+      g.translate(0, getScrollOffset());
+      g.setColor(Color.black);
+    }
     SequenceI lastSeqRef = null;
     String lastLabel = null;
     AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
-    int fontHeight = g.getFont().getSize();
+    int fontHeight = g != null ? g.getFont().getSize()
+            : fm.getFont().getSize();
     int y = 0;
     int x = 0;
     int graphExtras = 0;
     int offset = 0;
-    Font baseFont = g.getFont();
+    Font baseFont = g != null ? g.getFont() : fm.getFont();
     FontMetrics baseMetrics = fm;
     int ofontH = fontHeight;
     int sOffset = 0;
@@ -1232,7 +1378,7 @@ public class AnnotationLabels extends JPanel
             {
               if (debugRedraw)
               {
-                System.out.println("before vis: " + i);
+                jalview.bin.Console.outPrintln("before vis: " + i);
               }
               before = true;
             }
@@ -1246,7 +1392,7 @@ public class AnnotationLabels extends JPanel
             {
               if (debugRedraw)
               {
-                System.out.println(
+                jalview.bin.Console.outPrintln(
                         "Scroll offset: " + sOffset + " after vis: " + i);
               }
               after = true;
@@ -1255,8 +1401,10 @@ public class AnnotationLabels extends JPanel
             continue;
           }
         }
-        g.setColor(Color.black);
-
+        if (actuallyDraw && g != null)
+        {
+          g.setColor(Color.black);
+        }
         offset = -aa[i].height / 2;
 
         if (aa[i].hasText)
@@ -1301,7 +1449,9 @@ public class AnnotationLabels extends JPanel
             vertBar = true;
           }
         }
-        x = width - fm.stringWidth(label) - 3;
+
+        int labelWidth = fm.stringWidth(label) + 3;
+        x = width - labelWidth;
 
         if (aa[i].graphGroup > -1)
         {
@@ -1334,10 +1484,15 @@ public class AnnotationLabels extends JPanel
               s = ((float) fontHeight) / (float) ofontH;
               Font f = baseFont
                       .deriveFont(AffineTransform.getScaleInstance(s, s));
-              g.setFont(f);
-              fm = g.getFontMetrics();
-              graphExtras = (aa[i].height - (groupSize * (fontHeight + 8)))
-                      / 2;
+              Canvas c = new Canvas();
+              fm = c.getFontMetrics(f);
+              if (actuallyDraw && g != null)
+              {
+                g.setFont(f);
+                // fm = g.getFontMetrics();
+                graphExtras = (aa[i].height
+                        - (groupSize * (fontHeight + 8))) / 2;
+              }
             }
           }
           if (visible)
@@ -1346,58 +1501,81 @@ public class AnnotationLabels extends JPanel
             {
               if (aa[gg].graphGroup == aa[i].graphGroup)
               {
-                x = width - fm.stringWidth(aa[gg].label) - 3;
-                g.drawString(aa[gg].label, x, y - graphExtras);
-
-                if (aa[gg]._linecolour != null)
+                labelWidth = fm.stringWidth(aa[gg].label) + 3;
+                x = width - labelWidth;
+                if (actuallyDraw && g != null)
                 {
+                  g.drawString(aa[gg].label, x, y - graphExtras);
 
-                  g.setColor(aa[gg]._linecolour);
-                  g.drawLine(x, y - graphExtras + 3,
-                          x + fm.stringWidth(aa[gg].label),
-                          y - graphExtras + 3);
-                }
+                  if (aa[gg]._linecolour != null)
+                  {
+
+                    g.setColor(aa[gg]._linecolour);
+                    g.drawLine(x, y - graphExtras + 3,
+                            x + fm.stringWidth(aa[gg].label),
+                            y - graphExtras + 3);
+                  }
 
-                g.setColor(Color.black);
+                  g.setColor(Color.black);
+                }
                 graphExtras += fontHeight + 8;
               }
             }
           }
-          g.setFont(baseFont);
+          if (actuallyDraw && g != null)
+          {
+            g.setFont(baseFont);
+          }
           fm = baseMetrics;
           fontHeight = ofontH;
         }
         else
         {
-          if (vertBar)
+          if (actuallyDraw && g != null)
           {
-            g.drawLine(width - 3, y + offset - fontHeight, width - 3,
-                    (int) (y - 1.5 * aa[i].height - offset - fontHeight));
-            // g.drawLine(20, y + offset, x - 20, y + offset);
+            if (vertBar)
+            {
+              g.drawLine(width - 3, y + offset - fontHeight, width - 3,
+                      (int) (y - 1.5 * aa[i].height - offset - fontHeight));
+              // g.drawLine(20, y + offset, x - 20, y + offset);
 
+            }
+            g.drawString(label, x, y + offset);
           }
-          g.drawString(label, x, y + offset);
         }
         lastSeqRef = aa[i].sequenceRef;
+
+        if (labelWidth > actualWidth)
+        {
+          actualWidth = labelWidth;
+        }
       }
     }
 
     if (!resizePanel && dragEvent != null && aa != null)
     {
-      g.setColor(Color.lightGray);
-      g.drawString(
-              (aa[selectedRow].sequenceRef == null ? ""
-                      : aa[selectedRow].sequenceRef.getName())
-                      + aa[selectedRow].label,
-              dragEvent.getX(), dragEvent.getY() - getScrollOffset());
+      if (actuallyDraw && g != null)
+      {
+        g.setColor(Color.lightGray);
+        g.drawString(
+                (aa[selectedRow].sequenceRef == null ? ""
+                        : aa[selectedRow].sequenceRef.getName())
+                        + aa[selectedRow].label,
+                dragEvent.getX(), dragEvent.getY() - getScrollOffset());
+      }
     }
 
     if (!av.getWrapAlignment() && ((aa == null) || (aa.length < 1)))
     {
-      g.drawString(MessageManager.getString("label.right_click"), 2, 8);
-      g.drawString(MessageManager.getString("label.to_add_annotation"), 2,
-              18);
+      if (actuallyDraw && g != null)
+      {
+        g.drawString(MessageManager.getString("label.right_click"), 2, 8);
+        g.drawString(MessageManager.getString("label.to_add_annotation"), 2,
+                18);
+      }
     }
+
+    return actualWidth;
   }
 
   public int getScrollOffset()
index 8e04048..8a957bc 100755 (executable)
@@ -737,7 +737,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
         if (evt.isControlDown()
                 && PAEContactMatrix.PAEMATRIX.equals(clicked.getCalcId()))
         {
-          int c = fr - 1;
+          int c = fr;
           ContactRange cr = forCurrentX.getRangeFor(fr, to);
           double cval;
           // TODO: could use GraphLine instead of arbitrary picking
@@ -747,7 +747,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
           // controls feathering - what other elements in row/column
           // should we select
           double thresh = cr.getMean() + (cr.getMax() - cr.getMean()) * .15;
-          while (c > 0)
+          while (c >= 0)
           {
             cval = forCurrentX.getContactAt(c);
             if (// cr.getMin() <= cval &&
@@ -1078,12 +1078,12 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       ContactGeometry lastXcgeom = new ContactGeometry(forFromX,
               cma.graphHeight);
       ContactGeometry.contactInterval lastXci = lastXcgeom
-              .mapFor(rowIndex[1], rowIndex[1] - deltaY);
+              .mapFor(rowIndex[1], rowIndex[1] + deltaY);
 
       ContactGeometry cXcgeom = new ContactGeometry(forToX,
               cma.graphHeight);
       ContactGeometry.contactInterval cXci = cXcgeom.mapFor(rowIndex[1],
-              rowIndex[1] - deltaY);
+              rowIndex[1] + deltaY);
 
       // mark rectangular region formed by drag
       jalview.bin.Console.trace("Matrix Selection from last(" + fromXc
@@ -1247,7 +1247,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       {
         row = i;
         res[0] = row;
-        res[1] = height - yPos;
+        res[1] = yPos-lheight;
         break;
       }
     }
@@ -1301,6 +1301,10 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
     // TODO abstract tooltip generator so different implementations can be built
     if (ann.graph == AlignmentAnnotation.CONTACT_MAP)
     {
+      if (rowAndOffset>=ann.graphHeight)
+      {
+        return null;
+      }
       ContactListI clist = av.getContactList(ann, column);
       if (clist != null)
       {
@@ -1503,7 +1507,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
           tried = true;
         } catch (IllegalArgumentException exc)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Serious issue with viewport geometry imgWidth requested was "
                           + imgWidth);
           return;
@@ -1646,7 +1650,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
               && (fadedImage == null || fadedImage.getWidth() != imgWidth
                       || fadedImage.getHeight() != image.getHeight()))
       {
-        // System.err.println("redraw faded image ("+(fadedImage==null ?
+        // jalview.bin.Console.errPrintln("redraw faded image ("+(fadedImage==null ?
         // "null image" : "") + " lastGood="+lastImageGood+")");
         fadedImage = new BufferedImage(imgWidth, image.getHeight(),
                 BufferedImage.TYPE_INT_RGB);
index 1758b5b..950f129 100644 (file)
@@ -28,9 +28,16 @@ import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
 import java.io.File;
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
 
 import javax.swing.JPanel;
 import javax.swing.JSplitPane;
@@ -364,9 +371,9 @@ public class AppJmol extends StructureViewerBase
       }
       if (waitTotal > waitMax)
       {
-        System.err.println("Timed out waiting for Jmol to load files after "
+        jalview.bin.Console.errPrintln("Timed out waiting for Jmol to load files after "
                 + waitTotal + "ms");
-        // System.err.println("finished: " + jmb.isFinishedInit()
+        // jalview.bin.Console.errPrintln("finished: " + jmb.isFinishedInit()
         // + "; loaded: " + Arrays.toString(jmb.getPdbFile())
         // + "; files: " + files.toString());
         jmb.getStructureFiles();
@@ -472,11 +479,48 @@ public class AppJmol extends StructureViewerBase
     };
     String view = MessageManager.getString("action.view")
             .toLowerCase(Locale.ROOT);
-    ImageExporter exporter = new ImageExporter(writer,
+    final ImageExporter exporter = new ImageExporter(writer,
             getProgressIndicator(), type, getTitle());
     
-    exporter.doExport(file, this, width, height, view, renderer, userBis);
-    
+    final Throwable[] exceptions = new Throwable[1];
+    exceptions[0] = null;
+    final AppJmol us = this;
+    try
+    {
+      Thread runner = Executors.defaultThreadFactory().newThread(new Runnable()
+      {
+        @Override
+        public void run()
+        {
+          try
+          {
+            exporter.doExport(file, us, width, height, view, renderer,
+                    userBis);
+          } catch (Throwable t)
+          {
+            exceptions[0] = t;
+          }
+        }
+      });
+      runner.start();
+      do { Thread.sleep(25); } while (runner.isAlive());
+    } catch (Throwable e)
+    {
+      throw new ImageOutputException(
+              "Unexpected error when generating image", e);
+    }
+    if (exceptions[0] != null)
+    {
+      if (exceptions[0] instanceof ImageOutputException)
+      {
+        throw ((ImageOutputException) exceptions[0]);
+      }
+      else
+      {
+        throw new ImageOutputException(
+                "Unexpected error when generating image", exceptions[0]);
+      }
+    }
   }
 
   @Override
@@ -488,7 +532,7 @@ public class AppJmol extends StructureViewerBase
               .openURL("http://wiki.jmol.org");// http://jmol.sourceforge.net/docs/JmolUserGuide/");
     } catch (Exception ex)
     {
-      System.err.println("Show Jmol help failed with: " + ex.getMessage());
+      jalview.bin.Console.errPrintln("Show Jmol help failed with: " + ex.getMessage());
     }
   }
 
index 6fac8fc..eb2368d 100644 (file)
@@ -476,7 +476,7 @@ public class AppVarna extends JInternalFrame
       if (shift != null)
       {
         int i = shift.shift(newBase.getIndex());
-        // System.err.println("shifted "+(arg1.getIndex())+" to "+i);
+        // jalview.bin.Console.errPrintln("shifted "+(arg1.getIndex())+" to "+i);
         ssm.mouseOverVamsasSequence(seq, i, this);
       }
       else
index 5cfe72a..8951df0 100644 (file)
@@ -574,7 +574,7 @@ public class AppVarnaBinding extends JalviewVarnaBinding
     } catch (ExceptionNAViewAlgorithm e)
     {
       // only throwable for draw mode = 3 NAView
-      System.err.println("Error drawing RNA: " + e.getMessage());
+      jalview.bin.Console.errPrintln("Error drawing RNA: " + e.getMessage());
     }
   }
 }
index af59ca7..c120a1b 100644 (file)
@@ -772,7 +772,7 @@ public class BlogReader extends JPanel
       String formattedDate = Cache.setDateProperty(
               "JALVIEW_NEWS_RSS_LASTMODIFIED", lastread.getTime());
       BlogReader me = new BlogReader();
-      System.out.println("Set last date to " + formattedDate);
+      jalview.bin.Console.outPrintln("Set last date to " + formattedDate);
       if (me.isNewsNew())
       {
         Console.debug("There is news to read.");
index cc6a785..f13e151 100644 (file)
@@ -343,7 +343,7 @@ public class ChimeraViewFrame extends StructureViewerBase
       boolean opened = jmb.openSession(chimeraSessionFile);
       if (!opened)
       {
-        System.err.println("An error occurred opening Chimera session file "
+        jalview.bin.Console.errPrintln("An error occurred opening Chimera session file "
                 + chimeraSessionFile);
       }
     }
index c1c75f1..574ba28 100644 (file)
@@ -304,7 +304,7 @@ public class ColourMenuHelper
         }
       } catch (Exception ex)
       {
-        System.out.println("Error loading User ColourFile\n" + ex);
+        jalview.bin.Console.outPrintln("Error loading User ColourFile\n" + ex);
       }
     }
 
index 5a23048..6a6cb56 100644 (file)
@@ -433,20 +433,20 @@ public class Console extends WindowAdapter
     // you may omit this part for your application
     //
 
-    System.out.println("Hello World 2");
-    System.out.println("All fonts available to Graphic2D:\n");
+    jalview.bin.Console.outPrintln("Hello World 2");
+    jalview.bin.Console.outPrintln("All fonts available to Graphic2D:\n");
     GraphicsEnvironment ge = GraphicsEnvironment
             .getLocalGraphicsEnvironment();
     String[] fontNames = ge.getAvailableFontFamilyNames();
     for (int n = 0; n < fontNames.length; n++)
     {
-      System.out.println(fontNames[n]);
+      jalview.bin.Console.outPrintln(fontNames[n]);
     }
     // Testing part: simple an error thrown anywhere in this JVM will be printed
     // on the Console
     // We do it with a seperate Thread becasue we don't wan't to break a Thread
     // used by the Console.
-    System.out.println("\nLets throw an error on this console");
+    jalview.bin.Console.outPrintln("\nLets throw an error on this console");
     errorThrower = new Thread(this);
     errorThrower.setDaemon(true);
     errorThrower.start();
index c15cf2d..6cb59c3 100644 (file)
@@ -432,7 +432,7 @@ public class CrossRefAction implements Runnable
                 MessageManager.getString("label.cant_map_cds"),
                 MessageManager.getString("label.operation_failed"),
                 JvOptionPane.OK_OPTION);
-        System.err.println("Failed to make CDS alignment");
+        jalview.bin.Console.errPrintln("Failed to make CDS alignment");
         return null;
       }
 
@@ -466,7 +466,7 @@ public class CrossRefAction implements Runnable
 
     if (copyAlignment.getHeight() <= 0)
     {
-      System.err.println("No Sequences generated for xRef type " + source);
+      jalview.bin.Console.errPrintln("No Sequences generated for xRef type " + source);
       return null;
     }
 
index b901ae4..efefa21 100644 (file)
@@ -439,7 +439,7 @@ public class Desktop extends jalview.jbgui.GDesktop
          * Send this message to stderr as the warning that follows (due to
          * reflection) also goes to stderr.
          */
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Linux platform only! You may have the following warning next: \"WARNING: An illegal reflective access operation has occurred\"\nThis is expected and cannot be avoided, sorry about that.");
       }
       final String awtAppClassName = "awtAppClassName";
@@ -873,7 +873,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         }
       } catch (Exception ex)
       {
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "Unable to paste alignment from system clipboard:\n" + ex);
       }
     }
@@ -1078,7 +1078,36 @@ public class Desktop extends jalview.jbgui.GDesktop
 
     setKeyBindings(frame);
 
-    desktop.add(frame);
+    // Since the latest FlatLaf patch, we occasionally have problems showing structureViewer frames...
+    int tries=3;
+    boolean shown=false;
+    Exception last=null;
+    do
+    {
+      try
+      {
+        desktop.add(frame);
+        shown=true;
+      } catch (IllegalArgumentException iaex)
+      {
+        last=iaex;
+        tries--;
+        jalview.bin.Console.info(
+                "Squashed IllegalArgument Exception (" + tries + " left) for "+frame.getTitle(),
+                iaex);
+        try
+        {
+          Thread.sleep(5);
+        } catch (InterruptedException iex)
+        {
+        }
+        ;
+      }
+    } while (!shown && tries > 0);
+    if (!shown)
+    {
+      jalview.bin.Console.error("Serious Problem whilst showing window "+frame.getTitle(),last);
+    }
 
     windowMenu.add(menuItem);
 
@@ -1601,7 +1630,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       }
     } catch (Exception ex)
     {
-      System.err.println("Error opening help: " + ex.getMessage());
+      jalview.bin.Console.errPrintln("Error opening help: " + ex.getMessage());
     }
   }
 
@@ -1832,7 +1861,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     boolean autoSave = projectFile != null && !saveAs
             && BackupFiles.getEnabled();
 
-    // System.out.println("autoSave="+autoSave+", projectFile='"+projectFile+"',
+    // jalview.bin.Console.outPrintln("autoSave="+autoSave+", projectFile='"+projectFile+"',
     // saveAs="+saveAs+", Backups
     // "+(BackupFiles.getEnabled()?"enabled":"disabled"));
 
@@ -3381,7 +3410,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         {
           if (Platform.isAMacAndNotJS())
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Please ignore plist error - occurs due to problem with java 8 on OSX");
           }
         }
@@ -3623,8 +3652,22 @@ public class Desktop extends jalview.jbgui.GDesktop
     {
       Desktop.instance.closeAll_actionPerformed(null);
       Desktop.instance.setVisible(false);
-      Desktop.instance.dispose();
+      Desktop us = Desktop.instance;
       Desktop.instance = null;
+      // call dispose in a separate thread - try to avoid indirect deadlocks
+      new Thread(new Runnable() {
+        @Override
+        public void run()
+        {
+          ExecutorService dex = us.dialogExecutor;
+          if (dex!=null) {
+            dex.shutdownNow();
+            us.dialogExecutor=null;
+            us.block.drainPermits();
+          }
+          us.dispose();
+        }
+      }).start();
     }
   }
 
index 2e9731d..184fdc5 100644 (file)
@@ -1019,7 +1019,7 @@ public class FeatureSettings extends JPanel
       }
     } catch (Exception ex)
     {
-      System.out.println("Error loading User Colour File\n" + ex);
+      jalview.bin.Console.outPrintln("Error loading User Colour File\n" + ex);
     }
   }
 
@@ -1608,7 +1608,7 @@ public class FeatureSettings extends JPanel
     {
       Color newColor = gcol.getMaxColour();
       comp.setBackground(newColor);
-      // System.err.println("Width is " + w / 2);
+      // jalview.bin.Console.errPrintln("Width is " + w / 2);
       Icon ficon = new FeatureIcon(gcol, comp.getBackground(), w, h, thr);
       comp.setIcon(ficon);
       // tt+="RGB value: Max (" + newColor.getRed() + ", "
index 09bb2a3..327f6ca 100644 (file)
@@ -1096,7 +1096,7 @@ public class FeatureTypeSettings extends JalviewDialog
   {
     if (featureSettings != null)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "IMPLEMENTATION ISSUE: overwriting action listener for FeatureColourChooser");
     }
     featureSettings = listener;
index 658b34f..8829be9 100644 (file)
@@ -133,7 +133,7 @@ public class Help
         hb.setCurrentID(id.getId());
       } catch (BadIDException bad)
       {
-        System.out.println("Bad help link: " + id.getId()
+        jalview.bin.Console.outPrintln("Bad help link: " + id.getId()
                 + ": must match a target in help.jhm");
         throw bad;
       }
index c94dee0..eb0715a 100755 (executable)
@@ -22,6 +22,7 @@ package jalview.gui;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
+import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Graphics;
@@ -382,6 +383,12 @@ public class IdCanvas extends JPanel implements ViewportListenerI
   void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport,
           int startSeq, int pageHeight)
   {
+    drawIdsWrapped(g, alignViewport, startSeq, pageHeight, -1);
+  }
+
+  void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport,
+          int startSeq, int pageHeight, int idWidth)
+  {
     int alignmentWidth = alignViewport.getAlignment().getWidth();
     final int alheight = alignViewport.getAlignment().getHeight();
 
@@ -428,8 +435,23 @@ public class IdCanvas extends JPanel implements ViewportListenerI
 
       if (labels != null && alignViewport.isShowAnnotation())
       {
+        int getWidth = getWidth();
+        int thisIdWidth = getWidth;
         g.translate(0, ypos + (alheight * charHeight));
-        labels.drawComponent(g, getWidth());
+        if (!manuallyAdjusted())
+        {
+          int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false,
+                  null);
+          thisIdWidth = idWidth < 0 ? getAnnotationsIdWidth : idWidth;
+          if (thisIdWidth > getWidth)
+          {
+            this.setPreferredSize(
+                    new Dimension(thisIdWidth, this.getHeight()));
+            this.repaint();
+            alignViewport.setIdWidth(thisIdWidth);
+          }
+        }
+        labels.drawComponent(g, false, thisIdWidth);
         g.translate(0, -ypos - (alheight * charHeight));
       }
 
@@ -585,4 +607,16 @@ public class IdCanvas extends JPanel implements ViewportListenerI
       repaint();
     }
   }
+
+  private boolean manuallyAdjusted = false;
+
+  public boolean manuallyAdjusted()
+  {
+    return manuallyAdjusted;
+  }
+
+  public void setManuallyAdjusted(boolean b)
+  {
+    manuallyAdjusted = b;
+  }
 }
index 4ba0699..4596e1f 100755 (executable)
@@ -20,8 +20,6 @@
  */
 package jalview.gui;
 
-import jalview.api.AlignViewportI;
-
 import java.awt.Color;
 import java.awt.Cursor;
 import java.awt.Graphics;
@@ -31,6 +29,9 @@ import java.awt.event.MouseMotionListener;
 
 import javax.swing.JPanel;
 
+import jalview.api.AlignViewportI;
+import jalview.bin.Cache;
+
 /**
  * DOCUMENT ME!
  * 
@@ -136,6 +137,18 @@ public class IdwidthAdjuster extends JPanel
       return;
     }
 
+    /*
+     * don't allow residue width to be < 1 in wrapped format
+     */
+    if (viewport.getWrapAlignment())
+    {
+      SeqCanvas sc = ap.getSeqPanel().seqCanvas;
+      if (sc != null && sc.getWrappedCanvasWidth(sc.getWidth() - dif) < 1)
+      {
+        return;
+      }
+    }
+
     oldX = evt.getX();
 
     /*
@@ -146,9 +159,29 @@ public class IdwidthAdjuster extends JPanel
       return;
     }
     viewport.setIdWidth(newWidth);
+    ap.validateAnnotationDimensions(false);
+    ap.paintAlignment(true, false);
+
+    ap.getIdPanel().getIdCanvas().setManuallyAdjusted(true);
+  }
+
+  public void setWidth(int newWidth)
+  {
+    if (newWidth < MIN_ID_WIDTH
+            || ap.getIdPanel().getIdCanvas().manuallyAdjusted())
+    {
+      return;
+    }
+    final AlignViewportI viewport = ap.getAlignViewport();
+    viewport.setIdWidth(newWidth);
     ap.paintAlignment(true, false);
   }
 
+  public boolean manuallyAdjusted()
+  {
+    return ap.getIdPanel().getIdCanvas().manuallyAdjusted();
+  }
+
   @Override
   public void mouseMoved(MouseEvent evt)
   {
@@ -167,8 +200,21 @@ public class IdwidthAdjuster extends JPanel
   @Override
   public void paintComponent(Graphics g)
   {
+    int width = getWidth();
+    int height = getHeight();
     g.setColor(Color.white);
-    g.fillRect(0, 0, getWidth(), getHeight());
+    g.fillRect(0, 0, width, height);
+
+    if (!Cache.getDefault(AnnotationLabels.RESIZE_MARGINS_MARK_PREF, false))
+    // && !ap.getAlignViewport().getWrapAlignment()) // now allowing adjustment
+    // in wrap mode
+    {
+      int spacer = Math.max(2, AnnotationLabels.HEIGHT_ADJUSTER_HEIGHT / 4);
+      g.setColor(Color.LIGHT_GRAY);
+      g.drawLine(width - 3 * spacer, 0, width - 3 * spacer, height / 2);
+      g.drawLine(width - spacer, 0, width - spacer, height / 2);
+    }
+
     setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
   }
 }
index f337b39..4ea30d9 100644 (file)
@@ -124,6 +124,11 @@ public class ImageExporter
      */
     if (file == null && !Jalview.isHeadlessMode())
     {
+      if (Desktop.instance.isInBatchMode())
+      {
+        // defensive error report - we could wait for user input.. I  guess ?
+        throw(new ImageOutputException("Need an output file to render to when exporting images in batch mode!"));
+      }
       JalviewFileChooser chooser = imageType.getFileChooser();
       chooser.setFileView(new JalviewFileView());
       MessageManager.formatMessage("label.create_image_of",
index 327eade..9ae764e 100644 (file)
@@ -122,7 +122,7 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener
         }
         else
         {
-          System.err.println("dupe ig for : " + dbs[i] + " \t"
+          jalview.bin.Console.errPrintln("dupe ig for : " + dbs[i] + " \t"
                   + dbp.getDbName() + " (" + dbp.getDbSource() + ")");
           source.remove(tn);
         }
@@ -552,7 +552,7 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener
   @Override
   public void setVisible(boolean arg0)
   {
-    System.out.println("setVisible: " + arg0);
+    jalview.bin.Console.outPrintln("setVisible: " + arg0);
     super.setVisible(arg0);
   }
 }
index 5da37fe..eaaa2a1 100644 (file)
@@ -718,7 +718,7 @@ public class JvOptionPane extends JOptionPane
 
   private static void outputMessage(Object message)
   {
-    System.out.println(">>> JOption Message : " + message.toString());
+    jalview.bin.Console.outPrintln(">>> JOption Message : " + message.toString());
   }
 
   public static Object getMockResponse()
@@ -1137,7 +1137,13 @@ public class JvOptionPane extends JOptionPane
 
   private void internalDialogHandleResponse()
   {
-    String responseString = (String) this.getValue();
+    Object value = this.getValue();
+    if (value == null
+            || (value instanceof Integer && (Integer) value == -1))
+    {
+      return;
+    }
+    String responseString = value.toString();
     int response = ourOptions.indexOf(responseString);
 
     if (!Platform.isJS())
index e0427cc..f05110f 100644 (file)
@@ -713,7 +713,7 @@ public class OptsAndParamsPage
             }
           } catch (NumberFormatException e)
           {
-            System.err.println(e.toString());
+            jalview.bin.Console.errPrintln(e.toString());
           }
           if (minValue != null || maxValue != null)
           {
@@ -750,7 +750,7 @@ public class OptsAndParamsPage
             }
           } catch (NumberFormatException e)
           {
-            System.err.println(e.toString());
+            jalview.bin.Console.errPrintln(e.toString());
           }
           if (minValue != null && maxValue != null)
           {
index 953fdc5..36849b0 100755 (executable)
@@ -194,7 +194,7 @@ public class PaintRefresher
           {
             // raise an implementation warning here - not sure if this situation
             // will ever occur
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "IMPLEMENTATION PROBLEM: DATASET out of sync due to an insert whilst calling PaintRefresher.validateSequences(AlignmentI, ALignmentI)");
           }
           List<SequenceI> alsq = comp.getSequences();
index c4b5367..b5b6ffc 100755 (executable)
@@ -104,7 +104,7 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
 
         if (!first)
         {
-          System.out.println(DASHES);
+          jalview.bin.Console.outPrintln(DASHES);
           textarea.append(DASHES);
         }
         first = false;
@@ -139,7 +139,7 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
 
     for (int i = 0; i < seqs.length; i++)
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               String.format("%3d %s", i + 1, seqs[i].getDisplayId(true)));
     }
 
@@ -151,7 +151,7 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
     {
       System.out.print(String.format("%7d", i + 1));
     }
-    System.out.println();
+    jalview.bin.Console.outPrintln();
 
     for (int i = 0; i < seqs.length; i++)
     {
@@ -163,10 +163,10 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
          */
         System.out.print(String.format("%7.3f", scores[i][j] / totscore));
       }
-      System.out.println();
+      jalview.bin.Console.outPrintln();
     }
 
-    System.out.println("\n");
+    jalview.bin.Console.outPrintln("\n");
   }
 
   /**
index be9293f..7e86704 100644 (file)
@@ -1734,10 +1734,9 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
   protected void addReferenceAnnotations_actionPerformed(
           Map<SequenceI, List<AlignmentAnnotation>> candidates)
   {
-    final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup();
     final AlignmentI alignment = this.ap.getAlignment();
     AlignmentUtils.addReferenceAnnotations(candidates, alignment,
-            selectionGroup);
+            null);
     refresh();
   }
 
@@ -2190,7 +2189,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
 
     String[] omitHidden = null;
 
-    System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
+    jalview.bin.Console.outPrintln("PROMPT USER HERE"); // TODO: decide if a prompt happens
     // or we simply trust the user wants
     // wysiwig behaviour
 
index 011d810..d68d95f 100644 (file)
@@ -231,7 +231,7 @@ public class ProgressBar implements IProgressIndicator
         final JPanel progressPanel = progressBars.get(id);
         if (progressPanel == null)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "call setProgressBar before registering the progress bar's handler.");
           return;
         }
index 705102a..62dce24 100644 (file)
@@ -121,7 +121,7 @@ public class PymolBindingModel extends AAStructureBindingModel
   protected List<String> executeCommand(StructureCommandI command,
           boolean getReply)
   {
-    // System.out.println(command.toString()); // debug
+    // jalview.bin.Console.outPrintln(command.toString()); // debug
     return pymolManager.sendCommand(command, getReply);
   }
 
index 8d66a44..f487011 100755 (executable)
@@ -184,7 +184,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
 
     validate();
     sliderValueChanged();
-    // System.out.println((System.currentTimeMillis()-start));
+    // jalview.bin.Console.outPrintln((System.currentTimeMillis()-start));
   }
 
   void sliderValueChanged()
index 8ae5408..9b199fd 100644 (file)
@@ -53,7 +53,7 @@ public class RestInputParamEditDialog extends GRestInputParamEditDialog
               .newInstance());
     } catch (Throwable x)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Unexpected exception when instantiating rest input type.");
       x.printStackTrace();
     }
@@ -166,7 +166,7 @@ public class RestInputParamEditDialog extends GRestInputParamEditDialog
           updated = true;
         } catch (InvalidArgumentException ex)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "IMPLEMENTATION ERROR: Invalid argument for type : "
                           + typeList.getSelectedValue() + "\n");
           ex.printStackTrace();
@@ -215,7 +215,7 @@ public class RestInputParamEditDialog extends GRestInputParamEditDialog
         types.add(jtype.getURLtokenPrefix());
       } catch (Throwable x)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Unexpected exception when instantiating rest input type.");
         x.printStackTrace();
       }
index cda76d9..8953626 100644 (file)
@@ -363,7 +363,7 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
                 mtch.group(2) + ":" + mtch.group(3), mtch.group(1),
                 mtch.group(2), mtch.group(3), inputTypes, warnings))
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "IMPLEMENTATION PROBLEM: Cannot parse RestService input parameter string '"
                           + its + "'" + "\n" + warnings);
         }
@@ -389,7 +389,7 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
         } catch (Throwable x)
         {
 
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "IMPLEMENTATION PROBLEM: Cannot parse RestService output parameter string '"
                           + its + "'" + "\n" + warnings);
         }
@@ -399,7 +399,7 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
     }
     else
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "IMPLEMENTATION PROBLEM: Restservice generated from GUI is invalid\n"
                       + warnings);
 
index d15cdcf..0faedb0 100755 (executable)
@@ -343,7 +343,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
         }
       }
 
-      // System.err.println(">>> FastPaint to " + transX + " " + transY + " "
+      // jalview.bin.Console.errPrintln(">>> FastPaint to " + transX + " " + transY + " "
       // + horizontal + " " + vertical + " " + startRes + " " + endRes
       // + " " + startSeq + " " + endSeq);
 
@@ -362,7 +362,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
       // Call repaint on alignment panel so that repaints from other alignment
       // panel components can be aggregated. Otherwise performance of the
       // overview window and others may be adversely affected.
-      // System.out.println("SeqCanvas fastPaint() repaint() request...");
+      // jalview.bin.Console.outPrintln("SeqCanvas fastPaint() repaint() request...");
       av.getAlignPanel().repaint();
     } finally
     {
@@ -550,6 +550,20 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
     return (canvasWidth - labelWidthEast - labelWidthWest) / charWidth;
   }
 
+  public int getMinimumWrappedCanvasWidth()
+  {
+    int charWidth = av.getCharWidth();
+    FontMetrics fm = getFontMetrics(av.getFont());
+    int labelWidth = 0;
+    if (av.getScaleRightWrapped() || av.getScaleLeftWrapped())
+    {
+      labelWidth = getLabelWidth(fm);
+    }
+    labelWidthEast = av.getScaleRightWrapped() ? labelWidth : 0;
+    labelWidthWest = av.getScaleLeftWrapped() ? labelWidth : 0;
+    return labelWidthEast + labelWidthWest + charWidth;
+  }
+
   /**
    * Returns a pixel width sufficient to show the largest sequence coordinate
    * (end position) in the alignment, calculated as the FontMetrics width of
@@ -1665,7 +1679,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
   public void propertyChange(PropertyChangeEvent evt)
   {
     String eventName = evt.getPropertyName();
-    // System.err.println(">>SeqCanvas propertyChange " + eventName);
+    // jalview.bin.Console.errPrintln(">>SeqCanvas propertyChange " + eventName);
     if (eventName.equals(SequenceGroup.SEQ_GROUP_CHANGED))
     {
       fastPaint = true;
@@ -1675,7 +1689,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
     else if (eventName.equals(ViewportRanges.MOVE_VIEWPORT))
     {
       fastPaint = false;
-      // System.err.println("!!!! fastPaint false from MOVE_VIEWPORT");
+      // jalview.bin.Console.errPrintln("!!!! fastPaint false from MOVE_VIEWPORT");
       repaint();
       return;
     }
index c0a86df..3560efd 100755 (executable)
@@ -377,7 +377,7 @@ public class SeqCanvas extends JComponent
       } catch (OutOfMemoryError er)
       {
         System.gc();
-        System.err.println("SeqCanvas OutOfMemory Redraw Error.\n" + er);
+        jalview.bin.Console.errPrintln("SeqCanvas OutOfMemory Redraw Error.\n" + er);
         new OOMWarning("Creating alignment image for display", er);
 
         return;
index 55f06fc..ce60be6 100644 (file)
@@ -137,7 +137,7 @@ public class SeqPanel extends JPanel
       MousePos o = (MousePos) obj;
       boolean b = (column == o.column && seqIndex == o.seqIndex
               && annotationIndex == o.annotationIndex);
-      // System.out.println(obj + (b ? "= " : "!= ") + this);
+      // jalview.bin.Console.outPrintln(obj + (b ? "= " : "!= ") + this);
       return b;
     }
 
@@ -881,7 +881,7 @@ public class SeqPanel extends JPanel
 
     if (lastMessage == null || !lastMessage.equals(tmp))
     {
-      // System.err.println("mouseOver Sequence: "+tmp);
+      // jalview.bin.Console.errPrintln("mouseOver Sequence: "+tmp);
       ssm.mouseOverSequence(sequence, index, pos, av);
     }
     lastMessage = tmp;
@@ -1006,7 +1006,7 @@ public class SeqPanel extends JPanel
   @Override
   public void updateColours(SequenceI seq, int index)
   {
-    System.out.println("update the seqPanel colours");
+    jalview.bin.Console.outPrintln("update the seqPanel colours");
     // repaint();
   }
 
@@ -2861,7 +2861,7 @@ public class SeqPanel extends JPanel
     if (copycolsel && av.hasHiddenColumns()
             && (av.getAlignment().getHiddenColumns() == null))
     {
-      System.err.println("Bad things");
+      jalview.bin.Console.errPrintln("Bad things");
     }
     if (repaint) // always true!
     {
index 6b4c74a..137655f 100755 (executable)
@@ -599,7 +599,7 @@ public class SequenceFetcher extends JPanel implements Runnable
                 + ((StringPair) database.getSelectedItem()).getDisplay());
         // error
         // +="Couldn't retrieve sequences from "+database.getSelectedItem();
-        System.err.println("Retrieval failed for source ='"
+        jalview.bin.Console.errPrintln("Retrieval failed for source ='"
                 + ((StringPair) database.getSelectedItem()).getDisplay()
                 + "' and query\n'" + textArea.getText() + "'\n");
         e.printStackTrace();
index 0b7af0d..ff409e0 100755 (executable)
@@ -172,7 +172,7 @@ public class SplashScreen extends JPanel
           }
           if (mt.isErrorAny())
           {
-            System.err.println("Error when loading images!");
+            jalview.bin.Console.errPrintln("Error when loading images!");
           }
         } while (!mt.checkAll());
         Desktop.instance.setIconImages(ChannelProperties.getIconList());
@@ -228,7 +228,7 @@ public class SplashScreen extends JPanel
   protected boolean refreshText()
   {
     String newtext = Desktop.instance.getAboutMessage();
-    // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
+    // jalview.bin.Console.errPrintln("Text found: \n"+newtext+"\nEnd of newtext.");
     if (oldTextLength != newtext.length())
     {
       iframe.setVisible(false);
index 6fce984..d00b1c2 100644 (file)
@@ -71,7 +71,6 @@ import jalview.gui.structurechooser.PDBStructureChooserQuerySource;
 import jalview.gui.structurechooser.StructureChooserQuerySource;
 import jalview.gui.structurechooser.ThreeDBStructureChooserQuerySource;
 import jalview.io.DataSourceType;
-import jalview.io.FileFormatException;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
 import jalview.jbgui.FilterOption;
@@ -85,7 +84,6 @@ import jalview.util.StringUtils;
 import jalview.ws.DBRefFetcher;
 import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
 import jalview.ws.datamodel.alphafold.PAEContactMatrix;
-import jalview.ws.dbsources.EBIAlfaFold;
 import jalview.ws.seqfetcher.DbSourceProxy;
 import jalview.ws.sifts.SiftsSettings;
 
@@ -1525,7 +1523,7 @@ public class StructureChooser extends GStructureChooser
             // for moment, it will work fine as is because it is self-contained
             String searchTerm = text.toLowerCase(Locale.ROOT);
             searchTerm = searchTerm.split(":")[0];
-            // System.out.println(">>>>> search term : " + searchTerm);
+            // jalview.bin.Console.outPrintln(">>>>> search term : " + searchTerm);
             List<FTSDataColumnI> wantedFields = new ArrayList<>();
             FTSRestRequest pdbRequest = new FTSRestRequest();
             pdbRequest.setAllowEmptySeq(false);
@@ -1801,7 +1799,9 @@ public class StructureChooser extends GStructureChooser
     sc.mainFrame.dispose();
 
     if (showRefAnnotations)
+    {
       showReferenceAnnotationsForSequence(ap.alignFrame, seq);
+    }
 
     return sv;
   }
index 6cef665..ad3fc6a 100644 (file)
 package jalview.gui;
 
 import java.util.ArrayList;
+import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
 
@@ -66,7 +68,27 @@ public class StructureViewer
 
   public enum ViewerType
   {
-    JMOL, CHIMERA, CHIMERAX, PYMOL
+    JMOL, CHIMERA, CHIMERAX, PYMOL;
+
+    public static ViewerType getFromString(String viewerString)
+    {
+      ViewerType viewerType = null;
+      if (!"none".equals(viewerString))
+      {
+        for (ViewerType v : EnumSet.allOf(ViewerType.class))
+        {
+          String name = v.name().toLowerCase(Locale.ROOT).replaceAll(" ",
+                  "");
+          if (viewerString.equals(name))
+          {
+            viewerType = v;
+            break;
+          }
+        }
+      }
+      return viewerType;
+    }
+
   };
 
   /**
index 01a3c2d..b8d2cce 100644 (file)
@@ -1197,7 +1197,7 @@ public abstract class StructureViewerBase extends GStructureViewer
       }
     } catch (Exception e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Error retrieving PDB id " + pdbid + ": " + e.getMessage());
     } finally
     {
index 55ce44a..6fbd422 100755 (executable)
@@ -53,6 +53,7 @@ import javax.swing.ToolTipManager;
 import jalview.analysis.Conservation;
 import jalview.analysis.TreeModel;
 import jalview.api.AlignViewportI;
+import jalview.bin.Console;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.BinaryNode;
@@ -66,6 +67,7 @@ import jalview.datamodel.SequenceNode;
 import jalview.gui.JalviewColourChooser.ColourChooserListener;
 import jalview.schemes.ColourSchemeI;
 import jalview.structure.SelectionSource;
+import jalview.util.ColorUtils;
 import jalview.util.Format;
 import jalview.util.MessageManager;
 import jalview.ws.datamodel.MappableContactMatrixI;
@@ -221,6 +223,13 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
     boolean has_placeholders = false;
     longestName = "";
 
+    AlignmentAnnotation aa = tp.getAssocAnnotation();
+    ContactMatrixI cm = (aa!=null) ? av.getContactMatrix(aa) : null;
+    if (cm!=null && cm.hasCutHeight())
+    {
+      threshold=(float) cm.getCutHeight();
+    }
+    
     for (int i = 0; i < leaves.size(); i++)
     {
       BinaryNode lf = leaves.elementAt(i);
@@ -236,6 +245,14 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
         longestName = TreeCanvas.PLACEHOLDER
                 + ((Sequence) lf.element()).getName();
       }
+      if (tp.isColumnWise() && cm!=null)
+      {
+        // get color from group colours, if they are set for the matrix
+        try {
+          Color col = cm.getGroupColorForPosition(parseColumnNode(lf));
+          setColor(lf,col.brighter());
+        } catch (NumberFormatException ex) {};
+      }
     }
 
     setMarkPlaceholders(has_placeholders);
@@ -259,7 +276,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
    * @param offy
    *          DOCUMENT ME!
    */
-  public void drawNode(Graphics g, BinaryNode node, float chunk,
+  public void drawNode(Graphics g, BinaryNode node, double chunk,
           double wscale, int width, int offx, int offy)
   {
     if (node == null)
@@ -778,7 +795,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
               + ((BinaryNode) top.right()).count;
     }
 
-    float chunk = (float) (height - (offy)) / top.count;
+    double chunk = (double) (height - (offy)) / (double)top.count;
 
     drawNode(g2, tree.getTopNode(), chunk, wscale, width, offx, offy);
 
@@ -1025,7 +1042,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
           threshold = 0f;
         }
       }
-
+      Console.log.debug("Tree cut threshold set at:" + threshold);
       PaintRefresher.Refresh(tp,
               getAssociatedPanel().av.getSequenceSetId());
       repaint();
@@ -1040,8 +1057,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
     Map<BitSet, Color> colors = new HashMap();
     for (int i = 0; i < groups.size(); i++)
     {
-      Color col = new Color((int) (Math.random() * 255),
-              (int) (Math.random() * 255), (int) (Math.random() * 255));
+      Color col = ColorUtils.getARandomColor();
+      
       setColor(groups.get(i), col.brighter());
 
       Vector<BinaryNode> l = tree.findLeaves(groups.get(i));
@@ -1071,41 +1088,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
             cm.setColorForGroup(gp, colors.get(gp));
           }
         }
-        // stash colors in linked annotation row.
-        // doesn't work yet. TESTS!
-        int sstart = aa.sequenceRef != null ? aa.sequenceRef.getStart() - 1
-                : 0;
-        Annotation ae;
-        Color gpcol = null;
-        int[] seqpos = null;
-        for (BitSet gp : colors.keySet())
-        {
-          gpcol = colors.get(gp);
-          for (int p = gp.nextSetBit(0); p >= 0
-                  && p < Integer.MAX_VALUE; p = gp.nextSetBit(p + 1))
-          {
-            if (cm instanceof MappableContactMatrixI)
-            {
-              MappableContactMatrixI mcm = (MappableContactMatrixI) cm;
-              seqpos = mcm.getMappedPositionsFor(aa.sequenceRef, p);
-              if (seqpos == null)
-              {
-                // no mapping for this column.
-                continue;
-              }
-              // TODO: handle ranges...
-              ae = aa.getAnnotationForPosition(seqpos[0]);
-            }
-            else
-            {
-              ae = aa.getAnnotationForPosition(p + sstart);
-            }
-            if (ae != null)
-            {
-              ae.colour = gpcol.brighter().darker();
-            }
-          }
-        }
+        cm.transferGroupColorsTo(aa);
       }
     }
 
@@ -1123,15 +1106,18 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
       }
     }
   }
-
+  private int parseColumnNode(BinaryNode bn) throws NumberFormatException
+  {
+    return Integer.parseInt(
+            bn.getName().substring(bn.getName().indexOf("c") + 1));
+  }
   private boolean isColumnForNodeSelected(BinaryNode bn)
   {
     SequenceI rseq = tp.assocAnnotation.sequenceRef;
     int colm = -1;
     try
     {
-      colm = Integer.parseInt(
-              bn.getName().substring(bn.getName().indexOf("c") + 1));
+      colm = parseColumnNode(bn);
     } catch (Exception e)
     {
       return false;
@@ -1198,8 +1184,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
         // parse out from nodename
         try
         {
-          colm = Integer.parseInt(
-                  bn.getName().substring(bn.getName().indexOf("c") + 1));
+          colm = parseColumnNode(bn);
         } catch (Exception e)
         {
           continue;
@@ -1244,14 +1229,14 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
       if (mcm!=null)
       {
         int[] seqpos = mcm.getMappedPositionsFor(
-                tp.assocAnnotation.sequenceRef, colm);
+                rseq, colm);
         if (seqpos == null)
         {
           // no mapping for this column.
           continue;
         }
         // TODO: handle ranges...
-        offp = seqpos[0]-1;
+        offp = rseq.findIndex(seqpos[0])-1;
       }
       else
       {
index 5ccd68d..0a0c1b8 100755 (executable)
@@ -179,17 +179,18 @@ public class TreePanel extends GTreePanel
     this.treeType = type;
     this.scoreModelName = modelName;
 
+    treeCanvas = new TreeCanvas(this, ap, scrollPane);
+    scrollPane.setViewportView(treeCanvas);
+    
     if (columnWise)
     {
       bootstrapMenu.setVisible(false);
-      placeholdersMenu.setSelected(false);
+      placeholdersMenu.setState(false);
       placeholdersMenu.setVisible(false);
-      fitToWindow.setSelected(false);
+      fitToWindow.setState(false);
       sortAssocViews.setVisible(false);
     }
 
-    treeCanvas = new TreeCanvas(this, ap, scrollPane);
-    scrollPane.setViewportView(treeCanvas);
 
     addKeyListener(new KeyAdapter()
     {
@@ -260,7 +261,7 @@ public class TreePanel extends GTreePanel
         {
           if (tree == null)
           {
-            System.out.println("tree is null");
+            jalview.bin.Console.outPrintln("tree is null");
             // TODO: deal with case when a change event is received whilst a
             // tree is still being calculated - should save reference for
             // processing message later.
@@ -268,7 +269,7 @@ public class TreePanel extends GTreePanel
           }
           if (evt.getNewValue() == null)
           {
-            System.out.println(
+            jalview.bin.Console.outPrintln(
                     "new alignment sequences vector value is null");
           }
 
@@ -391,9 +392,9 @@ public class TreePanel extends GTreePanel
                 ? new NJTree(av, sm, similarityParams)
                 : new AverageDistanceTree(av, sm, similarityParams);
         tree = new TreeModel(njtree);
-        showDistances(true);
+        // don't display distances for columnwise trees        
       }
-
+      showDistances(!columnWise);
       tree.reCount(tree.getTopNode());
       tree.findHeight(tree.getTopNode());
       treeCanvas.setTree(tree);
@@ -895,7 +896,7 @@ public class TreePanel extends GTreePanel
       pg.close();
     } catch (Exception ex)
     {
-      System.err.println("Error writing tree as EPS");
+      jalview.bin.Console.errPrintln("Error writing tree as EPS");
       ex.printStackTrace();
     }
   }
index 8a8ba8d..28f6c59 100644 (file)
@@ -614,7 +614,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
       cdoc = null;
     } catch (Exception ee)
     {
-      System.err.println("Exception whilst updating :");
+      jalview.bin.Console.errPrintln("Exception whilst updating :");
       ee.printStackTrace(System.err);
       // recover object map backup, since its probably corrupted with references
       // to Vobjects that don't exist anymore.
@@ -803,7 +803,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
               // we only care about AlignmentSequence selections
               SelectionMessage sm = (SelectionMessage) message;
               sm.validate();
-              System.err.println("Received\n" + sm.getRawMessage());
+              jalview.bin.Console.errPrintln("Received\n" + sm.getRawMessage());
               Object[] jvobjs = sm.getVorbaIDs() == null ? null
                       : new Object[sm.getVorbaIDs().length];
               if (jvobjs == null)
index 7eeee9a..961caa7 100644 (file)
@@ -359,7 +359,7 @@ public class WebserviceInfo extends GWebserviceInfo
       @Override
       public void internalFrameClosed(InternalFrameEvent evt)
       {
-        // System.out.println("Shutting down webservice client");
+        // jalview.bin.Console.outPrintln("Shutting down webservice client");
         WSClientI service = thisinfo.getthisService();
         if (service != null && service.isCancellable())
         {
index e1613da..196eb32 100644 (file)
@@ -493,7 +493,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
     else
     {
       // TODO: show warning
-      System.err.println("Invalid name. Not saved.");
+      jalview.bin.Console.errPrintln("Invalid name. Not saved.");
     }
   }
 
@@ -642,7 +642,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
           }
           else
           {
-            System.err.println("Ignoring unknown service argument type "
+            jalview.bin.Console.errPrintln("Ignoring unknown service argument type "
                     + myarg.getClass().getName());
           }
         }
@@ -685,7 +685,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
         {
           if (arg instanceof OptionI)
           {
-            // System.out.println("Setting option "
+            // jalview.bin.Console.outPrintln("Setting option "
             // + System.identityHashCode(arg) + ":" + arg.getName()
             // + " with " + arg.getDefaultValue());
             opanp.selectOption((OptionI) arg, arg.getValue());
@@ -874,7 +874,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
         if (cw + 120 > panewidth)
         {
           jobOptions.add(pbox, "wrap");
-          // System.out.println("Wrap on "+pbox.option.getName());
+          // jalview.bin.Console.outPrintln("Wrap on "+pbox.option.getName());
           cw = hgap + pbox.getSize().width;
           fh = true;
         }
@@ -946,7 +946,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
     }
     // TODO: waste some time trying to eliminate any unnecessary .validate calls
     // here
-    // System.out.println("Size will be : "+w+","+os);
+    // jalview.bin.Console.outPrintln("Size will be : "+w+","+os);
     // optsAndparams.setPreferredSize(null);
     // paramPane.getViewport().setView(optsAndparams);
     paramPane.getViewport().setAutoscrolls(true);
@@ -976,7 +976,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
       disc.run();
     } catch (Exception e)
     {
-      System.err.println("Aborting. Problem discovering services.");
+      jalview.bin.Console.errPrintln("Aborting. Problem discovering services.");
       e.printStackTrace();
       return;
     }
@@ -1023,7 +1023,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
               pr = en.next();
             }
             {
-              System.out.println("Testing opts dupes for "
+              jalview.bin.Console.outPrintln("Testing opts dupes for "
                       + lastserv.getUri() + " : " + lastserv.getActionText()
                       + ":" + pr.getName());
               List<Option> rg = lastserv.getRunnerConfig().getOptions();
@@ -1034,17 +1034,17 @@ public class WsJobParameters extends JPanel implements ItemListener,
                   Option cpy = jalview.ws.jws2.ParameterUtils.copyOption(o);
                 } catch (Exception e)
                 {
-                  System.err.println("Failed to copy " + o.getName());
+                  jalview.bin.Console.errPrintln("Failed to copy " + o.getName());
                   e.printStackTrace();
                 } catch (Error e)
                 {
-                  System.err.println("Failed to copy " + o.getName());
+                  jalview.bin.Console.errPrintln("Failed to copy " + o.getName());
                   e.printStackTrace();
                 }
               }
             }
             {
-              System.out.println("Testing param dupes:");
+              jalview.bin.Console.outPrintln("Testing param dupes:");
               List<Parameter> rg = lastserv.getRunnerConfig()
                       .getParameters();
               for (Parameter o : rg)
@@ -1055,17 +1055,17 @@ public class WsJobParameters extends JPanel implements ItemListener,
                           .copyParameter(o);
                 } catch (Exception e)
                 {
-                  System.err.println("Failed to copy " + o.getName());
+                  jalview.bin.Console.errPrintln("Failed to copy " + o.getName());
                   e.printStackTrace();
                 } catch (Error e)
                 {
-                  System.err.println("Failed to copy " + o.getName());
+                  jalview.bin.Console.errPrintln("Failed to copy " + o.getName());
                   e.printStackTrace();
                 }
               }
             }
             {
-              System.out.println("Testing param write:");
+              jalview.bin.Console.outPrintln("Testing param write:");
               List<String> writeparam = null, readparam = null;
               try
               {
@@ -1073,7 +1073,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
                         .writeParameterSet(
                                 pr.getArguments(lastserv.getRunnerConfig()),
                                 " ");
-                System.out.println("Testing param read :");
+                jalview.bin.Console.outPrintln("Testing param read :");
                 List<Option> pset = jalview.ws.jws2.ParameterUtils
                         .processParameters(writeparam,
                                 lastserv.getRunnerConfig(), " ");
@@ -1087,7 +1087,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
                   String on = o.next(), sn = s.next(), st = t.next();
                   if (!sn.equals(st))
                   {
-                    System.out.println(
+                    jalview.bin.Console.outPrintln(
                             "Original was " + on + " Phase 1 wrote " + sn
                                     + "\tPhase 2 wrote " + st);
                     failed = true;
@@ -1095,11 +1095,11 @@ public class WsJobParameters extends JPanel implements ItemListener,
                 }
                 if (failed)
                 {
-                  System.out.println(
+                  jalview.bin.Console.outPrintln(
                           "Original parameters:\n" + pr.getOptions());
-                  System.out.println(
+                  jalview.bin.Console.outPrintln(
                           "Wrote parameters in first set:\n" + writeparam);
-                  System.out.println(
+                  jalview.bin.Console.outPrintln(
                           "Wrote parameters in second set:\n" + readparam);
 
                 }
@@ -1223,7 +1223,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
    * + storeSetName + ": ", jobParams); }
    * 
    * private void writeParam(String nm, List<ArgumentI> params) { for (ArgumentI
-   * p : params) { System.out.println(nm + ":" + System.identityHashCode(p) +
+   * p : params) { jalview.bin.Console.outPrintln(nm + ":" + System.identityHashCode(p) +
    * " Name: " + p.getName() + " Value: " + p.getDefaultValue()); } }
    * 
    * private Object[] _getUserPreset(String setName) { Object[] pset =
@@ -1376,7 +1376,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
         return;
       }
       settingDialog = true;
-      System.out.println("Prompting to save " + lsetname);
+      jalview.bin.Console.outPrintln("Prompting to save " + lsetname);
       if (JvOptionPane.showConfirmDialog(this, "Parameter set '" + lsetname
               + "' is modifed, and your changes will be lost.\nReally change preset ?",
               "Warning: Unsaved Changes",
@@ -1388,7 +1388,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
         settingDialog = false;
         // and leave.
         return;
-        // System.out.println("Saving for " + lsetname);
+        // jalview.bin.Console.outPrintln("Saving for " + lsetname);
         // _storeCurrentPreset(lsetname);
 
       }
@@ -1467,7 +1467,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
           return;
         }
         curSetName = newname;
-        System.err.println("New name for user setting " + curSetName
+        jalview.bin.Console.errPrintln("New name for user setting " + curSetName
                 + " (was " + setName.getSelectedItem() + ")");
         if (curSetName.equals(setName.getSelectedItem()))
         {
index 8555a78..76479e2 100644 (file)
@@ -150,7 +150,7 @@ public class PDBStructureChooserQuerySource
       String[] names = seqName.toLowerCase(Locale.ROOT).split("\\|");
       for (String name : names)
       {
-        // System.out.println("Found name : " + name);
+        // jalview.bin.Console.outPrintln("Found name : " + name);
         name.trim();
         if (isValidSeqName(name))
         {
@@ -196,7 +196,7 @@ public class PDBStructureChooserQuerySource
    */
   static boolean isValidSeqName(String seqName)
   {
-    // System.out.println("seqName : " + seqName);
+    // jalview.bin.Console.outPrintln("seqName : " + seqName);
     String ignoreList = "pdb,uniprot,swiss-prot";
     if (seqName.length() < 3)
     {
index cdf0d57..253c8dc 100644 (file)
@@ -120,7 +120,7 @@ public abstract class StructureChooserQuerySource
    */
   static boolean isValidSeqName(String seqName)
   {
-    // System.out.println("seqName : " + seqName);
+    // jalview.bin.Console.outPrintln("seqName : " + seqName);
     String ignoreList = "pdb,uniprot,swiss-prot";
     if (seqName.length() < 3)
     {
index e817b26..1cc7be4 100644 (file)
@@ -113,7 +113,7 @@ public class TDBResultAnalyser
     int idx = EXP_CATEGORIES.indexOf(upper_cat);
     if (idx == -1)
     {
-      System.out.println("Unknown category: '" + cat + "'");
+      jalview.bin.Console.outPrintln("Unknown category: '" + cat + "'");
       EXP_CATEGORIES.add(upper_cat);
       idx = EXP_CATEGORIES.size() - 1;
     }
index cbc6add..e32ba50 100644 (file)
@@ -587,7 +587,7 @@ public class ThreeDBStructureChooserQuerySource
       {
         if (!hasPdbResp)
         {
-          System.out.println(
+          jalview.bin.Console.outPrintln(
                   "Warning: seems like we couldn't get to the PDBe search interface.");
         }
         else
index ece2df0..a6e96cb 100644 (file)
@@ -67,14 +67,14 @@ public abstract class AbstractRequestHandler extends AbstractHandler
       /*
        * Set server error status on response
        */
-      System.err.println("Exception handling request "
+      jalview.bin.Console.errPrintln("Exception handling request "
               + request.getRequestURI() + " : " + t.getMessage());
       if (response.isCommitted())
       {
         /*
          * Can't write an HTTP header once any response content has been written
          */
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Unable to return HTTP 500 as response already committed");
       }
       else
@@ -105,20 +105,20 @@ public abstract class AbstractRequestHandler extends AbstractHandler
    */
   protected void dumpRequest(HttpServletRequest request)
   {
-    System.out.println(request.getMethod());
-    System.out.println(request.getRequestURL());
+    jalview.bin.Console.outPrintln(request.getMethod());
+    jalview.bin.Console.outPrintln(request.getRequestURL());
     for (String hdr : Collections.list(request.getHeaderNames()))
     {
       for (String val : Collections.list(request.getHeaders(hdr)))
       {
-        System.out.println(hdr + ": " + val);
+        jalview.bin.Console.outPrintln(hdr + ": " + val);
       }
     }
     for (String param : Collections.list(request.getParameterNames()))
     {
       for (String val : request.getParameterValues(param))
       {
-        System.out.println(param + "=" + val);
+        jalview.bin.Console.outPrintln(param + "=" + val);
       }
     }
   }
@@ -143,7 +143,7 @@ public abstract class AbstractRequestHandler extends AbstractHandler
       stop();
     } catch (Exception e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Error stopping " + getName() + ": " + e.getMessage());
     }
   }
index a18d38d..b9adcc6 100644 (file)
@@ -150,13 +150,13 @@ public class HttpServer
       contextHandlers = new HandlerCollection(true);
       server.setHandler(contextHandlers);
       server.start();
-      // System.out.println(String.format(
+      // jalview.bin.Console.outPrintln(String.format(
       // "HttpServer started with %d threads", server.getThreadPool()
       // .getThreads()));
       contextRoot = server.getURI();
     } catch (Exception e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Error trying to start HttpServer: " + e.getMessage());
       try
       {
@@ -195,14 +195,14 @@ public class HttpServer
     {
       for (String val : Collections.list(request.getHeaders(hdr)))
       {
-        System.out.println(hdr + ": " + val);
+        jalview.bin.Console.outPrintln(hdr + ": " + val);
       }
     }
     for (String param : Collections.list(request.getParameterNames()))
     {
       for (String val : request.getParameterValues(param))
       {
-        System.out.println(param + "=" + val);
+        jalview.bin.Console.outPrintln(param + "=" + val);
       }
     }
   }
@@ -221,7 +221,7 @@ public class HttpServer
           server.stop();
         } catch (Exception e)
         {
-          System.err.println("Error stopping Http Server on "
+          jalview.bin.Console.errPrintln("Error stopping Http Server on "
                   + server.getURI() + ": " + e.getMessage());
         }
       }
@@ -267,12 +267,12 @@ public class HttpServer
       ch.start();
     } catch (Exception e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Error starting handler for " + path + ": " + e.getMessage());
     }
 
     handler.setUri(this.contextRoot + ch.getContextPath().substring(1));
-    System.out.println("Jalview " + handler.getName()
+    jalview.bin.Console.outPrintln("Jalview " + handler.getName()
             + " handler started on " + handler.getUri());
   }
 
@@ -293,7 +293,7 @@ public class HttpServer
     {
       contextHandlers.removeHandler(ch);
       myHandlers.remove(handler);
-      System.out.println("Stopped Jalview " + handler.getName()
+      jalview.bin.Console.outPrintln("Stopped Jalview " + handler.getName()
               + " handler on " + handler.getUri());
     }
   }
index 09859c9..7e2539f 100755 (executable)
@@ -317,7 +317,7 @@ public class AnnotationFile
               }
               else
               {
-                // System.err.println("Skipping NaN - not valid value.");
+                // jalview.bin.Console.errPrintln("Skipping NaN - not valid value.");
                 text.append(comma + 0f);// row.annotations[j].value);
               }
               comma = ",";
@@ -679,10 +679,10 @@ public class AnnotationFile
     } catch (Exception ex)
     {
       ex.printStackTrace();
-      System.out.println("Problem reading annotation file: " + ex);
+      jalview.bin.Console.outPrintln("Problem reading annotation file: " + ex);
       if (nlinesread > 0)
       {
-        System.out.println("Last read line " + nlinesread + ": '" + lastread
+        jalview.bin.Console.outPrintln("Last read line " + nlinesread + ": '" + lastread
                 + "' (first 80 chars) ...");
       }
       return false;
@@ -821,7 +821,7 @@ public class AnnotationFile
               if (refSeqIndex < 1)
               {
                 refSeqIndex = 1;
-                System.out.println(
+                jalview.bin.Console.outPrintln(
                         "WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile");
               }
             } catch (Exception ex)
@@ -923,7 +923,7 @@ public class AnnotationFile
           {
             if (hidden == null)
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "Cannot process HIDE_INSERTIONS without an alignment view: Ignoring line: "
                               + line);
             }
@@ -1075,7 +1075,7 @@ public class AnnotationFile
             {
               // TODO: specify and implement duplication of alignment annotation
               // for multiple group references.
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "Ignoring 1:many group reference mappings for group name '"
                               + groupRef + "'");
             }
@@ -1368,7 +1368,7 @@ public class AnnotationFile
     }
     else
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Couldn't combine annotations. None are added to alignment yet!");
     }
   }
@@ -1385,7 +1385,7 @@ public class AnnotationFile
       value = Float.valueOf(nextToken);
     } catch (NumberFormatException e)
     {
-      System.err.println("line " + nlinesread + ": Threshold '" + nextToken
+      jalview.bin.Console.errPrintln("line " + nlinesread + ": Threshold '" + nextToken
               + "' invalid, setting to zero");
     }
     String label = st.hasMoreTokens() ? st.nextToken() : null;
@@ -1435,7 +1435,7 @@ public class AnnotationFile
       }
     } catch (Exception e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Couldn't parse Group Start or End Field as '*' or a valid column or sequence index: '"
                       + rng + "' - assuming alignment width for group.");
       // assume group is full width
index 9a4e982..56e9fa1 100755 (executable)
@@ -215,7 +215,7 @@ public class AppletFormatAdapter
     } catch (Exception e)
     {
       e.printStackTrace();
-      System.err.println("Failed to read alignment using the '" + fileFormat
+      jalview.bin.Console.errPrintln("Failed to read alignment using the '" + fileFormat
               + "' reader.\n" + e);
 
       if (e.getMessage() != null
@@ -297,7 +297,7 @@ public class AppletFormatAdapter
     } catch (Exception e)
     {
       e.printStackTrace();
-      System.err.println("Failed to read alignment using the '" + format
+      jalview.bin.Console.errPrintln("Failed to read alignment using the '" + format
               + "' reader.\n" + e);
 
       if (e.getMessage() != null
@@ -424,13 +424,13 @@ public class AppletFormatAdapter
       String afileresp = afile.print(seqs, jvsuffix);
       if (afile.hasWarningMessage())
       {
-        System.err.println("Warning raised when writing as " + format
+        jalview.bin.Console.errPrintln("Warning raised when writing as " + format
                 + " : " + afile.getWarningMessage());
       }
       return afileresp;
     } catch (Exception e)
     {
-      System.err.println("Failed to write alignment as a '"
+      jalview.bin.Console.errPrintln("Failed to write alignment as a '"
               + format.getName() + "' file\n");
       e.printStackTrace();
     }
@@ -488,7 +488,7 @@ public class AppletFormatAdapter
       {
         try
         {
-          System.out.println("Reading file: " + f);
+          jalview.bin.Console.outPrintln("Reading file: " + f);
           AppletFormatAdapter afa = new AppletFormatAdapter();
           Runtime r = Runtime.getRuntime();
           System.gc();
@@ -502,36 +502,36 @@ public class AppletFormatAdapter
           memf += r.totalMemory() - r.freeMemory();
           if (al != null)
           {
-            System.out.println("Alignment contains " + al.getHeight()
+            jalview.bin.Console.outPrintln("Alignment contains " + al.getHeight()
                     + " sequences and " + al.getWidth() + " columns.");
             try
             {
-              System.out.println(new AppletFormatAdapter()
+              jalview.bin.Console.outPrintln(new AppletFormatAdapter()
                       .formatSequences(FileFormat.Fasta, al, true));
             } catch (Exception e)
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "Couln't format the alignment for output as a FASTA file.");
               e.printStackTrace(System.err);
             }
           }
           else
           {
-            System.out.println("Couldn't read alignment");
+            jalview.bin.Console.outPrintln("Couldn't read alignment");
           }
-          System.out.println("Read took " + (t1 / 1000.0) + " seconds.");
-          System.out.println(
+          jalview.bin.Console.outPrintln("Read took " + (t1 / 1000.0) + " seconds.");
+          jalview.bin.Console.outPrintln(
                   "Difference between free memory now and before is "
                           + (memf / (1024.0 * 1024.0) * 1.0) + " MB");
         } catch (Exception e)
         {
-          System.err.println("Exception when dealing with " + i
+          jalview.bin.Console.errPrintln("Exception when dealing with " + i
                   + "'th argument: " + args[i] + "\n" + e);
         }
       }
       else
       {
-        System.err.println("Ignoring argument '" + args[i] + "' (" + i
+        jalview.bin.Console.errPrintln("Ignoring argument '" + args[i] + "' (" + i
                 + "'th)- not a readable file.");
       }
       i++;
@@ -559,7 +559,7 @@ public class AppletFormatAdapter
     DataSourceType protocol = null;
     if (debug)
     {
-      System.out.println("resolving datasource started with:\n>>file\n"
+      jalview.bin.Console.outPrintln("resolving datasource started with:\n>>file\n"
               + file + ">>endfile");
     }
 
@@ -577,7 +577,7 @@ public class AppletFormatAdapter
       }
       if (debug)
       {
-        System.err.println("Resource '" + file + "' was "
+        jalview.bin.Console.errPrintln("Resource '" + file + "' was "
                 + (rtn ? "" : "not") + " located by classloader.");
       }
       if (rtn)
@@ -605,7 +605,7 @@ public class AppletFormatAdapter
     {
       if (debug)
       {
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "Trying to get contents of resource as " + protocol + ":");
       }
       fp = new FileParse(file, protocol);
@@ -617,14 +617,14 @@ public class AppletFormatAdapter
       {
         if (debug)
         {
-          System.out.println("Successful.");
+          jalview.bin.Console.outPrintln("Successful.");
         }
       }
     } catch (Exception e)
     {
       if (debug)
       {
-        System.err.println("Exception when accessing content: " + e);
+        jalview.bin.Console.errPrintln("Exception when accessing content: " + e);
       }
       fp = null;
     }
@@ -632,7 +632,7 @@ public class AppletFormatAdapter
     {
       if (debug)
       {
-        System.out.println("Accessing as paste.");
+        jalview.bin.Console.outPrintln("Accessing as paste.");
       }
       protocol = DataSourceType.PASTE;
       fp = null;
@@ -645,7 +645,7 @@ public class AppletFormatAdapter
         }
       } catch (Exception e)
       {
-        System.err.println("Failed to access content as paste!");
+        jalview.bin.Console.errPrintln("Failed to access content as paste!");
         e.printStackTrace();
         fp = null;
       }
@@ -667,20 +667,20 @@ public class AppletFormatAdapter
         {
           if (debug)
           {
-            System.out.println("Format not identified. Inaccessible file.");
+            jalview.bin.Console.outPrintln("Format not identified. Inaccessible file.");
           }
           return null;
         }
         if (debug)
         {
-          System.out.println("Format identified as " + idformat
+          jalview.bin.Console.outPrintln("Format identified as " + idformat
                   + "and expected as " + format);
         }
         if (idformat.equals(format))
         {
           if (debug)
           {
-            System.out.println("Protocol identified as " + protocol);
+            jalview.bin.Console.outPrintln("Protocol identified as " + protocol);
           }
           return protocol;
         }
@@ -698,7 +698,7 @@ public class AppletFormatAdapter
       {
         if (debug)
         {
-          System.err.println("File deemed not accessible via " + protocol);
+          jalview.bin.Console.errPrintln("File deemed not accessible via " + protocol);
           e.printStackTrace();
         }
       }
index b8a721e..1a08363 100644 (file)
@@ -54,7 +54,7 @@ public class BackupFilenameFilter implements FilenameFilter
       }
     } catch (IOException e)
     {
-      System.out.println("IOException when checking file '" + filename
+      jalview.bin.Console.outPrintln("IOException when checking file '" + filename
               + "' is a backupfile");
     }
 
index 6779892..eef203f 100644 (file)
@@ -138,7 +138,7 @@ public class BioJsHTMLOutput extends HTMLOutput
       {
         if (!biojsDirectory.mkdirs())
         {
-          System.out.println("Couldn't create local directory : "
+          jalview.bin.Console.outPrintln("Couldn't create local directory : "
                   + BJS_TEMPLATES_LOCAL_DIRECTORY);
           return;
         }
@@ -264,7 +264,7 @@ public class BioJsHTMLOutput extends HTMLOutput
 
     } catch (OutOfMemoryError err)
     {
-      System.out.println("########################\n" + "OUT OF MEMORY "
+      jalview.bin.Console.outPrintln("########################\n" + "OUT OF MEMORY "
               + generatedFile + "\n" + "########################");
       new OOMWarning("Creating Image for " + generatedFile, err);
     } catch (Exception e)
index afb2009..a71e6e8 100755 (executable)
@@ -140,7 +140,7 @@ public class ClustalFile extends AlignFile
       }
     } catch (IOException e)
     {
-      System.err.println("Exception parsing clustal file " + e);
+      jalview.bin.Console.errPrintln("Exception parsing clustal file " + e);
       e.printStackTrace();
     }
 
@@ -168,7 +168,7 @@ public class ClustalFile extends AlignFile
         }
         else
         {
-          System.err.println("Clustal File Reader: Can't find sequence for "
+          jalview.bin.Console.errPrintln("Clustal File Reader: Can't find sequence for "
                   + headers.elementAt(i));
         }
       }
index 6332561..a704f24 100755 (executable)
@@ -312,7 +312,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI
       // should report somewhere useful for UI if necessary
       warningMessage = ((warningMessage == null) ? "" : warningMessage)
               + "Parsing error at\n" + line;
-      System.out.println("Error parsing feature file: " + ex + "\n" + line);
+      jalview.bin.Console.outPrintln("Error parsing feature file: " + ex + "\n" + line);
       ex.printStackTrace(System.err);
       resetMatcher();
       return false;
@@ -354,7 +354,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI
       String[] tokens = line.split(TAB_REGEX);
       if (tokens.length != 2)
       {
-        System.err.println(String.format("Invalid token count %d for %d",
+        jalview.bin.Console.errPrintln(String.format("Invalid token count %d for %d",
                 tokens.length, line));
       }
       else
@@ -392,7 +392,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI
      */
     if (gffColumns.length < 6)
     {
-      System.err.println("Ignoring feature line '" + line
+      jalview.bin.Console.errPrintln("Ignoring feature line '" + line
               + "' with too few columns (" + gffColumns.length + ")");
       return false;
     }
@@ -415,13 +415,13 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI
         seq = alignment.getSequenceAt(idx);
       } catch (NumberFormatException ex)
       {
-        System.err.println("Invalid sequence index: " + seqIndex);
+        jalview.bin.Console.errPrintln("Invalid sequence index: " + seqIndex);
       }
     }
 
     if (seq == null)
     {
-      System.out.println("Sequence not found: " + line);
+      jalview.bin.Console.outPrintln("Sequence not found: " + line);
       return false;
     }
 
@@ -1009,7 +1009,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI
   @Override
   public String print(SequenceI[] sqs, boolean jvsuffix)
   {
-    System.out.println("Use printGffFormat() or printJalviewFormat()");
+    jalview.bin.Console.outPrintln("Use printGffFormat() or printJalviewFormat()");
     return null;
   }
 
@@ -1333,7 +1333,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI
      */
     if (gffColumns.length < 5)
     {
-      System.err.println("Ignoring GFF feature line with too few columns ("
+      jalview.bin.Console.errPrintln("Ignoring GFF feature line with too few columns ("
               + gffColumns.length + ")");
       return null;
     }
@@ -1364,7 +1364,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI
         }
       } catch (IOException e)
       {
-        System.err.println("GFF parsing failed with: " + e.getMessage());
+        jalview.bin.Console.errPrintln("GFF parsing failed with: " + e.getMessage());
         return null;
       }
     }
@@ -1532,7 +1532,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI
     }
     else
     {
-      System.err.println("Ignoring unknown pragma: " + line);
+      jalview.bin.Console.errPrintln("Ignoring unknown pragma: " + line);
     }
   }
 }
index b7dd834..96489d0 100644 (file)
@@ -107,7 +107,7 @@ public class FileFormats
     String name = format.getName().toUpperCase(Locale.ROOT);
     if (formats.containsKey(name))
     {
-      System.err.println("Overwriting file format: " + format.getName());
+      jalview.bin.Console.errPrintln("Overwriting file format: " + format.getName());
     }
     formats.put(name, format);
     if (isIdentifiable)
index a2585b3..49571dc 100755 (executable)
@@ -321,7 +321,7 @@ public class FileLoader implements Runnable
       if (format == null)
       {
         Desktop.instance.stopLoading();
-        System.err.println("The input file \"" + file
+        jalview.bin.Console.errPrintln("The input file \"" + file
                 + "\" has null or unidentifiable data content!");
         if (!Jalview.isHeadlessMode())
         {
@@ -354,7 +354,7 @@ public class FileLoader implements Runnable
         if (source != null)
         {
           // Tell the user (developer?) that this is going to cause a problem
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "IMPLEMENTATION ERROR: Cannot read consecutive Jalview XML projects from a stream.");
           // We read the data anyway - it might make sense.
         }
@@ -552,7 +552,7 @@ public class FileLoader implements Runnable
           }
           else
           {
-            System.err.println(errorMessage);
+            jalview.bin.Console.errPrintln(errorMessage);
           }
         }
       }
@@ -561,7 +561,7 @@ public class FileLoader implements Runnable
 
     } catch (Exception er)
     {
-      System.err.println("Exception whilst opening file '" + file);
+      jalview.bin.Console.errPrintln("Exception whilst opening file '" + file);
       er.printStackTrace();
       if (raiseGUI)
       {
@@ -601,7 +601,7 @@ public class FileLoader implements Runnable
           }
         });
       }
-      System.err.println("Out of memory loading file " + file + "!!");
+      jalview.bin.Console.errPrintln("Out of memory loading file " + file + "!!");
 
     }
     loadtime += System.currentTimeMillis();
@@ -620,7 +620,7 @@ public class FileLoader implements Runnable
       {
         AlignmentI al = alignFrame.getViewport().getAlignment();
 
-        System.out.println("Loaded '" + title + "' in "
+        jalview.bin.Console.outPrintln("Loaded '" + title + "' in "
                 + (loadtime / 1000.0) + "s, took an additional "
                 + (1.0 * memused / (1024.0 * 1024.0)) + " MB ("
                 + al.getHeight() + " seqs by " + al.getWidth() + " cols)");
@@ -629,7 +629,7 @@ public class FileLoader implements Runnable
       {
         // report that we didn't load anything probably due to an out of memory
         // error
-        System.out.println("Failed to load '" + title + "' in "
+        jalview.bin.Console.outPrintln("Failed to load '" + title + "' in "
                 + (loadtime / 1000.0) + "s, took an additional "
                 + (1.0 * memused / (1024.0 * 1024.0))
                 + " MB (alignment is null)");
index 8d3283d..1f51d8c 100755 (executable)
@@ -380,7 +380,7 @@ public class FileParse
     if (sfpos > -1 && sfpos < fileStr.length() - 1)
     {
       suffix = fileStr.substring(sfpos + 1);
-      // System.err.println("DEBUG: Found Suffix:"+suffix);
+      // jalview.bin.Console.errPrintln("DEBUG: Found Suffix:"+suffix);
       return fileStr.substring(0, sfpos);
     }
     return null;
@@ -634,7 +634,7 @@ public class FileParse
   {
     if (bytesRead >= READAHEAD_LIMIT)
     {
-      System.err.println(String.format(
+      jalview.bin.Console.errPrintln(String.format(
               "File reset error: read %d bytes but reset limit is %d",
               bytesRead, READAHEAD_LIMIT));
     }
index d659e2a..02d46e7 100644 (file)
@@ -239,7 +239,7 @@ public abstract class HTMLOutput implements Runnable
     }
     else
     {
-      System.out.println(message);
+      jalview.bin.Console.outPrintln(message);
     }
   }
 
index 7b661f3..b5fdc2c 100644 (file)
@@ -249,7 +249,7 @@ public class HtmlSvgOutput extends HTMLOutput
       }
     } catch (OutOfMemoryError err)
     {
-      System.out.println("########################\n" + "OUT OF MEMORY "
+      jalview.bin.Console.outPrintln("########################\n" + "OUT OF MEMORY "
               + generatedFile + "\n" + "########################");
       new OOMWarning("Creating Image for " + generatedFile, err);
     } catch (Exception e)
index ab2c00a..9f8ac4e 100755 (executable)
@@ -150,7 +150,7 @@ public class JPredFile extends AlignFile
   @Override
   public void parse() throws IOException
   {
-    // JBPNote log.System.out.println("all read in ");
+    // JBPNote log.jalview.bin.Console.outPrintln("all read in ");
     String line;
     QuerySeqPosition = -1;
     noSeqs = 0;
@@ -240,7 +240,7 @@ public class JPredFile extends AlignFile
       }
       else if (id.equals("jnetconf"))
       {
-        // log.debug System.out.println("here");
+        // log.debug jalview.bin.Console.outPrintln("here");
         id = "Prediction Confidence";
         this.conf = new Vector(numSymbols);
 
@@ -377,14 +377,14 @@ public class JPredFile extends AlignFile
 
       for (int i = 0; i < jpred.seqs.size(); i++)
       {
-        System.out.println(((Sequence) jpred.seqs.elementAt(i)).getName()
+        jalview.bin.Console.outPrintln(((Sequence) jpred.seqs.elementAt(i)).getName()
                 + "\n"
                 + ((Sequence) jpred.seqs.elementAt(i)).getSequenceAsString()
                 + "\n");
       }
     } catch (java.io.IOException e)
     {
-      System.err.println("Exception " + e);
+      jalview.bin.Console.errPrintln("Exception " + e);
       // e.printStackTrace(); not java 1.1 compatible!
     }
   }
@@ -447,6 +447,6 @@ public class JPredFile extends AlignFile
  * out = BLCFile.print(s);
  * 
  * AlignFrame af = new AlignFrame(null, s); af.resize(700, 500); af.show();
- * System.out.println(out); } catch (java.io.IOException e) {
- * System.out.println("Exception " + e); } } }
+ * jalview.bin.Console.outPrintln(out); } catch (java.io.IOException e) {
+ * jalview.bin.Console.outPrintln("Exception " + e); } } }
  */
index 2ee305f..0b45ba6 100644 (file)
@@ -363,7 +363,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
                   .setSecondaryStructure(annotation.secondaryStructure);
           String displayChar = annotation.displayCharacter == null ? null
                   : annotation.displayCharacter;
-          // System.out.println("--------------------->[" + displayChar + "]");
+          // jalview.bin.Console.outPrintln("--------------------->[" + displayChar + "]");
           annotationPojo.setDisplayCharacter(displayChar);
           if (annotation.colour != null)
           {
index cb47610..b97df13 100755 (executable)
@@ -193,7 +193,7 @@ public class JalviewFileChooser extends JFileChooser
     }
     else
     {
-      System.err.println("JalviewFileChooser arguments mismatch: "
+      jalview.bin.Console.errPrintln("JalviewFileChooser arguments mismatch: "
               + extensions + ", " + descs);
     }
   }
@@ -408,7 +408,7 @@ public class JalviewFileChooser extends JFileChooser
         return FileFormats.getInstance().forName(format);
       } catch (IllegalArgumentException e)
       {
-        System.err.println("Unexpected format: " + format);
+        jalview.bin.Console.errPrintln("Unexpected format: " + format);
       }
     }
     return null;
@@ -462,7 +462,7 @@ public class JalviewFileChooser extends JFileChooser
         }
       } catch (Throwable x)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Unexpected exception when trying to get filename.");
         x.printStackTrace();
       }
index a9fc7ed..5996781 100755 (executable)
@@ -169,7 +169,7 @@ public class JalviewFileView extends FileView
         }
         else
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "JalviewFileView.createImageIcon: Couldn't find file: "
                           + filePath);
         }
index 158feb9..0a0520a 100755 (executable)
@@ -136,7 +136,7 @@ public class MSFfile extends AlignFile
       }
     } catch (IOException e)
     {
-      System.err.println("Exception parsing MSFFile " + e);
+      jalview.bin.Console.errPrintln("Exception parsing MSFFile " + e);
       e.printStackTrace();
     }
 
@@ -169,7 +169,7 @@ public class MSFfile extends AlignFile
       }
       else
       {
-        System.err.println("MSFFile Parser: Can't find sequence for "
+        jalview.bin.Console.errPrintln("MSFFile Parser: Can't find sequence for "
                 + headers.get(i));
       }
     }
@@ -200,7 +200,7 @@ public class MSFfile extends AlignFile
         }
       } catch (Exception e)
       {
-        System.err.println("Exception during MSF Checksum calculation");
+        jalview.bin.Console.errPrintln("Exception during MSF Checksum calculation");
         e.printStackTrace();
       }
     }
index b3c0011..38ee9ca 100755 (executable)
@@ -394,7 +394,7 @@ public class NewickFile extends FileParse
           // node string contains Comment or structured/extended NH format info
           /*
            * if ((fcp-cp>1 && nf.substring(cp,fcp).trim().length()>1)) { // will
-           * process in remains System.err.println("skipped text:
+           * process in remains jalview.bin.Console.errPrintln("skipped text:
            * '"+nf.substring(cp,fcp)+"'"); }
            */
           // verify termination.
@@ -665,7 +665,7 @@ public class NewickFile extends FileParse
             // more codes here.
           } catch (Exception e)
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Couldn't parse code '" + code + "' = '" + value + "'");
             e.printStackTrace(System.err);
           }
@@ -962,31 +962,31 @@ public class NewickFile extends FileParse
       }
 
       treefile.close();
-      System.out.println("Read file :\n");
+      jalview.bin.Console.outPrintln("Read file :\n");
 
       NewickFile trf = new NewickFile(args[0], DataSourceType.FILE);
       trf.parse();
-      System.out.println("Original file :\n");
+      jalview.bin.Console.outPrintln("Original file :\n");
 
       Regex nonl = new Regex("\n+", "");
-      System.out.println(nonl.replaceAll(newickfile.toString()) + "\n");
-
-      System.out.println("Parsed file.\n");
-      System.out.println("Default output type for original input.\n");
-      System.out.println(trf.print());
-      System.out.println("Without bootstraps.\n");
-      System.out.println(trf.print(false));
-      System.out.println("Without distances.\n");
-      System.out.println(trf.print(true, false));
-      System.out.println("Without bootstraps but with distanecs.\n");
-      System.out.println(trf.print(false, true));
-      System.out.println("Without bootstraps or distanecs.\n");
-      System.out.println(trf.print(false, false));
-      System.out.println("With bootstraps and with distances.\n");
-      System.out.println(trf.print(true, true));
+      jalview.bin.Console.outPrintln(nonl.replaceAll(newickfile.toString()) + "\n");
+
+      jalview.bin.Console.outPrintln("Parsed file.\n");
+      jalview.bin.Console.outPrintln("Default output type for original input.\n");
+      jalview.bin.Console.outPrintln(trf.print());
+      jalview.bin.Console.outPrintln("Without bootstraps.\n");
+      jalview.bin.Console.outPrintln(trf.print(false));
+      jalview.bin.Console.outPrintln("Without distances.\n");
+      jalview.bin.Console.outPrintln(trf.print(true, false));
+      jalview.bin.Console.outPrintln("Without bootstraps but with distanecs.\n");
+      jalview.bin.Console.outPrintln(trf.print(false, true));
+      jalview.bin.Console.outPrintln("Without bootstraps or distanecs.\n");
+      jalview.bin.Console.outPrintln(trf.print(false, false));
+      jalview.bin.Console.outPrintln("With bootstraps and with distances.\n");
+      jalview.bin.Console.outPrintln(trf.print(true, true));
     } catch (java.io.IOException e)
     {
-      System.err.println("Exception\n" + e);
+      jalview.bin.Console.errPrintln("Exception\n" + e);
       e.printStackTrace();
     }
   }
index d9ed516..adfc1cb 100755 (executable)
@@ -59,7 +59,7 @@ public class PIRFile extends AlignFile
     {
       if (line.length() == 0)
       {
-        // System.out.println("blank line");
+        // jalview.bin.Console.outPrintln("blank line");
         continue;
       }
       if (line.indexOf("C;") == 0 || line.indexOf("#") == 0)
index 6b9dc3f..57fae00 100755 (executable)
@@ -137,7 +137,7 @@ public class PfamFile extends AlignFile
       }
       else
       {
-        System.err.println("PFAM File reader: Can't find sequence for "
+        jalview.bin.Console.errPrintln("PFAM File reader: Can't find sequence for "
                 + headers.get(i));
       }
     }
index 12e87a6..7542884 100644 (file)
@@ -188,7 +188,7 @@ public class PhylipFile extends AlignFile
 
     } catch (IOException e)
     {
-      System.err.println("Exception parsing PHYLIP file " + e);
+      jalview.bin.Console.errPrintln("Exception parsing PHYLIP file " + e);
       e.printStackTrace(System.err);
       throw e;
     }
index 4d3ddc1..f8c384d 100644 (file)
@@ -160,8 +160,10 @@ public class RnamlFile extends AlignFile
         }
       }
       sqs[i] = new Sequence(id, seq, begin, end);
-
-      sqs[i].setEnd(sqs[i].findPosition(sqs[i].getLength()));
+      if (seq.length()!=(end-begin+1))
+      {
+        sqs[i].setEnd(sqs[i].findPosition(sqs[i].getLength()));
+      }
       String[] annot = new String[rna.length()];
       Annotation[] ann = new Annotation[rna.length()];
 
@@ -210,8 +212,8 @@ public class RnamlFile extends AlignFile
   // public static void main(String[] args) {
   // Pattern p= Pattern.compile("(.+)[.][^.]+");
   // Matcher m = p.matcher("toto.xml.zip");
-  // System.out.println(m.matches());
-  // System.out.println(m.group(1));
+  // jalview.bin.Console.outPrintln(m.matches());
+  // jalview.bin.Console.outPrintln(m.group(1));
   // }
   /**
    * make a friendly ID string.
index 95bd1cc..721cd47 100644 (file)
@@ -423,7 +423,7 @@ public class SequenceAnnotationReport
             }
           } catch (Exception x)
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "problem when creating links from " + urlstring);
             x.printStackTrace();
           }
@@ -446,7 +446,7 @@ public class SequenceAnnotationReport
     UrlLink urlLink = new UrlLink(link);
     if (!urlLink.isValid())
     {
-      System.err.println(urlLink.getInvalidMessage());
+      jalview.bin.Console.errPrintln(urlLink.getInvalidMessage());
       return null;
     }
 
index ba6b2f3..d8b3215 100644 (file)
@@ -165,7 +165,7 @@ public class SimpleBlastFile extends AlignFile
               rstart = Long.parseLong(stindx);
             } catch (Exception e)
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "Couldn't parse '" + stindx + "' as start of row");
               // inAlignments = false;
               // warn for this line
@@ -175,7 +175,7 @@ public class SimpleBlastFile extends AlignFile
               rend = Long.parseLong(endindx);
             } catch (Exception e)
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "Couldn't parse '" + endindx + "' as end of row");
               // inAlignments = false;
 
index 28f062f..d674485 100644 (file)
@@ -147,19 +147,19 @@ public class StockholmFile extends AlignFile
               + umcp.getMessage() + ")";
       throw new IOException(umcp);
     }
-    // DEBUG System.out.println("this is the secondary scructure:"
+    // DEBUG jalview.bin.Console.outPrintln("this is the secondary scructure:"
     // +result.size());
     SequenceI[] seqs = new SequenceI[result.size()];
     String id = null;
     for (int i = 0; i < result.size(); i++)
     {
-      // DEBUG System.err.println("Processing i'th sequence in Stockholm file")
+      // DEBUG jalview.bin.Console.errPrintln("Processing i'th sequence in Stockholm file")
       RNA current = result.get(i);
 
       String seq = current.getSeq();
       String rna = current.getStructDBN(true);
-      // DEBUG System.out.println(seq);
-      // DEBUG System.err.println(rna);
+      // DEBUG jalview.bin.Console.outPrintln(seq);
+      // DEBUG jalview.bin.Console.errPrintln(rna);
       int begin = 0;
       int end = seq.length() - 1;
       id = safeName(getDataName());
@@ -441,7 +441,7 @@ public class StockholmFile extends AlignFile
       }
       else if (!r.search(line))
       {
-        // System.err.println("Found sequence line: " + line);
+        // jalview.bin.Console.errPrintln("Found sequence line: " + line);
 
         // Split sequence in sequence and accession parts
         if (!x.search(line))
@@ -465,7 +465,7 @@ public class StockholmFile extends AlignFile
         String annType = r.stringMatched(1);
         String annContent = r.stringMatched(2);
 
-        // System.err.println("type:" + annType + " content: " + annContent);
+        // jalview.bin.Console.errPrintln("type:" + annType + " content: " + annContent);
 
         if (annType.equals("GF"))
         {
@@ -567,7 +567,7 @@ public class StockholmFile extends AlignFile
           else
           {
             // throw new IOException("Error parsing " + line);
-            System.err.println(">> missing annotation: " + line);
+            jalview.bin.Console.errPrintln(">> missing annotation: " + line);
           }
         }
         else if (annType.equals("GC"))
@@ -685,7 +685,7 @@ public class StockholmFile extends AlignFile
           // }
           else
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Warning - couldn't parse sequence annotation row line:\n"
                             + line);
             // throw new IOException("Error parsing " + line);
@@ -937,7 +937,7 @@ public class StockholmFile extends AlignFile
               annot.annotations.length);
       System.arraycopy(els, 0, anns, annot.annotations.length, els.length);
       annot.annotations = anns;
-      // System.out.println("else: ");
+      // jalview.bin.Console.outPrintln("else: ");
     }
     return annot;
   }
@@ -1270,7 +1270,7 @@ public class StockholmFile extends AlignFile
     {
       return (String) typeIds.get(id);
     }
-    System.err.println(
+    jalview.bin.Console.errPrintln(
             "Warning : Unknown Stockholm annotation type code " + id);
     return id;
   }
@@ -1292,7 +1292,7 @@ public class StockholmFile extends AlignFile
     {
       return key;
     }
-    System.err.println(
+    jalview.bin.Console.errPrintln(
             "Warning : Unknown Stockholm annotation type: " + type);
     return key;
   }
index 6ec0298..df384a6 100644 (file)
@@ -242,7 +242,7 @@ public abstract class StructureFile extends AlignFile
   protected void processPdbFileWithAnnotate3d(List<SequenceI> rna)
           throws Exception
   {
-    // System.out.println("this is a PDB format and RNA sequence");
+    // jalview.bin.Console.outPrintln("this is a PDB format and RNA sequence");
     // note: we use reflection here so that the applet can compile and run
     // without the HTTPClient bits and pieces needed for accessing Annotate3D
     // web service
@@ -336,7 +336,7 @@ public abstract class StructureFile extends AlignFile
         processPdbFileWithAnnotate3d(rnaSequences);
       } catch (Exception x)
       {
-        System.err.println("Exceptions when dealing with RNA in pdb file");
+        jalview.bin.Console.errPrintln("Exceptions when dealing with RNA in pdb file");
         x.printStackTrace();
 
       }
@@ -352,7 +352,7 @@ public abstract class StructureFile extends AlignFile
         processWithJmolParser(proteinSequences, true);
       } catch (Exception x)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Exceptions from Jmol when processing data in pdb file");
         x.printStackTrace();
       }
index 7e963d5..52751e9 100644 (file)
@@ -601,7 +601,7 @@ public class TCoffeeScoreFile extends AlignFile
           annotations[j] = null;
           if (val > 0)
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Warning: non-zero value for positional T-COFFEE score for gap at "
                             + j + " in sequence " + s.getName());
           }
index dd4b72c..c3776d3 100644 (file)
@@ -460,7 +460,7 @@ public class VamsasAppDatastore
           {
             // removeValignmentSequences(alignment, docseqs);
             docseqs.removeAllElements();
-            System.out.println(
+            jalview.bin.Console.outPrintln(
                     "Sequence deletion from alignment is not implemented.");
 
           }
@@ -488,11 +488,11 @@ public class VamsasAppDatastore
           }
           if (alismod)
           {
-            System.out.println("update alignment in document.");
+            jalview.bin.Console.outPrintln("update alignment in document.");
           }
           else
           {
-            System.out.println("alignment in document left unchanged.");
+            jalview.bin.Console.outPrintln("alignment in document left unchanged.");
           }
         }
         else
@@ -500,7 +500,7 @@ public class VamsasAppDatastore
           // unbind alignment from view.
           // create new binding and new alignment.
           // mark trail on new alignment as being derived from old ?
-          System.out.println(
+          jalview.bin.Console.outPrintln(
                   "update edited alignment to new alignment in document.");
         }
       }
@@ -1115,12 +1115,12 @@ public class VamsasAppDatastore
       // METHODS)
       {
         // verify existing alignment sequence annotation is up to date
-        System.out.println("update dataset sequence annotation.");
+        jalview.bin.Console.outPrintln("update dataset sequence annotation.");
       }
       else
       {
         // verify existing alignment sequence annotation is up to date
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "make new alignment dataset sequence annotation if modification has happened.");
       }
     }
@@ -1184,12 +1184,12 @@ public class VamsasAppDatastore
       // METHODS)
       {
         // verify existing alignment sequence annotation is up to date
-        System.out.println("update alignment sequence annotation.");
+        jalview.bin.Console.outPrintln("update alignment sequence annotation.");
       }
       else
       {
         // verify existing alignment sequence annotation is up to date
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "make new alignment sequence annotation if modification has happened.");
       }
     }
index 63b78b2..c7c90f4 100755 (executable)
@@ -84,7 +84,7 @@ public class WSWUBlastClient
     for (int i = 0; i < ids.size(); i++)
     {
       Sequence sequence = (Sequence) ids.get(i);
-      System.out.println(sequence.getName());
+      jalview.bin.Console.outPrintln(sequence.getName());
 
       BlastThread thread = new BlastThread(sequence);
       thread.start();
@@ -249,7 +249,7 @@ public class WSWUBlastClient
 
     BlastThread(Sequence sequence)
     {
-      System.out.println("blasting for: " + sequence.getName());
+      jalview.bin.Console.outPrintln("blasting for: " + sequence.getName());
       this.sequence = sequence;
     }
 
@@ -276,7 +276,7 @@ public class WSWUBlastClient
           else
           {
             Thread.sleep(10000);
-            System.out.println("WSWuBlastClient: I'm alive "
+            jalview.bin.Console.outPrintln("WSWuBlastClient: I'm alive "
                     + sequence.getName() + " " + jobid); // log.debug
           }
         } catch (Exception ex)
@@ -315,7 +315,7 @@ public class WSWUBlastClient
       {
         jobComplete = true;
         jobsRunning--;
-        System.err.println("WSWUBlastClient error:\n" + exp.toString());
+        jalview.bin.Console.errPrintln("WSWUBlastClient error:\n" + exp.toString());
         exp.printStackTrace();
       }
     }
index eedf09a..e4e2d99 100644 (file)
@@ -204,7 +204,7 @@ public class JvCacheableInputBox<E>
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        // System.out.println(">>>>> Clear cache items");
+        // jalview.bin.Console.outPrintln(">>>>> Clear cache items");
         setSelectedItem("");
         appCache.deleteCacheItems(cacheKey);
         updateCache();
index 9ce4cc6..77b641a 100644 (file)
@@ -90,7 +90,7 @@ public class ExonerateHelper extends Gff2Helper
               relaxedIdMatching);
     } catch (IOException ivfe)
     {
-      System.err.println(ivfe);
+      jalview.bin.Console.errPrintln(ivfe);
     }
 
     /*
@@ -200,7 +200,7 @@ public class ExonerateHelper extends Gff2Helper
     }
     else if (!"+".equals(strand))
     {
-      System.err.println("Strand must be specified for alignment");
+      jalview.bin.Console.errPrintln("Strand must be specified for alignment");
       return;
     }
 
@@ -239,7 +239,7 @@ public class ExonerateHelper extends Gff2Helper
     String[] tokens = region.split(" ");
     if (tokens.length != 3)
     {
-      System.err.println("Malformed Align descriptor: " + region);
+      jalview.bin.Console.errPrintln("Malformed Align descriptor: " + region);
       return null;
     }
 
@@ -257,7 +257,7 @@ public class ExonerateHelper extends Gff2Helper
       alignCount = Integer.parseInt(tokens[2]);
     } catch (NumberFormatException nfe)
     {
-      System.err.println(nfe.toString());
+      jalview.bin.Console.errPrintln(nfe.toString());
       return null;
     }
 
@@ -351,7 +351,7 @@ public class ExonerateHelper extends Gff2Helper
         return true;
       }
     }
-    System.err.println("Sorry, I don't handle exonerate model " + model);
+    jalview.bin.Console.errPrintln("Sorry, I don't handle exonerate model " + model);
     return false;
   }
 
index 1ef8848..646900d 100644 (file)
@@ -154,7 +154,7 @@ public class Gff3Helper extends GffHelperBase
      */
     if ("-".equals(strand))
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Skipping mapping from reverse complement as not yet supported");
       return null;
     }
@@ -162,7 +162,7 @@ public class Gff3Helper extends GffHelperBase
     List<String> targets = attributes.get(TARGET);
     if (targets == null)
     {
-      System.err.println("'Target' missing in GFF");
+      jalview.bin.Console.errPrintln("'Target' missing in GFF");
       return null;
     }
 
@@ -178,7 +178,7 @@ public class Gff3Helper extends GffHelperBase
       String[] tokens = target.split(" ");
       if (tokens.length < 3)
       {
-        System.err.println("Incomplete Target: " + target);
+        jalview.bin.Console.errPrintln("Incomplete Target: " + target);
         continue;
       }
 
@@ -225,7 +225,7 @@ public class Gff3Helper extends GffHelperBase
         }
       } catch (NumberFormatException nfe)
       {
-        System.err.println("Invalid start or end in Target " + target);
+        jalview.bin.Console.errPrintln("Invalid start or end in Target " + target);
       }
     }
 
index 22386d4..dccfd27 100644 (file)
@@ -114,7 +114,7 @@ public abstract class GffHelperBase implements GffHelperI
      */
     if (!trimMapping(from, to, fromRatio, toRatio))
     {
-      System.err.println("Ignoring mapping from " + Arrays.toString(from)
+      jalview.bin.Console.errPrintln("Ignoring mapping from " + Arrays.toString(from)
               + " to " + Arrays.toString(to) + " as counts don't match!");
       return null;
     }
@@ -166,7 +166,7 @@ public abstract class GffHelperBase implements GffHelperI
       {
         from[1] += fromOverlap / toRatio;
       }
-      System.err.println(Arrays.toString(from));
+      jalview.bin.Console.errPrintln(Arrays.toString(from));
       return true;
     }
     else if (fromOverlap < 0 && fromOverlap % fromRatio == 0)
@@ -185,7 +185,7 @@ public abstract class GffHelperBase implements GffHelperI
       {
         to[1] += fromOverlap / fromRatio;
       }
-      System.err.println(Arrays.toString(to));
+      jalview.bin.Console.errPrintln(Arrays.toString(to));
       return true;
     }
 
@@ -444,7 +444,7 @@ public abstract class GffHelperBase implements GffHelperI
       return sf;
     } catch (NumberFormatException nfe)
     {
-      System.err.println("Invalid number in gff: " + nfe.getMessage());
+      jalview.bin.Console.errPrintln("Invalid number in gff: " + nfe.getMessage());
       return null;
     }
   }
@@ -504,7 +504,7 @@ public abstract class GffHelperBase implements GffHelperI
 
     if (!valid)
     {
-      System.err.println(INVALID_GFF_ATTRIBUTE_FORMAT + s);
+      jalview.bin.Console.errPrintln(INVALID_GFF_ATTRIBUTE_FORMAT + s);
       return map;
     }
 
@@ -526,7 +526,7 @@ public abstract class GffHelperBase implements GffHelperI
       theKey = theKey.trim();
       if (theKey.isEmpty())
       {
-        System.err.println(INVALID_GFF_ATTRIBUTE_FORMAT + s);
+        jalview.bin.Console.errPrintln(INVALID_GFF_ATTRIBUTE_FORMAT + s);
         map.clear();
         return map;
       }
index 7d354e0..1e77f78 100644 (file)
@@ -215,7 +215,7 @@ public class SequenceOntologyLite implements SequenceOntologyI
       {
         // suppress logging here as it reports Uniprot sequence features
         // (which do not use SO terms) when auto-configuring feature colours
-        // System.out.println("SO term " + term
+        // jalview.bin.Console.outPrintln("SO term " + term
         // + " not known - add to model if needed in "
         // + getClass().getName());
         termsNotFound.add(term);
index 9f84c16..5248a16 100644 (file)
@@ -291,7 +291,7 @@ public class JalviewDataset
     AlignmentSet last = getLastAlignmentSet();
     if (last != null)
     {
-      System.err.println("Deuniquifying last alignment set.");
+      jalview.bin.Console.errPrintln("Deuniquifying last alignment set.");
       last.deuniquifyAlignment();
     }
     al.add(new AlignmentSet(newal));
index 37dd66b..3ce774e 100644 (file)
@@ -246,7 +246,7 @@ public class ParsePackedSet
           fp = new FileParse(file, AppletFormatAdapter.checkProtocol(file));
         } catch (Exception e)
         {
-          System.err.println("Couldn't handle datasource of type " + jtype
+          jalview.bin.Console.errPrintln("Couldn't handle datasource of type " + jtype
                   + " using URI " + file);
           e.printStackTrace();
           return;
@@ -255,7 +255,7 @@ public class ParsePackedSet
       }
       else
       {
-        System.out.println("Couldn't parse source type token '"
+        jalview.bin.Console.outPrintln("Couldn't parse source type token '"
                 + type.toUpperCase(Locale.ROOT) + "'");
       }
     }
@@ -269,7 +269,7 @@ public class ParsePackedSet
       System.out.print("\n");
 
     }
-    System.out.println("Now trying to parse set:");
+    jalview.bin.Console.outPrintln("Now trying to parse set:");
     JalviewDataset context;
     Object[] newdm;
     ParsePackedSet pps;
@@ -279,7 +279,7 @@ public class ParsePackedSet
               .getAlignment(context = new JalviewDataset(), dp);
     } catch (Exception e)
     {
-      System.out.println("Test failed for these arguments.\n");
+      jalview.bin.Console.outPrintln("Test failed for these arguments.\n");
       e.printStackTrace(System.out);
       return;
     }
@@ -287,7 +287,7 @@ public class ParsePackedSet
     {
       for (Object o : newdm)
       {
-        System.out.println("Will need to create an " + o.getClass());
+        jalview.bin.Console.outPrintln("Will need to create an " + o.getClass());
       }
 
       // now test uniquify/deuniquify stuff
@@ -300,7 +300,7 @@ public class ParsePackedSet
     {
       if (context.getLastAlignmentSet().isModified())
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Initial alignment set was modified and any associated views should be updated.");
       }
     }
index a33390f..3183bf6 100644 (file)
@@ -139,7 +139,7 @@ public class Sequencemapping extends Rangetype
 
   private void conflict(Mapping mjvmapping, SequenceMapping sequenceMapping)
   {
-    System.err.println("Conflict in update of sequenceMapping "
+    jalview.bin.Console.errPrintln("Conflict in update of sequenceMapping "
             + sequenceMapping.getVorbaId());
   }
 
index f6d17d4..a6dd8b6 100644 (file)
@@ -415,7 +415,7 @@ public class Tree extends DatastoreItem
             }
             else
             {
-              System.err.println("WARNING: Unassociated treeNode "
+              jalview.bin.Console.errPrintln("WARNING: Unassociated treeNode "
                       + tnode.element().toString() + " "
                       + ((tnode.getName() != null)
                               ? " label " + tnode.getName()
@@ -466,7 +466,7 @@ public class Tree extends DatastoreItem
       occurence = Integer.valueOf(oval).intValue();
     } catch (Exception e)
     {
-      System.err.println("Invalid nodespec '" + nodespec + "'");
+      jalview.bin.Console.errPrintln("Invalid nodespec '" + nodespec + "'");
       return null;
     }
     jalview.datamodel.BinaryNode bn = null;
index ea5b8e0..c3fbea8 100644 (file)
@@ -278,7 +278,7 @@ public class VCFLoader
       initialise(vcfFile);
     } catch (IOException e)
     {
-      System.err.println("Error opening VCF file: " + e.getMessage());
+      jalview.bin.Console.errPrintln("Error opening VCF file: " + e.getMessage());
     }
 
     // map of species!chromosome!fromAssembly!toAssembly to {fromRange, toRange}
@@ -398,7 +398,7 @@ public class VCFLoader
       }
     } catch (Throwable e)
     {
-      System.err.println("Error processing VCF: " + e.getMessage());
+      jalview.bin.Console.errPrintln("Error processing VCF: " + e.getMessage());
       e.printStackTrace();
       if (gui != null)
       {
@@ -678,7 +678,7 @@ public class VCFLoader
         patterns.add(Pattern.compile(token.toUpperCase(Locale.ROOT)));
       } catch (PatternSyntaxException e)
       {
-        System.err.println("Invalid pattern ignored: " + token);
+        jalview.bin.Console.errPrintln("Invalid pattern ignored: " + token);
       }
     }
     return patterns;
index 29f3fa9..c174696 100644 (file)
@@ -171,7 +171,7 @@ public class JSFunctionExec implements Runnable
           {
             if (jvlite.debug && dbgMsg != null)
             {
-              System.err.println(dbgMsg);
+              jalview.bin.Console.errPrintln(dbgMsg);
             }
             scriptObject.call(_listener, objects);
           }
@@ -182,7 +182,7 @@ public class JSFunctionExec implements Runnable
           {
             if (jvlite.debug)
             {
-              System.err.println(jex);
+              jalview.bin.Console.errPrintln(jex);
             }
             if (jex instanceof netscape.javascript.JSException
                     && jvlite.jsfallbackEnabled)
@@ -190,7 +190,7 @@ public class JSFunctionExec implements Runnable
               jsex[0] = jex;
               if (jvlite.debug)
               {
-                System.err.println("Falling back to javascript: url call");
+                jalview.bin.Console.errPrintln("Falling back to javascript: url call");
               }
               StringBuffer sb = new StringBuffer(
                       "javascript:" + _listener + "(");
@@ -213,7 +213,7 @@ public class JSFunctionExec implements Runnable
               sb.append(")");
               if (jvlite.debug)
               {
-                System.err.println(sb.toString());
+                jalview.bin.Console.errPrintln(sb.toString());
               }
               // alternate
               URL url = null;
index c2a963e..eda8741 100644 (file)
@@ -47,7 +47,7 @@ public class JsSelectionSender extends JSFunctionExec
   public void selection(SequenceGroup seqsel, ColumnSelection colsel,
           HiddenColumns hidden, SelectionSource source)
   {
-    // System.err.println("Testing selection event relay to
+    // jalview.bin.Console.errPrintln("Testing selection event relay to
     // jsfunction:"+_listener);
     try
     {
@@ -106,20 +106,20 @@ public class JsSelectionSender extends JSFunctionExec
         ;
 
       }
-      System.err.println("Relaying selection to jsfunction:" + _listener);
+      jalview.bin.Console.errPrintln("Relaying selection to jsfunction:" + _listener);
       executeJavascriptFunction(_listener,
               new Object[]
               { src, setid, jvlite.arrayToSeparatorList(seqs),
                   jvlite.arrayToSeparatorList(cols) });
     } catch (Exception ex)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Jalview Javascript exec error: Couldn't send selection message using function '"
                       + _listener + "'");
       ex.printStackTrace();
       if (ex instanceof netscape.javascript.JSException)
       {
-        System.err.println("Javascript Exception: "
+        jalview.bin.Console.errPrintln("Javascript Exception: "
                 + ((netscape.javascript.JSException) ex).getCause()
                         .toString());
       }
index 16b57a4..70a300c 100644 (file)
@@ -71,12 +71,12 @@ public class MouseOverListener extends JSFunctionExec
       } catch (Exception ex)
       {
 
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "JalviewLite javascript error: Couldn't send mouseOver with handler '"
                         + _listener + "'");
         if (ex instanceof netscape.javascript.JSException)
         {
-          System.err.println("Javascript Exception: "
+          jalview.bin.Console.errPrintln("Javascript Exception: "
                   + ((netscape.javascript.JSException) ex).getMessage());
         }
         ex.printStackTrace();
index e90b968..f0b3132 100644 (file)
@@ -156,7 +156,7 @@ public class MouseOverStructureListener extends JSFunctionExec
                     "" + (atom.getPdbResNum()), "" + atom.getAtomIndex() });
       } catch (Exception ex)
       {
-        System.err.println("Couldn't execute callback with " + _listenerfn
+        jalview.bin.Console.errPrintln("Couldn't execute callback with " + _listenerfn
                 + " for atomSpec: " + atom);
         ex.printStackTrace();
       }
@@ -172,7 +172,7 @@ public class MouseOverStructureListener extends JSFunctionExec
 
     if (JalviewLite.debug)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               this.getClass().getName() + " modelSet[0]: " + modelSet[0]);
       ssm.reportMapping();
     }
@@ -197,7 +197,7 @@ public class MouseOverStructureListener extends JSFunctionExec
         }
         // if (jvlite.debug)
         // {
-        // System.err.println("Mapped '" + modelSet[m] + "' to "
+        // jalview.bin.Console.errPrintln("Mapped '" + modelSet[m] + "' to "
         // + sequence[m].length + " sequences.");
         // }
       }
@@ -260,7 +260,7 @@ public class MouseOverStructureListener extends JSFunctionExec
           executeJavascriptFunction(true, _listenerfn, st);
         } catch (Exception ex)
         {
-          System.err.println("Couldn't execute callback with " + _listenerfn
+          jalview.bin.Console.errPrintln("Couldn't execute callback with " + _listenerfn
                   + " using args { " + st[0] + ", " + st[1] + ", " + st[2]
                   + "," + st[3] + "}"); // + ","+st[4]+"\n");
           ex.printStackTrace();
@@ -274,7 +274,7 @@ public class MouseOverStructureListener extends JSFunctionExec
        * executeJavascriptFunction( false, _listenerfn, st = new String[] {
        * "colourstruct", "" + ((jalview.appletgui.AlignmentPanel) source).av
        * .getViewId(), handle, "" }); } catch (Exception ex) {
-       * System.err.println("Couldn't execute callback with " + _listenerfn +
+       * jalview.bin.Console.errPrintln("Couldn't execute callback with " + _listenerfn +
        * " using args { " + st[0] + ", " + st[1] + ", " + st[2] + "," + st[3] +
        * "\n"); ex.printStackTrace();
        * 
index c0cdfee..c753dc1 100755 (executable)
@@ -246,7 +246,7 @@ public class GAlignFrame extends JInternalFrame
       }
     } catch (Exception e)
     {
-      System.err.println(e.toString());
+      jalview.bin.Console.errPrintln(e.toString());
     }
 
     if (Platform.allowMnemonics()) // was "not mac and not JS"
index 6594e2d..2f0c75e 100755 (executable)
@@ -76,7 +76,7 @@ public class GAlignmentPanel extends JPanel
 
   protected JPanel scalePanelHolder = newJPanel();
 
-  protected JPanel idPanelHolder = newJPanel();
+  public JPanel idPanelHolder = newJPanel();
 
   protected JPanel idSpaceFillerPanel1 = newJPanel();
 
index b0079b4..124c7c7 100755 (executable)
@@ -152,7 +152,7 @@ public class GDesktop extends JFrame
       APQHandlers.setAPQHandlers((Desktop) this);
     } catch (Exception e)
     {
-      System.out.println("Cannot set APQHandlers");
+      jalview.bin.Console.outPrintln("Cannot set APQHandlers");
       // e.printStackTrace();
     } catch (Throwable t)
     {
@@ -193,7 +193,7 @@ public class GDesktop extends JFrame
           inputURLMenuItem_actionPerformed(null);
         } catch (FileFormatException e1)
         {
-          System.err.println("Error loading from URL: " + e1.getMessage());
+          jalview.bin.Console.errPrintln("Error loading from URL: " + e1.getMessage());
         }
       }
     });
@@ -521,7 +521,7 @@ public class GDesktop extends JFrame
    */
   protected void quit()
   {
-    // System.out.println("********** GDesktop.quit()");
+    // jalview.bin.Console.outPrintln("********** GDesktop.quit()");
   }
 
   /**
index 8cb5b3c..5b04359 100644 (file)
@@ -295,7 +295,7 @@ public abstract class GStructureChooser extends JPanel
       mainFrame.pack();
     } catch (Exception e)
     {
-      System.out.println(e); // for JavaScript TypeError
+      jalview.bin.Console.outPrintln(e); // for JavaScript TypeError
       e.printStackTrace();
     }
   }
@@ -849,11 +849,11 @@ public abstract class GStructureChooser extends JPanel
 
   protected void closeAction(int preferredHeight)
   {
-    // System.out.println(">>>>>>>>>> closing internal frame!!!");
-    // System.out.println("width : " + mainFrame.getWidth());
-    // System.out.println("heigh : " + mainFrame.getHeight());
-    // System.out.println("x : " + mainFrame.getX());
-    // System.out.println("y : " + mainFrame.getY());
+    // jalview.bin.Console.outPrintln(">>>>>>>>>> closing internal frame!!!");
+    // jalview.bin.Console.outPrintln("width : " + mainFrame.getWidth());
+    // jalview.bin.Console.outPrintln("heigh : " + mainFrame.getHeight());
+    // jalview.bin.Console.outPrintln("x : " + mainFrame.getX());
+    // jalview.bin.Console.outPrintln("y : " + mainFrame.getY());
     tempUserPrefs.put("structureChooser.width", pnl_filter.getWidth());
     tempUserPrefs.put("structureChooser.height", preferredHeight);
     tempUserPrefs.put("structureChooser.x", mainFrame.getX());
index cfd41d0..554b997 100644 (file)
@@ -138,13 +138,13 @@ public abstract class JLogger implements JLoggerI
     {
       String logLine = String.format("%s: %s", loglevel.toString(),
               message);
-      System.out.println(logLine);
+      jalview.bin.Console.outPrintln(logLine);
       if (t != null)
       {
         if (loglevel.compareTo(LogLevel.DEBUG) <= 0)
           t.printStackTrace(System.err);
         else
-          System.err.println(t.getMessage());
+          jalview.bin.Console.errPrintln(t.getMessage());
       }
       return false;
     }
index b22bf4e..ad91464 100755 (executable)
@@ -464,7 +464,7 @@ public class Matrix implements MatrixI
           }
           else
           {
-            // System.out.println("Iteration " + iter);
+            // jalview.bin.Console.outPrintln("Iteration " + iter);
           }
 
           g = (d[l] - d[l - 1]) / (2.0 * e[l - 1]);
@@ -728,7 +728,7 @@ public class Matrix implements MatrixI
           }
           else
           {
-            // System.out.println("Iteration " + iter);
+            // jalview.bin.Console.outPrintln("Iteration " + iter);
           }
 
           g = (d[l] - d[l - 1]) / (2.0 * e[l - 1]);
index f3bf436..ea67f48 100755 (executable)
@@ -137,7 +137,7 @@ public class RotatableMatrix
     Float floatValue = Float.valueOf(degrees);
     if (cachedRotations.get(axis).containsKey(floatValue))
     {
-      // System.out.println("getRotation from cache: " + (int) degrees);
+      // jalview.bin.Console.outPrintln("getRotation from cache: " + (int) degrees);
       return cachedRotations.get(axis).get(floatValue);
     }
 
index 6f26036..bc2046e 100644 (file)
@@ -520,7 +520,7 @@ public class Jalview2XML
           }
         } catch (Exception x)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "IMPLEMENTATION ERROR: Failed to resolve forward reference for sequence "
                           + ref.getSref());
           x.printStackTrace();
@@ -534,29 +534,29 @@ public class Jalview2XML
     }
     if (unresolved > 0)
     {
-      System.err.println("Jalview Project Import: There were " + unresolved
+      jalview.bin.Console.errPrintln("Jalview Project Import: There were " + unresolved
               + " forward references left unresolved on the stack.");
     }
     if (failedtoresolve > 0)
     {
-      System.err.println("SERIOUS! " + failedtoresolve
+      jalview.bin.Console.errPrintln("SERIOUS! " + failedtoresolve
               + " resolvable forward references failed to resolve.");
     }
     if (incompleteSeqs != null && incompleteSeqs.size() > 0)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Jalview Project Import: There are " + incompleteSeqs.size()
                       + " sequences which may have incomplete metadata.");
       if (incompleteSeqs.size() < 10)
       {
         for (SequenceI s : incompleteSeqs.values())
         {
-          System.err.println(s.toString());
+          jalview.bin.Console.errPrintln(s.toString());
         }
       }
       else
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Too many to report. Skipping output of incomplete sequences.");
       }
     }
@@ -936,7 +936,7 @@ public class Jalview2XML
       object.setCreationDate(now);
     } catch (DatatypeConfigurationException e)
     {
-      System.err.println("error writing date: " + e.toString());
+      jalview.bin.Console.errPrintln("error writing date: " + e.toString());
     }
     object.setVersion(Cache.getDefault("VERSION", "Development Build"));
 
@@ -1003,14 +1003,14 @@ public class Jalview2XML
           // HAPPEN! (PF00072.15.stk does this)
           // JBPNote: Uncomment to debug writing out of files that do not read
           // back in due to ArrayOutOfBoundExceptions.
-          // System.err.println("vamsasSeq backref: "+id+"");
-          // System.err.println(jds.getName()+"
+          // jalview.bin.Console.errPrintln("vamsasSeq backref: "+id+"");
+          // jalview.bin.Console.errPrintln(jds.getName()+"
           // "+jds.getStart()+"-"+jds.getEnd()+" "+jds.getSequenceAsString());
-          // System.err.println("Hashcode: "+seqHash(jds));
+          // jalview.bin.Console.errPrintln("Hashcode: "+seqHash(jds));
           // SequenceI rsq = (SequenceI) seqRefIds.get(id + "");
-          // System.err.println(rsq.getName()+"
+          // jalview.bin.Console.errPrintln(rsq.getName()+"
           // "+rsq.getStart()+"-"+rsq.getEnd()+" "+rsq.getSequenceAsString());
-          // System.err.println("Hashcode: "+seqHash(rsq));
+          // jalview.bin.Console.errPrintln("Hashcode: "+seqHash(rsq));
         }
         else
         {
@@ -1763,7 +1763,7 @@ public class Jalview2XML
       try
       {
         fileName = fileName.replace('\\', '/');
-        System.out.println("Writing jar entry " + fileName);
+        jalview.bin.Console.outPrintln("Writing jar entry " + fileName);
         JarEntry entry = new JarEntry(fileName);
         jout.putNextEntry(entry);
         PrintWriter pout = new PrintWriter(
@@ -1784,7 +1784,7 @@ public class Jalview2XML
       } catch (Exception ex)
       {
         // TODO: raise error in GUI if marshalling failed.
-        System.err.println("Error writing Jalview project");
+        jalview.bin.Console.errPrintln("Error writing Jalview project");
         ex.printStackTrace();
       }
     }
@@ -2098,7 +2098,7 @@ public class Jalview2XML
       File file = new File(infilePath);
       if (file.exists() && jout != null)
       {
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "Writing jar entry " + jarEntryName + " (" + msg + ")");
         jout.putNextEntry(new JarEntry(jarEntryName));
         copyAll(is, jout);
@@ -2959,7 +2959,7 @@ public class Jalview2XML
         });
       } catch (Exception x)
       {
-        System.err.println("Error loading alignment: " + x.getMessage());
+        jalview.bin.Console.errPrintln("Error loading alignment: " + x.getMessage());
       }
     }
     return af;
@@ -2998,19 +2998,19 @@ public class Jalview2XML
         {
           if (bytes != null)
           {
-            // System.out.println("Jalview2XML: opening byte jarInputStream for
+            // jalview.bin.Console.outPrintln("Jalview2XML: opening byte jarInputStream for
             // bytes.length=" + bytes.length);
             return new JarInputStream(new ByteArrayInputStream(bytes));
           }
           if (_url != null)
           {
-            // System.out.println("Jalview2XML: opening url jarInputStream for "
+            // jalview.bin.Console.outPrintln("Jalview2XML: opening url jarInputStream for "
             // + _url);
             return new JarInputStream(_url.openStream());
           }
           else
           {
-            // System.out.println("Jalview2XML: opening file jarInputStream for
+            // jalview.bin.Console.outPrintln("Jalview2XML: opening file jarInputStream for
             // " + file);
             return new JarInputStream(new FileInputStream(file));
           }
@@ -3117,11 +3117,11 @@ public class Jalview2XML
     {
       ex.printStackTrace();
       errorMessage = "Couldn't locate Jalview XML file : " + file;
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Exception whilst loading jalview XML file : " + ex + "\n");
     } catch (Exception ex)
     {
-      System.err.println("Parsing as Jalview Version 2 file failed.");
+      jalview.bin.Console.errPrintln("Parsing as Jalview Version 2 file failed.");
       ex.printStackTrace(System.err);
       if (attemptversion1parse)
       {
@@ -3133,18 +3133,18 @@ public class Jalview2XML
       }
       if (af != null)
       {
-        System.out.println("Successfully loaded archive file");
+        jalview.bin.Console.outPrintln("Successfully loaded archive file");
         return af;
       }
       ex.printStackTrace();
 
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Exception whilst loading jalview XML file : " + ex + "\n");
     } catch (OutOfMemoryError e)
     {
       // Don't use the OOM Window here
       errorMessage = "Out of memory loading jalview XML file";
-      System.err.println("Out of memory whilst loading jalview XML file");
+      jalview.bin.Console.errPrintln("Out of memory whilst loading jalview XML file");
       e.printStackTrace();
     }
 
@@ -3248,7 +3248,7 @@ public class Jalview2XML
         Desktop.addInternalFrame(af, view.getTitle(),
                 safeInt(view.getWidth()), safeInt(view.getHeight()));
         af.setMenusForViewport();
-        System.err.println("Failed to restore view " + view.getTitle()
+        jalview.bin.Console.errPrintln("Failed to restore view " + view.getTitle()
                 + " to split frame");
       }
     }
@@ -3327,7 +3327,7 @@ public class Jalview2XML
       }
       else
       {
-        System.err.println("Problem loading Jalview file: " + errorMessage);
+        jalview.bin.Console.errPrintln("Problem loading Jalview file: " + errorMessage);
       }
     }
     errorMessage = null;
@@ -3525,7 +3525,7 @@ public class Jalview2XML
           if (tmpSeq.getStart() != jseq.getStart()
                   || tmpSeq.getEnd() != jseq.getEnd())
           {
-            System.err.println(String.format(
+            jalview.bin.Console.errPrintln(String.format(
                     "Warning JAL-2154 regression: updating start/end for sequence %s from %d/%d to %d/%d",
                     tmpSeq.getName(), tmpSeq.getStart(), tmpSeq.getEnd(),
                     jseq.getStart(), jseq.getEnd()));
@@ -4256,7 +4256,7 @@ public class Jalview2XML
       // XML.
       // and then recover its containing af to allow the settings to be applied.
       // TODO: fix for vamsas demo
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "About to recover a viewport for existing alignment: Sequence set ID is "
                       + uniqueSeqSetId);
       Object seqsetobj = retrieveExistingObj(uniqueSeqSetId);
@@ -4265,13 +4265,13 @@ public class Jalview2XML
         if (seqsetobj instanceof String)
         {
           uniqueSeqSetId = (String) seqsetobj;
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Recovered extant sequence set ID mapping for ID : New Sequence set ID is "
                           + uniqueSeqSetId);
         }
         else
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Warning : Collision between sequence set ID string and existing jalview object mapping.");
         }
 
@@ -4711,7 +4711,7 @@ public class Jalview2XML
         createOrLinkStructureViewer(entry, af, ap, jprovider);
       } catch (Exception e)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Error loading structure viewer: " + e.getMessage());
         // failed - try the next one
       }
@@ -4915,7 +4915,7 @@ public class Jalview2XML
             || version.equalsIgnoreCase("Test")
             || version.equalsIgnoreCase("AUTOMATED BUILD"))
     {
-      System.err.println("Assuming project file with "
+      jalview.bin.Console.errPrintln("Assuming project file with "
               + (version == null ? "null" : version)
               + " is compatible with Jalview version " + supported);
       return true;
@@ -4962,7 +4962,7 @@ public class Jalview2XML
     //
     // @Override
     // protected void processKeyEvent(java.awt.event.KeyEvent e) {
-    // System.out.println("Jalview2XML AF " + e);
+    // jalview.bin.Console.outPrintln("Jalview2XML AF " + e);
     // super.processKeyEvent(e);
     //
     // }
@@ -5377,7 +5377,7 @@ public class Jalview2XML
     }
     if (matchedAnnotation == null)
     {
-      System.err.println("Failed to match annotation colour scheme for "
+      jalview.bin.Console.errPrintln("Failed to match annotation colour scheme for "
               + annotationId);
       return null;
     }
@@ -5836,7 +5836,7 @@ public class Jalview2XML
         }
         // TODO: merges will never happen if we 'know' we have the real dataset
         // sequence - this should be detected when id==dssid
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "DEBUG Notice:  Merged dataset sequence (if you see this often, post at http://issues.jalview.org/browse/JAL-1474)"); // ("
         // + (pre ? "prepended" : "") + " "
         // + (post ? "appended" : ""));
@@ -6029,7 +6029,7 @@ public class Jalview2XML
       }
       else
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Warning - making up dataset sequence id for DbRef sequence map reference");
         sqid = ((Object) ms).toString(); // make up a new hascode for
         // undefined dataset sequence hash
@@ -6710,7 +6710,7 @@ public class Jalview2XML
     } catch (IllegalStateException e)
     {
       // mixing AND and OR conditions perhaps
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               String.format("Error reading filter conditions for '%s': %s",
                       featureType, e.getMessage()));
       // return as much as was parsed up to the error
@@ -6791,7 +6791,7 @@ public class Jalview2XML
       }
       else
       {
-        System.err.println("Malformed compound filter condition");
+        jalview.bin.Console.errPrintln("Malformed compound filter condition");
       }
     }
   }
index ad1fa4a..65631e3 100644 (file)
@@ -229,7 +229,7 @@ public class AnnotationRenderer
           int iconOffset, int startRes, int column, boolean validRes,
           boolean validEnd)
   {
-    // System.out.println(nonCanColor);
+    // jalview.bin.Console.outPrintln(nonCanColor);
 
     g.setColor(nonCanColor);
     int sCol = (lastSSX / charWidth)
@@ -245,7 +245,7 @@ public class AnnotationRenderer
     boolean diffdownstream = !validRes || !validEnd
             || row_annotations[column] == null
             || !dc.equals(row_annotations[column].displayCharacter);
-    // System.out.println("Column "+column+" diff up: "+diffupstream+"
+    // jalview.bin.Console.outPrintln("Column "+column+" diff up: "+diffupstream+"
     // down:"+diffdownstream);
     // If a closing base pair half of the stem, display a backward arrow
     if (column > 0 && Rna.isClosingParenthesis(dc))
@@ -784,7 +784,7 @@ public class AnnotationRenderer
               {
 
                 // int nb_annot = x - temp;
-                // System.out.println("\t type :"+lastSS+"\t x :"+x+"\t nbre
+                // jalview.bin.Console.outPrintln("\t type :"+lastSS+"\t x :"+x+"\t nbre
                 // annot :"+nb_annot);
                 switch (lastSS)
                 {
@@ -1006,7 +1006,7 @@ public class AnnotationRenderer
           case 'y':
           case 'Z':
           case 'z':
-            // System.out.println(lastSS);
+            // jalview.bin.Console.outPrintln(lastSS);
             Color nonCanColor = getNotCanonicalColor(lastSS);
             drawNotCanonicalAnnot(g, nonCanColor, row_annotations, lastSSX,
                     x, y, iconOffset, startRes, column, validRes, validEnd);
@@ -1091,7 +1091,7 @@ public class AnnotationRenderer
               }
               else
               {
-                System.err.println(
+                jalview.bin.Console.errPrintln(
                         "rendered with " + renderer.getClass().toString());
               }
             }
@@ -1122,17 +1122,17 @@ public class AnnotationRenderer
       {
         if (clipst)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Start clip at : " + yfrom + " (index " + f_i + ")");
         }
         if (clipend)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "End clip at : " + yto + " (index " + f_to + ")");
         }
       }
       ;
-      System.err.println("Annotation Rendering time:"
+      jalview.bin.Console.errPrintln("Annotation Rendering time:"
               + (System.currentTimeMillis() - stime));
     }
     ;
@@ -1455,7 +1455,7 @@ public class AnnotationRenderer
           // lm is not necessary - we can just use fm - could be off by no more
           // than 0.5 px
           // LineMetrics lm = g.getFontMetrics(ofont).getLineMetrics("Q", g);
-          // System.out.println(asc + " " + dec + " " + (asc - lm.getAscent())
+          // jalview.bin.Console.outPrintln(asc + " " + dec + " " + (asc - lm.getAscent())
           // + " " + (dec - lm.getDescent()));
 
           double asc = fm.getAscent();
@@ -1749,7 +1749,7 @@ public class AnnotationRenderer
       return new Color(0, 80, 255);
 
     default:
-      System.out.println("This is not a interaction : " + lastss);
+      jalview.bin.Console.outPrintln("This is not a interaction : " + lastss);
       return null;
 
     }
index 8f38d02..0471145 100644 (file)
@@ -109,11 +109,12 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI
     }
     eRes = Math.min(eRes, aa_annotations.length);
 
-    int x = 0, y2 = y;
+    int x = 0, topY = y;
 
-    g.setColor(shade.no_data);
-
-    g.drawLine(x, y2, (eRes - sRes) * charWidth, y2);
+    // uncomment below to render whole area of matrix as pink
+    // g.setColor(shade.no_data);
+    // g.fillRect(x, topY-_aa.height, (eRes - sRes) * charWidth, _aa.graphHeight);
+    
     boolean showGroups = _aa.isShowGroupsForContactMatrix();
     int column;
     int aaMax = aa_annotations.length - 1;
@@ -165,11 +166,11 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI
       final ContactGeometry cgeom = new ContactGeometry(contacts,
               _aa.graphHeight);
 
-      for (int ht = y2, eht = y2
-              - _aa.graphHeight; ht >= eht; ht -= cgeom.pixels_step)
+      for (int ht = 0, botY = topY
+              - _aa.height; ht < _aa.graphHeight; ht += cgeom.pixels_step)
       {
-        ContactGeometry.contactInterval ci = cgeom.mapFor(y2 - ht,
-                y2 - ht + cgeom.pixels_step);
+        ContactGeometry.contactInterval ci = cgeom.mapFor(ht,
+                ht + cgeom.pixels_step);
         // cstart = (int) Math.floor(((double) y2 - ht) * contacts_per_pixel);
         // cend = (int) Math.min(contact_height,
         // Math.ceil(cstart + contacts_per_pixel * pixels_step));
@@ -216,11 +217,11 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI
         g.setColor(col);
         if (cgeom.pixels_step > 1)
         {
-          g.fillRect(x * charWidth, ht, charWidth, 1 + cgeom.pixels_step);
+          g.fillRect(x * charWidth, botY+ht, charWidth, 1 + cgeom.pixels_step);
         }
         else
         {
-          g.drawLine(x * charWidth, ht, (x + 1) * charWidth, ht);
+          g.drawLine(x * charWidth, botY+ht, (x + 1) * charWidth, botY+ht);
         }
       }
       x++;
index a37882f..32672dd 100644 (file)
@@ -94,7 +94,7 @@ public class RestHandler extends AbstractRequestHandler
     final String reply = "REST not yet implemented; received "
             + request.getMethod() + ": " + request.getRequestURL()
             + (queryString == null ? "" : "?" + queryString);
-    System.out.println(reply);
+    jalview.bin.Console.outPrintln(reply);
 
     response.setHeader("Cache-Control", "no-cache/no-store");
     response.setHeader("Content-type", "text/plain");
index 061ccd4..f80669d 100644 (file)
@@ -117,7 +117,7 @@ public class ColourSchemeLoader
     } catch (Exception ex)
     {
       // used to try to parse a V1 Castor generated colours file
-      System.err.println("Failed to read colour scheme from " + filePath
+      jalview.bin.Console.errPrintln("Failed to read colour scheme from " + filePath
               + " : " + ex.toString());
     }
 
index 698769c..e2a8cb3 100644 (file)
@@ -77,7 +77,7 @@ public class ColourSchemes
                 cs.getSchemeClass().getDeclaredConstructor().newInstance());
       } catch (InstantiationException | IllegalAccessException e)
       {
-        System.err.println("Error instantiating colour scheme for "
+        jalview.bin.Console.errPrintln("Error instantiating colour scheme for "
                 + cs.toString() + " " + e.getMessage());
         e.printStackTrace();
       } catch (ReflectiveOperationException roe)
@@ -97,7 +97,7 @@ public class ColourSchemes
     String name = cs.getSchemeName();
     if (name == null)
     {
-      System.err.println("ColourScheme name may not be null");
+      jalview.bin.Console.errPrintln("ColourScheme name may not be null");
       return;
     }
 
index 9d2c738..fe71d31 100755 (executable)
@@ -46,7 +46,7 @@ public class Consensus
     this.mask = setNums(s);
 
     // for (int i=0; i < mask.length; i++) {
-    // System.out.println(mask[i] + " " + ResidueProperties.aa[mask[i]]);
+    // jalview.bin.Console.outPrintln(mask[i] + " " + ResidueProperties.aa[mask[i]]);
     // }
   }
 
@@ -56,7 +56,7 @@ public class Consensus
   @Deprecated
   public boolean isConserved(int[][] cons2, int col, int size)
   {
-    System.out.println("DEPRECATED!!!!");
+    jalview.bin.Console.outPrintln("DEPRECATED!!!!");
     return isConserved(cons2, col, size, true);
   }
 
@@ -75,7 +75,7 @@ public class Consensus
 
     if (tot > ((threshold * size) / 100))
     {
-      // System.out.println("True conserved "+tot+" from "+threshold+" out of
+      // jalview.bin.Console.outPrintln("True conserved "+tot+" from "+threshold+" out of
       // "+size+" : "+maskstr);
       return true;
     }
index dc7971b..4884283 100644 (file)
@@ -65,9 +65,9 @@ public class CovariationColourScheme extends ResidueColourScheme
 
     for (int x = 0; x < this.annotation._rnasecstr.length; x++)
     {
-      // System.out.println(this.annotation._rnasecstr[x] + " Begin" +
+      // jalview.bin.Console.outPrintln(this.annotation._rnasecstr[x] + " Begin" +
       // this.annotation._rnasecstr[x].getBegin());
-      // System.out.println(this.annotation._rnasecstr[x].getFeatureGroup());
+      // jalview.bin.Console.outPrintln(this.annotation._rnasecstr[x].getFeatureGroup());
       // pairs.put(this.annotation._rnasecstr[x].getBegin(),
       // this.annotation._rnasecstr[x].getEnd());
 
@@ -104,7 +104,7 @@ public class CovariationColourScheme extends ResidueColourScheme
   @Override
   public Color findColour(char c)
   {
-    // System.out.println("called"); log.debug
+    // jalview.bin.Console.outPrintln("called"); log.debug
     // Generate a random pastel color
 
     return ResidueProperties.purinepyrimidine[ResidueProperties.purinepyrimidineIndex[c]];// jalview.util.ColorUtils.generateRandomColor(Color.white);
@@ -124,16 +124,16 @@ public class CovariationColourScheme extends ResidueColourScheme
   {
     Color currentColour = Color.white;
     String currentHelix = null;
-    // System.out.println(c + " " + j);
+    // jalview.bin.Console.outPrintln(c + " " + j);
     currentHelix = positionsToHelix.get(j);
-    // System.out.println(positionsToHelix.get(j));
+    // jalview.bin.Console.outPrintln(positionsToHelix.get(j));
 
     if (currentHelix != null)
     {
       currentColour = helixcolorhash.get(currentHelix);
     }
 
-    // System.out.println(c + " " + j + " helix " + currentHelix + " " +
+    // jalview.bin.Console.outPrintln(c + " " + j + " helix " + currentHelix + " " +
     // currentColour);
     return currentColour;
   }
index f1bade1..3d91b58 100644 (file)
@@ -395,7 +395,7 @@ public class FeatureColour implements FeatureColourI
         {
           if (!ttype.toLowerCase(Locale.ROOT).startsWith("no"))
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Ignoring unrecognised threshold type : " + ttype);
           }
         }
@@ -409,19 +409,19 @@ public class FeatureColour implements FeatureColourI
           featureColour.setThreshold(Float.valueOf(tval).floatValue());
         } catch (Exception e)
         {
-          System.err.println("Couldn't parse threshold value as a float: ("
+          jalview.bin.Console.errPrintln("Couldn't parse threshold value as a float: ("
                   + tval + ")");
         }
       }
       if (gcol.hasMoreTokens())
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Ignoring additional tokens in parameters in graduated colour specification\n");
         while (gcol.hasMoreTokens())
         {
-          System.err.println(BAR + gcol.nextToken());
+          jalview.bin.Console.errPrintln(BAR + gcol.nextToken());
         }
-        System.err.println("\n");
+        jalview.bin.Console.errPrintln("\n");
       }
       return featureColour;
     } catch (Exception e)
index 33b275d..62b4579 100644 (file)
@@ -142,10 +142,10 @@ public class RNAHelicesColour extends ResidueColourScheme
       {
 
         /*
-         * System.out.println(this.annotation._rnasecstr[x] + " Begin" +
+         * jalview.bin.Console.outPrintln(this.annotation._rnasecstr[x] + " Begin" +
          * this.annotation._rnasecstr[x].getBegin());
          */
-        // System.out.println(this.annotation._rnasecstr[x].getFeatureGroup());
+        // jalview.bin.Console.outPrintln(this.annotation._rnasecstr[x].getFeatureGroup());
 
         positionsToHelix.put(this.annotation._rnasecstr[x].getBegin(),
                 this.annotation._rnasecstr[x].getFeatureGroup());
index 42d03ec..f8b7856 100755 (executable)
@@ -2414,7 +2414,7 @@ public class ResidueProperties
   public static void main(String[] args)
   {
     Hashtable<String, Vector<String>> aaProps = new Hashtable<>();
-    System.out.println("my %aa = {");
+    jalview.bin.Console.outPrintln("my %aa = {");
     // invert property hashes
     for (String pname : propHash.keySet())
     {
@@ -2446,12 +2446,12 @@ public class ResidueProperties
         System.out.print("'" + props.nextElement() + "'");
         if (props.hasMoreElements())
         {
-          System.out.println(", ");
+          jalview.bin.Console.outPrintln(", ");
         }
       }
-      System.out.println("]" + (res.hasMoreElements() ? "," : ""));
+      jalview.bin.Console.outPrintln("]" + (res.hasMoreElements() ? "," : ""));
     }
-    System.out.println("};");
+    jalview.bin.Console.outPrintln("};");
   }
 
   // to here
index d55ffbf..ec0f008 100755 (executable)
@@ -108,7 +108,7 @@ public class UserColourScheme extends ResidueColourScheme
 
     if (col == null)
     {
-      System.out.println("Making colour from name: " + colour);
+      jalview.bin.Console.outPrintln("Making colour from name: " + colour);
       col = ColorUtils.createColourFromName(colour);
     }
 
@@ -234,7 +234,7 @@ public class UserColourScheme extends ResidueColourScheme
       }
     } catch (Exception ex)
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "Error parsing userDefinedColours:\n" + token + "\n" + ex);
     }
 
index 64c1547..8968742 100644 (file)
@@ -155,16 +155,16 @@ public class StructureSelectionManager
   {
     if (mappings.isEmpty())
     {
-      System.err.println("reportMapping: No PDB/Sequence mappings.");
+      jalview.bin.Console.errPrintln("reportMapping: No PDB/Sequence mappings.");
     }
     else
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "reportMapping: There are " + mappings.size() + " mappings.");
       int i = 0;
       for (StructureMapping sm : mappings)
       {
-        System.err.println("mapping " + i++ + " : " + sm.pdbfile);
+        jalview.bin.Console.errPrintln("mapping " + i++ + " : " + sm.pdbfile);
       }
     }
   }
@@ -617,12 +617,12 @@ public class StructureSelectionManager
               chain.transferResidueAnnotation(siftsMapping, null);
             } catch (SiftsException e)
             {
-              System.err.println(e.getMessage());
+              jalview.bin.Console.errPrintln(e.getMessage());
             } catch (Exception e)
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "Unexpected exception during SIFTS mapping - falling back to NW for this sequence/structure pair");
-              System.err.println(e.getMessage());
+              jalview.bin.Console.errPrintln(e.getMessage());
             }
           }
           if (!foundSiftsMappings.isEmpty())
@@ -1254,7 +1254,7 @@ public class StructureSelectionManager
      * 
      * if (mappings[j].sequence == seq && mappings[j].getPdbId().equals(pdbid)
      * && mappings[j].pdbfile.equals(sl.getPdbFile())) {
-     * System.out.println(pdbid+" "+mappings[j].getPdbId() +"
+     * jalview.bin.Console.outPrintln(pdbid+" "+mappings[j].getPdbId() +"
      * "+mappings[j].pdbfile);
      * 
      * java.awt.Color col; for(int index=0; index<seq.getLength(); index++) {
@@ -1351,7 +1351,7 @@ public class StructureSelectionManager
       boolean removed = seqmappings.remove(acf);
       if (removed && seqmappings.isEmpty())
       { // debug
-        System.out.println("All mappings removed");
+        jalview.bin.Console.outPrintln("All mappings removed");
       }
     }
   }
index 7d9674e..9f15e55 100644 (file)
@@ -780,7 +780,7 @@ public abstract class AAStructureBindingModel
 
     if (waiting)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Timed out waiting for structure viewer to load file "
                       + notLoaded);
       return false;
index 850a230..c298639 100644 (file)
@@ -99,7 +99,7 @@ public class IdentifiersUrlProvider extends UrlProviderImpl
       }
       else
       {
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "Unexpected key returned from identifiers jalview service");
         return idData;
       }
@@ -132,7 +132,7 @@ public class IdentifiersUrlProvider extends UrlProviderImpl
     // BH 2018 -- added more valuable report
     if (errorMessage != null)
     {
-      System.err.println("IdentifiersUrlProvider: cannot read " + idFileName
+      jalview.bin.Console.errPrintln("IdentifiersUrlProvider: cannot read " + idFileName
               + ": " + errorMessage);
     }
     return idData;
index 2cb0173..7d8e4e4 100644 (file)
@@ -84,7 +84,7 @@ public class UrlProvider implements UrlProviderI
       }
     }
 
-    System.out.println(
+    jalview.bin.Console.outPrintln(
             "Error initialising UrlProvider - no custom url provider");
     return null;
   }
index cf44dcb..f6145c2 100644 (file)
@@ -138,20 +138,20 @@ public class AWTConsole extends WindowAdapter
     // testing part
     // you may omit this part for your application
     //
-    System.out.println("Hello World 2");
-    System.out.println("All fonts available to Graphic2D:\n");
+    jalview.bin.Console.outPrintln("Hello World 2");
+    jalview.bin.Console.outPrintln("All fonts available to Graphic2D:\n");
     GraphicsEnvironment ge = GraphicsEnvironment
             .getLocalGraphicsEnvironment();
     String[] fontNames = ge.getAvailableFontFamilyNames();
     for (int n = 0; n < fontNames.length; n++)
     {
-      System.out.println(fontNames[n]);
+      jalview.bin.Console.outPrintln(fontNames[n]);
     }
     // Testing part: simple an error thrown anywhere in this JVM will be printed
     // on the Console
     // We do it with a seperate Thread becasue we don't wan't to break a Thread
     // used by the Console.
-    System.out.println("\nLets throw an error on this console");
+    jalview.bin.Console.outPrintln("\nLets throw an error on this console");
     errorThrower = new Thread(this);
     errorThrower.setDaemon(true);
     errorThrower.start();
index 4832588..b0f25eb 100644 (file)
@@ -86,7 +86,7 @@ public class ChannelProperties
     if (channelPropsURL == null)
     {
       // complete failure of channel_properties, set all properties to defaults
-      System.err.println("Failed to find '/" + CHANNEL_PROPERTIES_FILENAME
+      jalview.bin.Console.errPrintln("Failed to find '/" + CHANNEL_PROPERTIES_FILENAME
               + "' file at '"
               + (channelPropsURL == null ? "null"
                       : channelPropsURL.toString())
@@ -102,7 +102,7 @@ public class ChannelProperties
         channelPropsIS.close();
       } catch (IOException e)
       {
-        System.err.println(e.getMessage());
+        jalview.bin.Console.errPrintln(e.getMessage());
         // return false;
       }
     }
@@ -157,10 +157,10 @@ public class ChannelProperties
         channelProps.load(is);
       } catch (FileNotFoundException e)
       {
-        System.err.println(e.getMessage());
+        jalview.bin.Console.errPrintln(e.getMessage());
       } catch (IOException e)
       {
-        System.err.println(e.getMessage());
+        jalview.bin.Console.errPrintln(e.getMessage());
       }
     }
   }
@@ -214,7 +214,7 @@ public class ChannelProperties
       }
       else
       {
-        System.err.println("Failed to get channel property '" + key + "'");
+        jalview.bin.Console.errPrintln("Failed to get channel property '" + key + "'");
       }
     }
     return null;
@@ -266,7 +266,7 @@ public class ChannelProperties
       img = imgIcon == null ? null : imgIcon.getImage();
       if (img == null)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Failed to load channel image " + key + "=" + path);
         if (!useClassDefaultImage)
         {
@@ -293,7 +293,7 @@ public class ChannelProperties
       {
         return urlMap().getOrDefault(key, null);
       }
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Do not use getImageURL(key) before using getImage(key...)");
     }
     return null;
index 6734735..b728c9d 100644 (file)
@@ -68,7 +68,18 @@ public class ColorUtils
     return color;
 
   }
+  
+  /**
+   * 
+   * @return random color
+   */
+  public static final Color getARandomColor()
+  {
 
+    Color col = new Color((int) (Math.random() * 255),
+            (int) (Math.random() * 255), (int) (Math.random() * 255));
+    return col;
+  }
   /**
    * Convert to Tk colour code format
    * 
index 98d5e11..a101d82 100755 (executable)
@@ -406,7 +406,7 @@ public class DBRefUtils
         }
         else
         {
-          System.err.println("Malformed PDB DR line:" + acn);
+          jalview.bin.Console.errPrintln("Malformed PDB DR line:" + acn);
         }
       }
       else
index 67309a0..bd375bb 100644 (file)
@@ -585,7 +585,7 @@ public class GroupUrlLink
               // debug
               /*
                * for (int s = 0; s <= rg.numSubs(); s++) {
-               * System.err.println("Sub " + s + " : " + rg.matchedFrom(s) +
+               * jalview.bin.Console.errPrintln("Sub " + s + " : " + rg.matchedFrom(s) +
                * " : " + rg.matchedTo(s) + " : '" + rg.stringMatched(s) + "'");
                * }
                */
@@ -787,32 +787,32 @@ public class GroupUrlLink
 
     if (url == null)
     {
-      System.out.println("Created NO urls.");
+      jalview.bin.Console.outPrintln("Created NO urls.");
     }
     else
     {
-      System.out.println("Created a url from " + ((int[]) url[0])[0]
+      jalview.bin.Console.outPrintln("Created a url from " + ((int[]) url[0])[0]
               + "out of " + idstring[0].length + " sequences.");
-      System.out.println("Sequences that did not match:");
+      jalview.bin.Console.outPrintln("Sequences that did not match:");
       for (int sq = 0; sq < idstring[0].length; sq++)
       {
         if (!((boolean[]) url[1])[sq])
         {
-          System.out.println("Seq " + sq + ": " + idstring[0][sq] + "\t: "
+          jalview.bin.Console.outPrintln("Seq " + sq + ": " + idstring[0][sq] + "\t: "
                   + idstring[1][sq]);
         }
       }
-      System.out.println("Sequences that DID match:");
+      jalview.bin.Console.outPrintln("Sequences that DID match:");
       for (int sq = 0; sq < idstring[0].length; sq++)
       {
         if (((boolean[]) url[1])[sq])
         {
-          System.out.println("Seq " + sq + ": " + idstring[0][sq] + "\t: "
+          jalview.bin.Console.outPrintln("Seq " + sq + ": " + idstring[0][sq] + "\t: "
                   + idstring[1][sq]);
         }
       }
-      System.out.println("The generated URL:");
-      System.out.println(((String[]) url[3])[0]);
+      jalview.bin.Console.outPrintln("The generated URL:");
+      jalview.bin.Console.outPrintln(((String[]) url[3])[0]);
     }
   }
 
@@ -849,15 +849,15 @@ public class GroupUrlLink
       GroupUrlLink ul = new GroupUrlLink(links[i]);
       if (ul.isValid())
       {
-        System.out.println("\n\n\n");
-        System.out.println(
+        jalview.bin.Console.outPrintln("\n\n\n");
+        jalview.bin.Console.outPrintln(
                 "Link " + i + " " + links[i] + " : " + ul.toString());
-        System.out.println(" pref : " + ul.getUrl_prefix());
-        System.out.println(" IdReplace : " + ul.getIDRegexReplace());
-        System.out.println(" SeqReplace : " + ul.getSeqRegexReplace());
-        System.out.println(" Suffixes : " + ul.getUrl_suffix());
+        jalview.bin.Console.outPrintln(" pref : " + ul.getUrl_prefix());
+        jalview.bin.Console.outPrintln(" IdReplace : " + ul.getIDRegexReplace());
+        jalview.bin.Console.outPrintln(" SeqReplace : " + ul.getSeqRegexReplace());
+        jalview.bin.Console.outPrintln(" Suffixes : " + ul.getUrl_suffix());
 
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "<insert input id and sequence strings here> Without onlyIfMatches:");
         Object[] urls;
         try
@@ -867,9 +867,9 @@ public class GroupUrlLink
           testUrls(ul, seqsandids, urls);
         } catch (UrlStringTooLongException ex)
         {
-          System.out.println("too long exception " + ex);
+          jalview.bin.Console.outPrintln("too long exception " + ex);
         }
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "<insert input id and sequence strings here> With onlyIfMatches set:");
         try
         {
@@ -878,12 +878,12 @@ public class GroupUrlLink
           testUrls(ul, seqsandids, urls);
         } catch (UrlStringTooLongException ex)
         {
-          System.out.println("too long exception " + ex);
+          jalview.bin.Console.outPrintln("too long exception " + ex);
         }
       }
       else
       {
-        System.err.println("Invalid URLLink : " + links[i] + " : "
+        jalview.bin.Console.errPrintln("Invalid URLLink : " + links[i] + " : "
                 + ul.getInvalidMessage());
       }
     }
index 0454cab..5438d4e 100644 (file)
@@ -25,10 +25,11 @@ import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.ProtocolException;
 import java.net.URL;
-import java.util.List;
 
 import javax.ws.rs.HttpMethod;
 
+import jalview.bin.Cache;
+
 public class HttpUtils
 {
 
@@ -87,7 +88,7 @@ public class HttpUtils
   public static boolean checkUrlAvailable(URL url, int readTimeout)
           throws IOException, ProtocolException
   {
-    // System.out.println(System.currentTimeMillis() + " " + url);
+    // jalview.bin.Console.outPrintln(System.currentTimeMillis() + " " + url);
 
     HttpURLConnection connection = (HttpURLConnection) url.openConnection();
 
@@ -101,4 +102,46 @@ public class HttpUtils
     return connection.getResponseCode() == 200;
   }
 
+  public static String getUserAgent()
+  {
+    return getUserAgent(null);
+  }
+
+  public static String getUserAgent(String className)
+  {
+    StringBuilder sb = new StringBuilder();
+    sb.append("Jalview");
+    sb.append('/');
+    sb.append(Cache.getDefault("VERSION", "Unknown"));
+    sb.append(" (");
+    sb.append(System.getProperty("os.name"));
+    sb.append("; ");
+    sb.append(System.getProperty("os.arch"));
+    sb.append(' ');
+    sb.append(System.getProperty("os.name"));
+    sb.append(' ');
+    sb.append(System.getProperty("os.version"));
+    sb.append("; ");
+    sb.append("java/");
+    sb.append(System.getProperty("java.version"));
+    sb.append("; ");
+    sb.append("jalview/");
+    sb.append(ChannelProperties.getProperty("channel"));
+    if (className != null)
+    {
+      sb.append("; ");
+      sb.append(className);
+    }
+    String installation = Cache.applicationProperties
+            .getProperty("INSTALLATION");
+    if (installation != null)
+    {
+      sb.append("; ");
+      sb.append(installation);
+    }
+    sb.append(')');
+    sb.append(" help@jalview.org");
+    return sb.toString();
+  }
+
 }
index 5bd4a08..e4f393c 100644 (file)
@@ -29,9 +29,21 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Properties;
 
+import jalview.bin.Console;
+
 public class LaunchUtils
 {
 
+  // setting these is LaunchUtils so don't need to import Platform
+  public final static boolean isMac = System.getProperty("os.name")
+          .indexOf("Mac") > -1;
+
+  public final static boolean isWindows = System.getProperty("os.name")
+          .indexOf("Win") > -1;
+
+  private static boolean isJS = /** @j2sNative true || */
+          false;
+
   public static void loadChannelProps(File dir)
   {
     ChannelProperties.loadProps(dir);
@@ -65,7 +77,7 @@ public class LaunchUtils
         return null;
       } catch (IOException e)
       {
-        System.err.println(e.getMessage());
+        jalview.bin.Console.errPrintln(e.getMessage());
         return null;
       }
     }
@@ -81,7 +93,7 @@ public class LaunchUtils
 
   public static int getJavaCompileVersion()
   {
-    if (Platform.isJS())
+    if (LaunchUtils.isJS)
     {
       return -1;
     }
@@ -103,22 +115,22 @@ public class LaunchUtils
               null);
       if (JCV == null)
       {
-        System.out.println(
+        Console.errPrintln(
                 "Could not obtain JAVA_COMPILE_VERSION for comparison");
         return -2;
       }
       JAVA_COMPILE_VERSION = Integer.parseInt(JCV);
     } catch (MalformedURLException e)
     {
-      System.err.println("Could not find " + buildDetails);
+      jalview.bin.Console.errPrintln("Could not find " + buildDetails);
       return -3;
     } catch (IOException e)
     {
-      System.err.println("Could not load " + buildDetails);
+      jalview.bin.Console.errPrintln("Could not load " + buildDetails);
       return -4;
     } catch (NumberFormatException e)
     {
-      System.err.println("Could not parse JAVA_COMPILE_VERSION");
+      jalview.bin.Console.errPrintln("Could not parse JAVA_COMPILE_VERSION");
       return -5;
     }
 
@@ -129,7 +141,7 @@ public class LaunchUtils
 
   public static int getJavaVersion()
   {
-    if (Platform.isJS())
+    if (LaunchUtils.isJS)
     {
       return -1;
     }
@@ -142,7 +154,7 @@ public class LaunchUtils
       String JV = System.getProperty("java.version");
       if (JV == null)
       {
-        System.out.println("Could not obtain java.version for comparison");
+        Console.errPrintln("Could not obtain java.version for comparison");
         return -2;
       }
       if (JV.startsWith("1."))
@@ -153,7 +165,7 @@ public class LaunchUtils
               : Integer.parseInt(JV.substring(0, JV.indexOf(".")));
     } catch (NumberFormatException e)
     {
-      System.err.println("Could not parse java.version");
+      jalview.bin.Console.errPrintln("Could not parse java.version");
       return -3;
     }
     return JAVA_VERSION;
@@ -161,7 +173,7 @@ public class LaunchUtils
 
   public static boolean checkJavaVersion()
   {
-    if (Platform.isJS())
+    if (LaunchUtils.isJS)
     {
       return true;
     }
@@ -174,7 +186,7 @@ public class LaunchUtils
 
     if (java_compile_version <= 0 || java_version <= 0)
     {
-      System.out.println("Could not make Java version check");
+      Console.errPrintln("Could not make Java version check");
       return true;
     }
     // Warn if these java.version and JAVA_COMPILE_VERSION conditions exist
@@ -186,4 +198,88 @@ public class LaunchUtils
 
     return true;
   }
+
+  public static String findJavaBin(boolean winConsole)
+  {
+    return findJavaBin(System.getProperty("java.home"), winConsole, true);
+  }
+
+  /*
+   * Returns a string path to the most likely java binary wanted to run this
+   * installation of Jalview.
+   * 
+   * @param  winConsole  whether to use java.exe (console) in preference to javaw.exe
+   *                     (only affects Windows).
+   * @param  javaHome    Try this javaHome dir (defaults to the running java.home).
+   * @param  generic     Return a generic java command if not found.
+   */
+  public static String findJavaBin(String javaHome, boolean winConsole,
+          boolean generic)
+  {
+    String javaBin = null;
+    final String javaExe = winConsole ? "java.exe" : "javaw.exe";
+    final String java = "java";
+
+    if (javaHome != null)
+    {
+      // property "channel.app_name" is set by install4j when launching getdown
+      String propertyAppName = System.getProperty("channel.app_name");
+      final String appName = (propertyAppName != null
+              && propertyAppName.length() > 0) ? propertyAppName
+                      : ChannelProperties.getProperty("app_name");
+
+      final String javaBinDir = javaHome + File.separator + "bin"
+              + File.separator;
+
+      // appName and "Jalview" will not point to javaw.exe or java.exe but in
+      // this case that's okay because the taskbar display name problem doesn't
+      // manifest in Windows. See JAL-3820, JAL-4189.
+      for (String name : new String[] { appName, "Jalview", java, javaExe })
+      {
+        if (LaunchUtils.checkJVMSymlink(javaBinDir + name, winConsole))
+        {
+          javaBin = javaBinDir + name;
+          break;
+        }
+      }
+    }
+
+    if (javaBin == null && generic)
+    {
+      javaBin = LaunchUtils.isWindows ? javaExe : java;
+    }
+
+    return javaBin;
+  }
+
+  /*
+   * checkJVMSymlink returns true if the path in testBin *is* a java binary, or
+   * points to a java binary.
+   * @param  testBin     The binary or symbolic link to check
+   * @param  winConsole  whether we are in/want a Windows console (only relevant for Windows,
+   *                     determines whether we use java.exe or javaw.exe)
+   */
+  private static boolean checkJVMSymlink(String testBin, boolean winConsole)
+  {
+    File testBinFile = new File(testBin);
+    if (!testBinFile.exists())
+    {
+      return false;
+    }
+    File targetFile = null;
+    try
+    {
+      targetFile = testBinFile.getCanonicalFile();
+    } catch (IOException e)
+    {
+      return false;
+    }
+    final String javaExe = winConsole ? "java.exe" : "javaw.exe";
+    if (targetFile != null && ("java".equals(targetFile.getName())
+            || javaExe.equals(targetFile.getName())))
+    {
+      return true;
+    }
+    return false;
+  }
 }
index 60eef4c..de8f719 100644 (file)
@@ -96,7 +96,7 @@ public class Log4j
       init = true;
     } catch (Exception e)
     {
-      System.err.println("Problems initializing the log4j system\n");
+      jalview.bin.Console.errPrintln("Problems initializing the log4j system\n");
       e.printStackTrace(System.err);
     }
   }
index f5953bf..4ecf637 100644 (file)
@@ -309,7 +309,7 @@ public class Platform
       time = mark = t;
       if (msg != null)
       {
-        System.err.println("Platform: timer reset\t\t\t" + msg);
+        jalview.bin.Console.errPrintln("Platform: timer reset\t\t\t" + msg);
       }
       break;
     case TIME_MARK:
@@ -325,7 +325,7 @@ public class Platform
         }
         if (msg != null)
         {
-          System.err.println("Platform: timer mark\t" + ((t - time) / 1000f)
+          jalview.bin.Console.errPrintln("Platform: timer mark\t" + ((t - time) / 1000f)
                   + "\t" + ((t - mark) / 1000f) + "\t" + msg);
         }
         mark = t;
@@ -337,7 +337,7 @@ public class Platform
     case TIME_GET:
       if (msg != null)
       {
-        System.err.println("Platform: timer dur\t" + ((t - time) / 1000f)
+        jalview.bin.Console.errPrintln("Platform: timer dur\t" + ((t - time) / 1000f)
                 + "\t" + ((duration) / 1000f) + "\t" + msg);
       }
       set = 0;
@@ -494,7 +494,7 @@ public class Platform
      *            info[key];
      */
 
-    System.out.println(
+    jalview.bin.Console.outPrintln(
             "Platform id=" + id + " reading Info." + key + " = " + value);
     p.put(id + "_" + key, value);
 
@@ -620,7 +620,7 @@ public class Platform
 
     if (isJS())
     {
-      System.out.println(
+      jalview.bin.Console.outPrintln(
               "Platform adding known access-control-allow-origin * for domain "
                       + domain);
       /**
@@ -644,11 +644,11 @@ public class Platform
        * @j2sNative var a =
        *            decodeURI((document.location.href.replace("&","?").split("?j2s")[0]
        *            + "?").split("?")[1].split("#")[0]); a &&
-       *            (System.out.println("URL arguments detected were "+a)) &&
+       *            (jalview.bin.Console.outPrintln("URL arguments detected were "+a)) &&
        *            (J2S.thisApplet.__Info.urlargs = a.split(" "));
        *            (!J2S.thisApplet.__Info.args || J2S.thisApplet.__Info.args
        *            == "" || J2S.thisApplet.__Info.args == "??") &&
-       *            (J2S.thisApplet.__Info.args = a) && (System.out.println("URL
+       *            (J2S.thisApplet.__Info.args = a) && (jalview.bin.Console.outPrintln("URL
        *            arguments were passed to J2S main."));
        */
     } catch (Throwable t)
index 1c67c92..11a1088 100644 (file)
@@ -202,18 +202,18 @@ public class StringUtils
       jv.clear();
       if (DEBUG)
       {
-        System.err.println("Array from '" + delimiter
+        jalview.bin.Console.errPrintln("Array from '" + delimiter
                 + "' separated List:\n" + v.length);
         for (int i = 0; i < v.length; i++)
         {
-          System.err.println("item " + i + " '" + v[i] + "'");
+          jalview.bin.Console.errPrintln("item " + i + " '" + v[i] + "'");
         }
       }
       return v;
     }
     if (DEBUG)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Empty Array from '" + delimiter + "' separated List");
     }
     return null;
@@ -249,13 +249,13 @@ public class StringUtils
       {
         System.err
                 .println("Returning '" + separator + "' separated List:\n");
-        System.err.println(v);
+        jalview.bin.Console.errPrintln(v);
       }
       return v.toString();
     }
     if (DEBUG)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Returning empty '" + separator + "' separated List\n");
     }
     return "" + separator;
index 0141a6a..78d0b4c 100644 (file)
@@ -322,7 +322,7 @@ public class UrlLink
             // debug
             for (int s = 0; s <= rg.numSubs(); s++)
             {
-              System.err.println("Sub " + s + " : " + rg.matchedFrom(s)
+              jalview.bin.Console.errPrintln("Sub " + s + " : " + rg.matchedFrom(s)
                       + " : " + rg.matchedTo(s) + " : '"
                       + rg.stringMatched(s) + "'");
             }
index a8c93cf..42768a6 100644 (file)
@@ -934,7 +934,7 @@ public abstract class AlignmentViewport
     }
     if (calculator.workingInvolvedWith(alignmentAnnotation))
     {
-      // System.err.println("grey out ("+alignmentAnnotation.label+")");
+      // jalview.bin.Console.errPrintln("grey out ("+alignmentAnnotation.label+")");
       return true;
     }
     return false;
@@ -1207,7 +1207,7 @@ public abstract class AlignmentViewport
   {
     if (sequenceSetID != null)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Warning - overwriting a sequenceSetId for a viewport!");
     }
     sequenceSetID = new String(newid);
@@ -2100,7 +2100,7 @@ public abstract class AlignmentViewport
       {
         if (aa == null)
         {
-          System.err.println("Null annotation row: ignoring.");
+          jalview.bin.Console.errPrintln("Null annotation row: ignoring.");
           continue;
         }
         if (!aa.visible)
@@ -2132,7 +2132,7 @@ public abstract class AlignmentViewport
 
         if (aa.graph > 0)
         {
-          aa.height += aa.graphHeight;
+          aa.height += aa.graphHeight+20;
         }
 
         if (aa.height == 0)
@@ -2293,7 +2293,7 @@ public abstract class AlignmentViewport
   {
     if (this == av)
     {
-      System.err.println("Ignoring recursive setCodingComplement request");
+      jalview.bin.Console.errPrintln("Ignoring recursive setCodingComplement request");
     }
     else
     {
index 104fb62..33c4c26 100644 (file)
@@ -224,7 +224,7 @@ public class ViewportRanges extends ViewportProperties
    */
   public void setStartEndSeq(int start, int end)
   {
-    // System.out.println("ViewportRange setStartEndSeq " + start + " " + end);
+    // jalview.bin.Console.outPrintln("ViewportRange setStartEndSeq " + start + " " + end);
     int[] oldvalues = updateStartEndSeq(start, end);
     int oldstartseq = oldvalues[0];
     int oldendseq = oldvalues[1];
@@ -438,7 +438,7 @@ public class ViewportRanges extends ViewportProperties
     {
       vpstart = visHeight - h;
     }
-    // System.out.println("ViewportRanges setviewportStartAndHeight " + vpstart
+    // jalview.bin.Console.outPrintln("ViewportRanges setviewportStartAndHeight " + vpstart
     // + " " + start + " " + h + " " + getVisibleAlignmentHeight());
 
     setStartEndSeq(vpstart, vpstart + h - 1);
index 91f2f0c..715645a 100644 (file)
  */
 package jalview.viewmodel.styles;
 
-import jalview.api.ViewStyleI;
-
 import java.awt.Color;
 
+import jalview.api.ViewStyleI;
+
 /**
  * A container for holding alignment view properties. View properties are
  * data-independent, which means they can be safely copied between views
index fc28e53..435d40c 100644 (file)
@@ -145,7 +145,7 @@ public class AlignCalcManager implements AlignCalcManagerI
   {
     synchronized (inProgress)
     {
-      // System.err.println("Worker " + worker + " marked as complete.");
+      // jalview.bin.Console.errPrintln("Worker " + worker + " marked as complete.");
       inProgress.remove(worker);
       List<AlignCalcWorkerI> upd = updating.get(worker.getClass());
       if (upd != null)
@@ -192,7 +192,7 @@ public class AlignCalcManager implements AlignCalcManagerI
   public boolean isWorking(AlignCalcWorkerI worker)
   {
     synchronized (inProgress)
-    {// System.err.println("isWorking : worker "+(worker!=null ?
+    {// jalview.bin.Console.errPrintln("isWorking : worker "+(worker!=null ?
      // worker.getClass():"null")+ " "+hashCode());
       return worker != null && inProgress.contains(worker);
     }
@@ -204,7 +204,7 @@ public class AlignCalcManager implements AlignCalcManagerI
     boolean working=false;
     synchronized (inProgress)
     {
-      // System.err.println("isWorking "+hashCode());
+      // jalview.bin.Console.errPrintln("isWorking "+hashCode());
       working |= inProgress.size() > 0;
     }
     synchronized (updating)
@@ -367,7 +367,7 @@ public class AlignCalcManager implements AlignCalcManagerI
      * {
      * 
      * if (isPending(worker)) { worker.abortAndDestroy(); startWorker(worker); }
-     * else { System.err.println("Pending exists for " + workerClass); } }
+     * else { jalview.bin.Console.errPrintln("Pending exists for " + workerClass); } }
      */
   }
 
index 2507bb5..c4e4b04 100644 (file)
@@ -56,7 +56,7 @@ public class AlignmentAnnotationFactory
             .getCurrentAlignFrame().alignPanel;
     if (currentAlignFrame == null)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Can't register calculator as no alignment window has focus");
       return;
     }
@@ -82,7 +82,7 @@ public class AlignmentAnnotationFactory
     }
     else
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Can't register calculator as no alignment window has focus");
     }
   }
index 1a5aaa4..8882b53 100644 (file)
@@ -58,7 +58,7 @@ public class ConsensusThread extends AlignCalcWorker
       }
       while (!calcMan.notifyWorking(this))
       {
-        // System.err.println("Thread
+        // jalview.bin.Console.errPrintln("Thread
         // (Consensus"+Thread.currentThread().getName()+") Waiting around.");
         try
         {
index 6746d1a..2e3dddd 100644 (file)
@@ -186,7 +186,7 @@ public abstract class AWSThread extends Thread
         {
           Console.debug("Interrupted sleep waiting for next job poll.", e);
         }
-        // System.out.println("I'm alive "+alTitle);
+        // jalview.bin.Console.outPrintln("I'm alive "+alTitle);
       }
     }
     if (jobComplete && jobs != null)
index d8858a9..0ebd3c3 100644 (file)
@@ -302,7 +302,7 @@ public class DBRefFetcher implements Runnable
       }
     } catch (Exception e)
     {
-      System.err.println("Couldn't locate PICR service instance.\n");
+      jalview.bin.Console.errPrintln("Couldn't locate PICR service instance.\n");
       e.printStackTrace();
     }
 
@@ -316,7 +316,7 @@ public class DBRefFetcher implements Runnable
     while (sdataset.size() > 0 && db < dbSources.length)
     {
       int maxqlen = 1; // default number of queries made at one time
-      System.out.println("Verifying against " + dbSources[db].getDbName());
+      jalview.bin.Console.outPrintln("Verifying against " + dbSources[db].getDbName());
 
       // iterate through db for each remaining un-verified sequence
       SequenceI[] currSeqs = new SequenceI[sdataset.size()];
@@ -425,7 +425,7 @@ public class DBRefFetcher implements Runnable
                             true);
                   } catch (Exception e)
                   {
-                    System.err.println(
+                    jalview.bin.Console.errPrintln(
                             "Exception with Picr for '" + token + "'\n");
                     e.printStackTrace();
                   }
@@ -438,7 +438,7 @@ public class DBRefFetcher implements Runnable
                     // present, and do a transferReferences
                     // otherwise transfer non sequence x-references directly.
                   }
-                  System.out.println(
+                  jalview.bin.Console.outPrintln(
                           "Validated ID against PICR... (for what its worth):"
                                   + token);
                   addSeqId(sequence, token);
@@ -447,7 +447,7 @@ public class DBRefFetcher implements Runnable
                 else
                 {
                   // if ()
-                  // System.out.println("Not querying source with
+                  // jalview.bin.Console.outPrintln("Not querying source with
                   // token="+token+"\n");
                   addSeqId(sequence, token);
                   queries.addElement(token.toUpperCase(Locale.ROOT));
@@ -512,7 +512,7 @@ public class DBRefFetcher implements Runnable
           DbSourceProxy dbSourceProxy, AlignmentI retrievedAl,
           boolean trimDatasetSeqs, List<String> warningMessages)
   {
-    // System.out.println("trimming ? " + trimDatasetSeqs);
+    // jalview.bin.Console.outPrintln("trimming ? " + trimDatasetSeqs);
     if (retrievedAl == null || retrievedAl.getHeight() == 0)
     {
       return false;
@@ -678,7 +678,7 @@ public class DBRefFetcher implements Runnable
           }
         }
 
-        System.out.println("Adding dbrefs to " + sequence.getName()
+        jalview.bin.Console.outPrintln("Adding dbrefs to " + sequence.getName()
                 + " from " + dbSource + " sequence : "
                 + retrievedSeq.getName());
         sequence.transferAnnotation(retrievedSeq, mp);
index 6b86775..ff6f74f 100644 (file)
@@ -153,7 +153,7 @@ public class JobStateSummary
         }
         // } catch (OutOfMemoryError e)
         // {
-        // System.err.println("Out of memory when displaying status. Squashing
+        // jalview.bin.Console.errPrintln("Out of memory when displaying status. Squashing
         // error.");
         // wsInfo.appendProgressText(j.jobnum,
         // "..\n(Out of memory when displaying status)\n");
index c822ef4..22884f1 100644 (file)
@@ -21,6 +21,21 @@ import jalview.util.MapList;
 import jalview.util.MapUtils;
 import jalview.ws.dbsources.EBIAlfaFold;
 
+/**
+ * routines and class for holding predicted alignment error matrices as produced
+ * by alphafold et al.
+ * 
+ * getContactList(column) returns the vector of predicted alignment errors for
+ * reference position given by column getElementAt(column, i) returns the
+ * predicted superposition error for the ith position when column is used as
+ * reference
+ * 
+ * Many thanks to Ora Schueler Furman for noticing that earlier development
+ * versions did not show the PAE oriented correctly
+ *
+ * @author jprocter
+ *
+ */
 public class PAEContactMatrix extends
         MappableContactMatrix<PAEContactMatrix> implements ContactMatrixI
 {
@@ -129,17 +144,18 @@ public class PAEContactMatrix extends
         Object d = scores.next();
         if (d instanceof Double)
         {
-          elements[row][col++] = ((Double) d).longValue();
+          elements[col][row] = ((Double) d).longValue();
         }
         else
         {
-          elements[row][col++] = (float) ((Long) d).longValue();
+          elements[col][row] = (float) ((Long) d).longValue();
         }
 
-        if (maxscore < elements[row][col - 1])
+        if (maxscore < elements[col][row])
         {
-          maxscore = elements[row][col - 1];
+          maxscore = elements[col][row];
         }
+        col++;
       }
       row++;
       col = 0;
@@ -180,7 +196,7 @@ public class PAEContactMatrix extends
     cols = ((List<Long>) pae_obj.get("residue2")).iterator();
     Iterator<Double> scores = ((List<Double>) pae_obj.get("distance"))
             .iterator();
-    elements = new float[maxrow][maxcol];
+    elements = new float[maxcol][maxrow];
     while (scores.hasNext())
     {
       float escore = scores.next().floatValue();
@@ -194,13 +210,17 @@ public class PAEContactMatrix extends
       {
         maxcol = col;
       }
-      elements[row - 1][col - 1] = escore;
+      elements[col - 1][row-1] = escore;
     }
 
     maxscore = ((Double) MapUtils.getFirst(pae_obj,
             "max_predicted_aligned_error", "max_pae")).floatValue();
   }
 
+  /**
+   * getContactList(column) @returns the vector of predicted alignment errors
+   * for reference position given by column
+   */
   @Override
   public ContactListI getContactList(final int column)
   {
@@ -235,6 +255,10 @@ public class PAEContactMatrix extends
     });
   }
 
+  /**
+   * getElementAt(column, i) @returns the predicted superposition error for the
+   * ith position when column is used as reference
+   */
   @Override
   protected double getElementAt(int _column, int i)
   {
index 5ab05e0..6b27488 100644 (file)
@@ -176,7 +176,7 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
 
     if (!isValidReference(id))
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "(AFClient) Ignoring invalid alphafold query: '" + id + "'");
       stopQuery();
       return null;
index 7ac6936..bef6976 100644 (file)
@@ -57,7 +57,7 @@ public abstract class EbiFileRetrievedProxy extends DbSourceProxyImpl
       }
     } catch (Exception e)
     {
-      System.err.println("Warning: problems reading temp file " + file);
+      jalview.bin.Console.errPrintln("Warning: problems reading temp file " + file);
       return null;
     }
     return bf;
index 034ea4f..a4d9633 100644 (file)
@@ -161,7 +161,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
       }
       else
       {
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "No record found for '" + emprefx + ":" + query + "'");
       }
     }
@@ -283,11 +283,11 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
       }
     } catch (Exception e)
     {
-      System.err.println("EMBL Record Features parsing error!");
+      jalview.bin.Console.errPrintln("EMBL Record Features parsing error!");
       System.err
               .println("Please report the following to help@jalview.org :");
-      System.err.println("EMBL Record " + accession);
-      System.err.println("Resulted in exception: " + e.getMessage());
+      jalview.bin.Console.errPrintln("EMBL Record " + accession);
+      jalview.bin.Console.errPrintln("Resulted in exception: " + e.getMessage());
       e.printStackTrace(System.err);
     }
 
@@ -354,7 +354,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
             codonStart = Integer.parseInt(value.trim());
           } catch (NumberFormatException e)
           {
-            System.err.println("Invalid codon_start in XML for "
+            jalview.bin.Console.errPrintln("Invalid codon_start in XML for "
                     + entry.getAccession() + ": " + e.getMessage());
           }
         }
@@ -406,13 +406,13 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
          * workaround until we handle dna location for CDS sequence
          * e.g. location="X53828.1:60..1058" correctly
          */
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Implementation Notice: EMBLCDS records not properly supported yet - Making up the CDNA region of this sequence... may be incorrect ("
                         + sourceDb + ":" + entry.getAccession() + ")");
         int dnaLength = dna.getLength();
         if (translationLength * 3 == (1 - codonStart + dnaLength))
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Not allowing for additional stop codon at end of cDNA fragment... !");
           // this might occur for CDS sequences where no features are marked
           exons = new int[] { dna.getStart() + (codonStart - 1),
@@ -423,7 +423,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
         }
         if ((translationLength + 1) * 3 == (1 - codonStart + dnaLength))
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Allowing for additional stop codon at end of cDNA fragment... will probably cause an error in VAMSAs!");
           exons = new int[] { dna.getStart() + (codonStart - 1),
               dna.getEnd() - 3 };
index bb5c165..68a7328 100644 (file)
@@ -138,7 +138,7 @@ public class Pdb extends EbiFileRetrievedProxy
 
     if (!isValidReference(id))
     {
-      System.err.println("Ignoring invalid pdb query: '" + id + "'");
+      jalview.bin.Console.errPrintln("Ignoring invalid pdb query: '" + id + "'");
       stopQuery();
       return null;
     }
index 65b9655..3eef460 100644 (file)
@@ -136,8 +136,8 @@ public class EBIFetchClient
     String database = parseIds(ids, querystring);
     if (database == null)
     {
-      System.err.println("Invalid Query string : '" + ids + "'");
-      System.err.println("Should be of form 'dbname:q1;q2;q3;q4'");
+      jalview.bin.Console.errPrintln("Invalid Query string : '" + ids + "'");
+      jalview.bin.Console.errPrintln("Should be of form 'dbname:q1;q2;q3;q4'");
       return null;
     }
 
@@ -227,11 +227,11 @@ public class EBIFetchClient
         }
         return (String[]) arl.toArray();
       }
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Warning: response code " + responseCode + " for " + url);
     } catch (OutOfMemoryError er)
     {
-      System.out.println("OUT OF MEMORY DOWNLOADING QUERY FROM " + database
+      jalview.bin.Console.outPrintln("OUT OF MEMORY DOWNLOADING QUERY FROM " + database
               + ":\n" + ids);
       throw er;
     } catch (Exception ex)
@@ -239,7 +239,7 @@ public class EBIFetchClient
       if (!ex.getMessage().startsWith(
               "uk.ac.ebi.jdbfetch.exceptions.DbfNoEntryFoundException"))
       {
-        System.err.println("Unexpected exception when retrieving from "
+        jalview.bin.Console.errPrintln("Unexpected exception when retrieving from "
                 + database + "\nQuery was : '" + ids + "'");
         ex.printStackTrace(System.err);
       }
index 022ae6d..4165eae 100644 (file)
@@ -44,7 +44,7 @@ public class Annotate3D
 
   public Annotate3D()
   {
-    System.out.println("Annotate3D");
+    jalview.bin.Console.outPrintln("Annotate3D");
     // try {
     // Create a URL for the desired page
     // String id = "1HR2";
@@ -55,7 +55,7 @@ public class Annotate3D
     // OutputStream out1 = null;
     // out = new BufferedWriter(new OutputStreamWriter(out1, "temp.rnaml"));
     // while ((str = in.readLine()) != null) {
-    // System.out.println(str);
+    // jalview.bin.Console.outPrintln(str);
     // out.write(str);
     // }
     // in.close();
@@ -117,19 +117,19 @@ public class Annotate3D
 
   public Annotate3D(String path) throws InterruptedException
   {
-    System.out.println("Annotate3D");
+    jalview.bin.Console.outPrintln("Annotate3D");
     try
     {
       // //URL url = new
       // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+inFile);
-      // System.out.println("Step1");
+      // jalview.bin.Console.outPrintln("Step1");
       // FileReader r = new FileReader(inFile);
       // BufferedReader in = new BufferedReader(r);
       // StringBuffer content = new StringBuffer();
-      // System.out.println("Step2");
+      // jalview.bin.Console.outPrintln("Step2");
       // while(in.readLine()!=null){
       // content.append(in.readLine());
-      // //System.out.println("Step3"+in.readLine());
+      // //jalview.bin.Console.outPrintln("Step3"+in.readLine());
       // }
       //
       // String data = URLEncoder.encode("data", "UTF-8") + "=" +
@@ -145,21 +145,21 @@ public class Annotate3D
       // FileReader r = new FileReader(path);
       // BufferedReader in = new BufferedReader(r);
       // StringBuffer content = new StringBuffer();
-      // System.out.println("Step1");
+      // jalview.bin.Console.outPrintln("Step1");
       // while(in.readLine()!=null){
       // content.append(in.readLine());
       //
       // }
-      // System.out.println("Step2");
+      // jalview.bin.Console.outPrintln("Step2");
       // String data = URLEncoder.encode("data", "UTF-8") + "=" +
       // URLEncoder.encode(content.toString(), "UTF-8");
-      // System.out.println("Step2");
+      // jalview.bin.Console.outPrintln("Step2");
       // URL url = new
       // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
       // DataInputStream is = new DataInputStream(url.openStream());
       // String str;
       // while ((str = is.readLine()) != null) {
-      // System.out.println(str);
+      // jalview.bin.Console.outPrintln(str);
       // //out.write(str);
       // }
       FileReader r = new FileReader(path);
@@ -169,14 +169,14 @@ public class Annotate3D
 
       while ((str = in.readLine()) != null)
       {
-        // System.out.println(str);
+        // jalview.bin.Console.outPrintln(str);
 
         content = content + str;
       }
-      System.out.println("pdbfile=" + content.toString());
-      System.out.println("capacité=" + content.length());
+      jalview.bin.Console.outPrintln("pdbfile=" + content.toString());
+      jalview.bin.Console.outPrintln("capacité=" + content.length());
       String paramfile = URLEncoder.encode(content.toString(), "UTF-8");
-      System.out.println("param=" + paramfile);
+      jalview.bin.Console.outPrintln("param=" + paramfile);
       URL url = new URL(
               "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="
                       + content);
@@ -185,7 +185,7 @@ public class Annotate3D
       String str4;
       while ((str4 = is.readLine()) != null)
       {
-        System.out.println(str4);
+        jalview.bin.Console.outPrintln(str4);
         // out.write(str);
       }
       in.close();
@@ -207,7 +207,7 @@ public class Annotate3D
       // BufferedReader in1 = new BufferedReader(is);
 
       // OutputStream out1 = null;
-      // System.out.println("Step3");
+      // jalview.bin.Console.outPrintln("Step3");
       // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(out1,
       // "temp.rnaml"));
       //
@@ -216,11 +216,11 @@ public class Annotate3D
 
       // return;
 
-      // System.out.println(data.length());
-      // System.out.println("step2");
+      // jalview.bin.Console.outPrintln(data.length());
+      // jalview.bin.Console.outPrintln("step2");
       // URL url = new
       // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
-      // System.out.println("step3");
+      // jalview.bin.Console.outPrintln("step3");
       // URLConnection conn = url.openConnection();
       // conn.setDoOutput(true);
       // OutputStreamWriter writer = new
@@ -237,7 +237,7 @@ public class Annotate3D
       // //String line;
       // while ((line = reader.readLine()) != null) {
       // answer.append(line);
-      // System.out.println(line);
+      // jalview.bin.Console.outPrintln(line);
       // }
       // writer.close();
       // reader.close();
@@ -261,9 +261,9 @@ public class Annotate3D
   // out = new BufferedWriter(new FileWriter("temp.rnaml"));
 
   // while ((str = in.readLine()) != null) {
-  // System.out.println(str);
+  // jalview.bin.Console.outPrintln(str);
   // out.write(str);
-  // System.out.println(str);
+  // jalview.bin.Console.outPrintln(str);
   // in.close();
 
   // out.close();
@@ -275,7 +275,7 @@ public class Annotate3D
 
   // public BufferedWriter getReader()
   // {
-  // System.out.println("The buffer");
+  // jalview.bin.Console.outPrintln("The buffer");
 
   // return out;
 
index 69e47a3..d4a2fd4 100644 (file)
@@ -222,7 +222,7 @@ public class Discoverer implements Runnable
 
     } catch (Exception e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "jalview.rootRegistry is not a proper url!\nWas set to "
                       + RootServiceURL + "\n" + e);
     }
@@ -404,7 +404,7 @@ public class Discoverer implements Runnable
     WS1Client instance = serviceClientBindings.get(sh.getAbstractName());
     if (instance == null)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "WARNING - POSSIBLE IMPLEMENTATION ERROR - cannot find WSClient implementation for "
                       + sh.getAbstractName());
     }
index a39945e..a042dee 100644 (file)
@@ -480,7 +480,7 @@ class JPredThread extends JWS1Thread implements WSClientI
         wsInfo.setProgressText(j.getJobnum(),
                 "Failed to submit the prediction. (Just close the window)\n"
                         + "It is most likely that there is a problem with the server.\n");
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "JPredWS Client: Failed to submit the prediction. Quite possibly because of a server error - see below)\n"
                         + e.getMessage() + "\n");
 
index e027038..727f5be 100644 (file)
@@ -479,7 +479,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI
         j.setJobId(jobsubmit.getJobId());
         j.setSubmitted(true);
         j.setSubjobComplete(false);
-        // System.out.println(WsURL + " Job Id '" + jobId + "'");
+        // jalview.bin.Console.outPrintln(WsURL + " Job Id '" + jobId + "'");
       }
       else
       {
@@ -497,7 +497,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI
     {
       // TODO: JBPNote catch timeout or other fault types explicitly
       // For unexpected errors
-      System.err.println(WebServiceName
+      jalview.bin.Console.errPrintln(WebServiceName
               + "Client: Failed to submit the sequences for alignment (probably a server side problem)\n"
               + "When contacting Server:" + WsUrl + "\n" + e.toString()
               + "\n");
@@ -544,9 +544,9 @@ class MsaWSThread extends JWS1Thread implements WSClientI
           results++;
           // if (Cache.isDebugEnabled())
           // {
-          // System.out.println("Job lob for job
+          // jalview.bin.Console.outPrintln("Job lob for job
           // "+jobs[j].getJobId()+":"+jobs[j].getJobnum());
-          // System.out.println(jobs[j].getStatus());
+          // jalview.bin.Console.outPrintln(jobs[j].getStatus());
           // }
 
           vamsas.objects.simple.Alignment valign = ((MsaResult) ((MsaWSJob) jobs[j]).result)
@@ -709,7 +709,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI
     }
     else
     {
-      System.out.println("MERGE WITH OLD FRAME");
+      jalview.bin.Console.outPrintln("MERGE WITH OLD FRAME");
       // TODO: modify alignment in original frame, replacing old for new
       // alignment using the commands.EditCommand model to ensure the update can
       // be undone
index 0f28230..805f64c 100644 (file)
@@ -212,9 +212,9 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI
           }
         } catch (Exception e)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Failed to parse the annotation file associated with the alignment.");
-          System.err.println(">>>EOF" + inFile + "\n<<<EOF\n");
+          jalview.bin.Console.errPrintln(">>>EOF" + inFile + "\n<<<EOF\n");
           e.printStackTrace(System.err);
         }
 
@@ -229,9 +229,9 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI
           }
         } catch (Exception e)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Failed to parse the Features file associated with the alignment.");
-          System.err.println(">>>EOF" + inFile + "\n<<<EOF\n");
+          jalview.bin.Console.errPrintln(">>>EOF" + inFile + "\n<<<EOF\n");
           e.printStackTrace(System.err);
         }
         jalview.io.NewickFile nf = null;
@@ -250,9 +250,9 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI
           }
         } catch (Exception e)
         {
-          System.err.println(
+          jalview.bin.Console.errPrintln(
                   "Failed to parse the treeFile associated with the alignment.");
-          System.err.println(">>>EOF" + inFile + "\n<<<EOF\n");
+          jalview.bin.Console.errPrintln(">>>EOF" + inFile + "\n<<<EOF\n");
           e.printStackTrace(System.err);
         }
 
@@ -496,7 +496,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI
         j.setJobId(jobsubmit.getJobId());
         j.setSubmitted(true);
         j.setSubjobComplete(false);
-        // System.out.println(WsURL + " Job Id '" + jobId + "'");
+        // jalview.bin.Console.outPrintln(WsURL + " Job Id '" + jobId + "'");
       }
       else
       {
@@ -514,7 +514,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI
     {
       // TODO: JBPNote catch timeout or other fault types explicitly
       // For unexpected errors
-      System.err.println(WebServiceName
+      jalview.bin.Console.errPrintln(WebServiceName
               + "Client: Failed to submit the sequences for alignment (probably a server side problem)\n"
               + "When contacting Server:" + WsUrl + "\n" + e.toString()
               + "\n");
@@ -616,7 +616,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI
   {
     if (!newFrame)
     {
-      System.err.println("MERGE WITH OLD FRAME NOT IMPLEMENTED");
+      jalview.bin.Console.errPrintln("MERGE WITH OLD FRAME NOT IMPLEMENTED");
       return;
     }
     // each subjob is an independent alignment for the moment
index 9d56de4..3b56a70 100644 (file)
@@ -259,11 +259,11 @@ public abstract class AbstractJabaCalcWorker extends AlignCalcWorker
           {
             if (cancelJob(rslt))
             {
-              System.err.println("Cancelled AACon job: " + rslt);
+              jalview.bin.Console.errPrintln("Cancelled AACon job: " + rslt);
             }
             else
             {
-              System.err.println("FAILED TO CANCEL AACon job: " + rslt);
+              jalview.bin.Console.errPrintln("FAILED TO CANCEL AACon job: " + rslt);
             }
 
           } catch (Exception x)
@@ -356,13 +356,13 @@ public abstract class AbstractJabaCalcWorker extends AlignCalcWorker
     catch (JobSubmissionException x)
     {
 
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "submission error with " + getServiceActionText() + " :");
       x.printStackTrace();
       calcMan.disableWorker(this);
     } catch (ResultNotAvailableException x)
     {
-      System.err.println("collection error:\nJob ID: " + rslt);
+      jalview.bin.Console.errPrintln("collection error:\nJob ID: " + rslt);
       x.printStackTrace();
       calcMan.disableWorker(this);
 
@@ -441,11 +441,11 @@ public abstract class AbstractJabaCalcWorker extends AlignCalcWorker
       String id = rslt;
       if (cancelJob(rslt))
       {
-        System.err.println("Cancelled job " + id);
+        jalview.bin.Console.errPrintln("Cancelled job " + id);
       }
       else
       {
-        System.err.println("Job " + id + " couldn't be cancelled.");
+        jalview.bin.Console.errPrintln("Job " + id + " couldn't be cancelled.");
       }
     } catch (Exception q)
     {
index 5e034cd..5b46a97 100644 (file)
@@ -84,7 +84,7 @@ public class JabaParamStore implements ParamDatastoreI
           }
           else
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "Warning: Ignoring parameter set instance of type "
                             + paramset.getClass()
                             + " : Bound but not applicable for service at "
index 5831df8..e4d0669 100644 (file)
@@ -117,7 +117,7 @@ public class JabaWsServerQuery implements Runnable
           registry = Jws2Client.connectToRegistry(jwsserver);
           if (registry != null)
           {
-            // System.err.println("Test Services Output\n"
+            // jalview.bin.Console.errPrintln("Test Services Output\n"
             // + registry.testAllServices());
             // TODO: enumerate services and test those that haven't been tested
             // in the last n-days/hours/etc.
@@ -126,23 +126,23 @@ public class JabaWsServerQuery implements Runnable
             srv_set = registry.getSupportedServices();
 
             // dan test
-            System.out.println(
+            jalview.bin.Console.outPrintln(
                     "registry.getSupportedServices: " + srv_set.toString());
 
             svccategories = registry.getServiceCategories();
 
             // dan test
-            // System.out.println("registry.getServiceCategories: " +
+            // jalview.bin.Console.outPrintln("registry.getServiceCategories: " +
             // svccategories.toString());
 
           }
         } catch (Exception ex)
         {
-          System.err.println("Exception whilst trying to get at registry:");
+          jalview.bin.Console.errPrintln("Exception whilst trying to get at registry:");
           ex.printStackTrace();
           // if that failed, then we are probably working with a JABAWS1 server.
           // in that case, look for each service endpoint
-          System.err.println("JWS2 Discoverer: " + jwsserver
+          jalview.bin.Console.errPrintln("JWS2 Discoverer: " + jwsserver
                   + " is a JABAWS1 server. Using hardwired list.");
           for (Services srv : JABAWS1SERVERS)
           {
@@ -169,7 +169,7 @@ public class JabaWsServerQuery implements Runnable
               service = Jws2Client.connect(jwsserver, srv);
             } catch (Exception e)
             {
-              System.err.println("Jws2 Discoverer: Problem on " + jwsserver
+              jalview.bin.Console.errPrintln("Jws2 Discoverer: Problem on " + jwsserver
                       + " with service " + srv + ":\n" + e.getMessage());
               if (!(e instanceof javax.xml.ws.WebServiceException))
               {
@@ -245,11 +245,11 @@ public class JabaWsServerQuery implements Runnable
         result = true;
       } catch (MalformedURLException e)
       {
-        System.err.println("Invalid server URL: " + server);
+        jalview.bin.Console.errPrintln("Invalid server URL: " + server);
         result = false;
       } catch (IOException e)
       {
-        System.err.println("Error connecting to server: " + server + ": "
+        jalview.bin.Console.errPrintln("Error connecting to server: " + server + ": "
                 + e.toString());
         result = false;
       }
index fc36205..47e82de 100644 (file)
@@ -142,7 +142,7 @@ public abstract class JabawsCalcWorker extends AbstractJabaCalcWorker
           List<AlignmentAnnotation> ourAnnot, String typeName,
           String calcId, SequenceI dseq, int base, Score scr)
   {
-    System.out.println("Creating annotation on dseq:" + dseq.getStart()
+    jalview.bin.Console.outPrintln("Creating annotation on dseq:" + dseq.getStart()
             + " base is " + base + " and length=" + dseq.getLength()
             + " == " + scr.getScores().size());
     // AlignmentAnnotation annotation = new AlignmentAnnotation(
index ee36d4a..13d60de 100644 (file)
@@ -156,7 +156,7 @@ public abstract class JabawsMsaInterfaceAlignCalcWorker
           List<AlignmentAnnotation> ourAnnot, String typeName,
           String calcId, SequenceI dseq, int base, Score scr)
   {
-    System.out.println("Creating annotation on dseq:" + dseq.getStart()
+    jalview.bin.Console.outPrintln("Creating annotation on dseq:" + dseq.getStart()
             + " base is " + base + " and length=" + dseq.getLength()
             + " == " + scr.getScores().size());
     // AlignmentAnnotation annotation = new AlignmentAnnotation(
index b6b4b2e..ca36a51 100644 (file)
@@ -195,7 +195,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
               .loadClass("compbio.ws.client.Jws2Client");
     } catch (ClassNotFoundException e)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Not enabling JABA Webservices : client jar is not available."
                       + "\nPlease check that your webstart JNLP file is up to date!");
       running = false;
@@ -314,7 +314,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
     {
       services = new Vector<>();
     }
-    System.out.println(
+    jalview.bin.Console.outPrintln(
             "Discovered service: " + jwsservers + " " + service.toString());
     // Jws2Instance service = new Jws2Instance(jwsservers, srv.toString(),
     // service2);
@@ -600,12 +600,12 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
               {
                 if (getDiscoverer().services != null)
                 {
-                  System.out.println("Changesupport: There are now "
+                  jalview.bin.Console.outPrintln("Changesupport: There are now "
                           + getDiscoverer().services.size() + " services");
                   int i = 1;
                   for (Jws2Instance instance : getDiscoverer().services)
                   {
-                    System.out.println("Service " + i++ + " "
+                    jalview.bin.Console.outPrintln("Service " + i++ + " "
                             + instance.getClass() + "@" + instance.getHost()
                             + ": " + instance.getActionText());
                   }
index ee0fbc5..611aa79 100644 (file)
@@ -703,7 +703,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI
       {
         j.setSubmitted(true);
         j.setSubjobComplete(false);
-        // System.out.println(WsURL + " Job Id '" + jobId + "'");
+        // jalview.bin.Console.outPrintln(WsURL + " Job Id '" + jobId + "'");
         return;
       }
       else
@@ -749,7 +749,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI
     } catch (Error e)
     {
       // For unexpected errors
-      System.err.println(WebServiceName
+      jalview.bin.Console.errPrintln(WebServiceName
               + "Client: Failed to submit the sequences for alignment (probably a server side problem)\n"
               + "When contacting Server:" + WsUrl + "\n");
       e.printStackTrace(System.err);
@@ -759,7 +759,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI
     } catch (Exception e)
     {
       // For unexpected errors
-      System.err.println(WebServiceName
+      jalview.bin.Console.errPrintln(WebServiceName
               + "Client: Failed to submit the sequences for alignment (probably a server side problem)\n"
               + "When contacting Server:" + WsUrl + "\n");
       e.printStackTrace(System.err);
@@ -837,10 +837,10 @@ class MsaWSThread extends AWS2Thread implements WSClientI
 
           if (Console.isDebugEnabled())
           {
-            System.out.println("Job Execution file for job: "
+            jalview.bin.Console.outPrintln("Job Execution file for job: "
                     + msjob.getJobId() + " on server " + WsUrl);
-            System.out.println(msjob.getStatus());
-            System.out.println("*** End of status");
+            jalview.bin.Console.outPrintln(msjob.getStatus());
+            jalview.bin.Console.outPrintln("*** End of status");
 
           }
           try
@@ -986,7 +986,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI
     else
     {
       // TODO 2.9.x feature
-      System.out.println("MERGE WITH OLD FRAME");
+      jalview.bin.Console.outPrintln("MERGE WITH OLD FRAME");
       // TODO: modify alignment in original frame, replacing old for new
       // alignment using the commands.EditCommand model to ensure the update can
       // be undone
index c7fad05..0fb36ad 100644 (file)
@@ -79,7 +79,7 @@ public class ParameterUtils
       Option o = options.getArgumentByOptionName(oname);
       if (o == null)
       {
-        System.out.println("WARN ignoring unsuppoted parameter: " + oname);
+        jalview.bin.Console.outPrintln("WARN ignoring unsuppoted parameter: " + oname);
         continue;
       }
       if (o instanceof Parameter)
@@ -98,7 +98,7 @@ public class ParameterUtils
                   : param);
         } catch (WrongParameterException e)
         {
-          System.out.println(
+          jalview.bin.Console.outPrintln(
                   "Problem setting value for the parameter: " + param);
           e.printStackTrace();
         }
index e092192..9e49ce7 100644 (file)
@@ -114,7 +114,7 @@ public class Jws2Instance implements AutoCloseable
         }
       } catch (Exception ex)
       {
-        System.err.println("Exception when retrieving presets for service "
+        jalview.bin.Console.errPrintln("Exception when retrieving presets for service "
                 + serviceType + " at " + hosturl);
       }
     }
@@ -128,7 +128,7 @@ public class Jws2Instance implements AutoCloseable
      * try { URL serviceurl = new URL(hosturl); if (serviceurl.getPort()!=80) {
      * return serviceurl.getHost()+":"+serviceurl.getPort(); } return
      * serviceurl.getHost(); } catch (Exception e) {
-     * System.err.println("Failed to parse service URL '" + hosturl +
+     * jalview.bin.Console.errPrintln("Failed to parse service URL '" + hosturl +
      * "' as a valid URL!"); } return null;
      */
   }
@@ -190,7 +190,7 @@ public class Jws2Instance implements AutoCloseable
                         : null));
       } catch (Exception ex)
       {
-        System.err.println("Unexpected exception creating JabaParamStore.");
+        jalview.bin.Console.errPrintln("Unexpected exception creating JabaParamStore.");
         ex.printStackTrace();
       }
 
index fb291da..6ac720a 100644 (file)
@@ -142,7 +142,7 @@ public abstract class InputType
       }
     } catch (Exception ex)
     {
-      System.err.println("Couldn't transform string\n" + content
+      jalview.bin.Console.errPrintln("Couldn't transform string\n" + content
               + "\nException was :");
       ex.printStackTrace(System.err);
     }
index 255ab58..450f1b4 100644 (file)
@@ -134,7 +134,7 @@ public class RestClient extends WSClient
   @Override
   public void cancelJob()
   {
-    System.err.println("Cannot cancel this job type: " + service);
+    jalview.bin.Console.errPrintln("Cannot cancel this job type: " + service);
   }
 
   @Override
@@ -418,7 +418,7 @@ public class RestClient extends WSClient
         }
       } catch (Exception ex)
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Serious - RSBS descriptions in user preferences are corrupt!");
         ex.printStackTrace();
       }
index eff38fb..c8efcda 100644 (file)
@@ -422,7 +422,7 @@ public class RestJobThread extends AWSThread
   public void pollJob(AWsJob job) throws Exception
   {
     assert (job instanceof RestJob);
-    System.err.println("Debug RestJob: Polling Job");
+    jalview.bin.Console.errPrintln("Debug RestJob: Polling Job");
     doPoll((RestJob) job);
   }
 
@@ -432,7 +432,7 @@ public class RestJobThread extends AWSThread
     assert (job instanceof RestJob);
     try
     {
-      System.err.println("Debug RestJob: Posting Job");
+      jalview.bin.Console.errPrintln("Debug RestJob: Posting Job");
       doPost((RestJob) job);
     } catch (NoValidInputDataException erex)
     {
@@ -1258,7 +1258,7 @@ public class RestJobThread extends AWSThread
         if (!rj.hasValidInput())
         {
           // invalid input for this job
-          System.err.println("Job " + rj.getJobnum()
+          jalview.bin.Console.errPrintln("Job " + rj.getJobnum()
                   + " has invalid input. ( " + rj.getStatus() + ")");
           if (rj.hasStatus() && !_warnings.contains(rj.getStatus()))
           {
index 0d0a314..374147a 100644 (file)
@@ -191,9 +191,9 @@ public class ASequenceFetcher
               seqset = fetcher.getSequenceRecords(qsb.toString());
             } catch (Exception ex)
             {
-              System.err.println(
+              jalview.bin.Console.errPrintln(
                       "Failed to retrieve the following from " + db);
-              System.err.println(qsb);
+              jalview.bin.Console.errPrintln(qsb);
               ex.printStackTrace(System.err);
             }
             // TODO: Merge alignment together - perhaps
@@ -222,7 +222,7 @@ public class ASequenceFetcher
               {
                 if (fetcher.getRawRecords() != null)
                 {
-                  System.out.println(
+                  jalview.bin.Console.outPrintln(
                           "# Retrieved from " + db + ":" + qsb.toString());
                   StringBuffer rrb = fetcher.getRawRecords();
                   /*
@@ -235,12 +235,12 @@ public class ASequenceFetcher
                   /*
                    * } else { hdr = "# part "+rr; }
                    */
-                  System.out.println(hdr);
+                  jalview.bin.Console.outPrintln(hdr);
                   if (rrb != null)
                   {
-                    System.out.println(rrb);
+                    jalview.bin.Console.outPrintln(rrb);
                   }
-                  System.out.println("# end of " + hdr);
+                  jalview.bin.Console.outPrintln("# end of " + hdr);
                 }
 
               }
@@ -253,7 +253,7 @@ public class ASequenceFetcher
         }
         if (queriesMade.size() > 0)
         {
-          System.out.println("# Adding " + queriesMade.size()
+          jalview.bin.Console.outPrintln("# Adding " + queriesMade.size()
                   + " ids back to queries list for searching again (" + db
                   + ")");
           queriesLeft.addAll(queriesMade);
@@ -279,7 +279,7 @@ public class ASequenceFetcher
           Exception ex)
   {
 
-    System.err.println(
+    jalview.bin.Console.errPrintln(
             "Failed to retrieve the following references from " + db);
     int n = 0;
     for (String qv : queriesMade)
@@ -287,11 +287,11 @@ public class ASequenceFetcher
       System.err.print(" " + qv + ";");
       if (n++ > 10)
       {
-        System.err.println();
+        jalview.bin.Console.errPrintln();
         n = 0;
       }
     }
-    System.err.println();
+    jalview.bin.Console.errPrintln();
     ex.printStackTrace();
   }
 
index 0c707e5..92cb7af 100644 (file)
@@ -57,6 +57,7 @@ import jalview.analysis.scoremodels.ScoreMatrix;
 import jalview.analysis.scoremodels.ScoreModels;
 import jalview.api.DBRefEntryI;
 import jalview.api.SiftsClientI;
+import jalview.bin.Console;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
 import jalview.datamodel.SequenceI;
@@ -116,7 +117,7 @@ public class SiftsClient implements SiftsClientI
 
   private static final String NOT_OBSERVED = "Not_Observed";
 
-  private static final String SIFTS_FTP_BASE_URL = "http://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/";
+  private static final String SIFTS_SPLIT_FTP_BASE_URL = "https://ftp.ebi.ac.uk/pub/databases/msd/sifts/split_xml/";
 
   private final static String NEWLINE = System.lineSeparator();
 
@@ -188,7 +189,7 @@ public class SiftsClient implements SiftsClientI
     try (InputStream in = new FileInputStream(siftFile);
             GZIPInputStream gzis = new GZIPInputStream(in);)
     {
-      // System.out.println("File : " + siftFile.getAbsolutePath());
+      // jalview.bin.Console.outPrintln("File : " + siftFile.getAbsolutePath());
       JAXBContext jc = JAXBContext.newInstance("jalview.xml.binding.sifts");
       XMLStreamReader streamReader = XMLInputFactory.newInstance()
               .createXMLStreamReader(gzis);
@@ -226,7 +227,7 @@ public class SiftsClient implements SiftsClientI
     if (siftsFile.exists())
     {
       // The line below is required for unit testing... don't comment it out!!!
-      System.out.println(">>> SIFTS File already downloaded for " + pdbId);
+      jalview.bin.Console.outPrintln(">>> SIFTS File already downloaded for " + pdbId);
 
       if (isFileOlderThanThreshold(siftsFile,
               SiftsSettings.getCacheThresholdInDays()))
@@ -281,7 +282,7 @@ public class SiftsClient implements SiftsClientI
       diffInDays = (int) ((new Date().getTime()
               - attr.lastModifiedTime().toMillis())
               / (1000 * 60 * 60 * 24));
-      // System.out.println("Diff in days : " + diffInDays);
+      // jalview.bin.Console.outPrintln("Diff in days : " + diffInDays);
     } catch (IOException e)
     {
       e.printStackTrace();
@@ -305,7 +306,7 @@ public class SiftsClient implements SiftsClientI
       pdbId = pdbId.replace(".cif", "");
     }
     String siftFile = pdbId + ".xml.gz";
-    String siftsFileFTPURL = SIFTS_FTP_BASE_URL + siftFile;
+    String siftsFileFTPURL = getDownloadUrlFor(siftFile);
 
     /*
      * Download the file from URL to either
@@ -329,7 +330,7 @@ public class SiftsClient implements SiftsClientI
       }
     }
 
-    // System.out.println(">> Download ftp url : " + siftsFileFTPURL);
+    // jalview.bin.Console.outPrintln(">> Download ftp url : " + siftsFileFTPURL);
     // long now = System.currentTimeMillis();
     URL url = new URL(siftsFileFTPURL);
     URLConnection conn = url.openConnection();
@@ -343,11 +344,19 @@ public class SiftsClient implements SiftsClientI
     }
     outputStream.close();
     inputStream.close();
-    // System.out.println(">>> File downloaded : " + downloadedSiftsFile
+    // jalview.bin.Console.outPrintln(">>> File downloaded : " + downloadedSiftsFile
     // + " took " + (System.currentTimeMillis() - now) + "ms");
     return downloadTo;
   }
 
+  public static String getDownloadUrlFor(String siftFile)
+  {
+    String durl = SIFTS_SPLIT_FTP_BASE_URL+siftFile.substring(1, 3)+"/"+siftFile;
+    Console.trace("SIFTS URL for "+siftFile+" is "+durl);
+    return durl;
+    
+  }
+
   /**
    * Delete the SIFTs file for the given PDB Id in the local SIFTs download
    * directory
@@ -450,7 +459,7 @@ public class SiftsClient implements SiftsClientI
       seq = seq.getDatasetSequence();
     }
     structId = (chain == null) ? pdbId : pdbId + "|" + chain;
-    System.out.println("Getting SIFTS mapping for " + structId + ": seq "
+    jalview.bin.Console.outPrintln("Getting SIFTS mapping for " + structId + ": seq "
             + seq.getName());
 
     final StringBuilder mappingDetails = new StringBuilder(128);
@@ -483,7 +492,7 @@ public class SiftsClient implements SiftsClientI
   {
     List<Integer> omitNonObserved = new ArrayList<>();
     int nonObservedShiftIndex = 0, pdbeNonObserved = 0;
-    // System.out.println("Generating mappings for : " + entityId);
+    // jalview.bin.Console.outPrintln("Generating mappings for : " + entityId);
     Entity entity = null;
     entity = getEntityById(entityId);
     String originalSeq = AlignSeq.extractGaps(
@@ -535,7 +544,7 @@ public class SiftsClient implements SiftsClientI
 
     if (mapping.isEmpty())
     {
-      throw new SiftsException("SIFTS mapping failed");
+      throw new SiftsException("SIFTS mapping failed for "+entityId+" and "+seq.getName());
     }
     // also construct a mapping object between the seq-coord sys and the PDB
     // seq's coord sys
@@ -653,7 +662,7 @@ public class SiftsClient implements SiftsClientI
     int firstPDBResNum = UNASSIGNED;
     for (Segment segment : segments)
     {
-      // System.out.println("Mapping segments : " + segment.getSegId() + "\\"s
+      // jalview.bin.Console.outPrintln("Mapping segments : " + segment.getSegId() + "\\"s
       // + segStartEnd);
       List<Residue> residues = segment.getListResidue().getResidue();
       for (Residue residue : residues)
@@ -922,8 +931,8 @@ public class SiftsClient implements SiftsClientI
     // Arrays.sort(keys);
     int firstIndex = keys[0];
     int lastIndex = keys[keys.length - 1];
-    // System.out.println("Min value " + firstIndex);
-    // System.out.println("Max value " + lastIndex);
+    // jalview.bin.Console.outPrintln("Min value " + firstIndex);
+    // jalview.bin.Console.outPrintln("Max value " + lastIndex);
     for (int x = firstIndex; x <= lastIndex; x++)
     {
       if (!resNumMap.containsKey(x) && !omitNonObserved.contains(x))
@@ -956,7 +965,7 @@ public class SiftsClient implements SiftsClientI
    */
   public Entity getEntityByMostOptimalMatchedId(String chainId)
   {
-    // System.out.println("---> advanced greedy entityId matching block
+    // jalview.bin.Console.outPrintln("---> advanced greedy entityId matching block
     // entered..");
     List<Entity> entities = siftsEntry.getEntity();
     SiftsEntitySortPojo[] sPojo = new SiftsEntitySortPojo[entities.size()];
@@ -992,8 +1001,8 @@ public class SiftsClient implements SiftsClientI
       ++count;
     }
     Arrays.sort(sPojo, Collections.reverseOrder());
-    // System.out.println("highest matched entity : " + sPojo[0].entityId);
-    // System.out.println("highest matched pid : " + sPojo[0].pid);
+    // jalview.bin.Console.outPrintln("highest matched entity : " + sPojo[0].entityId);
+    // jalview.bin.Console.outPrintln("highest matched pid : " + sPojo[0].pid);
 
     if (sPojo[0].entityId != null)
     {
index e2fb1b8..8299b02 100644 (file)
@@ -78,7 +78,7 @@ public class UrlDownloadClient
         }
       } catch (IOException e)
       {
-        System.out.println(
+        jalview.bin.Console.outPrintln(
                 "Exception while closing download file output stream: "
                         + e.getMessage());
       }
@@ -90,7 +90,7 @@ public class UrlDownloadClient
         }
       } catch (IOException e)
       {
-        System.out.println("Exception while closing download channel: "
+        jalview.bin.Console.outPrintln("Exception while closing download channel: "
                 + e.getMessage());
       }
       try
@@ -101,7 +101,7 @@ public class UrlDownloadClient
         }
       } catch (IOException e)
       {
-        System.out.println("Exception while deleting download temp file: "
+        jalview.bin.Console.outPrintln("Exception while deleting download temp file: "
                 + e.getMessage());
       }
     }
diff --git a/test/files/annotation_label_width/sample.a2m b/test/files/annotation_label_width/sample.a2m
new file mode 100644 (file)
index 0000000..0ca6801
--- /dev/null
@@ -0,0 +1,80 @@
+>101
+P.I...A..Q..I.....H.....I........L.......E........G.......R.......S....D.......E.......Q.....K....E.
+T..LI....RE...V.S.E...A...I......S.......R...S.......L........D....A.....P......L...................
+..........T......S.......V.......R......V...I....I.......T......E.....M........A....K.........G.....
+.H..........F..........G........I..........G........G......E........L....A...SK
+>UPI
+P.Hye.V..S..V.....T.....M........P.......T........G.......Wl......N....T.......V.......R.....K....Q.
+G..MI....DA...V.T.R...A...L......L.......E...A.......I........A....T.....P......F...................
+..........D......Essrfr..V.......R......C...L....I.......P......E.....I........P....D.........G.....
+.N..........W..........G........S..........G........Gya....L........P....L...S-
+>SRR
+P.H...V..A..V.....K.....L........Y.......P........G.......R.......T....E.......Q.......Q.....K....E.
+Q..LA....RA...I.A.D...D...V......M.......R...I.......L........G....S.....S......E...................
+..........A......S.......V.......S......V...S....I.......E......E.....V........D....A.........A.....
+.D..........W..........A........EkvyrplivegG........G......T........L....Y...KK
+>SRR
+P.H...V..I..V.....K.....L........W.......P........G.......R.......S....E.......P.......Q.....K....Q.
+K..LV....ES...V.T.K...A...V......T.......T...S.......L........G....Y.....S......D...................
+..........E......A.......V.......S......V...S....L.......Q......E.....V........P....S.........D.....
+.Q..........WtekvyrpdilG........T..........A........G......R........L....Y...KK
+>MGY
+P.I...V..R..I.....T.....M........F.......E........G.......R.......T....K.......E.......Q.....K....Q.
+E..LA....RV...I.T.E...A...V......V.......N...I.......A........K....T.....T......P...................
+..........D......A.......T.......E......VkdqI....L.......Q......K.....VllvrslrlP....PppasrrqvsG.....
+.A..........W..........S........A..........D........G......K........P....T...SE
+>446
+P.H...V..I..V.....K.....L........W.......P........G.......K.......S....E.......R.......E.....E....T.
+Q..LA....EA...I.T.K...S...V......T.......E...T.......L........N....F.....G......P...................
+..........E......S.......V.......S......V...A....F.......E......E.....I........P....A.........K.....
+.D..........W..........AskvyhadiI..........Gne......G......K........L....Y...KK
+>SRR
+P.L...V..R..I.....T.....Y........P.......R........Ga......L.......S....P.......E.......H.....K....T.
+R..IA....RA...L.T.E...I...V......L.......D...Vevdaa..T........D....A.....G......R...................
+..........M......V.......T.......V......V...H....F.......N......E.....A........A....P.........D.....
+.D..........W..........A........V..........G........G......Eirs.....T....A...AE
+>SRR
+P.L...V..R..I.....T.....Y........P.......R........Ga......L.......S....P.......D.......H.....K....R.
+R..IA....RE...L.T.E...I...V......L.......D...Vevdaa..T........D....A.....G......R...................
+..........M......V.......T.......V......I...H....F.......N......E.....A........A....A.........D.....
+.D..........W..........A........V..........G........G......Eirs.....T....A...AE
+>SRR
+P.R...Y..R..Vip...T.....V........P.......E........G.......Qy......S....N.......E.......S.....R....K.
+A..LV....KD...V.T.E...A...V......V.......R...A.......D........G....G.....K......Y...................
+..........E......Dvapr...V.......W......V...F....P.......T......E.....I........P....D.........G.....
+.Q..........W..........G........S..........R........Gvi....R........P....L...PE
+>SRR
+P.R...Y..R..Iip...T.....V........P.......E........G.......Qy......S....N.......E.......S.....R....K.
+A..LV....KD...V.T.E...A...V......V.......R...A.......D........G....G.....K......Y...................
+..........E......Dvapr...V.......W......V...F....P.......T......E.....I........P....D.........G.....
+.Q..........W..........G........S..........R........Gvi....R........P....L...PE
+>SRR
+P.V...I..E..M.....F.....V........P.......E........G.......La......D....A.......E.......A.....K....R.
+A..LH....DR...V.S.R...Q...V......L.......E...V.......E........G....AtydesP......L...................
+..........A......Qsi.....T.......W......M...L....I.......Q......E.....V........L....E.........C.....
+.G..........W..........S........V..........G........S......K........Avw..A...SE
+>SRR
+P.I...I..E..M.....H.....V........Q.......E........Gv......L.......D....E.......E.......T.....K....R.
+T..LH....ER...V.G.R...Q...V......L.......E...I.......E........G....Any...D......E...................
+..........N......D.......Varllt..F......M...F....I.......R......E.....H........P....E.........G.....
+.G..........F..........S........I..........G........G......E........M....It..SE
+>SRR
+P.Lyr.V..D..V.....T.....V........P.......E........Gsmihg..Q.......G....Pwal....S.......R.....R....R.
+A..IV....RE...V.T.E...I...V......L.......E...A.......E........G....S.....D......P...................
+..........Slgeaw.R.......V.......W......V...V....L.......R......E.....V........G....D.........A.....
+.F..........W..........G........A..........A........G......E........L....-...--
+>SRR
+P.Lyr.V..Q..I.....T.....V........P.......E........Gsmlhg..Q.......G....Pwai....E.......R.....R....R.
+E..LV....RA...V.S.K...A...V......L.......D...A.......E........G....Teyn..P......A...................
+..........Saw....R.......V.......W......V...L....M.......S......E.....I........S....E.........T.....
+.H..........W..........G........A..........A........G......E........-....-...--
+>SRR
+P.L...V..E..M.....S.....F........P.......V........Gv......L.......T....L.......D.......Q.....K....A.
+A..MI....KS...V.T.D...V...V......R.......G...A.......M........K....L.....P......P...................
+..........Dpar...K.......L.......F......V...E....I.......F......E.....T........P....G.........G.....
+.G..........F..........G........Vtakvvvvp..G........Gky....R........P....A...P-
+>SRR
+P.L...V..E..I.....D.....L........L.......E........A.......W.......A....P.......D.......Q.....I....D.
+A..IA....DA...I.H.E...A...M......V.......E...T.......L........G....V.....P......Eraagrdsatkqhfysrfaa
+llaeratvqsA......D.......L.......T......A...V....L.......V......E.....N........S....R.........D.....
+.D..........W..........S........F..........Gm.......G......Q........-....-...--
diff --git a/test/files/annotation_label_width/test_fab41_nostructureviewers.txt b/test/files/annotation_label_width/test_fab41_nostructureviewers.txt
new file mode 100644 (file)
index 0000000..b40c4e2
--- /dev/null
@@ -0,0 +1,15 @@
+--nonews
+--nosplash
+--open=./test/files/annotation_label_width/sample.a2m
+--colour=gecos:flower
+--gui
+--structure=[structureviewer=none]./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb
+--paematrix=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json
+--structure=[structureviewer=none]./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb
+--paematrix=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4_scores.json
+--structure=[structureviewer=none]./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb
+--paematrix=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2_scores.json
+--structure=[structureviewer=none]./examples/test_fab41.result/test_fab41_unrelaxed_rank_4_model_5.pdb
+--paematrix=./examples/test_fab41.result/test_fab41_unrelaxed_rank_4_model_5_scores.json
+--structure=[structureviewer=none]./examples/test_fab41.result/test_fab41_unrelaxed_rank_5_model_1.pdb
+--paematrix=./examples/test_fab41.result/test_fab41_unrelaxed_rank_5_model_1_scores.json
index 5a8361d..760e0ba 100644 (file)
@@ -67,7 +67,7 @@ public class AverageDistanceEngineTest
             + matrix.getMin());
     long start = System.currentTimeMillis();
     AverageDistanceEngine clusterer = new AverageDistanceEngine(
-            af.getViewport(), null, matrix);
+            af.getViewport(), null, matrix, false);
     System.out.println("built a tree in "
             + (System.currentTimeMillis() - start) * 0.001 + " seconds.");
     StringBuffer sb = new StringBuffer();
index 5134511..44bea81 100644 (file)
@@ -29,11 +29,15 @@ import jalview.datamodel.SequenceI;
 import jalview.gui.JvOptionPane;
 
 import java.io.PrintStream;
+import java.nio.charset.Charset;
+import java.util.Locale;
 
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import com.google.common.base.Charsets;
+
 /**
  * Test the alignment -> Mapping routines
  * 
@@ -83,16 +87,44 @@ public class TestAlignSeq
     assertEquals(as.getAStr1(), as.getAStr2());
 
     Mapping s1tos2 = as.getMappingFromS1(false);
+    checkMapping(s1tos2,s1,s2);
+  }
+
+  public void checkMapping(Mapping s1tos2,SequenceI _s1,SequenceI _s2)
+  {
     System.out.println(s1tos2.getMap().toString());
-    for (int i = s2.getStart(); i < s2.getEnd(); i++)
+    for (int i = _s2.getStart(); i < _s2.getEnd(); i++)
     {
-      System.out.println("Position in s2: " + i
-              + " maps to position in s1: " + s1tos2.getPosition(i));
-      // TODO fails: getCharAt doesn't allow for the start position??
-      // assertEquals(String.valueOf(s2.getCharAt(i)),
-      // String.valueOf(s1.getCharAt(s1tos2.getPosition(i))));
+      int p=s1tos2.getPosition(i);
+      char s2c=_s2.getCharAt(i-_s2.getStart());
+      char s1c=_s1.getCharAt(p-_s1.getStart());
+      System.out.println("Position in s2: " + i +s2c 
+      + " maps to position in s1: " +p+s1c);
+      assertEquals(s1c,s2c);
     }
   }
+  @Test(groups = { "Functional" })
+  /**
+   * simple test that mapping from alignment corresponds identical positions.
+   */
+  public void testGetMappingForS1_withLowerCase()
+  {
+    // make one of the sequences lower case
+    SequenceI ns2 = new Sequence(s2);
+    ns2.replace('D', 'd');
+    AlignSeq as = AlignSeq.doGlobalNWAlignment(s1, ns2, AlignSeq.PEP);
+    System.out.println("s1: " + as.getAStr1());
+    System.out.println("s2: " + as.getAStr2());
+
+    // aligned results match
+    assertEquals("ASDFA", as.getAStr1());
+    assertEquals(as.getAStr1(), as.getAStr2().toUpperCase(Locale.ROOT));
+
+    Mapping s1tos2 = as.getMappingFromS1(false);
+    assertEquals("ASdFA",as.getAStr2());
+    // verify mapping is consistent between original all-caps sequences
+    checkMapping(s1tos2,s1,s2);
+  }
 
   @Test(groups = { "Functional" })
   public void testExtractGaps()
index 0486744..77cbd92 100644 (file)
@@ -229,12 +229,13 @@ public class CommandLineOperations
     String ln = null;
     while ((ln = worker.getOutputReader().readLine()) != null)
     {
-      System.out.println(ln);
+      System.out.println("STDOUT: " + ln);
       successfulCMDs.add(ln);
     }
     while ((ln = worker.getErrorReader().readLine()) != null)
     {
-      System.err.println(ln);
+      System.err.println("STDERR: " + ln);
+      successfulCMDs.add(ln);
     }
   }
 
@@ -247,6 +248,7 @@ public class CommandLineOperations
 
     // number of lines expected on STDERR when Jalview starts up normally
     // may need to adjust this if Jalview is excessively noisy ?
+    final int STDOUT_SETUPLINES = 50;
     final int STDERR_SETUPLINES = 50;
 
     // thread monitors stderr - bails after SETUP_TIMEOUT or when
@@ -257,14 +259,24 @@ public class CommandLineOperations
       public void run()
       {
         String ln = null;
-        int count = 0;
+        int stdoutcount = 0;
+        int stderrcount = 0;
         try
         {
           while ((ln = worker.getOutputReader().readLine()) != null)
           {
             System.out.println(ln);
             successfulCMDs.add(ln);
-            if (++count > STDERR_SETUPLINES)
+            if (++stdoutcount > STDOUT_SETUPLINES)
+            {
+              break;
+            }
+          }
+          while ((ln = worker.getErrorReader().readLine()) != null)
+          {
+            System.err.println(ln);
+            successfulCMDs.add(ln);
+            if (++stderrcount > STDERR_SETUPLINES)
             {
               break;
             }
index 30a1b9f..56d4300 100644 (file)
@@ -27,6 +27,7 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.ArrayList;
@@ -161,6 +162,12 @@ public class CommandLineOperationsNG
   private Worker getJalviewDesktopRunner(boolean withAwt, String cmd,
           int timeout)
   {
+    return getJalviewDesktopRunner(withAwt, cmd, timeout, true);
+  }
+
+  private Worker getJalviewDesktopRunner(boolean withAwt, String cmd,
+          int timeout, boolean testoutput)
+  {
     /*
     boolean win = System.getProperty("os.name").indexOf("Win") >= 0;
     String pwd = "";
@@ -193,7 +200,7 @@ public class CommandLineOperationsNG
     Worker worker = null;
     try
     {
-      cmd = " --testoutput " + cmd;
+      cmd = cmd + (testoutput ? " --testoutput " : "");
       System.out.println("Running '" + _cmd + cmd + "'");
       ls2_proc = Runtime.getRuntime().exec(_cmd + cmd);
     } catch (Throwable e1)
@@ -368,6 +375,42 @@ public class CommandLineOperationsNG
     file.delete();
   }
 
+  @Test(
+    groups =
+    { "Functional", "testTask1" },
+    dataProvider = "headlessModeOutputToStdout")
+  public void testHeadlessModeOutputToStdout(String args,
+          String comparisonFile, int timeout)
+  {
+    String cmd = args;
+    File file = new File(comparisonFile);
+    Worker worker = getJalviewDesktopRunner(true, cmd, timeout, false);
+    int b = -1;
+    StringBuilder sb = new StringBuilder();
+    try
+    {
+      while ((b = worker.getOutputReader().read()) != -1)
+      {
+        sb.append(Character.toChars(b));
+      }
+    } catch (IOException e)
+    {
+      Assert.fail("IOException whilst trying to read from jalview process");
+    }
+
+    String comparisonContent = null;
+    try
+    {
+      comparisonContent = new String(Files.readAllBytes(file.toPath()));
+    } catch (IOException e)
+    {
+      Assert.fail("IOException whilst trying to read comparison file");
+    }
+
+    Assert.assertEquals(sb.toString(), comparisonContent,
+            "STDOUT from jalview command did not match the comparison file");
+  }
+
   @DataProvider(name = "allInputOperationsData")
   public Object[][] getHeadlessModeInputParams()
   {
@@ -459,4 +502,36 @@ public class CommandLineOperationsNG
         //
     };
   }
+
+  @DataProvider(name = "headlessModeOutputToStdout")
+  public static Object[][] getHeadlessModeOutputToStdout()
+  {
+    // JBPNote: I'm not clear why need to specify full path for output file
+    // when running tests on build server, but we will keep this patch for now
+    // since it works.
+    // https://issues.jalview.org/browse/JAL-1889?focusedCommentId=21609&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-21609
+    String workingDir = "test/jalview/bin";
+    return new Object[][] {
+        //
+        { "--open=examples/uniref50.fa --output=-",
+            workingDir + "/uniref50-output.fa", TEST_TIMEOUT },
+        { "--open examples/uniref50.fa --output -",
+            workingDir + "/uniref50-output.fa", TEST_TIMEOUT },
+        { "--open examples/uniref50.fa --output=[format=blc]-",
+            workingDir + "/uniref50-output.blc", TEST_TIMEOUT },
+        { "--open examples/uniref50.fa --output - --format blc",
+            workingDir + "/uniref50-output.blc", TEST_TIMEOUT },
+        { "./examples/uniref50.fa --output=-",
+            workingDir + "/uniref50-output.fa", TEST_TIMEOUT },
+        { "./examples/uniref50.fa --output - --format blc",
+            workingDir + "/uniref50-output.blc", TEST_TIMEOUT },
+        // remember you can't use shell wildcards for filenames in a test
+        { "./test/jalview/bin/argparser/testfiles/test1.fa ./test/jalview/bin/argparser/testfiles/test2.fa ./test/jalview/bin/argparser/testfiles/test3.fa --all --output -",
+            workingDir + "/test1-3.fa", TEST_TIMEOUT },
+        // but you can use java wildcards when using an equals sign
+        { "--open=./test/jalview/bin/argparser/testfiles/test*.fa --all --output -",
+            workingDir + "/test1-3.fa", TEST_TIMEOUT },
+        //
+    };
+  }
 }
index 61892df..fe40682 100644 (file)
@@ -19,7 +19,6 @@ import jalview.gui.Desktop;
 import jalview.gui.JvOptionPane;
 import jalview.util.ArrayUtils;
 
-@Test
 public class CommandsTest
 {
   private static final String testfiles = "test/jalview/bin/argparser/testfiles";
@@ -51,11 +50,15 @@ public class CommandsTest
   {
     Desktop.closeDesktop();
   }
-  
-  public static void callJalviewMain(String[] args) {
-    if (Jalview.getInstance()!=null) {
+
+  public static void callJalviewMain(String[] args)
+  {
+    if (Jalview.getInstance() != null)
+    {
       Jalview.getInstance().doMain(args);
-    } else {
+    }
+    else
+    {
       Jalview.main(args);
     }
   }
@@ -77,67 +80,89 @@ public class CommandsTest
   public void commandsOpenTest(String cmdLine, boolean cmdArgs,
           int numFrames, String[] sequences)
   {
-    String[] args = (cmdLine + " --gui").split("\\s+");
-    callJalviewMain(args);
-    Commands cmds = Jalview.getInstance().getCommands();
-    Assert.assertNotNull(cmds);
-    Assert.assertEquals(cmds.commandArgsProvided(), cmdArgs,
-            "Commands were not provided in the args");
-    Assert.assertEquals(cmds.argsWereParsed(), cmdArgs,
-            "Overall command parse and operation is false");
+    try
+    {
+      String[] args = (cmdLine + " --gui").split("\\s+");
+      callJalviewMain(args);
+      Commands cmds = Jalview.getInstance().getCommands();
+      Assert.assertNotNull(cmds);
+      Assert.assertEquals(cmds.commandArgsProvided(), cmdArgs,
+              "Commands were not provided in the args");
+      Assert.assertEquals(cmds.argsWereParsed(), cmdArgs,
+              "Overall command parse and operation is false");
 
-    Assert.assertEquals(Desktop.getAlignFrames().length, numFrames,
-            "Wrong number of AlignFrames");
+      Assert.assertEquals(Desktop.getAlignFrames().length, numFrames,
+              "Wrong number of AlignFrames");
 
-    if (sequences != null)
-    {
-      Set<String> openedSequenceNames = new HashSet<>();
-      AlignFrame[] afs = Desktop.getAlignFrames();
-      for (AlignFrame af : afs)
+      if (sequences != null)
       {
-        openedSequenceNames
-                .addAll(af.getViewport().getAlignment().getSequenceNames());
-      }
-      for (String sequence : sequences)
-      {
-        Assert.assertTrue(openedSequenceNames.contains(sequence),
-                "Sequence '" + sequence
-                        + "' was not found in opened alignment files: "
-                        + cmdLine + ".\nOpened sequence names are:\n"
-                        + String.join("\n", openedSequenceNames));
+        Set<String> openedSequenceNames = new HashSet<>();
+        AlignFrame[] afs = Desktop.getAlignFrames();
+        for (AlignFrame af : afs)
+        {
+          openedSequenceNames.addAll(
+                  af.getViewport().getAlignment().getSequenceNames());
+        }
+        for (String sequence : sequences)
+        {
+          Assert.assertTrue(openedSequenceNames.contains(sequence),
+                  "Sequence '" + sequence
+                          + "' was not found in opened alignment files: "
+                          + cmdLine + ".\nOpened sequence names are:\n"
+                          + String.join("\n", openedSequenceNames));
+        }
       }
-    }
 
-    Assert.assertFalse(
-            lookForSequenceName("THIS_SEQUENCE_ID_DOESN'T_EXIST"));
+      Assert.assertFalse(
+              lookForSequenceName("THIS_SEQUENCE_ID_DOESN'T_EXIST"));
+    } catch (Exception x)
+    {
+      Assert.fail("Unexpected exception during commandsOpenTest", x);
+    } finally
+    {
+      tearDown();
+
+    }
   }
 
-  @Test(groups = "Functional", dataProvider = "structureImageOutputFiles")
+  @Test(
+    groups =
+    { "Functional", "testTask1" },
+    dataProvider = "structureImageOutputFiles")
   public void structureImageOutputTest(String cmdLine, String[] filenames)
           throws IOException
   {
     cleanupFiles(filenames);
     String[] args = (cmdLine + " --gui").split("\\s+");
-    callJalviewMain(args);
-    Commands cmds = Jalview.getInstance().getCommands();
-    Assert.assertNotNull(cmds);
-    File lastFile = null;
-    for (String filename : filenames)
+    try
     {
-      File file = new File(filename);
-      Assert.assertTrue(file.exists(), "File '" + filename
-              + "' was not created by '" + cmdLine + "'");
-      Assert.assertTrue(file.isFile(), "File '" + filename
-              + "' is not a file from '" + cmdLine + "'");
-      Assert.assertTrue(Files.size(file.toPath()) > 0, "File '" + filename
-              + "' has no content from '" + cmdLine + "'");
-      // make sure the successive output files get bigger!
-      if (lastFile != null)
-        Assert.assertTrue(
-                Files.size(file.toPath()) > Files.size(lastFile.toPath()));
+      callJalviewMain(args);
+      Commands cmds = Jalview.getInstance().getCommands();
+      Assert.assertNotNull(cmds);
+      File lastFile = null;
+      for (String filename : filenames)
+      {
+        File file = new File(filename);
+        Assert.assertTrue(file.exists(), "File '" + filename
+                + "' was not created by '" + cmdLine + "'");
+        Assert.assertTrue(file.isFile(), "File '" + filename
+                + "' is not a file from '" + cmdLine + "'");
+        Assert.assertTrue(Files.size(file.toPath()) > 0, "File '" + filename
+                + "' has no content from '" + cmdLine + "'");
+        // make sure the successive output files get bigger!
+        if (lastFile != null)
+          Assert.assertTrue(Files.size(file.toPath()) > Files
+                  .size(lastFile.toPath()));
+      }
+    } catch (Exception x)
+    {
+      Assert.fail("Unexpected exception during structureImageOutputTest",
+              x);
+    } finally
+    {
+      cleanupFiles(filenames);
+      tearDown();
     }
-    cleanupFiles(filenames);
-    tearDown();
   }
 
   @Test(groups = "Functional", dataProvider = "argfileOutputFiles")
@@ -146,26 +171,36 @@ public class CommandsTest
   {
     cleanupFiles(filenames);
     String[] args = (cmdLine + " --gui").split("\\s+");
-    callJalviewMain(args);
-    Commands cmds = Jalview.getInstance().getCommands();
-    Assert.assertNotNull(cmds);
-    File lastFile = null;
-    for (String filename : filenames)
+    try
     {
-      File file = new File(filename);
-      Assert.assertTrue(file.exists(), "File '" + filename
-              + "' was not created by '" + cmdLine + "'");
-      Assert.assertTrue(file.isFile(), "File '" + filename
-              + "' is not a file from '" + cmdLine + "'");
-      Assert.assertTrue(Files.size(file.toPath()) > 0, "File '" + filename
-              + "' has no content from '" + cmdLine + "'");
-      // make sure the successive output files get bigger!
-      if (lastFile != null)
-        Assert.assertTrue(
-                Files.size(file.toPath()) > Files.size(lastFile.toPath()));
+      callJalviewMain(args);
+      Commands cmds = Jalview.getInstance().getCommands();
+      Assert.assertNotNull(cmds);
+      File lastFile = null;
+      for (String filename : filenames)
+      {
+        File file = new File(filename);
+        Assert.assertTrue(file.exists(), "File '" + filename
+                + "' was not created by '" + cmdLine + "'");
+        Assert.assertTrue(file.isFile(), "File '" + filename
+                + "' is not a file from '" + cmdLine + "'");
+        Assert.assertTrue(Files.size(file.toPath()) > 0, "File '" + filename
+                + "' has no content from '" + cmdLine + "'");
+        // make sure the successive output files get bigger!
+        if (lastFile != null)
+          Assert.assertTrue(Files.size(file.toPath()) > Files
+                  .size(lastFile.toPath()));
+      }
+    } catch (Exception x)
+    {
+      Assert.fail(
+              "Unexpected exception during argFilesGlobAndSubstitutions",
+              x);
+    } finally
+    {
+      cleanupFiles(filenames);
+      tearDown();
     }
-    cleanupFiles(filenames);
-    tearDown();
   }
 
   @DataProvider(name = "structureImageOutputFiles")
@@ -188,7 +223,6 @@ public class CommandsTest
             { testfiles + "/structureimage1.png",
                 testfiles + "/structureimage2.png",
                 testfiles + "/structureimage3.png" } },
-        /*
         { "--headless --noquit --open=./examples/test_fab41.result/sample.a2m "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
                 + "--structureimage=" + testfiles + "/structureimage1.png "
@@ -204,6 +238,7 @@ public class CommandsTest
             { testfiles + "/structureimage1.png",
                 testfiles + "/structureimage2.png",
                 testfiles + "/structureimage3.png" } },
+        /*
                 */
         //
     };
diff --git a/test/jalview/bin/test1-3.fa b/test/jalview/bin/test1-3.fa
new file mode 100644 (file)
index 0000000..c01e6cf
--- /dev/null
@@ -0,0 +1,6 @@
+>TEST1/1-4
+AAAA
+>TEST2/1-4
+LLLL
+>TEST3/1-5
+AAARG
diff --git a/test/jalview/bin/uniref50-output.blc b/test/jalview/bin/uniref50-output.blc
new file mode 100644 (file)
index 0000000..3614ef8
--- /dev/null
@@ -0,0 +1,174 @@
+>FER_CAPAA/1-97 Ferredoxin
+>FER_CAPAN/1-144 Ferredoxin, chloroplast precursor
+>FER1_SOLLC/1-144 Ferredoxin-1, chloroplast precursor
+>Q93XJ9_SOLTU/1-144 Ferredoxin I precursor
+>FER1_PEA/1-149 Ferredoxin-1, chloroplast precursor
+>Q7XA98_TRIPR/1-152 Ferredoxin I
+>FER1_MESCR/1-148 Ferredoxin-1, chloroplast precursor
+>FER1_SPIOL/1-147 Ferredoxin-1, chloroplast precursor
+>FER3_RAPSA/1-96 Ferredoxin, leaf L-A
+>FER2_ARATH/1-148 Ferredoxin-2, chloroplast precursor
+>FER_BRANA/1-96 Ferredoxin
+>FER1_ARATH/1-148 Ferredoxin-1, chloroplast precursor
+>Q93Z60_ARATH/1-118 At1g10960/T19D16_12
+>FER1_MAIZE/1-150 Ferredoxin-1, chloroplast precursor
+>O80429_MAIZE/1-140 Ferredoxin
+* iteration 1
+-MMMMMMM-M-MMMM
+-AAAAAAA-A-AAAA
+----TTAA-S-SSTA
+----TTTT-T-TTVT
+-------------L-
+-------------G-
+------TT-----S-
+----PPAT-----P-
+-SSSAAAT-A-AAR-
+-VIILLLM-L-LLA-
+-SSSYYSM-S-SSP-
+-AGGGGGG-S-SSA-
+-TTTTTA--A-AAF-
+-MMMAAT--I-IIFA
+-IIIVVMM-V-VVFL
+-SSSSSSA-G-SSSS
+-TTTTTTT-T-TTSM
+-SSSSSAT-S-SSSS
+-FFFFFFF-F-FFSI
+-MLLLMAV-I-LLLL
+-PPPRRPP-R-RRRR
+-RRRTRKK-R-RRA-
+-KKKQQ-P-S-QQA-
+-PPPPP-Q-P-QQP-
+-AAVMVTA-A-TTAA
+-VVVPPPP-P-PPPP
+-TTTMMPP-I-IITP
+-SSSSSMM-S-SSAP
+-LLLVVTM-L-LLVC
+------AA-R-RR-F
+-KKKTAAA-S-SS-S
+-PAATTLL-L-LLAS
+-IIITTPP-P-PPLP
+-PSSKTTS-S-FFPL
+-NNNATNN-A-AAAR
+-VVVFTVT-N-NNAL
+-GGGSKGG-T-TTKR
+-EEENARR-Q-QQVV
+-----F---------
+-----P---------
+-AAAGSAS-S-SSGA
+-LLLFGLL-L-LLIV
+-FFFLFFF-F-FFMA
+-GGGGGGG-G-GGGK
+-LLLLLLL-L-LLRP
+-KKKKKKK-K-KKSL
+-SSSTSST-S-SSAA
+-----V---------
+-AGGSSSG-G-SSSA
+----LTAS-T-TTSP
+----KKSR-A-AARM
+-NRRRRR--R-RRRR
+-GNNGG---G-GG-R
+-GGGDDGG-G-GG-Q
+-KRRLLRG-R-RRRL
+-VIIAAVR-V-VVLL
+-TTTVVTM-T-TTRR
+-CCCAAAT-A-AAAA
+-MMMMMMM-M-MMQQ
+AAAAAAAAAAAAAAA
+SSSSSTAATTTTTTT
+YYYYYYYYYYYYYYY
+KKKKKKKKKKKKKNN
+VVVVVVVVVVVVVVV
+KKKKKKTTKKKKKKK
+LLLLLLLLFFFFFLL
+IIIIVIVVIIIIIII
+TTTTTTTTTTTTTTT
+PPPPPPPPPPPPPPP
+DDEDDEETEEEEEEE
+GGGGGGGGGGGGGGG
+PPPPTPKNEEEEEEE
+IIIIQQQVQLQQQVV
+EEEEEEEEEEEEEEE
+FFFFFFLFVVVVVLL
+DDEEEDEQEEEEEQQ
+CCCCCCCCCCCCCVV
+PPPPPPPPDDDEEPP
+DDDDSDDDDDDEEDD
+DNDDDDDDDDDDDDD
+VVVVVVVVVVVVVVV
+YYYYYYYYYYYYYYY
+IIIIIIIIVVVVVII
+LLLLLLLLLLLLLLL
+DDDDDDDDDDDDDDD
+QQQQHHAAAAAAAQF
+AAAAAAAAAAAAAAA
+EEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEE
+AAEEVVAEAAAAADE
+GGGGGGGGGGGGGGG
+HHHHIIIIIIILLII
+DDDDDEDDDDDDDDD
+LLLLLLLLLLLLLLL
+PPPPPPPPPPPPPPP
+YYYYYYYYYYYYYYF
+SSSSSSSSSSSSSSS
+CCCCCCCCCCCCCCC
+RRRRRRRRRRRRRRR
+AAAAAAAAAAAAAAA
+GGGGGGGGGGGGGGG
+SSSSSSSSSSSSSSS
+CCCCCCCCCCCCCCC
+SSSSSSSSSSSSSSS
+SSSSSSSSSSSSSSS
+CCCCCCCCCCCCCCC
+AAAAAAAAAAAAAAA
+GGGGGGGGGGGGGGG
+KKKKKKKKKKKKKKK
+IIVVVVVLVVVVVVV
+AATTVVTKVVVVVVV
+GGAAGNSTSSSSSSS
+GGGGGGGGGGGGGGG
+AASTENSSSSFSSSS
+VVVVVVVLVVVIIVV
+DDDDDNNNDDDDDDD
+QQQQQQQQQQQQQQQ
+TTSSSEDDSSSSSSS
+DDDDDDDDDDDDDDD
+GGGGGGGQQQEQQQQ
+NNNKSSSSSSSSSSS
+FFFFFFFFFFFFFYF
+LLLLLLLLLLLLLLL
+DDDDDDDDDDDDDDN
+DDEDDDDDDDDDDDD
+DDDDEEDDDEDE-GN
+QQQQQQQQQQQQ-QQ
+LLEEIIIIIIIM-IV
+EEAAEEKDAGAS-AA
+EEAAAGEEEEEE-DD
+GGGGGGGGGGGG-GG
+WWFFFWWWFFFY-WW
+VVVVVVVVVVVV-VV
+LLLLLLLLLLLL-LL
+TTTTTTTTTTTT-TT
+CCCCCCCCCCCC-CC
+VVVVVVVAAAAV-HA
+AAAAAAAAAAAA-AA
+YYYYYFYYYYYY-YY
+PPPPPPPPPPPP-PP
+QQKKTTTVTTTT-TT
+SSGCSSGSSSSS-SS
+DDDDDDDDDDDD-DD
+VVVVVVVVVVVV-VV
+TTTTVTTTTTTV-VV
+IIIIIIIIIIII-II
+EEEEEEEEEEEE-EE
+TTTTTTTTTTTT-TT
+HHHHHHHHHHHH-HH
+KKKKKKKKRKKK-KK
+EEEEEEEEEEEE-EE
+AAEEEEEEEEEE-ED
+EEEEDEEEDDEA-ED
+LLLLLLLLMILI-LL
+VVTTTTTTVVVM-TL
+GGAAAAAA-----G-
+-------------A-
+*
diff --git a/test/jalview/bin/uniref50-output.fa b/test/jalview/bin/uniref50-output.fa
new file mode 100644 (file)
index 0000000..98e89f2
--- /dev/null
@@ -0,0 +1,60 @@
+>FER_CAPAA/1-97 Ferredoxin
+-----------------------------------------------------------ASYKVKLITPDGP
+IEFDCPDDVYILDQAEEAGHDLPYSCRAGSCSSCAGKIAGGAVDQTDGNFLDDDQLEEGWVLTCVAYPQSDV
+TIETHKEAELVG-
+>FER_CAPAN/1-144 Ferredoxin, chloroplast precursor
+MA------SVSATMISTSFMPRKPAVTSL-KPIPNVGE--ALFGLKS-A--NGGKVTCMASYKVKLITPDGP
+IEFDCPDNVYILDQAEEAGHDLPYSCRAGSCSSCAGKIAGGAVDQTDGNFLDDDQLEEGWVLTCVAYPQSDV
+TIETHKEAELVG-
+>FER1_SOLLC/1-144 Ferredoxin-1, chloroplast precursor
+MA------SISGTMISTSFLPRKPAVTSL-KAISNVGE--ALFGLKS-G--RNGRITCMASYKVKLITPEGP
+IEFECPDDVYILDQAEEEGHDLPYSCRAGSCSSCAGKVTAGSVDQSDGNFLDEDQEAAGFVLTCVAYPKGDV
+TIETHKEEELTA-
+>Q93XJ9_SOLTU/1-144 Ferredoxin I precursor
+MA------SISGTMISTSFLPRKPVVTSL-KAISNVGE--ALFGLKS-G--RNGRITCMASYKVKLITPDGP
+IEFECPDDVYILDQAEEEGHDLPYSCRAGSCSSCAGKVTAGTVDQSDGKFLDDDQEAAGFVLTCVAYPKCDV
+TIETHKEEELTA-
+>FER1_PEA/1-149 Ferredoxin-1, chloroplast precursor
+MATT---PALYGTAVSTSFLRTQPMPMSV-TTTKAFSN--GFLGLKT-SLKRGDLAVAMASYKVKLVTPDGT
+QEFECPSDVYILDHAEEVGIDLPYSCRAGSCSSCAGKVVGGEVDQSDGSFLDDEQIEAGFVLTCVAYPTSDV
+VIETHKEEDLTA-
+>Q7XA98_TRIPR/1-152 Ferredoxin I
+MATT---PALYGTAVSTSFMRRQPVPMSV-ATTTTTKAFPSGFGLKSVSTKRGDLAVAMATYKVKLITPEGP
+QEFDCPDDVYILDHAEEVGIELPYSCRAGSCSSCAGKVVNGNVNQEDGSFLDDEQIEGGWVLTCVAFPTSDV
+TIETHKEEELTA-
+>FER1_MESCR/1-148 Ferredoxin-1, chloroplast precursor
+MAAT--TAALSGATMSTAFAPK--TPPMTAALPTNVGR--ALFGLKS-SASR-GRVTAMAAYKVTLVTPEGK
+QELECPDDVYILDAAEEAGIDLPYSCRAGSCSSCAGKVTSGSVNQDDGSFLDDDQIKEGWVLTCVAYPTGDV
+TIETHKEEELTA-
+>FER1_SPIOL/1-147 Ferredoxin-1, chloroplast precursor
+MAAT--TTTMMG--MATTFVPKPQAPPMMAALPSNTGR--SLFGLKT-GSR--GGRMTMAAYKVTLVTPTGN
+VEFQCPDDVYILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDDQSFLDDDQIDEGWVLTCAAYPVSDV
+TIETHKEEELTA-
+>FER3_RAPSA/1-96 Ferredoxin, leaf L-A
+-----------------------------------------------------------ATYKVKFITPEGE
+QEVECDDDVYVLDAAEEAGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSFLDDDQIAEGFVLTCAAYPTSDV
+TIETHREEDMV--
+>FER2_ARATH/1-148 Ferredoxin-2, chloroplast precursor
+MAST----ALSSAIVGTSFIRRSPAPISLRSLPSANTQ--SLFGLKS-GTARGGRVTAMATYKVKFITPEGE
+LEVECDDDVYVLDAAEEAGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSFLDDEQIGEGFVLTCAAYPTSDV
+TIETHKEEDIV--
+>FER_BRANA/1-96 Ferredoxin
+-----------------------------------------------------------ATYKVKFITPEGE
+QEVECDDDVYVLDAAEEAGIDLPYSCRAGSCSSCAGKVVSGFVDQSDESFLDDDQIAEGFVLTCAAYPTSDV
+TIETHKEEELV--
+>FER1_ARATH/1-148 Ferredoxin-1, chloroplast precursor
+MAST----ALSSAIVSTSFLRRQQTPISLRSLPFANTQ--SLFGLKS-STARGGRVTAMATYKVKFITPEGE
+QEVECEEDVYVLDAAEEAGLDLPYSCRAGSCSSCAGKVVSGSIDQSDQSFLDDEQMSEGYVLTCVAYPTSDV
+VIETHKEEAIM--
+>Q93Z60_ARATH/1-118 At1g10960/T19D16_12
+MAST----ALSSAIVSTSFLRRQQTPISLRSLPFANTQ--SLFGLKS-STARGGRVTAMATYKVKFITPEGE
+QEVECEEDVYVLDAAEEAGLDLPYSCRAGSCSSCAGKVVSGSIDQSDQSFLDD-------------------
+-------------
+>FER1_MAIZE/1-150 Ferredoxin-1, chloroplast precursor
+MATVLGSPRAPAFFFSSSSLRAAPAPTAV--ALPAAKV--GIMGRSA-SSRR--RLRAQATYNVKLITPEGE
+VELQVPDDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDV
+VIETHKEEELTGA
+>O80429_MAIZE/1-140 Ferredoxin
+MAAT---------ALSMSILR---APPPCFSSPLRLRV--AVAKPLA-APMRRQLLRAQATYNVKLITPEGE
+VELQVPDDVYILDFAEEEGIDLPFSCRAGSCSSCAGKVVSGSVDQSDQSFLNDNQVADGWVLTCAAYPTSDV
+VIETHKEDDLL--
index 67edb37..bdfa5a3 100644 (file)
@@ -73,7 +73,7 @@ public class PAEContactMatrixTest
     verifyPAEmatrix(seq, aa, 0, 0, 4);
 
     // test clustering
-    paematrix.setGroupSet(GroupSet.makeGroups(paematrix, 0.1f, false));
+    paematrix.setGroupSet(GroupSet.makeGroups(paematrix, false,0.1f, false));
 
     // remap - test the MappableContactMatrix.liftOver method
     SequenceI newseq = new Sequence("Seq", "ASDQEASDQEASDQE");
index 344d74d..7bbb9f3 100644 (file)
@@ -2315,8 +2315,16 @@ public class SequenceTest
   {
     Sequence origSeq = new Sequence("MYSEQ", "THISISASEQ");
     Sequence toSeq = new Sequence("MYSEQ", "THISISASEQ");
+    origSeq.setDescription("DESCRIPTION");
     origSeq.addDBRef(new DBRefEntry("UNIPROT", "0", "Q12345", null, true));
+
+    toSeq.transferAnnotation(origSeq, null);
+    assertEquals("DESCRIPTION",toSeq.getDescription());
+    toSeq = new Sequence("MYSEQ", "THISISASEQ");
+    toSeq.setDescription("unchanged");
     toSeq.transferAnnotation(origSeq, null);
+    assertEquals("unchanged",toSeq.getDescription());
+    
     assertTrue(toSeq.getDBRefs().size() == 1);
 
     assertTrue(toSeq.getDBRefs().get(0).isCanonical());
diff --git a/test/jalview/gui/AnnotationLabelsTest2.java b/test/jalview/gui/AnnotationLabelsTest2.java
new file mode 100644 (file)
index 0000000..ad97e8b
--- /dev/null
@@ -0,0 +1,253 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.gui;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.io.File;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SequenceI;
+import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.DataSourceType;
+import jalview.io.FileLoader;
+import jalview.structure.StructureImportSettings.TFType;
+
+public class AnnotationLabelsTest2
+{
+  @BeforeClass(alwaysRun = true)
+  public static void setUpBeforeClass() throws Exception
+  {
+    if (Desktop.instance != null)
+      Desktop.instance.closeAll_actionPerformed(null);
+
+    setUpJvOptionPane();
+    /*
+     * use read-only test properties file
+     */
+    Cache.loadProperties("test/jalview/io/testProps.jvprops");
+    Jalview.main(new String[] { "--nonews", "--nosplash", });
+  }
+
+  @AfterMethod(alwaysRun = true)
+  public void tearDown()
+  {
+    if (Desktop.instance != null)
+      Desktop.instance.closeAll_actionPerformed(null);
+  }
+
+  /**
+   * configure (read-only) properties for test to ensure Consensus is computed
+   * for colour Above PID testing
+   */
+  @BeforeMethod(alwaysRun = true)
+  public void setUp()
+  {
+    Cache.loadProperties("test/jalview/io/testProps.jvprops");
+    Cache.applicationProperties.setProperty("SHOW_IDENTITY",
+            Boolean.TRUE.toString());
+
+  }
+
+  public static void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
+  @Test(
+    groups =
+    { "Functional", "testTask1" },
+    dataProvider = "openFilesWithIdWidthChanges")
+  public void testIdWidthChanges(String alignmentFilename, boolean wrap,
+          int idWidth1min, int idWidth1max, int manualWidth,
+          String structureFilename, String paeFilename,
+          boolean secondaryStructureView, TFType temperatureFactorType,
+          ViewerType viewerType, int idWidth2min, int idWidth2max)
+  {
+    AlignFrame af = new FileLoader()
+            .LoadFileWaitTillLoaded(alignmentFilename, DataSourceType.FILE);
+    try
+    {
+      Thread.sleep(200); // to allow alignment annotations to open
+    } catch (InterruptedException e)
+    {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+    AlignViewport av = af.getCurrentView();
+
+    int idWidth = 0;
+
+    idWidth = av.getIdWidth();
+    assertTrue(idWidth > idWidth1min,
+            "idWidth (" + idWidth + ") is not greater than " + idWidth1min);
+    assertTrue(idWidth < idWidth1max,
+            "idWidth (" + idWidth + ") is not narrower than" + idWidth1max);
+
+    // set wrap
+    if (wrap)
+    {
+      af.setWrapFormat(true, false);
+      idWidth = av.getIdWidth();
+      assertTrue(idWidth > idWidth1min, "After wrap idWidth (" + idWidth
+              + ") is not greater than " + idWidth1min);
+      assertTrue(idWidth < idWidth1max, "After wrap idWidth (" + idWidth
+              + ") is not narrower than" + idWidth1max);
+    }
+
+    AlignmentI al = av.getAlignment();
+    SequenceI s = al.getSequenceAt(0);
+    AlignmentPanel ap = af.alignPanel;
+
+    File structureFile = new File(structureFilename);
+    File paeFile = new File(paeFilename);
+
+    StructureViewer sv = StructureChooser.openStructureFileForSequence(null,
+            null, ap, s, false, structureFile.getAbsolutePath(),
+            temperatureFactorType, paeFile.getAbsolutePath(), true,
+            secondaryStructureView, false, viewerType);
+    // give time for annotations to open
+    try
+    {
+      Thread.sleep(200); // to allow alignment annotations to open
+    } catch (InterruptedException e)
+    {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+
+    // idWidth = ap.getIdPanel().getWidth();
+    idWidth = av.getIdWidth();
+    assertTrue(idWidth > idWidth2min,
+            "idWidth (" + idWidth + ") is not greater than " + idWidth2min);
+    assertTrue(idWidth < idWidth2max,
+            "idWidth (" + idWidth + ") is not narrower than" + idWidth2max);
+  }
+
+  @Test(
+    groups =
+    { "Functional", "testTask1" },
+    dataProvider = "openFilesWithIdWidthChanges")
+  public void testIdWidthNoChanges(String alignmentFilename, boolean wrap,
+          int idWidth1min, int idWidth1max, int manualWidth,
+          String structureFilename, String paeFilename,
+          boolean secondaryStructureView, TFType temperatureFactorType,
+          ViewerType viewerType, int idWidth2min, int idWidth2max)
+  {
+    AlignFrame af = new FileLoader()
+            .LoadFileWaitTillLoaded(alignmentFilename, DataSourceType.FILE);
+    try
+    {
+      Thread.sleep(200); // to allow alignment annotations to open
+    } catch (InterruptedException e)
+    {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+    AlignViewport av = af.getCurrentView();
+
+    int idWidth = 0;
+
+    idWidth = av.getIdWidth();
+    assertTrue(idWidth > idWidth1min,
+            "idWidth (" + idWidth + ") is not greater than " + idWidth1min);
+    assertTrue(idWidth < idWidth1max,
+            "idWidth (" + idWidth + ") is not narrower than" + idWidth1max);
+
+    AlignmentI al = av.getAlignment();
+    SequenceI s = al.getSequenceAt(0);
+    AlignmentPanel ap = af.alignPanel;
+
+    // set width manually
+    av.setIdWidth(manualWidth);
+    ap.validateAnnotationDimensions(false);
+    ap.paintAlignment(true, false);
+    ap.getIdPanel().getIdCanvas().setManuallyAdjusted(true);
+
+    idWidth = av.getIdWidth();
+    assertEquals(idWidth, manualWidth,
+            "idWidth is not set to the manually set width " + manualWidth);
+
+    File structureFile = new File(structureFilename);
+    File paeFile = new File(paeFilename);
+
+    StructureViewer sv = StructureChooser.openStructureFileForSequence(null,
+            null, ap, s, false, structureFile.getAbsolutePath(),
+            temperatureFactorType, paeFile.getAbsolutePath(), false,
+            secondaryStructureView, false, viewerType);
+
+    idWidth = ap.getIdPanel().getWidth();// av.getIdWidth();
+    idWidth = av.getIdWidth();
+    assertEquals(idWidth, manualWidth,
+            "idWidth is not set to the manually set width " + manualWidth
+                    + " after adding structure annotations");
+    assertFalse(idWidth > idWidth2min,
+            "idWidth (" + idWidth + ") is greater than " + idWidth2min);
+  }
+
+  @DataProvider(name = "openFilesWithIdWidthChanges")
+  public Object[][] openFilesWithIdWidthChanges()
+  {
+    /*
+      String alignmentFilename,
+      boolean wrap,
+      int idWidth1min,
+      int idWidth1max,
+      int manualWidth, // ignored by testIdWidthChanges()
+      String structureFilename,
+      String paeFilename,
+      boolean secondaryStructureView,
+      TFType temperatureFactorType,
+      ViewerType viewerType,
+      int idWidth2min,
+      int idWidth2max,
+     */
+    return new Object[][] {
+        //
+        /*
+         */
+        { "./test/files/annotation_label_width/sample.a2m", false, 50, 70,
+            100,
+            "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
+            "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json",
+            true, TFType.PLDDT, null, 115, 130 },
+        { "./test/files/annotation_label_width/sample.a2m", true, 50, 70,
+            100,
+            "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
+            "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json",
+            true, TFType.PLDDT, null, 115, 130 },
+        /*
+         */
+    };
+  }
+
+}
index 65cea6f..d2b6f65 100644 (file)
  */
 package jalview.io;
 
+import jalview.datamodel.SequenceI;
 import jalview.gui.JvOptionPane;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
 import java.io.File;
+import java.io.IOException;
 
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import fr.orsay.lri.varna.utils.RNAMLParser;
+import groovy.lang.Sequence;
+
 public class RNAMLfileTest
 {
 
@@ -57,4 +65,14 @@ public class RNAMLfileTest
 
   }
 
+  @Test(groups= {"Functional"})
+  public void testRnamlSeqImport() throws IOException
+  {
+    RnamlFile parser = new RnamlFile("examples/testdata/7WKP-rna1.xml", DataSourceType.FILE);
+    SequenceI[] seqs  = parser.getSeqsAsArray();
+    assertNotNull(seqs);
+    assertEquals(seqs.length,1);
+    assertEquals(seqs[0].getEnd()-seqs[0].getStart()+1,seqs[0].getSequence().length);
+  }
+
 }
index 9946f4c..288444e 100644 (file)
  */
 package jalview.io.cache;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.LinkedHashSet;
 
+import javax.swing.SwingUtilities;
+
 import org.junit.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -54,11 +57,19 @@ public class JvCacheableInputBoxTest
 
     try
     {
-      // This delay is essential to prevent the
-      // assertion below from executing before
-      // swing thread finishes updating the combo-box
-      Thread.sleep(350);
-    } catch (InterruptedException e)
+      // fix for JAL-4153
+      // This delay is essential to prevent the assertion below from executing
+      // before swing thread finishes updating the combo-box
+      SwingUtilities.invokeAndWait(() -> {
+        try
+        {
+          Thread.sleep(1);
+        } catch (InterruptedException e)
+        {
+          e.printStackTrace();
+        }
+      });
+    } catch (InvocationTargetException | InterruptedException e)
     {
       e.printStackTrace();
     }
@@ -73,12 +84,21 @@ public class JvCacheableInputBoxTest
     cacheBox.addItem(testInput);
     cacheBox.setSelectedItem(testInput);
     cacheBox.updateCache();
+
     try
     {
-      // This delay is to let
-      // cacheBox.updateCache() finish updating the cache
-      Thread.sleep(350);
-    } catch (InterruptedException e)
+      // fix for JAL-4153
+      // This delay is to let cacheBox.updateCache() finish updating the cache
+      SwingUtilities.invokeAndWait(() -> {
+        try
+        {
+          Thread.sleep(1);
+        } catch (InterruptedException e)
+        {
+          e.printStackTrace();
+        }
+      });
+    } catch (InvocationTargetException | InterruptedException e)
     {
       e.printStackTrace();
     }
index 37f946b..c9532cc 100644 (file)
@@ -1563,7 +1563,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
       {
         paevals[i][j] = ((i - j < 2)
                 || ((i > 1 && i < 5) && (j > 1 && i < 5))) ? 1 : 0f;
-        paevals[j][i] = paevals[i][j];
+        paevals[j][i] = -paevals[i][j];
       }
     }
     PAEContactMatrix dummyMat = new PAEContactMatrix(sq, paevals);
@@ -1573,7 +1573,8 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     float[][] vals = ContactMatrix.fromFloatStringToContacts(content,
             sq.getLength(), sq.getLength());
     assertEquals(vals[3][4], paevals[3][4]);
-    dummyMat.setGroupSet(GroupSet.makeGroups(dummyMat, 0.5f, false));
+    assertEquals(vals[4][3], paevals[4][3]);
+    dummyMat.setGroupSet(GroupSet.makeGroups(dummyMat, false,0.5f, false));
     Assert.assertNotSame(dummyMat.getNewick(), "");
     AlignmentAnnotation paeCm = sq.addContactList(dummyMat);
     al.addAnnotation(paeCm);
index 44a6a02..0f5bd4d 100644 (file)
@@ -195,8 +195,10 @@ public class SiftsClientTest
     SiftsSettings.setCacheThresholdInDays("2");
     SiftsSettings.setFailSafePIDThreshold("70");
     PDBfile pdbFile;
+    
     pdbFile = new PDBfile(false, false, false,
             "test/jalview/io/" + testPDBId + ".pdb", DataSourceType.FILE);
+    // TODO: this uses a network connection - we should mock the sifts testPDBId.xml.gz
     siftsClient = new SiftsClient(pdbFile);
   }
 
@@ -205,6 +207,12 @@ public class SiftsClientTest
   {
     siftsClient = null;
   }
+  
+  @Test(groups= {"Functional"})
+  public void testSIFTsDownloadURL() {
+    String expectedUrl = "https://ftp.ebi.ac.uk/pub/databases/msd/sifts/split_xml/xy/1xyz.sifts.xml.gz";
+    Assert.assertEquals(SiftsClient.getDownloadUrlFor("1xyz.sifts.xml.gz"), expectedUrl);
+  }
 
   @Test(groups = { "Network" })
   public void getSIFTsFileTest() throws SiftsException, IOException
@@ -215,7 +223,7 @@ public class SiftsClientTest
     long t1 = siftsFile.lastModified();
 
     // re-read file should be returned from cache
-    siftsFile = SiftsClient.downloadSiftsFile(testPDBId);
+    siftsFile = SiftsClient.getSiftsFile(testPDBId);
     FileAssert.assertFile(siftsFile);
     long t2 = siftsFile.lastModified();
     assertEquals(t1, t2);
@@ -368,7 +376,7 @@ public class SiftsClientTest
   {
     SequenceI invalidTestSeq = new Sequence("testSeq", "ABCDEFGH");
     DBRefEntry invalidDBRef = new DBRefEntry();
-    invalidDBRef.setAccessionId("BLAR");
+    invalidDBRef.setAccessionId("BLAR"); // note no version is set, so also invalid
     invalidTestSeq.addDBRef(invalidDBRef);
     siftsClient.getValidSourceDBRef(invalidTestSeq);
   }
diff --git a/utils/biotools/Jalview.json b/utils/biotools/Jalview.json
new file mode 100644 (file)
index 0000000..69aa95c
--- /dev/null
@@ -0,0 +1,417 @@
+{
+  "name": "Jalview",
+  "description": "Jalview is a free program for multiple sequence alignment editing, visualisation and analysis. Use it to view and edit sequence alignments, analyse them with phylogenetic trees and principal components analysis (PCA) plots and explore molecular structures and annotation.",
+  "homepage": "https://www.jalview.org/",
+  "biotoolsID": "Jalview",
+  "biotoolsCURIE": "biotools:Jalview",
+  "version": [
+    "2.11.2.7"
+  ],
+  "relation": [
+    {
+      "biotoolsID": "jabaws",
+      "type": "uses"
+    },
+    {
+      "biotoolsID": "chimera",
+      "type": "uses"
+    },
+    {
+      "biotoolsID": "chimerax",
+      "type": "uses"
+    },
+    {
+      "biotoolsID": "pymol",
+      "type": "uses"
+    },
+    {
+      "biotoolsID": "bioconda",
+      "type": "includedIn"
+    },
+    {
+      "biotoolsID": "3d-beacons",
+      "type": "uses"
+    },
+    {
+      "biotoolsID": "uniprot",
+      "type": "uses"
+    },
+    {
+      "biotoolsID": "pfam",
+      "type": "uses"
+    },
+    {
+      "biotoolsID": "ensembl",
+      "type": "uses"
+    },
+    {
+      "biotoolsID": "pdb",
+      "type": "uses"
+    },
+    {
+      "biotoolsID": "rfam",
+      "type": "uses"
+    }
+  ],
+  "function": [
+    {
+      "operation": [
+        {
+          "uri": "http://edamontology.org/operation_0564",
+          "term": "Sequence visualisation"
+        },
+        {
+          "uri": "http://edamontology.org/operation_0324",
+          "term": "Phylogenetic tree analysis"
+        },
+        {
+          "uri": "http://edamontology.org/operation_3081",
+          "term": "Sequence alignment editing"
+        }
+      ],
+      "input": [
+        {
+          "data": {
+            "uri": "http://edamontology.org/data_0863",
+            "term": "Sequence alignment"
+          },
+          "format": [
+            {
+              "uri": "http://edamontology.org/format_1939",
+              "term": "GFF3-seq"
+            },
+            {
+              "uri": "http://edamontology.org/format_1982",
+              "term": "ClustalW format"
+            },
+            {
+              "uri": "http://edamontology.org/format_1961",
+              "term": "Stockholm format"
+            },
+            {
+              "uri": "http://edamontology.org/format_1984",
+              "term": "FASTA-aln"
+            },
+            {
+              "uri": "http://edamontology.org/format_1938",
+              "term": "GFF2-seq"
+            },
+            {
+              "uri": "http://edamontology.org/format_1929",
+              "term": "FASTA"
+            },
+            {
+              "uri": "http://edamontology.org/format_1948",
+              "term": "nbrf/pir"
+            },
+            {
+              "uri": "http://edamontology.org/format_3774",
+              "term": "BioJSON (Jalview)"
+            },
+            {
+              "uri": "http://edamontology.org/format_1997",
+              "term": "PHYLIP format"
+            },
+            {
+              "uri": "http://edamontology.org/format_3313",
+              "term": "BLC"
+            },
+            {
+              "uri": "http://edamontology.org/format_3311",
+              "term": "RNAML"
+            },
+            {
+              "uri": "http://edamontology.org/format_1947",
+              "term": "GCG MSF"
+            },
+            {
+              "uri": "http://edamontology.org/format_3015",
+              "term": "Pileup"
+            },
+            {
+              "uri": "http://edamontology.org/format_1477",
+              "term": "mmCIF"
+            },
+            {
+              "uri": "http://edamontology.org/format_3016",
+              "term": "VCF"
+            },
+            {
+              "uri": "http://edamontology.org/format_1915",
+              "term": "Format"
+            }
+          ]
+        },
+        {
+          "data": {
+            "uri": "http://edamontology.org/data_0886",
+            "term": "Structure alignment"
+          },
+          "format": [
+            {
+              "uri": "http://edamontology.org/format_1476",
+              "term": "PDB"
+            }
+          ]
+        }
+      ],
+      "output": [
+        {
+          "data": {
+            "uri": "http://edamontology.org/data_0863",
+            "term": "Sequence alignment"
+          },
+          "format": [
+            {
+              "uri": "http://edamontology.org/format_1948",
+              "term": "nbrf/pir"
+            },
+            {
+              "uri": "http://edamontology.org/format_3464",
+              "term": "JSON"
+            },
+            {
+              "uri": "http://edamontology.org/format_1961",
+              "term": "Stockholm format"
+            },
+            {
+              "uri": "http://edamontology.org/format_1929",
+              "term": "FASTA"
+            },
+            {
+              "uri": "http://edamontology.org/format_1997",
+              "term": "PHYLIP format"
+            },
+            {
+              "uri": "http://edamontology.org/format_3313",
+              "term": "BLC"
+            },
+            {
+              "uri": "http://edamontology.org/format_3774",
+              "term": "BioJSON (Jalview)"
+            },
+            {
+              "uri": "http://edamontology.org/format_1947",
+              "term": "GCG MSF"
+            },
+            {
+              "uri": "http://edamontology.org/format_3015",
+              "term": "Pileup"
+            },
+            {
+              "uri": "http://edamontology.org/format_1982",
+              "term": "ClustalW format"
+            }
+          ]
+        },
+        {
+          "data": {
+            "uri": "http://edamontology.org/data_2884",
+            "term": "Plot"
+          },
+          "format": [
+            {
+              "uri": "http://edamontology.org/format_3603",
+              "term": "PNG"
+            },
+            {
+              "uri": "http://edamontology.org/format_2331",
+              "term": "HTML"
+            },
+            {
+              "uri": "http://edamontology.org/format_3466",
+              "term": "EPS"
+            },
+            {
+              "uri": "http://edamontology.org/format_3604",
+              "term": "SVG"
+            },
+            {
+              "uri": "http://edamontology.org/format_1915",
+              "term": "Format"
+            }
+          ]
+        }
+      ],
+      "note": "Other Input formats:\nAMSA (.amsa);\nJnetFile (.concise, .jnet);\nPFAM (.pfam);\nSubstitution matrix (.matrix);\nJalview Project File (.jvp);\nJalview Feature File (.features, .jvfeatures);\nJalview Annotations File (.annotations, .jvannotations);\n\n...\nOther Output formats:\nPFAM (.pfam);\nBioJS (.biojs) (interactive HTML/Javascript);\nJalview Project File (.jvp);"
+    }
+  ],
+  "toolType": [
+    "Desktop application"
+  ],
+  "topic": [
+    {
+      "uri": "http://edamontology.org/topic_0080",
+      "term": "Sequence analysis"
+    },
+    {
+      "uri": "http://edamontology.org/topic_0092",
+      "term": "Data visualisation"
+    }
+  ],
+  "operatingSystem": [
+    "Linux",
+    "Windows",
+    "Mac"
+  ],
+  "license": "GPL-3.0",
+  "maturity": "Mature",
+  "cost": "Free of charge",
+  "accessibility": "Open access",
+  "elixirPlatform": [
+    "Tools"
+  ],
+  "elixirNode": [
+    "UK"
+  ],
+  "link": [
+    {
+      "url": "https://discourse.jalview.org/",
+      "type": [
+        "Discussion forum"
+      ]
+    },
+    {
+      "url": "https://issues.jalview.org/",
+      "type": [
+        "Issue tracker"
+      ]
+    },
+    {
+      "url": "https://www.jalview.org/development/jalview_develop/",
+      "type": [
+        "Other"
+      ],
+      "note": "Latest development version"
+    },
+    {
+      "url": "https://source.jalview.org/crucible/browse/jalview",
+      "type": [
+        "Repository"
+      ]
+    },
+    {
+      "url": "https://twitter.com/Jalview",
+      "type": [
+        "Social media"
+      ],
+      "note": "Twitter feed"
+    },
+    {
+      "url": "https://www.youtube.com/channel/UCIjpnvZB770yz7ftbrJ0tfw",
+      "type": [
+        "Social media"
+      ],
+      "note": "YouTube training videos"
+    }
+  ],
+  "download": [
+    {
+      "url": "https://www.jalview.org/download",
+      "type": "Downloads page"
+    },
+    {
+      "url": "https://www.jalview.org/download/source/",
+      "type": "Source code"
+    },
+    {
+      "url": "https://www.jalview.org/download/?os=all",
+      "type": "Binaries",
+      "note": "Binaries for all platforms"
+    },
+    {
+      "url": "https://www.jalview.org/favicon.svg",
+      "type": "Icon"
+    },
+    {
+      "url": "https://www.jalview.org/download/other/jar/",
+      "type": "Binaries",
+      "note": "Executable JAR file"
+    }
+  ],
+  "documentation": [
+    {
+      "url": "https://www.jalview.org/about/citation",
+      "type": [
+        "Citation instructions"
+      ]
+    },
+    {
+      "url": "https://www.jalview.org/training/",
+      "type": [
+        "Training material"
+      ],
+      "note": "Hands-on exercises, Training courses and Training videos"
+    },
+    {
+      "url": "https://www.jalview.org/help/faq",
+      "type": [
+        "FAQ"
+      ]
+    },
+    {
+      "url": "https://www.jalview.org/help/documentation/",
+      "type": [
+        "User manual"
+      ]
+    }
+  ],
+  "publication": [
+    {
+      "doi": "10.1093/bioinformatics/btp033",
+      "metadata": {
+        "title": "Jalview Version 2-A multiple sequence alignment editor and analysis workbench",
+        "abstract": "Summary: Jalview Version 2 is a system for interactive WYSIWYG editing, analysis and annotation of multiple sequence alignments. Core features include keyboard and mouse-based editing, multiple views and alignment overviews, and linked structure display with Jmol. Jalview 2 is available in two forms: a lightweight Java applet for use in web applications, and a powerful desktop application that employs web services for sequence alignment, secondary structure prediction and the retrieval of alignments, sequences, annotation and structures from public databases and any DAS 1.53 compliant sequence or annotation server. © 2009 The Author(s).",
+        "date": "2009-05-07T00:00:00Z",
+        "citationCount": 5999,
+        "authors": [
+          {
+            "name": "Waterhouse A.M."
+          },
+          {
+            "name": "Procter J.B."
+          },
+          {
+            "name": "Martin D.M.A."
+          },
+          {
+            "name": "Clamp M."
+          },
+          {
+            "name": "Barton G.J."
+          }
+        ],
+        "journal": "Bioinformatics"
+      }
+    }
+  ],
+  "credit": [
+    {
+      "name": "Jim Procter",
+      "url": "http://www.lifesci.dundee.ac.uk/people/jim-procter",
+      "orcidid": "https://orcid.org/0000-0002-7865-7382",
+      "typeEntity": "Person",
+      "typeRole": [
+        "Primary contact"
+      ]
+    },
+    {
+      "name": "Geoff Barton",
+      "url": "https://www.lifesci.dundee.ac.uk/people/geoff-barton",
+      "orcidid": "https://orcid.org/0000-0002-9014-5355"
+    }
+  ],
+  "owner": "ben_s",
+  "additionDate": "2019-02-13T17:01:40Z",
+  "lastUpdate": "2023-07-22T09:24:44.755337Z",
+  "editPermission": {
+    "type": "group",
+    "authors": [
+      "ben_s",
+      "jimprocter"
+    ]
+  },
+  "validated": 1,
+  "homepage_status": 0,
+  "elixir_badge": 0
+}
diff --git a/utils/biotools/README.md b/utils/biotools/README.md
new file mode 100644 (file)
index 0000000..948a751
--- /dev/null
@@ -0,0 +1,13 @@
+This is the JSON representation of the latest Jalview release's record on bio.tools
+
+To update:
+1. go to https://bio.tools/Jalview
+2. log in and scroll down to the 'Update Record' button to open the edit interface.
+3. Make any chances to the entry - press Validate to ensure all is good
+4. Select the JSON tab and copy paste into
+
+``
+cat > utils/biotools/Jalview.json
+``
+
+Thanks to Herve Menager for the tutorial on storing bio.tools records with the tool's software repository at [CoFest 2023](https://www.open-bio.org/events/bosc-2023/obf-bosc-collaborationfest-2023)
\ No newline at end of file
diff --git a/utils/conda/jalview.sh b/utils/conda/jalview.sh
new file mode 100755 (executable)
index 0000000..995195f
--- /dev/null
@@ -0,0 +1,178 @@
+#!/usr/bin/env bash
+
+###############################
+# Wrapper for Jalview
+#
+# 2023-08-16 Jalview 2.11.3.0 has new command line arguments
+# Old command line arguments are currently detected and actioned
+# but are no longer supported and will be removed at a later date.
+#
+# See
+#   Jalview -> Help -> Documentation -> Command Line -> introduction and reference
+# or
+#   https://www.jalview.org/help/html/features/clarguments.html
+# for details of the new command line arguments.
+#
+# Note, in order to run commandline-only calls use
+#   --headless
+#
+# By default, this wrapper executes java -version to determine the JRE version
+# Set JALVIEW_JRE=j1.8 or JALVIEW_JRE=j11 to skip the version check.
+#
+# By default, this wrapper does NOT restrict the memory consumption of Jalview.
+# Set eg. JALVIEW_MAXMEM=1g to set the maximal memory of Jalview's VM
+#
+# This script is maintained in the Jalview repository in utils/conda/jalview.sh
+###############################
+
+declare -a ARGS=("${@}")
+ARG1=$1
+
+# this function is because there's no readlink -f in Darwin/macOS
+function readlinkf() {
+  FINDFILE="$1"
+  FILE="${FINDFILE}"
+  PREVFILE=""
+  C=0
+  MAX=100 # just in case we end up in a loop
+  FOUND=0
+  while [ "${C}" -lt "${MAX}" -a "${FILE}" != "${PREVFILE}" -a "${FOUND}" -ne 1 ]; do
+    PREVFILE="${FILE}"
+    FILE="$(readlink "${FILE}")"
+    if [ -z "${FILE}" ]; then
+      # the readlink is empty means we've arrived at the script, let's canonicalize with pwd
+      FILE="$(cd "$(dirname "${PREVFILE}")" &> /dev/null && pwd -P)"/"$(basename "${PREVFILE}")"
+      FOUND=1
+    elif [ "${FILE#/}" = "${FILE}" ]; then
+      # FILE is not an absolute path link, we need to add the relative path to the previous dir
+      FILE="$(dirname "${PREVFILE}")/${FILE}"
+    fi
+    C=$((C+1))
+  done
+  if [ "${FOUND}" -ne 1 ]; then
+    echo "Could not determine path to actual file '$(basename "${FINDFILE}")'" >&2
+    exit 1
+  fi
+  echo "${FILE}"
+}
+
+ISMACOS=0
+if [ "$( uname -s )" = "Darwin" ]; then
+  ISMACOS=1
+fi
+
+# check for headless mode
+HEADLESS=0
+GUI=0
+HELP=0
+DEBUG=0
+for RAWARG in "${@}"; do
+  ARG="${RAWARG%%=*}"
+  case "${ARG}" in
+    --headless|--output|--image|--structureimage)
+      HEADLESS=1
+      ;;
+    --help|--help-*|--version)
+      HELP=1
+      ;;
+    --gui)
+      GUI=1
+      ;;
+    --debug)
+      DEBUG=1
+      ;;
+  esac
+  
+  if [ "${HELP}" = 1 ]; then
+    # --help takes precedence
+    HEADLESS=1
+    GUI=0
+  elif [ "${GUI}" = 1 ]; then
+    # --gui takes precedence over --headless
+    HEADLESS=0
+  fi
+done
+
+declare -a JVMARGS=()
+
+# set vars for being inside the macos App Bundle
+if [ "${ISMACOS}" = 1 ]; then
+# MACOS ONLY
+  DIR="$(dirname "$(readlinkf "$0")")"
+  JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${DIR}/jalview_logo.png" )
+else
+# NOT MACOS
+  DIR="$(dirname "$(readlink -f "$0")")"
+fi
+
+if [ "${HEADLESS}" = 1 ]; then
+  # this suppresses the Java icon appearing in the macOS Dock and maybe other things in other OSes
+  JVMARGS=( "${JVMARGS[@]}" "-Djava.awt.headless=true" )
+fi
+
+JAVA=java
+
+# decide which jalview jar to launch - either 'j11' or 'j1.8'
+if [[ "$JALVIEW_JRE" != "j11" && "$JALVIEW_JRE" != "j1.8" ]]; then
+  JALVIEW_JRE="j11"
+  # if java 8 is installed we pick the j1.8 build
+  if [[ $( "${JAVA}" -version 2>&1 | grep '"1.8' ) != "" ]]; then
+    JALVIEW_JRE="j1.8"
+  fi
+fi
+
+JARPATH="${DIR}/jalview-all-${JALVIEW_JRE}.jar"
+
+# check if memory maximum is set and if so forward to java-based jalview call
+if [ \! -z "$JALVIEW_MAXMEM" ]; then
+  JVMARGS=( "${JVMARGS[@]}" "-Xmx${JALVIEW_MAXMEM}" )
+fi
+
+# WINDOWS ONLY (Cygwin or WSL)
+# change paths for Cygwin or Windows Subsystem for Linux (WSL)
+if [ "${ISMACOS}" != 1 ]; then # older macos doesn't like uname -o, best to avoid
+  if [ "$(uname -o)" = "Cygwin" ]; then
+  # CYGWIN
+    JARPATH="$(cygpath -pw "${JARPATH}")"
+    # now for some arg paths fun. only translating paths starting with './', '../', '/' or '~'
+    ARGS=()
+    for ARG in "${@}"; do
+      if [ "${ARG}" != "${ARG#@(/|./|../|~)}" ]; then
+        ARGS=( "${ARGS[@]}" "$(cygpath -aw "${ARG}")" )
+      else
+        ARGS=( "${ARGS[@]}" "${ARG}" )
+      fi
+    done
+  elif uname -r | grep -i microsoft | grep -i wsl >/dev/null; then
+  # WSL
+    JARPATH="$(wslpath -aw "${JARPATH}")"
+    ARGS=()
+    for ARG in "${@}"; do
+      if [ "${ARG}" != "${ARG#@(/|./|../|~)}" ]; then
+        # annoyingly wslpath does not work if the file doesn't exist!
+        ARGBASENAME="$(basename "${ARG}")"
+        ARGDIRNAME="$(dirname "${ARG}")"
+        ARGS=( "${ARGS[@]}" "$(wslpath -aw "${ARGDIRNAME}")\\${ARGBASENAME}" )
+      else
+        ARGS=( "${ARGS[@]}" "${ARG}" )
+      fi
+    done
+    JAVA="${JAVA}.exe"
+  fi
+fi
+
+# get console width -- three ways to try, just in case
+if command -v tput 2>&1 >/dev/null; then
+  COLUMNS=$(tput cols) 2>/dev/null
+elif command -v stty 2>&1 >/dev/null; then
+  COLUMNS=$(stty size | cut -d" " -f2) 2>/dev/null
+elif command -v resize 2>&1 >/dev/null; then
+  COLUMNS=$(resize -u | grep COLUMNS= | sed -e 's/.*=//;s/;//') 2>/dev/null
+fi
+JVMARGS=( "${JVMARGS[@]}" "-DCONSOLEWIDTH=${COLUMNS}" )
+
+if [ "${DEBUG}" = 1 ]; then
+ echo Shell running: "${JAVA}" "${JVMARGS[@]}" -jar \""${JARPATH}"\" "${ARGS[@]}"
+fi
+
+"${JAVA}" "${JVMARGS[@]}" -jar "${JARPATH}" "${ARGS[@]}"
index 9e3a8c7..9281be2 100755 (executable)
@@ -36,18 +36,45 @@ if [ "$( uname -s )" = "Darwin" ]; then
   ISMACOS=1
 fi
 
+# check for headless mode
+HEADLESS=0
+GUI=0
+HELP=0
+DEBUG=0
+for RAWARG in "${@}"; do
+  ARG="${RAWARG%%=*}"
+  case "${ARG}" in
+    --headless|--output|--image|--structureimage)
+      HEADLESS=1
+      ;;
+    --help|--help-*|--version)
+      HELP=1
+      ;;
+    --gui)
+      GUI=1
+      ;;
+    --debug)
+      DEBUG=1
+      ;;
+  esac
+  
+  if [ "${HELP}" = 1 ]; then
+    # --help takes precedence
+    HEADLESS=1
+    GUI=0
+  elif [ "${GUI}" = 1 ]; then
+    # --gui takes precedence over --headless
+    HEADLESS=0
+  fi
+done
+
 declare -a JVMARGS=()
 
 # set vars for being inside the macos App Bundle
 if [ "${ISMACOS}" = 1 ]; then
 # MACOS ONLY
   DIR="$(dirname "$(readlinkf "$0")")"
-  APP="${DIR%.app/Contents/*}".app
-  if [ "${APP}" = "${APP%.app}" ]; then
-    echo "Could not find Jalview.app" >&2
-    exit 2
-  fi
-  APPDIR="${APP}/Contents/Resources/app"
+  APPDIR="${DIR%/bin}"
   JAVA="${APPDIR}/jre/Contents/Home/bin/java"
   JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${APPDIR}/resource/jalview_logo.png" )
 else
@@ -57,6 +84,11 @@ else
   JAVA="${APPDIR}/jre/bin/java"
 fi
 
+if [ "${HEADLESS}" = 1 ]; then
+  # this suppresses the Java icon appearing in the macOS Dock and maybe other things in other OSes
+  JVMARGS=( "${JVMARGS[@]}" "-Djava.awt.headless=true" )
+fi
+
 SYSJAVA=java
 GETDOWNTXT="${APPDIR}/getdown.txt"
 
@@ -131,4 +163,8 @@ if [ \! -e "${JAVA}" ]; then
   echo "Cannot find bundled java, using system ${JAVA} and hoping for the best!" >&2
 fi
 
+if [ "${DEBUG}" = 1 ]; then
+ echo Shell running: \""${JAVA}"\" \""${JVMARGS[@]}"\" -cp \""${CLASSPATH}"\" jalview.bin.Launcher "${ARGS[@]}"
+fi
+
 "${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" jalview.bin.Launcher "${ARGS[@]}"
index 3bc98ae..b0887e3 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<install4j version="10.0.5" transformSequenceNumber="10">
+<install4j version="10.0.6" transformSequenceNumber="10">
   <directoryPresets config="bin/Jalview" />
   <application name="${compiler:JALVIEW_APPLICATION_NAME}" applicationId="${compiler:WINDOWS_APPLICATION_ID}" mediaDir="${compiler:BUILD_DIR}" lzmaCompression="true" shortName="${compiler:INTERNAL_ID}" publisher="University of Dundee" publisherWeb="https://www.jalview.org/" version="${compiler:JALVIEW_VERSION}" allPathsRelative="true" macVolumeId="5aac4968c304f65" javaMinVersion="${compiler:JAVA_MIN_VERSION}" javaMaxVersion="${compiler:JAVA_MAX_VERSION}" allowBetaVM="true" jdkMode="jdk" jdkName="JDK 11.0">
     <searchSequence>
@@ -1477,7 +1477,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch.</property>
       </exclude>
       <jreBundle jreBundleSource="preCreated" includedJre="${compiler:WINDOWS_X64_JAVA_VM_TGZ}" manualJreEntry="true" />
     </windows>
-    <macosArchive name="macOS x64 Disk Image" id="878" customizedId="MACOS-X64-DMG" mediaFileName="${compiler:APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-x64-java_${compiler:JAVA_INTEGER_VERSION}" volumeName="${compiler:INSTALLER_NAME}" launcherId="737" setupAppId="2746">
+    <macosArchive name="macOS x64 (intel) Disk Image" id="878" customizedId="MACOS-X64-DMG" mediaFileName="${compiler:APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-x64-java_${compiler:JAVA_INTEGER_VERSION}" volumeName="${compiler:INSTALLER_NAME}" launcherId="737" setupAppId="2746">
       <exclude>
         <entry defaultFileset="true" />
         <entry filesetId="2803" />
@@ -1494,7 +1494,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch.</property>
         <symlink name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/app/jre/Contents/Home/bin/${compiler:JALVIEW_NAME}" target="java" />
       </topLevelFiles>
     </macosArchive>
-    <macosArchive name="macOS aarch64 Disk Image" id="2796" customizedId="MACOS-AARCH64-DMG" mediaFileName="${compiler:APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-aarch64-java_${compiler:JAVA_INTEGER_VERSION}" volumeName="${compiler:INSTALLER_NAME}" architecture="aarch64" launcherId="737" setupAppId="2746">
+    <macosArchive name="macOS aarch64 (Apple Silicon) Disk Image" id="2796" customizedId="MACOS-AARCH64-DMG" mediaFileName="${compiler:APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-aarch64-java_${compiler:JAVA_INTEGER_VERSION}" volumeName="${compiler:INSTALLER_NAME}" architecture="aarch64" launcherId="737" setupAppId="2746">
       <exclude>
         <entry defaultFileset="true" />
         <entry filesetId="2801" />