return sb.toString();
}
- // Helper methods with safety checks
- protected static ArgValues getArgValues(Map<Arg, ArgValues> m, Arg a)
- {
- return m == null ? null : m.get(a);
- }
-
- public static List<ArgValue> getArgValueList(Map<Arg, ArgValues> m, Arg a)
- {
- ArgValues av = getArgValues(m, a);
- return av == null ? null : av.getArgValueList();
- }
-
- public static ArgValue getArgValue(Map<Arg, ArgValues> m, Arg a)
- {
- List<ArgValue> vals = getArgValueList(m, a);
- return (vals == null || vals.size() == 0) ? null : vals.get(0);
- }
-
- public static String getValue(Map<Arg, ArgValues> m, Arg a)
- {
- ArgValue av = getArgValue(m, a);
- return av == null ? null : av.getValue();
- }
-
- public static boolean hasValue(Map<Arg, ArgValues> m, Arg a)
- {
- if (!m.containsKey(a))
- return false;
- return getArgValue(m, a) != null;
- }
-
- public static boolean getBoolean(Map<Arg, ArgValues> m, Arg a)
- {
- ArgValues av = getArgValues(m, a);
- return av == null ? false : av.getBoolean();
- }
-
public static SubVals getSubVals(String item)
{
return new SubVals(item);
}
}
+ /**
+ * Helper class to allow easy extraction of information about specific
+ * argument values (without having to check for null etc all the time)
+ */
+ protected static class ArgValuesMap
+ {
+ protected Map<Arg, ArgValues> m;
+
+ protected ArgValuesMap(Map<Arg, ArgValues> map)
+ {
+ this.m = map;
+ }
+
+ protected ArgValues getArgValues(Arg a)
+ {
+ return m == null ? null : m.get(a);
+ }
+
+ protected List<ArgValue> getArgValueList(Arg a)
+ {
+ ArgValues av = getArgValues(a);
+ return av == null ? null : av.getArgValueList();
+ }
+
+ protected ArgValue getArgValue(Arg a)
+ {
+ List<ArgValue> vals = getArgValueList(a);
+ return (vals == null || vals.size() == 0) ? null : vals.get(0);
+ }
+
+ protected String getValue(Arg a)
+ {
+ ArgValue av = getArgValue(a);
+ return av == null ? null : av.getValue();
+ }
+
+ protected boolean hasValue(Arg a)
+ {
+ if (!m.containsKey(a))
+ return false;
+ return getArgValue(a) != null;
+ }
+
+ protected boolean getBoolean(Arg a)
+ {
+ ArgValues av = getArgValues(a);
+ return av == null ? false : av.getBoolean();
+ }
+ }
+
private static final Collection<String> bootstrapArgs = new ArrayList(
Arrays.asList("props", "debug"));
import jalview.api.AlignmentViewPanel;
import jalview.bin.ArgParser.Arg;
import jalview.bin.ArgParser.ArgValue;
-import jalview.bin.ArgParser.ArgValues;
+import jalview.bin.ArgParser.ArgValuesMap;
import jalview.bin.ArgParser.SubVals;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
protected void processUnlinked(String id)
{
- Map<Arg, ArgValues> m = argParser.linkedArgs(id);
+ ArgValuesMap avm = new ArgValuesMap(argParser.linkedArgs(id));
processLinked(id);
}
protected void processLinked(String id)
{
- Map<Arg, ArgValues> m = argParser.linkedArgs(id);
+ ArgValuesMap avm = new ArgValuesMap(argParser.linkedArgs(id));
/*
// script to execute after all loading is completed one way or another
FileFormatI format = null;
DataSourceType protocol = null;
*/
- if (ArgParser.getArgValues(m, Arg.OPEN) != null)
+ if (avm.hasValue(Arg.OPEN))
{
long progress = -1;
boolean first = true;
AlignFrame af;
- for (ArgValue av : ArgParser.getArgValueList(m, Arg.OPEN))
+ for (ArgValue av : avm.getArgValueList(Arg.OPEN))
{
String openFile = av.getValue();
if (openFile == null)
// get kind of temperature factor annotation
StructureImportSettings.TFType tempfacType = TFType.DEFAULT;
- if ((!ArgParser.getBoolean(m, Arg.NOTEMPFAC))
- && ArgParser.getArgValues(m, Arg.TEMPFAC) != null)
+ if ((!avm.getBoolean(Arg.NOTEMPFAC)) && avm.hasValue(Arg.TEMPFAC))
{
try
{
tempfacType = StructureImportSettings.TFType
- .valueOf(ArgParser.getArgValue(m, Arg.TEMPFAC)
- .getValue().toUpperCase(Locale.ROOT));
+ .valueOf(avm.getArgValue(Arg.TEMPFAC).getValue()
+ .toUpperCase(Locale.ROOT));
Console.debug("Obtained Temperature Factor type of '"
+ tempfacType + "'");
} catch (IllegalArgumentException e)
format);
// wrap alignment?
- if (ArgParser.getBoolean(m, Arg.WRAP))
+ if (avm.getBoolean(Arg.WRAP))
{
af.getCurrentView().setWrapAlignment(true);
}
// colour aligment?
- if (ArgParser.hasValue(m, Arg.COLOUR))
+ if (avm.hasValue(Arg.COLOUR))
{
- af.changeColour_actionPerformed(
- ArgParser.getValue(m, Arg.COLOUR));
+ af.changeColour_actionPerformed(avm.getValue(Arg.COLOUR));
}
// change alignment frame title
- if (ArgParser.getValue(m, Arg.TITLE) != null)
- af.setTitle(ArgParser.getValue(m, Arg.TITLE));
+ if (avm.hasValue(Arg.TITLE))
+ af.setTitle(avm.getValue(Arg.TITLE));
/* hacky approach to hiding the annotations */
// show secondary structure annotations?
- if (ArgParser.getBoolean(m, Arg.SSANNOTATION))
+ if (avm.getBoolean(Arg.SSANNOTATION))
{
// do this better (annotation types?)
AlignmentUtils.showOrHideSequenceAnnotations(
}
// show temperature factor annotations?
- if (ArgParser.getBoolean(m, Arg.NOTEMPFAC))
+ if (avm.getBoolean(Arg.NOTEMPFAC))
{
// do this better (annotation types?)
List<String> hideThese = new ArrayList<>();
if (showTemperatureFactor)
*/
{
- if (ArgParser.getValue(m, Arg.TEMPFAC_LABEL) != null)
+ if (avm.hasValue(Arg.TEMPFAC_LABEL))
{
AlignmentAnnotation aa = AlignmentUtils
.getFirstSequenceAnnotationOfType(
af.getCurrentView().getAlignment(),
AlignmentAnnotation.LINE_GRAPH);
- String label = ArgParser.getValue(m, Arg.TEMPFAC_LABEL);
+ String label = avm.getValue(Arg.TEMPFAC_LABEL);
if (aa != null)
{
aa.label = label;
}
// open the structure (from same PDB file or given PDBfile)
- if (!ArgParser.getBoolean(m, Arg.NOSTRUCTURE))
+ if (!avm.getBoolean(Arg.NOSTRUCTURE))
{
AlignFrame af = afMap.get(id);
- if (ArgParser.getArgValues(m, Arg.STRUCTURE) != null)
+ if (avm.hasValue(Arg.STRUCTURE))
{
- for (ArgValue av : ArgParser.getArgValueList(m, Arg.STRUCTURE))
+ for (ArgValue av : avm.getArgValueList(Arg.STRUCTURE))
{
String val = av.getValue();
SubVals subId = new SubVals(val);
}
// load a pAE file if given
- if (ArgParser.getArgValueList(m, Arg.PAEMATRIX) != null)
+ if (avm.hasValue(Arg.PAEMATRIX))
{
AlignFrame af = afMap.get(id);
if (af != null)
{
- for (ArgValue av : ArgParser.getArgValueList(m, Arg.PAEMATRIX))
+ for (ArgValue av : avm.getArgValueList(Arg.PAEMATRIX))
{
String val = av.getValue();
SubVals subVals = ArgParser.getSubVals(val);
}
}
- boolean doShading = ArgParser.getBoolean(m, Arg.TEMPFAC_SHADING);
+ boolean doShading = avm.getBoolean(Arg.TEMPFAC_SHADING);
if (doShading)
{
AlignFrame af = afMap.get(id);
protected void processImages(String id)
{
- Map<Arg, ArgValues> m = argParser.linkedArgs(id);
+ ArgValuesMap avm = new ArgValuesMap(argParser.linkedArgs(id));
AlignFrame af = afMap.get(id);
if (af == null)
return;
}
- if (ArgParser.getArgValueList(m, Arg.IMAGE) != null)
+ if (avm.hasValue(Arg.IMAGE))
{
- for (ArgValue av : ArgParser.getArgValueList(m, Arg.IMAGE))
+ for (ArgValue av : avm.getArgValueList(Arg.IMAGE))
{
String val = av.getValue();
SubVals subVal = new SubVals(val);