*/
package jalview.bin;
+import java.awt.GraphicsEnvironment;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.ws.jws2.Jws2Discoverer;
-//import netscape.javascript.JSObject;
/**
* Main class for Jalview Application <br>
// }
public static Jalview getInstance()
{
- System.out.println("Hello, MW!!!!!!!!!!!!");
return (Jalview) ApplicationSingletonProvider
.getInstance(Jalview.class);
}
showUsage();
System.exit(0);
}
- // ?>>
+ // BH note: Only -nodisplay is official; others are deprecated?
if (aparser.contains("nodisplay") || aparser.contains("nogui")
- || aparser.contains("headless"))
+ || aparser.contains("headless")
+ || GraphicsEnvironment.isHeadless())
{
- // BH Is this necessary? Seems like a hack; was removed for applet branch
- System.setProperty("java.awt.headless", "true");
+ if (!isJS) {
+ // BH Definitely not a good idea in JavaScript;
+ // probably should not be here for Java, either.
+ System.setProperty("java.awt.headless", "true");
+ }
headless = true;
}
- if ("true".equals(System.getProperty("java.awt.headless")))
+ if (GraphicsEnvironment.isHeadless())
{
headless = true;
}
* @param aparser
* @param format
*/
- private void createOutputFiles(ArgsParser aparser,
- FileFormatI format)
+ private void createOutputFiles(ArgsParser aparser, FileFormatI format)
{
AlignFrame af = currentAlignFrame;
while (aparser.getSize() >= 2)
"Creating image map: " + imageFile.getAbsolutePath());
continue;
default:
- format = FileFormats.getInstance().forName(outputFormat);
- if (format == null)
+ // fall through - try to parse as an alignment data export format
+ FileFormatI outFormat = null;
+ try
+ {
+ outFormat = FileFormats.getInstance().forName(outputFormat);
+ } catch (Exception formatP)
{
- System.out.println("Invalid file format: " + outputFormat);
- break;
}
- fname = new File(aparser.nextValue()).getAbsolutePath();
- af.saveAlignment(fname, format);
+ if (outFormat == null)
+ {
+ System.out.println("Couldn't parse " + outputFormat
+ + " as a valid Jalview format string.");
+ continue;
+ }
+ if (!outFormat.isWritable())
+ {
+ System.out.println(
+ "This version of Jalview does not support alignment export as "
+ + outputFormat);
+ continue;
+ }
+ // record file as it was passed to Jalview so it is recognisable to the CLI
+ // caller
+ String file;
+ fname = new File(file = aparser.nextValue()).getAbsolutePath();
+ // JBPNote - yuck - really wish we did have a bean returned from this which gave
+ // success/fail like before !
+ af.saveAlignment(fname, outFormat);
if (!af.isSaveAlignmentSuccessful())
{
- System.out.println("Error writing file " + fname + " in " + format
- + " format!!");
- break;
+ System.out.println("Written alignment in " + outputFormat
+ + " format to " + file);
+ continue;
+ }
+ else
+ {
+ System.out.println("Error writing file " + file + " in "
+ + outputFormat + " format!!");
}
- continue;
}
- System.out.println("Unknown arg: " + outputFormat);
- break;
}
+ // ??? Should report - 'ignoring' extra args here...
while (aparser.getSize() > 0)
{
- System.out.println("Unknown arg: " + aparser.nextValue());
+ System.out.println("Ignoring extra argument: " + aparser.nextValue());
}
}