From: <ton...@us...> - 2008-01-03 15:33:45
|
Revision: 338 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=338&view=rev Author: tonytacker Date: 2008-01-03 07:33:41 -0800 (Thu, 03 Jan 2008) Log Message: ----------- version 1 Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java Added 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/OutputPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/Startgui$1.class trunk/src/dl-learner/org/dllearner/gui/Startgui.class Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/gui/StartGUI_v4.java Modified: trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java 2008-01-02 13:52:44 UTC (rev 337) +++ trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java 2008-01-03 15:33:41 UTC (rev 338) @@ -37,6 +37,7 @@ ComponentManager cm = ComponentManager.getInstance(); List<Class<? extends KnowledgeSource>> sources = cm.getKnowledgeSources(); cm.knowledgeSource(sources.get(0)); + System.out.println(sources.get(1).toString()); } } Added: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-03 15:33:41 UTC (rev 338) @@ -0,0 +1,123 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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.io.File; +import java.util.List; + +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.dl.Individual; + +/** + * config + * + * this class save all together used variables + * + * @author Tilo Hielscher + * + */ + +public class Config { + protected static ComponentManager cm = ComponentManager.getInstance(); + protected static KnowledgeSource source; + protected static File selectedFile; + protected static ReasonerComponent reasoner; + protected static ReasoningService rs; + protected static List<Individual> individuals; + protected static String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; + + /** + * status should show witch variables are set + * status[0] ... cm + * status[1] ... KnowledgeSource + * status[2] ... File or URL + * status[3] ... + */ + protected static boolean[] status = new boolean[8]; + + protected boolean getStatus(int position) { + if (status[position]) + return true; + else + return false; + } + + protected ComponentManager getComponentManager() { + return cm; + } + + protected void setComponentManager (ComponentManager input) { + cm = input; + } + + protected File getFile () { + return selectedFile; + } + + protected void setFile (File input) { + status[2] = true; + selectedFile = input; + } + + protected ReasonerComponent getReasoner () { + return reasoner; + } + + protected void setReasoner (ReasonerComponent input) { + status[3] = true; + reasoner = input; + } + + + protected ReasoningService getReasoningService () { + return rs; + } + + protected void setReasoningService (ReasoningService input) { + status[4] = true; + rs = input; + } + + protected List<Individual> getListIndividuals () { + return individuals; + } + + protected void setListIndividuals (List<Individual> input) { + individuals = input; + } + + protected String[] getKBBoxItems() { + return kbBoxItems; + } + + protected KnowledgeSource getKnowledgeSource() { + status[1] = true; + return source; + } + + protected void setKnowledgeSource(KnowledgeSource input) { + source = input; + } + +} Added: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-03 15:33:41 UTC (rev 338) @@ -0,0 +1,122 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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.io.File; +//import java.util.List; + +import javax.swing.*; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import org.dllearner.kb.OWLFile; +import org.dllearner.kb.KBFile; + + + +/** + * KnowledgeSourcePanel + * + * @author Tilo Hielscher + * + */ + +public class KnowledgeSourcePanel extends JPanel implements ActionListener { + + private static final long serialVersionUID = -7678275020058043937L; + + private JFileChooser fc; + private JButton openButton; + private JTextField fileDisplay; + private String[] kbBoxItems = StartGUI.config.getKBBoxItems(); + private JComboBox cb = new JComboBox(kbBoxItems); + private JPanel openPanel = new JPanel(); + + KnowledgeSourcePanel() { + super(new BorderLayout()); + + fc = new JFileChooser(new File("examples/")); + openButton = new JButton("Open File"); + openButton.addActionListener(this); + fileDisplay = new JTextField(35); + fileDisplay.setEditable(false); + + // test output + //List<Class<? extends KnowledgeSource>> sources = config.getComponentManager().getKnowledgeSources(); + //for (int i=0; i<sources.size(); i++) cb.addItem(sources.get(i)); + cb.addActionListener(this); + + JPanel choosePanel = new JPanel(); + choosePanel.add(cb); + + add(choosePanel, BorderLayout.PAGE_START); + add(openPanel, BorderLayout.CENTER); + } + + public void actionPerformed(ActionEvent e) { + // open File + if (e.getSource() == openButton) { + int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + StartGUI.config.setFile(fc.getSelectedFile()); //save variable + fileDisplay.setText(StartGUI.config.getFile().toString()); + StartGUI.config.getComponentManager().applyConfigEntry(StartGUI.config.getKnowledgeSource(), "url", StartGUI.config.getFile().toURI().toString()); + StartGUI.config.getKnowledgeSource().init(); + } + } + // choose none + if (cb.getSelectedItem().toString() == kbBoxItems[0]) { + System.out.println("Item: " + cb.getSelectedItem()); + makeCenterClean(); + } + // choose KB class + if (cb.getSelectedItem().toString() == kbBoxItems[1]) { + System.out.println("Item: " + cb.getSelectedItem()); + makeCenterClean(); + openPanel.add(fileDisplay); + openPanel.add(openButton); + openPanel.repaint(); + StartGUI.config.setKnowledgeSource(StartGUI.config.getComponentManager().knowledgeSource(KBFile.class)); + } + // choose OWL class + if (cb.getSelectedItem().toString() == kbBoxItems[2]) { + makeCenterClean(); + openPanel.add(fileDisplay); + openPanel.add(openButton); + openPanel.repaint(); + StartGUI.config.setKnowledgeSource(StartGUI.config.getComponentManager().knowledgeSource(OWLFile.class)); + } + // choose SPARCLE class + if (cb.getSelectedItem().toString() == kbBoxItems[3]) { + System.out.println("Item: " + cb.getSelectedItem()); + makeCenterClean(); + } + } + + private void makeCenterClean() { + openPanel.remove(fileDisplay); + openPanel.remove(openButton); + openPanel.repaint(); + StartGUI.renew(); + } +} Added: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-03 15:33:41 UTC (rev 338) @@ -0,0 +1,39 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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 javax.swing.*; + +/** + * LearningAlgorithmPanel + * + * @author Tilo Hielscher + * + */ + +public class LearningAlgorithmPanel extends JPanel { + + private static final long serialVersionUID = 8721490771860452959L; + + LearningAlgorithmPanel() { + + } +} Added: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-03 15:33:41 UTC (rev 338) @@ -0,0 +1,39 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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 javax.swing.*; + +/** + * LearningProblemPanel + * + * @author Tilo Hielscher + * + */ + +public class LearningProblemPanel extends JPanel { + + private static final long serialVersionUID = -3819627680918930203L; + + LearningProblemPanel() { + + } +} Added: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-03 15:33:41 UTC (rev 338) @@ -0,0 +1,71 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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 javax.swing.*; + +/** + * OutputPanel + * + * @author Tilo Hielscher + * + */ + +public class OutputPanel extends JPanel implements ActionListener { + + private static final long serialVersionUID = 1643304576470046636L; + + private JButton showButton; + private JTextArea infoArea; + + OutputPanel() { + super(new BorderLayout()); + + showButton = new JButton("Show Variables"); + showButton.addActionListener(this); + infoArea = new JTextArea(20,40); + + JPanel showPanel = new JPanel(); + showPanel.add(showButton); + JPanel infoPanel = new JPanel(); + infoPanel.add(infoArea); + + add(showPanel, BorderLayout.PAGE_START); + add(infoPanel, BorderLayout.CENTER); + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == showButton) { + if (StartGUI.config.getStatus(1)) { // file is selected and exist? + infoArea.append("SourceClass: " + StartGUI.config.getKnowledgeSource().toString() + "\n"); + infoArea.append("FILE: " + StartGUI.config.getFile().toString() + "\n"); + } + if (StartGUI.config.getStatus(2)) { + + } + + } + } +} Added: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-03 15:33:41 UTC (rev 338) @@ -0,0 +1,99 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.*; + +import org.dllearner.reasoning.DIGReasoner; + +//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 JPanel centerPanel = new JPanel(); + private JButton digButton; + private JList digList = new JList(); + + ReasonerPanel() { + super(new BorderLayout()); + + digButton = new JButton("Use DIG by default"); + digButton.addActionListener(this); + + // create a scrollable list of examples + digList.setLayoutOrientation(JList.VERTICAL); + digList.setVisibleRowCount(-1); + JScrollPane listScroller = new JScrollPane(digList); + listScroller.setPreferredSize(new Dimension(250, 80)); + centerPanel.add(listScroller); + + digPanel.add(digButton); + add(digPanel, BorderLayout.PAGE_START); + + centerPanel.add(digList); + add(centerPanel, BorderLayout.CENTER); + + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == digButton) { // DIG + StartGUI.config.setReasoner(StartGUI.config.getComponentManager().reasoner(DIGReasoner.class, StartGUI.config.getKnowledgeSource())); + //StartGUI.config.getReasoner().init(); //error + System.out.println("test"); + + //config.setReasoningService(config.getComponentManager().reasoningService(config.getReasoner())); + + // set list + //Set<Individual> individualsSet = config.getReasoningService().getIndividuals(); + //config.setListIndividuals(new LinkedList<Individual>(individualsSet)); + + // graphic + //DefaultListModel listModel = new DefaultListModel(); + //for(Individual ind : config.getListIndividuals()) + //listModel.addElement(ind); + + // graphic + //Set<String> exampleSet = new HashSet<String>(); + //int[] selectedIndices = digList.getSelectedIndices(); + //for(int i : selectedIndices) + //exampleSet.add(config.getListIndividuals().get(i).toString()); + } + } +} Added: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-03 15:33:41 UTC (rev 338) @@ -0,0 +1,71 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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 javax.swing.*; + +/** + * StartGUI + * + * @author Tilo Hielscher + * + */ + +public class StartGUI extends JFrame { + + private static final long serialVersionUID = -739265982906533775L; + + public static Config config = new Config(); + + private static final JTabbedPane tabPane = new JTabbedPane(); + private JPanel tab1 = new JPanel(); + private JPanel tab2 = new JPanel(); + private JPanel tab3 = new JPanel(); + private JPanel tab4 = new JPanel(); + private JPanel tab5 = new JPanel(); + + public StartGUI() { + this.setTitle("DL-Learner GUI"); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLocationByPlatform(true); + this.setSize(640, 480); + tab1.add(new KnowledgeSourcePanel()); + tab2.add(new ReasonerPanel()); + tab3.add(new LearningProblemPanel()); + tab4.add(new LearningAlgorithmPanel()); + tab5.add(new OutputPanel()); + tabPane.addTab("Knowledge Source", tab1); + tabPane.addTab("Reasoner", tab2); + tabPane.addTab("Learning Problem", tab3); + tabPane.addTab("Learning Algortihm", tab4); + tabPane.addTab("Output", tab5); + this.add(tabPane); + this.setVisible(true); + } + + public static void main(String[] args) { + new StartGUI(); + } + + protected static void renew() { + tabPane.repaint(); + } +} Deleted: trunk/src/dl-learner/org/dllearner/gui/StartGUI_v4.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI_v4.java 2008-01-02 13:52:44 UTC (rev 337) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI_v4.java 2008-01-03 15:33:41 UTC (rev 338) @@ -1,214 +0,0 @@ -package org.dllearner.gui; - -//File : gui/containers/dialogs/filechooser/CountWords.java -//Purpose: Counts words in file. -// Illustrates menus, JFileChooser, Scanner.. -//Author : Fred Swartz - 2006-10-10 - Placed in public domain. - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -//import org.dllearner.algorithms.RandomGuesser; -//import org.dllearner.core.Component; -import org.dllearner.core.ComponentManager; -import org.dllearner.core.KnowledgeSource; -//import org.dllearner.core.LearningAlgorithm; -//import org.dllearner.core.LearningProblem; -//import org.dllearner.core.ReasonerComponent; -//import org.dllearner.core.ReasoningService; -import org.dllearner.kb.OWLFile; -//import org.dllearner.learningproblems.PosNegDefinitionLP; -//import org.dllearner.reasoning.DIGReasoner; - -import java.io.*; -import java.util.*; - -////////////////////////////////////////////////////////CountWords -public class StartGUI_v4 extends JFrame { - - - /** - * - */ - private static final long serialVersionUID = 9151367563590748364L; - -//====================================================== fields - JTextField _fileNameTF = new JTextField(15); - JTextField _wordCountTF = new JTextField(4); - JFileChooser _fileChooser = new JFileChooser(); - JTextArea _textField = new JTextArea(); - ComponentManager cm = ComponentManager.getInstance(); // create singleton instance - - //================================================= constructor - StartGUI_v4() { - //... Create / set component characteristics. - _fileNameTF.setEditable(false); - _wordCountTF.setEditable(false); - - //... Add listeners <-- extra classes - - //... Create content pane, layout components - JPanel content = new JPanel(); - content.setLayout(new FlowLayout()); - content.add(new JLabel("File:")); // name of opend file - content.add(_fileNameTF); - content.add(new JLabel("Word Count:")); // test - content.add(_wordCountTF); // test - content.add(_textField); // test_output - - //... Create menu elements (menubar, menu, menu item) - JMenuBar menubar = new JMenuBar(); - JMenu fileMenu = new JMenu("File"); - JMenuItem openItem = new JMenuItem("Open"); - openItem.addActionListener(new OpenAction()); - JMenuItem saveItem = new JMenuItem("Save"); - saveItem.addActionListener(new SaveAction()); - JMenuItem exitItem = new JMenuItem("Exit"); - exitItem.addActionListener(new ExitAction()); - - - //... Assemble the menu - menubar.add(fileMenu); - fileMenu.add(openItem); - //fileMenu.add(saveItem); - fileMenu.add(exitItem); - - //... _textField (TextArea) into a JScrollPane - JScrollPane scrollPane = new JScrollPane(_textField); - scrollPane.setPreferredSize(new Dimension(320, 240)); - - //... Set window characteristics - this.setJMenuBar(menubar); - this.setContentPane(content); - this.setTitle("DL-Learner"); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.add(scrollPane); - this.pack(); // Layout components. - this.setLocationRelativeTo(null); // Center window. - - // RUN - - - //System.out.println("components"); - //System.out.println(cm.getComponents()); // show components - //System.out.println("knowledgeSources"); - //System.out.println(cm.getKnowledgeSources()); // possible sources - - - -/* - // create DIG reasoning service with standard settings - ReasonerComponent reasoner = cm.reasoner(DIGReasoner.class, source); - // ReasoningService rs = cm.reasoningService(DIGReasonerNew.class, source); - reasoner.init(); - ReasoningService rs = cm.reasoningService(reasoner); - - // create a learning problem and set positive and negative examples - LearningProblem lp = cm.learningProblem(PosNegDefinitionLP.class, rs); - Set<String> positiveExamples = new TreeSet<String>(); - positiveExamples.add("http://example.com/father#stefan"); - positiveExamples.add("http://example.com/father#markus"); - positiveExamples.add("http://example.com/father#martin"); - Set<String> negativeExamples = new TreeSet<String>(); - negativeExamples.add("http://example.com/father#heinz"); - negativeExamples.add("http://example.com/father#anna"); - negativeExamples.add("http://example.com/father#michelle"); - cm.applyConfigEntry(lp, "positiveExamples", positiveExamples); - cm.applyConfigEntry(lp, "negativeExamples", negativeExamples); - lp.init(); - - // create the learning algorithm - LearningAlgorithm la = cm.learningAlgorithm(RandomGuesser.class, lp, rs); - cm.applyConfigEntry(la, "numberOfTrees", 100); - cm.applyConfigEntry(la, "maxDepth", 5); - la.init(); - - // start the algorithm and print the best concept found - //la.start(); - //System.out.println(la.getBestSolution()); -*/ - - } - - // a test method - //============================================= countWordsInFile - private int countWordsInFile(File f) { - - int numberOfWords = 0; // Count of words. - - try { - Scanner in = new Scanner(f); - - while (in.hasNext()) { - String word = in.next(); // Read a "token". - numberOfWords++; - } - in.close(); // Close Scanner's file. - - } catch (FileNotFoundException fnfex) { - // ... We just got the file from the JFileChooser, - // so it's hard to believe there's problem, but... - JOptionPane.showMessageDialog(StartGUI_v4.this, - fnfex.getMessage()); - } - return numberOfWords; - } - - - ///////////////////////////////////////////////////// OpenAction - class OpenAction implements ActionListener { - public void actionPerformed(ActionEvent ae) { - //... Open a file dialog. - int retval = _fileChooser.showOpenDialog(StartGUI_v4.this); - if (retval == JFileChooser.APPROVE_OPTION) { - //... The user selected a file, get it, use it. - File file = _fileChooser.getSelectedFile(); - - //... Update user interface. - _fileNameTF.setText(file.getName()); - _wordCountTF.setText("" + countWordsInFile(file)); - //show file in _textField - try { - _textField.read(new FileReader(file), ""); - } catch (Exception e) { - e.printStackTrace(); - } - // create knowledge source - KnowledgeSource source = cm.knowledgeSource(OWLFile.class); - //String example = "examples/father.owl"; - cm.applyConfigEntry(source, "url", file.toURI().toString()); - source.init(); - } - } - } - - ///////////////////////////////////////////////////// OpenAction - class SaveAction implements ActionListener { - public void actionPerformed(ActionEvent ae) { - //... Open a file dialog. - int retval = _fileChooser.showOpenDialog(StartGUI_v4.this); - if (retval == JFileChooser.APPROVE_OPTION) { - //... The user selected a file, get it, use it. - File file = _fileChooser.getSelectedFile(); - - //... Update user interface. - _fileNameTF.setText(file.getName()); - _wordCountTF.setText("" + countWordsInFile(file)); - } - } - } - - ///////////////////////////////////////////////////// ExitAction - class ExitAction implements ActionListener { - public void actionPerformed(ActionEvent ae) { - System.exit(0); - } - } - - //========================================================= main - public static void main(String[] args) { - JFrame window = new StartGUI_v4(); - window.setVisible(true); - } -} \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/gui/Startgui$1.class =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/gui/Startgui$1.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dl-learner/org/dllearner/gui/Startgui.class =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/gui/Startgui.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-06 18:47:25
|
Revision: 345 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=345&view=rev Author: tonytacker Date: 2008-01-06 10:47:12 -0800 (Sun, 06 Jan 2008) Log Message: ----------- you can choose owl and load a file at first tab (knowledgesource) - control over last tab (output) - by choosing dig (tab 2) it crash, don't know why - init doesn't work 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/OutputPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-06 15:14:35 UTC (rev 344) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-06 18:47:12 UTC (rev 345) @@ -45,7 +45,7 @@ protected static ReasonerComponent reasoner; protected static ReasoningService rs; protected static List<Individual> individuals; - protected static String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; + protected String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; /** * status should show witch variables are set Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-06 15:14:35 UTC (rev 344) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-06 18:47:12 UTC (rev 345) @@ -21,7 +21,7 @@ */ import java.io.File; -//import java.util.List; +import java.util.List; import javax.swing.*; @@ -32,6 +32,7 @@ import org.dllearner.kb.OWLFile; import org.dllearner.kb.KBFile; +import org.dllearner.core.KnowledgeSource; /** @@ -48,10 +49,10 @@ private JFileChooser fc; private JButton openButton; private JTextField fileDisplay; - private String[] kbBoxItems = StartGUI.config.getKBBoxItems(); + private String[] kbBoxItems = StartGUI.myconfig.getKBBoxItems(); private JComboBox cb = new JComboBox(kbBoxItems); private JPanel openPanel = new JPanel(); - + KnowledgeSourcePanel() { super(new BorderLayout()); @@ -62,8 +63,8 @@ fileDisplay.setEditable(false); // test output - //List<Class<? extends KnowledgeSource>> sources = config.getComponentManager().getKnowledgeSources(); - //for (int i=0; i<sources.size(); i++) cb.addItem(sources.get(i)); + List<Class<? extends KnowledgeSource>> sources = StartGUI.myconfig.getComponentManager().getKnowledgeSources(); + for (int i=0; i<sources.size(); i++) cb.addItem(sources.get(i)); cb.addActionListener(this); JPanel choosePanel = new JPanel(); @@ -78,12 +79,14 @@ if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); if (returnVal == JFileChooser.APPROVE_OPTION) { - StartGUI.config.setFile(fc.getSelectedFile()); //save variable - fileDisplay.setText(StartGUI.config.getFile().toString()); - StartGUI.config.getComponentManager().applyConfigEntry(StartGUI.config.getKnowledgeSource(), "url", StartGUI.config.getFile().toURI().toString()); - StartGUI.config.getKnowledgeSource().init(); + StartGUI.myconfig.setFile(fc.getSelectedFile()); //save variable + fileDisplay.setText(StartGUI.myconfig.getFile().toString()); + System.out.println("Init KnowledgeSource after loading file ... show over output"); + StartGUI.myconfig.getComponentManager().applyConfigEntry(StartGUI.myconfig.getKnowledgeSource(), "url", StartGUI.myconfig.getFile().toURI().toString()); + StartGUI.myconfig.getKnowledgeSource().init(); } } + // choose none if (cb.getSelectedItem().toString() == kbBoxItems[0]) { System.out.println("Item: " + cb.getSelectedItem()); @@ -92,19 +95,16 @@ // choose KB class if (cb.getSelectedItem().toString() == kbBoxItems[1]) { System.out.println("Item: " + cb.getSelectedItem()); - makeCenterClean(); - openPanel.add(fileDisplay); - openPanel.add(openButton); - openPanel.repaint(); - StartGUI.config.setKnowledgeSource(StartGUI.config.getComponentManager().knowledgeSource(KBFile.class)); + makeCenterClean(); } // choose OWL class if (cb.getSelectedItem().toString() == kbBoxItems[2]) { - makeCenterClean(); + System.out.println("Item: " + cb.getSelectedItem()); + makeCenterClean(); openPanel.add(fileDisplay); openPanel.add(openButton); openPanel.repaint(); - StartGUI.config.setKnowledgeSource(StartGUI.config.getComponentManager().knowledgeSource(OWLFile.class)); + StartGUI.myconfig.setKnowledgeSource(StartGUI.myconfig.getComponentManager().knowledgeSource(OWLFile.class)); } // choose SPARCLE class if (cb.getSelectedItem().toString() == kbBoxItems[3]) { @@ -117,6 +117,6 @@ openPanel.remove(fileDisplay); openPanel.remove(openButton); openPanel.repaint(); - StartGUI.renew(); - } + StartGUI.myrun.renew(); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-06 15:14:35 UTC (rev 344) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-06 18:47:12 UTC (rev 345) @@ -58,11 +58,11 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == showButton) { - if (StartGUI.config.getStatus(1)) { // file is selected and exist? - infoArea.append("SourceClass: " + StartGUI.config.getKnowledgeSource().toString() + "\n"); - infoArea.append("FILE: " + StartGUI.config.getFile().toString() + "\n"); + if (StartGUI.myconfig.getStatus(1)) { // file is selected and exist? + infoArea.append("SourceClass: " + StartGUI.myconfig.getKnowledgeSource().toString() + "\n"); + infoArea.append("FILE: " + StartGUI.myconfig.getFile().toString() + "\n"); } - if (StartGUI.config.getStatus(2)) { + if (StartGUI.myconfig.getStatus(2)) { } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-06 15:14:35 UTC (rev 344) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-06 18:47:12 UTC (rev 345) @@ -74,8 +74,8 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == digButton) { // DIG - StartGUI.config.setReasoner(StartGUI.config.getComponentManager().reasoner(DIGReasoner.class, StartGUI.config.getKnowledgeSource())); - //StartGUI.config.getReasoner().init(); //error + StartGUI.myconfig.setReasoner(StartGUI.myconfig.getComponentManager().reasoner(DIGReasoner.class, StartGUI.myconfig.getKnowledgeSource())); + StartGUI.myconfig.getReasoner().init(); //error System.out.println("test"); //config.setReasoningService(config.getComponentManager().reasoningService(config.getReasoner())); Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-06 15:14:35 UTC (rev 344) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-06 18:47:12 UTC (rev 345) @@ -33,15 +33,18 @@ private static final long serialVersionUID = -739265982906533775L; - public static Config config = new Config(); + protected static StartGUI myrun; - private static final JTabbedPane tabPane = new JTabbedPane(); + protected static Config myconfig = new Config(); + + public JTabbedPane tabPane = new JTabbedPane(); + private JPanel tab1 = new JPanel(); private JPanel tab2 = new JPanel(); private JPanel tab3 = new JPanel(); private JPanel tab4 = new JPanel(); private JPanel tab5 = new JPanel(); - + public StartGUI() { this.setTitle("DL-Learner GUI"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -55,17 +58,22 @@ tabPane.addTab("Knowledge Source", tab1); tabPane.addTab("Reasoner", tab2); tabPane.addTab("Learning Problem", tab3); - tabPane.addTab("Learning Algortihm", tab4); + tabPane.addTab("Learning Algorithm", tab4); tabPane.addTab("Output", tab5); this.add(tabPane); this.setVisible(true); } - + public static void main(String[] args) { - new StartGUI(); + myrun = new StartGUI(); } - protected static void renew() { - tabPane.repaint(); + protected void renew() { + myrun.tabPane.repaint(); } + + protected StartGUI getStartGUI() { + return myrun; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-07 16:12:17
|
Revision: 348 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=348&view=rev Author: tonytacker Date: 2008-01-07 08:12:15 -0800 (Mon, 07 Jan 2008) Log Message: ----------- now it runs up to Reasoner and a list will be shown - don't forget to choose first KnowledgeSource OWL (the others don't work yet) and load a file 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/OutputPanel.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-01-07 09:47:05 UTC (rev 347) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-07 16:12:15 UTC (rev 348) @@ -39,20 +39,20 @@ */ public class Config { - protected static ComponentManager cm = ComponentManager.getInstance(); - protected static KnowledgeSource source; - protected static File selectedFile; - protected static ReasonerComponent reasoner; - protected static ReasoningService rs; - protected static List<Individual> individuals; - protected String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; + private ComponentManager cm = ComponentManager.getInstance(); + private KnowledgeSource source; + private File selectedFile; + private ReasonerComponent reasoner; + private ReasoningService rs; + private List<Individual> individuals; + private String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; /** * status should show witch variables are set * status[0] ... cm * status[1] ... KnowledgeSource * status[2] ... File or URL - * status[3] ... + * status[3] ... Resoner */ protected static boolean[] status = new boolean[8]; @@ -112,11 +112,11 @@ } protected KnowledgeSource getKnowledgeSource() { - status[1] = true; return source; } protected void setKnowledgeSource(KnowledgeSource input) { + status[1] = true; source = input; } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-07 09:47:05 UTC (rev 347) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-07 16:12:15 UTC (rev 348) @@ -21,7 +21,7 @@ */ import java.io.File; -import java.util.List; +//import java.util.List; import javax.swing.*; @@ -30,9 +30,9 @@ import java.awt.event.ActionListener; import org.dllearner.kb.OWLFile; -import org.dllearner.kb.KBFile; +// import org.dllearner.kb.KBFile; -import org.dllearner.core.KnowledgeSource; +//import org.dllearner.core.KnowledgeSource; /** @@ -62,9 +62,10 @@ fileDisplay = new JTextField(35); fileDisplay.setEditable(false); - // test output - List<Class<? extends KnowledgeSource>> sources = StartGUI.myconfig.getComponentManager().getKnowledgeSources(); - for (int i=0; i<sources.size(); i++) cb.addItem(sources.get(i)); + // test output - if you activat next 2 lines, it will show alle available kb.classes + // activate import too! + //List<Class<? extends KnowledgeSource>> sources = StartGUI.myconfig.getComponentManager().getKnowledgeSources(); + //for (int i=0; i<sources.size(); i++) cb.addItem(sources.get(i)); cb.addActionListener(this); JPanel choosePanel = new JPanel(); @@ -81,8 +82,8 @@ if (returnVal == JFileChooser.APPROVE_OPTION) { StartGUI.myconfig.setFile(fc.getSelectedFile()); //save variable fileDisplay.setText(StartGUI.myconfig.getFile().toString()); - System.out.println("Init KnowledgeSource after loading file ... show over output"); - System.out.println("test: " + StartGUI.myconfig.getFile().toURI().toString()); + //System.out.println("Init KnowledgeSource after loading file ... show over output"); + //System.out.println("test: " + StartGUI.myconfig.getFile().toURI().toString()); StartGUI.myconfig.getComponentManager().applyConfigEntry(StartGUI.myconfig.getKnowledgeSource(), "url", StartGUI.myconfig.getFile().toURI().toString()); StartGUI.myconfig.getKnowledgeSource().init(); } @@ -91,17 +92,17 @@ // choose none if (cb.getSelectedItem().toString() == kbBoxItems[0]) { - System.out.println("Item: " + cb.getSelectedItem()); + //System.out.println("Item: " + cb.getSelectedItem()); makeCenterClean(); } // choose KB class if (cb.getSelectedItem().toString() == kbBoxItems[1]) { - System.out.println("Item: " + cb.getSelectedItem()); + //System.out.println("Item: " + cb.getSelectedItem()); makeCenterClean(); } // choose OWL class if (cb.getSelectedItem().toString() == kbBoxItems[2]) { - System.out.println("Item: " + cb.getSelectedItem()); + //System.out.println("Item: " + cb.getSelectedItem()); makeCenterClean(); openPanel.add(fileDisplay); openPanel.add(openButton); @@ -110,7 +111,7 @@ } // choose SPARCLE class if (cb.getSelectedItem().toString() == kbBoxItems[3]) { - System.out.println("Item: " + cb.getSelectedItem()); + //System.out.println("Item: " + cb.getSelectedItem()); makeCenterClean(); } } Modified: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-07 09:47:05 UTC (rev 347) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-07 16:12:15 UTC (rev 348) @@ -45,27 +45,36 @@ showButton = new JButton("Show Variables"); showButton.addActionListener(this); - infoArea = new JTextArea(20,40); - + infoArea = new JTextArea(20, 50); + JScrollPane infoScroll = new JScrollPane(infoArea); + JPanel showPanel = new JPanel(); showPanel.add(showButton); JPanel infoPanel = new JPanel(); - infoPanel.add(infoArea); - + infoPanel.add(infoScroll); + add(showPanel, BorderLayout.PAGE_START); add(infoPanel, BorderLayout.CENTER); } public void actionPerformed(ActionEvent e) { if (e.getSource() == showButton) { - if (StartGUI.myconfig.getStatus(1)) { // file is selected and exist? + infoArea.setText(""); + if (StartGUI.myconfig.getStatus(2)) { // file is selected and exist? infoArea.append("SourceClass: " + StartGUI.myconfig.getKnowledgeSource().toString() + "\n"); - infoArea.append("FILE: " + StartGUI.myconfig.getFile().toString() + "\n"); + infoArea.append("FILE: " + StartGUI.myconfig.getFile() + "\n"); } - if (StartGUI.myconfig.getStatus(2)) { - + if (StartGUI.myconfig.getStatus(3)) { // Reasoner is set + infoArea.append("Reasoner: " + StartGUI.myconfig.getReasoner() + "\n"); } - + if (StartGUI.myconfig.getStatus(4)) { // ReasoningServic is set + infoArea.append("ReasoningService: " + StartGUI.myconfig.getReasoningService() + "\n"); + } + if (false) { + for (int i = 0; i<8; i++) { // show status-vars + infoArea.append("i: " + StartGUI.myconfig.getStatus(i) + "\n"); + } + } } } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-07 09:47:05 UTC (rev 347) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-07 16:12:15 UTC (rev 348) @@ -24,9 +24,13 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; import javax.swing.*; +import org.dllearner.core.dl.Individual; import org.dllearner.reasoning.DIGReasoner; //import org.dllearner.core.ReasonerComponent; @@ -50,6 +54,7 @@ private JPanel centerPanel = new JPanel(); private JButton digButton; private JList digList = new JList(); + private List<Individual> individuals; ReasonerPanel() { super(new BorderLayout()); @@ -58,43 +63,48 @@ digButton.addActionListener(this); // create a scrollable list of examples + digList = new JList(); digList.setLayoutOrientation(JList.VERTICAL); digList.setVisibleRowCount(-1); JScrollPane listScroller = new JScrollPane(digList); - listScroller.setPreferredSize(new Dimension(250, 80)); - centerPanel.add(listScroller); + listScroller.setPreferredSize(new Dimension(550, 350)); digPanel.add(digButton); add(digPanel, BorderLayout.PAGE_START); - centerPanel.add(digList); + centerPanel.add(listScroller); add(centerPanel, BorderLayout.CENTER); } public void actionPerformed(ActionEvent e) { - if (e.getSource() == digButton) { // DIG + if (e.getSource() == digButton) { + // set reasoner StartGUI.myconfig.setReasoner(StartGUI.myconfig.getComponentManager().reasoner(DIGReasoner.class, StartGUI.myconfig.getKnowledgeSource())); - System.out.println(StartGUI.myconfig.getKnowledgeSource()); - StartGUI.myconfig.getReasoner().init(); //error - System.out.println("test"); + //System.out.println(StartGUI.myconfig.getKnowledgeSource()); + StartGUI.myconfig.getReasoner().init(); + //System.out.println(StartGUI.myconfig.getReasoner()); - //config.setReasoningService(config.getComponentManager().reasoningService(config.getReasoner())); + // set ReasoningService + StartGUI.myconfig.setReasoningService(StartGUI.myconfig.getComponentManager().reasoningService(StartGUI.myconfig.getReasoner())); - // set list - //Set<Individual> individualsSet = config.getReasoningService().getIndividuals(); - //config.setListIndividuals(new LinkedList<Individual>(individualsSet)); + // get list from ReasoningService + Set<Individual> individualsSet = StartGUI.myconfig.getReasoningService().getIndividuals(); + //System.out.println("IndividualsSet: " + individualsSet); + individuals = new LinkedList<Individual>(individualsSet); + //System.out.println("individuals: " + individuals); + // make list + DefaultListModel listModel = new DefaultListModel(); + for(Individual ind : individuals) { + listModel.addElement(ind); + } + //System.out.println("listModel: " + listModel); + // graphic - //DefaultListModel listModel = new DefaultListModel(); - //for(Individual ind : config.getListIndividuals()) - //listModel.addElement(ind); + digList.setModel(listModel); + StartGUI.myrun.renew(); - // graphic - //Set<String> exampleSet = new HashSet<String>(); - //int[] selectedIndices = digList.getSelectedIndices(); - //for(int i : selectedIndices) - //exampleSet.add(config.getListIndividuals().get(i).toString()); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-09 21:00:30
|
Revision: 358 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=358&view=rev Author: tonytacker Date: 2008-01-09 13:00:23 -0800 (Wed, 09 Jan 2008) Log Message: ----------- now it runs with owl-files, you have to choose every tab from left to right and use all buttons Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.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/OutputPanel.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-01-09 17:55:25 UTC (rev 357) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-09 21:00:23 UTC (rev 358) @@ -21,13 +21,15 @@ */ import java.io.File; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; -import org.dllearner.core.dl.Individual; /** * config @@ -44,8 +46,10 @@ private File selectedFile; private ReasonerComponent reasoner; private ReasoningService rs; - private List<Individual> individuals; private String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; + private Set<String> exampleSet = new HashSet<String>(); + private LearningProblem lp; + private LearningAlgorithm la; /** * status should show witch variables are set @@ -53,6 +57,9 @@ * status[1] ... KnowledgeSource * status[2] ... File or URL * status[3] ... Resoner + * status[4] ... ReasoningService + * status[5] ... ExampleSet + * status[6] ... LearningProblem */ protected static boolean[] status = new boolean[8]; @@ -99,14 +106,6 @@ rs = input; } - protected List<Individual> getListIndividuals () { - return individuals; - } - - protected void setListIndividuals (List<Individual> input) { - individuals = input; - } - protected String[] getKBBoxItems() { return kbBoxItems; } @@ -120,4 +119,32 @@ source = input; } + protected void setExampleSet(Set<String> input) { + status[5] = true; + exampleSet = input; + } + + protected Set<String> getExampleSet () { + return exampleSet; + } + + protected void setLearningProblem (LearningProblem input) { + status[6] = true; + lp = input; + } + + protected LearningProblem getLearningProblem () { + return lp; + } + + protected void setLearningAlgorithm (LearningAlgorithm input) { + status[6] = true; + la = input; + } + + protected LearningAlgorithm getLearningAlgorithm () { + return la; + } + + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-09 17:55:25 UTC (rev 357) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-09 21:00:23 UTC (rev 358) @@ -22,6 +22,14 @@ import javax.swing.*; +import org.dllearner.algorithms.refinement.ROLearner; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + + /** * LearningAlgorithmPanel * @@ -29,11 +37,29 @@ * */ -public class LearningAlgorithmPanel extends JPanel { +public class LearningAlgorithmPanel extends JPanel implements ActionListener { private static final long serialVersionUID = 8721490771860452959L; + + private JPanel laPanel = new JPanel(); + private JButton laButton; + + LearningAlgorithmPanel() { + super(new BorderLayout()); - LearningAlgorithmPanel() { + laButton = new JButton("Use ROLearner"); + laButton.addActionListener(this); + laPanel.add(laButton); + add(laPanel, BorderLayout.PAGE_START); } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == laButton) { + if (StartGUI.myconfig.getStatus(6)) { + StartGUI.myconfig.setLearningAlgorithm(StartGUI.myconfig.getComponentManager().learningAlgorithm(ROLearner.class, StartGUI.myconfig.getLearningProblem(), StartGUI.myconfig.getReasoningService())); + StartGUI.myconfig.getLearningAlgorithm().init(); + } + } + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-09 17:55:25 UTC (rev 357) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-09 21:00:23 UTC (rev 358) @@ -20,8 +20,14 @@ * */ +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + import javax.swing.*; +import org.dllearner.learningproblems.PosOnlyDefinitionLP; + /** * LearningProblemPanel * @@ -29,11 +35,32 @@ * */ -public class LearningProblemPanel extends JPanel { +public class LearningProblemPanel extends JPanel implements ActionListener { private static final long serialVersionUID = -3819627680918930203L; + private JPanel lpPanel = new JPanel(); + private JButton lpButton; + LearningProblemPanel() { + super(new BorderLayout()); + + lpButton = new JButton("Use PosOnlyDefinitionLP"); + lpButton.addActionListener(this); + lpPanel.add(lpButton); + add(lpPanel, BorderLayout.PAGE_START); } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == lpButton) { + if (StartGUI.myconfig.getStatus(5)) { + System.out.println(StartGUI.myconfig.getExampleSet()); + StartGUI.myconfig.setLearningProblem(StartGUI.myconfig.getComponentManager().learningProblem(PosOnlyDefinitionLP.class, StartGUI.myconfig.getReasoningService())); + StartGUI.myconfig.getComponentManager().applyConfigEntry(StartGUI.myconfig.getLearningProblem(), "positiveExamples", StartGUI.myconfig.getExampleSet()); + StartGUI.myconfig.getLearningProblem().init(); + } + } + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-09 17:55:25 UTC (rev 357) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-09 21:00:23 UTC (rev 358) @@ -26,6 +26,8 @@ import javax.swing.*; +import org.dllearner.core.dl.Concept; + /** * OutputPanel * @@ -38,6 +40,7 @@ private static final long serialVersionUID = 1643304576470046636L; private JButton showButton; + private JButton runButton; private JTextArea infoArea; OutputPanel() { @@ -45,11 +48,16 @@ showButton = new JButton("Show Variables"); showButton.addActionListener(this); + + runButton = new JButton("Run"); + runButton.addActionListener(this); + infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); JPanel showPanel = new JPanel(); showPanel.add(showButton); + showPanel.add(runButton); JPanel infoPanel = new JPanel(); infoPanel.add(infoScroll); @@ -76,5 +84,12 @@ } } } + if (e.getSource() == runButton) { + if (StartGUI.myconfig.getStatus(6)) { + StartGUI.myconfig.getLearningAlgorithm().start(); + Concept solution = StartGUI.myconfig.getLearningAlgorithm().getBestSolution(); + infoArea.setText(solution.toString()); + } + } } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-09 17:55:25 UTC (rev 357) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-09 21:00:23 UTC (rev 358) @@ -24,11 +24,13 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import javax.swing.*; +import javax.swing.event.*; import org.dllearner.core.dl.Individual; import org.dllearner.reasoning.DIGReasoner; @@ -68,13 +70,27 @@ digList.setVisibleRowCount(-1); JScrollPane listScroller = new JScrollPane(digList); listScroller.setPreferredSize(new Dimension(550, 350)); - + digPanel.add(digButton); add(digPanel, BorderLayout.PAGE_START); centerPanel.add(listScroller); add(centerPanel, BorderLayout.CENTER); + digList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent evt) { + if (evt.getValueIsAdjusting()) + return; + //System.out.println("Selected from " + evt.getFirstIndex() + " to " + evt.getLastIndex()); + // detect which examples have been selected + Set<String> exampleSet = new HashSet<String>(); + int[] selectedIndices = digList.getSelectedIndices(); + for(int i : selectedIndices) + exampleSet.add(individuals.get(i).toString()); + StartGUI.myconfig.setExampleSet(exampleSet); + System.out.println("digList: " + StartGUI.myconfig.getExampleSet() ); + } + }); } public void actionPerformed(ActionEvent e) { @@ -96,15 +112,16 @@ // make list DefaultListModel listModel = new DefaultListModel(); - for(Individual ind : individuals) { + for(Individual ind : individuals) listModel.addElement(ind); - } - //System.out.println("listModel: " + listModel); + digList.setModel(listModel); + // graphic digList.setModel(listModel); StartGUI.myrun.renew(); + //return; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-10 16:49:34
|
Revision: 363 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=363&view=rev Author: tonytacker Date: 2008-01-10 08:49:25 -0800 (Thu, 10 Jan 2008) Log Message: ----------- lines 94 and 95 in ReasonerPanel.java produce errors Modified Paths: -------------- 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/OutputPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-10 16:30:32 UTC (rev 362) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-10 16:49:25 UTC (rev 363) @@ -49,13 +49,16 @@ private JFileChooser fc; private JButton openButton; private JTextField fileDisplay; - private String[] kbBoxItems = StartGUI.myconfig.getKBBoxItems(); + private String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; private JComboBox cb = new JComboBox(kbBoxItems); private JPanel openPanel = new JPanel(); - - KnowledgeSourcePanel() { + private Config config; + + KnowledgeSourcePanel(Config config) { super(new BorderLayout()); + this.config = config; + fc = new JFileChooser(new File("examples/")); openButton = new JButton("Open File"); openButton.addActionListener(this); @@ -80,12 +83,12 @@ if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); if (returnVal == JFileChooser.APPROVE_OPTION) { - StartGUI.myconfig.setFile(fc.getSelectedFile()); //save variable - fileDisplay.setText(StartGUI.myconfig.getFile().toString()); + config.setFile(fc.getSelectedFile()); //save variable + fileDisplay.setText(config.getFile().toString()); //System.out.println("Init KnowledgeSource after loading file ... show over output"); //System.out.println("test: " + StartGUI.myconfig.getFile().toURI().toString()); - StartGUI.myconfig.getComponentManager().applyConfigEntry(StartGUI.myconfig.getKnowledgeSource(), "url", StartGUI.myconfig.getFile().toURI().toString()); - StartGUI.myconfig.getKnowledgeSource().init(); + config.getComponentManager().applyConfigEntry(config.getKnowledgeSource(), "url", config.getFile().toURI().toString()); + config.getKnowledgeSource().init(); } return; } @@ -107,7 +110,7 @@ openPanel.add(fileDisplay); openPanel.add(openButton); openPanel.repaint(); - StartGUI.myconfig.setKnowledgeSource(StartGUI.myconfig.getComponentManager().knowledgeSource(OWLFile.class)); + config.setKnowledgeSource(config.getComponentManager().knowledgeSource(OWLFile.class)); } // choose SPARCLE class if (cb.getSelectedItem().toString() == kbBoxItems[3]) { Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-10 16:30:32 UTC (rev 362) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-10 16:49:25 UTC (rev 363) @@ -44,9 +44,13 @@ private JPanel laPanel = new JPanel(); private JButton laButton; - LearningAlgorithmPanel() { + private Config config; + + LearningAlgorithmPanel(Config config) { super(new BorderLayout()); + this.config = config; + laButton = new JButton("Use ROLearner"); laButton.addActionListener(this); @@ -56,9 +60,9 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == laButton) { - if (StartGUI.myconfig.getStatus(6)) { - StartGUI.myconfig.setLearningAlgorithm(StartGUI.myconfig.getComponentManager().learningAlgorithm(ROLearner.class, StartGUI.myconfig.getLearningProblem(), StartGUI.myconfig.getReasoningService())); - StartGUI.myconfig.getLearningAlgorithm().init(); + if (config.getStatus(6)) { + config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm(ROLearner.class, config.getLearningProblem(), config.getReasoningService())); + config.getLearningAlgorithm().init(); } } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-10 16:30:32 UTC (rev 362) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-10 16:49:25 UTC (rev 363) @@ -42,9 +42,13 @@ private JPanel lpPanel = new JPanel(); private JButton lpButton; - LearningProblemPanel() { + private Config config; + + LearningProblemPanel(Config config) { super(new BorderLayout()); + this.config = config; + lpButton = new JButton("Use PosOnlyDefinitionLP"); lpButton.addActionListener(this); @@ -54,11 +58,11 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == lpButton) { - if (StartGUI.myconfig.getStatus(5)) { - System.out.println(StartGUI.myconfig.getExampleSet()); - StartGUI.myconfig.setLearningProblem(StartGUI.myconfig.getComponentManager().learningProblem(PosOnlyDefinitionLP.class, StartGUI.myconfig.getReasoningService())); - StartGUI.myconfig.getComponentManager().applyConfigEntry(StartGUI.myconfig.getLearningProblem(), "positiveExamples", StartGUI.myconfig.getExampleSet()); - StartGUI.myconfig.getLearningProblem().init(); + if (config.getStatus(5)) { + System.out.println(config.getExampleSet()); + config.setLearningProblem(config.getComponentManager().learningProblem(PosOnlyDefinitionLP.class, config.getReasoningService())); + config.getComponentManager().applyConfigEntry(config.getLearningProblem(), "positiveExamples", config.getExampleSet()); + config.getLearningProblem().init(); } } } Modified: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-10 16:30:32 UTC (rev 362) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-10 16:49:25 UTC (rev 363) @@ -42,10 +42,13 @@ private JButton showButton; private JButton runButton; private JTextArea infoArea; + private Config config; - OutputPanel() { + OutputPanel(Config config) { super(new BorderLayout()); + this.config = config; + showButton = new JButton("Show Variables"); showButton.addActionListener(this); @@ -68,26 +71,26 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == showButton) { infoArea.setText(""); - if (StartGUI.myconfig.getStatus(2)) { // file is selected and exist? - infoArea.append("SourceClass: " + StartGUI.myconfig.getKnowledgeSource().toString() + "\n"); - infoArea.append("FILE: " + StartGUI.myconfig.getFile() + "\n"); + if (config.getStatus(2)) { // file is selected and exist? + infoArea.append("SourceClass: " + config.getKnowledgeSource().toString() + "\n"); + infoArea.append("FILE: " + config.getFile() + "\n"); } - if (StartGUI.myconfig.getStatus(3)) { // Reasoner is set - infoArea.append("Reasoner: " + StartGUI.myconfig.getReasoner() + "\n"); + if (config.getStatus(3)) { // Reasoner is set + infoArea.append("Reasoner: " + config.getReasoner() + "\n"); } - if (StartGUI.myconfig.getStatus(4)) { // ReasoningServic is set - infoArea.append("ReasoningService: " + StartGUI.myconfig.getReasoningService() + "\n"); + if (config.getStatus(4)) { // ReasoningServic is set + infoArea.append("ReasoningService: " + config.getReasoningService() + "\n"); } if (false) { for (int i = 0; i<8; i++) { // show status-vars - infoArea.append("i: " + StartGUI.myconfig.getStatus(i) + "\n"); + infoArea.append("i: " + config.getStatus(i) + "\n"); } } } if (e.getSource() == runButton) { - if (StartGUI.myconfig.getStatus(6)) { - StartGUI.myconfig.getLearningAlgorithm().start(); - Concept solution = StartGUI.myconfig.getLearningAlgorithm().getBestSolution(); + if (config.getStatus(6)) { + config.getLearningAlgorithm().start(); + Concept solution = config.getLearningAlgorithm().getBestSolution(); infoArea.setText(solution.toString()); } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-10 16:30:32 UTC (rev 362) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-10 16:49:25 UTC (rev 363) @@ -57,10 +57,13 @@ private JButton digButton; private JList digList = new JList(); private List<Individual> individuals; + private Config config; - ReasonerPanel() { + ReasonerPanel(Config config) { super(new BorderLayout()); + this.config = config; + digButton = new JButton("Use DIG by default"); digButton.addActionListener(this); @@ -76,7 +79,8 @@ centerPanel.add(listScroller); add(centerPanel, BorderLayout.CENTER); - + + digList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (evt.getValueIsAdjusting()) @@ -87,25 +91,41 @@ int[] selectedIndices = digList.getSelectedIndices(); for(int i : selectedIndices) exampleSet.add(individuals.get(i).toString()); - StartGUI.myconfig.setExampleSet(exampleSet); - System.out.println("digList: " + StartGUI.myconfig.getExampleSet() ); + //config.setExampleSet(exampleSet); //error + //System.out.println("digList: " + config.getExampleSet() ); //error } }); + } - + + public void valueChanged(ListSelectionEvent evt) { + System.out.println("s"); + if (evt.getValueIsAdjusting()) + return; + System.out.println("Selected from " + evt.getFirstIndex() + " to " + evt.getLastIndex()); + // detect which examples have been selected + Set<String> exampleSet = new HashSet<String>(); + int[] selectedIndices = digList.getSelectedIndices(); + for(int i : selectedIndices) + exampleSet.add(individuals.get(i).toString()); + //StartGUI.myconfig.setExampleSet(exampleSet); + //System.out.println("digList: " + config.getExampleSet() ); + } + + public void actionPerformed(ActionEvent e) { if (e.getSource() == digButton) { // set reasoner - StartGUI.myconfig.setReasoner(StartGUI.myconfig.getComponentManager().reasoner(DIGReasoner.class, StartGUI.myconfig.getKnowledgeSource())); + config.setReasoner(config.getComponentManager().reasoner(DIGReasoner.class, config.getKnowledgeSource())); //System.out.println(StartGUI.myconfig.getKnowledgeSource()); - StartGUI.myconfig.getReasoner().init(); + config.getReasoner().init(); //System.out.println(StartGUI.myconfig.getReasoner()); // set ReasoningService - StartGUI.myconfig.setReasoningService(StartGUI.myconfig.getComponentManager().reasoningService(StartGUI.myconfig.getReasoner())); + config.setReasoningService(config.getComponentManager().reasoningService(config.getReasoner())); // get list from ReasoningService - Set<Individual> individualsSet = StartGUI.myconfig.getReasoningService().getIndividuals(); + Set<Individual> individualsSet = config.getReasoningService().getIndividuals(); //System.out.println("IndividualsSet: " + individualsSet); individuals = new LinkedList<Individual>(individualsSet); //System.out.println("individuals: " + individuals); Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-10 16:30:32 UTC (rev 362) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-10 16:49:25 UTC (rev 363) @@ -35,7 +35,7 @@ protected static StartGUI myrun; - protected static Config myconfig = new Config(); + //protected static Config myconfig = new Config(); public JTabbedPane tabPane = new JTabbedPane(); @@ -44,17 +44,18 @@ private JPanel tab3 = new JPanel(); private JPanel tab4 = new JPanel(); private JPanel tab5 = new JPanel(); - + public StartGUI() { + Config config = new Config(); this.setTitle("DL-Learner GUI"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationByPlatform(true); this.setSize(640, 480); - tab1.add(new KnowledgeSourcePanel()); - tab2.add(new ReasonerPanel()); - tab3.add(new LearningProblemPanel()); - tab4.add(new LearningAlgorithmPanel()); - tab5.add(new OutputPanel()); + tab1.add(new KnowledgeSourcePanel(config)); + tab2.add(new ReasonerPanel(config)); + tab3.add(new LearningProblemPanel(config)); + tab4.add(new LearningAlgorithmPanel(config)); + tab5.add(new OutputPanel(config)); tabPane.addTab("Knowledge Source", tab1); tabPane.addTab("Reasoner", tab2); tabPane.addTab("Learning Problem", tab3); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-16 01:53:36
|
Revision: 378 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=378&view=rev Author: tonytacker Date: 2008-01-15 17:53:33 -0800 (Tue, 15 Jan 2008) Log Message: ----------- This Version runs with file and URL. At moment you have to click from left to right all tabs and in every tab the init-button. It will be improved later. Normally you can use both SparceEndpoints. If it is there something wrong with GUI let me know. I need some links for testing. Greetings -Tilo- 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/OutputPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-15 16:00:04 UTC (rev 377) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-16 01:53:33 UTC (rev 378) @@ -43,7 +43,7 @@ public class Config { private ComponentManager cm = ComponentManager.getInstance(); private KnowledgeSource source; - private File selectedFile; + private String uri; private ReasonerComponent reasoner; private ReasoningService rs; private String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; @@ -55,7 +55,7 @@ * status should show witch variables are set * status[0] ... cm * status[1] ... KnowledgeSource - * status[2] ... File or URL + * status[2] ... URI * status[3] ... Resoner * status[4] ... ReasoningService * status[5] ... ExampleSet @@ -78,13 +78,13 @@ cm = input; } - protected File getFile () { - return selectedFile; + protected String getURI () { + return uri; } - protected void setFile (File input) { + protected void setURI (String input) { status[2] = true; - selectedFile = input; + uri = input; } protected ReasonerComponent getReasoner () { Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-15 16:00:04 UTC (rev 377) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-16 01:53:33 UTC (rev 378) @@ -21,7 +21,7 @@ */ import java.io.File; -//import java.util.List; +import java.util.List; import javax.swing.*; @@ -29,12 +29,10 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import org.dllearner.kb.OWLFile; -// import org.dllearner.kb.KBFile; +//import org.dllearner.kb.*; +import org.dllearner.core.KnowledgeSource; -//import org.dllearner.core.KnowledgeSource; - /** * KnowledgeSourcePanel * @@ -47,35 +45,49 @@ private static final long serialVersionUID = -7678275020058043937L; private JFileChooser fc; - private JButton openButton; + private JButton openButton, initButton; private JTextField fileDisplay; - private String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; + private String[] kbBoxItems = {"Pleae select a type"}; private JComboBox cb = new JComboBox(kbBoxItems); - private JPanel openPanel = new JPanel(); + private JPanel openPanel; private Config config; + private int choosenClassIndex; + private List<Class<? extends KnowledgeSource>> sources; KnowledgeSourcePanel(Config config) { super(new BorderLayout()); this.config = config; + sources = config.getComponentManager().getKnowledgeSources(); fc = new JFileChooser(new File("examples/")); - openButton = new JButton("Open File"); + openButton = new JButton("Open local file otherwise type URL"); openButton.addActionListener(this); + + initButton = new JButton("Init KnowledgeSource"); + initButton.addActionListener(this); + fileDisplay = new JTextField(35); - fileDisplay.setEditable(false); + fileDisplay.setEditable(true); - // test output - if you activat next 2 lines, it will show alle available kb.classes - // activate import too! - //List<Class<? extends KnowledgeSource>> sources = StartGUI.myconfig.getComponentManager().getKnowledgeSources(); - //for (int i=0; i<sources.size(); i++) cb.addItem(sources.get(i)); + for (int i=0; i<sources.size(); i++) { + String ksClass = sources.get(i).toString().substring(23).concat(".class"); + cb.addItem(ksClass); + } + cb.addActionListener(this); + openPanel = new JPanel(); + JPanel choosePanel = new JPanel(); choosePanel.add(cb); + JPanel initPanel = new JPanel(); + initPanel.add(initButton); + add(choosePanel, BorderLayout.PAGE_START); add(openPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); } public void actionPerformed(ActionEvent e) { @@ -83,39 +95,35 @@ if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); if (returnVal == JFileChooser.APPROVE_OPTION) { - config.setFile(fc.getSelectedFile()); //save variable - fileDisplay.setText(config.getFile().toString()); - //System.out.println("Init KnowledgeSource after loading file ... show over output"); - //System.out.println("test: " + StartGUI.myconfig.getFile().toURI().toString()); - config.getComponentManager().applyConfigEntry(config.getKnowledgeSource(), "url", config.getFile().toURI().toString()); - config.getKnowledgeSource().init(); + String URI = "file://"; + URI = URI.concat(fc.getSelectedFile().toString()); // make "file://" before local URI's + config.setURI(URI); //save variable + fileDisplay.setText(URI); } return; } + - // choose none - if (cb.getSelectedItem().toString() == kbBoxItems[0]) { - //System.out.println("Item: " + cb.getSelectedItem()); + // something changes in cb + if (cb.isEnabled()) { + System.out.println("Item: " + cb.getSelectedItem()); + System.out.println("Item: " + cb.getSelectedIndex()); + + choosenClassIndex = cb.getSelectedIndex() -1; + makeCenterClean(); - } - // choose KB class - if (cb.getSelectedItem().toString() == kbBoxItems[1]) { - //System.out.println("Item: " + cb.getSelectedItem()); - makeCenterClean(); - } - // choose OWL class - if (cb.getSelectedItem().toString() == kbBoxItems[2]) { - //System.out.println("Item: " + cb.getSelectedItem()); - makeCenterClean(); openPanel.add(fileDisplay); openPanel.add(openButton); - openPanel.repaint(); - config.setKnowledgeSource(config.getComponentManager().knowledgeSource(OWLFile.class)); + } - // choose SPARCLE class - if (cb.getSelectedItem().toString() == kbBoxItems[3]) { - //System.out.println("Item: " + cb.getSelectedItem()); - makeCenterClean(); + + // init + if (e.getSource() == initButton) { + String testURI = config.getURI(); + config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); + config.getComponentManager().applyConfigEntry(config.getKnowledgeSource(), "url", testURI); + config.getKnowledgeSource().init(); + System.out.println("init KnowledgeSource"); } } Modified: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-15 16:00:04 UTC (rev 377) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-16 01:53:33 UTC (rev 378) @@ -71,10 +71,12 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == showButton) { infoArea.setText(""); - if (config.getStatus(2)) { // file is selected and exist? + if (config.getStatus(1)) { // kb is set infoArea.append("SourceClass: " + config.getKnowledgeSource().toString() + "\n"); - infoArea.append("FILE: " + config.getFile() + "\n"); } + if (config.getStatus(2)) { // file is set + infoArea.append("URI: " + config.getURI() + "\n"); + } if (config.getStatus(3)) { // Reasoner is set infoArea.append("Reasoner: " + config.getReasoner() + "\n"); } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-15 16:00:04 UTC (rev 377) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-16 01:53:33 UTC (rev 378) @@ -97,22 +97,7 @@ }); } - - public void valueChanged(ListSelectionEvent evt) { - System.out.println("s"); - if (evt.getValueIsAdjusting()) - return; - System.out.println("Selected from " + evt.getFirstIndex() + " to " + evt.getLastIndex()); - // detect which examples have been selected - Set<String> exampleSet = new HashSet<String>(); - int[] selectedIndices = digList.getSelectedIndices(); - for(int i : selectedIndices) - exampleSet.add(individuals.get(i).toString()); - //StartGUI.myconfig.setExampleSet(exampleSet); - //System.out.println("digList: " + config.getExampleSet() ); - } - - + public void actionPerformed(ActionEvent e) { if (e.getSource() == digButton) { // set reasoner @@ -140,8 +125,6 @@ // graphic digList.setModel(listModel); StartGUI.myrun.renew(); - - //return; } } } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-15 16:00:04 UTC (rev 377) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-16 01:53:33 UTC (rev 378) @@ -35,8 +35,6 @@ protected static StartGUI myrun; - //protected static Config myconfig = new Config(); - public JTabbedPane tabPane = new JTabbedPane(); private JPanel tab1 = new JPanel(); @@ -50,7 +48,7 @@ this.setTitle("DL-Learner GUI"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationByPlatform(true); - this.setSize(640, 480); + this.setSize(800, 600); tab1.add(new KnowledgeSourcePanel(config)); tab2.add(new ReasonerPanel(config)); tab3.add(new LearningProblemPanel(config)); @@ -70,11 +68,11 @@ } protected void renew() { - myrun.tabPane.repaint(); + tabPane.repaint(); } - + protected StartGUI getStartGUI() { return myrun; } - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-16 15:40:01
|
Revision: 381 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=381&view=rev Author: tonytacker Date: 2008-01-16 07:39:43 -0800 (Wed, 16 Jan 2008) Log Message: ----------- improved handling for URI Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-16 12:42:45 UTC (rev 380) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-16 15:39:43 UTC (rev 381) @@ -20,9 +20,9 @@ * */ -import java.io.File; import java.util.HashSet; import java.util.Set; +//import java.io.File; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-16 12:42:45 UTC (rev 380) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-16 15:39:43 UTC (rev 381) @@ -24,6 +24,7 @@ import java.util.List; import javax.swing.*; +import javax.swing.event.*; import java.awt.BorderLayout; import java.awt.event.ActionEvent; @@ -47,21 +48,21 @@ private JFileChooser fc; private JButton openButton, initButton; private JTextField fileDisplay; - private String[] kbBoxItems = {"Pleae select a type"}; - private JComboBox cb = new JComboBox(kbBoxItems); + private String[] kbBoxItems = {}; + private JComboBox cb = new JComboBox(kbBoxItems); private JPanel openPanel; private Config config; private int choosenClassIndex; private List<Class<? extends KnowledgeSource>> sources; - KnowledgeSourcePanel(Config config) { + KnowledgeSourcePanel(final Config config) { super(new BorderLayout()); this.config = config; sources = config.getComponentManager().getKnowledgeSources(); fc = new JFileChooser(new File("examples/")); - openButton = new JButton("Open local file otherwise type URL + ENTER"); + openButton = new JButton("Open local file or type URL"); openButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); @@ -69,8 +70,21 @@ fileDisplay = new JTextField(35); fileDisplay.setEditable(true); - fileDisplay.addActionListener(this); + // update config if textfield changed + fileDisplay.getDocument().addDocumentListener(new DocumentListener() { + public void insertUpdate(DocumentEvent e) { + config.setURI(fileDisplay.getText()); + } + public void removeUpdate(DocumentEvent e) { + config.setURI(fileDisplay.getText()); + } + public void changedUpdate(DocumentEvent e) { + config.setURI(fileDisplay.getText()); + } + }); + + // parse for (int i=0; i<sources.size(); i++) { String ksClass = sources.get(i).toString().substring(23).concat(".class"); cb.addItem(ksClass); @@ -85,20 +99,21 @@ JPanel initPanel = new JPanel(); initPanel.add(initButton); + + openPanel.add(fileDisplay); + openPanel.add(openButton); add(choosePanel, BorderLayout.PAGE_START); add(openPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); + + choosenClassIndex = cb.getSelectedIndex(); } public void actionPerformed(ActionEvent e) { - // change URI - if (e.getSource() == fileDisplay) { - System.out.println(fileDisplay.getText()); - config.setURI(fileDisplay.getText()); - } + // read selected KnowledgeSourceClass + choosenClassIndex = cb.getSelectedIndex(); - // open File if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); @@ -110,35 +125,14 @@ } return; } - - - // something changes in cb - if (cb.isEnabled()) { - System.out.println("Item: " + cb.getSelectedItem()); - System.out.println("Item: " + cb.getSelectedIndex()); - - choosenClassIndex = cb.getSelectedIndex() -1; - - makeCenterClean(); - openPanel.add(fileDisplay); - openPanel.add(openButton); - - } - + // init if (e.getSource() == initButton) { - //String testURI = config.getURI(); config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); config.getComponentManager().applyConfigEntry(config.getKnowledgeSource(), "url", config.getURI()); config.getKnowledgeSource().init(); - System.out.println("init KnowledgeSource with " + sources.get(choosenClassIndex) + " and ..."); + System.out.println("init KnowledgeSource with \n" + sources.get(choosenClassIndex) + " and \n" + config.getURI() + "\n"); } } - - private void makeCenterClean() { - openPanel.remove(fileDisplay); - openPanel.remove(openButton); - openPanel.repaint(); - StartGUI.myrun.renew(); - } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-18 16:40:04
|
Revision: 393 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=393&view=rev Author: tonytacker Date: 2008-01-18 08:40:00 -0800 (Fri, 18 Jan 2008) Log Message: ----------- - add negative Examples - add all LearningProblems 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/LearningProblemPanel.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-01-18 13:10:58 UTC (rev 392) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-18 16:40:00 UTC (rev 393) @@ -46,8 +46,8 @@ private String uri; private ReasonerComponent reasoner; private ReasoningService rs; - private String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; - private Set<String> exampleSet = new HashSet<String>(); + private Set<String> posExampleSet = new HashSet<String>(); + private Set<String> negExampleSet = new HashSet<String>(); private LearningProblem lp; private LearningAlgorithm la; @@ -106,10 +106,6 @@ rs = input; } - protected String[] getKBBoxItems() { - return kbBoxItems; - } - protected KnowledgeSource getKnowledgeSource() { return source; } @@ -119,15 +115,24 @@ source = input; } - protected void setExampleSet(Set<String> input) { + protected void setPosExampleSet(Set<String> posExampleSet) { status[5] = true; - exampleSet = input; + this.posExampleSet = posExampleSet; } - protected Set<String> getExampleSet () { - return exampleSet; + protected Set<String> getPosExampleSet () { + return this.posExampleSet; } + protected void setNegExampleSet(Set<String> negExampleSet) { + status[5] = true; + this.negExampleSet = negExampleSet; + } + + protected Set<String> getNegExampleSet () { + return this.negExampleSet; + } + protected void setLearningProblem (LearningProblem input) { status[6] = true; lp = input; Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-18 13:10:58 UTC (rev 392) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-18 16:40:00 UTC (rev 393) @@ -71,7 +71,7 @@ fileDisplay = new JTextField(35); fileDisplay.setEditable(true); - // update config if textfield changed + // update config if textfield fileDisplay changed fileDisplay.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { config.setURI(fileDisplay.getText()); @@ -84,10 +84,9 @@ } }); - // parse + // add to comboBox for (int i=0; i<sources.size(); i++) { - String ksClass = sources.get(i).toString().substring(23).concat(".class"); - cb.addItem(ksClass); + cb.addItem(sources.get(i).getSimpleName()); } cb.addActionListener(this); @@ -119,7 +118,7 @@ int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); if (returnVal == JFileChooser.APPROVE_OPTION) { String URI = "file://"; - URI = URI.concat(fc.getSelectedFile().toString()); // make "file://" before local URI's + URI = URI.concat(fc.getSelectedFile().toString()); // make "file://" before local URI config.setURI(URI); //save variable fileDisplay.setText(URI); } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-18 13:10:58 UTC (rev 392) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-18 16:40:00 UTC (rev 393) @@ -21,12 +21,23 @@ */ import java.awt.BorderLayout; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.dl.Individual; +//import org.dllearner.learningproblems.*; /** * LearningProblemPanel @@ -39,32 +50,166 @@ private static final long serialVersionUID = -3819627680918930203L; + private List<Class<? extends LearningProblem>> problems; + 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 JButton lpButton; + private JLabel posLabel = new JLabel("positive Examples"); + private JLabel negLabel = new JLabel("negative Examples"); + private JButton initButton, readListButton; + private int choosenClassIndex; + private List<Individual> individuals; + private JList posList = new JList(); + private JList negList = new JList(); private Config config; - LearningProblemPanel(Config config) { + LearningProblemPanel(final Config config) { super(new BorderLayout()); this.config = config; - lpButton = new JButton("Use PosOnlyDefinitionLP"); - lpButton.addActionListener(this); + initButton = new JButton("Init LearningProblem"); + initButton.addActionListener(this); - lpPanel.add(lpButton); - add(lpPanel, BorderLayout.PAGE_START); + readListButton = new JButton("Read List"); + readListButton.addActionListener(this); + + choosePanel.add(cb); + choosePanel.add(readListButton); + lpPanel.add(initButton); + add(choosePanel, BorderLayout.PAGE_START); + add(centerPanel, BorderLayout.CENTER); + add(lpPanel, BorderLayout.PAGE_END); + + problems = config.getComponentManager().getLearningProblems(); + + // add into comboBox + for (int i=0; i<problems.size(); i++) { + cb.addItem(problems.get(i).getSimpleName()); + } + + // read choosen LearningProblem + choosenClassIndex = cb.getSelectedIndex(); + + // create a scrollable list of positive examples + posList = new JList(); + posList.setLayoutOrientation(JList.VERTICAL); + posList.setVisibleRowCount(-1); + JScrollPane posListScroller = new JScrollPane(posList); + posListScroller.setPreferredSize(new Dimension(300, 200)); + + // create a scrollable list of negative examples + negList = new JList(); + negList.setLayoutOrientation(JList.VERTICAL); + negList.setVisibleRowCount(-1); + JScrollPane negListScroller = new JScrollPane(negList); + negListScroller.setPreferredSize(new Dimension(300, 200)); + + // define GridBag + GridBagLayout gridbag = new GridBagLayout(); + centerPanel.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); + + buildConstraints(constraints, 1, 0, 1, 1, 100, 100); + gridbag.setConstraints(negLabel, constraints); + centerPanel.add(negLabel); + + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(posListScroller, constraints); + centerPanel.add(posListScroller); + + buildConstraints(constraints, 1, 1, 1, 1, 100, 100); + gridbag.setConstraints(negListScroller, constraints); + centerPanel.add(negListScroller); + + add(centerPanel, BorderLayout.CENTER); + + // listener for posList + posList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent evt) { + if (evt.getValueIsAdjusting()) + return; + // detect witch examples have been selected + Set<String> posExampleSet = new HashSet<String>(); + int[] selectedIndices = posList.getSelectedIndices(); + for(int i : selectedIndices) + posExampleSet.add(individuals.get(i).toString()); + config.setPosExampleSet(posExampleSet); + System.out.println("posList: " + config.getPosExampleSet() ); + } + }); + + // listener for negList + negList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent evt) { + if (evt.getValueIsAdjusting()) + return; + // detect witch examples have been selected + Set<String> negExampleSet = new HashSet<String>(); + int[] selectedIndices = negList.getSelectedIndices(); + for(int i : selectedIndices) + negExampleSet.add(individuals.get(i).toString()); + config.setNegExampleSet(negExampleSet); + System.out.println("negList: " + config.getNegExampleSet() ); + } + }); } public void actionPerformed(ActionEvent e) { - if (e.getSource() == lpButton) { + // read selected LearningProblemClass + choosenClassIndex = cb.getSelectedIndex(); + + // later for read options + //List a = config.getComponentManager().getConfigOptions(problems.get(cb.getSelectedIndex())); + //System.out.println("optionName: " + a); + + // get list after reasoner init + if (e.getSource() == readListButton) { + // fill lists + if (config.getStatus(4)) { // only with a reasoner + 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); + } + } + + //init + if (e.getSource() == initButton) { if (config.getStatus(5)) { - System.out.println(config.getExampleSet()); - config.setLearningProblem(config.getComponentManager().learningProblem(PosOnlyDefinitionLP.class, config.getReasoningService())); - config.getComponentManager().applyConfigEntry(config.getLearningProblem(), "positiveExamples", config.getExampleSet()); + 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 with \n" + problems.get(choosenClassIndex) + "\nand " + "\nposExample: " + + config.getPosExampleSet() + "\nand negExample: " + config.getNegExampleSet()); } } } + /* + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-18 13:10:58 UTC (rev 392) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-18 16:40:00 UTC (rev 393) @@ -21,18 +21,11 @@ */ import java.awt.BorderLayout; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; import javax.swing.*; -import javax.swing.event.*; -import org.dllearner.core.dl.Individual; import org.dllearner.reasoning.DIGReasoner; //import org.dllearner.core.ReasonerComponent; @@ -53,10 +46,7 @@ private static final long serialVersionUID = -7678275020058043937L; private JPanel digPanel = new JPanel(); - private JPanel centerPanel = new JPanel(); - private JButton digButton; - private JList digList = new JList(); - private List<Individual> individuals; + private JButton initButton; private Config config; ReasonerPanel(final Config config) { @@ -64,67 +54,30 @@ this.config = config; - digButton = new JButton("Use DIG by default"); - digButton.addActionListener(this); + initButton = new JButton("Use DIG by default"); + initButton.addActionListener(this); - // create a scrollable list of examples - digList = new JList(); - digList.setLayoutOrientation(JList.VERTICAL); - digList.setVisibleRowCount(-1); - JScrollPane listScroller = new JScrollPane(digList); - listScroller.setPreferredSize(new Dimension(550, 350)); - - digPanel.add(digButton); + digPanel.add(initButton); add(digPanel, BorderLayout.PAGE_START); - - centerPanel.add(listScroller); - add(centerPanel, BorderLayout.CENTER); - - digList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent evt) { - if (evt.getValueIsAdjusting()) - return; - //System.out.println("Selected from " + evt.getFirstIndex() + " to " + evt.getLastIndex()); - // detect which examples have been selected - Set<String> exampleSet = new HashSet<String>(); - int[] selectedIndices = digList.getSelectedIndices(); - for(int i : selectedIndices) - exampleSet.add(individuals.get(i).toString()); - config.setExampleSet(exampleSet); //error - System.out.println("digList: " + config.getExampleSet() ); //error - } - }); - } public void actionPerformed(ActionEvent e) { - if (e.getSource() == digButton) { - // set reasoner - config.setReasoner(config.getComponentManager().reasoner(DIGReasoner.class, config.getKnowledgeSource())); - //System.out.println(StartGUI.myconfig.getKnowledgeSource()); - config.getReasoner().init(); - //System.out.println(StartGUI.myconfig.getReasoner()); + if (e.getSource() == initButton) { + if (config.getStatus(2)) { // no check if button init was used + // set reasoner + config.setReasoner(config.getComponentManager().reasoner(DIGReasoner.class, config.getKnowledgeSource())); + config.getReasoner().init(); - // set ReasoningService - config.setReasoningService(config.getComponentManager().reasoningService(config.getReasoner())); - - // get list from ReasoningService - Set<Individual> individualsSet = config.getReasoningService().getIndividuals(); - //System.out.println("IndividualsSet: " + individualsSet); - individuals = new LinkedList<Individual>(individualsSet); - //System.out.println("individuals: " + individuals); - - // make list - DefaultListModel listModel = new DefaultListModel(); - for(Individual ind : individuals) - listModel.addElement(ind); - - digList.setModel(listModel); - - // graphic - digList.setModel(listModel); - StartGUI.myrun.renew(); + // set ReasoningService + config.setReasoningService(config.getComponentManager().reasoningService(config.getReasoner())); + } + if (config.getStatus(3)) { // Reasoner is set + System.out.println("Reasoner: " + config.getReasoner()); + } + if (config.getStatus(4)) { // ReasoningServic is set + System.out.println("ReasoningService: " + config.getReasoningService()); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <ton...@us...> - 2008-01-19 16:04:45
|
Revision: 401 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=401&view=rev Author: tonytacker Date: 2008-01-19 08:04:43 -0800 (Sat, 19 Jan 2008) Log Message: ----------- - improved button for local file or URL @ KnowledgeSourcePanel - deleted myrun-variable @ StartGUI - add ComponentManager.getName($class) for class-names Modified Paths: -------------- 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/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-19 14:32:48 UTC (rev 400) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-19 16:04:43 UTC (rev 401) @@ -27,10 +27,11 @@ import javax.swing.event.*; import java.awt.BorderLayout; +import java.awt.GridBagConstraints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.GridBagLayout; -//import org.dllearner.kb.*; import org.dllearner.core.KnowledgeSource; @@ -50,10 +51,11 @@ private JTextField fileDisplay; private String[] kbBoxItems = {}; private JComboBox cb = new JComboBox(kbBoxItems); - private JPanel openPanel; + private JPanel centerPanel, choosePanel, initPanel; private Config config; private int choosenClassIndex; private List<Class<? extends KnowledgeSource>> sources; + private JLabel infoLabel = new JLabel("choose lokal file or type URL"); KnowledgeSourcePanel(final Config config) { super(new BorderLayout()); @@ -62,7 +64,7 @@ sources = config.getComponentManager().getKnowledgeSources(); fc = new JFileChooser(new File("examples/")); - openButton = new JButton("Open local file or type URL"); + openButton = new JButton("choose local file"); openButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); @@ -86,24 +88,41 @@ // add to comboBox for (int i=0; i<sources.size(); i++) { - cb.addItem(sources.get(i).getSimpleName()); + // cb.addItem(sources.get(i).getSimpleName()); + cb.addItem(config.getComponentManager().getComponentName(sources.get(i))); } cb.addActionListener(this); - openPanel = new JPanel(); - - JPanel choosePanel = new JPanel(); + choosePanel = new JPanel(); choosePanel.add(cb); - JPanel initPanel = new JPanel(); + initPanel = new JPanel(); initPanel.add(initButton); - openPanel.add(fileDisplay); - openPanel.add(openButton); + centerPanel = new JPanel(); + // define GridBag + GridBagLayout gridbag = new GridBagLayout(); + centerPanel.setLayout(gridbag); + GridBagConstraints constraints = new GridBagConstraints(); + constraints.fill = GridBagConstraints.BOTH; + constraints.anchor = GridBagConstraints.CENTER; + + buildConstraints(constraints, 0, 0, 1, 1, 100, 100); + gridbag.setConstraints(infoLabel, constraints); + centerPanel.add(infoLabel); + + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(fileDisplay, constraints); + centerPanel.add(fileDisplay); + + buildConstraints(constraints, 1, 1, 1, 1, 100, 100); + gridbag.setConstraints(openButton, constraints); + centerPanel.add(openButton); + add(choosePanel, BorderLayout.PAGE_START); - add(openPanel, BorderLayout.CENTER); + add(centerPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); choosenClassIndex = cb.getSelectedIndex(); @@ -112,6 +131,7 @@ public void actionPerformed(ActionEvent e) { // read selected KnowledgeSourceClass choosenClassIndex = cb.getSelectedIndex(); + checkIfSparcle(); // open File if (e.getSource() == openButton) { @@ -133,5 +153,26 @@ System.out.println("init KnowledgeSource with \n" + sources.get(choosenClassIndex) + " and \n" + config.getURI() + "\n"); } } + + /* + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + + private void checkIfSparcle() { + if (sources.get(choosenClassIndex).toString().contains("Sparql")) { + openButton.setEnabled(false); + } + else { + openButton.setEnabled(true); + } + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-19 14:32:48 UTC (rev 400) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-19 16:04:43 UTC (rev 401) @@ -67,7 +67,9 @@ // add into comboBox learners = config.getComponentManager().getLearningAlgorithms(); for (int i=0; i<learners.size(); i++) { - cb.addItem(learners.get(i).getSimpleName()); + //cb.addItem(learners.get(i).getSimpleName()); + //System.out.println(learners.get(i).getSimpleName()); + cb.addItem(config.getComponentManager().getComponentName(learners.get(i))); } } @@ -80,7 +82,7 @@ config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm(learners.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); config.getLearningAlgorithm().init(); } - if (config.getStatus(5)) { // exemples are set + if (config.getStatus(5)) { // examples are set System.out.println("LearningAlgorithm: " + config.getLearningAlgorithm() + "\n"); } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-19 14:32:48 UTC (rev 400) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-19 16:04:43 UTC (rev 401) @@ -88,7 +88,8 @@ // add into comboBox for (int i=0; i<problems.size(); i++) { - cb.addItem(problems.get(i).getSimpleName()); + //cb.addItem(problems.get(i).getSimpleName()); + cb.addItem(config.getComponentManager().getComponentName(problems.get(i))); } // read choosen LearningProblem Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-19 14:32:48 UTC (rev 400) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-19 16:04:43 UTC (rev 401) @@ -66,7 +66,8 @@ // add into comboBox reasoners = config.getComponentManager().getReasonerComponents(); for (int i=0; i<reasoners.size(); i++) { - cb.addItem(reasoners.get(i).getSimpleName()); + //cb.addItem(reasoners.get(i).getSimpleName()); + cb.addItem(config.getComponentManager().getComponentName(reasoners.get(i))); } } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-19 14:32:48 UTC (rev 400) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-19 16:04:43 UTC (rev 401) @@ -38,8 +38,6 @@ private static final long serialVersionUID = -739265982906533775L; - protected static StartGUI myrun; - public JTabbedPane tabPane = new JTabbedPane(); private JPanel tab1 = new JPanel(); @@ -77,15 +75,12 @@ logger.addAppender(consoleAppender); logger.setLevel(Level.INFO); - myrun = new StartGUI(); + new StartGUI(); } protected void renew() { tabPane.repaint(); } - protected StartGUI getStartGUI() { - return myrun; - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-19 17:43:49
|
Revision: 403 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=403&view=rev Author: tonytacker Date: 2008-01-19 09:43:46 -0800 (Sat, 19 Jan 2008) Log Message: ----------- + testButton in LearningAlgorithm for possible options Modified Paths: -------------- 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/OutputPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-19 16:20:53 UTC (rev 402) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-19 17:43:46 UTC (rev 403) @@ -28,8 +28,11 @@ import java.util.List; import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.config.ConfigOption; + + /** * LearningAlgorithmPanel * @@ -44,10 +47,11 @@ private List<Class<? extends LearningAlgorithm>> learners; private JPanel choosePanel = new JPanel(); private JPanel initPanel = new JPanel(); - private JButton initButton; + private JButton initButton, testButton; private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); private int choosenClassIndex; + private List<ConfigOption<?>> optionList; LearningAlgorithmPanel(Config config) { @@ -57,8 +61,11 @@ initButton = new JButton("Init LearingAlgorithm"); initButton.addActionListener(this); + testButton = new JButton("Test"); + testButton.addActionListener(this); initPanel.add(initButton); + initPanel.add(testButton); choosePanel.add(cb); add(choosePanel, BorderLayout.PAGE_START); @@ -77,6 +84,15 @@ // read selected Class choosenClassIndex = cb.getSelectedIndex(); + if (e.getSource() == testButton) { + // TEST + optionList = config.getComponentManager().getConfigOptions(learners.get(cb.getSelectedIndex())); + //System.out.println("optionName: " + optionList); + System.out.println("option 0:\n" + optionList.get(0)); + + + } + if (e.getSource() == initButton) { if (config.getStatus(6)) { config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm(learners.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-19 16:20:53 UTC (rev 402) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-19 17:43:46 UTC (rev 403) @@ -37,7 +37,6 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.dl.Individual; -//import org.dllearner.learningproblems.*; /** * LearningProblemPanel @@ -168,11 +167,7 @@ public void actionPerformed(ActionEvent e) { // read selected LearningProblemClass choosenClassIndex = cb.getSelectedIndex(); - - // later for read options - //List a = config.getComponentManager().getConfigOptions(problems.get(cb.getSelectedIndex())); - //System.out.println("optionName: " + a); - + // get list after reasoner init if (e.getSource() == readListButton) { // fill lists Modified: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-19 16:20:53 UTC (rev 402) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-19 17:43:46 UTC (rev 403) @@ -89,6 +89,7 @@ } } } + if (e.getSource() == runButton) { if (config.getStatus(6)) { config.getLearningAlgorithm().start(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-22 02:49:31
|
Revision: 407 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=407&view=rev Author: tonytacker Date: 2008-01-21 18:49:27 -0800 (Mon, 21 Jan 2008) Log Message: ----------- - add an OptionPanel (could be used in all implemented tabs) - add an AbstractWidgetPanel (will be used at future to get a panel for changing option) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java Added: trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-01-22 02:49:27 UTC (rev 407) @@ -0,0 +1,74 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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.util.List; + +//import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +//import javax.swing.JTable; +//import javax.swing.table.DefaultTableModel; + +//import org.dllearner.core.Component; +//import org.dllearner.core.ComponentManager; +//import org.dllearner.core.config.ConfigOption; +//import org.dllearner.core.ComponentManager; +import org.dllearner.core.config.ConfigOption; + + +/** + * AbstractWidgetPanel + * + * @author Tilo Hielscher + * + */ +public class AbstractWidgetPanel extends JPanel implements ActionListener { + + private static final long serialVersionUID = -1802111225835164644L; + + //private Config config; + private ConfigOption<?> configOption; + private JLabel nameLabel; + private JPanel centerPanel = new JPanel(); + + public AbstractWidgetPanel(Config config, ConfigOption<?> configOption) { + super(new BorderLayout()); + //this.config = config; + this.configOption = configOption; + + //show info + nameLabel = new JLabel(this.configOption.getName()); + centerPanel.add(nameLabel); + + //layout + add(centerPanel, BorderLayout.CENTER); + + + } + + public void actionPerformed(ActionEvent e) { + + } +} Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-21 18:29:46 UTC (rev 406) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-22 02:49:27 UTC (rev 407) @@ -21,8 +21,7 @@ */ import javax.swing.*; -import javax.swing.JTable; -import javax.swing.table.DefaultTableModel; +//import javax.swing.table.DefaultTableModel; import java.awt.BorderLayout; import java.awt.event.ActionEvent; @@ -30,8 +29,8 @@ import java.util.List; import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.config.ConfigOption; -import org.dllearner.core.ComponentManager; +//import org.dllearner.core.config.ConfigOption; +//import org.dllearner.core.ComponentManager; @@ -48,15 +47,12 @@ private Config config; private List<Class<? extends LearningAlgorithm>> learners; private JPanel choosePanel = new JPanel(); - private JPanel centerPanel = new JPanel(); + private OptionPanel centerPanel; private JPanel initPanel = new JPanel(); - private JButton initButton, testButton; + private JButton initButton; private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); private int choosenClassIndex; - private List<ConfigOption<?>> optionList; - private DefaultTableModel optionModel = new DefaultTableModel(); - private JTable optionTable = new JTable(optionModel); @@ -67,20 +63,11 @@ initButton = new JButton("Init LearingAlgorithm"); initButton.addActionListener(this); - testButton = new JButton("Test"); - testButton.addActionListener(this); - + initPanel.add(initButton); - initPanel.add(testButton); choosePanel.add(cb); - - centerPanel.add(optionTable); - add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); - // add into comboBox learners = config.getComponentManager().getLearningAlgorithms(); for (int i=0; i<learners.size(); i++) { @@ -89,58 +76,24 @@ cb.addItem(config.getComponentManager().getComponentName(learners.get(i))); } - // set JTable - optionModel.addColumn("name"); - optionModel.addColumn("default"); - optionModel.addColumn("class"); - - // first row - where is header? - optionModel.addRow(new Object[] {"name","default","class"}); - - //optionTable.setSize(400, 400); - //System.out.println("optionModel.getSize(): " + optionTable.getSize()); - optionTable.updateUI(); + cb.addActionListener(this); + + centerPanel = new OptionPanel(config, learners.get(choosenClassIndex)); + + add(choosePanel, BorderLayout.PAGE_START); + add(centerPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); + } + public void actionPerformed(ActionEvent e) { // read selected Class choosenClassIndex = cb.getSelectedIndex(); - if (e.getSource() == testButton) { - // TEST - //available options for selected class - optionList = ComponentManager.getConfigOptions(learners.get(cb.getSelectedIndex())); - //System.out.println(optionList + "\n"); - //System.out.println("option 0:\n" + optionList.get(0)); - //System.out.println("size: " + optionList.size() + "\n"); // size -/* for (int i=0; i<optionList.size(); i++) { - System.out.println("name: " + optionList.get(i).getName()); // name - System.out.println("default value: " + optionList.get(i).getDefaultValue()); // default value - System.out.println("class: " + optionList.get(i).getClass()); // class - System.out.println("description: " + optionList.get(i).getDescription()); // description - System.out.println("allowed value description: " + optionList.get(i).getAllowedValuesDescription()); // allowed value description - System.out.println(); - } -*/ - - // show Options - // clear JTable - for (int i=optionModel.getRowCount()-1; i>0; i--) { - // from last to first - optionModel.removeRow(i); - } - // new JTable - for (int i=0; i<optionList.size(); i++) { - optionModel.addRow(new Object[] {optionList.get(i).getName(), optionList.get(i).getDefaultValue(), - optionList.get(i).getClass().getSimpleName()}); - // System.out.println("v2 name: " + optionList.get(i).getName()); // name - - } - // update graphic - centerPanel.updateUI(); - - } - + // update OptionPanel + centerPanel.setClass(learners.get(choosenClassIndex)); + // init if (e.getSource() == initButton) { if (config.getStatus(6)) { @@ -152,4 +105,5 @@ } } } + } Added: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-22 02:49:27 UTC (rev 407) @@ -0,0 +1,134 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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.util.List; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +import org.dllearner.core.Component; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.config.ConfigOption; + +/** + * OptionPanel + * + * @author Tilo Hielscher + * + */ +public class OptionPanel extends JPanel implements ActionListener { + + private static final long serialVersionUID = -3053205578443575240L; + private Config config; + private Class<? extends Component> componentClass; + private List<ConfigOption<?>> optionList; + private JButton tableButton; + private JButton normalButton; + private DefaultTableModel optionModel = new DefaultTableModel(); + private JTable optionTable = new JTable(optionModel); + private JPanel startPanel = new JPanel(); + private JPanel centerPanel = new JPanel(); + + public OptionPanel(Config config, Class<? extends Component> componentClass) { + super(new BorderLayout()); + + this.config = config; + this.componentClass = componentClass; + + tableButton = new JButton("show options as table"); + tableButton.addActionListener(this); + + normalButton = new JButton("show normal"); + normalButton.addActionListener(this); + + optionList = ComponentManager.getConfigOptions(componentClass); + + startPanel.add(tableButton); + startPanel.add(normalButton); + + add(startPanel, BorderLayout.PAGE_START); + add(centerPanel, BorderLayout.CENTER); + + // set JTable + optionModel.addColumn("name"); + optionModel.addColumn("default"); + optionModel.addColumn("class"); + optionModel.addRow(new Object[] {"name","default","class"}); // header + optionTable.setSize(400, 400); + optionTable.updateUI(); + + } + + public void actionPerformed(ActionEvent e) { + // show as table + if (e.getSource() == tableButton) { + optionList = ComponentManager.getConfigOptions(componentClass); +/* + System.out.println("name: " + optionList.get(i).getName()); // name + System.out.println("default value: " + optionList.get(i).getDefaultValue()); // default value + System.out.println("class: " + optionList.get(i).getClass()); // class + System.out.println("description: " + optionList.get(i).getDescription()); // description + System.out.println("allowed value description: " + optionList.get(i).getAllowedValuesDescription()); // allowed value description +*/ + // clear JTable + for (int i=optionModel.getRowCount()-1; i>0; i--) { // from last to first + optionModel.removeRow(i); + } + // new JTable + for (int i=0; i<optionList.size(); i++) { + optionModel.addRow(new Object[] {optionList.get(i).getName(), optionList.get(i).getDefaultValue(), + optionList.get(i).getClass().getSimpleName()}); + } + // update graphic + centerPanel.add(optionTable); + centerPanel.updateUI(); + } + // show normal + if (e.getSource() == normalButton) { + optionList = ComponentManager.getConfigOptions(componentClass); // get class for options + for (int i=0; i<optionList.size(); i++) { + System.out.println("option: " + optionList.get(i)); + } + + // clear + centerPanel.removeAll(); + + //get an AbstractWidgetPanel + AbstractWidgetPanel firstPanel = new AbstractWidgetPanel(config, optionList.get(0)); + centerPanel.add(firstPanel); + + // update graphic + centerPanel.updateUI(); + + + } + } + + public void setClass (Class<? extends Component> componentClass) { + this.componentClass = componentClass; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-22 16:47:25
|
Revision: 410 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=410&view=rev Author: tonytacker Date: 2008-01-22 08:47:20 -0800 (Tue, 22 Jan 2008) Log Message: ----------- - 2 examples for OptionPanel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-01-22 15:50:29 UTC (rev 409) +++ trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-01-22 16:47:20 UTC (rev 410) @@ -25,7 +25,7 @@ import java.awt.event.ActionListener; //import java.util.List; -//import javax.swing.JButton; +import javax.swing.JTextField; import javax.swing.JLabel; import javax.swing.JPanel; //import javax.swing.JTable; @@ -49,21 +49,35 @@ private static final long serialVersionUID = -1802111225835164644L; //private Config config; - private ConfigOption<?> configOption; - private JLabel nameLabel; + //private ConfigOption<?> configOption; + //private JLabel nameLabel; private JPanel centerPanel = new JPanel(); public AbstractWidgetPanel(Config config, ConfigOption<?> configOption) { super(new BorderLayout()); //this.config = config; - this.configOption = configOption; + //this.configOption = configOption; - //show info - nameLabel = new JLabel(this.configOption.getName()); - centerPanel.add(nameLabel); + if (configOption.toString().contains("IntegerConfigOption")) { + JLabel nameLabel = new JLabel(configOption.getName()); + JTextField integerField = new JTextField(3); + integerField.setText("100"); + System.out.println(configOption.getDefaultValue()); + centerPanel.add(nameLabel); + centerPanel.add(integerField); + add(centerPanel, BorderLayout.CENTER); + } + else if (false) { + + } + else { + JLabel nameLabel = new JLabel(configOption.getName()); + JLabel notImplementedLabel = new JLabel("not implemented"); + centerPanel.add(nameLabel); + centerPanel.add(notImplementedLabel); + add(centerPanel, BorderLayout.CENTER); + } - //layout - add(centerPanel, BorderLayout.CENTER); } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-22 15:50:29 UTC (rev 409) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-22 16:47:20 UTC (rev 410) @@ -131,7 +131,7 @@ public void actionPerformed(ActionEvent e) { // read selected KnowledgeSourceClass choosenClassIndex = cb.getSelectedIndex(); - checkIfSparcle(); + checkIfSparql(); // open File if (e.getSource() == openButton) { @@ -166,7 +166,7 @@ gbc.weighty = wy; } - private void checkIfSparcle() { + private void checkIfSparql() { if (sources.get(choosenClassIndex).toString().contains("Sparql")) { openButton.setEnabled(false); infoLabel.setText("type URL"); Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-22 15:50:29 UTC (rev 409) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-22 16:47:20 UTC (rev 410) @@ -117,9 +117,11 @@ // clear centerPanel.removeAll(); - //get an AbstractWidgetPanel + //get an AbstractWidgetPanel TEST AbstractWidgetPanel firstPanel = new AbstractWidgetPanel(config, optionList.get(0)); + AbstractWidgetPanel secondPanel = new AbstractWidgetPanel(config, optionList.get(1)); centerPanel.add(firstPanel); + centerPanel.add(secondPanel); // update graphic centerPanel.updateUI(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-24 01:10:04
|
Revision: 422 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=422&view=rev Author: tonytacker Date: 2008-01-23 17:10:00 -0800 (Wed, 23 Jan 2008) Log Message: ----------- changed widgets Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java Deleted: trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-01-23 12:41:32 UTC (rev 421) +++ trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-01-24 01:10:00 UTC (rev 422) @@ -1,88 +0,0 @@ -package org.dllearner.gui; - -/** - * Copyright (C) 2007, 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.util.List; - -import javax.swing.JTextField; -import javax.swing.JLabel; -import javax.swing.JPanel; -//import javax.swing.JTable; -//import javax.swing.table.DefaultTableModel; - -//import org.dllearner.core.Component; -//import org.dllearner.core.ComponentManager; -//import org.dllearner.core.config.ConfigOption; -//import org.dllearner.core.ComponentManager; -import org.dllearner.core.config.ConfigOption; - - -/** - * AbstractWidgetPanel - * - * @author Tilo Hielscher - * - */ -public class AbstractWidgetPanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = -1802111225835164644L; - - //private Config config; - //private ConfigOption<?> configOption; - //private JLabel nameLabel; - private JPanel centerPanel = new JPanel(); - - public AbstractWidgetPanel(Config config, ConfigOption<?> configOption) { - super(new BorderLayout()); - //this.config = config; - //this.configOption = configOption; - - if (configOption.toString().contains("IntegerConfigOption")) { - JLabel nameLabel = new JLabel(configOption.getName()); - JTextField integerField = new JTextField(3); - integerField.setText("100"); - System.out.println(configOption.getDefaultValue()); - centerPanel.add(nameLabel); - centerPanel.add(integerField); - add(centerPanel, BorderLayout.CENTER); - } - else if (false) { - - } - else { - JLabel nameLabel = new JLabel(configOption.getName()); - JLabel notImplementedLabel = new JLabel("not implemented"); - centerPanel.add(nameLabel); - centerPanel.add(notImplementedLabel); - add(centerPanel, BorderLayout.CENTER); - } - - - - } - - public void actionPerformed(ActionEvent e) { - - } -} Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-23 12:41:32 UTC (rev 421) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-24 01:10:00 UTC (rev 422) @@ -32,6 +32,7 @@ import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; +import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; /** @@ -87,6 +88,9 @@ // show as table if (e.getSource() == tableButton) { optionList = ComponentManager.getConfigOptions(componentClass); + + // clear + centerPanel.removeAll(); /* System.out.println("name: " + optionList.get(i).getName()); // name System.out.println("default value: " + optionList.get(i).getDefaultValue()); // default value @@ -110,19 +114,26 @@ // show normal if (e.getSource() == normalButton) { optionList = ComponentManager.getConfigOptions(componentClass); // get class for options - for (int i=0; i<optionList.size(); i++) { +/* for (int i=0; i<optionList.size(); i++) { System.out.println("option: " + optionList.get(i)); } - +*/ // clear centerPanel.removeAll(); - //get an AbstractWidgetPanel TEST - AbstractWidgetPanel firstPanel = new AbstractWidgetPanel(config, optionList.get(0)); - AbstractWidgetPanel secondPanel = new AbstractWidgetPanel(config, optionList.get(1)); + //get a WidgetPanel TEST + WidgetPanelInteger firstPanel = new WidgetPanelInteger(config, optionList.get(0)); centerPanel.add(firstPanel); - centerPanel.add(secondPanel); + //ConfigEntry(ConfigOption<T> option, T value); + + + // PROBLEM + //ConfigEntry testEntry = new ConfigEntry(optionList.get(0), (int)10); + + + + // update graphic centerPanel.updateUI(); Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-24 01:10:00 UTC (rev 422) @@ -0,0 +1,99 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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.List; + +import javax.swing.JTextField; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JButton; + +//import javax.swing.JTable; +//import javax.swing.table.DefaultTableModel; + + +import org.dllearner.core.config.ConfigOption; + + +/** + * WidgetPanel + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelInteger extends JPanel implements ActionListener { + + private static final long serialVersionUID = -1802111225835164644L; + + //private Config config; + private ConfigOption<?> configOption; + private JLabel nameLabel; + private JPanel centerPanel = new JPanel(); + private JButton setButton = new JButton("Set"); + + + public WidgetPanelInteger(Config config, ConfigOption<?> configOption) { + //this.config = config; + this.configOption = configOption; + + // default + nameLabel = new JLabel(configOption.getName()); + setButton.addActionListener(this); + + // IntegerConfigOption + if (configOption.toString().contains("IntegerConfigOption")) { + JTextField integerField = new JTextField(3); + integerField.setText("100"); + System.out.println(configOption.getDefaultValue()); + centerPanel.add(nameLabel); + centerPanel.add(integerField); + centerPanel.add(setButton); + } + // UNKNOWN + else { + nameLabel = new JLabel(configOption.getName()); + JLabel notImplementedLabel = new JLabel("not an integer"); + notImplementedLabel.setForeground(Color.RED); + centerPanel.add(nameLabel); + centerPanel.add(notImplementedLabel); + } + + // default + add(centerPanel, BorderLayout.CENTER); + } + + public JPanel getPanel() { + return this; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == setButton) { + int number = 10; + System.out.println(number); + System.out.println(configOption); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-26 01:41:05
|
Revision: 427 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=427&view=rev Author: tonytacker Date: 2008-01-25 17:40:55 -0800 (Fri, 25 Jan 2008) Log Message: ----------- commit for me: panel to set IntegerConfigOption works, but not safe Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-24 12:52:57 UTC (rev 426) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-26 01:40:55 UTC (rev 427) @@ -47,7 +47,7 @@ private Config config; private List<Class<? extends LearningAlgorithm>> learners; private JPanel choosePanel = new JPanel(); - private OptionPanel centerPanel; + private OptionPanel optionPanel; private JPanel initPanel = new JPanel(); private JButton initButton; private String[] cbItems = {}; @@ -77,26 +77,27 @@ } cb.addActionListener(this); + + optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), learners.get(choosenClassIndex)); + updateOptionPanel(); + - centerPanel = new OptionPanel(config, learners.get(choosenClassIndex)); - add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); + add(optionPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); - } public void actionPerformed(ActionEvent e) { // read selected Class choosenClassIndex = cb.getSelectedIndex(); - - // update OptionPanel - centerPanel.setClass(learners.get(choosenClassIndex)); - + + updateOptionPanel(); + // init if (e.getSource() == initButton) { if (config.getStatus(6)) { + updateOptionPanel(); config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm(learners.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); config.getLearningAlgorithm().init(); } @@ -106,4 +107,9 @@ } } + public void updateOptionPanel() { + // update OptionPanel + optionPanel.setComponent(config.getLearningAlgorithm()); + optionPanel.setComponentOption(learners.get(choosenClassIndex)); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-24 12:52:57 UTC (rev 426) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-26 01:40:55 UTC (rev 427) @@ -32,8 +32,7 @@ import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; -import org.dllearner.core.config.ConfigEntry; -import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.*; /** * OptionPanel @@ -45,20 +44,23 @@ private static final long serialVersionUID = -3053205578443575240L; private Config config; - private Class<? extends Component> componentClass; + private Class<? extends Component> componentOption; private List<ConfigOption<?>> optionList; private JButton tableButton; private JButton normalButton; + private JButton readOptionsButton; private DefaultTableModel optionModel = new DefaultTableModel(); private JTable optionTable = new JTable(optionModel); private JPanel startPanel = new JPanel(); private JPanel centerPanel = new JPanel(); + private Component component; - public OptionPanel(Config config, Class<? extends Component> componentClass) { + public OptionPanel(Config config, Component component, Class<? extends Component> componentOption) { super(new BorderLayout()); this.config = config; - this.componentClass = componentClass; + this.component = component; + this.componentOption = componentOption; tableButton = new JButton("show options as table"); tableButton.addActionListener(this); @@ -66,10 +68,14 @@ normalButton = new JButton("show normal"); normalButton.addActionListener(this); - optionList = ComponentManager.getConfigOptions(componentClass); + readOptionsButton = new JButton("read set option"); + readOptionsButton.addActionListener(this); + + optionList = ComponentManager.getConfigOptions(componentOption); startPanel.add(tableButton); startPanel.add(normalButton); + startPanel.add(readOptionsButton); add(startPanel, BorderLayout.PAGE_START); add(centerPanel, BorderLayout.CENTER); @@ -87,17 +93,11 @@ public void actionPerformed(ActionEvent e) { // show as table if (e.getSource() == tableButton) { - optionList = ComponentManager.getConfigOptions(componentClass); + optionList = ComponentManager.getConfigOptions(componentOption); // clear centerPanel.removeAll(); -/* - System.out.println("name: " + optionList.get(i).getName()); // name - System.out.println("default value: " + optionList.get(i).getDefaultValue()); // default value - System.out.println("class: " + optionList.get(i).getClass()); // class - System.out.println("description: " + optionList.get(i).getDescription()); // description - System.out.println("allowed value description: " + optionList.get(i).getAllowedValuesDescription()); // allowed value description -*/ + // clear JTable for (int i=optionModel.getRowCount()-1; i>0; i--) { // from last to first optionModel.removeRow(i); @@ -113,35 +113,32 @@ } // show normal if (e.getSource() == normalButton) { - optionList = ComponentManager.getConfigOptions(componentClass); // get class for options -/* for (int i=0; i<optionList.size(); i++) { - System.out.println("option: " + optionList.get(i)); - } -*/ + optionList = ComponentManager.getConfigOptions(componentOption); // get class for options + // clear centerPanel.removeAll(); - //get a WidgetPanel TEST - WidgetPanelInteger firstPanel = new WidgetPanelInteger(config, optionList.get(0)); + //get a WidgetPanel Example + // optionList is the list of possible options for componentOption + // each option can be type of IntegerConfigOption, StringConfigOption and so on + WidgetPanelInteger firstPanel = new WidgetPanelInteger(config, component, componentOption, optionList.get(0)); centerPanel.add(firstPanel); - //ConfigEntry(ConfigOption<T> option, T value); - - - - // PROBLEM - //ConfigEntry testEntry = new ConfigEntry(optionList.get(0), (int)10); - - - - + // update graphic centerPanel.updateUI(); - - } + // read set options + if (e.getSource() == readOptionsButton) { + System.out.println("setOptions: " + config.getComponentManager().getConfigOption(componentOption, optionList.get(0).getName())); + } } - - public void setClass (Class<? extends Component> componentClass) { - this.componentClass = componentClass; + + public void setComponent (Component component) { + this.component = component; } + + public void setComponentOption (Class<? extends Component> componentOption) { + this.componentOption = componentOption; + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-24 12:52:57 UTC (rev 426) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-26 01:40:55 UTC (rev 427) @@ -24,18 +24,18 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Color; -//import java.util.List; import javax.swing.JTextField; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JButton; -//import javax.swing.JTable; -//import javax.swing.table.DefaultTableModel; - - +import org.dllearner.core.Component; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.IntegerConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; /** @@ -48,17 +48,22 @@ private static final long serialVersionUID = -1802111225835164644L; - //private Config config; + private Config config; private ConfigOption<?> configOption; private JLabel nameLabel; private JPanel centerPanel = new JPanel(); private JButton setButton = new JButton("Set"); - - - public WidgetPanelInteger(Config config, ConfigOption<?> configOption) { - //this.config = config; + private Component component; + private Class<? extends Component> componentOption; + + public WidgetPanelInteger(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { + this.config = config; this.configOption = configOption; + this.component = component; + this.componentOption = componentOption; + System.out.println("1st: " + component); + // default nameLabel = new JLabel(configOption.getName()); setButton.addActionListener(this); @@ -91,9 +96,30 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == setButton) { - int number = 10; - System.out.println(number); - System.out.println(configOption); + // INTEGER + Integer value = 10; + IntegerConfigOption specialOption; + String name = configOption.getName(); + //Component component = config.getLearningAlgorithm(); + System.out.println("name: " + name + " & value: " + value); + specialOption = (IntegerConfigOption) config.getComponentManager().getConfigOption(componentOption, name); + try { + ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); + System.out.println("TEST specialEntry: " + specialEntry); + System.out.println("TEST component: " + component); + config.getComponentManager().applyConfigEntry(component, specialEntry); + } + catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } } } + + public void setComponent (Component component) { + this.component = component; + } + + public void setComponentOption (Class<? extends Component> componentOption) { + this.componentOption = componentOption; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-28 02:38:42
|
Revision: 430 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=430&view=rev Author: tonytacker Date: 2008-01-27 18:38:38 -0800 (Sun, 27 Jan 2008) Log Message: ----------- WidgetPanelInteger works, but you have init it twice (its a small bug), after you can then set integers Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-26 19:25:33 UTC (rev 429) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-28 02:38:38 UTC (rev 430) @@ -21,14 +21,14 @@ */ import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; + import java.util.List; -import javax.swing.JButton; import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableModel; +import javax.swing.JScrollPane; import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; @@ -40,20 +40,16 @@ * @author Tilo Hielscher * */ -public class OptionPanel extends JPanel implements ActionListener { +public class OptionPanel extends JPanel { private static final long serialVersionUID = -3053205578443575240L; private Config config; private Class<? extends Component> componentOption; private List<ConfigOption<?>> optionList; - private JButton tableButton; - private JButton normalButton; - private JButton readOptionsButton; - private DefaultTableModel optionModel = new DefaultTableModel(); - private JTable optionTable = new JTable(optionModel); - private JPanel startPanel = new JPanel(); private JPanel centerPanel = new JPanel(); private Component component; + private GridBagLayout gridBagLayout = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); public OptionPanel(Config config, Component component, Class<? extends Component> componentOption) { super(new BorderLayout()); @@ -62,83 +58,66 @@ this.component = component; this.componentOption = componentOption; - tableButton = new JButton("show options as table"); - tableButton.addActionListener(this); - - normalButton = new JButton("show normal"); - normalButton.addActionListener(this); - - readOptionsButton = new JButton("read set option"); - readOptionsButton.addActionListener(this); - optionList = ComponentManager.getConfigOptions(componentOption); - startPanel.add(tableButton); - startPanel.add(normalButton); - startPanel.add(readOptionsButton); - - add(startPanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); + // define GridBagLayout + centerPanel.setLayout(gridBagLayout); + constraints.anchor = GridBagConstraints.NORTHWEST; - // set JTable - optionModel.addColumn("name"); - optionModel.addColumn("default"); - optionModel.addColumn("class"); - optionModel.addRow(new Object[] {"name","default","class"}); // header - optionTable.setSize(400, 400); - optionTable.updateUI(); + // add scrollPane + JScrollPane centerScroller = new JScrollPane(centerPanel); + centerScroller.setPreferredSize(new Dimension(400, 200)); + // add Panels + add(centerScroller, BorderLayout.CENTER); + + showWidgets(); } - public void actionPerformed(ActionEvent e) { - // show as table - if (e.getSource() == tableButton) { - optionList = ComponentManager.getConfigOptions(componentOption); - - // clear - centerPanel.removeAll(); - - // clear JTable - for (int i=optionModel.getRowCount()-1; i>0; i--) { // from last to first - optionModel.removeRow(i); - } - // new JTable - for (int i=0; i<optionList.size(); i++) { - optionModel.addRow(new Object[] {optionList.get(i).getName(), optionList.get(i).getDefaultValue(), - optionList.get(i).getClass().getSimpleName()}); - } - // update graphic - centerPanel.add(optionTable); - centerPanel.updateUI(); - } - // show normal - if (e.getSource() == normalButton) { - optionList = ComponentManager.getConfigOptions(componentOption); // get class for options - - // clear - centerPanel.removeAll(); - - //get a WidgetPanel Example - // optionList is the list of possible options for componentOption - // each option can be type of IntegerConfigOption, StringConfigOption and so on - WidgetPanelInteger firstPanel = new WidgetPanelInteger(config, component, componentOption, optionList.get(0)); - centerPanel.add(firstPanel); - - // update graphic - centerPanel.updateUI(); - } - // read set options - if (e.getSource() == readOptionsButton) { - System.out.println("setOptions: " + config.getComponentManager().getConfigOption(componentOption, optionList.get(0).getName())); - } - } - public void setComponent (Component component) { this.component = component; + showWidgets(); } public void setComponentOption (Class<? extends Component> componentOption) { this.componentOption = componentOption; + showWidgets(); } + /* + * define here what core.config.class is what type of widget + * WidgetPanelDefault is for none defined classes + */ + private void showWidgets() { + JPanel widgetPanel; + optionList = ComponentManager.getConfigOptions(componentOption); // get class for options + centerPanel.removeAll(); // clear panel + for (int i=0; i<optionList.size(); i++) { + buildConstraints(constraints, 0, i, 1, 1, 0, 0); + if (optionList.get(i).getClass().toString().contains("IntegerConfigOption")) { + widgetPanel = new WidgetPanelInteger(config, component, componentOption, optionList.get(i)); + } + else if (false) { + } + else { + widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); + } + gridBagLayout.setConstraints(widgetPanel, constraints); + centerPanel.add(widgetPanel); + } + centerPanel.updateUI(); // update graphic + } + + /* + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + } Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-01-28 02:38:38 UTC (rev 430) @@ -0,0 +1,61 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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.Color; + +import javax.swing.JLabel; +import javax.swing.JPanel; + +import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigOption; + + +/** + * WidgetPanelDefault + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelDefault extends JPanel { + + private static final long serialVersionUID = 4059515858894036769L; + private JLabel nameLabel; + private JPanel centerPanel = new JPanel(); + + public WidgetPanelDefault(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { + + // default + nameLabel = new JLabel(configOption.getName()); + + // text + nameLabel = new JLabel(configOption.getName()); + JLabel notImplementedLabel = new JLabel(configOption.getClass().getSimpleName() + " not implemented"); + notImplementedLabel.setForeground(Color.RED); + centerPanel.add(nameLabel); + centerPanel.add(notImplementedLabel); + + // default + add(centerPanel, BorderLayout.CENTER); + } + +} Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-26 19:25:33 UTC (rev 429) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-28 02:38:38 UTC (rev 430) @@ -39,7 +39,7 @@ /** - * WidgetPanel + * WidgetPanelInteger * * @author Tilo Hielscher * @@ -55,38 +55,19 @@ private JButton setButton = new JButton("Set"); private Component component; private Class<? extends Component> componentOption; - + + private Integer value; + private JTextField integerField = new JTextField(3); + + public WidgetPanelInteger(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; this.componentOption = componentOption; - System.out.println("1st: " + component); - - // default - nameLabel = new JLabel(configOption.getName()); - setButton.addActionListener(this); - - // IntegerConfigOption - if (configOption.toString().contains("IntegerConfigOption")) { - JTextField integerField = new JTextField(3); - integerField.setText("100"); - System.out.println(configOption.getDefaultValue()); - centerPanel.add(nameLabel); - centerPanel.add(integerField); - centerPanel.add(setButton); - } - // UNKNOWN - else { - nameLabel = new JLabel(configOption.getName()); - JLabel notImplementedLabel = new JLabel("not an integer"); - notImplementedLabel.setForeground(Color.RED); - centerPanel.add(nameLabel); - centerPanel.add(notImplementedLabel); - } - - // default + showLabel(); // name of option and tooltip + showThingToChange(); // textfield, setbutton add(centerPanel, BorderLayout.CENTER); } @@ -96,30 +77,79 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == setButton) { - // INTEGER - Integer value = 10; - IntegerConfigOption specialOption; - String name = configOption.getName(); - //Component component = config.getLearningAlgorithm(); - System.out.println("name: " + name + " & value: " + value); - specialOption = (IntegerConfigOption) config.getComponentManager().getConfigOption(componentOption, name); - try { - ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); - System.out.println("TEST specialEntry: " + specialEntry); - System.out.println("TEST component: " + component); - config.getComponentManager().applyConfigEntry(component, specialEntry); + setEntry(); + } + } + + private void showLabel() { + nameLabel = new JLabel(configOption.getName()); + centerPanel.add(nameLabel); + } + + + private void showThingToChange () { + if (component != null) { + System.out.println("show set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, configOption.getName())); + + // IntegerConfigOption + if (configOption.getClass().toString().contains("IntegerConfigOption")) { + // seted value + if (config.getComponentManager().getConfigOptionValue(component, configOption.getName()) != null) { + value = (Integer) config.getComponentManager().getConfigOptionValue(component, configOption.getName()); + System.out.println("value readed: " + value); + } + // default value + else if (configOption.getDefaultValue() != null) { + System.out.println("default value null"); + value = (Integer) configOption.getDefaultValue(); + } + // then 0 + else { + value = 0; + System.out.println("default value not null"); + } + System.out.println("value: " + value); + integerField.setText(value.toString()); + System.out.println("configOption.getDefaultValue(): " + configOption.getDefaultValue()); + setButton.addActionListener(this); + centerPanel.add(integerField); + centerPanel.add(setButton); } - catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); + // UNKNOWN + else { + nameLabel = new JLabel(configOption.getName()); + JLabel notImplementedLabel = new JLabel("not an integer"); + notImplementedLabel.setForeground(Color.RED); + centerPanel.add(nameLabel); + centerPanel.add(notImplementedLabel); } } + else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no init at moment"); + noConfigOptionLabel.setForeground(Color.RED); + centerPanel.add(noConfigOptionLabel); + } } - public void setComponent (Component component) { - this.component = component; + private void setEntry() { + // INTEGER + IntegerConfigOption specialOption; + value = Integer.parseInt(integerField.getText()); + System.out.println("set Integer: " + configOption.getName() + " = " + value); + specialOption = (IntegerConfigOption) config.getComponentManager().getConfigOption(componentOption, configOption.getName()); + try { + ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); + //System.out.println("set Integer specialEntry: " + specialEntry); + //System.out.println("set Integer component: " + component); + //System.out.println("set Integer componentOption: " + componentOption); + //System.out.println("set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, name)); + config.getComponentManager().applyConfigEntry(component, specialEntry); + // update this + System.out.println("set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, configOption.getName())); + System.out.println("seted value: " + this.value); + } + catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } } - - public void setComponentOption (Class<? extends Component> componentOption) { - this.componentOption = componentOption; - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-28 22:16:28
|
Revision: 444 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=444&view=rev Author: tonytacker Date: 2008-01-28 14:16:24 -0800 (Mon, 28 Jan 2008) Log Message: ----------- changed copyright, add check for init in KnowledgeSourcePanel, switched option and init-button in LearningAlgorithmPanel 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/MiniGUI.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java Deleted: trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,60 +0,0 @@ -/** - * Copyright (C) 2007, 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/>. - * - */ -package org.dllearner.gui; - -import java.util.List; - -import org.dllearner.core.ComponentManager; -import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.config.ConfigEntry; -import org.dllearner.core.config.InvalidConfigOptionValueException; -import org.dllearner.core.config.StringConfigOption; -import org.dllearner.kb.OWLFile; - -/** - * @author Jens Lehmann - * - */ -public class ComponentRetrievalTest { - - /** - * @param args - */ - public static void main(String[] args) { - // example 1: getting all components of a given type - ComponentManager cm = ComponentManager.getInstance(); - List<Class<? extends KnowledgeSource>> sources = cm.getKnowledgeSources(); - cm.knowledgeSource(sources.get(0)); - System.out.println(sources.get(1).toString()); - - // example 2: setting a config value using a ConfigEntry object - KnowledgeSource owlFile = cm.knowledgeSource(OWLFile.class); - StringConfigOption urlOption = (StringConfigOption) cm.getConfigOption(OWLFile.class, "url"); - ConfigEntry<String> urlEntry; - try { - urlEntry = new ConfigEntry<String>(urlOption, "http://example.com"); - cm.applyConfigEntry(owlFile, urlEntry); - } catch (InvalidConfigOptionValueException e) { - e.printStackTrace(); - } - - } - -} Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -21,8 +21,8 @@ */ import java.util.HashSet; +import java.util.List; import java.util.Set; -//import java.io.File; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; @@ -30,7 +30,9 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; +import org.dllearner.core.config.ConfigOption; + /** * config * @@ -51,6 +53,8 @@ private LearningProblem lp; private LearningAlgorithm la; + private List<ConfigOption<?>> optionLearningAlgorithm ; + /** * status should show witch variables are set * status[0] ... cm Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -41,7 +41,6 @@ * @author Tilo Hielscher * */ - public class KnowledgeSourcePanel extends JPanel implements ActionListener { private static final long serialVersionUID = -7678275020058043937L; @@ -129,24 +128,24 @@ } public void actionPerformed(ActionEvent e) { - // read selected KnowledgeSourceClass - choosenClassIndex = cb.getSelectedIndex(); - checkIfSparql(); + // read selected KnowledgeSourceClass + choosenClassIndex = cb.getSelectedIndex(); + checkIfSparql(); - // open File - if (e.getSource() == openButton) { - int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - String URI = "file://"; - URI = URI.concat(fc.getSelectedFile().toString()); // make "file://" before local URI - config.setURI(URI); //save variable - fileDisplay.setText(URI); - } - return; + // open File + if (e.getSource() == openButton) { + int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String URI = "file://"; + URI = URI.concat(fc.getSelectedFile().toString()); // make "file://" before local URI + config.setURI(URI); //save variable + fileDisplay.setText(URI); } + return; + } // init - if (e.getSource() == initButton) { + if (e.getSource() == initButton && config.getStatus(2)) { config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); config.getComponentManager().applyConfigEntry(config.getKnowledgeSource(), "url", config.getURI()); config.getKnowledgeSource().init(); Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -19,7 +19,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ - import javax.swing.*; import java.awt.BorderLayout; @@ -29,15 +28,12 @@ import org.dllearner.core.LearningAlgorithm; - - /** * LearningAlgorithmPanel * * @author Tilo Hielscher * */ - public class LearningAlgorithmPanel extends JPanel implements ActionListener { private static final long serialVersionUID = 8721490771860452959L; @@ -50,9 +46,8 @@ private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); private int choosenClassIndex; + - - LearningAlgorithmPanel(Config config) { super(new BorderLayout()); @@ -68,8 +63,6 @@ // add into comboBox learners = config.getComponentManager().getLearningAlgorithms(); for (int i=0; i<learners.size(); i++) { - //cb.addItem(learners.get(i).getSimpleName()); - //System.out.println(learners.get(i).getSimpleName()); cb.addItem(config.getComponentManager().getComponentName(learners.get(i))); } @@ -80,8 +73,9 @@ add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(initPanel, BorderLayout.CENTER); + add(optionPanel, BorderLayout.PAGE_END); + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * Modified: trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -72,6 +72,9 @@ add(centerScroller, BorderLayout.CENTER); showWidgets(); + + System.out.println("AAA: " + ComponentManager.getConfigOptions(componentOption)); + } public void setComponent (Component component) { Modified: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -34,7 +34,6 @@ * @author Tilo Hielscher * */ - public class OutputPanel extends JPanel implements ActionListener { private static final long serialVersionUID = 1643304576470046636L; Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -140,7 +140,7 @@ try { ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); //System.out.println("set Integer specialEntry: " + specialEntry); - //System.out.println("set Integer component: " + component); + System.out.println("set Integer component: " + component); //System.out.println("set Integer componentOption: " + componentOption); //System.out.println("set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, name)); config.getComponentManager().applyConfigEntry(component, specialEntry); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-28 23:32:53
|
Revision: 445 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=445&view=rev Author: tonytacker Date: 2008-01-28 15:32:48 -0800 (Mon, 28 Jan 2008) Log Message: ----------- renamed OutputPanel to RunPanel, formated code, removed variable status 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/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-28 23:32:48 UTC (rev 445) @@ -21,7 +21,6 @@ */ import java.util.HashSet; -import java.util.List; import java.util.Set; import org.dllearner.core.ComponentManager; @@ -30,9 +29,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; -import org.dllearner.core.config.ConfigOption; - /** * config * @@ -43,117 +40,86 @@ */ public class Config { - private ComponentManager cm = ComponentManager.getInstance(); - private KnowledgeSource source; - private String uri; - private ReasonerComponent reasoner; - private ReasoningService rs; - private Set<String> posExampleSet = new HashSet<String>(); - private Set<String> negExampleSet = new HashSet<String>(); - private LearningProblem lp; - private LearningAlgorithm la; - - private List<ConfigOption<?>> optionLearningAlgorithm ; - - /** - * status should show witch variables are set - * status[0] ... cm - * status[1] ... KnowledgeSource - * status[2] ... URI - * status[3] ... Resoner - * status[4] ... ReasoningService - * status[5] ... ExampleSet - * status[6] ... LearningProblem - */ - protected static boolean[] status = new boolean[8]; - - protected boolean getStatus(int position) { - if (status[position]) - return true; - else - return false; - } + private ComponentManager cm = ComponentManager.getInstance(); + private KnowledgeSource source; + private String uri; + private ReasonerComponent reasoner; + private ReasoningService rs; + private Set<String> posExampleSet = new HashSet<String>(); + private Set<String> negExampleSet = new HashSet<String>(); + private LearningProblem lp; + private LearningAlgorithm la; - protected ComponentManager getComponentManager() { - return cm; - } - - protected void setComponentManager (ComponentManager input) { - cm = input; - } + protected ComponentManager getComponentManager() { + return cm; + } - protected String getURI () { - return uri; - } - - protected void setURI (String input) { - status[2] = true; - uri = input; - } - - protected ReasonerComponent getReasoner () { - return reasoner; - } + protected void setComponentManager(ComponentManager input) { + cm = input; + } - protected void setReasoner (ReasonerComponent input) { - status[3] = true; - reasoner = input; - } - - - protected ReasoningService getReasoningService () { - return rs; - } - - protected void setReasoningService (ReasoningService input) { - status[4] = true; - rs = input; - } - - protected KnowledgeSource getKnowledgeSource() { - return source; - } + protected String getURI() { + return uri; + } - protected void setKnowledgeSource(KnowledgeSource input) { - status[1] = true; - source = input; - } + protected void setURI(String input) { + uri = input; + } - protected void setPosExampleSet(Set<String> posExampleSet) { - status[5] = true; - this.posExampleSet = posExampleSet; - } - - protected Set<String> getPosExampleSet () { - return this.posExampleSet; - } - - protected void setNegExampleSet(Set<String> negExampleSet) { - status[5] = true; - this.negExampleSet = negExampleSet; - } - - protected Set<String> getNegExampleSet () { - return this.negExampleSet; - } + protected ReasonerComponent getReasoner() { + return reasoner; + } - protected void setLearningProblem (LearningProblem input) { - status[6] = true; - lp = input; - } - - protected LearningProblem getLearningProblem () { - return lp; - } - - protected void setLearningAlgorithm (LearningAlgorithm input) { - status[6] = true; - la = input; - } - - protected LearningAlgorithm getLearningAlgorithm () { - return la; - } + protected void setReasoner(ReasonerComponent input) { + reasoner = input; + } - + protected ReasoningService getReasoningService() { + return rs; + } + + protected void setReasoningService(ReasoningService input) { + rs = input; + } + + protected KnowledgeSource getKnowledgeSource() { + return source; + } + + protected void setKnowledgeSource(KnowledgeSource input) { + source = input; + } + + protected void setPosExampleSet(Set<String> posExampleSet) { + this.posExampleSet = posExampleSet; + } + + protected Set<String> getPosExampleSet() { + return this.posExampleSet; + } + + protected void setNegExampleSet(Set<String> negExampleSet) { + this.negExampleSet = negExampleSet; + } + + protected Set<String> getNegExampleSet() { + return this.negExampleSet; + } + + protected void setLearningProblem(LearningProblem input) { + lp = input; + } + + protected LearningProblem getLearningProblem() { + return lp; + } + + protected void setLearningAlgorithm(LearningAlgorithm input) { + la = input; + } + + protected LearningAlgorithm getLearningAlgorithm() { + return la; + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -34,7 +34,6 @@ import org.dllearner.core.KnowledgeSource; - /** * KnowledgeSourcePanel * @@ -42,138 +41,146 @@ * */ public class KnowledgeSourcePanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = -7678275020058043937L; - - private JFileChooser fc; - private JButton openButton, initButton; - private JTextField fileDisplay; + + private static final long serialVersionUID = -7678275020058043937L; + + private JFileChooser fc; + private JButton openButton, initButton; + private JTextField fileDisplay; private String[] kbBoxItems = {}; - private JComboBox cb = new JComboBox(kbBoxItems); - private JPanel centerPanel, choosePanel, initPanel; - private Config config; - private int choosenClassIndex; - private List<Class<? extends KnowledgeSource>> sources; - private JLabel infoLabel = new JLabel("choose local file or type URL"); - - KnowledgeSourcePanel(final Config config) { - super(new BorderLayout()); - - this.config = config; - sources = config.getComponentManager().getKnowledgeSources(); - - fc = new JFileChooser(new File("examples/")); - openButton = new JButton("choose local file"); - openButton.addActionListener(this); - - initButton = new JButton("Init KnowledgeSource"); - initButton.addActionListener(this); - - fileDisplay = new JTextField(35); - fileDisplay.setEditable(true); - - // update config if textfield fileDisplay changed - fileDisplay.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - config.setURI(fileDisplay.getText()); - } - public void removeUpdate(DocumentEvent e) { - config.setURI(fileDisplay.getText()); - } - public void changedUpdate(DocumentEvent e) { - config.setURI(fileDisplay.getText()); - } - }); - - // add to comboBox - for (int i=0; i<sources.size(); i++) { - // cb.addItem(sources.get(i).getSimpleName()); - cb.addItem(config.getComponentManager().getComponentName(sources.get(i))); - } - - cb.addActionListener(this); - - choosePanel = new JPanel(); - choosePanel.add(cb); + private JComboBox cb = new JComboBox(kbBoxItems); + private JPanel centerPanel, choosePanel, initPanel; + private Config config; + private int choosenClassIndex; + private List<Class<? extends KnowledgeSource>> sources; + private JLabel infoLabel = new JLabel("choose local file or type URL"); - initPanel = new JPanel(); - initPanel.add(initButton); + KnowledgeSourcePanel(final Config config) { + super(new BorderLayout()); - centerPanel = new JPanel(); - - // define GridBag - GridBagLayout gridbag = new GridBagLayout(); - centerPanel.setLayout(gridbag); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.fill = GridBagConstraints.BOTH; - constraints.anchor = GridBagConstraints.CENTER; + this.config = config; + sources = config.getComponentManager().getKnowledgeSources(); - buildConstraints(constraints, 0, 0, 1, 1, 100, 100); - gridbag.setConstraints(infoLabel, constraints); - centerPanel.add(infoLabel); + fc = new JFileChooser(new File("examples/")); + openButton = new JButton("choose local file"); + openButton.addActionListener(this); - buildConstraints(constraints, 0, 1, 1, 1, 100, 100); - gridbag.setConstraints(fileDisplay, constraints); - centerPanel.add(fileDisplay); - - buildConstraints(constraints, 1, 1, 1, 1, 100, 100); - gridbag.setConstraints(openButton, constraints); - centerPanel.add(openButton); - - add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); - - choosenClassIndex = cb.getSelectedIndex(); + initButton = new JButton("Init KnowledgeSource"); + initButton.addActionListener(this); + + fileDisplay = new JTextField(35); + fileDisplay.setEditable(true); + + // update config if textfield fileDisplay changed + fileDisplay.getDocument().addDocumentListener(new DocumentListener() { + public void insertUpdate(DocumentEvent e) { + config.setURI(fileDisplay.getText()); + } + + public void removeUpdate(DocumentEvent e) { + config.setURI(fileDisplay.getText()); + } + + public void changedUpdate(DocumentEvent e) { + config.setURI(fileDisplay.getText()); + } + }); + + // add to comboBox + for (int i = 0; i < sources.size(); i++) { + // cb.addItem(sources.get(i).getSimpleName()); + cb.addItem(config.getComponentManager().getComponentName( + sources.get(i))); } - - public void actionPerformed(ActionEvent e) { - // read selected KnowledgeSourceClass - choosenClassIndex = cb.getSelectedIndex(); - checkIfSparql(); - - // open File - if (e.getSource() == openButton) { - int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - String URI = "file://"; - URI = URI.concat(fc.getSelectedFile().toString()); // make "file://" before local URI - config.setURI(URI); //save variable - fileDisplay.setText(URI); - } - return; + + cb.addActionListener(this); + + choosePanel = new JPanel(); + choosePanel.add(cb); + + initPanel = new JPanel(); + initPanel.add(initButton); + + centerPanel = new JPanel(); + + // define GridBag + GridBagLayout gridbag = new GridBagLayout(); + centerPanel.setLayout(gridbag); + GridBagConstraints constraints = new GridBagConstraints(); + constraints.fill = GridBagConstraints.BOTH; + constraints.anchor = GridBagConstraints.CENTER; + + buildConstraints(constraints, 0, 0, 1, 1, 100, 100); + gridbag.setConstraints(infoLabel, constraints); + centerPanel.add(infoLabel); + + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(fileDisplay, constraints); + centerPanel.add(fileDisplay); + + buildConstraints(constraints, 1, 1, 1, 1, 100, 100); + gridbag.setConstraints(openButton, constraints); + centerPanel.add(openButton); + + add(choosePanel, BorderLayout.PAGE_START); + add(centerPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); + + choosenClassIndex = cb.getSelectedIndex(); + } + + public void actionPerformed(ActionEvent e) { + // read selected KnowledgeSourceClass + choosenClassIndex = cb.getSelectedIndex(); + checkIfSparql(); + + // open File + if (e.getSource() == openButton) { + int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String URI = "file://"; + // make "file://" before local URI + URI = URI.concat(fc.getSelectedFile().toString()); + config.setURI(URI); // save variable + fileDisplay.setText(URI); } - - // init - if (e.getSource() == initButton && config.getStatus(2)) { - config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); - config.getComponentManager().applyConfigEntry(config.getKnowledgeSource(), "url", config.getURI()); - config.getKnowledgeSource().init(); - System.out.println("init KnowledgeSource with \n" + sources.get(choosenClassIndex) + " and \n" + config.getURI() + "\n"); - } + return; } - - /* - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; + + // init + if (e.getSource() == initButton && config.getURI() != null) { + config.setKnowledgeSource(config.getComponentManager() + .knowledgeSource(sources.get(choosenClassIndex))); + config.getComponentManager().applyConfigEntry( + config.getKnowledgeSource(), "url", config.getURI()); + config.getKnowledgeSource().init(); + System.out.println("init KnowledgeSource with \n" + + sources.get(choosenClassIndex) + " and \n" + + config.getURI() + "\n"); } - - private void checkIfSparql() { - if (sources.get(choosenClassIndex).toString().contains("Sparql")) { - openButton.setEnabled(false); - infoLabel.setText("type URL"); - } - else { - openButton.setEnabled(true); - infoLabel.setText("choose local file or type URL"); - } + } + + /* + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, + int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + + private void checkIfSparql() { + if (sources.get(choosenClassIndex).toString().contains("Sparql")) { + openButton.setEnabled(false); + infoLabel.setText("type URL"); + } else { + openButton.setEnabled(true); + infoLabel.setText("choose local file or type URL"); } - + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -35,72 +35,69 @@ * */ public class LearningAlgorithmPanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = 8721490771860452959L; + + private static final long serialVersionUID = 8721490771860452959L; private Config config; private List<Class<? extends LearningAlgorithm>> learners; - private JPanel choosePanel = new JPanel(); - private OptionPanel optionPanel; - private JPanel initPanel = new JPanel(); + private JPanel choosePanel = new JPanel(); + private OptionPanel optionPanel; + private JPanel initPanel = new JPanel(); private JButton initButton; private String[] cbItems = {}; - private JComboBox cb = new JComboBox(cbItems); - private int choosenClassIndex; + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; - - LearningAlgorithmPanel(Config config) { - super(new BorderLayout()); + LearningAlgorithmPanel(Config config) { + super(new BorderLayout()); - this.config = config; - - initButton = new JButton("Init LearingAlgorithm"); - initButton.addActionListener(this); - - initPanel.add(initButton); + this.config = config; - 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))); - } - - cb.addActionListener(this); - - optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), learners.get(choosenClassIndex)); - updateOptionPanel(); + initButton = new JButton("Init LearingAlgorithm"); + initButton.addActionListener(this); - - add(choosePanel, BorderLayout.PAGE_START); - add(initPanel, BorderLayout.CENTER); - add(optionPanel, BorderLayout.PAGE_END); - - } - + initPanel.add(initButton); - public void actionPerformed(ActionEvent e) { - // read selected Class - choosenClassIndex = cb.getSelectedIndex(); + choosePanel.add(cb); - updateOptionPanel(); - - // init - if (e.getSource() == initButton) { - if (config.getStatus(6)) { - config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm(learners.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); - updateOptionPanel(); - config.getLearningAlgorithm().init(); - } - if (config.getStatus(5)) { // examples are set - System.out.println("LearningAlgorithm: " + config.getLearningAlgorithm() + "\n"); - } - } + // add into comboBox + learners = config.getComponentManager().getLearningAlgorithms(); + for (int i = 0; i < learners.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName( + learners.get(i))); } - public void updateOptionPanel() { - // update OptionPanel - optionPanel.setComponent(config.getLearningAlgorithm()); - optionPanel.setComponentOption(learners.get(choosenClassIndex)); + cb.addActionListener(this); + + optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), + learners.get(choosenClassIndex)); + updateOptionPanel(); + + add(choosePanel, BorderLayout.PAGE_START); + add(initPanel, BorderLayout.CENTER); + add(optionPanel, BorderLayout.PAGE_END); + + } + + public void actionPerformed(ActionEvent e) { + // read selected Class + choosenClassIndex = cb.getSelectedIndex(); + + updateOptionPanel(); + + // init + if (e.getSource() == initButton && config.getLearningProblem() != null) { + config.setLearningAlgorithm(config.getComponentManager() + .learningAlgorithm(learners.get(choosenClassIndex), + config.getLearningProblem(), + config.getReasoningService())); + updateOptionPanel(); + config.getLearningAlgorithm().init(); } + } + + public void updateOptionPanel() { + // update OptionPanel + optionPanel.setComponent(config.getLearningAlgorithm()); + optionPanel.setComponentOption(learners.get(choosenClassIndex)); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -42,170 +42,175 @@ * LearningProblemPanel * * @author Tilo Hielscher - * */ - public class LearningProblemPanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = -3819627680918930203L; - private List<Class<? extends LearningProblem>> problems; + private static final long serialVersionUID = -3819627680918930203L; + + private List<Class<? extends LearningProblem>> problems; 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 JLabel posLabel = new JLabel("positive Examples"); - private JLabel negLabel = new JLabel("negative Examples"); + private JComboBox cb = new JComboBox(lpBoxItems); + private JPanel choosePanel = new JPanel(); + private JPanel centerPanel = new JPanel(); + private JPanel lpPanel = new JPanel(); + private JLabel posLabel = new JLabel("positive Examples"); + private JLabel negLabel = new JLabel("negative Examples"); private JButton initButton, readListButton; - private int choosenClassIndex; + private int choosenClassIndex; private List<Individual> individuals; private JList posList = new JList(); private JList negList = new JList(); - + private Config config; - - LearningProblemPanel(final Config config) { - super(new BorderLayout()); - this.config = config; - - initButton = new JButton("Init LearningProblem"); - initButton.addActionListener(this); - - readListButton = new JButton("Read List"); - readListButton.addActionListener(this); - - choosePanel.add(cb); - choosePanel.add(readListButton); - lpPanel.add(initButton); - add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); - add(lpPanel, BorderLayout.PAGE_END); - - problems = config.getComponentManager().getLearningProblems(); - - // add into comboBox - for (int i=0; i<problems.size(); i++) { - //cb.addItem(problems.get(i).getSimpleName()); - cb.addItem(config.getComponentManager().getComponentName(problems.get(i))); - } - - // read choosen LearningProblem - choosenClassIndex = cb.getSelectedIndex(); - - // create a scrollable list of positive examples - posList = new JList(); - posList.setLayoutOrientation(JList.VERTICAL); - posList.setVisibleRowCount(-1); - JScrollPane posListScroller = new JScrollPane(posList); - posListScroller.setPreferredSize(new Dimension(300, 200)); - - // create a scrollable list of negative examples - negList = new JList(); - negList.setLayoutOrientation(JList.VERTICAL); - negList.setVisibleRowCount(-1); - JScrollPane negListScroller = new JScrollPane(negList); - negListScroller.setPreferredSize(new Dimension(300, 200)); - - // define GridBag - GridBagLayout gridbag = new GridBagLayout(); - centerPanel.setLayout(gridbag); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.fill = GridBagConstraints.BOTH; - constraints.anchor = GridBagConstraints.CENTER; + LearningProblemPanel(final Config config) { + super(new BorderLayout()); - buildConstraints(constraints, 0, 0, 1, 1, 100, 100); - gridbag.setConstraints(posLabel, constraints); - centerPanel.add(posLabel); + this.config = config; - buildConstraints(constraints, 1, 0, 1, 1, 100, 100); - gridbag.setConstraints(negLabel, constraints); - centerPanel.add(negLabel); + initButton = new JButton("Init LearningProblem"); + initButton.addActionListener(this); - buildConstraints(constraints, 0, 1, 1, 1, 100, 100); - gridbag.setConstraints(posListScroller, constraints); - centerPanel.add(posListScroller); - - buildConstraints(constraints, 1, 1, 1, 1, 100, 100); - gridbag.setConstraints(negListScroller, constraints); - centerPanel.add(negListScroller); + readListButton = new JButton("Read List"); + readListButton.addActionListener(this); - add(centerPanel, BorderLayout.CENTER); - - // listener for posList - posList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent evt) { - if (evt.getValueIsAdjusting()) - return; - // detect witch examples have been selected - Set<String> posExampleSet = new HashSet<String>(); - int[] selectedIndices = posList.getSelectedIndices(); - for(int i : selectedIndices) - posExampleSet.add(individuals.get(i).toString()); - config.setPosExampleSet(posExampleSet); - System.out.println("posList: " + config.getPosExampleSet() ); - } - }); - - // listener for negList - negList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent evt) { - if (evt.getValueIsAdjusting()) - return; - // detect witch examples have been selected - Set<String> negExampleSet = new HashSet<String>(); - int[] selectedIndices = negList.getSelectedIndices(); - for(int i : selectedIndices) - negExampleSet.add(individuals.get(i).toString()); - config.setNegExampleSet(negExampleSet); - System.out.println("negList: " + config.getNegExampleSet() ); - } - }); + choosePanel.add(cb); + choosePanel.add(readListButton); + lpPanel.add(initButton); + add(choosePanel, BorderLayout.PAGE_START); + add(centerPanel, BorderLayout.CENTER); + add(lpPanel, BorderLayout.PAGE_END); + + problems = config.getComponentManager().getLearningProblems(); + + // add into comboBox + for (int i = 0; i < problems.size(); i++) { + // cb.addItem(problems.get(i).getSimpleName()); + cb.addItem(config.getComponentManager().getComponentName( + problems.get(i))); } - - public void actionPerformed(ActionEvent e) { - // read selected LearningProblemClass - choosenClassIndex = cb.getSelectedIndex(); - - // get list after reasoner init - if (e.getSource() == readListButton) { - // fill lists - if (config.getStatus(4)) { // only with a reasoner - 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); - } - } - - //init - if (e.getSource() == initButton) { - if (config.getStatus(5)) { - 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 with \n" + problems.get(choosenClassIndex) + "\nand " + "\nposExample: " - + config.getPosExampleSet() + "\nand negExample: " + config.getNegExampleSet()); - } - } + + // read choosen LearningProblem + choosenClassIndex = cb.getSelectedIndex(); + + // create a scrollable list of positive examples + posList = new JList(); + posList.setLayoutOrientation(JList.VERTICAL); + posList.setVisibleRowCount(-1); + JScrollPane posListScroller = new JScrollPane(posList); + posListScroller.setPreferredSize(new Dimension(300, 200)); + + // create a scrollable list of negative examples + negList = new JList(); + negList.setLayoutOrientation(JList.VERTICAL); + negList.setVisibleRowCount(-1); + JScrollPane negListScroller = new JScrollPane(negList); + negListScroller.setPreferredSize(new Dimension(300, 200)); + + // define GridBag + GridBagLayout gridbag = new GridBagLayout(); + centerPanel.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); + + buildConstraints(constraints, 1, 0, 1, 1, 100, 100); + gridbag.setConstraints(negLabel, constraints); + centerPanel.add(negLabel); + + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(posListScroller, constraints); + centerPanel.add(posListScroller); + + buildConstraints(constraints, 1, 1, 1, 1, 100, 100); + gridbag.setConstraints(negListScroller, constraints); + centerPanel.add(negListScroller); + + add(centerPanel, BorderLayout.CENTER); + + // listener for posList + posList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent evt) { + if (evt.getValueIsAdjusting()) + return; + // detect witch examples have been selected + Set<String> posExampleSet = new HashSet<String>(); + int[] selectedIndices = posList.getSelectedIndices(); + for (int i : selectedIndices) + posExampleSet.add(individuals.get(i).toString()); + config.setPosExampleSet(posExampleSet); + } + }); + + // listener for negList + negList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent evt) { + if (evt.getValueIsAdjusting()) + return; + // detect witch examples have been selected + Set<String> negExampleSet = new HashSet<String>(); + int[] selectedIndices = negList.getSelectedIndices(); + for (int i : selectedIndices) + negExampleSet.add(individuals.get(i).toString()); + config.setNegExampleSet(negExampleSet); + } + }); + } + + public void actionPerformed(ActionEvent e) { + // read selected LearningProblemClass + choosenClassIndex = cb.getSelectedIndex(); + + // get list after reasoner init + if (e.getSource() == readListButton + && 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); } - - /* - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; + + // init + if (e.getSource() == initButton + && config.getReasoningService() != null + && (config.getPosExampleSet().size() > 0 || config + .getNegExampleSet().size() > 0)) { + 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"); } - + + } + + /* + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, + int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + } Deleted: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -1,100 +0,0 @@ -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 javax.swing.*; - -import org.dllearner.core.dl.Concept; - -/** - * OutputPanel - * - * @author Tilo Hielscher - * - */ -public class OutputPanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = 1643304576470046636L; - - private JButton showButton; - private JButton runButton; - private JTextArea infoArea; - private Config config; - - OutputPanel(Config config) { - super(new BorderLayout()); - - this.config = config; - - showButton = new JButton("Show Variables"); - showButton.addActionListener(this); - - runButton = new JButton("Run"); - runButton.addActionListener(this); - - infoArea = new JTextArea(20, 50); - JScrollPane infoScroll = new JScrollPane(infoArea); - - JPanel showPanel = new JPanel(); - showPanel.add(showButton); - showPanel.add(runButton); - JPanel infoPanel = new JPanel(); - infoPanel.add(infoScroll); - - add(showPanel, BorderLayout.PAGE_START); - add(infoPanel, BorderLayout.CENTER); - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == showButton) { - infoArea.setText(""); - if (config.getStatus(1)) { // kb is set - infoArea.append("SourceClass: " + config.getKnowledgeSource().toString() + "\n"); - } - if (config.getStatus(2)) { // file is set - infoArea.append("URI: " + config.getURI() + "\n"); - } - if (config.getStatus(3)) { // Reasoner is set - infoArea.append("Reasoner: " + config.getReasoner() + "\n"); - } - if (config.getStatus(4)) { // ReasoningServic is set - infoArea.append("ReasoningService: " + config.getReasoningService() + "\n"); - } - if (false) { - for (int i = 0; i<8; i++) { // show status-vars - infoArea.append("i: " + config.getStatus(i) + "\n"); - } - } - } - - if (e.getSource() == runButton) { - if (config.getStatus(6)) { - config.getLearningAlgorithm().start(); - Concept solution = config.getLearningAlgorithm().getBestSolution(); - infoArea.setText(solution.toString()); - } - } - } -} Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -29,7 +29,6 @@ import org.dllearner.core.ReasonerComponent; - /** * ReasonerPanel * @@ -37,60 +36,56 @@ * */ public class ReasonerPanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = -7678275020058043937L; - private List<Class<? extends ReasonerComponent>> reasoners; - private JPanel choosePanel = new JPanel(); - private JPanel initPanel = new JPanel(); + private static final long serialVersionUID = -7678275020058043937L; + + 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("Init Reasoner"); - initButton.addActionListener(this); - initPanel.add(initButton); - - 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()); - cb.addItem(config.getComponentManager().getComponentName(reasoners.get(i))); - } + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; + ReasonerPanel(final Config config) { + super(new BorderLayout()); + + this.config = config; + + initButton = new JButton("Init Reasoner"); + initButton.addActionListener(this); + initPanel.add(initButton); + + 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()); + cb.addItem(config.getComponentManager().getComponentName( + reasoners.get(i))); } - - public void actionPerformed(ActionEvent e) { - // read selected Class - choosenClassIndex = cb.getSelectedIndex(); - - if (e.getSource() == initButton) { - if (config.getStatus(2)) { // no check if button initKnowledgeSource was pressed - // set reasoner - config.setReasoner(config.getComponentManager().reasoner(reasoners.get(choosenClassIndex), config.getKnowledgeSource())); - config.getReasoner().init(); - - // set ReasoningService - config.setReasoningService(config.getComponentManager().reasoningService(config.getReasoner())); - } - if (config.getStatus(3)) { // Reasoner is set - System.out.println("Reasoner: " + config.getReasoner()); - } - if (config.getStatus(4)) { // ReasoningServic is set - System.out.println("ReasoningService: " + config.getReasoningService()); - } - } + + } + + public void actionPerformed(ActionEvent e) { + // read selected Class + choosenClassIndex = cb.getSelectedIndex(); + + if (e.getSource() == initButton && config.getKnowledgeSource() != null) { + // set reasoner + config.setReasoner(config.getComponentManager().reasoner( + reasoners.get(choosenClassIndex), + config.getKnowledgeSource())); + config.getReasoner().init(); + + // set ReasoningService + config.setReasoningService(config.getComponentManager() + .reasoningService(config.getReasoner())); } + } } Added: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -0,0 +1,72 @@ +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 javax.swing.*; + +import org.dllearner.core.dl.Concept; + +/** + * OutputPanel + * + * @author Tilo Hielscher + * + */ +public class RunPanel extends JPanel implements ActionListener { + + private static final long serialVersionUID = 1643304576470046636L; + + private JButton runButton; + private JTextArea infoArea; + private Config config; + + RunPanel(Config config) { + super(new BorderLayout()); + + this.config = config; + + runButton = new JButton("Run"); + runButton.addActionListener(this); + + infoArea = new JTextArea(20, 50); + JScrollPane infoScroll = new JScrollPane(infoArea); + + JPanel showPanel = new JPanel(); + showPanel.add(runButton); + JPanel infoPanel = new JPanel(); + infoPanel.add(infoScroll); + + add(showPanel, BorderLayout.PAGE_START); + add(infoPanel, BorderLayout.CENTER); + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == runButton && config.getLearningAlgorithm() != null) { + config.getLearningAlgorithm().start(); + Concept solution = config.getLearningAlgorithm().getBestSolution(); + infoArea.setText(solution.toString()); + } + } +} Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-28 23:32:48 UTC (rev 445) @@ -35,52 +35,51 @@ */ public class StartGUI extends JFrame { - - private static final long serialVersionUID = -739265982906533775L; - - public JTabbedPane tabPane = new JTabbedPane(); - - private JPanel tab1 = new JPanel(); - private JPanel tab2 = new JPanel(); - private JPanel tab3 = new JPanel(); - private JPanel tab4 = new JPanel(); - private JPanel tab5 = new JPanel(); - public StartGUI() { - Config config = new Config(); - this.setTitle("DL-Learner GUI"); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.setLocationByPlatform(true); - this.setSize(800, 600); - tab1.add(new KnowledgeSourcePanel(config)); - tab2.add(new ReasonerPanel(config)); - tab3.add(new LearningProblemPanel(config)); - tab4.add(new LearningAlgorithmPanel(config)); - tab5.add(new OutputPanel(config)); - tabPane.addTab("Knowledge Source", tab1); - tabPane.addTab("Reasoner", tab2); - tabPane.addTab("Learning Problem", tab3); - tabPane.addTab("Learning Algorithm", tab4); - tabPane.addTab("Output", tab5); - this.add(tabPane); - this.setVisible(true); - } - - public static void main(String[] args) { - // create GUI logger - SimpleLayout layout = new SimpleLayout(); - ConsoleAppender consoleAppender = new ConsoleAppender(layout); - Logger logger = Logger.getRootLogger(); - logger.removeAllAppenders(); - logger.addAppender(consoleAppender); - logger.setLevel(Level.INFO); - - new StartGUI(); - } - - protected void renew() { - tabPane.repaint(); - } + private static final long serialVersionUID = -739265982906533775L; + public JTabbedPane tabPane = new JTabbedPane(); + private JPanel tab1 = new JPanel(); + private JPanel tab2 = new JPanel(); + private JPanel tab3 = new JPanel(); + private JPanel tab4 = new JPanel(); + private JPanel tab5 = new JPanel(); + + public StartGUI() { + Config config = new Config(); + this.setTitle("DL-Learner GUI"); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLocationByPlatform(true); + this.setSize(800, 600); + tab1.add(new KnowledgeSourcePanel(config)); + tab2.add(new ReasonerPanel(config)); + tab3.add(new LearningProblemPanel(config)); + tab4.add(new LearningAlgorithmPanel(config)); + tab5.add(new RunPanel(config)); + tabPane.addTab("Knowledge Source", tab1); + tabPane.addTab("Reasoner", tab2); + tabPane.addTab("Learning Problem", tab3); + tabPane.addTab("Learning Algorithm", tab4); + tabPane.addTab("Run", tab5); + this.add(tabPane); + this.setVisible(true); + } + + public static void main(String[] args) { + // create GUI logger + SimpleLayout layout = new SimpleLayout(); + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + Logger logger = Logger.getRootLogger(); + logger.removeAllAppenders(); + logger.addAppender(consoleAppender); + logger.setLevel(Level.INFO); + + new StartGUI(); + } + + protected void renew() { + tabPane.repaint(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-29 03:12:07
|
Revision: 446 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=446&view=rev Author: tonytacker Date: 2008-01-28 19:12:04 -0800 (Mon, 28 Jan 2008) Log Message: ----------- add AbstractWidgetPanel for all WidgetPanels to set options, add tooltip on each widgetlabel, add WidgetPanelBoolean, removed a small bug Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.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/WidgetPanelDefault.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/gui/Startgui$1.class trunk/src/dl-learner/org/dllearner/gui/Startgui.class Added: trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-01-29 03:12:04 UTC (rev 446) @@ -0,0 +1,49 @@ +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 javax.swing.JPanel; + +/** + * AbstractWidgetPanel + * + * @author Tilo Hielscher + * + */ +public abstract class AbstractWidgetPanel extends JPanel { + + + /* + * show label and tooltip + */ + protected abstract void showLabel(); + + /* + * show textfield, setbutton and so on + */ + protected abstract void showThingToChange(); + + /* + * set entry you got from showThingToChange() + */ + protected abstract void setEntry(); + +} Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 23:32:48 UTC (rev 445) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-29 03:12:04 UTC (rev 446) @@ -81,9 +81,7 @@ public void actionPerformed(ActionEvent e) { // read selected Class choosenClassIndex = cb.getSelectedIndex(); - updateOptionPanel(); - // init if (e.getSource() == initButton && config.getLearningProblem() != null) { config.setLearningAlgorithm(config.getComponentManager() @@ -91,6 +89,7 @@ config.getLearningProblem(), config.getReasoningService())); updateOptionPanel(); + System.out.println("init LearningAlgorithm"); config.getLearningAlgorithm().init(); } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-28 23:32:48 UTC (rev 445) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-29 03:12:04 UTC (rev 446) @@ -42,85 +42,95 @@ */ public class OptionPanel extends JPanel { - private static final long serialVersionUID = -3053205578443575240L; - private Config config; - private Class<? extends Component> componentOption; - private List<ConfigOption<?>> optionList; - private JPanel centerPanel = new JPanel(); - private Component component; - private GridBagLayout gridBagLayout = new GridBagLayout(); - private GridBagConstraints constraints = new GridBagConstraints(); + private static final long serialVersionUID = -3053205578443575240L; + private Config config; + private Class<? extends Component> componentOption; + private List<ConfigOption<?>> optionList; + private JPanel centerPanel = new JPanel(); + private Component component; + private GridBagLayout gridBagLayout = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); - public OptionPanel(Config config, Component component, Class<? extends Component> componentOption) { - super(new BorderLayout()); - - this.config = config; - this.component = component; - this.componentOption = componentOption; - - optionList = ComponentManager.getConfigOptions(componentOption); - - // define GridBagLayout - centerPanel.setLayout(gridBagLayout); - constraints.anchor = GridBagConstraints.NORTHWEST; + public OptionPanel(Config config, Component component, + Class<? extends Component> componentOption) { + super(new BorderLayout()); - // add scrollPane - JScrollPane centerScroller = new JScrollPane(centerPanel); - centerScroller.setPreferredSize(new Dimension(400, 200)); - - // add Panels - add(centerScroller, BorderLayout.CENTER); - - showWidgets(); + this.config = config; + this.component = component; + this.componentOption = componentOption; - System.out.println("AAA: " + ComponentManager.getConfigOptions(componentOption)); + optionList = ComponentManager.getConfigOptions(componentOption); + // define GridBagLayout + centerPanel.setLayout(gridBagLayout); + constraints.anchor = GridBagConstraints.NORTHWEST; + + // add scrollPane + JScrollPane centerScroller = new JScrollPane(centerPanel); + centerScroller.setPreferredSize(new Dimension(400, 200)); + + // add Panels + add(centerScroller, BorderLayout.CENTER); + + showWidgets(); + + System.out.println("AAA: " + + ComponentManager.getConfigOptions(componentOption)); + + } + + public void setComponent(Component component) { + this.component = component; + showWidgets(); + } + + public void setComponentOption(Class<? extends Component> componentOption) { + this.componentOption = componentOption; + showWidgets(); + } + + /* + * define here what core.config.class is what type of widget + * WidgetPanelDefault is for none defined classes + */ + private void showWidgets() { + JPanel widgetPanel; + optionList = ComponentManager.getConfigOptions(componentOption); // get + // class + // for + // options + centerPanel.removeAll(); // clear panel + for (int i = 0; i < optionList.size(); i++) { + buildConstraints(constraints, 0, i, 1, 1, 0, 0); + if (optionList.get(i).getClass().toString().contains( + "IntegerConfigOption")) { + widgetPanel = new WidgetPanelInteger(config, component, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains( + "BooleanConfigOption")) { + widgetPanel = new WidgetPanelBoolean(config, component, + componentOption, optionList.get(i)); + } else { + widgetPanel = new WidgetPanelDefault(config, component, + componentOption, optionList.get(i)); + } + gridBagLayout.setConstraints(widgetPanel, constraints); + centerPanel.add(widgetPanel); } - - public void setComponent (Component component) { - this.component = component; - showWidgets(); - } - - public void setComponentOption (Class<? extends Component> componentOption) { - this.componentOption = componentOption; - showWidgets(); - } - - /* - * define here what core.config.class is what type of widget - * WidgetPanelDefault is for none defined classes - */ - private void showWidgets() { - JPanel widgetPanel; - optionList = ComponentManager.getConfigOptions(componentOption); // get class for options - centerPanel.removeAll(); // clear panel - for (int i=0; i<optionList.size(); i++) { - buildConstraints(constraints, 0, i, 1, 1, 0, 0); - if (optionList.get(i).getClass().toString().contains("IntegerConfigOption")) { - widgetPanel = new WidgetPanelInteger(config, component, componentOption, optionList.get(i)); - } - else if (false) { - } - else { - widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); - } - gridBagLayout.setConstraints(widgetPanel, constraints); - centerPanel.add(widgetPanel); - } - centerPanel.updateUI(); // update graphic - } - - /* - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; - } - + centerPanel.updateUI(); // update graphic + } + + /* + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, + int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-28 23:32:48 UTC (rev 445) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-29 03:12:04 UTC (rev 446) @@ -86,6 +86,8 @@ // set ReasoningService config.setReasoningService(config.getComponentManager() .reasoningService(config.getReasoner())); + + System.out.println("init Reasoner"); } } } Deleted: trunk/src/dl-learner/org/dllearner/gui/Startgui$1.class =================================================================== (Binary files differ) Deleted: trunk/src/dl-learner/org/dllearner/gui/Startgui.class =================================================================== (Binary files differ) Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 03:12:04 UTC (rev 446) @@ -0,0 +1,145 @@ +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 javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JButton; + +import org.dllearner.core.Component; // import +// org.dllearner.core.ComponentManager; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.BooleanConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; + +/** + * WidgetPanelInteger + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelBoolean extends AbstractWidgetPanel implements + ActionListener { + + private static final long serialVersionUID = -4800583253223939928L; + 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 Boolean value; + private String[] kbBoxItems = { "true", "false" }; + private JComboBox cb = new JComboBox(kbBoxItems); + + public WidgetPanelBoolean(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(); + } + } + + protected void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + widgetPanel.add(nameLabel); + } + + protected void showThingToChange() { + if (component != null) { + // IntegerConfigOption + if (configOption.getClass().toString().contains( + "BooleanConfigOption")) { + // default value + if (configOption.getDefaultValue() != null) { + value = (Boolean) configOption.getDefaultValue(); + } + // then false + else { + value = false; + } + // cb.setText(value.toString()); + if (value == false) + cb.setSelectedIndex(0); + else + cb.setSelectedIndex(1); + setButton.addActionListener(this); + widgetPanel.add(cb); + widgetPanel.add(setButton); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel("not a boolean"); + notImplementedLabel.setForeground(Color.RED); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no init at moment (Boolean)"); + noConfigOptionLabel.setForeground(Color.RED); + widgetPanel.add(noConfigOptionLabel); + } + } + + protected void setEntry() { + BooleanConfigOption specialOption; + if (cb.getSelectedIndex() == 0) + value = true; + else + value = false; + specialOption = (BooleanConfigOption) config.getComponentManager() + .getConfigOption(componentOption, configOption.getName()); + try { + ConfigEntry<Boolean> specialEntry = new ConfigEntry<Boolean>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set Boolean: " + configOption.getName() + " = " + + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + } +} Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-01-28 23:32:48 UTC (rev 445) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-01-29 03:12:04 UTC (rev 446) @@ -29,33 +29,47 @@ import org.dllearner.core.Component; import org.dllearner.core.config.ConfigOption; - /** * WidgetPanelDefault * * @author Tilo Hielscher * */ -public class WidgetPanelDefault extends JPanel { +public class WidgetPanelDefault extends AbstractWidgetPanel { - private static final long serialVersionUID = 4059515858894036769L; - private JLabel nameLabel; - private JPanel centerPanel = new JPanel(); - - public WidgetPanelDefault(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { - - // default - nameLabel = new JLabel(configOption.getName()); + private static final long serialVersionUID = 4059515858894036769L; - // text - nameLabel = new JLabel(configOption.getName()); - JLabel notImplementedLabel = new JLabel(configOption.getClass().getSimpleName() + " not implemented"); - notImplementedLabel.setForeground(Color.RED); - centerPanel.add(nameLabel); - centerPanel.add(notImplementedLabel); - - // default - add(centerPanel, BorderLayout.CENTER); - } - + private ConfigOption<?> configOption; + private JLabel nameLabel; + private JPanel widgetPanel = new JPanel(); + + public WidgetPanelDefault(Config config, Component component, + Class<? extends Component> componentOption, + ConfigOption<?> configOption) { + + this.configOption = configOption; + + showLabel(); + showThingToChange(); + add(widgetPanel, BorderLayout.CENTER); + } + + protected void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + widgetPanel.add(nameLabel); + } + + protected void showThingToChange() { + JLabel notImplementedLabel = new JLabel(configOption.getClass() + .getSimpleName() + + " not implemented"); + notImplementedLabel.setForeground(Color.RED); + + widgetPanel.add(notImplementedLabel); + } + + protected void setEntry() { + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-28 23:32:48 UTC (rev 445) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 03:12:04 UTC (rev 446) @@ -30,126 +30,109 @@ import javax.swing.JPanel; import javax.swing.JButton; -import org.dllearner.core.Component; -//import org.dllearner.core.ComponentManager; +import org.dllearner.core.Component; // import +// org.dllearner.core.ComponentManager; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.IntegerConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; - /** * WidgetPanelInteger * * @author Tilo Hielscher * */ -public class WidgetPanelInteger extends JPanel implements ActionListener { +public class WidgetPanelInteger extends AbstractWidgetPanel implements + ActionListener { - private static final long serialVersionUID = -1802111225835164644L; + private static final long serialVersionUID = -1802111225835164644L; - private Config config; - private ConfigOption<?> configOption; - private JLabel nameLabel; - private JPanel centerPanel = new JPanel(); - private JButton setButton = new JButton("Set"); - private Component component; - private Class<? extends Component> componentOption; - - private Integer value; - private JTextField integerField = new JTextField(3); + 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; - - public WidgetPanelInteger(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(centerPanel, BorderLayout.CENTER); + private Integer value; + private JTextField integerField = new JTextField(3); + + public WidgetPanelInteger(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(); } - - public JPanel getPanel() { - return this; - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == setButton) { - setEntry(); - } - } - - private void showLabel() { - nameLabel = new JLabel(configOption.getName()); - centerPanel.add(nameLabel); - } - - - private void showThingToChange () { - if (component != null) { - System.out.println("show set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, configOption.getName())); + } - // IntegerConfigOption - if (configOption.getClass().toString().contains("IntegerConfigOption")) { - // seted value - if (config.getComponentManager().getConfigOptionValue(component, configOption.getName()) != null) { - value = (Integer) config.getComponentManager().getConfigOptionValue(component, configOption.getName()); - System.out.println("value readed: " + value); - } - // default value - else if (configOption.getDefaultValue() != null) { - System.out.println("default value null"); - value = (Integer) configOption.getDefaultValue(); - } - // then 0 - else { - value = 0; - System.out.println("default value not null"); - } - System.out.println("value: " + value); - integerField.setText(value.toString()); - System.out.println("configOption.getDefaultValue(): " + configOption.getDefaultValue()); - setButton.addActionListener(this); - centerPanel.add(integerField); - centerPanel.add(setButton); - } - // UNKNOWN - else { - nameLabel = new JLabel(configOption.getName()); - JLabel notImplementedLabel = new JLabel("not an integer"); - notImplementedLabel.setForeground(Color.RED); - centerPanel.add(nameLabel); - centerPanel.add(notImplementedLabel); - } + protected void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + widgetPanel.add(nameLabel); + } + + protected void showThingToChange() { + if (component != null) { + // IntegerConfigOption + if (configOption.getClass().toString().contains( + "IntegerConfigOption")) { + // default value + if (configOption.getDefaultValue() != null) { + value = (Integer) configOption.getDefaultValue(); } - else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init at moment"); - noConfigOptionLabel.setForeground(Color.RED); - centerPanel.add(noConfigOptionLabel); + // then 0 + else { + value = 0; } + integerField.setText(value.toString()); + setButton.addActionListener(this); + widgetPanel.add(integerField); + widgetPanel.add(setButton); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel("not an integer"); + notImplementedLabel.setForeground(Color.RED); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no init at moment (Integer)"); + noConfigOptionLabel.setForeground(Color.RED); + widgetPanel.add(noConfigOptionLabel); } - - private void setEntry() { - // INTEGER - IntegerConfigOption specialOption; - value = Integer.parseInt(integerField.getText()); - System.out.println("set Integer: " + configOption.getName() + " = " + value); - specialOption = (IntegerConfigOption) config.getComponentManager().getConfigOption(componentOption, configOption.getName()); - try { - ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); - //System.out.println("set Integer specialEntry: " + specialEntry); - System.out.println("set Integer component: " + component); - //System.out.println("set Integer componentOption: " + componentOption); - //System.out.println("set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, name)); - config.getComponentManager().applyConfigEntry(component, specialEntry); - // update this - System.out.println("set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, configOption.getName())); - System.out.println("seted value: " + this.value); - } - catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } + } + + protected void setEntry() { + IntegerConfigOption specialOption; + value = Integer.parseInt(integerField.getText()); // get from input + specialOption = (IntegerConfigOption) config.getComponentManager() + .getConfigOption(componentOption, configOption.getName()); + try { + ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set Integer: " + 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. |
From: <ton...@us...> - 2008-01-29 05:12:34
|
Revision: 447 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=447&view=rev Author: tonytacker Date: 2008-01-28 21:12:31 -0800 (Mon, 28 Jan 2008) Log Message: ----------- implemented all configOptions in all 4 classes Modified Paths: -------------- 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/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-29 05:12:31 UTC (rev 447) @@ -54,6 +54,7 @@ private int choosenClassIndex; private List<Class<? extends KnowledgeSource>> sources; private JLabel infoLabel = new JLabel("choose local file or type URL"); + private OptionPanel optionPanel; KnowledgeSourcePanel(final Config config) { super(new BorderLayout()); @@ -122,9 +123,17 @@ gridbag.setConstraints(openButton, constraints); centerPanel.add(openButton); + buildConstraints(constraints, 0, 2, 2, 1, 100, 100); + gridbag.setConstraints(initPanel, constraints); + centerPanel.add(initPanel); + + optionPanel = new OptionPanel(config, config.getKnowledgeSource(), + sources.get(choosenClassIndex)); + updateOptionPanel(); + add(choosePanel, BorderLayout.PAGE_START); add(centerPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(optionPanel, BorderLayout.PAGE_END); choosenClassIndex = cb.getSelectedIndex(); } @@ -132,6 +141,7 @@ public void actionPerformed(ActionEvent e) { // read selected KnowledgeSourceClass choosenClassIndex = cb.getSelectedIndex(); + updateOptionPanel(); checkIfSparql(); // open File @@ -157,6 +167,7 @@ System.out.println("init KnowledgeSource with \n" + sources.get(choosenClassIndex) + " and \n" + config.getURI() + "\n"); + updateOptionPanel(); } } @@ -183,4 +194,9 @@ } } + public void updateOptionPanel() { + // update OptionPanel + optionPanel.setComponent(config.getKnowledgeSource()); + optionPanel.setComponentOption(sources.get(choosenClassIndex)); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-29 05:12:31 UTC (rev 447) @@ -60,6 +60,7 @@ private List<Individual> individuals; private JList posList = new JList(); private JList negList = new JList(); + private OptionPanel optionPanel; private Config config; @@ -71,15 +72,12 @@ initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); - readListButton = new JButton("Read List"); + readListButton = new JButton("Get Instances"); readListButton.addActionListener(this); choosePanel.add(cb); choosePanel.add(readListButton); lpPanel.add(initButton); - add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); - add(lpPanel, BorderLayout.PAGE_END); problems = config.getComponentManager().getLearningProblems(); @@ -129,6 +127,10 @@ buildConstraints(constraints, 1, 1, 1, 1, 100, 100); gridbag.setConstraints(negListScroller, constraints); centerPanel.add(negListScroller); + + buildConstraints(constraints, 0, 2, 2, 1, 100, 100); + gridbag.setConstraints(lpPanel, constraints); + centerPanel.add(lpPanel); add(centerPanel, BorderLayout.CENTER); @@ -159,11 +161,23 @@ config.setNegExampleSet(negExampleSet); } }); + + optionPanel = new OptionPanel(config, config.getLearningProblem(), + problems.get(choosenClassIndex)); + updateOptionPanel(); + + cb.addActionListener(this); + + add(choosePanel, BorderLayout.PAGE_START); + add(centerPanel, BorderLayout.CENTER); + add(optionPanel, BorderLayout.PAGE_END); + } public void actionPerformed(ActionEvent e) { // read selected LearningProblemClass choosenClassIndex = cb.getSelectedIndex(); + updateOptionPanel(); // get list after reasoner init if (e.getSource() == readListButton @@ -196,6 +210,7 @@ config.getNegExampleSet()); config.getLearningProblem().init(); System.out.println("init LearningProblem"); + updateOptionPanel(); } } @@ -213,4 +228,9 @@ gbc.weighty = wy; } + public void updateOptionPanel() { + // update OptionPanel + optionPanel.setComponent(config.getLearningProblem()); + optionPanel.setComponentOption(problems.get(choosenClassIndex)); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-29 05:12:31 UTC (rev 447) @@ -74,9 +74,6 @@ showWidgets(); - System.out.println("AAA: " - + ComponentManager.getConfigOptions(componentOption)); - } public void setComponent(Component component) { Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-29 05:12:31 UTC (rev 447) @@ -42,6 +42,7 @@ private List<Class<? extends ReasonerComponent>> reasoners; private JPanel choosePanel = new JPanel(); private JPanel initPanel = new JPanel(); + private OptionPanel optionPanel; private JButton initButton; private Config config; private String[] cbItems = {}; @@ -59,9 +60,6 @@ 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++) { @@ -70,11 +68,22 @@ reasoners.get(i))); } + optionPanel = new OptionPanel(config, config.getReasoner(), reasoners + .get(choosenClassIndex)); + updateOptionPanel(); + + cb.addActionListener(this); + + add(choosePanel, BorderLayout.PAGE_START); + add(initPanel, BorderLayout.CENTER); + add(optionPanel, BorderLayout.PAGE_END); + } public void actionPerformed(ActionEvent e) { // read selected Class choosenClassIndex = cb.getSelectedIndex(); + updateOptionPanel(); if (e.getSource() == initButton && config.getKnowledgeSource() != null) { // set reasoner @@ -86,8 +95,15 @@ // set ReasoningService config.setReasoningService(config.getComponentManager() .reasoningService(config.getReasoner())); - + System.out.println("init Reasoner"); + updateOptionPanel(); } } + + public void updateOptionPanel() { + // update OptionPanel + optionPanel.setComponent(config.getReasoner()); + optionPanel.setComponentOption(reasoners.get(choosenClassIndex)); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 05:12:31 UTC (rev 447) @@ -30,8 +30,7 @@ import javax.swing.JPanel; import javax.swing.JButton; -import org.dllearner.core.Component; // import -// org.dllearner.core.ComponentManager; +import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.BooleanConfigOption; @@ -117,7 +116,8 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init at moment (Boolean)"); + JLabel noConfigOptionLabel = new JLabel( + "no init at moment (Boolean)"); noConfigOptionLabel.setForeground(Color.RED); widgetPanel.add(noConfigOptionLabel); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 05:12:31 UTC (rev 447) @@ -30,8 +30,7 @@ import javax.swing.JPanel; import javax.swing.JButton; -import org.dllearner.core.Component; // import -// org.dllearner.core.ComponentManager; +import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.IntegerConfigOption; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-29 05:51:33
|
Revision: 448 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=448&view=rev Author: tonytacker Date: 2008-01-28 21:51:30 -0800 (Mon, 28 Jan 2008) Log Message: ----------- changed colors on errors Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 05:12:31 UTC (rev 447) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 05:51:30 UTC (rev 448) @@ -117,8 +117,8 @@ } } else { // configOption == NULL JLabel noConfigOptionLabel = new JLabel( - "no init at moment (Boolean)"); - noConfigOptionLabel.setForeground(Color.RED); + "no init (Boolean)"); + 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-01-29 05:12:31 UTC (rev 447) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 05:51:30 UTC (rev 448) @@ -112,8 +112,8 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init at moment (Integer)"); - noConfigOptionLabel.setForeground(Color.RED); + JLabel noConfigOptionLabel = new JLabel("no init (Integer)"); + noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-30 06:03:31
|
Revision: 459 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=459&view=rev Author: tonytacker Date: 2008-01-29 22:03:27 -0800 (Tue, 29 Jan 2008) Log Message: ----------- widgetPanelBoolean without setButton, add widget double, add widget string Modified Paths: -------------- 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/WidgetPanelInteger.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-29 20:04:57 UTC (rev 458) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-30 06:03:27 UTC (rev 459) @@ -92,10 +92,7 @@ */ private void showWidgets() { JPanel widgetPanel; - optionList = ComponentManager.getConfigOptions(componentOption); // get - // class - // for - // options + optionList = ComponentManager.getConfigOptions(componentOption); centerPanel.removeAll(); // clear panel for (int i = 0; i < optionList.size(); i++) { buildConstraints(constraints, 0, i, 1, 1, 0, 0); @@ -107,6 +104,14 @@ "BooleanConfigOption")) { widgetPanel = new WidgetPanelBoolean(config, component, componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains( + "DoubleConfigOption")) { + widgetPanel = new WidgetPanelDouble(config, component, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains( + "StringConfigOption")) { + widgetPanel = new WidgetPanelString(config, component, + componentOption, optionList.get(i)); } else { widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 20:04:57 UTC (rev 458) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-30 06:03:27 UTC (rev 459) @@ -50,7 +50,6 @@ 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; @@ -76,9 +75,7 @@ } public void actionPerformed(ActionEvent e) { - if (e.getSource() == setButton) { - setEntry(); - } + setEntry(); } @Override @@ -107,9 +104,9 @@ cb.setSelectedIndex(0); else cb.setSelectedIndex(1); - setButton.addActionListener(this); + cb.addActionListener(this); + widgetPanel.add(cb); - widgetPanel.add(setButton); } // UNKNOWN else { Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-01-30 06:03:27 UTC (rev 459) @@ -0,0 +1,140 @@ +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 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.DoubleConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; + +/** + * WidgetPanelDouble + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelDouble extends AbstractWidgetPanel implements + ActionListener { + + private static final long serialVersionUID = 5238903690721116289L; + 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 Double value; + private JTextField doubleField = new JTextField(5); + + public WidgetPanelDouble(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) { + // DoubleConfigOption + if (configOption.getClass().toString().contains( + "DoubleConfigOption")) { + // default value + if (configOption.getDefaultValue() != null) { + value = (Double) configOption.getDefaultValue(); + } + // then 0 + else { + value = 0.0; + } + doubleField.setText(value.toString()); + doubleField.setToolTipText(configOption.getAllowedValuesDescription()); + setButton.addActionListener(this); + widgetPanel.add(doubleField); + widgetPanel.add(setButton); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel("not a double"); + notImplementedLabel.setForeground(Color.RED); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no init (Double)"); + noConfigOptionLabel.setForeground(Color.MAGENTA); + widgetPanel.add(noConfigOptionLabel); + } + } + + @Override + protected void setEntry() { + DoubleConfigOption specialOption; + value = Double.parseDouble(doubleField.getText()); // get from input + specialOption = (DoubleConfigOption) config.getComponentManager() + .getConfigOption(componentOption, configOption.getName()); + try { + ConfigEntry<Double> specialEntry = new ConfigEntry<Double>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set Double: " + configOption.getName() + " = " + + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + } +} Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 20:04:57 UTC (rev 458) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-30 06:03:27 UTC (rev 459) @@ -103,6 +103,7 @@ value = 0; } integerField.setText(value.toString()); + integerField.setToolTipText(configOption.getAllowedValuesDescription()); setButton.addActionListener(this); widgetPanel.add(integerField); widgetPanel.add(setButton); Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-01-30 06:03:27 UTC (rev 459) @@ -0,0 +1,140 @@ +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 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.StringConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; + +/** + * WidgetPanelString + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelString extends AbstractWidgetPanel implements + ActionListener { + + private static final long serialVersionUID = -2169739820989891226L; + 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 String value; + private JTextField stringField = new JTextField(15); + + public WidgetPanelString(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) { + // StringConfigOption + if (configOption.getClass().toString().contains( + "StringConfigOption")) { + // default value + if (configOption.getDefaultValue() != null) { + value = (String) configOption.getDefaultValue(); + } + // then "" + else { + value = ""; + } + stringField.setText(value.toString()); + stringField.setToolTipText(configOption.getAllowedValuesDescription()); + setButton.addActionListener(this); + widgetPanel.add(stringField); + widgetPanel.add(setButton); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel("not a string"); + notImplementedLabel.setForeground(Color.RED); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no init (String)"); + noConfigOptionLabel.setForeground(Color.MAGENTA); + widgetPanel.add(noConfigOptionLabel); + } + } + + @Override + protected void setEntry() { + StringConfigOption specialOption; + value = stringField.getText(); // get from input + specialOption = (StringConfigOption) config.getComponentManager() + .getConfigOption(componentOption, configOption.getName()); + try { + ConfigEntry<String> specialEntry = new ConfigEntry<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. |
From: <ton...@us...> - 2008-02-01 05:29:01
|
Revision: 480 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=480&view=rev Author: tonytacker Date: 2008-01-31 21:28:50 -0800 (Thu, 31 Jan 2008) Log Message: ----------- implement an if on all widgets to read config before setting default value, fixed some bugs to do this Modified Paths: -------------- 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 Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-01 02:50:44 UTC (rev 479) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-01 05:28:50 UTC (rev 480) @@ -129,7 +129,6 @@ optionPanel = new OptionPanel(config, config.getKnowledgeSource(), sources.get(choosenClassIndex)); - updateOptionPanel(); add(choosePanel, BorderLayout.PAGE_START); add(centerPanel, BorderLayout.CENTER); @@ -141,7 +140,6 @@ public void actionPerformed(ActionEvent e) { // read selected KnowledgeSourceClass choosenClassIndex = cb.getSelectedIndex(); - updateOptionPanel(); checkIfSparql(); // open File @@ -196,7 +194,7 @@ public void updateOptionPanel() { // update OptionPanel - optionPanel.setComponent(config.getKnowledgeSource()); - optionPanel.setComponentOption(sources.get(choosenClassIndex)); + optionPanel.update(config.getKnowledgeSource(), sources + .get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-01 02:50:44 UTC (rev 479) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-01 05:28:50 UTC (rev 480) @@ -70,7 +70,6 @@ optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), learners.get(choosenClassIndex)); - updateOptionPanel(); add(choosePanel, BorderLayout.PAGE_START); add(initPanel, BorderLayout.CENTER); @@ -81,22 +80,21 @@ public void actionPerformed(ActionEvent e) { // read selected Class choosenClassIndex = cb.getSelectedIndex(); - updateOptionPanel(); + // init if (e.getSource() == initButton && config.getLearningProblem() != null) { config.setLearningAlgorithm(config.getComponentManager() .learningAlgorithm(learners.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); - updateOptionPanel(); System.out.println("init LearningAlgorithm"); config.getLearningAlgorithm().init(); + updateOptionPanel(); } } public void updateOptionPanel() { // update OptionPanel - optionPanel.setComponent(config.getLearningAlgorithm()); - optionPanel.setComponentOption(learners.get(choosenClassIndex)); + optionPanel.update(config.getLearningAlgorithm(), learners.get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-01 02:50:44 UTC (rev 479) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-01 05:28:50 UTC (rev 480) @@ -55,7 +55,7 @@ private JPanel lpPanel = new JPanel(); private JLabel posLabel = new JLabel("positive Examples"); private JLabel negLabel = new JLabel("negative Examples"); - private JButton initButton, readListButton; + private JButton initButton; private int choosenClassIndex; private List<Individual> individuals; private JList posList = new JList(); @@ -72,18 +72,13 @@ initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); - readListButton = new JButton("Get Instances"); - readListButton.addActionListener(this); - choosePanel.add(cb); - choosePanel.add(readListButton); - lpPanel.add(initButton); + choosePanel.add(initButton); problems = config.getComponentManager().getLearningProblems(); // add into comboBox for (int i = 0; i < problems.size(); i++) { - // cb.addItem(problems.get(i).getSimpleName()); cb.addItem(config.getComponentManager().getComponentName( problems.get(i))); } @@ -127,10 +122,10 @@ buildConstraints(constraints, 1, 1, 1, 1, 100, 100); gridbag.setConstraints(negListScroller, constraints); centerPanel.add(negListScroller); - + buildConstraints(constraints, 0, 2, 2, 1, 100, 100); gridbag.setConstraints(lpPanel, constraints); - centerPanel.add(lpPanel); + centerPanel.add(lpPanel); add(centerPanel, BorderLayout.CENTER); @@ -164,41 +159,21 @@ optionPanel = new OptionPanel(config, config.getLearningProblem(), problems.get(choosenClassIndex)); - updateOptionPanel(); cb.addActionListener(this); - + add(choosePanel, BorderLayout.PAGE_START); add(centerPanel, BorderLayout.CENTER); add(optionPanel, BorderLayout.PAGE_END); - + } public void actionPerformed(ActionEvent e) { // read selected LearningProblemClass choosenClassIndex = cb.getSelectedIndex(); - updateOptionPanel(); - // get list after reasoner init - if (e.getSource() == readListButton - && 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); - } - // init - if (e.getSource() == initButton - && config.getReasoningService() != null - && (config.getPosExampleSet().size() > 0 || config - .getNegExampleSet().size() > 0)) { + if (e.getSource() == initButton && config.getReasoningService() != null) { config.setLearningProblem(config.getComponentManager() .learningProblem(problems.get(choosenClassIndex), config.getReasoningService())); @@ -211,6 +186,20 @@ config.getLearningProblem().init(); System.out.println("init LearningProblem"); updateOptionPanel(); + + // 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); + } } } @@ -230,7 +219,7 @@ public void updateOptionPanel() { // update OptionPanel - optionPanel.setComponent(config.getLearningProblem()); - optionPanel.setComponentOption(problems.get(choosenClassIndex)); + optionPanel.update(config.getLearningProblem(), problems + .get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-01 02:50:44 UTC (rev 479) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-01 05:28:50 UTC (rev 480) @@ -76,16 +76,12 @@ } - public void setComponent(Component component) { + public void update(Component component, Class<? extends Component> componentOption) { + this.componentOption = componentOption; this.component = component; showWidgets(); } - public void setComponentOption(Class<? extends Component> componentOption) { - this.componentOption = componentOption; - showWidgets(); - } - /* * define here what core.config.class is what type of widget * WidgetPanelDefault is for none defined classes Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-01 02:50:44 UTC (rev 479) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-01 05:28:50 UTC (rev 480) @@ -63,14 +63,12 @@ // add into comboBox reasoners = config.getComponentManager().getReasonerComponents(); for (int i = 0; i < reasoners.size(); i++) { - // cb.addItem(reasoners.get(i).getSimpleName()); cb.addItem(config.getComponentManager().getComponentName( reasoners.get(i))); } optionPanel = new OptionPanel(config, config.getReasoner(), reasoners .get(choosenClassIndex)); - updateOptionPanel(); cb.addActionListener(this); @@ -83,7 +81,6 @@ public void actionPerformed(ActionEvent e) { // read selected Class choosenClassIndex = cb.getSelectedIndex(); - updateOptionPanel(); if (e.getSource() == initButton && config.getKnowledgeSource() != null) { // set reasoner @@ -103,7 +100,6 @@ public void updateOptionPanel() { // update OptionPanel - optionPanel.setComponent(config.getReasoner()); - optionPanel.setComponentOption(reasoners.get(choosenClassIndex)); + optionPanel.update(config.getReasoner(), reasoners.get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-01 02:50:44 UTC (rev 479) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-01 05:28:50 UTC (rev 480) @@ -87,25 +87,30 @@ @Override protected void showThingToChange() { if (component != null) { - // IntegerConfigOption + // BooleanConfigOption if (configOption.getClass().toString().contains( "BooleanConfigOption")) { + // previous set value + if (configOption != null) { + value = (Boolean) config.getComponentManager() + .getConfigOptionValue(component, + configOption.getName()); + } // default value - if (configOption.getDefaultValue() != null) { + else if (configOption.getDefaultValue() != null) { value = (Boolean) configOption.getDefaultValue(); - System.out.println ("TEST Boolean default: " + configOption.getDefaultValue()); } - // then false - else { + // value == null + if (value == null) { value = false; } - // cb.setText(value.toString()); + // set cb-index if (value == false) cb.setSelectedIndex(0); else cb.setSelectedIndex(1); cb.addActionListener(this); - + widgetPanel.add(cb); } // UNKNOWN @@ -115,8 +120,7 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel( - "no init (Boolean)"); + JLabel noConfigOptionLabel = new JLabel("no init (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-01 02:50:44 UTC (rev 479) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-01 05:28:50 UTC (rev 480) @@ -30,7 +30,7 @@ import javax.swing.JPanel; import javax.swing.JButton; -import org.dllearner.core.Component; +import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.DoubleConfigOption; @@ -93,16 +93,23 @@ // DoubleConfigOption if (configOption.getClass().toString().contains( "DoubleConfigOption")) { + // previous set value + if (configOption != null) { + value = (Double) config.getComponentManager() + .getConfigOptionValue(component, + configOption.getName()); + } // default value - if (configOption.getDefaultValue() != null) { + else if (configOption.getDefaultValue() != null) { value = (Double) configOption.getDefaultValue(); } - // then 0 - else { + // value == null + if (value == null) { value = 0.0; } doubleField.setText(value.toString()); - doubleField.setToolTipText(configOption.getAllowedValuesDescription()); + doubleField.setToolTipText(configOption + .getAllowedValuesDescription()); setButton.addActionListener(this); widgetPanel.add(doubleField); widgetPanel.add(setButton); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-01 02:50:44 UTC (rev 479) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-01 05:28:50 UTC (rev 480) @@ -30,7 +30,7 @@ import javax.swing.JPanel; import javax.swing.JButton; -import org.dllearner.core.Component; +import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.IntegerConfigOption; @@ -94,16 +94,23 @@ // IntegerConfigOption if (configOption.getClass().toString().contains( "IntegerConfigOption")) { + // previous set value + if (configOption != null) { + value = (Integer) config.getComponentManager() + .getConfigOptionValue(component, + configOption.getName()); + } // default value - if (configOption.getDefaultValue() != null) { + else if (configOption.getDefaultValue() != null) { value = (Integer) configOption.getDefaultValue(); } - // then 0 - else { + // value == null + if (value == null) { value = 0; } integerField.setText(value.toString()); - integerField.setToolTipText(configOption.getAllowedValuesDescription()); + integerField.setToolTipText(configOption + .getAllowedValuesDescription()); setButton.addActionListener(this); widgetPanel.add(integerField); widgetPanel.add(setButton); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-01 02:50:44 UTC (rev 479) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-01 05:28:50 UTC (rev 480) @@ -30,7 +30,7 @@ import javax.swing.JPanel; import javax.swing.JButton; -import org.dllearner.core.Component; +import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.StringConfigOption; @@ -93,16 +93,23 @@ // StringConfigOption if (configOption.getClass().toString().contains( "StringConfigOption")) { + // previous set value + if (configOption != null) { + value = (String) config.getComponentManager() + .getConfigOptionValue(component, + configOption.getName()); + } // default value - if (configOption.getDefaultValue() != null) { + else if (configOption.getDefaultValue() != null) { value = (String) configOption.getDefaultValue(); } - // then "" - else { + // value == null + if (value == null) { value = ""; } stringField.setText(value.toString()); - stringField.setToolTipText(configOption.getAllowedValuesDescription()); + stringField.setToolTipText(configOption + .getAllowedValuesDescription()); setButton.addActionListener(this); widgetPanel.add(stringField); widgetPanel.add(setButton); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-01 06:38:07
|
Revision: 481 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=481&view=rev Author: tonytacker Date: 2008-01-31 22:38:03 -0800 (Thu, 31 Jan 2008) Log Message: ----------- implement JMenu for later open/save config Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-01 05:28:50 UTC (rev 480) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-01 06:38:03 UTC (rev 481) @@ -76,19 +76,20 @@ } - public void update(Component component, Class<? extends Component> componentOption) { + public void update(Component component, + Class<? extends Component> componentOption) { this.componentOption = componentOption; this.component = component; showWidgets(); } /* - * define here what core.config.class is what type of widget - * WidgetPanelDefault is for none defined classes + * Define here what core.config.class is what type of widget. + * WidgetPanelDefault is for none defined classes. */ private void showWidgets() { JPanel widgetPanel; - optionList = ComponentManager.getConfigOptions(componentOption); + optionList = ComponentManager.getConfigOptions(componentOption); centerPanel.removeAll(); // clear panel for (int i = 0; i < optionList.size(); i++) { buildConstraints(constraints, 0, i, 1, 1, 0, 0); @@ -105,9 +106,9 @@ widgetPanel = new WidgetPanelDouble(config, component, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( - "StringConfigOption")) { - widgetPanel = new WidgetPanelString(config, component, - componentOption, optionList.get(i)); + "StringConfigOption")) { + widgetPanel = new WidgetPanelString(config, component, + componentOption, optionList.get(i)); } else { widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-01 05:28:50 UTC (rev 480) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-01 06:38:03 UTC (rev 481) @@ -22,6 +22,9 @@ import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -33,25 +36,31 @@ * @author Tilo Hielscher * */ +public class StartGUI extends JFrame implements ActionListener { -public class StartGUI extends JFrame { - private static final long serialVersionUID = -739265982906533775L; - public JTabbedPane tabPane = new JTabbedPane(); + private JTabbedPane tabPane = new JTabbedPane(); + private Config config = new Config(); + private JPanel tab1 = new JPanel(); private JPanel tab2 = new JPanel(); private JPanel tab3 = new JPanel(); private JPanel tab4 = new JPanel(); private JPanel tab5 = new JPanel(); + private JMenuBar menuBar = new JMenuBar(); + private JMenu menuFile = new JMenu("File"); + private JMenuItem openItem = new JMenuItem("Open Config"); + private JMenuItem saveItem = new JMenuItem("Save Config"); + public StartGUI() { - Config config = new Config(); this.setTitle("DL-Learner GUI"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationByPlatform(true); this.setSize(800, 600); + tab1.add(new KnowledgeSourcePanel(config)); tab2.add(new ReasonerPanel(config)); tab3.add(new LearningProblemPanel(config)); @@ -62,6 +71,14 @@ tabPane.addTab("Learning Problem", tab3); tabPane.addTab("Learning Algorithm", tab4); tabPane.addTab("Run", tab5); + + this.setJMenuBar(menuBar); + menuBar.add(menuFile); + menuFile.add(openItem); + openItem.addActionListener(this); + menuFile.add(saveItem); + saveItem.addActionListener(this); + this.add(tabPane); this.setVisible(true); } @@ -78,8 +95,13 @@ new StartGUI(); } - protected void renew() { - tabPane.repaint(); + public void actionPerformed(ActionEvent e) { + if (e.getSource() == openItem) { + System.out.println("openItem was pressed"); + } + if (e.getSource() == saveItem) { + System.out.println("saveItem was pressed"); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-01 07:58:33
|
Revision: 482 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=482&view=rev Author: tonytacker Date: 2008-01-31 23:58:29 -0800 (Thu, 31 Jan 2008) Log Message: ----------- run algorithm in extra thread to stop if you want Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-01 06:38:03 UTC (rev 481) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-01 07:58:29 UTC (rev 482) @@ -38,10 +38,13 @@ private static final long serialVersionUID = 1643304576470046636L; - private JButton runButton; + private JButton runButton, stopButton; private JTextArea infoArea; private Config config; + + private ThreadRun thread; + RunPanel(Config config) { super(new BorderLayout()); @@ -49,12 +52,15 @@ runButton = new JButton("Run"); runButton.addActionListener(this); - + stopButton = new JButton("Stop"); + stopButton.addActionListener(this); + infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); JPanel showPanel = new JPanel(); showPanel.add(runButton); + showPanel.add(stopButton); JPanel infoPanel = new JPanel(); infoPanel.add(infoScroll); @@ -64,9 +70,17 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == runButton && config.getLearningAlgorithm() != null) { - config.getLearningAlgorithm().start(); - Concept solution = config.getLearningAlgorithm().getBestSolution(); - infoArea.setText(solution.toString()); + //config.getLearningAlgorithm().start(); + //thread = new ThreadRun(config); + thread = new ThreadRun(config); + thread.start(); + //Concept solution = config.getLearningAlgorithm().getBestSolution(); + //infoArea.setText(solution.toString()); } + if (e.getSource() == stopButton && config.getLearningAlgorithm() != null) { + //config.getLearningAlgorithm().stop(); + thread.exit(); + } } + } Added: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-01 07:58:29 UTC (rev 482) @@ -0,0 +1,46 @@ +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/>. + * + */ + +/** + * threadRun + * + * @author Tilo Hielscher + */ +public class ThreadRun extends Thread { + + Config config; + + public ThreadRun(Config config) { + this.config = config; + } + + // method to start thread + public void run() { + if (config.getLearningAlgorithm() != null) + config.getLearningAlgorithm().start(); + } + + public void exit() { + if (config.getLearningAlgorithm() != null) + config.getLearningAlgorithm().stop(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |