List of usage examples for org.apache.commons.cli ParseException toString
public String toString()
From source file:org.lsc.jmx.LscAgent.java
/** * Manage command line options.// ww w .j a v a 2 s .co m * * @param args command line * @return the status code (0: OK, >=1 : failed) */ protected int parseOptions(final String[] args) { Options options = new Options(); options.addOption("a", "start", true, "Start an asynchronous task"); options.addOption("h", "hostname", true, "Specify the hostname to connect to"); options.addOption("l", "list", false, "List the available asynchronous tasks"); options.addOption("o", "stop", true, "Stop an asynchronous task"); options.addOption("p", "port", true, "Specify the port to connect to"); options.addOption("i", "identifier", true, "Specify the identifier to synchronize"); options.addOption("t", "attributes", true, "Specify the attributes pivot to synchronize (comma separated, identifier parameter required)"); options.addOption("s", "status", true, "Get a task status"); CommandLineParser parser = new GnuParser(); try { CommandLine cmdLine = parser.parse(options, args); if (cmdLine.hasOption("a")) { operation = OperationType.START; taskName = cmdLine.getOptionValue("a"); } if (cmdLine.hasOption("l")) { operation = OperationType.TASKS_LIST; } if (cmdLine.hasOption("o")) { operation = OperationType.STOP; taskName = cmdLine.getOptionValue("o"); } if (cmdLine.hasOption("s")) { operation = OperationType.STATUS; taskName = cmdLine.getOptionValue("s"); } if (cmdLine.hasOption("i")) { idToSync = cmdLine.getOptionValue("i"); if (cmdLine.hasOption("t")) { StringTokenizer attrsStr = new StringTokenizer(cmdLine.getOptionValue("t"), ","); while (attrsStr.hasMoreTokens()) { String token = attrsStr.nextToken(); if (token.contains("=")) { attrsToSync.put(token.substring(0, token.indexOf("=")), token.substring(token.indexOf("=") + 1)); } else { LOGGER.error( "Unknown attribute name=value couple in \"{}\". Please check your parameters !", token); printHelp(options); return 1; } } } } else if (cmdLine.hasOption("t")) { LOGGER.error("Attributes specified, but missing identifier !"); printHelp(options); return 1; } if (cmdLine.hasOption("h")) { hostname = cmdLine.getOptionValue("h"); } else { hostname = "localhost"; LOGGER.info("Hostname parameter not specified, using {} as default value.", hostname); } if (cmdLine.hasOption("p")) { port = cmdLine.getOptionValue("p"); } else { port = "1099"; LOGGER.info("TCP Port parameter not specified, using {} as default value.", port); } if (operation == OperationType.UNKNOWN) { printHelp(options); return 1; } } catch (ParseException e) { LOGGER.error("Unable to parse the options ({})", e.toString()); LOGGER.debug(e.toString(), e); return 1; } return 0; }
From source file:org.lsc.opendj.LdapServer.java
private static void parseOptionsForConfiguration(String[] args) { try {/*from w w w . j a va 2 s . c o m*/ CommandLine cmdLine = getOptionsCmdLine(args); if (cmdLine.getOptions().length > 0 && !cmdLine.hasOption("h")) { if (cmdLine.hasOption("f")) { Configuration.setUp(new File(cmdLine.getOptionValue("f")).getAbsolutePath(), false); } } else { printHelp(options); } } catch (ParseException e) { if (LOGGER.isErrorEnabled()) { StringBuilder sbf = new StringBuilder(); for (String arg : args) { sbf.append(arg).append(" "); } LOGGER.error("Unable to parse options : {}({})", sbf.toString(), e); } LOGGER.debug(e.toString(), e); } catch (LscException e) { LOGGER.warn("Error while loading configuration: " + e.toString()); } }
From source file:org.lsc.opendj.LdapServer.java
/** * Manage command line options/*from w ww. ja v a 2 s .c om*/ * @param args command line * @return the status code (0: OK, >=1 : failed) * @throws Exception */ private static int usage(String[] args) throws Exception { try { CommandLine cmdLine = getOptionsCmdLine(args); if (cmdLine.getOptions().length > 0 && !cmdLine.hasOption("h")) { if (cmdLine.hasOption("a")) { start(); } else if (cmdLine.hasOption("o")) { stop(); } } else { printHelp(options); return 1; } } catch (ParseException e) { if (LOGGER.isErrorEnabled()) { StringBuilder sbf = new StringBuilder(); for (String arg : args) { sbf.append(arg).append(" "); } LOGGER.error("Unable to parse options : {}({})", sbf.toString(), e); } LOGGER.debug(e.toString(), e); return 1; } return 0; }
From source file:org.lsc.utils.security.SymmetricEncryption.java
/** * This main allow user to generate random key file. * @param argv//from ww w .j a v a 2s . c o m */ public static void main(String argv[]) { try { Options options = new Options(); options.addOption("f", "cfg", true, "Specify configuration directory"); CommandLine cmdLine = new GnuParser().parse(options, argv); if (cmdLine.getOptions().length > 0 && cmdLine.hasOption("f")) { // if a configuration directory was set on command line, use it to set up Configuration Configuration.setUp(cmdLine.getOptionValue("f"), false); } else { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("lsc", options); System.exit(1); } } catch (ParseException e) { StringBuilder sbf = new StringBuilder(); for (String arg : argv) { sbf.append(arg).append(" "); } LOGGER.error("Unable to parse options : {}({})", sbf.toString(), e); System.exit(1); } catch (LscException e) { LOGGER.error("Something goes wrong while loading configuration: " + e.toString(), e); System.exit(2); } try { if (LscConfiguration.getSecurity() == null) { throw new RuntimeException("lsc>security node of the LSC configuration cannot be null !"); } else if (LscConfiguration.getSecurity().getEncryption() == null) { throw new RuntimeException( "lsc>security>encryption node of the LSC configuration cannot be null !"); } SymmetricEncryption se = new SymmetricEncryption(LscConfiguration.getSecurity().getEncryption()); if (se.generateDefaultRandomKeyFile()) { LOGGER.info( "Key generated: {}. Do not forget to check the lsc>security>encryption>keyfile node value in your configuration file !", se.keyPath); } } catch (GeneralSecurityException ex) { LOGGER.debug(ex.toString(), ex); } }
From source file:org.mmadsen.sim.transmissionlab.models.MultipleNeutralTraitModel.java
public static void main(String[] args) { // parse command line options to see if this is a batch run Options cliOptions = new Options(); cliOptions.addOption("b", false, "enable batch mode"); CommandLineParser parser = new PosixParser(); CommandLine cmd = null;/*from w w w. j a v a 2 s. com*/ try { cmd = parser.parse(cliOptions, args); } catch (ParseException ex) { System.out.println("ERROR: Command line exception: " + ex.toString()); System.exit(1); } SimInit init = new SimInit(); MultipleNeutralTraitModel model = new MultipleNeutralTraitModel(); model.preModelLoadSetup(); model.isBatchExecution = cmd.hasOption("b"); String paramFile = null; if (model.isBatchExecution) { if (!cmd.getArgList().isEmpty()) { System.out.println(cmd.getArgList().toString()); paramFile = (String) cmd.getArgList().get(0); System.out.println("debug: " + paramFile); } } System.out.println("INFO: batch mode setting: " + model.isBatchExecution); init.loadModel(model, paramFile, model.isBatchExecution); }
From source file:org.mmadsen.sim.transmissionlab.models.NeutralCTModel.java
public static void main(String[] args) { // parse command line options to see if this is a batch run Options cliOptions = new Options(); cliOptions.addOption("b", false, "enable batch mode"); CommandLineParser parser = new PosixParser(); CommandLine cmd = null;// w w w .j av a2s. co m try { cmd = parser.parse(cliOptions, args); } catch (ParseException ex) { System.out.println("ERROR: Command line exception: " + ex.toString()); System.exit(1); } SimInit init = new SimInit(); NeutralCTModel model = new NeutralCTModel(); model.preModelLoadSetup(); model.isBatchExecution = cmd.hasOption("b"); String paramFile = null; if (model.isBatchExecution) { if (!cmd.getArgList().isEmpty()) { System.out.println(cmd.getArgList().toString()); paramFile = (String) cmd.getArgList().get(0); System.out.println("debug: " + paramFile); } } System.out.println("INFO: batch mode setting: " + model.isBatchExecution); init.loadModel(model, paramFile, model.isBatchExecution); }
From source file:org.mule.util.SystemUtils.java
private static CommandLine parseCommandLine(String args[], String opts[][]) throws DefaultMuleException { Options options = new Options(); for (int i = 0; i < opts.length; i++) { options.addOption(opts[i][0], opts[i][1].equals("true") ? true : false, opts[i][2]); }/* w w w. j ava 2 s . c om*/ BasicParser parser = new BasicParser(); try { CommandLine line = parser.parse(options, args, true); if (line == null) { throw new DefaultMuleException("Unknown error parsing the Mule command line"); } return line; } catch (ParseException p) { throw new DefaultMuleException("Unable to parse the Mule command line because of: " + p.toString(), p); } }
From source file:org.openscience.jmol.app.Jmol.java
public static void main(String[] args) { Dialog.setupUIManager();//from w w w . ja v a 2 s . c o m Jmol jmol = null; String modelFilename = null; String scriptFilename = null; Options options = new Options(); options.addOption("b", "backgroundtransparent", false, GT._("transparent background")); options.addOption("h", "help", false, GT._("give this help page")); options.addOption("n", "nodisplay", false, GT._("no display (and also exit when done)")); options.addOption("c", "check", false, GT._("check script syntax only")); options.addOption("i", "silent", false, GT._("silent startup operation")); options.addOption("l", "list", false, GT._("list commands during script execution")); options.addOption("o", "noconsole", false, GT._("no console -- all output to sysout")); options.addOption("t", "threaded", false, GT._("independent commmand thread")); options.addOption("x", "exit", false, GT._("exit after script (implicit with -n)")); OptionBuilder.withLongOpt("script"); OptionBuilder.withDescription("script file to execute"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("s")); OptionBuilder.withLongOpt("menu"); OptionBuilder.withDescription("menu file to use"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("m")); OptionBuilder.withArgName(GT._("property=value")); OptionBuilder.hasArg(); OptionBuilder.withValueSeparator(); OptionBuilder.withDescription(GT._("supported options are given below")); options.addOption(OptionBuilder.create("D")); OptionBuilder.withLongOpt("geometry"); // OptionBuilder.withDescription(GT._("overall window width x height, e.g. {0}", "-g512x616")); OptionBuilder.withDescription(GT._("window width x height, e.g. {0}", "-g500x500")); OptionBuilder.withValueSeparator(); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("g")); OptionBuilder.withLongOpt("quality"); // OptionBuilder.withDescription(GT._("overall window width x height, e.g. {0}", "-g512x616")); OptionBuilder.withDescription(GT._( "JPG image quality (1-100; default 75) or PNG image compression (0-9; default 2, maximum compression 9)")); OptionBuilder.withValueSeparator(); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("q")); OptionBuilder.withLongOpt("write"); OptionBuilder .withDescription(GT._("{0} or {1}:filename", new Object[] { "CLIP", "GIF|JPG|JPG64|PNG|PPM" })); OptionBuilder.withValueSeparator(); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("w")); int startupWidth = 0, startupHeight = 0; CommandLine line = null; try { CommandLineParser parser = new PosixParser(); line = parser.parse(options, args); } catch (ParseException exception) { System.err.println("Unexpected exception: " + exception.toString()); } if (line.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Jmol", options); // now report on the -D options System.out.println(); System.out.println(GT._("For example:")); System.out.println(); System.out.println("Jmol -ions myscript.spt -w JPEG:myfile.jpg > output.txt"); System.out.println(); System.out.println(GT._("The -D options are as follows (defaults in parenthesis):")); System.out.println(); System.out.println(" cdk.debugging=[true|false] (false)"); System.out.println(" cdk.debug.stdout=[true|false] (false)"); System.out.println(" display.speed=[fps|ms] (ms)"); System.out.println(" JmolConsole=[true|false] (true)"); System.out.println(" jmol.logger.debug=[true|false] (false)"); System.out.println(" jmol.logger.error=[true|false] (true)"); System.out.println(" jmol.logger.fatal=[true|false] (true)"); System.out.println(" jmol.logger.info=[true|false] (true)"); System.out.println(" jmol.logger.logLevel=[true|false] (false)"); System.out.println(" jmol.logger.warn=[true|false] (true)"); System.out.println(" plugin.dir (unset)"); System.out.println(" user.language=[CA|CS|DE|EN|ES|FR|NL|PT|TR] (EN)"); System.exit(0); } args = line.getArgs(); if (args.length > 0) { modelFilename = args[0]; } // Process more command line arguments // these are also passed to viewer String commandOptions = ""; //silent startup if (line.hasOption("i")) { commandOptions += "-i"; isSilent = Boolean.TRUE; } // transparent background if (line.hasOption("b")) { commandOptions += "-b"; } // independent command thread if (line.hasOption("t")) { commandOptions += "-t"; } //list commands during script operation if (line.hasOption("l")) { commandOptions += "-l"; } //output to sysout if (line.hasOption("o")) { commandOptions += "-o"; haveConsole = Boolean.FALSE; } //no display (and exit) if (line.hasOption("n")) { // this ensures that noDisplay also exits commandOptions += "-n-x"; haveDisplay = Boolean.FALSE; } //check script only if (line.hasOption("c")) { commandOptions += "-c"; } //run script if (line.hasOption("s")) { commandOptions += "-s"; scriptFilename = line.getOptionValue("s"); } //menu file if (line.hasOption("m")) { menuFile = line.getOptionValue("m"); } //exit when script completes (or file is read) if (line.hasOption("x")) { commandOptions += "-x"; } String imageType_name = null; //write image to clipboard or image file if (line.hasOption("w")) { imageType_name = line.getOptionValue("w"); } Dimension size; try { String vers = System.getProperty("java.version"); if (vers.compareTo("1.1.2") < 0) { System.out.println("!!!WARNING: Swing components require a " + "1.1.2 or higher version VM!!!"); } size = historyFile.getWindowSize(JMOL_WINDOW_NAME); if (size != null && haveDisplay.booleanValue()) { startupWidth = size.width; startupHeight = size.height; } //OUTER window dimensions /* if (line.hasOption("g") && haveDisplay.booleanValue()) { String geometry = line.getOptionValue("g"); int indexX = geometry.indexOf('x'); if (indexX > 0) { startupWidth = parseInt(geometry.substring(0, indexX)); startupHeight = parseInt(geometry.substring(indexX + 1)); } } */ Point b = historyFile.getWindowBorder(JMOL_WINDOW_NAME); //first one is just approximate, but this is set in doClose() //so it will reset properly -- still, not perfect //since it is always one step behind. if (b == null) border = new Point(12, 116); else border = new Point(b.x, b.y); //note -- the first time this is run after changes it will not work //because there is a bootstrap problem. int width = -1; int height = -1; int quality = 75; //INNER frame dimensions if (line.hasOption("g")) { String geometry = line.getOptionValue("g"); int indexX = geometry.indexOf('x'); if (indexX > 0) { width = Parser.parseInt(geometry.substring(0, indexX)); height = Parser.parseInt(geometry.substring(indexX + 1)); //System.out.println("setting geometry to " + geometry + " " + border + " " + startupWidth + startupHeight); } if (haveDisplay.booleanValue()) { startupWidth = width + border.x; startupHeight = height + border.y; } } if (line.hasOption("q")) quality = Parser.parseInt(line.getOptionValue("q")); if (imageType_name != null) commandOptions += "-w\1" + imageType_name + "\t" + width + "\t" + height + "\t" + quality + "\1"; if (startupWidth <= 0 || startupHeight <= 0) { startupWidth = 500 + border.x; startupHeight = 500 + border.y; } JFrame jmolFrame = new JFrame(); Point jmolPosition = historyFile.getWindowPosition(JMOL_WINDOW_NAME); if (jmolPosition != null) { jmolFrame.setLocation(jmolPosition); } //now pass these to viewer jmol = getJmol(jmolFrame, startupWidth, startupHeight, commandOptions); // Open a file if one is given as an argument -- note, this CAN be a script file if (modelFilename != null) { jmol.viewer.openFile(modelFilename); jmol.viewer.getOpenFileError(); } // OK, by now it is time to execute the script if (scriptFilename != null) { report("Executing script: " + scriptFilename); if (haveDisplay.booleanValue()) jmol.splash.showStatus(GT._("Executing script...")); jmol.viewer.evalFile(scriptFilename); } } catch (Throwable t) { System.out.println("uncaught exception: " + t); t.printStackTrace(); } if (haveConsole.booleanValue()) { Point location = jmol.frame.getLocation(); size = jmol.frame.getSize(); // Adding console frame to grab System.out & System.err consoleframe = new JFrame(GT._("Jmol Java Console")); consoleframe.setIconImage(jmol.frame.getIconImage()); try { final ConsoleTextArea consoleTextArea = new ConsoleTextArea(); consoleTextArea.setFont(java.awt.Font.decode("monospaced")); consoleframe.getContentPane().add(new JScrollPane(consoleTextArea), java.awt.BorderLayout.CENTER); if (Boolean.getBoolean("clearConsoleButton")) { JButton buttonClear = new JButton(GT._("Clear")); buttonClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { consoleTextArea.setText(""); } }); consoleframe.getContentPane().add(buttonClear, java.awt.BorderLayout.SOUTH); } } catch (IOException e) { JTextArea errorTextArea = new JTextArea(); errorTextArea.setFont(java.awt.Font.decode("monospaced")); consoleframe.getContentPane().add(new JScrollPane(errorTextArea), java.awt.BorderLayout.CENTER); errorTextArea.append(GT._("Could not create ConsoleTextArea: ") + e); } Dimension consoleSize = historyFile.getWindowSize(CONSOLE_WINDOW_NAME); Point consolePosition = historyFile.getWindowPosition(CONSOLE_WINDOW_NAME); if ((consoleSize != null) && (consolePosition != null)) { consoleframe.setBounds(consolePosition.x, consolePosition.y, consoleSize.width, consoleSize.height); } else { consoleframe.setBounds(location.x, location.y + size.height, size.width, 200); } Boolean consoleVisible = historyFile.getWindowVisibility(CONSOLE_WINDOW_NAME); if ((consoleVisible != null) && (consoleVisible.equals(Boolean.TRUE))) { consoleframe.show(); } } }
From source file:org.openscience.jmol.app.JmolApp.java
public void parseCommandLine(String[] args) { Options options = getOptions();/*from w ww.j a v a2 s .co m*/ CommandLine line = null; try { CommandLineParser parser = new PosixParser(); line = parser.parse(options, args); } catch (ParseException exception) { System.err.println("Unexpected exception: " + exception.toString()); } args = line.getArgs(); if (args.length > 0) { modelFilename = args[0]; } checkOptions(line, options); }
From source file:org.openscience.jvxl.Jvxl.java
public static void main(String[] args) { boolean blockData = false; int fileIndex = Integer.MAX_VALUE; String inputFile = null;//from w ww .jav a2s. co m String mapFile = null; String outputFile = null; float cutoff = Float.NaN; boolean isPositiveOnly = false; P4 plane = null; boolean bicolor = false; boolean reverseColor = false; float min = Float.NaN; float max = Float.NaN; Options options = new Options(); options.addOption("h", "help", false, "give this help page"); /* * examples: * * jvxl ch3cl-density.cub --min=0.0 --max=0.2 --map ch3cl-esp.cub * jvxl ethene-HOMO.cub --bicolor --output ethene.jvxl * jvxl d_orbitals.jvxl --index 2 --phase yz * jvxl d_orbitals.jvxl --map sets * jvxl --plane xy --min=0.0 --max=0.2 --map data/ch3cl-density.cub */ // file options options.addOption("B", "blockdata", false, "multiple cube data are in blocks, not interspersed"); options.addOption("P", "progressive", false, "create JVXL+ progressive X low-to-high format"); OptionBuilder.withLongOpt("file"); OptionBuilder.withDescription("file containing surface data"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("f")); OptionBuilder.withLongOpt("index"); OptionBuilder.withDescription("index of surface in file (starting with 1)"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("i")); OptionBuilder.withLongOpt("plane"); OptionBuilder.withDescription("plane: x, y, z, xy, xz, yz, z2, x2-y2, or {a,b,c,d}"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("p")); OptionBuilder.withLongOpt("map"); OptionBuilder.withDescription("file containing data to map onto the surface or \"sets\""); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("m")); OptionBuilder.withLongOpt("output"); OptionBuilder.withDescription("JVXL output file"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("o")); // surface options OptionBuilder.withLongOpt("cutoff"); OptionBuilder.withDescription("isosurface cutoff value"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("c")); // color mapping options options.addOption("b", "bicolor", false, "bicolor map (orbital)"); options.addOption("r", "reversecolor", false, "reverse color"); OptionBuilder.withLongOpt("colorScheme"); OptionBuilder.withDescription("VRML color scheme: bw, wb, roygb, bgyor, rwb, bwr, low, high"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("s")); OptionBuilder.withLongOpt("phase"); OptionBuilder.withDescription("color by phase: x, y, z, xy, xz, yz, z2, x2-y2"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("F")); OptionBuilder.withLongOpt("min"); OptionBuilder.withDescription("color absolute minimum value"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("n")); OptionBuilder.withLongOpt("max"); OptionBuilder.withDescription("color absolute maximum value"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("x")); CommandLine line = null; try { CommandLineParser parser = new PosixParser(); line = parser.parse(options, args); } catch (ParseException exception) { Logger.error("Unexpected exception: " + exception.toString()); } if (line.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Jvxl", options); return; } args = line.getArgs(); if (args.length > 0) { inputFile = args[0]; } // files blockData = (line.hasOption("B")); if (line.hasOption("i")) { fileIndex = PT.parseInt(line.getOptionValue("i")); } if (line.hasOption("f")) { inputFile = line.getOptionValue("f"); } if (line.hasOption("m")) { mapFile = line.getOptionValue("m"); } if (line.hasOption("p")) { plane = getPlane(line.getOptionValue("p")); if (plane == null) { Logger.error("invalid plane"); return; } Logger.info("using plane " + plane); if (mapFile == null) mapFile = inputFile; if (inputFile == null) inputFile = mapFile; } if (line.hasOption("o")) { outputFile = line.getOptionValue("o"); } else { outputFile = inputFile; if (outputFile.indexOf(".") < 0) outputFile += "."; String sIndex = (fileIndex == Integer.MAX_VALUE ? "" : "_" + fileIndex); if (sIndex.length() == 0 && outputFile.indexOf(".jvxl") >= 0) sIndex += "_new"; outputFile = outputFile.substring(0, outputFile.lastIndexOf(".")) + sIndex + ".jvxl"; } // Process more command line arguments // these are also passed to vwr bicolor = (line.hasOption("b")); reverseColor = (line.hasOption("r")); if (bicolor && mapFile != null) { Logger.warn("--map option ignored; incompatible with --bicolor"); mapFile = null; } if (line.hasOption("c")) { String s = line.getOptionValue("c"); if (s.indexOf("+") == 0) { isPositiveOnly = true; s = s.substring(1); } cutoff = PT.parseFloat(s); } if (line.hasOption("n")) { if (bicolor) Logger.warn("--min option ignored; incompatible with --bicolor"); else min = PT.parseFloat(line.getOptionValue("n")); } if (line.hasOption("x")) { if (bicolor) Logger.warn("--max option ignored; incompatible with --bicolor"); else max = PT.parseFloat(line.getOptionValue("x")); } // if (line.hasOption("P")) { // phase = line.getOptionValue("P"); // } boolean progressive = line.hasOption("P"); // compose the surface SurfaceGenerator sg = new SurfaceGenerator(null, null, null, null); // input file sg.version = VERSION; if (blockData) sg.setProp("blockData", Boolean.TRUE, null); if (!Float.isNaN(cutoff)) sg.setProp(isPositiveOnly ? "cutoffPositive" : "cutoff", Float.valueOf(cutoff), null); if (bicolor) sg.setProp("sign", null, null); if (reverseColor) sg.setProp("reverseColor", null, null); //if (phase != null) //sg.setProp("phase", phase); if (progressive) sg.setProp("progressive", null, null); if (plane != null) sg.setProp("plane", plane, null); else { if (fileIndex != Integer.MAX_VALUE) sg.setProp("fileIndex", Integer.valueOf(fileIndex), null); Object t = FileReader.getBufferedReaderOrErrorMessageFromName(inputFile); if (t instanceof String) { Logger.error((String) t); return; } BufferedReader br = (BufferedReader) t; sg.setProp("readFile", br, null); try { br.close(); } catch (Exception e) { // } } sg.setProp("title", line.toString(), null); //color scheme is only for VMRL //if (colorScheme != null) { // ColorEncoder ce = new ColorEncoder(null); // ce.setColorScheme(colorScheme, false); // sg.setProp("colorScheme", ce); // } if (!Float.isNaN(min)) sg.setProp("red", Float.valueOf(min), null); if (!Float.isNaN(max)) sg.setProp("blue", Float.valueOf(max), null); if (mapFile != null) { Object t = FileReader.getBufferedReaderOrErrorMessageFromName(mapFile); if (t instanceof String) { Logger.error((String) t); return; } BufferedReader br2 = (BufferedReader) t; sg.setProp("mapColor", br2, null); try { br2.close(); } catch (Exception e) { // } } writeFile(outputFile, (String) sg.getProperty("jvxlFileData", 0)); Logger.info((String) sg.getProperty("jvxlFileInfo", 0)); Logger.info("\ncreated " + outputFile); }