From: <ton...@us...> - 2008-02-03 04:56:16
|
Revision: 486 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=486&view=rev Author: tonytacker Date: 2008-02-02 20:55:57 -0800 (Sat, 02 Feb 2008) Log Message: ----------- LearningProblemPanel works now, add WidgetPanelStringSet for StringSetConfigOption (not implemented in GUI) 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 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 Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-03 04:55:57 UTC (rev 486) @@ -124,7 +124,7 @@ return la; } - /* + /** * KnowledgeSource.init has run? * return true, if it was */ @@ -132,7 +132,7 @@ return isInit[0]; } - /* + /** * set true if you run KnowwledgeSource.init */ protected void setInitKnowledgeSource(Boolean is) { @@ -141,7 +141,7 @@ isInit[i] = false; } - /* + /** * Reasoner.init has run? * return true, if it was */ @@ -149,7 +149,7 @@ return isInit[1]; } - /* + /** * set true if you run Reasoner.init */ protected void setInitReasoner(Boolean is) { @@ -158,7 +158,7 @@ isInit[i] = false; } - /* + /** * LearningProblem.init has run? * return true, if it was */ @@ -166,7 +166,7 @@ return isInit[2]; } - /* + /** * set true if you run LearningProblem.init */ protected void setInitLearningProblem(Boolean is) { @@ -175,7 +175,7 @@ isInit[i] = false; } - /* + /** * LearningAlgorithm.init() has run? * return true, if it was */ @@ -183,7 +183,7 @@ return isInit[3]; } - /* + /** * set true if you run LearningAlgorithm.init */ protected void setLearningAlgorithm(Boolean is) { Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-03 04:55:57 UTC (rev 486) @@ -89,7 +89,7 @@ init(); } - /* + /** * after this, you can change widgets */ public void getInstances() { @@ -98,7 +98,7 @@ updateOptionPanel(); } - /* + /** * after this, next tab can be used */ public void init() { @@ -109,7 +109,7 @@ + "\n"); } - /* + /** * update OptionPanel with new selection */ public void updateOptionPanel() { Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-03 04:55:57 UTC (rev 486) @@ -82,14 +82,14 @@ // read selected Class choosenClassIndex = cb.getSelectedIndex(); - if (e.getSource() == getInstancesButton) + if (e.getSource() == getInstancesButton && config.isInitLearningProblem()) getInstances(); - if (e.getSource() == initButton && config.getURI() != null) + if (e.getSource() == initButton && config.isInitLearningProblem()) init(); } - /* + /** * after this, you can change widgets */ public void getInstances() { @@ -103,7 +103,7 @@ } } - /* + /** * after this, next tab can be used */ public void init() { @@ -112,7 +112,7 @@ } - /* + /** * update OptionPanel with new selection */ public void updateOptionPanel() { Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-03 04:55:57 UTC (rev 486) @@ -51,11 +51,11 @@ private String[] lpBoxItems = {}; private JComboBox cb = new JComboBox(lpBoxItems); private JPanel choosePanel = new JPanel(); - private JPanel centerPanel = new JPanel(); - private JPanel lpPanel = new JPanel(); + private JPanel listPanel = new JPanel(); + private JPanel initPanel = new JPanel(); private JLabel posLabel = new JLabel("positive Examples"); private JLabel negLabel = new JLabel("negative Examples"); - private JButton initButton; + private JButton initButton, getInstancesButton; private int choosenClassIndex; private List<Individual> individuals; private JList posList = new JList(); @@ -71,9 +71,12 @@ initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); - + initPanel.add(initButton); + getInstancesButton = new JButton("Get Instances"); + getInstancesButton.addActionListener(this); choosePanel.add(cb); - choosePanel.add(initButton); + choosePanel.add(getInstancesButton); + cb.addActionListener(this); problems = config.getComponentManager().getLearningProblems(); @@ -102,33 +105,29 @@ // define GridBag GridBagLayout gridbag = new GridBagLayout(); - centerPanel.setLayout(gridbag); + listPanel.setLayout(gridbag); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; buildConstraints(constraints, 0, 0, 1, 1, 100, 100); gridbag.setConstraints(posLabel, constraints); - centerPanel.add(posLabel); + listPanel.add(posLabel); buildConstraints(constraints, 1, 0, 1, 1, 100, 100); gridbag.setConstraints(negLabel, constraints); - centerPanel.add(negLabel); + listPanel.add(negLabel); buildConstraints(constraints, 0, 1, 1, 1, 100, 100); gridbag.setConstraints(posListScroller, constraints); - centerPanel.add(posListScroller); + listPanel.add(posListScroller); buildConstraints(constraints, 1, 1, 1, 1, 100, 100); gridbag.setConstraints(negListScroller, constraints); - centerPanel.add(negListScroller); + listPanel.add(negListScroller); - buildConstraints(constraints, 0, 2, 2, 1, 100, 100); - gridbag.setConstraints(lpPanel, constraints); - centerPanel.add(lpPanel); + add(listPanel, BorderLayout.CENTER); - add(centerPanel, BorderLayout.CENTER); - // listener for posList posList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { @@ -160,11 +159,13 @@ optionPanel = new OptionPanel(config, config.getLearningProblem(), problems.get(choosenClassIndex)); - cb.addActionListener(this); + buildConstraints(constraints, 0, 2, 2, 1, 100, 100); + gridbag.setConstraints(optionPanel, constraints); + listPanel.add(optionPanel); add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); - add(optionPanel, BorderLayout.PAGE_END); + add(listPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); } @@ -172,39 +173,14 @@ // read selected LearningProblemClass choosenClassIndex = cb.getSelectedIndex(); - // init - if (e.getSource() == initButton && config.getReasoningService() != null) { - config.setLearningProblem(config.getComponentManager() - .learningProblem(problems.get(choosenClassIndex), - config.getReasoningService())); - config.getComponentManager().applyConfigEntry( - config.getLearningProblem(), "positiveExamples", - config.getPosExampleSet()); - config.getComponentManager().applyConfigEntry( - config.getLearningProblem(), "negativeExamples", - config.getNegExampleSet()); - config.getLearningProblem().init(); - System.out.println("init LearningProblem"); - updateOptionPanel(); + if (e.getSource() == getInstancesButton && config.isInitReasoner()) + getInstances(); - // lists - if (config.getReasoningService() != null) { - // fill lists - Set<Individual> individualsSet = config.getReasoningService() - .getIndividuals(); - individuals = new LinkedList<Individual>(individualsSet); - DefaultListModel listModel = new DefaultListModel(); - for (Individual ind : individuals) { - listModel.addElement(ind); - } - posList.setModel(listModel); - negList.setModel(listModel); - } - } - + if (e.getSource() == initButton && config.isInitReasoner()) + init(); } - /* + /** * Define GridBagConstraints */ private void buildConstraints(GridBagConstraints gbc, int gx, int gy, @@ -217,6 +193,47 @@ gbc.weighty = wy; } + /** + * after this, you can change widgets + */ + public void getInstances() { + config.setLearningProblem(config.getComponentManager().learningProblem( + problems.get(choosenClassIndex), config.getReasoningService())); + // lists + if (config.getReasoningService() != null) { + // fill lists + Set<Individual> individualsSet = config.getReasoningService() + .getIndividuals(); + individuals = new LinkedList<Individual>(individualsSet); + DefaultListModel listModel = new DefaultListModel(); + for (Individual ind : individuals) { + listModel.addElement(ind); + } + posList.setModel(listModel); + negList.setModel(listModel); + } + updateOptionPanel(); + } + + /** + * after this, next tab can be used + */ + public void init() { + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "positiveExamples", + config.getPosExampleSet()); + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "negativeExamples", + config.getNegExampleSet()); + config.getLearningProblem().init(); + config.setInitLearningProblem(true); + System.out.println("init LearningProblem"); + + } + + /** + * update OptionPanel with new selection + */ public void updateOptionPanel() { // update OptionPanel optionPanel.update(config.getLearningProblem(), problems Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-03 04:55:57 UTC (rev 486) @@ -109,7 +109,11 @@ "StringConfigOption")) { widgetPanel = new WidgetPanelString(config, component, componentOption, optionList.get(i)); - } else { +/* } else if (optionList.get(i).getClass().toString().contains( + "StringSetConfigOption")) { + widgetPanel = new WidgetPanelStringSet(config, component, + componentOption, optionList.get(i)); +*/ } else { widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-03 04:55:57 UTC (rev 486) @@ -93,7 +93,7 @@ init(); } - /* + /** * after this, you can change widgets */ public void getInstances() { @@ -105,7 +105,7 @@ } } - /* + /** * after this, next tab can be used */ public void init() { @@ -118,7 +118,7 @@ config.setInitReasoner(true); } - /* + /** * update OptionPanel with new selection */ public void updateOptionPanel() { Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-03 04:55:57 UTC (rev 486) @@ -120,7 +120,7 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init (Boolean)"); + JLabel noConfigOptionLabel = new JLabel("no instance (Boolean)"); noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-03 04:55:57 UTC (rev 486) @@ -121,7 +121,7 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init (Double)"); + JLabel noConfigOptionLabel = new JLabel("no instance (Double)"); noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-03 04:55:57 UTC (rev 486) @@ -122,7 +122,7 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init (Integer)"); + JLabel noConfigOptionLabel = new JLabel("no instance (Integer)"); noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-03 04:55:57 UTC (rev 486) @@ -135,7 +135,7 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init (String)"); + JLabel noConfigOptionLabel = new JLabel("no instance (String)"); noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-03 04:55:57 UTC (rev 486) @@ -0,0 +1,139 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.Color; +import java.util.Set; + +//import javax.swing.JTextField; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JButton; + +import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.StringSetConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; + +/** + * WidgetPanelStringSet + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelStringSet extends AbstractWidgetPanel implements + ActionListener { + + private static final long serialVersionUID = 7832726987046601916L; + private Config config; + private ConfigOption<?> configOption; + private JLabel nameLabel; + private JPanel widgetPanel = new JPanel(); + private JButton setButton = new JButton("Set"); + private Component component; + private Class<? extends Component> componentOption; + + private Set<String> value; + //private JTextField stringField = new JTextField(15); + + public WidgetPanelStringSet(Config config, Component component, + Class<? extends Component> componentOption, + ConfigOption<?> configOption) { + this.config = config; + this.configOption = configOption; + this.component = component; + this.componentOption = componentOption; + + showLabel(); // name of option and tooltip + showThingToChange(); // textfield, setbutton + add(widgetPanel, BorderLayout.CENTER); + } + + public JPanel getPanel() { + return this; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == setButton) { + setEntry(); + } + } + + @Override + protected void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + widgetPanel.add(nameLabel); + } + + @Override + protected void showThingToChange() { + if (component != null) { + // StringSetConfigOption + if (configOption.getClass().toString().contains( + "StringSetConfigOption")) { + setButton.addActionListener(this); + //widgetPanel.add(stringField); + widgetPanel.add(setButton); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel("not a stringSet"); + notImplementedLabel.setForeground(Color.RED); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no instance (StringSet)"); + noConfigOptionLabel.setForeground(Color.MAGENTA); + widgetPanel.add(noConfigOptionLabel); + } + + //System.out.println("value: " + value); + + + } + + @Override + protected void setEntry() { + StringSetConfigOption specialOption; + //value = stringField.getText(); // get from input + specialOption = (StringSetConfigOption) config.getComponentManager() + .getConfigOption(componentOption, configOption.getName()); + try { + ConfigEntry<Set<String>> specialEntry = new ConfigEntry<Set<String>>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set String: " + configOption.getName() + " = " + + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + + + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |