List of usage examples for org.apache.commons.cli OptionBuilder create
public static Option create(String opt) throws IllegalArgumentException
char
. From source file:org.openmainframe.ade.ext.main.helper.AdeExtOptions.java
public static Options buildOptions(Options subClassOptions) { /* Add the options from subClass */ Options options = new Options(); for (Object subClassOption : subClassOptions.getOptions()) { Option option = (Option) subClassOption; options.addOption(option);// ww w . j a va2s . co m } /* Add the general options */ OptionBuilder.withArgName(OPTION_HELP); OptionBuilder.withLongOpt(OPTION_HELP); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Print help message and exit"); options.addOption(OptionBuilder.create('h')); OptionBuilder.withArgName(OPTION_INPUT_FILE); OptionBuilder.withLongOpt(OPTION_INPUT_FILE); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Input file name or 'stdin'"); options.addOption(OptionBuilder.create('f')); OptionBuilder.withArgName(OPTION_INPUT_DIR); OptionBuilder.withLongOpt(OPTION_INPUT_DIR); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Input dir name"); options.addOption(OptionBuilder.create('d')); OptionBuilder.withArgName(OPTION_SOURCES); OptionBuilder.withLongOpt(OPTION_SOURCES); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Source Names."); options.addOption(OptionBuilder.create('s')); OptionBuilder.withArgName(OPTION_OS_TYPE); OptionBuilder.withLongOpt(OPTION_OS_TYPE); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("The OS Type." + "If this option is omitted, the default is Linux"); options.addOption(OptionBuilder.create('o')); OptionBuilder.withArgName(OPTION_GMT_OFFSET); OptionBuilder.withLongOpt(OPTION_GMT_OFFSET); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("hours offset from GMT"); options.addOption(OptionBuilder.create('g')); return options; }
From source file:org.openmainframe.ade.ext.main.helper.LinuxOptions.java
@Override public void addPlatformSpecificOptions(Options options) { OptionBuilder.withArgName(OPTION_YEAR); OptionBuilder.hasArg();/*from ww w .ja va 2 s . c o m*/ OptionBuilder.withDescription("year of messages in Linux syslogs"); options.addOption(OptionBuilder.create(OPTION_YEAR)); }
From source file:org.openmainframe.ade.ext.main.UpdateGroups.java
/** * Method for building the allowed options. * @param options Options object for adding the options created with OptionBuilder. *//* w ww. j a v a 2 s.co m*/ private void buildOptions(Options options) { OptionBuilder.withArgName(OPTION_HELP); OptionBuilder.withLongOpt(OPTION_HELP); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Print help message and exit."); options.addOption(OptionBuilder.create('h')); OptionBuilder.withArgName(OPTION_INPUT_JSON); OptionBuilder.withLongOpt(OPTION_INPUT_JSON); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); OptionBuilder.withDescription("Specify the JSON input file."); options.addOption(OptionBuilder.create("j")); }
From source file:org.openmainframe.ade.ext.main.Upload.java
/** * Method to parse specific arguments for "Upload". * /*from ww w .j av a 2 s . c om*/ * @throws AdeException * */ protected final void parseArgs(String[] args) throws AdeException { final Options options = new Options(); OptionBuilder.withArgName(OPTION_DUMP_PARSE_REPORT); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Specify this option to generate parse report"); options.addOption(OptionBuilder.create(OPTION_DUMP_PARSE_REPORT)); final CommandLine line = super.parseArgs(options, args); if (line.hasOption(OPTION_DUMP_PARSE_REPORT)) { getAdeExtProperties().setParseReportRequested(true); } }
From source file:org.openmainframe.ade.main.ControlDB.java
@Override protected void parseArgs(String[] args) throws AdeException { final Option helpOpt = new Option("h", "help", false, "Print help message and exit"); final Option forceOpt = new Option("f", "force", false, "Force operation. Do not prompt for confirmation"); OptionBuilder.withLongOpt("create"); OptionBuilder.hasArg(false);/*from ww w.j av a 2s. c om*/ OptionBuilder.isRequired(false); OptionBuilder.withDescription("Create Ade DB tables"); final Option createOpt = OptionBuilder.create('c'); OptionBuilder.withLongOpt("drop"); OptionBuilder.hasArg(false); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Drops all Ade DB tables, and clears the data store dictionaries"); final Option deleteOpt = OptionBuilder.create('d'); OptionBuilder.withLongOpt("reset"); OptionBuilder.hasArg(false); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Clears all Ade DB tables content"); final Option resetOpt = OptionBuilder.create('r'); OptionBuilder.withLongOpt("query"); OptionBuilder.hasArg(); OptionBuilder.withArgName("SQL query string"); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Performs the input query"); final Option queryOpt = OptionBuilder.create('q'); final OptionGroup actionGroupOpt = new OptionGroup().addOption(createOpt).addOption(deleteOpt) .addOption(resetOpt).addOption(queryOpt); actionGroupOpt.setRequired(true); final Options options = new Options(); options.addOption(helpOpt); options.addOption(forceOpt); options.addOptionGroup(actionGroupOpt); final CommandLineParser parser = new GnuParser(); CommandLine line = null; try { // parse the command line arguments line = parser.parse(options, args); } catch (MissingOptionException exp) { logger.error("Command line parsing failed.", exp); new HelpFormatter().printHelp(ControlDB.class.getName(), options); System.exit(0); } catch (ParseException exp) { // oops, something went wrong logger.error("Parsing failed. Reason: " + exp.getMessage()); throw new AdeUsageException("Argument Parsing failed", exp); } if (line.hasOption('h')) { new HelpFormatter().printHelp(getClass().getSimpleName(), options); closeAll(); System.exit(0); } if (line.hasOption('f')) { m_forceOp = true; } if (line.hasOption('c')) { m_op = ControlDBOperator.Create; } else if (line.hasOption('d')) { m_op = ControlDBOperator.Drop; } else if (line.hasOption('r')) { m_op = ControlDBOperator.Reset; } else if (line.hasOption('q')) { m_op = ControlDBOperator.Query; m_args = new String[] { line.getOptionValue('q') }; } }
From source file:org.openmainframe.ade.main.Train.java
@Override protected void parseArgs(String[] args) throws AdeException { final Option helpOpt = new Option("h", "help", false, "Print help message and exit"); OptionBuilder.withLongOpt(ALL_OPT);//from ww w .ja v a 2 s .c o m OptionBuilder.isRequired(false); OptionBuilder.withDescription("All analysis groups"); final Option allAnalysisGroupsOpt = OptionBuilder.create('a'); OptionBuilder.withLongOpt(GROUPS_OPT); OptionBuilder.withArgName("ANALYSIs GROUPS"); OptionBuilder.hasArgs(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Selected analysis groups"); final Option selectAnalysisGroupsOpt = OptionBuilder.create('s'); final OptionGroup inputAnalysisGroupsOptGroup = new OptionGroup().addOption(allAnalysisGroupsOpt) .addOption(selectAnalysisGroupsOpt); inputAnalysisGroupsOptGroup.setRequired(true); OptionBuilder.withLongOpt(UNSELECT_OPT); OptionBuilder.withArgName("ANALYSIS GROUPS"); OptionBuilder.hasArgs(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Unselect analysis groups. Used only with '" + ALL_OPT + "'"); final Option unselectAnalysisGroupsOpt = OptionBuilder.create('u'); OptionBuilder.withLongOpt(DURATION_OPT); OptionBuilder.withArgName("DURATION (ISO 8601)"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); OptionBuilder.withDescription( "Duration from/to start/end date. Defaults to infinity. Replaces either 'start-date' or 'end-date'"); final Option periodOpt = OptionBuilder.create(); OptionBuilder.withLongOpt(NUM_DAYS_OPT); OptionBuilder.withArgName("INT"); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Number of days. same as '" + DURATION_OPT + "'"); final Option numDaysOpt = OptionBuilder.create('n'); final OptionGroup periodOptGroup = new OptionGroup().addOption(periodOpt).addOption(numDaysOpt); OptionBuilder.withLongOpt(START_DATE_OPT); OptionBuilder.withArgName("MM/dd/yyyy[ HH:mm][ Z]"); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder.withDescription( "Start of date range. Optional. Replaces 'duration'/'num-days' when used along with 'end-date'"); final Option startDateOpt = OptionBuilder.create(); OptionBuilder.withLongOpt(END_DATE_OPT); OptionBuilder.withArgName("MM/dd/yyyy[ HH:mm][ Z]"); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder .withDescription("End of date range. Defaults to this moment. Replaces 'duration'/'num-days' when" + " used along with 'start-date'"); final Option endDateOpt = OptionBuilder.create(); final Options options = new Options(); options.addOption(helpOpt); options.addOptionGroup(inputAnalysisGroupsOptGroup); options.addOption(unselectAnalysisGroupsOpt); options.addOptionGroup(periodOptGroup); options.addOption(endDateOpt); options.addOption(startDateOpt); final CommandLineParser parser = new GnuParser(); CommandLine line; try { // parse the command line arguments line = parser.parse(options, args); } catch (MissingOptionException exp) { new HelpFormatter().printHelp(HELP + "\nOptions:", options); throw new AdeUsageException("Command line parsing failed", exp); } catch (ParseException exp) { // oops, something went wrong throw new AdeUsageException("Argument Parsing failed", exp); } if (line.hasOption(helpOpt.getLongOpt())) { new HelpFormatter().printHelp(HELP, options); closeAll(); System.exit(0); } if (line.hasOption(UNSELECT_OPT) && !line.hasOption(ALL_OPT)) { throw new AdeUsageException("'" + UNSELECT_OPT + "' cannot be used without '" + ALL_OPT + "'"); } final Set<Integer> allAnalysisGroups = Ade.getAde().getDataStore().sources().getAllAnalysisGroups(); if (line.hasOption(ALL_OPT)) { System.out.println("Operating on all available analysis groups"); if (!line.hasOption(UNSELECT_OPT)) { m_analysisGroups = allAnalysisGroups; } else { final Set<Integer> unselectedAnalysisGroups = parseAnalysisGroups(allAnalysisGroups, line.getOptionValues(UNSELECT_OPT)); final Set<String> unselectedGroupNames = getGroupNames(unselectedAnalysisGroups); System.out.println("Omitting analysis groups: " + unselectedGroupNames.toString()); m_analysisGroups = new TreeSet<Integer>(allAnalysisGroups); m_analysisGroups.removeAll(unselectedAnalysisGroups); } } else if (line.hasOption(GROUPS_OPT)) { m_analysisGroups = parseAnalysisGroups(allAnalysisGroups, line.getOptionValues(GROUPS_OPT)); final Set<String> operatingAnalysisGroups = getGroupNames(m_analysisGroups); System.out.println("Operating on analysis groups: " + operatingAnalysisGroups.toString()); } if ((line.hasOption(NUM_DAYS_OPT) || line.hasOption(DURATION_OPT)) && line.hasOption(START_DATE_OPT) && line.hasOption(END_DATE_OPT)) { throw new AdeUsageException("Cannot use '" + DURATION_OPT + "'/'" + NUM_DAYS_OPT + "', '" + START_DATE_OPT + "' and '" + END_DATE_OPT + "' together"); } if (line.hasOption(NUM_DAYS_OPT)) { final String numDaysStr = line.getOptionValue(NUM_DAYS_OPT); final int numDays = Integer.parseInt(numDaysStr); this.m_period = Period.days(numDays); } if (line.hasOption(DURATION_OPT)) { final String periodStr = line.getOptionValue(DURATION_OPT); this.m_period = ISOPeriodFormat.standard().parsePeriod(periodStr); } if (line.hasOption(START_DATE_OPT)) { m_startDate = parseDate(line.getOptionValue(START_DATE_OPT)); } if (line.hasOption(END_DATE_OPT)) { m_endDate = parseDate(line.getOptionValue(END_DATE_OPT)); } }
From source file:org.openscience.jmol.app.Jmol.java
public static void main(String[] args) { Dialog.setupUIManager();//from w w w . j a v a 2s. co 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.jvxl.Jvxl.java
public static void main(String[] args) { boolean blockData = false; int fileIndex = Integer.MAX_VALUE; String inputFile = null;//from www . ja v a 2 s . c o 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); }
From source file:org.parallelj.launching.transport.tcp.command.option.AsyncLaunchArgsOption.java
public AsyncLaunchArgsOption() { this.option = OptionBuilder.create("a"); this.option.setLongOpt("args"); this.option.setArgs(100); this.option.setArgName("arg1=value1 arg2=value2 ... argx=valueX"); this.option.setDescription("Arguments of the Program"); this.option.setRequired(false); }
From source file:org.parallelj.launching.transport.tcp.command.option.AsyncLaunchIdOption.java
public AsyncLaunchIdOption() { this.option = OptionBuilder.create("i"); this.option.setLongOpt("id"); this.option.setArgs(1); this.option.setArgName("id"); this.option.setDescription("Id of the Program from the list return by ll command"); this.option.setRequired(true); }