From: <ton...@us...> - 2008-02-02 05:06:49
|
Revision: 485 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=485&view=rev Author: tonytacker Date: 2008-02-01 21:06:46 -0800 (Fri, 01 Feb 2008) Log Message: ----------- changed layout- LearningProblemPanel doesn't work now - will be fixed on next commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.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/ReasonerPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-02 02:49:37 UTC (rev 484) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-02 05:06:46 UTC (rev 485) @@ -49,7 +49,9 @@ private Set<String> negExampleSet = new HashSet<String>(); private LearningProblem lp; private LearningAlgorithm la; - + private boolean[] isInit = new boolean[4]; + + protected ComponentManager getComponentManager() { return cm; } @@ -122,4 +124,70 @@ return la; } + /* + * KnowledgeSource.init has run? + * return true, if it was + */ + protected boolean isInitKnowledgeSource() { + return isInit[0]; + } + + /* + * set true if you run KnowwledgeSource.init + */ + protected void setInitKnowledgeSource(Boolean is) { + isInit[0] = is; + for (int i=1; i<4; i++) + isInit[i] = false; + } + + /* + * Reasoner.init has run? + * return true, if it was + */ + protected boolean isInitReasoner() { + return isInit[1]; + } + + /* + * set true if you run Reasoner.init + */ + protected void setInitReasoner(Boolean is) { + isInit[1] = is; + for (int i=2; i<4; i++) + isInit[i] = false; + } + + /* + * LearningProblem.init has run? + * return true, if it was + */ + protected boolean isInitLearningProblem() { + return isInit[2]; + } + + /* + * set true if you run LearningProblem.init + */ + protected void setInitLearningProblem(Boolean is) { + isInit[2] = is; + for (int i=3; i<4; i++) + isInit[i] = false; + } + + /* + * LearningAlgorithm.init() has run? + * return true, if it was + */ + protected boolean isLearningAlgorithm() { + return isInit[3]; + } + + /* + * set true if you run LearningAlgorithm.init + */ + protected void setLearningAlgorithm(Boolean is) { + isInit[3] = is; + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-02 02:49:37 UTC (rev 484) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-02 05:06:46 UTC (rev 485) @@ -103,6 +103,7 @@ */ public void init() { config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); System.out.println("init KnowledgeSource with \n" + sources.get(choosenClassIndex) + " and \n" + config.getURI() + "\n"); Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-02 02:49:37 UTC (rev 484) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-02 05:06:46 UTC (rev 485) @@ -42,7 +42,7 @@ private JPanel choosePanel = new JPanel(); private OptionPanel optionPanel; private JPanel initPanel = new JPanel(); - private JButton initButton; + private JButton initButton, getInstancesButton; private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); private int choosenClassIndex; @@ -51,29 +51,30 @@ super(new BorderLayout()); this.config = config; + learners = config.getComponentManager().getLearningAlgorithms(); initButton = new JButton("Init LearingAlgorithm"); initButton.addActionListener(this); - initPanel.add(initButton); + getInstancesButton = new JButton("Get Instances"); + getInstancesButton.addActionListener(this); - choosePanel.add(cb); - // add into comboBox - learners = config.getComponentManager().getLearningAlgorithms(); for (int i = 0; i < learners.size(); i++) { cb.addItem(config.getComponentManager().getComponentName( learners.get(i))); } + choosePanel.add(cb); + choosePanel.add(getInstancesButton); cb.addActionListener(this); optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), learners.get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); - add(initPanel, BorderLayout.CENTER); - add(optionPanel, BorderLayout.PAGE_END); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); } @@ -81,20 +82,42 @@ // read selected Class choosenClassIndex = cb.getSelectedIndex(); - // init - if (e.getSource() == initButton && config.getLearningProblem() != null) { + if (e.getSource() == getInstancesButton) + getInstances(); + + if (e.getSource() == initButton && config.getURI() != null) + init(); + } + + /* + * after this, you can change widgets + */ + public void getInstances() { + if (config.getLearningProblem() != null + && config.getReasoningService() != null) { config.setLearningAlgorithm(config.getComponentManager() .learningAlgorithm(learners.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); - System.out.println("init LearningAlgorithm"); - config.getLearningAlgorithm().init(); updateOptionPanel(); } } + /* + * after this, next tab can be used + */ + public void init() { + config.getLearningAlgorithm().init(); + System.out.println("init LearningAlgorithm"); + + } + + /* + * update OptionPanel with new selection + */ public void updateOptionPanel() { // update OptionPanel - optionPanel.update(config.getLearningAlgorithm(), learners.get(choosenClassIndex)); + optionPanel.update(config.getLearningAlgorithm(), learners + .get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-02 02:49:37 UTC (rev 484) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-02 05:06:46 UTC (rev 485) @@ -97,9 +97,12 @@ * after this, you can change widgets */ public void getInstances() { - config.setReasoner(config.getComponentManager().reasoner( - reasoners.get(choosenClassIndex), config.getKnowledgeSource())); - updateOptionPanel(); + if (config.isInitKnowledgeSource()) { + config.setReasoner(config.getComponentManager().reasoner( + reasoners.get(choosenClassIndex), + config.getKnowledgeSource())); + updateOptionPanel(); + } } /* @@ -112,6 +115,7 @@ config.setReasoningService(config.getComponentManager() .reasoningService(config.getReasoner())); System.out.println("init ReasoningService"); + config.setInitReasoner(true); } /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |