From: <ton...@us...> - 2008-02-19 15:54:29
|
Revision: 613 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=613&view=rev Author: tonytacker Date: 2008-02-19 07:54:02 -0800 (Tue, 19 Feb 2008) Log Message: ----------- formated Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelAbstract.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-19 15:54:02 UTC (rev 613) @@ -34,83 +34,83 @@ * @author Tilo Hielscher */ public class CheckBoxList extends JPanel { - private static final long serialVersionUID = -7119007550662195455L; - private JPanel checkBoxPanel = new JPanel(); - private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); - private GridBagLayout gridbag = new GridBagLayout(); - private GridBagConstraints constraints = new GridBagConstraints(); + private static final long serialVersionUID = -7119007550662195455L; + private JPanel checkBoxPanel = new JPanel(); + private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); + private GridBagLayout gridbag = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); - /** - * Make a JPanel with GridBagLayout. - */ - public CheckBoxList() { - checkBoxPanel.setLayout(gridbag); - add(checkBoxPanel, BorderLayout.CENTER); - constraints.anchor = GridBagConstraints.WEST; - } + /** + * Make a JPanel with GridBagLayout. + */ + public CheckBoxList() { + checkBoxPanel.setLayout(gridbag); + add(checkBoxPanel, BorderLayout.CENTER); + constraints.anchor = GridBagConstraints.WEST; + } - /** - * Add new entry and make a new JCheckBox. - * - * @param label - * This text will be shown. It is the name of new JCheckBox - * and will add to list. - */ - public void add(String label) { - list.add(new JCheckBox(label)); - update(); - } + /** + * Add new entry and make a new JCheckBox. + * + * @param label + * This text will be shown. It is the name of new JCheckBox and + * will add to list. + */ + public void add(String label) { + list.add(new JCheckBox(label)); + update(); + } - /** - * Return a set of selected items. - */ - public Set<String> getSelections() { - Set<String> selectionSet = new HashSet<String>(); - selectionSet.clear(); // remove all - for (int i = 0; i < list.size(); i++) { - if (list.get(i).isSelected()) - selectionSet.add(list.get(i).getText()); + /** + * Return a set of selected items. + */ + public Set<String> getSelections() { + Set<String> selectionSet = new HashSet<String>(); + selectionSet.clear(); // remove all + for (int i = 0; i < list.size(); i++) { + if (list.get(i).isSelected()) + selectionSet.add(list.get(i).getText()); + } + return selectionSet; } - return selectionSet; - } - /** - * Select items. - * - * @param selectionSet - * Is a Set of Strings. - */ - public void setSelections(Set<String> selectionSet) { - for (int i = 0; i < this.list.size(); i++) { - if (selectionSet.contains(list.get(i).getText())) - list.get(i).setSelected(true); - else - this.list.get(i).setSelected(false); + /** + * Select items. + * + * @param selectionSet + * Is a Set of Strings. + */ + public void setSelections(Set<String> selectionSet) { + for (int i = 0; i < this.list.size(); i++) { + if (selectionSet.contains(list.get(i).getText())) + list.get(i).setSelected(true); + else + this.list.get(i).setSelected(false); + } } - } - /** - * update JCheckBox's - */ - private void update() { - checkBoxPanel.removeAll(); - for (int i = 0; i < list.size(); i++) { - buildConstraints(constraints, 0, i, 1, 1, 100, 100); - gridbag.setConstraints(list.get(i), constraints); - checkBoxPanel.add(list.get(i), constraints); + /** + * update JCheckBox's + */ + private void update() { + checkBoxPanel.removeAll(); + for (int i = 0; i < list.size(); i++) { + buildConstraints(constraints, 0, i, 1, 1, 100, 100); + gridbag.setConstraints(list.get(i), constraints); + checkBoxPanel.add(list.get(i), constraints); + } } - } - /** - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, - int gw, int gh, int wx, int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; - } + /** + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, + int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-19 15:54:02 UTC (rev 613) @@ -37,242 +37,242 @@ * @author Tilo Hielscher */ public class Config { - private ComponentManager cm = ComponentManager.getInstance(); - private KnowledgeSource source; - private KnowledgeSource oldSource; - private ReasonerComponent reasoner; - private ReasonerComponent oldReasoner; - private ReasoningService rs; - private LearningProblem lp; - private LearningProblem oldLearningProblem; - private LearningAlgorithm la; - private LearningAlgorithm oldLearningAlgorithm; - private boolean[] isInit = new boolean[4]; + private ComponentManager cm = ComponentManager.getInstance(); + private KnowledgeSource source; + private KnowledgeSource oldSource; + private ReasonerComponent reasoner; + private ReasonerComponent oldReasoner; + private ReasoningService rs; + private LearningProblem lp; + private LearningProblem oldLearningProblem; + private LearningAlgorithm la; + private LearningAlgorithm oldLearningAlgorithm; + private boolean[] isInit = new boolean[4]; - /** - * Get ComponentManager. - * - * @return ComponentManager - */ - public ComponentManager getComponentManager() { - return this.cm; - } + /** + * Get ComponentManager. + * + * @return ComponentManager + */ + public ComponentManager getComponentManager() { + return this.cm; + } - /** - * It is necessary for init KnowledgeSource. - * - * @return true, if url was set otherwise false - */ - public Boolean isSetURL() { - // return this.isURL; - // String value = (String) cm.getConfigOptionValue(source, "url"); - if (cm.getConfigOptionValue(source, "url") != null) - return true; - else - return false; - } + /** + * It is necessary for init KnowledgeSource. + * + * @return true, if url was set otherwise false + */ + public Boolean isSetURL() { + // return this.isURL; + // String value = (String) cm.getConfigOptionValue(source, "url"); + if (cm.getConfigOptionValue(source, "url") != null) + return true; + else + return false; + } - /** - * Set KnowledgeSource. - * - * @param knowledgeSource - */ - public void setKnowledgeSource(KnowledgeSource knowledgeSource) { - this.oldSource = this.source; - this.source = knowledgeSource; - } + /** + * Set KnowledgeSource. + * + * @param knowledgeSource + */ + public void setKnowledgeSource(KnowledgeSource knowledgeSource) { + this.oldSource = this.source; + this.source = knowledgeSource; + } - /** - * Get KnowledgeSource. - * - * @return KnowledgeSource - */ - public KnowledgeSource getKnowledgeSource() { - return this.source; - } + /** + * Get KnowledgeSource. + * + * @return KnowledgeSource + */ + public KnowledgeSource getKnowledgeSource() { + return this.source; + } - /** - * Get old KnowledgeSource. - * - * @return old KnowledgeSource - */ - public KnowledgeSource getOldKnowledgeSource() { - return this.oldSource; - } + /** + * Get old KnowledgeSource. + * + * @return old KnowledgeSource + */ + public KnowledgeSource getOldKnowledgeSource() { + return this.oldSource; + } - /** - * Set Reasoner. - * - * @param reasoner - */ - public void setReasoner(ReasonerComponent reasoner) { - this.oldReasoner = this.reasoner; - this.reasoner = reasoner; - } + /** + * Set Reasoner. + * + * @param reasoner + */ + public void setReasoner(ReasonerComponent reasoner) { + this.oldReasoner = this.reasoner; + this.reasoner = reasoner; + } - /** - * Get Reasoner. - * - * @return reasoner - */ - public ReasonerComponent getReasoner() { - return this.reasoner; - } + /** + * Get Reasoner. + * + * @return reasoner + */ + public ReasonerComponent getReasoner() { + return this.reasoner; + } - /** - * Get old Reasoner as a set. - * - * @return oldReasonerSet. - */ - public ReasonerComponent getOldReasonerSet() { - return this.oldReasoner; - } + /** + * Get old Reasoner as a set. + * + * @return oldReasonerSet. + */ + public ReasonerComponent getOldReasonerSet() { + return this.oldReasoner; + } - /** - * Set ReasoningService. - * - * @param reasoningService - */ - public void setReasoningService(ReasoningService reasoningService) { - this.rs = reasoningService; - } + /** + * Set ReasoningService. + * + * @param reasoningService + */ + public void setReasoningService(ReasoningService reasoningService) { + this.rs = reasoningService; + } - /** - * Get ReasoningService. - * - * @return ReasoningService - */ - public ReasoningService getReasoningService() { - return this.rs; - } + /** + * Get ReasoningService. + * + * @return ReasoningService + */ + public ReasoningService getReasoningService() { + return this.rs; + } - /** - * Set LearningProblem. - * - * @param learningProblem - */ - public void setLearningProblem(LearningProblem learningProblem) { - this.oldLearningProblem = this.lp; - this.lp = learningProblem; - } + /** + * Set LearningProblem. + * + * @param learningProblem + */ + public void setLearningProblem(LearningProblem learningProblem) { + this.oldLearningProblem = this.lp; + this.lp = learningProblem; + } - /** - * Get LearningProblem. - * - * @return learningProblem - */ - public LearningProblem getLearningProblem() { - return this.lp; - } + /** + * Get LearningProblem. + * + * @return learningProblem + */ + public LearningProblem getLearningProblem() { + return this.lp; + } - /** - * Get old LearningProblem as a set. - * - * @return old learningProblemSet. - */ - public LearningProblem getOldLearningProblem() { - return this.oldLearningProblem; - } + /** + * Get old LearningProblem as a set. + * + * @return old learningProblemSet. + */ + public LearningProblem getOldLearningProblem() { + return this.oldLearningProblem; + } - /** - * Set LearningAlgorithm. - * - * @param learningAlgorithm - */ - public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { - this.oldLearningAlgorithm = this.la; - this.la = learningAlgorithm; - } + /** + * Set LearningAlgorithm. + * + * @param learningAlgorithm + */ + public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { + this.oldLearningAlgorithm = this.la; + this.la = learningAlgorithm; + } - /** - * Get LearningAlgorithm. - * - * @return LearningAlgorithm - */ - public LearningAlgorithm getLearningAlgorithm() { - return this.la; - } + /** + * Get LearningAlgorithm. + * + * @return LearningAlgorithm + */ + public LearningAlgorithm getLearningAlgorithm() { + return this.la; + } - /** - * Get old LearningAlgorithmSet. - * - * @return old LearningAlgorithmSet - */ - public LearningAlgorithm getOldLearningAlgorithm() { - return this.oldLearningAlgorithm; - } + /** + * Get old LearningAlgorithmSet. + * + * @return old LearningAlgorithmSet + */ + public LearningAlgorithm getOldLearningAlgorithm() { + return this.oldLearningAlgorithm; + } - /** - * KnowledgeSource.init has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitKnowledgeSource() { - return isInit[0]; - } + /** + * KnowledgeSource.init has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitKnowledgeSource() { + return isInit[0]; + } - /** - * Set true if you run KnowwledgeSource.init. The inits from other tabs - * behind will automatic set to false. - */ - public void setInitKnowledgeSource(Boolean is) { - isInit[0] = is; - for (int i = 1; i < 4; i++) - isInit[i] = false; - } + /** + * Set true if you run KnowwledgeSource.init. The inits from other tabs + * behind will automatic set to false. + */ + public void setInitKnowledgeSource(Boolean is) { + isInit[0] = is; + for (int i = 1; i < 4; i++) + isInit[i] = false; + } - /** - * Reasoner.init has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitReasoner() { - return isInit[1]; - } + /** + * Reasoner.init has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitReasoner() { + return isInit[1]; + } - /** - * Set true if you run Reasoner.init. The inits from other tabs behind will - * automatic set to false. - */ - public void setInitReasoner(Boolean is) { - isInit[1] = is; - for (int i = 2; i < 4; i++) - isInit[i] = false; - } + /** + * Set true if you run Reasoner.init. The inits from other tabs behind will + * automatic set to false. + */ + public void setInitReasoner(Boolean is) { + isInit[1] = is; + for (int i = 2; i < 4; i++) + isInit[i] = false; + } - /** - * LearningProblem.init has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitLearningProblem() { - return isInit[2]; - } + /** + * LearningProblem.init has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitLearningProblem() { + return isInit[2]; + } - /** - * Set true if you run LearningProblem.init. The inits from other tabs - * behind will automatic set to false. - */ - public void setInitLearningProblem(Boolean is) { - isInit[2] = is; - for (int i = 3; i < 4; i++) - isInit[i] = false; - } + /** + * Set true if you run LearningProblem.init. The inits from other tabs + * behind will automatic set to false. + */ + public void setInitLearningProblem(Boolean is) { + isInit[2] = is; + for (int i = 3; i < 4; i++) + isInit[i] = false; + } - /** - * LearningAlgorithm.init() has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitLearningAlgorithm() { - return isInit[3]; - } + /** + * LearningAlgorithm.init() has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitLearningAlgorithm() { + return isInit[3]; + } - /** - * set true if you run LearningAlgorithm.init - */ - public void setInitLearningAlgorithm(Boolean is) { - isInit[3] = is; - } + /** + * set true if you run LearningAlgorithm.init + */ + public void setInitLearningAlgorithm(Boolean is) { + isInit[3] = is; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-19 15:54:02 UTC (rev 613) @@ -45,117 +45,110 @@ */ public class ConfigLoad { - private File file; - private Config config; - private StartGUI startGUI; + private File file; + private Config config; + private StartGUI startGUI; - private Class<? extends KnowledgeSource> componentOption; + private Class<? extends KnowledgeSource> componentOption; - /** - * set config and startGUI - * - * @param config - * @param startGUI - */ - public ConfigLoad(Config config, StartGUI startGUI) { - this.config = config; - this.startGUI = startGUI; - } + /** + * set config and startGUI + * + * @param config + * @param startGUI + */ + public ConfigLoad(Config config, StartGUI startGUI) { + this.config = config; + this.startGUI = startGUI; + } - /** - * set your file to read - * - * @param file - * @return true if file exist - */ - public boolean openFile(File file) { - this.file = file; - return file.exists(); - } + /** + * set your file to read + * + * @param file + * @return true if file exist + */ + public boolean openFile(File file) { + this.file = file; + return file.exists(); + } - /** - * parse file - */ - public void startParser() { - if (this.file.exists()) { - ConfParser parser = ConfParser.parseFile(file); - // KNOWLEDGE SOURCE - // filename - String value = parser.getFunctionCalls().get("import").get(0) - .get(0); - // only first of imported files - if (value.endsWith(".kb")) { - componentOption = KBFile.class; - } else if (value.endsWith(".owl")) { - componentOption = OWLFile.class; - } else if (parser.getFunctionCalls().get("import").get(0).size() > 1) { - if (parser.getFunctionCalls().get("import").get(0).get(1) - .equalsIgnoreCase("sparql")) { - System.out.println("IT IS SPARQL"); - componentOption = SparqlKnowledgeSource.class; - } - } - // check if class was set - if (componentOption != null) - config.setKnowledgeSource(config.getComponentManager() - .knowledgeSource(componentOption)); - // set url - // value = parser.getFunctionCalls().get("import").get(0).get(0); - value = makeURL(value); - Component component = config.getKnowledgeSource(); - StringConfigOption specialOption = (StringConfigOption) config - .getComponentManager().getConfigOption(componentOption, - "url"); - try { - ConfigEntry<String> specialEntry = new ConfigEntry<String>( - specialOption, value); - config.getComponentManager().applyConfigEntry(component, - specialEntry); - System.out.println("set String: " + "url" + " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } - // startGUI.updateTabColors(); - // init - if (config.getKnowledgeSource() != null && config.isSetURL()) { - try { - config.getKnowledgeSource().init(); - config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); - } catch (ComponentInitException e) { - e.printStackTrace(); - } - } + /** + * parse file + */ + public void startParser() { + if (this.file.exists()) { + ConfParser parser = ConfParser.parseFile(file); + // KNOWLEDGE SOURCE + // filename + String value = parser.getFunctionCalls().get("import").get(0).get(0); + // only first of imported files + if (value.endsWith(".kb")) { + componentOption = KBFile.class; + } else if (value.endsWith(".owl")) { + componentOption = OWLFile.class; + } else if (parser.getFunctionCalls().get("import").get(0).size() > 1) { + if (parser.getFunctionCalls().get("import").get(0).get(1) + .equalsIgnoreCase("sparql")) { + System.out.println("IT IS SPARQL"); + componentOption = SparqlKnowledgeSource.class; + } + } + // check if class was set + if (componentOption != null) + config.setKnowledgeSource(config.getComponentManager().knowledgeSource( + componentOption)); + // set url + // value = parser.getFunctionCalls().get("import").get(0).get(0); + value = makeURL(value); + Component component = config.getKnowledgeSource(); + StringConfigOption specialOption = (StringConfigOption) config.getComponentManager() + .getConfigOption(componentOption, "url"); + try { + ConfigEntry<String> specialEntry = new ConfigEntry<String>(specialOption, value); + config.getComponentManager().applyConfigEntry(component, specialEntry); + System.out.println("set String: " + "url" + " = " + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + // startGUI.updateTabColors(); + // init + if (config.getKnowledgeSource() != null && config.isSetURL()) { + try { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } - // update - startGUI.updateTabColors(); + // update + startGUI.updateTabColors(); - System.out.println("reasoner: " - + parser.getConfOptionsByName("reasoner")); - System.out.println("confoptions: " + parser.getConfOptions()); - System.out.println("posExamples: " + parser.getPositiveExamples()); - System.out.println("confoptionbyname: " - + parser.getConfOptionsByName()); + System.out.println("reasoner: " + parser.getConfOptionsByName("reasoner")); + System.out.println("confoptions: " + parser.getConfOptions()); + System.out.println("posExamples: " + parser.getPositiveExamples()); + System.out.println("confoptionbyname: " + parser.getConfOptionsByName()); - // do it - // only url from first entry, ignore others - // parser.getFunctionCalls().get("import").get(0); + // do it + // only url from first entry, ignore others + // parser.getFunctionCalls().get("import").get(0); + } } - } - /** - * If value is not a valid url and starts with "http://" or "file://" then - * add "file://" - * - * @param value - * is a string - * @return a valid url made from value - */ - public String makeURL(String value) { - if (!value.startsWith("http://") && !value.startsWith("file://")) - value = "file://".concat(file.getPath().replace(file.getName(), "") - .concat(value)); - return value; - } + /** + * If value is not a valid url and starts with "http://" or "file://" then + * add "file://" + * + * @param value + * is a string + * @return a valid url made from value + */ + public String makeURL(String value) { + if (!value.startsWith("http://") && !value.startsWith("file://")) + value = "file://".concat(file.getPath().replace(file.getName(), "").concat(value)); + return value; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -29,8 +29,9 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.KnowledgeSource; -import org.dllearner.kb.*; +// import org.dllearner.kb.*; + /** * KnowledgeSourcePanel, tab 0. Choose Source, change Options and final initiate * KnowledgeSource. @@ -39,154 +40,149 @@ */ public class KnowledgeSourcePanel extends JPanel implements ActionListener { - private static final long serialVersionUID = -7678275020058043937L; + private static final long serialVersionUID = -7678275020058043937L; - private Config config; - private StartGUI startGUI; - private JButton initButton; - private JButton setButton; - private String[] kbBoxItems = {}; - private JComboBox cb = new JComboBox(kbBoxItems); - private JPanel choosePanel = new JPanel(); - private JPanel initPanel = new JPanel(); - private int choosenClassIndex; - private List<Class<? extends KnowledgeSource>> sources; - private OptionPanel optionPanel; + private Config config; + private StartGUI startGUI; + private JButton initButton; + private JButton setButton; + private String[] kbBoxItems = {}; + private JComboBox cb = new JComboBox(kbBoxItems); + private JPanel choosePanel = new JPanel(); + private JPanel initPanel = new JPanel(); + private int choosenClassIndex; + private List<Class<? extends KnowledgeSource>> sources; + private OptionPanel optionPanel; - KnowledgeSourcePanel(final Config config, StartGUI startGUI) { - super(new BorderLayout()); + KnowledgeSourcePanel(final Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - sources = config.getComponentManager().getKnowledgeSources(); + this.config = config; + this.startGUI = startGUI; + sources = config.getComponentManager().getKnowledgeSources(); - System.out.println("SOURCES: " + sources); + System.out.println("SOURCES: " + sources); - setButton = new JButton("Set"); - setButton.addActionListener(this); - initButton = new JButton("Init KnowledgeSource"); - initButton.addActionListener(this); - initButton.setEnabled(true); + setButton = new JButton("Set"); + setButton.addActionListener(this); + initButton = new JButton("Init KnowledgeSource"); + initButton.addActionListener(this); + initButton.setEnabled(true); - // add to comboBox - for (int i = 0; i < sources.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - sources.get(i))); - } - cb.addActionListener(this); + // add to comboBox + for (int i = 0; i < sources.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(sources.get(i))); + } + cb.addActionListener(this); - choosePanel.add(cb); - choosePanel.add(setButton); - choosenClassIndex = cb.getSelectedIndex(); + choosePanel.add(cb); + choosePanel.add(setButton); + choosenClassIndex = cb.getSelectedIndex(); - optionPanel = new OptionPanel(config, config.getKnowledgeSource(), - config.getOldKnowledgeSource(), sources.get(choosenClassIndex)); - initPanel.add(initButton); + optionPanel = new OptionPanel(config, config.getKnowledgeSource(), config + .getOldKnowledgeSource(), sources.get(choosenClassIndex)); + initPanel.add(initButton); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - // setSource(); - updateAll(); - } - - public void actionPerformed(ActionEvent e) { - // read selected KnowledgeSourceClass - // choosenClassIndex = cb.getSelectedIndex(); - if (choosenClassIndex != cb.getSelectedIndex()) { - choosenClassIndex = cb.getSelectedIndex(); - config.setInitKnowledgeSource(false); - setSource(); + // setSource(); + updateAll(); } - if (e.getSource() == setButton) { - setSource(); + public void actionPerformed(ActionEvent e) { + // read selected KnowledgeSourceClass + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitKnowledgeSource(false); + setSource(); + } + + if (e.getSource() == setButton) { + setSource(); + } + + if (e.getSource() == initButton) + init(); } - if (e.getSource() == initButton) - init(); - } + /** + * after this, you can change widgets + */ + public void setSource() { + System.out.println("cm: " + config.getComponentManager()); + System.out.println("setSOURCE :" + sources.get(choosenClassIndex)); - /** - * after this, you can change widgets - */ - public void setSource() { - System.out.println("cm: " + config.getComponentManager()); - System.out.println("setSOURCE :" + sources.get(choosenClassIndex)); - - config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); -// KBFile.class doesn't work -// config.setKnowledgeSource(config.getComponentManager().knowledgeSource(KBFile.class)); - - - System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); - System.out - .println("ABC: " - + config.getComponentManager().getComponentName( - sources.get(0))); + config.setKnowledgeSource(config.getComponentManager().knowledgeSource( + sources.get(choosenClassIndex))); + // KBFile.class doesn't work + // config.setKnowledgeSource(config.getComponentManager().knowledgeSource(KBFile.class)); - config.setInitKnowledgeSource(false); - updateAll(); - } + System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); + System.out.println("ABC: " + config.getComponentManager().getComponentName(sources.get(0))); - /** - * after this, next tab can be used - */ - public void init() { - System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); - System.out.println("isSetURL: " + config.isSetURL()); - if (config.getKnowledgeSource() != null && config.isSetURL()) { - try { - config.getKnowledgeSource().init(); - config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); - startGUI.updateTabColors(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } + config.setInitKnowledgeSource(false); + updateAll(); } - } - /** - * updateAll - */ - public void updateAll() { - updateComboBox(); - updateOptionPanel(); - updateInitButtonColor(); - } - - /** - * set ComboBox to selected class - */ - public void updateComboBox() { - if (config.getKnowledgeSource() != null) - for (int i = 0; i < sources.size(); i++) - if (config.getKnowledgeSource().getClass().equals( - config.getComponentManager().getKnowledgeSources().get( - i))) { - cb.setSelectedIndex(i); + /** + * after this, next tab can be used + */ + public void init() { + System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); + System.out.println("isSetURL: " + config.isSetURL()); + if (config.getKnowledgeSource() != null && config.isSetURL()) { + try { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } } - this.choosenClassIndex = cb.getSelectedIndex(); - } + } - /** - * update OptionPanel with new selection - */ - public void updateOptionPanel() { - optionPanel.update(config.getKnowledgeSource(), config - .getOldKnowledgeSource(), sources.get(choosenClassIndex)); - } + /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } - /** - * make init-button red if you have to click - */ - public void updateInitButtonColor() { - if (!config.isInitKnowledgeSource()) { - initButton.setForeground(Color.RED); - } else - initButton.setForeground(Color.BLACK); - } + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getKnowledgeSource() != null) + for (int i = 0; i < sources.size(); i++) + if (config.getKnowledgeSource().getClass().equals( + config.getComponentManager().getKnowledgeSources().get(i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + /** + * update OptionPanel with new selection + */ + public void updateOptionPanel() { + optionPanel.update(config.getKnowledgeSource(), config.getOldKnowledgeSource(), sources + .get(choosenClassIndex)); + } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitKnowledgeSource()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -39,122 +39,118 @@ */ public class LearningAlgorithmPanel extends JPanel implements ActionListener { - private static final long serialVersionUID = 8721490771860452959L; + private static final long serialVersionUID = 8721490771860452959L; - private Config config; - private StartGUI startGUI; - private List<Class<? extends LearningAlgorithm>> learners; - private JPanel choosePanel = new JPanel(); - private OptionPanel optionPanel; - private JPanel initPanel = new JPanel(); - private JButton initButton, autoInitButton; - private String[] cbItems = {}; - private JComboBox cb = new JComboBox(cbItems); - private int choosenClassIndex; + private Config config; + private StartGUI startGUI; + private List<Class<? extends LearningAlgorithm>> learners; + private JPanel choosePanel = new JPanel(); + private OptionPanel optionPanel; + private JPanel initPanel = new JPanel(); + private JButton initButton, autoInitButton; + private String[] cbItems = {}; + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; - LearningAlgorithmPanel(Config config, StartGUI startGUI) { - super(new BorderLayout()); + LearningAlgorithmPanel(Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - learners = config.getComponentManager().getLearningAlgorithms(); + this.config = config; + this.startGUI = startGUI; + learners = config.getComponentManager().getLearningAlgorithms(); - initButton = new JButton("Init LearingAlgorithm"); - initButton.addActionListener(this); - initPanel.add(initButton); - initButton.setEnabled(true); - autoInitButton = new JButton("Set"); - autoInitButton.addActionListener(this); + initButton = new JButton("Init LearingAlgorithm"); + initButton.addActionListener(this); + initPanel.add(initButton); + initButton.setEnabled(true); + autoInitButton = new JButton("Set"); + autoInitButton.addActionListener(this); - // add into comboBox - for (int i = 0; i < learners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - learners.get(i))); - } + // add into comboBox + for (int i = 0; i < learners.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(learners.get(i))); + } - choosePanel.add(cb); - choosePanel.add(autoInitButton); - cb.addActionListener(this); + choosePanel.add(cb); + choosePanel.add(autoInitButton); + cb.addActionListener(this); - optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), - config.getOldLearningAlgorithm(), learners - .get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), config + .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - updateInitButtonColor(); - } - - public void actionPerformed(ActionEvent e) { - // read selected Class - // choosenClassIndex = cb.getSelectedIndex(); - if (choosenClassIndex != cb.getSelectedIndex()) { - choosenClassIndex = cb.getSelectedIndex(); - config.setInitLearningAlgorithm(false); - setLearningAlgorithm(); + updateInitButtonColor(); } - if (e.getSource() == autoInitButton) - setLearningAlgorithm(); + public void actionPerformed(ActionEvent e) { + // read selected Class + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitLearningAlgorithm(false); + setLearningAlgorithm(); + } - if (e.getSource() == initButton) - init(); - } + if (e.getSource() == autoInitButton) + setLearningAlgorithm(); - /** - * after this, you can change widgets - */ - public void setLearningAlgorithm() { - if (config.getLearningProblem() != null - && config.getReasoningService() != null) { - try { - config.setLearningAlgorithm(config.getComponentManager() - .learningAlgorithm(learners.get(choosenClassIndex), - config.getLearningProblem(), - config.getReasoningService())); - updateOptionPanel(); - } catch (LearningProblemUnsupportedException e) { - e.printStackTrace(); - } + if (e.getSource() == initButton) + init(); } - } - /** - * after this, next tab can be used - */ - public void init() { - setLearningAlgorithm(); - if (config.getLearningProblem() != null) { - try { - config.getLearningAlgorithm().init(); - } catch (ComponentInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - config.setInitLearningAlgorithm(true); - System.out.println("init LearningAlgorithm"); - startGUI.updateTabColors(); + /** + * after this, you can change widgets + */ + public void setLearningAlgorithm() { + if (config.getLearningProblem() != null && config.getReasoningService() != null) { + try { + config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm( + learners.get(choosenClassIndex), config.getLearningProblem(), + config.getReasoningService())); + updateOptionPanel(); + } catch (LearningProblemUnsupportedException e) { + e.printStackTrace(); + } + } } - } - /** - * update OptionPanel with new selection - */ - public void updateOptionPanel() { - // update OptionPanel - optionPanel.update(config.getLearningAlgorithm(), config - .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); - } + /** + * after this, next tab can be used + */ + public void init() { + setLearningAlgorithm(); + if (config.getLearningProblem() != null) { + try { + config.getLearningAlgorithm().init(); + } catch (ComponentInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + config.setInitLearningAlgorithm(true); + System.out.println("init LearningAlgorithm"); + startGUI.updateTabColors(); + } + } - /** - * make init-button red if you have to click - */ - public void updateInitButtonColor() { - if (!config.isInitLearningAlgorithm()) { - initButton.setForeground(Color.RED); - } else - initButton.setForeground(Color.BLACK); - } + /** + * update OptionPanel with new selection + */ + public void updateOptionPanel() { + // update OptionPanel + optionPanel.update(config.getLearningAlgorithm(), config.getOldLearningAlgorithm(), + learners.get(choosenClassIndex)); + } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitLearningAlgorithm()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -38,118 +38,116 @@ */ public class LearningProblemPanel extends JPanel implements ActionListener { - private static final long serialVersionUID = -3819627680918930203L; + private static final long serialVersionUID = -3819627680918930203L; - private Config config; - private StartGUI startGUI; - private List<Class<? extends LearningProblem>> problems; - private String[] lpBoxItems = {}; - private JComboBox cb = new JComboBox(lpBoxItems); - private JPanel choosePanel = new JPanel(); - private OptionPanel optionPanel; - private JPanel initPanel = new JPanel(); - private JButton initButton, setButton; - private int choosenClassIndex; + private Config config; + private StartGUI startGUI; + private List<Class<? extends LearningProblem>> problems; + private String[] lpBoxItems = {}; + private JComboBox cb = new JComboBox(lpBoxItems); + private JPanel choosePanel = new JPanel(); + private OptionPanel optionPanel; + private JPanel initPanel = new JPanel(); + private JButton initButton, setButton; + private int choosenClassIndex; - LearningProblemPanel(final Config config, StartGUI startGUI) { - super(new BorderLayout()); + LearningProblemPanel(final Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - problems = config.getComponentManager().getLearningProblems(); + this.config = config; + this.startGUI = startGUI; + problems = config.getComponentManager().getLearningProblems(); - initButton = new JButton("Init LearningProblem"); - initButton.addActionListener(this); - initPanel.add(initButton); - initButton.setEnabled(true); - setButton = new JButton("Set"); - setButton.addActionListener(this); - choosePanel.add(cb); - choosePanel.add(setButton); - cb.addActionListener(this); + initButton = new JButton("Init LearningProblem"); + initButton.addActionListener(this); + initPanel.add(initButton); + initButton.setEnabled(true); + setButton = new JButton("Set"); + setButton.addActionListener(this); + choosePanel.add(cb); + choosePanel.add(setButton); + cb.addActionListener(this); - // add into comboBox - for (int i = 0; i < problems.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - problems.get(i))); - } + // add into comboBox + for (int i = 0; i < problems.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(problems.get(i))); + } - // read choosen LearningProblem - choosenClassIndex = cb.getSelectedIndex(); + // read choosen LearningProblem + choosenClassIndex = cb.getSelectedIndex(); - optionPanel = new OptionPanel(config, config.getLearningProblem(), - config.getOldLearningProblem(), problems.get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getLearningProblem(), config + .getOldLearningProblem(), problems.get(choosenClassIndex)); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - choosenClassIndex = cb.getSelectedIndex(); - // setLearningProblem(); - updateInitButtonColor(); - } - - public void actionPerformed(ActionEvent e) { - // read selected LearningProblemClass - if (choosenClassIndex != cb.getSelectedIndex()) { - this.choosenClassIndex = cb.getSelectedIndex(); - config.setInitLearningProblem(false); - setLearningProblem(); + choosenClassIndex = cb.getSelectedIndex(); + // setLearningProblem(); + updateInitButtonColor(); } - if (e.getSource() == setButton) - setLearningProblem(); + public void actionPerformed(ActionEvent e) { + // read selected LearningProblemClass + if (choosenClassIndex != cb.getSelectedIndex()) { + this.choosenClassIndex = cb.getSelectedIndex(); + config.setInitLearningProblem(false); + setLearningProblem(); + } - if (e.getSource() == initButton) - init(); - } + if (e.getSource() == setButton) + setLearningProblem(); - /** - * after this, you can change widgets - */ - private void setLearningProblem() { - if (config.isInitReasoner()) { - config.setLearningProblem(config.getComponentManager() - .learningProblem(problems.get(choosenClassIndex), - config.getReasoningService())); - startGUI.updateTabColors(); - updateOptionPanel(); + if (e.getSource() == initButton) + init(); } - } - /** - * after this, next tab can be used - */ - private void init() { - setLearningProblem(); - if (config.getReasoner() != null && config.getLearningProblem() != null) { - try { - config.getLearningProblem().init(); - config.setInitLearningProblem(true); - System.out.println("init LearningProblem"); - startGUI.updateTabColors(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } + /** + * after this, you can change widgets + */ + private void setLearningProblem() { + if (config.isInitReasoner()) { + config.setLearningProblem(config.getComponentManager().learningProblem( + problems.get(choosenClassIndex), config.getReasoningService())); + startGUI.updateTabColors(); + updateOptionPanel(); + } } - } - /** - * update OptionPanel with new selection - */ - private void updateOptionPanel() { - // update OptionPanel - optionPanel.update(config.getLearningProblem(), config - .getOldLearningProblem(), problems.get(choosenClassIndex)); - } + /** + * after this, next tab can be used + */ + private void init() { + setLearningProblem(); + if (config.getReasoner() != null && config.getLearningProblem() != null) { + try { + config.getLearningProblem().init(); + config.setInitLearningProblem(true); + System.out.println("init LearningProblem"); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + } - /** - * make init-button red if you have to click - */ - public void updateInitButtonColor() { - if (!config.isInitLearningProblem()) { - initButton.setForeground(Color.RED); - } else - initButton.setForeground(Color.BLACK); - } + /** + * update OptionPanel with new selection + */ + private void updateOptionPanel() { + // update OptionPanel + optionPanel.update(config.getLearningProblem(), config.getOldLearningProblem(), problems + .get(choosenClassIndex)); + } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitLearningProblem()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -43,105 +43,100 @@ */ public class OptionPanel extends JPanel { - private static final long serialVersionUID = -3053205578443575240L; - private Config config; - private Class<? extends Component> componentOption; - private List<ConfigOption<?>> optionList; - private JPanel centerPanel = new JPanel(); - private Component component; - private Component oldComponent; - private GridBagLayout gridBagLayout = new GridBagLayout(); - private GridBagConstraints constraints = new GridBagConstraints(); + private static final long serialVersionUID = -3053205578443575240L; + private Config config; + private Class<? extends Component> componentOption; + private List<ConfigOption<?>> optionList; + private JPanel centerPanel = new JPanel(); + private Component component; + private Component oldComponent; + private GridBagLayout gridBagLayout = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); - public OptionPanel(Config config, Component component, - Component oldComponent, Class<? extends Component> componentOption) { - super(new BorderLayout()); + public OptionPanel(Config config, Component component, Component oldComponent, + Class<? extends Component> componentOption) { + super(new BorderLayout()); - this.config = config; - this.component = component; - this.oldComponent = oldComponent; - this.componentOption = componentOption; + this.config = config; + this.component = component; + this.oldComponent = oldComponent; + this.componentOption = componentOption; - optionList = ComponentManager.getConfigOptions(componentOption); + optionList = ComponentManager.getConfigOptions(componentOption); - // define GridBagLayout - centerPanel.setLayout(gridBagLayout); - constraints.anchor = GridBagConstraints.NORTHWEST; + // define GridBagLayout + centerPanel.setLayout(gridBagLayout); + constraints.anchor = GridBagConstraints.NORTHWEST; - // add scrollPane - JScrollPane centerScroller = new JScrollPane(centerPanel); - centerScroller.setPreferredSize(new Dimension(400, 200)); - // add Panels - add(centerScroller, BorderLayout.CENTER); - // show widgets - showWidgets(); - } + // add scrollPane + JScrollPane centerScroller = new JScrollPane(centerPanel); + centerScroller.setPreferredSize(new Dimension(400, 200)); + // add Panels + add(centerScroller, BorderLayout.CENTER); + // show widgets + showWidgets(); + } - /** update this OptionPanel */ - public void update(Component component, Component oldComponent, - Class<? extends Component> componentOption) { - this.component = component; - this.oldComponent = oldComponent; - this.componentOption = componentOption; - showWidgets(); + /** update this OptionPanel */ + public void update(Component component, Component oldComponent, + Class<? extends Component> componentOption) { + this.component = component; + this.oldComponent = oldComponent; + this.componentOption = componentOption; + showWidgets(); - } + } - /** - * Define here what core.config.class is what type of widget. - * WidgetPanelDefault is for none defined classes. - */ - private void showWidgets() { - JPanel widgetPanel; - optionList = ComponentManager.getConfigOptions(componentOption); - centerPanel.removeAll(); // clear panel - for (int i = 0; i < optionList.size(); i++) { - buildConstraints(constraints, 0, i, 1, 1, 0, 0); - if (optionList.get(i).getClass().toString().contains( - "IntegerConfigOption")) { - widgetPanel = new WidgetPanelInteger(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "BooleanConfigOption")) { - widgetPanel = new WidgetPanelBoolean(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "DoubleConfigOption")) { - widgetPanel = new WidgetPanelDouble(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "StringConfigOption")) { - widgetPanel = new WidgetPanelString(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "StringSetConfigOption")) { - widgetPanel = new WidgetPanelStringSet(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "StringTupleListConfigOption")) { - widgetPanel = new WidgetPanelStringTupleList(config, component, - oldComponent, componentOption, optionList.get(i)); - } else { - widgetPanel = new WidgetPanelDefault(config, component, - /* oldComponent, */componentOption, optionList.get(i)); - } - gridBagLayout.setConstraints(widgetPanel, constraints); - centerPanel.add(widgetPanel); + /** + * Define here what core.config.class is what type of widget. + * WidgetPanelDefault is for none defined classes. + */ + private void showWidgets() { + JPanel widgetPanel; + optionList = ComponentManager.getConfigOptions(componentOption); + centerPanel.removeAll(); // clear panel + for (int i = 0; i < optionList.size(); i++) { + buildConstraints(constraints, 0, i, 1, 1, 0, 0); + if (optionList.get(i).getClass().toString().contains("IntegerConfigOption")) { + widgetPanel = new WidgetPanelInteger(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("BooleanConfigOption")) { + widgetPanel = new WidgetPanelBoolean(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("DoubleConfigOption")) { + widgetPanel = new WidgetPanelDouble(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("StringConfigOption")) { + widgetPanel = new WidgetPanelString(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("StringSetConfigOption")) { + widgetPanel = new WidgetPanelStringSet(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains( + "StringTupleListConfigOption")) { + widgetPanel = new WidgetPanelStringTupleList(config, component, oldComponent, + componentOption, optionList.get(i)); + } else { + widgetPanel = new WidgetPanelDefault(config, component, + /* oldComponent, */componentOption, optionList.get(i)); + } + gridBagLayout.setConstraints(widgetPanel, constraints); + centerPanel.add(widgetPanel); + } + centerPanel.updateUI(); // update graphic } - centerPanel.updateUI(); // update graphic - } - /** - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, - int gw, int gh, int wx, int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; - } + /** + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, + int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -39,126 +39,124 @@ */ public class ReasonerPanel extends JPanel implements ActionListener { - private static final long serialVersionUID = -7678275020058043937L; + private static final long serialVersionUID = -7678275020058043937L; - private Config config; - private StartGUI startGUI; - private List<Class<? extends ReasonerComponent>> reasoners; - private JPanel choosePanel = new JPanel(); - private JPanel initPanel = new JPanel(); - private OptionPanel optionPanel; - private JButton initButton, setButton; - private String[] cbItems = {}; - private JComboBox cb = new JComboBox(cbItems); - private int choosenClassIndex; + private Config config; + private StartGUI startGUI; + private List<Class<? extends ReasonerComponent>> reasoners; + private JPanel choosePanel = new JPanel(); + private JPanel initPanel = new JPanel(); + private OptionPanel optionPanel; + private JButton initButton, setButton; + private String[] cbItems = {}; + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; - ReasonerPanel(final Config config, StartGUI startGUI) { - super(new BorderLayout()); + ReasonerPanel(final Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - reasoners = config.getComponentManager().getReasonerComponents(); + this.config = config; + this.startGUI = startGUI; + reasoners = config.getComponentManager().getReasonerComponents(); - initButton = new JButton("Init Reasoner"); - initButton.addActionListener(this); - initPanel.add(initButton); - initButton.setEnabled(true); - setButton = new JButton("Set"); - setButton.addActionListener(this); + initButton = new JButton("Init Reasoner"); + initButton.addActionListener(this); + initPanel.add(initButton); + initButton.setEnabled(true); + setButton = new JButton("Set"); + setButton.addActionListener(this); - choosePanel.add(cb); + choosePanel.add(cb); - // add into comboBox - for (int i = 0; i < reasoners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - reasoners.get(i))); - } + // add into comboBox + for (int i = 0; i < reasoners.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(reasoners.get(i))); + } - optionPanel = new OptionPanel(config, config.getReasoner(), config - .getOldReasonerSet(), reasoners.get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getReasoner(), config.getOldReasonerSet(), + reasoners.get(choosenClassIndex)); - choosePanel.add(setButton); - cb.addActionListener(this); + choosePanel.add(setButton); + cb.addActionListener(this); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - choosenClassIndex = cb.getSelectedIndex(); - setReasoner(); - updateInitButtonColor(); - } + choosenClassIndex = cb.getSelectedIndex(); + setReasoner(); + updateInitButtonColor(); + } - public void actionPerformed(ActionEvent e) { - // read selected Class - // choosenClassIndex = cb.getSelectedIndex(); - if (choosenClassIndex != cb.getSelectedIndex()) { - choosenClassIndex = cb.getSelectedIndex(); - config.setInitReasoner(false); - setReasoner(); + public void actionPerformed(ActionEvent e) { + // read selected Class + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitReasoner(false); + setReasoner(); + } + + if (e.getSource() == setButton) { + config.setInitReasoner(false); + setReasoner(); + } + + if (e.getSource() == initButton) + init(); } - if (e.getSource() == setButton) { - config.setInitReasoner(false); - setReasoner(); + /** + * after this, you can change widgets + */ + public void setReasoner() { + if (config.isInitKnowledgeSource()) { + config.setReasoner(config.getComponentManager().reasoner( + reasoners.get(choosenClassIndex), config.getKnowledgeSource())); + updateOptionPanel(); + startGUI.updateTabColors(); + config.setInitReasoner(false); + updateInitButtonColor(); + } } - if (e.getSource() == initButton) - init(); - } + /** + * after this, next tab can be used + */ + public void init() { + setReasoner(); + if (config.getKnowledgeSource() != null && config.getReasoner() != null) { + try { + config.getReasoner().init(); + System.out.println("init Reasoner"); + // set ReasoningService + config.setReasoningService(config.getComponentManager().reasoningService( + config.getReasoner())); + System.out.println("init ReasoningService"); + config.setInitReasoner(true); + startGUI.update... [truncated message content] |