From: <ton...@us...> - 2008-02-14 15:08:52
|
Revision: 572 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=572&view=rev Author: tonytacker Date: 2008-02-14 07:08:47 -0800 (Thu, 14 Feb 2008) Log Message: ----------- "Set"-button on top reloads now previous made entry from last component. You can change i.e. KnowledgeSource and can initiate the other tabulators (Reasoner, LerningProblem, LearningAlgorithm) without setting your options again. 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/KnowledgeSourcePanel.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/WidgetPanelBoolean.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-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-14 15:08:47 UTC (rev 572) @@ -81,11 +81,11 @@ * Is a Set of Strings. */ public void setSelections(Set<String> selectionSet) { - for (int i = 0; i < list.size(); i++) { + for (int i = 0; i < this.list.size(); i++) { if (selectionSet.contains(list.get(i).getText())) list.get(i).setSelected(true); else - list.get(i).setSelected(false); + this.list.get(i).setSelected(false); } } Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-14 15:08:47 UTC (rev 572) @@ -20,16 +20,12 @@ * */ -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, @@ -41,15 +37,15 @@ public class Config { private ComponentManager cm = ComponentManager.getInstance(); private KnowledgeSource source; - private Set<Component> oldKnowledgeSourceSet = new HashSet<Component>(); + private KnowledgeSource oldSource; private String uri; private ReasonerComponent reasoner; - private Set<Component> oldReasonerSet = new HashSet<Component>(); + private ReasonerComponent oldReasoner; private ReasoningService rs; private LearningProblem lp; - private Set<Component> oldLearningProblemSet = new HashSet<Component>(); + private LearningProblem oldLearningProblem; private LearningAlgorithm la; - private Set<Component> oldLearningAlgorithmSet = new HashSet<Component>(); + private LearningAlgorithm oldLearningAlgorithm; private boolean[] isInit = new boolean[4]; /** @@ -86,7 +82,7 @@ * @param knowledgeSource */ public void setKnowledgeSource(KnowledgeSource knowledgeSource) { - this.oldKnowledgeSourceSet.add(this.source); + this.oldSource = this.source; this.source = knowledgeSource; } @@ -104,8 +100,8 @@ * * @return old KnowledgeSource */ - public Set<Component> getOldKnowledgeSource() { - return this.oldKnowledgeSourceSet; + public KnowledgeSource getOldKnowledgeSource() { + return this.oldSource; } /** @@ -114,7 +110,7 @@ * @param reasoner */ public void setReasoner(ReasonerComponent reasoner) { - this.oldReasonerSet.add(this.reasoner); + this.oldReasoner = this.reasoner; this.reasoner = reasoner; } @@ -132,8 +128,8 @@ * * @return oldReasonerSet. */ - public Set<Component> getOldReasonerSet() { - return this.oldReasonerSet; + public ReasonerComponent getOldReasonerSet() { + return this.oldReasoner; } /** @@ -160,7 +156,7 @@ * @param learningProblem */ public void setLearningProblem(LearningProblem learningProblem) { - this.oldLearningProblemSet.add(this.lp); + this.oldLearningProblem = this.lp; this.lp = learningProblem; } @@ -178,8 +174,8 @@ * * @return old learningProblemSet. */ - public Set<Component> getOldLearningProblem() { - return this.oldLearningProblemSet; + public LearningProblem getOldLearningProblem() { + return this.oldLearningProblem; } /** @@ -188,7 +184,7 @@ * @param learningAlgorithm */ public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { - this.oldLearningAlgorithmSet.add(this.la); + this.oldLearningAlgorithm = this.la; this.la = learningAlgorithm; } @@ -206,8 +202,8 @@ * * @return old LearningAlgorithmSet */ - public Set<Component> getOldLearningAlgorithm() { - return this.oldLearningAlgorithmSet; + public LearningAlgorithm getOldLearningAlgorithm() { + return this.oldLearningAlgorithm; } /** Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-14 15:08:47 UTC (rev 572) @@ -40,6 +40,7 @@ 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(); @@ -55,6 +56,8 @@ this.startGUI = startGUI; sources = config.getComponentManager().getKnowledgeSources(); + setButton = new JButton ("Set"); + setButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); initButton.addActionListener(this); initButton.setEnabled(true); @@ -67,10 +70,9 @@ cb.addActionListener(this); choosePanel.add(cb); - optionPanel = new OptionPanel(config, - config.getKnowledgeSource(), - config.getOldKnowledgeSource(), - sources.get(choosenClassIndex)); + choosePanel.add(setButton); + optionPanel = new OptionPanel(config, config.getKnowledgeSource(), + config.getOldKnowledgeSource(), sources.get(choosenClassIndex)); initPanel.add(initButton); add(choosePanel, BorderLayout.PAGE_START); @@ -91,6 +93,9 @@ setSource(); } + if (e.getSource() == setButton) + setSource(); + if (e.getSource() == initButton) init(); } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-14 15:08:47 UTC (rev 572) @@ -108,21 +108,6 @@ 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(); } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-14 15:08:47 UTC (rev 572) @@ -25,9 +25,7 @@ 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; @@ -51,18 +49,17 @@ private List<ConfigOption<?>> optionList; private JPanel centerPanel = new JPanel(); private Component component; - private Set<Component> oldComponentSet = new HashSet<Component>(); + private Component oldComponent; private GridBagLayout gridBagLayout = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); public OptionPanel(Config config, Component component, - Set<Component> oldComponentSet, - Class<? extends Component> componentOption) { + Component oldComponent, Class<? extends Component> componentOption) { super(new BorderLayout()); this.config = config; this.component = component; - this.oldComponentSet = oldComponentSet; + this.oldComponent = oldComponent; this.componentOption = componentOption; optionList = ComponentManager.getConfigOptions(componentOption); @@ -81,10 +78,10 @@ } /** update this OptionPanel */ - public void update(Component component, Set<Component> oldComponentSet, + public void update(Component component, Component oldComponent, Class<? extends Component> componentOption) { this.component = component; - this.oldComponentSet = oldComponentSet; + this.oldComponent = oldComponent; this.componentOption = componentOption; showWidgets(); @@ -103,30 +100,30 @@ if (optionList.get(i).getClass().toString().contains( "IntegerConfigOption")) { widgetPanel = new WidgetPanelInteger(config, component, - componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "BooleanConfigOption")) { widgetPanel = new WidgetPanelBoolean(config, component, - oldComponentSet, componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "DoubleConfigOption")) { widgetPanel = new WidgetPanelDouble(config, component, - componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "StringConfigOption")) { widgetPanel = new WidgetPanelString(config, component, - componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "StringSetConfigOption")) { widgetPanel = new WidgetPanelStringSet(config, component, - componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "StringTupleListConfigOption")) { widgetPanel = new WidgetPanelStringTupleList(config, component, - componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else { widgetPanel = new WidgetPanelDefault(config, component, - componentOption, optionList.get(i)); + /* oldComponent, */componentOption, optionList.get(i)); } gridBagLayout.setConstraints(widgetPanel, constraints); centerPanel.add(widgetPanel); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-14 15:08:47 UTC (rev 572) @@ -29,8 +29,6 @@ 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; @@ -52,20 +50,19 @@ private JLabel nameLabel; private JPanel widgetPanel = new JPanel(); private Component component; - private Set<Component> oldComponentSet; + private Component oldComponent; 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, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; - this.oldComponentSet = oldComponentSet; + this.oldComponent = oldComponent; this.componentOption = componentOption; showLabel(); // name of option and tooltip @@ -98,26 +95,20 @@ 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()); - + if (component != null && oldComponent != null) { + if (oldComponent.getClass().equals(component.getClass())) { + value = (Boolean) config.getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value == null) + value = false; + else + setEntry(); // set cb-index if (value == false) cb.setSelectedIndex(0); else cb.setSelectedIndex(1); - setEntry(); } } // default value Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-14 15:08:47 UTC (rev 572) @@ -53,17 +53,19 @@ private JPanel widgetPanel = new JPanel(); private JButton setButton = new JButton("Set"); private Component component; + private Component oldComponent; private Class<? extends Component> componentOption; private Double value; private JTextField doubleField = new JTextField(5); public WidgetPanelDouble(Config config, Component component, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponent = oldComponent; this.componentOption = componentOption; showLabel(); // name of option and tooltip @@ -96,6 +98,20 @@ .getConfigOptionValue(component, configOption.getName()); } + // previous set value from old + if (component != null && oldComponent != null) { + if (oldComponent.getClass().equals(component.getClass())) { + value = (Double) config.getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value == null) + value = 0.0; + else { + doubleField.setText(value.toString()); + setEntry(); + } + } + } // default value else if (configOption.getDefaultValue() != null) { value = (Double) configOption.getDefaultValue(); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-14 15:08:47 UTC (rev 572) @@ -54,17 +54,19 @@ private JPanel widgetPanel = new JPanel(); private JButton setButton = new JButton("Set"); private Component component; + private Component oldComponent; private Class<? extends Component> componentOption; private Integer value; private JTextField integerField = new JTextField(3); public WidgetPanelInteger(Config config, Component component, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponent = oldComponent; this.componentOption = componentOption; showLabel(); // name of option and tooltip @@ -97,6 +99,20 @@ .getConfigOptionValue(component, configOption.getName()); } + // previous set value from old + if (component != null && oldComponent != null) { + if (oldComponent.getClass().equals(component.getClass())) { + value = (Integer) config.getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value == null) + value = 0; + else { + integerField.setText(value.toString()); + setEntry(); + } + } + } // default value else if (configOption.getDefaultValue() != null) { value = (Integer) configOption.getDefaultValue(); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-14 15:08:47 UTC (rev 572) @@ -55,17 +55,19 @@ private JPanel widgetPanel = new JPanel(); private JButton setButton = new JButton("Set"); private Component component; + private Component oldComponent; private Class<? extends Component> componentOption; private String value; private JTextField stringField = new JTextField(35); public WidgetPanelString(Config config, Component component, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponent = oldComponent; this.componentOption = componentOption; showLabel(); // name of option and tooltip @@ -115,6 +117,18 @@ .getConfigOptionValue(component, configOption.getName()); } + // previous set value from old + if (component != null && oldComponent != null) { + if (oldComponent.getClass().equals(component.getClass())) { + value = (String) config.getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value != null) { + stringField.setText(value.toString()); + setEntry(); + } + } + } // default value else if (configOption.getDefaultValue() != null) { value = (String) configOption.getDefaultValue(); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-14 15:08:47 UTC (rev 572) @@ -73,6 +73,7 @@ private JTextField stringField = new JTextField(25); private Component component; + private Component oldComponent; private Class<? extends Component> componentOption; private Set<String> value = new HashSet<String>(); @@ -83,12 +84,13 @@ private CheckBoxList cBL = new CheckBoxList(); public WidgetPanelStringSet(Config config, Component component, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponent = oldComponent; this.componentOption = componentOption; widgetPanel.setLayout(gridbag); @@ -167,7 +169,18 @@ value = (Set<String>) config.getComponentManager() .getConfigOptionValue(component, configOption.getName()); - + // previous set value from old + if (component != null && oldComponent != null) { + if (oldComponent.getClass() + .equals(component.getClass())) { + value = (Set<String>) config.getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value != null) { + setEntry(); + } + } + } // fill list if (value != null) { for (Iterator<String> iterator = value.iterator(); iterator @@ -177,6 +190,7 @@ } } } + if (!isSpecial()) { // NORMAL LAYOUT // stringField @@ -215,8 +229,6 @@ buildConstraints(constraints, 1, 1, 1, 1, 100, 100); gridbag.setConstraints(setButton, constraints); widgetPanel.add(setButton, constraints); - // set selections - cBL.setSelections(value); // DEFINE LIST // positiveExamples or negativeExamples if (configOption.getName().equalsIgnoreCase( @@ -256,6 +268,9 @@ for (ObjectProperty ind : atomicRoles) cBL.add(ind.getName()); } + // set selections + if (value != null) + cBL.setSelections(value); } } // UNKNOWN Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-02-14 15:08:47 UTC (rev 572) @@ -72,6 +72,7 @@ private List<StringTuple> exampleList = new LinkedList<StringTuple>(); private Component component; + private Component oldComponent; private Class<? extends Component> componentOption; private List<StringTuple> value = new LinkedList<StringTuple>(); @@ -81,12 +82,13 @@ private JButton setButton = new JButton("set"); public WidgetPanelStringTupleList(Config config, Component component, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponent = oldComponent; this.componentOption = componentOption; widgetPanel.setLayout(gridbag); @@ -156,7 +158,20 @@ value = (List<StringTuple>) config.getComponentManager() .getConfigOptionValue(component, configOption.getName()); - + // previous set value from old + if (component != null && oldComponent != null) { + if (oldComponent.getClass() + .equals(component.getClass())) { + value = (List<StringTuple>) config + .getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value != null) { + setEntry(); + exampleList = value; + } + } + } // fill list if (value != null) { for (Iterator<StringTuple> iterator = value.iterator(); iterator This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |