X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FCommands.java;h=8ba4194550cf59ec3d9638a23075f112f0415748;hb=a2f16af6d565a7535083ff87da9be198b31d95c0;hp=a092cd697f9392ecf3a875f8db1542ac6a652d63;hpb=ab980b5a5576787c34f6b5ea4e31c11ffda286bd;p=jalview.git diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index a092cd6..8ba4194 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -1,3 +1,23 @@ +/* + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.bin; import java.awt.Color; @@ -196,7 +216,7 @@ public class Commands if (avm.containsArg(Arg.APPEND) || avm.containsArg(Arg.OPEN)) { commandArgsProvided = true; - long progress = -1; + final long progress = System.currentTimeMillis(); boolean first = true; boolean progressBarSet = false; @@ -222,10 +242,18 @@ public class Commands first = false; if (!headless && desktop != null) { - desktop.setProgressBar( - MessageManager.getString( - "status.processing_commandline_args"), - progress = System.currentTimeMillis()); + SwingUtilities.invokeLater(new Runnable() + { + @Override + public void run() + { + desktop.setProgressBar( + MessageManager.getString( + "status.processing_commandline_args"), + progress); + + } + }); progressBarSet = true; } } @@ -300,9 +328,17 @@ public class Commands } // colour alignment - String colour = avm.getFromSubValArgOrPref(av, Arg.COLOUR, sv, - null, "DEFAULT_COLOUR_PROT", ""); - this.colourAlignFrame(af, colour); + String colour = null; + if (avm.containsArg(Arg.COLOUR) + || !(format == FileFormat.Jalview)) + { + colour = avm.getFromSubValArgOrPref(av, Arg.COLOUR, sv, null, + "DEFAULT_COLOUR_PROT", null); + } + if (colour != null) + { + this.colourAlignFrame(af, colour); + } // Change alignment frame title String title = avm.getFromSubValArgOrPref(av, Arg.TITLE, sv, null, @@ -363,25 +399,27 @@ public class Commands } } - // Show secondary structure annotations? boolean showSSAnnotations = avm.getFromSubValArgOrPref( Arg.SHOWSSANNOTATIONS, av.getSubVals(), null, "STRUCT_FROM_PDB", true); - + // Show sequence annotations? boolean showAnnotations = avm.getFromSubValArgOrPref( Arg.SHOWANNOTATIONS, av.getSubVals(), null, "SHOW_ANNOTATIONS", true); - + boolean hideTFrows = (avm.getBoolean(Arg.NOTEMPFAC)); final AlignFrame _af = af; - // many of jalview's format/layout methods are only thread safe on the swingworker thread. - // all these methods should be on the alignViewController so it can coordinate such details + // many of jalview's format/layout methods are only thread safe on the + // swingworker thread. + // all these methods should be on the alignViewController so it can + // coordinate such details try { SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { @@ -433,9 +471,11 @@ public class Commands { Console.debug( "Opening '" + openFile + "' in existing alignment frame"); + DataSourceType dst = HttpUtils.startsWithHttpOrHttps(openFile) ? DataSourceType.URL : DataSourceType.FILE; + FileLoader fileLoader = new FileLoader(!headless); fileLoader.LoadFile(af.getCurrentView(), openFile, dst, null, false); @@ -464,17 +504,18 @@ public class Commands // open the structure (from same PDB file or given PDBfile) if (!avm.getBoolean(Arg.NOSTRUCTURE)) { + AlignFrame af = afMap.get(id); if (avm.containsArg(Arg.STRUCTURE)) { commandArgsProvided = true; - for (ArgValue av : avm.getArgValueList(Arg.STRUCTURE)) + for (ArgValue structureAv : avm.getArgValueList(Arg.STRUCTURE)) { argParser.setStructureFilename(null); - String val = av.getValue(); - SubVals subVals = av.getSubVals(); - int argIndex = av.getArgIndex(); - SequenceI seq = getSpecifiedSequence(af, avm, av); + String val = structureAv.getValue(); + SubVals subVals = structureAv.getSubVals(); + int argIndex = structureAv.getArgIndex(); + SequenceI seq = getSpecifiedSequence(af, avm, structureAv); if (seq == null) { // Could not find sequence from subId, let's assume the first @@ -543,8 +584,8 @@ public class Commands // get PAEMATRIX file and label from subvals or Arg.PAEMATRIX String paeFilepath = avm.getFromSubValArgOrPrefWithSubstitutions( - argParser, Arg.PAEMATRIX, ArgValuesMap.Position.AFTER, av, - subVals, null, null, null); + argParser, Arg.PAEMATRIX, ArgValuesMap.Position.AFTER, + structureAv, subVals, null, null, null); if (paeFilepath != null) { File paeFile = new File(paeFilepath); @@ -568,8 +609,8 @@ public class Commands // get TEMPFAC type from subvals or Arg.TEMPFAC in case user Adds // reference annotations String tftString = avm.getFromSubValArgOrPrefWithSubstitutions( - argParser, Arg.TEMPFAC, ArgValuesMap.Position.AFTER, av, - subVals, null, null, null); + argParser, Arg.TEMPFAC, ArgValuesMap.Position.AFTER, + structureAv, subVals, null, null, null); boolean notempfac = avm.getFromSubValArgOrPref(Arg.NOTEMPFAC, subVals, null, "ADD_TEMPFACT_ANN", false, true); TFType tft = notempfac ? null : TFType.DEFAULT; @@ -601,8 +642,8 @@ public class Commands } String sViewerName = avm.getFromSubValArgOrPref( - Arg.STRUCTUREVIEWER, ArgValuesMap.Position.AFTER, av, - subVals, null, null, "jmol"); + Arg.STRUCTUREVIEWER, ArgValuesMap.Position.AFTER, + structureAv, subVals, null, null, "jmol"); ViewerType viewerType = ViewerType.getFromString(sViewerName); // TODO use ssFromStructure @@ -663,7 +704,8 @@ public class Commands if (avm.containsArg(Arg.STRUCTUREIMAGE)) { for (ArgValue structureImageArgValue : avm - .getArgValueList(Arg.STRUCTUREIMAGE)) + .getArgValueListFromSubValOrArg(structureAv, + Arg.STRUCTUREIMAGE, subVals)) { String structureImageFilename = argParser.makeSubstitutions( structureImageArgValue.getValue(), id, true); @@ -835,6 +877,7 @@ public class Commands if (wrap) { + AlignFrame af = afMap.get(id); if (af != null) { @@ -846,16 +889,16 @@ public class Commands boolean doShading = avm.getBoolean(Arg.TEMPFAC_SHADING); if (doShading) { - AlignFrame af = afMap.get(id); - for (AlignmentAnnotation aa : af.alignPanel.getAlignment() - .findAnnotation(PDBChain.class.getName().toString())) - { - AnnotationColourGradient acg = new AnnotationColourGradient(aa, - af.alignPanel.av.getGlobalColourScheme(), 0); - acg.setSeqAssociated(true); - af.changeColour(acg); - Console.info("Changed colour " + acg.toString()); - } + AlignFrame af = afMap.get(id); + for (AlignmentAnnotation aa : af.alignPanel.getAlignment() + .findAnnotation(PDBChain.class.getName().toString())) + { + AnnotationColourGradient acg = new AnnotationColourGradient(aa, + af.alignPanel.av.getGlobalColourScheme(), 0); + acg.setSeqAssociated(true); + af.changeColour(acg); + Console.info("Changed colour " + acg.toString()); + } } */ @@ -1232,8 +1275,19 @@ public class Commands private void colourAlignFrame(AlignFrame af, ColourSchemeI cs) { - // Note that cs == null removes colour scheme from af - af.changeColour(cs); + try { + SwingUtilities.invokeAndWait(new Runnable() + { + @Override + public void run() + { + // Note that cs == null removes colour scheme from af + af.changeColour(cs); + } + }); } catch (Exception x) { + Console.trace("Interrupted whilst waiting for colorAlignFrame action",x); + + } } private ColourSchemeI getColourScheme(AlignFrame af)