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. |