com.github.javacliparser.Option Java Examples
The following examples show how to use
com.github.javacliparser.Option.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WEKAClassOptionEditComponent.java From moa with GNU General Public License v3.0 | 6 votes |
public WEKAClassOptionEditComponent(Option opt) { WEKAClassOption option = (WEKAClassOption) opt; this.editedOption = option; this.textField.setEditable(false); setLayout(new BorderLayout()); add(this.textField, BorderLayout.CENTER); add(this.editButton, BorderLayout.EAST); this.editButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editObject(); } }); setEditState(this.editedOption.getValueAsCLIString()); }
Example #2
Source File: ClassOptionWithListenerOptionEditComponent.java From moa with GNU General Public License v3.0 | 6 votes |
public ClassOptionWithListenerOptionEditComponent(Option opt) { super(opt); this.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (!ClassOptionWithListenerOptionEditComponent.this.textField .getText().isEmpty()) { // apply state to set the selected value in the ClassOption // so that it can be picked up by dependent options ClassOptionWithListenerOptionEditComponent.this.applyState(); } } }); }
Example #3
Source File: EnsembleDriftDetectionMethods.java From moa with GNU General Public License v3.0 | 6 votes |
@Override protected void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository) { // TODO Auto-generated method stub Option[] changeDetectorOptions = this.changeDetectorsOption.getList(); cds = new ChangeDetector[changeDetectorOptions.length]; preds = new Boolean[changeDetectorOptions.length]; for (int i = 0; i < cds.length; i++) { //monitor.setCurrentActivity("Materializing change detector " + (i + 1) // + "...", -1.0); cds[i] = ((ChangeDetector) ((ClassOption) changeDetectorOptions[i]).materializeObject(monitor, repository)).copy(); if (monitor.taskShouldAbort()) { return; } if (cds[i] instanceof OptionHandler) { monitor.setCurrentActivity("Preparing change detector " + (i + 1) + "...", -1.0); ((OptionHandler) cds[i]).prepareForUse(monitor, repository); if (monitor.taskShouldAbort()) { return; } } preds[i] = false; } }
Example #4
Source File: WeightedMajorityAlgorithm.java From moa with GNU General Public License v3.0 | 6 votes |
@Override public void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository) { Option[] learnerOptions = this.learnerListOption.getList(); this.ensemble = new Classifier[learnerOptions.length]; for (int i = 0; i < learnerOptions.length; i++) { monitor.setCurrentActivity("Materializing learner " + (i + 1) + "...", -1.0); this.ensemble[i] = (Classifier) ((ClassOption) learnerOptions[i]).materializeObject(monitor, repository); if (monitor.taskShouldAbort()) { return; } monitor.setCurrentActivity("Preparing learner " + (i + 1) + "...", -1.0); this.ensemble[i].prepareForUse(monitor, repository); if (monitor.taskShouldAbort()) { return; } } super.prepareForUseImpl(monitor, repository); }
Example #5
Source File: HeterogeneousEnsembleAbstract.java From moa with GNU General Public License v3.0 | 6 votes |
@Override public void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository) { Option[] learnerOptions = this.baselearnersOption.getList(); this.ensemble = new Classifier[learnerOptions.length]; for (int i = 0; i < learnerOptions.length; i++) { monitor.setCurrentActivity("Materializing learner " + (i + 1) + "...", -1.0); this.ensemble[i] = (Classifier) ((ClassOption) learnerOptions[i]) .materializeObject(monitor, repository); if (monitor.taskShouldAbort()) { return; } monitor.setCurrentActivity("Preparing learner " + (i + 1) + "...", -1.0); this.ensemble[i].prepareForUse(monitor, repository); if (monitor.taskShouldAbort()) { return; } } super.prepareForUseImpl(monitor, repository); topK = topK(historyTotal, activeClassifiersOption.getValue()); }
Example #6
Source File: OptionsHandler.java From incubator-samoa with Apache License 2.0 | 5 votes |
/** * Prepares the options of this class. * * @param monitor * the TaskMonitor to use * @param repository * the ObjectRepository to use */ public void prepareClassOptions(TaskMonitor monitor, ObjectRepository repository) { this.classOptionNamesToPreparedObjects = null; Option[] optionArray = getOptions().getOptionArray(); for (Option option : optionArray) { if (option instanceof ClassOption) { ClassOption classOption = (ClassOption) option; monitor.setCurrentActivity("Materializing option " + classOption.getName() + "...", -1.0); Object optionObj = classOption.materializeObject(monitor, repository); if (monitor.taskShouldAbort()) { return; } if (optionObj instanceof OptionHandler) { monitor.setCurrentActivity("Preparing option " + classOption.getName() + "...", -1.0); ((OptionHandler) optionObj).prepareForUse(monitor, repository); if (monitor.taskShouldAbort()) { return; } } if (this.classOptionNamesToPreparedObjects == null) { this.classOptionNamesToPreparedObjects = new HashMap<String, Object>(); } this.classOptionNamesToPreparedObjects.put(option.getName(), optionObj); } } }
Example #7
Source File: OptionsHandler.java From samoa with Apache License 2.0 | 5 votes |
/** * Prepares the options of this class. * * @param monitor the TaskMonitor to use * @param repository the ObjectRepository to use */ public void prepareClassOptions(TaskMonitor monitor, ObjectRepository repository) { this.classOptionNamesToPreparedObjects = null; Option[] optionArray = getOptions().getOptionArray(); for (Option option : optionArray) { if (option instanceof ClassOption) { ClassOption classOption = (ClassOption) option; monitor.setCurrentActivity("Materializing option " + classOption.getName() + "...", -1.0); Object optionObj = classOption.materializeObject(monitor, repository); if (monitor.taskShouldAbort()) { return; } if (optionObj instanceof OptionHandler) { monitor.setCurrentActivity("Preparing option " + classOption.getName() + "...", -1.0); ((OptionHandler) optionObj).prepareForUse(monitor, repository); if (monitor.taskShouldAbort()) { return; } } if (this.classOptionNamesToPreparedObjects == null) { this.classOptionNamesToPreparedObjects = new HashMap<String, Object>(); } this.classOptionNamesToPreparedObjects.put(option.getName(), optionObj); } } }
Example #8
Source File: LocalDoTask.java From samoa with Apache License 2.0 | 5 votes |
/** * The main method. * * @param args * the arguments */ public static void main(String[] args) { // ArrayList<String> tmpArgs = new ArrayList<String>(Arrays.asList(args)); // args = tmpArgs.toArray(new String[0]); FlagOption suppressStatusOutOpt = new FlagOption("suppressStatusOut", 'S', SUPPRESS_STATUS_OUT_MSG); FlagOption suppressResultOutOpt = new FlagOption("suppressResultOut", 'R', SUPPRESS_RESULT_OUT_MSG); IntOption statusUpdateFreqOpt = new IntOption("statusUpdateFrequency", 'F', STATUS_UPDATE_FREQ_MSG, 1000, 0, Integer.MAX_VALUE); Option[] extraOptions = new Option[] { suppressStatusOutOpt, suppressResultOutOpt, statusUpdateFreqOpt }; StringBuilder cliString = new StringBuilder(); for (String arg : args) { cliString.append(" ").append(arg); } logger.debug("Command line string = {}", cliString.toString()); System.out.println("Command line string = " + cliString.toString()); Task task; try { task = ClassOption.cliStringToObject(cliString.toString(), Task.class, extraOptions); logger.info("Successfully instantiating {}", task.getClass().getCanonicalName()); } catch (Exception e) { logger.error("Fail to initialize the task", e); System.out.println("Fail to initialize the task" + e); return; } task.setFactory(new SimpleComponentFactory()); task.init(); SimpleEngine.submitTopology(task.getTopology()); }
Example #9
Source File: EditableMultiChoiceOptionEditComponent.java From moa with GNU General Public License v3.0 | 5 votes |
public EditableMultiChoiceOptionEditComponent(Option option) { super(option); // register the EditComponent with the corresponding // EditableMultiChoiceOption, so that updates can be received ((EditableMultiChoiceOption) option).registerEditComponent(this); }
Example #10
Source File: MultiFilteredStream.java From moa with GNU General Public License v3.0 | 5 votes |
@Override public void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository) { Option[] filterOptions = this.filtersOption.getList(); StreamFilter[] filters = new StreamFilter[filterOptions.length]; for (int i = 0; i < filters.length; i++) { monitor.setCurrentActivity("Materializing filter " + (i + 1) + "...", -1.0); filters[i] = (StreamFilter) ((ClassOption) filterOptions[i]).materializeObject(monitor, repository); if (monitor.taskShouldAbort()) { return; } if (filters[i] instanceof OptionHandler) { monitor.setCurrentActivity("Preparing filter " + (i + 1) + "...", -1.0); ((OptionHandler) filters[i]).prepareForUse(monitor, repository); if (monitor.taskShouldAbort()) { return; } } } ExampleStream chain = (ExampleStream) getPreparedClassOption(this.streamOption); for (int i = 0; i < filters.length; i++) { filters[i].setInputStream(chain); chain = filters[i]; } this.filterChain = chain; }
Example #11
Source File: DependentOptionsUpdater.java From moa with GNU General Public License v3.0 | 5 votes |
/** * Resolve the name of the varied parameter and return the corresponding option. * The varied parameter name has the format "learner/suboptions.../numberOption". * If no matching parameter can be found, <code>null</code> is returned. * * @param learner the learner object that has the varied option * @param variedParamName name of the (nested) varied parameter * @return varied option */ public static Option getVariedOption(OptionHandler learner, String variedParamName) { // split nested option string String[] singleOptions = variedParamName.split("/"); // check if first level is "learner", which has already been resolved int startIndex = 0; if (singleOptions.length > 0 && singleOptions[0].equals("learner/")) { startIndex = 1; } // iteratively create objects and get next options for each level Option learnerVariedParamOption = null; OptionHandler currentOptionHandler = learner; for (int i = startIndex; i < singleOptions.length; i++) { for (Option opt : currentOptionHandler.getOptions().getOptionArray()) { if (opt.getName().equals(singleOptions[i])) { if (opt instanceof ClassOption) { currentOptionHandler = (OptionHandler) ((ClassOption) opt).getPreMaterializedObject(); } else { learnerVariedParamOption = opt; } break; } } } return learnerVariedParamOption; }
Example #12
Source File: OptionsHandler.java From moa with GNU General Public License v3.0 | 5 votes |
/** * Prepares the options of this class. * * @param monitor the TaskMonitor to use * @param repository the ObjectRepository to use */ public void prepareClassOptions(TaskMonitor monitor, ObjectRepository repository) { this.classOptionNamesToPreparedObjects = null; Option[] optionArray = getOptions().getOptionArray(); for (Option option : optionArray) { if (option instanceof ClassOption) { ClassOption classOption = (ClassOption) option; monitor.setCurrentActivity("Materializing option " + classOption.getName() + "...", -1.0); Object optionObj = classOption.materializeObject(monitor, repository); if (monitor.taskShouldAbort()) { return; } if (optionObj instanceof OptionHandler) { monitor.setCurrentActivity("Preparing option " + classOption.getName() + "...", -1.0); ((OptionHandler) optionObj).prepareForUse(monitor, repository); if (monitor.taskShouldAbort()) { return; } } if (this.classOptionNamesToPreparedObjects == null) { this.classOptionNamesToPreparedObjects = new HashMap<String, Object>(); } this.classOptionNamesToPreparedObjects.put(option.getName(), optionObj); } } }
Example #13
Source File: OptionsConfigurationPanel.java From moa with GNU General Public License v3.0 | 5 votes |
protected static JPanel createLabelledOptionComponentListPanel( Option[] options, List<OptionEditComponent> editComponents) { JPanel panel = new JPanel(); if ((options != null) && (options.length > 0)) { GridBagLayout gbLayout = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); panel.setLayout(gbLayout); for (int i = 0; i < options.length; i++) { JLabel label = new JLabel(options[i].getName()); label.setToolTipText(options[i].getPurpose()); gbc.gridx = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.EAST; gbc.weightx = 0; gbc.insets = new Insets(5, 5, 5, 5); gbLayout.setConstraints(label, gbc); panel.add(label); JComponent editor = getEditComponent(options[i]); label.setLabelFor(editor); if (editComponents != null) { editComponents.add((OptionEditComponent) editor); } gbc.gridx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.weightx = 1; gbc.insets = new Insets(5, 5, 5, 5); gbLayout.setConstraints(editor, gbc); panel.add(editor); } } else { panel.add(new JLabel("No options.")); } return panel; }
Example #14
Source File: FileOptionEditComponent.java From moa with GNU General Public License v3.0 | 5 votes |
public FileOptionEditComponent(Option opt) { FileOption option = (FileOption) opt; this.editedOption = option; setLayout(new BorderLayout()); add(this.textField, BorderLayout.CENTER); add(this.browseButton, BorderLayout.EAST); this.browseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { browseForFile(); } }); setEditState(this.editedOption.getValueAsCLIString()); }
Example #15
Source File: LocalDoTask.java From incubator-samoa with Apache License 2.0 | 5 votes |
/** * The main method. * * @param args * the arguments */ public static void main(String[] args) { // ArrayList<String> tmpArgs = new ArrayList<String>(Arrays.asList(args)); // args = tmpArgs.toArray(new String[0]); FlagOption suppressStatusOutOpt = new FlagOption("suppressStatusOut", 'S', SUPPRESS_STATUS_OUT_MSG); FlagOption suppressResultOutOpt = new FlagOption("suppressResultOut", 'R', SUPPRESS_RESULT_OUT_MSG); IntOption statusUpdateFreqOpt = new IntOption("statusUpdateFrequency", 'F', STATUS_UPDATE_FREQ_MSG, 1000, 0, Integer.MAX_VALUE); Option[] extraOptions = new Option[] { suppressStatusOutOpt, suppressResultOutOpt, statusUpdateFreqOpt }; StringBuilder cliString = new StringBuilder(); for (String arg : args) { cliString.append(" ").append(arg); } logger.debug("Command line string = {}", cliString.toString()); System.out.println("Command line string = " + cliString.toString()); Task task; try { task = ClassOption.cliStringToObject(cliString.toString(), Task.class, extraOptions); logger.info("Successfully instantiating {}", task.getClass().getCanonicalName()); } catch (Exception e) { logger.error("Fail to initialize the task", e); System.out.println("Fail to initialize the task" + e); return; } task.setFactory(new SimpleComponentFactory()); task.init(); SimpleEngine.submitTopology(task.getTopology()); }
Example #16
Source File: IntOptionEditComponent.java From moa with GNU General Public License v3.0 | 4 votes |
@Override public Option getEditedOption() { return this.editedOption; }
Example #17
Source File: MOAClassOptionEditor.java From moa with GNU General Public License v3.0 | 4 votes |
public JComponent getEditComponent(Option option){ return OptionsConfigurationPanel.getEditComponent(option); }
Example #18
Source File: OutlierAlgoPanel.java From moa with GNU General Public License v3.0 | 4 votes |
public JComponent getEditComponent(Option option){ return OptionsConfigurationPanel.getEditComponent(option); }
Example #19
Source File: OutlierAlgoPanel.java From moa with GNU General Public License v3.0 | 4 votes |
public void renderAlgoPanel(){ setLayout(new BorderLayout()); ArrayList<Option> options = new ArrayList<Option>(); options.add(streamOption); options.add(algorithmOption0); options.add(algorithmOption1); JPanel optionsPanel = new JPanel(); GridBagLayout gbLayout = new GridBagLayout(); optionsPanel.setLayout(gbLayout); //Create generic label constraints GridBagConstraints gbcLabel = new GridBagConstraints(); gbcLabel.gridx = 0; gbcLabel.fill = GridBagConstraints.NONE; gbcLabel.anchor = GridBagConstraints.EAST; gbcLabel.weightx = 0; gbcLabel.insets = new Insets(5, 5, 5, 5); //Create generic editor constraints GridBagConstraints gbcOption = new GridBagConstraints(); gbcOption.gridx = 1; gbcOption.fill = GridBagConstraints.HORIZONTAL; gbcOption.anchor = GridBagConstraints.CENTER; gbcOption.weightx = 1; gbcOption.insets = new Insets(5, 5, 5, 0); //Stream Option JLabel labelStream = new JLabel("Stream"); labelStream.setToolTipText("Stream to use."); optionsPanel.add(labelStream, gbcLabel); JComponent editorStream = getEditComponent(streamOption); labelStream.setLabelFor(editorStream); editComponents.add((OptionEditComponent) editorStream); optionsPanel.add(editorStream, gbcOption); //Algorithm0 Option JLabel labelAlgo0 = new JLabel("Algorithm1"); labelAlgo0.setForeground(Color.RED); labelAlgo0.setToolTipText("Algorithm to use."); optionsPanel.add(labelAlgo0, gbcLabel); JComponent editorAlgo0 = getEditComponent(algorithmOption0); labelAlgo0.setLabelFor(editorAlgo0); editComponents.add((OptionEditComponent) editorAlgo0); optionsPanel.add(editorAlgo0, gbcOption); //Algorithm1 Option JLabel labelAlgo1 = new JLabel("Algorithm2"); labelAlgo1.setForeground(Color.BLUE); labelAlgo1.setToolTipText("Algorithm to use."); optionsPanel.add(labelAlgo1, gbcLabel); JComponent editorAlgo1 = getEditComponent(algorithmOption1); labelAlgo1.setLabelFor(editorAlgo1); editComponents.add((OptionEditComponent) editorAlgo1); optionsPanel.add(editorAlgo1, gbcOption); //use comparison Algorithm Option GridBagConstraints gbcClearButton = new GridBagConstraints(); gbcClearButton.gridx = 2; gbcClearButton.gridy = 2; gbcClearButton.fill = GridBagConstraints.NONE; gbcClearButton.anchor = GridBagConstraints.CENTER; gbcClearButton.insets = new Insets(5, 0, 5, 5); JButton clearButton = new JButton("Clear"); clearButton.addActionListener(this); clearButton.setActionCommand("clear"); optionsPanel.add(clearButton, gbcClearButton); add(optionsPanel); }
Example #20
Source File: WEKAClassOptionEditComponent.java From moa with GNU General Public License v3.0 | 4 votes |
@Override public Option getEditedOption() { return this.editedOption; }
Example #21
Source File: StringOptionEditComponent.java From moa with GNU General Public License v3.0 | 4 votes |
public StringOptionEditComponent(Option option) { this.editedOption = option; setEditState(this.editedOption.getValueAsCLIString()); }
Example #22
Source File: StringOptionEditComponent.java From moa with GNU General Public License v3.0 | 4 votes |
@Override public Option getEditedOption() { return this.editedOption; }
Example #23
Source File: ClusteringAlgoPanel.java From moa with GNU General Public License v3.0 | 4 votes |
public JComponent getEditComponent(Option option){ return OptionsConfigurationPanel.getEditComponent(option); }
Example #24
Source File: ClusteringAlgoPanel.java From moa with GNU General Public License v3.0 | 4 votes |
public void renderAlgoPanel(){ setLayout(new BorderLayout()); ArrayList<Option> options = new ArrayList<Option>(); options.add(streamOption); options.add(algorithmOption0); options.add(algorithmOption1); JPanel optionsPanel = new JPanel(); GridBagLayout gbLayout = new GridBagLayout(); optionsPanel.setLayout(gbLayout); //Create generic label constraints GridBagConstraints gbcLabel = new GridBagConstraints(); gbcLabel.gridx = 0; gbcLabel.fill = GridBagConstraints.NONE; gbcLabel.anchor = GridBagConstraints.EAST; gbcLabel.weightx = 0; gbcLabel.insets = new Insets(5, 5, 5, 5); //Create generic editor constraints GridBagConstraints gbcOption = new GridBagConstraints(); gbcOption.gridx = 1; gbcOption.fill = GridBagConstraints.HORIZONTAL; gbcOption.anchor = GridBagConstraints.CENTER; gbcOption.weightx = 1; gbcOption.insets = new Insets(5, 5, 5, 0); //Stream Option JLabel labelStream = new JLabel("Stream"); labelStream.setToolTipText("Stream to use."); optionsPanel.add(labelStream, gbcLabel); JComponent editorStream = getEditComponent(streamOption); labelStream.setLabelFor(editorStream); editComponents.add((OptionEditComponent) editorStream); optionsPanel.add(editorStream, gbcOption); //Algorithm0 Option JLabel labelAlgo0 = new JLabel("Algorithm1"); labelAlgo0.setToolTipText("Algorithm to use."); optionsPanel.add(labelAlgo0, gbcLabel); JComponent editorAlgo0 = getEditComponent(algorithmOption0); labelAlgo0.setLabelFor(editorAlgo0); editComponents.add((OptionEditComponent) editorAlgo0); optionsPanel.add(editorAlgo0, gbcOption); //Algorithm1 Option JLabel labelAlgo1 = new JLabel("Algorithm2"); labelAlgo1.setToolTipText("Comparison algorithm to use."); optionsPanel.add(labelAlgo1, gbcLabel); JComponent editorAlgo1 = getEditComponent(algorithmOption1); labelAlgo1.setLabelFor(editorAlgo1); editComponents.add((OptionEditComponent) editorAlgo1); optionsPanel.add(editorAlgo1, gbcOption); //use comparison Algorithm Option GridBagConstraints gbcClearButton = new GridBagConstraints(); gbcClearButton.gridx = 2; gbcClearButton.gridy = 2; gbcClearButton.fill = GridBagConstraints.NONE; gbcClearButton.anchor = GridBagConstraints.CENTER; gbcClearButton.insets = new Insets(5, 0, 5, 5); JButton clearButton = new JButton("Clear"); clearButton.addActionListener(this); clearButton.setActionCommand("clear"); optionsPanel.add(clearButton, gbcClearButton); add(optionsPanel); }
Example #25
Source File: ListOptionEditComponent.java From moa with GNU General Public License v3.0 | 4 votes |
public ListOptionEditComponent(Option option) { super(option); }
Example #26
Source File: FlagOptionEditComponent.java From moa with GNU General Public License v3.0 | 4 votes |
public FlagOptionEditComponent(Option opt) { FlagOption option = (FlagOption) opt; this.editedOption = option; setEditState(this.editedOption.getValueAsCLIString()); }
Example #27
Source File: FlagOptionEditComponent.java From moa with GNU General Public License v3.0 | 4 votes |
@Override public Option getEditedOption() { return this.editedOption; }
Example #28
Source File: MultiChoiceOptionEditComponent.java From moa with GNU General Public License v3.0 | 4 votes |
public MultiChoiceOptionEditComponent(Option option) { super(((MultiChoiceOption) option).getOptionLabels()); this.editedOption = (MultiChoiceOption) option; setSelectedIndex(this.editedOption.getChosenIndex()); }
Example #29
Source File: MultiChoiceOptionEditComponent.java From moa with GNU General Public License v3.0 | 4 votes |
@Override public Option getEditedOption() { return this.editedOption; }
Example #30
Source File: ClassOptionWithNamesEditComponent.java From moa with GNU General Public License v3.0 | 4 votes |
public Option getEditedOption() { return this.editedOption; }