From: <ton...@us...> - 2008-01-18 18:49:54
|
Revision: 394 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=394&view=rev Author: tonytacker Date: 2008-01-18 10:49:49 -0800 (Fri, 18 Jan 2008) Log Message: ----------- + all reasoners + all LearningAlgorithms Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-18 16:40:00 UTC (rev 393) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-18 18:49:49 UTC (rev 394) @@ -22,12 +22,12 @@ import javax.swing.*; -import org.dllearner.algorithms.refinement.ROLearner; - import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.List; +import org.dllearner.core.LearningAlgorithm; /** @@ -40,30 +40,49 @@ public class LearningAlgorithmPanel extends JPanel implements ActionListener { private static final long serialVersionUID = 8721490771860452959L; + private Config config; + private List<Class<? extends LearningAlgorithm>> learners; + private JPanel choosePanel = new JPanel(); + private JPanel initPanel = new JPanel(); + private JButton initButton; + private String[] cbItems = {}; + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; - private JPanel laPanel = new JPanel(); - private JButton laButton; - private Config config; - LearningAlgorithmPanel(Config config) { super(new BorderLayout()); this.config = config; - laButton = new JButton("Use ROLearner"); - laButton.addActionListener(this); + initButton = new JButton("Init LearingAlgorithm"); + initButton.addActionListener(this); - laPanel.add(laButton); - add(laPanel, BorderLayout.PAGE_START); + initPanel.add(initButton); + choosePanel.add(cb); + + add(choosePanel, BorderLayout.PAGE_START); + add(initPanel, BorderLayout.PAGE_END); + + // add into comboBox + learners = config.getComponentManager().getLearningAlgorithms(); + for (int i=0; i<learners.size(); i++) { + cb.addItem(learners.get(i).getSimpleName()); + } } public void actionPerformed(ActionEvent e) { - if (e.getSource() == laButton) { + // read selected Class + choosenClassIndex = cb.getSelectedIndex(); + + if (e.getSource() == initButton) { if (config.getStatus(6)) { - config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm(ROLearner.class, config.getLearningProblem(), config.getReasoningService())); + config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm(learners.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); config.getLearningAlgorithm().init(); } + if (config.getStatus(5)) { // exemples are set + System.out.println("LearningAlgorithm: " + config.getLearningAlgorithm() + "\n"); + } } } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-18 16:40:00 UTC (rev 393) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-18 18:49:49 UTC (rev 394) @@ -23,50 +23,62 @@ import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.List; import javax.swing.*; -import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.core.ReasonerComponent; -//import org.dllearner.core.ReasonerComponent; -//import org.dllearner.reasoning.DIGReasoner; -//import org.dllearner.core.ComponentManager; -//import org.dllearner.core.ReasoningService; - /** * ReasonerPanel * * @author Tilo Hielscher * */ - public class ReasonerPanel extends JPanel implements ActionListener { private static final long serialVersionUID = -7678275020058043937L; - private JPanel digPanel = new JPanel(); + private List<Class<? extends ReasonerComponent>> reasoners; + private JPanel choosePanel = new JPanel(); + private JPanel initPanel = new JPanel(); private JButton initButton; private Config config; - + private String[] cbItems = {}; + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; + ReasonerPanel(final Config config) { super(new BorderLayout()); this.config = config; - initButton = new JButton("Use DIG by default"); + initButton = new JButton("Init Reasoner"); initButton.addActionListener(this); + initPanel.add(initButton); - digPanel.add(initButton); - add(digPanel, BorderLayout.PAGE_START); + choosePanel.add(cb); + + add(choosePanel, BorderLayout.PAGE_START); + add(initPanel, BorderLayout.PAGE_END); + + // add into comboBox + reasoners = config.getComponentManager().getReasonerComponents(); + for (int i=0; i<reasoners.size(); i++) { + cb.addItem(reasoners.get(i).getSimpleName()); + } } public void actionPerformed(ActionEvent e) { + // read selected Class + choosenClassIndex = cb.getSelectedIndex(); + if (e.getSource() == initButton) { - if (config.getStatus(2)) { // no check if button init was used + if (config.getStatus(2)) { // no check if button initKnowledgeSource was pressed // set reasoner - config.setReasoner(config.getComponentManager().reasoner(DIGReasoner.class, config.getKnowledgeSource())); + config.setReasoner(config.getComponentManager().reasoner(reasoners.get(choosenClassIndex), config.getKnowledgeSource())); config.getReasoner().init(); // set ReasoningService This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |