From: <ton...@us...> - 2008-02-13 19:28:35
|
Revision: 571 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=571&view=rev Author: tonytacker Date: 2008-02-13 11:28:25 -0800 (Wed, 13 Feb 2008) Log Message: ----------- please ignore - i'm thinking about a way to get old entry's 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/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/WidgetPanelBoolean.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-13 19:28:25 UTC (rev 571) @@ -20,28 +20,36 @@ * */ +import java.util.HashSet; +import java.util.Set; + import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.Component; /** * Config save all together used variables: ComponentManager, KnowledgeSource, * Reasoner, ReasoningService, LearningProblem, LearningAlgorithm; also inits of - * these components + * these components. * * @author Tilo Hielscher */ public class Config { private ComponentManager cm = ComponentManager.getInstance(); private KnowledgeSource source; + private Set<Component> oldKnowledgeSourceSet = new HashSet<Component>(); private String uri; private ReasonerComponent reasoner; + private Set<Component> oldReasonerSet = new HashSet<Component>(); private ReasoningService rs; private LearningProblem lp; + private Set<Component> oldLearningProblemSet = new HashSet<Component>(); private LearningAlgorithm la; + private Set<Component> oldLearningAlgorithmSet = new HashSet<Component>(); private boolean[] isInit = new boolean[4]; /** @@ -73,57 +81,77 @@ } /** - * Get Reasoner. + * Set KnowledgeSource. * - * @return reasoner + * @param knowledgeSource */ - public ReasonerComponent getReasoner() { - return this.reasoner; + public void setKnowledgeSource(KnowledgeSource knowledgeSource) { + this.oldKnowledgeSourceSet.add(this.source); + this.source = knowledgeSource; } /** + * Get KnowledgeSource. + * + * @return KnowledgeSource + */ + public KnowledgeSource getKnowledgeSource() { + return this.source; + } + + /** + * Get old KnowledgeSource. + * + * @return old KnowledgeSource + */ + public Set<Component> getOldKnowledgeSource() { + return this.oldKnowledgeSourceSet; + } + + /** * Set Reasoner. * * @param reasoner */ public void setReasoner(ReasonerComponent reasoner) { + this.oldReasonerSet.add(this.reasoner); this.reasoner = reasoner; } /** - * Get ReasoningService. + * Get Reasoner. * - * @return ReasoningService + * @return reasoner */ - public ReasoningService getReasoningService() { - return this.rs; + public ReasonerComponent getReasoner() { + return this.reasoner; } /** - * Set ReasoningService. + * Get old Reasoner as a set. * - * @param reasoningService + * @return oldReasonerSet. */ - public void setReasoningService(ReasoningService reasoningService) { - this.rs = reasoningService; + public Set<Component> getOldReasonerSet() { + return this.oldReasonerSet; } /** - * Get KnowledgeSource. + * Set ReasoningService. * - * @return KnowledgeSource + * @param reasoningService */ - public KnowledgeSource getKnowledgeSource() { - return this.source; + public void setReasoningService(ReasoningService reasoningService) { + this.rs = reasoningService; } /** - * Set KnowledgeSource. + * Get ReasoningService. * - * @param knowledgeSource + * @return ReasoningService */ - public void setKnowledgeSource(KnowledgeSource knowledgeSource) { - this.source = knowledgeSource; + public ReasoningService getReasoningService() { + return this.rs; } /** @@ -132,6 +160,7 @@ * @param learningProblem */ public void setLearningProblem(LearningProblem learningProblem) { + this.oldLearningProblemSet.add(this.lp); this.lp = learningProblem; } @@ -145,11 +174,21 @@ } /** + * Get old LearningProblem as a set. + * + * @return old learningProblemSet. + */ + public Set<Component> getOldLearningProblem() { + return this.oldLearningProblemSet; + } + + /** * Set LearningAlgorithm. * * @param learningAlgorithm */ public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { + this.oldLearningAlgorithmSet.add(this.la); this.la = learningAlgorithm; } @@ -163,6 +202,15 @@ } /** + * Get old LearningAlgorithmSet. + * + * @return old LearningAlgorithmSet + */ + public Set<Component> getOldLearningAlgorithm() { + return this.oldLearningAlgorithmSet; + } + + /** * KnowledgeSource.init has run? * * @return true, if init was made, false if not Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-13 19:28:25 UTC (rev 571) @@ -67,7 +67,9 @@ cb.addActionListener(this); choosePanel.add(cb); - optionPanel = new OptionPanel(config, config.getKnowledgeSource(), + optionPanel = new OptionPanel(config, + config.getKnowledgeSource(), + config.getOldKnowledgeSource(), sources.get(choosenClassIndex)); initPanel.add(initButton); @@ -121,7 +123,7 @@ * update OptionPanel with new selection */ public void updateOptionPanel() { - optionPanel.update(config.getKnowledgeSource(), sources - .get(choosenClassIndex)); + optionPanel.update(config.getKnowledgeSource(), config + .getOldKnowledgeSource(), sources.get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-13 19:28:25 UTC (rev 571) @@ -74,7 +74,8 @@ cb.addActionListener(this); optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), - learners.get(choosenClassIndex)); + config.getOldLearningAlgorithm(), learners + .get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); add(optionPanel, BorderLayout.CENTER); @@ -133,7 +134,7 @@ */ public void updateOptionPanel() { // update OptionPanel - optionPanel.update(config.getLearningAlgorithm(), learners - .get(choosenClassIndex)); + optionPanel.update(config.getLearningAlgorithm(), config + .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-13 19:28:25 UTC (rev 571) @@ -75,7 +75,7 @@ choosenClassIndex = cb.getSelectedIndex(); optionPanel = new OptionPanel(config, config.getLearningProblem(), - problems.get(choosenClassIndex)); + config.getOldLearningProblem(), problems.get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); add(optionPanel, BorderLayout.CENTER); @@ -108,8 +108,23 @@ config.setLearningProblem(config.getComponentManager() .learningProblem(problems.get(choosenClassIndex), config.getReasoningService())); + // TEST + // previous set value in old component + if (config.getLearningProblem() != null + && config.getOldLearningProblem() != null) { + System.out.println("NOW: " + + config.getLearningProblem().getClass()); + System.out.println("OLD: " + config.getOldLearningProblem()); + System.out.println("OLD contains?: " + + config.getOldLearningProblem().contains( + config.getLearningProblem().getClass())); + if (config.getLearningProblem().getClass().equals( + config.getOldLearningProblem().getClass())) { + System.out.println("--> THE SAME"); + } + } + startGUI.updateTabColors(); updateOptionPanel(); - startGUI.updateTabColors(); } } @@ -130,7 +145,7 @@ */ private void updateOptionPanel() { // update OptionPanel - optionPanel.update(config.getLearningProblem(), problems - .get(choosenClassIndex)); + optionPanel.update(config.getLearningProblem(), config + .getOldLearningProblem(), problems.get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-13 19:28:25 UTC (rev 571) @@ -25,7 +25,9 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -49,15 +51,18 @@ private List<ConfigOption<?>> optionList; private JPanel centerPanel = new JPanel(); private Component component; + private Set<Component> oldComponentSet = new HashSet<Component>(); private GridBagLayout gridBagLayout = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); public OptionPanel(Config config, Component component, + Set<Component> oldComponentSet, Class<? extends Component> componentOption) { super(new BorderLayout()); this.config = config; this.component = component; + this.oldComponentSet = oldComponentSet; this.componentOption = componentOption; optionList = ComponentManager.getConfigOptions(componentOption); @@ -71,17 +76,18 @@ centerScroller.setPreferredSize(new Dimension(400, 200)); // add Panels add(centerScroller, BorderLayout.CENTER); - + // show widgets showWidgets(); - } /** update this OptionPanel */ - public void update(Component component, + public void update(Component component, Set<Component> oldComponentSet, Class<? extends Component> componentOption) { + this.component = component; + this.oldComponentSet = oldComponentSet; this.componentOption = componentOption; - this.component = component; showWidgets(); + } /** @@ -101,7 +107,7 @@ } else if (optionList.get(i).getClass().toString().contains( "BooleanConfigOption")) { widgetPanel = new WidgetPanelBoolean(config, component, - componentOption, optionList.get(i)); + oldComponentSet, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "DoubleConfigOption")) { widgetPanel = new WidgetPanelDouble(config, component, Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-13 19:28:25 UTC (rev 571) @@ -72,8 +72,8 @@ reasoners.get(i))); } - optionPanel = new OptionPanel(config, config.getReasoner(), reasoners - .get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getReasoner(), config + .getOldReasonerSet(), reasoners.get(choosenClassIndex)); choosePanel.add(autoInitButton); cb.addActionListener(this); @@ -92,12 +92,13 @@ if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); config.setInitReasoner(false); - setReasoner(); } - if (e.getSource() == autoInitButton) + if (e.getSource() == autoInitButton) { + config.setInitReasoner(false); setReasoner(); + } if (e.getSource() == initButton) init(); @@ -121,7 +122,7 @@ * after this, next tab can be used */ public void init() { - if (/* !config.isInitReasoner() && */config.getKnowledgeSource() != null + if (config.getKnowledgeSource() != null && config.getReasoner() != null) { config.getReasoner().init(); System.out.println("init Reasoner"); @@ -140,8 +141,8 @@ * update OptionPanel with new selection */ public void updateOptionPanel() { - optionPanel.update(config.getReasoner(), reasoners - .get(choosenClassIndex)); + optionPanel.update(config.getReasoner(), config.getOldReasonerSet(), + reasoners.get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-13 19:28:25 UTC (rev 571) @@ -29,6 +29,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; +import java.util.Set; + import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; @@ -50,18 +52,20 @@ private JLabel nameLabel; private JPanel widgetPanel = new JPanel(); private Component component; + private Set<Component> oldComponentSet; private Class<? extends Component> componentOption; - private Boolean value; private String[] kbBoxItems = { "false", "true" }; private JComboBox cb = new JComboBox(kbBoxItems); public WidgetPanelBoolean(Config config, Component component, + Set<Component> oldComponentSet, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponentSet = oldComponentSet; this.componentOption = componentOption; showLabel(); // name of option and tooltip @@ -70,6 +74,7 @@ } public void actionPerformed(ActionEvent e) { + setEntry(); } @@ -92,11 +97,34 @@ .getConfigOptionValue(component, configOption.getName()); } + // previous set value from old + /* + * if (component != null && componentOld != null) { if + * (component.getClass().equals(componentOld.getClass())) { + * value = (Boolean) config.getComponentManager() + * .getConfigOptionValue(componentOld, configOption.getName()); + */ + if (component != null && oldComponentSet != null) { + if (oldComponentSet.contains(component)) { + System.out.println("oldComponentSet: " + + oldComponentSet); + // value = (Boolean) + // config.getComponentManager().getConfigOptionValue(componentOld, + // configOption.getName()); + + // set cb-index + if (value == false) + cb.setSelectedIndex(0); + else + cb.setSelectedIndex(1); + setEntry(); + } + } // default value - else if (configOption.getDefaultValue() != null) { + if (value != null && configOption.getDefaultValue() != null) { value = (Boolean) configOption.getDefaultValue(); } - // value == null + // value == null? if (value == null) { value = false; } @@ -142,4 +170,5 @@ s.printStackTrace(); } } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |