From: <ton...@us...> - 2008-02-02 02:17:21
|
Revision: 483 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=483&view=rev Author: tonytacker Date: 2008-02-01 18:17:19 -0800 (Fri, 01 Feb 2008) Log Message: ----------- choose now file/URI over widget in KnowledgeSourcePanel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.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 07:58:29 UTC (rev 482) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-02 02:17:19 UTC (rev 483) @@ -20,18 +20,11 @@ * */ -import java.io.File; import java.util.List; - import javax.swing.*; -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.core.KnowledgeSource; /** @@ -44,16 +37,14 @@ private static final long serialVersionUID = -7678275020058043937L; - private JFileChooser fc; - private JButton openButton, initButton; - private JTextField fileDisplay; + private JButton initButton, getInstancesButton; private String[] kbBoxItems = {}; private JComboBox cb = new JComboBox(kbBoxItems); - private JPanel centerPanel, choosePanel, initPanel; + private JPanel choosePanel = new JPanel(); + private JPanel initPanel = new JPanel(); private Config config; 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) { @@ -62,77 +53,27 @@ this.config = config; sources = config.getComponentManager().getKnowledgeSources(); - fc = new JFileChooser(new File("examples/")); - openButton = new JButton("choose local file"); - openButton.addActionListener(this); - + getInstancesButton = new JButton("Get Instances"); + getInstancesButton.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); - - initPanel = new JPanel(); + choosePanel.add(getInstancesButton); 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); - - buildConstraints(constraints, 0, 2, 2, 1, 100, 100); - gridbag.setConstraints(initPanel, constraints); - centerPanel.add(initPanel); - optionPanel = new OptionPanel(config, config.getKnowledgeSource(), sources.get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); - add(optionPanel, BorderLayout.PAGE_END); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); choosenClassIndex = cb.getSelectedIndex(); } @@ -140,60 +81,37 @@ 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); - } - return; - } + if (e.getSource() == getInstancesButton) + getInstances(); - // 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"); - updateOptionPanel(); - } + if (e.getSource() == initButton && config.getURI() != null) + init(); } /* - * Define GridBagConstraints + * after this, you can change widgets */ - 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; + public void getInstances() { + config.setKnowledgeSource(config.getComponentManager().knowledgeSource( + sources.get(choosenClassIndex))); + updateOptionPanel(); } - 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"); - } + /* + * after this, next tab can be used + */ + public void init() { + config.getKnowledgeSource().init(); + System.out.println("init KnowledgeSource with \n" + + sources.get(choosenClassIndex) + " and \n" + config.getURI() + + "\n"); } + /* + * update OptionPanel with new selection + */ public void updateOptionPanel() { - // update OptionPanel optionPanel.update(config.getKnowledgeSource(), sources .get(choosenClassIndex)); } Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-01 07:58:29 UTC (rev 482) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-02 02:17:19 UTC (rev 483) @@ -26,7 +26,7 @@ import javax.swing.*; -import org.dllearner.core.dl.Concept; +//import org.dllearner.core.dl.Concept; /** * OutputPanel @@ -70,8 +70,6 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == runButton && config.getLearningAlgorithm() != null) { - //config.getLearningAlgorithm().start(); - //thread = new ThreadRun(config); thread = new ThreadRun(config); thread.start(); //Concept solution = config.getLearningAlgorithm().getBestSolution(); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-01 07:58:29 UTC (rev 482) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-02 02:17:19 UTC (rev 483) @@ -24,7 +24,9 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Color; +import java.io.File; +import javax.swing.JFileChooser; import javax.swing.JTextField; import javax.swing.JLabel; import javax.swing.JPanel; @@ -76,6 +78,16 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == setButton) { + if (checkForFilename()) { + // file dialog + JFileChooser fc = new JFileChooser(new File("examples/")); + int returnVal = fc.showOpenDialog(this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + value = fc.getSelectedFile().toString(); + stringField.setText(value); + config.setURI(value); // save variable + } + } setEntry(); } } @@ -113,6 +125,8 @@ setButton.addActionListener(this); widgetPanel.add(stringField); widgetPanel.add(setButton); + if (checkForFilename()) + setButton.setText("choose local file"); } // UNKNOWN else { @@ -144,4 +158,16 @@ s.printStackTrace(); } } + + /* + * Widget filename getName() == filename you should open a file dialog in + * ActionPerformed + */ + private Boolean checkForFilename() { + if (configOption.getName().equalsIgnoreCase("filename")) + return true; + else + return false; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-02 02:49:39
|
Revision: 484 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=484&view=rev Author: tonytacker Date: 2008-02-01 18:49:37 -0800 (Fri, 01 Feb 2008) Log Message: ----------- better ReasonerPanel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-02 02:17:19 UTC (rev 483) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-02 02:49:37 UTC (rev 484) @@ -67,9 +67,9 @@ choosePanel.add(cb); choosePanel.add(getInstancesButton); - initPanel.add(initButton); optionPanel = new OptionPanel(config, config.getKnowledgeSource(), sources.get(choosenClassIndex)); + initPanel.add(initButton); add(choosePanel, BorderLayout.PAGE_START); add(optionPanel, BorderLayout.CENTER); Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-02 02:17:19 UTC (rev 483) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-02 02:49:37 UTC (rev 484) @@ -43,7 +43,7 @@ private JPanel choosePanel = new JPanel(); private JPanel initPanel = new JPanel(); private OptionPanel optionPanel; - private JButton initButton; + private JButton initButton, getInstancesButton; private Config config; private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); @@ -53,15 +53,17 @@ super(new BorderLayout()); this.config = config; + reasoners = config.getComponentManager().getReasonerComponents(); initButton = new JButton("Init Reasoner"); initButton.addActionListener(this); initPanel.add(initButton); + getInstancesButton = new JButton("Get Instances"); + getInstancesButton.addActionListener(this); choosePanel.add(cb); // add into comboBox - reasoners = config.getComponentManager().getReasonerComponents(); for (int i = 0; i < reasoners.size(); i++) { cb.addItem(config.getComponentManager().getComponentName( reasoners.get(i))); @@ -70,11 +72,13 @@ optionPanel = new OptionPanel(config, config.getReasoner(), reasoners .get(choosenClassIndex)); + choosePanel.add(getInstancesButton); + cb.addActionListener(this); add(choosePanel, BorderLayout.PAGE_START); - add(initPanel, BorderLayout.CENTER); - add(optionPanel, BorderLayout.PAGE_END); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); } @@ -82,24 +86,40 @@ // 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(); + if (e.getSource() == getInstancesButton) + getInstances(); - // set ReasoningService - config.setReasoningService(config.getComponentManager() - .reasoningService(config.getReasoner())); + if (e.getSource() == initButton && config.getKnowledgeSource() != null) + init(); + } - System.out.println("init Reasoner"); - updateOptionPanel(); - } + /* + * after this, you can change widgets + */ + public void getInstances() { + config.setReasoner(config.getComponentManager().reasoner( + reasoners.get(choosenClassIndex), config.getKnowledgeSource())); + updateOptionPanel(); } + /* + * after this, next tab can be used + */ + public void init() { + config.getReasoner().init(); + System.out.println("init Reasoner"); + // set ReasoningService + config.setReasoningService(config.getComponentManager() + .reasoningService(config.getReasoner())); + System.out.println("init ReasoningService"); + } + + /* + * update OptionPanel with new selection + */ public void updateOptionPanel() { - // update OptionPanel - optionPanel.update(config.getReasoner(), reasoners.get(choosenClassIndex)); + optionPanel.update(config.getReasoner(), reasoners + .get(choosenClassIndex)); } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-02 05:06:49
|
Revision: 485 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=485&view=rev Author: tonytacker Date: 2008-02-01 21:06:46 -0800 (Fri, 01 Feb 2008) Log Message: ----------- changed layout- LearningProblemPanel doesn't work now - will be fixed on next commit 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/ReasonerPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-02 02:49:37 UTC (rev 484) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-02 05:06:46 UTC (rev 485) @@ -49,7 +49,9 @@ private Set<String> negExampleSet = new HashSet<String>(); private LearningProblem lp; private LearningAlgorithm la; - + private boolean[] isInit = new boolean[4]; + + protected ComponentManager getComponentManager() { return cm; } @@ -122,4 +124,70 @@ return la; } + /* + * KnowledgeSource.init has run? + * return true, if it was + */ + protected boolean isInitKnowledgeSource() { + return isInit[0]; + } + + /* + * set true if you run KnowwledgeSource.init + */ + protected void setInitKnowledgeSource(Boolean is) { + isInit[0] = is; + for (int i=1; i<4; i++) + isInit[i] = false; + } + + /* + * Reasoner.init has run? + * return true, if it was + */ + protected boolean isInitReasoner() { + return isInit[1]; + } + + /* + * set true if you run Reasoner.init + */ + protected void setInitReasoner(Boolean is) { + isInit[1] = is; + for (int i=2; i<4; i++) + isInit[i] = false; + } + + /* + * LearningProblem.init has run? + * return true, if it was + */ + protected boolean isInitLearningProblem() { + return isInit[2]; + } + + /* + * set true if you run LearningProblem.init + */ + protected void setInitLearningProblem(Boolean is) { + isInit[2] = is; + for (int i=3; i<4; i++) + isInit[i] = false; + } + + /* + * LearningAlgorithm.init() has run? + * return true, if it was + */ + protected boolean isLearningAlgorithm() { + return isInit[3]; + } + + /* + * set true if you run LearningAlgorithm.init + */ + protected void setLearningAlgorithm(Boolean is) { + isInit[3] = is; + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-02 02:49:37 UTC (rev 484) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-02 05:06:46 UTC (rev 485) @@ -103,6 +103,7 @@ */ public void init() { config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); System.out.println("init KnowledgeSource with \n" + sources.get(choosenClassIndex) + " and \n" + config.getURI() + "\n"); Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-02 02:49:37 UTC (rev 484) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-02 05:06:46 UTC (rev 485) @@ -42,7 +42,7 @@ private JPanel choosePanel = new JPanel(); private OptionPanel optionPanel; private JPanel initPanel = new JPanel(); - private JButton initButton; + private JButton initButton, getInstancesButton; private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); private int choosenClassIndex; @@ -51,29 +51,30 @@ super(new BorderLayout()); this.config = config; + learners = config.getComponentManager().getLearningAlgorithms(); initButton = new JButton("Init LearingAlgorithm"); initButton.addActionListener(this); - initPanel.add(initButton); + getInstancesButton = new JButton("Get Instances"); + getInstancesButton.addActionListener(this); - 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))); } + choosePanel.add(cb); + choosePanel.add(getInstancesButton); cb.addActionListener(this); optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), learners.get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); - add(initPanel, BorderLayout.CENTER); - add(optionPanel, BorderLayout.PAGE_END); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); } @@ -81,20 +82,42 @@ // read selected Class choosenClassIndex = cb.getSelectedIndex(); - // init - if (e.getSource() == initButton && config.getLearningProblem() != null) { + if (e.getSource() == getInstancesButton) + getInstances(); + + if (e.getSource() == initButton && config.getURI() != null) + init(); + } + + /* + * after this, you can change widgets + */ + public void getInstances() { + if (config.getLearningProblem() != null + && config.getReasoningService() != null) { config.setLearningAlgorithm(config.getComponentManager() .learningAlgorithm(learners.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); - System.out.println("init LearningAlgorithm"); - config.getLearningAlgorithm().init(); updateOptionPanel(); } } + /* + * after this, next tab can be used + */ + public void init() { + config.getLearningAlgorithm().init(); + System.out.println("init LearningAlgorithm"); + + } + + /* + * update OptionPanel with new selection + */ public void updateOptionPanel() { // update OptionPanel - optionPanel.update(config.getLearningAlgorithm(), learners.get(choosenClassIndex)); + optionPanel.update(config.getLearningAlgorithm(), learners + .get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-02 02:49:37 UTC (rev 484) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-02 05:06:46 UTC (rev 485) @@ -97,9 +97,12 @@ * after this, you can change widgets */ public void getInstances() { - config.setReasoner(config.getComponentManager().reasoner( - reasoners.get(choosenClassIndex), config.getKnowledgeSource())); - updateOptionPanel(); + if (config.isInitKnowledgeSource()) { + config.setReasoner(config.getComponentManager().reasoner( + reasoners.get(choosenClassIndex), + config.getKnowledgeSource())); + updateOptionPanel(); + } } /* @@ -112,6 +115,7 @@ config.setReasoningService(config.getComponentManager() .reasoningService(config.getReasoner())); System.out.println("init ReasoningService"); + config.setInitReasoner(true); } /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-03 04:56:16
|
Revision: 486 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=486&view=rev Author: tonytacker Date: 2008-02-02 20:55:57 -0800 (Sat, 02 Feb 2008) Log Message: ----------- LearningProblemPanel works now, add WidgetPanelStringSet for StringSetConfigOption (not implemented in GUI) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-03 04:55:57 UTC (rev 486) @@ -124,7 +124,7 @@ return la; } - /* + /** * KnowledgeSource.init has run? * return true, if it was */ @@ -132,7 +132,7 @@ return isInit[0]; } - /* + /** * set true if you run KnowwledgeSource.init */ protected void setInitKnowledgeSource(Boolean is) { @@ -141,7 +141,7 @@ isInit[i] = false; } - /* + /** * Reasoner.init has run? * return true, if it was */ @@ -149,7 +149,7 @@ return isInit[1]; } - /* + /** * set true if you run Reasoner.init */ protected void setInitReasoner(Boolean is) { @@ -158,7 +158,7 @@ isInit[i] = false; } - /* + /** * LearningProblem.init has run? * return true, if it was */ @@ -166,7 +166,7 @@ return isInit[2]; } - /* + /** * set true if you run LearningProblem.init */ protected void setInitLearningProblem(Boolean is) { @@ -175,7 +175,7 @@ isInit[i] = false; } - /* + /** * LearningAlgorithm.init() has run? * return true, if it was */ @@ -183,7 +183,7 @@ return isInit[3]; } - /* + /** * set true if you run LearningAlgorithm.init */ protected void setLearningAlgorithm(Boolean is) { Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-03 04:55:57 UTC (rev 486) @@ -89,7 +89,7 @@ init(); } - /* + /** * after this, you can change widgets */ public void getInstances() { @@ -98,7 +98,7 @@ updateOptionPanel(); } - /* + /** * after this, next tab can be used */ public void init() { @@ -109,7 +109,7 @@ + "\n"); } - /* + /** * update OptionPanel with new selection */ public void updateOptionPanel() { Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-03 04:55:57 UTC (rev 486) @@ -82,14 +82,14 @@ // read selected Class choosenClassIndex = cb.getSelectedIndex(); - if (e.getSource() == getInstancesButton) + if (e.getSource() == getInstancesButton && config.isInitLearningProblem()) getInstances(); - if (e.getSource() == initButton && config.getURI() != null) + if (e.getSource() == initButton && config.isInitLearningProblem()) init(); } - /* + /** * after this, you can change widgets */ public void getInstances() { @@ -103,7 +103,7 @@ } } - /* + /** * after this, next tab can be used */ public void init() { @@ -112,7 +112,7 @@ } - /* + /** * update OptionPanel with new selection */ public void updateOptionPanel() { Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-03 04:55:57 UTC (rev 486) @@ -51,11 +51,11 @@ private String[] lpBoxItems = {}; private JComboBox cb = new JComboBox(lpBoxItems); private JPanel choosePanel = new JPanel(); - private JPanel centerPanel = new JPanel(); - private JPanel lpPanel = new JPanel(); + private JPanel listPanel = new JPanel(); + private JPanel initPanel = new JPanel(); private JLabel posLabel = new JLabel("positive Examples"); private JLabel negLabel = new JLabel("negative Examples"); - private JButton initButton; + private JButton initButton, getInstancesButton; private int choosenClassIndex; private List<Individual> individuals; private JList posList = new JList(); @@ -71,9 +71,12 @@ initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); - + initPanel.add(initButton); + getInstancesButton = new JButton("Get Instances"); + getInstancesButton.addActionListener(this); choosePanel.add(cb); - choosePanel.add(initButton); + choosePanel.add(getInstancesButton); + cb.addActionListener(this); problems = config.getComponentManager().getLearningProblems(); @@ -102,33 +105,29 @@ // define GridBag GridBagLayout gridbag = new GridBagLayout(); - centerPanel.setLayout(gridbag); + listPanel.setLayout(gridbag); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; buildConstraints(constraints, 0, 0, 1, 1, 100, 100); gridbag.setConstraints(posLabel, constraints); - centerPanel.add(posLabel); + listPanel.add(posLabel); buildConstraints(constraints, 1, 0, 1, 1, 100, 100); gridbag.setConstraints(negLabel, constraints); - centerPanel.add(negLabel); + listPanel.add(negLabel); buildConstraints(constraints, 0, 1, 1, 1, 100, 100); gridbag.setConstraints(posListScroller, constraints); - centerPanel.add(posListScroller); + listPanel.add(posListScroller); buildConstraints(constraints, 1, 1, 1, 1, 100, 100); gridbag.setConstraints(negListScroller, constraints); - centerPanel.add(negListScroller); + listPanel.add(negListScroller); - buildConstraints(constraints, 0, 2, 2, 1, 100, 100); - gridbag.setConstraints(lpPanel, constraints); - centerPanel.add(lpPanel); + add(listPanel, BorderLayout.CENTER); - add(centerPanel, BorderLayout.CENTER); - // listener for posList posList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { @@ -160,11 +159,13 @@ optionPanel = new OptionPanel(config, config.getLearningProblem(), problems.get(choosenClassIndex)); - cb.addActionListener(this); + buildConstraints(constraints, 0, 2, 2, 1, 100, 100); + gridbag.setConstraints(optionPanel, constraints); + listPanel.add(optionPanel); add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); - add(optionPanel, BorderLayout.PAGE_END); + add(listPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); } @@ -172,39 +173,14 @@ // read selected LearningProblemClass choosenClassIndex = cb.getSelectedIndex(); - // init - if (e.getSource() == initButton && config.getReasoningService() != null) { - config.setLearningProblem(config.getComponentManager() - .learningProblem(problems.get(choosenClassIndex), - config.getReasoningService())); - config.getComponentManager().applyConfigEntry( - config.getLearningProblem(), "positiveExamples", - config.getPosExampleSet()); - config.getComponentManager().applyConfigEntry( - config.getLearningProblem(), "negativeExamples", - config.getNegExampleSet()); - config.getLearningProblem().init(); - System.out.println("init LearningProblem"); - updateOptionPanel(); + if (e.getSource() == getInstancesButton && config.isInitReasoner()) + getInstances(); - // lists - if (config.getReasoningService() != null) { - // fill lists - Set<Individual> individualsSet = config.getReasoningService() - .getIndividuals(); - individuals = new LinkedList<Individual>(individualsSet); - DefaultListModel listModel = new DefaultListModel(); - for (Individual ind : individuals) { - listModel.addElement(ind); - } - posList.setModel(listModel); - negList.setModel(listModel); - } - } - + if (e.getSource() == initButton && config.isInitReasoner()) + init(); } - /* + /** * Define GridBagConstraints */ private void buildConstraints(GridBagConstraints gbc, int gx, int gy, @@ -217,6 +193,47 @@ gbc.weighty = wy; } + /** + * after this, you can change widgets + */ + public void getInstances() { + config.setLearningProblem(config.getComponentManager().learningProblem( + problems.get(choosenClassIndex), config.getReasoningService())); + // lists + if (config.getReasoningService() != null) { + // fill lists + Set<Individual> individualsSet = config.getReasoningService() + .getIndividuals(); + individuals = new LinkedList<Individual>(individualsSet); + DefaultListModel listModel = new DefaultListModel(); + for (Individual ind : individuals) { + listModel.addElement(ind); + } + posList.setModel(listModel); + negList.setModel(listModel); + } + updateOptionPanel(); + } + + /** + * after this, next tab can be used + */ + public void init() { + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "positiveExamples", + config.getPosExampleSet()); + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "negativeExamples", + config.getNegExampleSet()); + config.getLearningProblem().init(); + config.setInitLearningProblem(true); + System.out.println("init LearningProblem"); + + } + + /** + * update OptionPanel with new selection + */ public void updateOptionPanel() { // update OptionPanel optionPanel.update(config.getLearningProblem(), problems Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-03 04:55:57 UTC (rev 486) @@ -109,7 +109,11 @@ "StringConfigOption")) { widgetPanel = new WidgetPanelString(config, component, componentOption, optionList.get(i)); - } else { +/* } else if (optionList.get(i).getClass().toString().contains( + "StringSetConfigOption")) { + widgetPanel = new WidgetPanelStringSet(config, component, + componentOption, optionList.get(i)); +*/ } else { widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-03 04:55:57 UTC (rev 486) @@ -93,7 +93,7 @@ init(); } - /* + /** * after this, you can change widgets */ public void getInstances() { @@ -105,7 +105,7 @@ } } - /* + /** * after this, next tab can be used */ public void init() { @@ -118,7 +118,7 @@ config.setInitReasoner(true); } - /* + /** * update OptionPanel with new selection */ public void updateOptionPanel() { Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-03 04:55:57 UTC (rev 486) @@ -120,7 +120,7 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init (Boolean)"); + JLabel noConfigOptionLabel = new JLabel("no instance (Boolean)"); noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-03 04:55:57 UTC (rev 486) @@ -121,7 +121,7 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init (Double)"); + JLabel noConfigOptionLabel = new JLabel("no instance (Double)"); noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-03 04:55:57 UTC (rev 486) @@ -122,7 +122,7 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init (Integer)"); + JLabel noConfigOptionLabel = new JLabel("no instance (Integer)"); noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-02 05:06:46 UTC (rev 485) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-03 04:55:57 UTC (rev 486) @@ -135,7 +135,7 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init (String)"); + JLabel noConfigOptionLabel = new JLabel("no instance (String)"); noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-03 04:55:57 UTC (rev 486) @@ -0,0 +1,139 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.Color; +import java.util.Set; + +//import javax.swing.JTextField; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JButton; + +import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.StringSetConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; + +/** + * WidgetPanelStringSet + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelStringSet extends AbstractWidgetPanel implements + ActionListener { + + private static final long serialVersionUID = 7832726987046601916L; + private Config config; + private ConfigOption<?> configOption; + private JLabel nameLabel; + private JPanel widgetPanel = new JPanel(); + private JButton setButton = new JButton("Set"); + private Component component; + private Class<? extends Component> componentOption; + + private Set<String> value; + //private JTextField stringField = new JTextField(15); + + public WidgetPanelStringSet(Config config, Component component, + Class<? extends Component> componentOption, + ConfigOption<?> configOption) { + this.config = config; + this.configOption = configOption; + this.component = component; + this.componentOption = componentOption; + + showLabel(); // name of option and tooltip + showThingToChange(); // textfield, setbutton + add(widgetPanel, BorderLayout.CENTER); + } + + public JPanel getPanel() { + return this; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == setButton) { + setEntry(); + } + } + + @Override + protected void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + widgetPanel.add(nameLabel); + } + + @Override + protected void showThingToChange() { + if (component != null) { + // StringSetConfigOption + if (configOption.getClass().toString().contains( + "StringSetConfigOption")) { + setButton.addActionListener(this); + //widgetPanel.add(stringField); + widgetPanel.add(setButton); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel("not a stringSet"); + notImplementedLabel.setForeground(Color.RED); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no instance (StringSet)"); + noConfigOptionLabel.setForeground(Color.MAGENTA); + widgetPanel.add(noConfigOptionLabel); + } + + //System.out.println("value: " + value); + + + } + + @Override + protected void setEntry() { + StringSetConfigOption specialOption; + //value = stringField.getText(); // get from input + specialOption = (StringSetConfigOption) config.getComponentManager() + .getConfigOption(componentOption, configOption.getName()); + try { + ConfigEntry<Set<String>> specialEntry = new ConfigEntry<Set<String>>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set String: " + configOption.getName() + " = " + + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + + + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-04 11:12:58
|
Revision: 487 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=487&view=rev Author: tonytacker Date: 2008-02-04 03:12:46 -0800 (Mon, 04 Feb 2008) Log Message: ----------- could be a way to change set<String> - change button should later open an extra window Modified Paths: -------------- 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/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-03 04:55:57 UTC (rev 486) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-04 11:12:46 UTC (rev 487) @@ -68,6 +68,7 @@ super(new BorderLayout()); this.config = config; + problems = config.getComponentManager().getLearningProblems(); initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); @@ -78,8 +79,6 @@ choosePanel.add(getInstancesButton); cb.addActionListener(this); - problems = config.getComponentManager().getLearningProblems(); - // add into comboBox for (int i = 0; i < problems.size(); i++) { cb.addItem(config.getComponentManager().getComponentName( @@ -139,6 +138,10 @@ for (int i : selectedIndices) posExampleSet.add(individuals.get(i).toString()); config.setPosExampleSet(posExampleSet); + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "positiveExamples", + config.getPosExampleSet()); + updateOptionPanel(); } }); @@ -153,6 +156,10 @@ for (int i : selectedIndices) negExampleSet.add(individuals.get(i).toString()); config.setNegExampleSet(negExampleSet); + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "negativeExamples", + config.getNegExampleSet()); + updateOptionPanel(); } }); @@ -219,10 +226,8 @@ * after this, next tab can be used */ public void init() { + config.getComponentManager().applyConfigEntry( - config.getLearningProblem(), "positiveExamples", - config.getPosExampleSet()); - config.getComponentManager().applyConfigEntry( config.getLearningProblem(), "negativeExamples", config.getNegExampleSet()); config.getLearningProblem().init(); Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-03 04:55:57 UTC (rev 486) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-04 11:12:46 UTC (rev 487) @@ -109,11 +109,11 @@ "StringConfigOption")) { widgetPanel = new WidgetPanelString(config, component, componentOption, optionList.get(i)); -/* } else if (optionList.get(i).getClass().toString().contains( + } else if (optionList.get(i).getClass().toString().contains( "StringSetConfigOption")) { widgetPanel = new WidgetPanelStringSet(config, component, componentOption, optionList.get(i)); -*/ } else { + } else { widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-03 04:55:57 UTC (rev 486) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-04 11:12:46 UTC (rev 487) @@ -21,15 +21,18 @@ */ import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Color; -import java.util.Set; +import java.util.*; -//import javax.swing.JTextField; +import javax.swing.DefaultListModel; import javax.swing.JLabel; +import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JButton; +import javax.swing.JScrollPane; import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; @@ -51,13 +54,15 @@ private ConfigOption<?> configOption; private JLabel nameLabel; private JPanel widgetPanel = new JPanel(); - private JButton setButton = new JButton("Set"); + private JButton changeButton = new JButton("Change"); private Component component; private Class<? extends Component> componentOption; - private Set<String> value; - //private JTextField stringField = new JTextField(15); + private Set<String> value = new HashSet<String>(); + private JList stringList = new JList(); + private DefaultListModel listModel = new DefaultListModel(); + public WidgetPanelStringSet(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { @@ -76,7 +81,7 @@ } public void actionPerformed(ActionEvent e) { - if (e.getSource() == setButton) { + if (e.getSource() == changeButton) { setEntry(); } } @@ -88,19 +93,40 @@ widgetPanel.add(nameLabel); } + @SuppressWarnings("unchecked") @Override protected void showThingToChange() { if (component != null) { // StringSetConfigOption if (configOption.getClass().toString().contains( "StringSetConfigOption")) { - setButton.addActionListener(this); - //widgetPanel.add(stringField); - widgetPanel.add(setButton); + // previous set value + if (configOption != null) { + // take set + value = (Set<String>) config.getComponentManager() + .getConfigOptionValue(component, + configOption.getName()); + // fill list + if (value != null) { + for (Iterator<String> iterator = value.iterator(); iterator + .hasNext();) { + String item = iterator.next(); + listModel.addElement(item); + } + } + } + stringList.setModel(listModel); + stringList.setLayoutOrientation(JList.VERTICAL); + stringList.setVisibleRowCount(-1); + JScrollPane stringListScroller = new JScrollPane(stringList); + stringListScroller.setPreferredSize(new Dimension(200, 100)); + widgetPanel.add(stringListScroller); + widgetPanel.add(changeButton); + changeButton.addActionListener(this); } // UNKNOWN else { - JLabel notImplementedLabel = new JLabel("not a stringSet"); + JLabel notImplementedLabel = new JLabel("not a set of strings"); notImplementedLabel.setForeground(Color.RED); widgetPanel.add(notImplementedLabel); } @@ -109,31 +135,26 @@ noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } - - //System.out.println("value: " + value); - - } @Override protected void setEntry() { StringSetConfigOption specialOption; - //value = stringField.getText(); // get from input + // value = stringField.getText(); // get from input specialOption = (StringSetConfigOption) config.getComponentManager() .getConfigOption(componentOption, configOption.getName()); + try { ConfigEntry<Set<String>> specialEntry = new ConfigEntry<Set<String>>( specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set String: " + configOption.getName() + " = " + System.out.println("set StringSet: " + 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-04 11:38:57
|
Revision: 488 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=488&view=rev Author: tonytacker Date: 2008-02-04 03:38:43 -0800 (Mon, 04 Feb 2008) Log Message: ----------- full width for optionPanel 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-04 11:12:46 UTC (rev 487) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-04 11:38:43 UTC (rev 488) @@ -68,7 +68,6 @@ // add scrollPane JScrollPane centerScroller = new JScrollPane(centerPanel); centerScroller.setPreferredSize(new Dimension(400, 200)); - // add Panels add(centerScroller, BorderLayout.CENTER); Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-04 11:12:46 UTC (rev 487) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-04 11:38:43 UTC (rev 488) @@ -44,11 +44,11 @@ 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 JPanel tab1; + private JPanel tab2; + private JPanel tab3; + private JPanel tab4; + private JPanel tab5; private JMenuBar menuBar = new JMenuBar(); private JMenu menuFile = new JMenu("File"); @@ -61,11 +61,11 @@ 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)); + tab1 = new KnowledgeSourcePanel(config); + tab2 = new ReasonerPanel(config); + tab3 = new LearningProblemPanel(config); + tab4 = new LearningAlgorithmPanel(config); + tab5 = new RunPanel(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-02-07 09:55:17
|
Revision: 509 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=509&view=rev Author: tonytacker Date: 2008-02-07 01:55:12 -0800 (Thu, 07 Feb 2008) Log Message: ----------- add autoInit() for init all 4 tabs in one method (in config.java) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-07 09:40:38 UTC (rev 508) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-07 09:55:12 UTC (rev 509) @@ -50,8 +50,7 @@ private LearningProblem lp; private LearningAlgorithm la; private boolean[] isInit = new boolean[4]; - - + protected ComponentManager getComponentManager() { return cm; } @@ -125,64 +124,60 @@ } /** - * KnowledgeSource.init has run? - * return true, if it was + * KnowledgeSource.init has run? return true, if it was */ protected boolean isInitKnowledgeSource() { return isInit[0]; } - + /** * set true if you run KnowwledgeSource.init */ protected void setInitKnowledgeSource(Boolean is) { isInit[0] = is; - for (int i=1; i<4; i++) + for (int i = 1; i < 4; i++) isInit[i] = false; } /** - * Reasoner.init has run? - * return true, if it was + * Reasoner.init has run? return true, if it was */ protected boolean isInitReasoner() { return isInit[1]; } - + /** * set true if you run Reasoner.init */ protected void setInitReasoner(Boolean is) { isInit[1] = is; - for (int i=2; i<4; i++) + for (int i = 2; i < 4; i++) isInit[i] = false; } /** - * LearningProblem.init has run? - * return true, if it was + * LearningProblem.init has run? return true, if it was */ protected boolean isInitLearningProblem() { return isInit[2]; } - + /** * set true if you run LearningProblem.init */ protected void setInitLearningProblem(Boolean is) { isInit[2] = is; - for (int i=3; i<4; i++) + for (int i = 3; i < 4; i++) isInit[i] = false; } /** - * LearningAlgorithm.init() has run? - * return true, if it was + * LearningAlgorithm.init() has run? return true, if it was */ - protected boolean isLearningAlgorithm() { + protected boolean isInitLearningAlgorithm() { return isInit[3]; } - + /** * set true if you run LearningAlgorithm.init */ @@ -190,4 +185,43 @@ isInit[3] = is; } + protected void autoInit() { + // Knowledge Source + if (!this.isInitKnowledgeSource() && this.getKnowledgeSource() != null + && this.getURI() != null) { + this.getKnowledgeSource().init(); + this.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + } + // Reasoner + if (!this.isInitReasoner() && this.getKnowledgeSource() != null + && this.getReasoner() != null) { + this.getReasoner().init(); + System.out.println("init Reasoner"); + // set ReasoningService + this.setReasoningService(this.getComponentManager() + .reasoningService(this.getReasoner())); + System.out.println("init ReasoningService"); + this.setInitReasoner(true); + } + // Learning Problem + if (!this.isInitLearningProblem() && this.getReasoner() != null + && this.getLearningProblem() != null) { + this.getComponentManager().applyConfigEntry( + this.getLearningProblem(), "negativeExamples", + this.getNegExampleSet()); + this.getLearningProblem().init(); + this.setInitLearningProblem(true); + System.out.println("init LearningProblem"); + } + // Learning Algorithm + if (!this.isInitLearningAlgorithm() + && this.getLearningProblem() != null + && this.getLearningAlgorithm() != null) { + this.getLearningAlgorithm().init(); + System.out.println("init LearningAlgorithm"); + } + + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-07 09:40:38 UTC (rev 508) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-07 09:55:12 UTC (rev 509) @@ -37,7 +37,7 @@ private static final long serialVersionUID = -7678275020058043937L; - private JButton initButton, getInstancesButton; + private JButton initButton; private String[] kbBoxItems = {}; private JComboBox cb = new JComboBox(kbBoxItems); private JPanel choosePanel = new JPanel(); @@ -53,10 +53,9 @@ this.config = config; sources = config.getComponentManager().getKnowledgeSources(); - getInstancesButton = new JButton("Get Instances"); - getInstancesButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); initButton.addActionListener(this); + initButton.setEnabled(false); // add to comboBox for (int i = 0; i < sources.size(); i++) { @@ -66,7 +65,6 @@ cb.addActionListener(this); choosePanel.add(cb); - choosePanel.add(getInstancesButton); optionPanel = new OptionPanel(config, config.getKnowledgeSource(), sources.get(choosenClassIndex)); initPanel.add(initButton); @@ -76,23 +74,27 @@ add(initPanel, BorderLayout.PAGE_END); choosenClassIndex = cb.getSelectedIndex(); + setSource(); } public void actionPerformed(ActionEvent e) { // read selected KnowledgeSourceClass - choosenClassIndex = cb.getSelectedIndex(); + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setURI(null); // default null + config.setInitKnowledgeSource(false); + setSource(); + } - if (e.getSource() == getInstancesButton) - getInstances(); - - if (e.getSource() == initButton && config.getURI() != null) + if (e.getSource() == initButton) init(); } /** * after this, you can change widgets */ - public void getInstances() { + public void setSource() { config.setKnowledgeSource(config.getComponentManager().knowledgeSource( sources.get(choosenClassIndex))); updateOptionPanel(); @@ -102,11 +104,12 @@ * after this, next tab can be used */ public void init() { - config.getKnowledgeSource().init(); - config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource with \n" - + sources.get(choosenClassIndex) + " and \n" + config.getURI() - + "\n"); +/* if (config.getKnowledgeSource() != null && config.getURI() != null) { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + } +*/ config.autoInit(); } /** Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-07 09:40:38 UTC (rev 508) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-07 09:55:12 UTC (rev 509) @@ -42,7 +42,7 @@ private JPanel choosePanel = new JPanel(); private OptionPanel optionPanel; private JPanel initPanel = new JPanel(); - private JButton initButton, getInstancesButton; + private JButton initButton, autoInitButton; private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); private int choosenClassIndex; @@ -56,8 +56,9 @@ initButton = new JButton("Init LearingAlgorithm"); initButton.addActionListener(this); initPanel.add(initButton); - getInstancesButton = new JButton("Get Instances"); - getInstancesButton.addActionListener(this); + initButton.setEnabled(false); + autoInitButton = new JButton("AutoInit"); + autoInitButton.addActionListener(this); // add into comboBox for (int i = 0; i < learners.size(); i++) { @@ -66,7 +67,7 @@ } choosePanel.add(cb); - choosePanel.add(getInstancesButton); + choosePanel.add(autoInitButton); cb.addActionListener(this); optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), @@ -80,10 +81,15 @@ public void actionPerformed(ActionEvent e) { // read selected Class - choosenClassIndex = cb.getSelectedIndex(); + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitLearningProblem(false); + setLearningAlgorithm(); + } - if (e.getSource() == getInstancesButton && config.isInitLearningProblem()) - getInstances(); + if (e.getSource() == autoInitButton) + setLearningAlgorithm(); if (e.getSource() == initButton && config.isInitLearningProblem()) init(); @@ -92,8 +98,10 @@ /** * after this, you can change widgets */ - public void getInstances() { - if (config.getLearningProblem() != null + public void setLearningAlgorithm() { + config.autoInit(); + if (config.isInitLearningProblem() + && config.getLearningProblem() != null && config.getReasoningService() != null) { config.setLearningAlgorithm(config.getComponentManager() .learningAlgorithm(learners.get(choosenClassIndex), @@ -107,9 +115,11 @@ * after this, next tab can be used */ public void init() { - config.getLearningAlgorithm().init(); - System.out.println("init LearningAlgorithm"); - + /* + * if (config.isInitLearningProblem()) { + * config.getLearningAlgorithm().init(); System.out.println("init + * LearningAlgorithm"); } + */config.autoInit(); } /** Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-07 09:40:38 UTC (rev 508) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-07 09:55:12 UTC (rev 509) @@ -55,7 +55,7 @@ private JPanel initPanel = new JPanel(); private JLabel posLabel = new JLabel("positive Examples"); private JLabel negLabel = new JLabel("negative Examples"); - private JButton initButton, getInstancesButton; + private JButton initButton, autoInitButton; private int choosenClassIndex; private List<Individual> individuals; private JList posList = new JList(); @@ -73,10 +73,11 @@ initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); initPanel.add(initButton); - getInstancesButton = new JButton("Get Instances"); - getInstancesButton.addActionListener(this); + initButton.setEnabled(false); + autoInitButton = new JButton("AutoInit"); + autoInitButton.addActionListener(this); choosePanel.add(cb); - choosePanel.add(getInstancesButton); + choosePanel.add(autoInitButton); cb.addActionListener(this); // add into comboBox @@ -174,16 +175,24 @@ add(listPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); + choosenClassIndex = cb.getSelectedIndex(); + setLearningProblem(); } public void actionPerformed(ActionEvent e) { // read selected LearningProblemClass - choosenClassIndex = cb.getSelectedIndex(); + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitLearningProblem(false); + setLearningProblem(); + } - if (e.getSource() == getInstancesButton && config.isInitReasoner()) - getInstances(); - if (e.getSource() == initButton && config.isInitReasoner()) + if (e.getSource() == autoInitButton) + setLearningProblem(); + + if (e.getSource() == initButton) init(); } @@ -203,37 +212,42 @@ /** * after this, you can change widgets */ - public void getInstances() { - config.setLearningProblem(config.getComponentManager().learningProblem( - problems.get(choosenClassIndex), config.getReasoningService())); - // lists - if (config.getReasoningService() != null) { - // fill lists - Set<Individual> individualsSet = config.getReasoningService() - .getIndividuals(); - individuals = new LinkedList<Individual>(individualsSet); - DefaultListModel listModel = new DefaultListModel(); - for (Individual ind : individuals) { - listModel.addElement(ind); + public void setLearningProblem() { + config.autoInit(); + if (config.isInitReasoner()) { + config.setLearningProblem(config.getComponentManager() + .learningProblem(problems.get(choosenClassIndex), + config.getReasoningService())); + // lists + if (config.getReasoningService() != null) { + // fill lists + Set<Individual> individualsSet = config.getReasoningService() + .getIndividuals(); + individuals = new LinkedList<Individual>(individualsSet); + DefaultListModel listModel = new DefaultListModel(); + for (Individual ind : individuals) { + listModel.addElement(ind); + } + posList.setModel(listModel); + negList.setModel(listModel); } - posList.setModel(listModel); - negList.setModel(listModel); + updateOptionPanel(); } - updateOptionPanel(); } /** * after this, next tab can be used */ public void init() { - - config.getComponentManager().applyConfigEntry( - config.getLearningProblem(), "negativeExamples", - config.getNegExampleSet()); - config.getLearningProblem().init(); - config.setInitLearningProblem(true); - System.out.println("init LearningProblem"); - +/* if (config.isInitReasoner()) { + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "negativeExamples", + config.getNegExampleSet()); + config.getLearningProblem().init(); + config.setInitLearningProblem(true); + System.out.println("init LearningProblem"); + } +*/ config.autoInit(); } /** Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-07 09:40:38 UTC (rev 508) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-07 09:55:12 UTC (rev 509) @@ -75,6 +75,7 @@ } + /** update this OptionPanel */ public void update(Component component, Class<? extends Component> componentOption) { this.componentOption = componentOption; @@ -82,7 +83,7 @@ showWidgets(); } - /* + /** * Define here what core.config.class is what type of widget. * WidgetPanelDefault is for none defined classes. */ @@ -122,7 +123,7 @@ centerPanel.updateUI(); // update graphic } - /* + /** * Define GridBagConstraints */ private void buildConstraints(GridBagConstraints gbc, int gx, int gy, Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-07 09:40:38 UTC (rev 508) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-07 09:55:12 UTC (rev 509) @@ -43,7 +43,7 @@ private JPanel choosePanel = new JPanel(); private JPanel initPanel = new JPanel(); private OptionPanel optionPanel; - private JButton initButton, getInstancesButton; + private JButton initButton, autoInitButton; private Config config; private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); @@ -58,8 +58,9 @@ initButton = new JButton("Init Reasoner"); initButton.addActionListener(this); initPanel.add(initButton); - getInstancesButton = new JButton("Get Instances"); - getInstancesButton.addActionListener(this); + initButton.setEnabled(false); + autoInitButton = new JButton("AutoInit"); + autoInitButton.addActionListener(this); choosePanel.add(cb); @@ -72,31 +73,38 @@ optionPanel = new OptionPanel(config, config.getReasoner(), reasoners .get(choosenClassIndex)); - choosePanel.add(getInstancesButton); - + choosePanel.add(autoInitButton); cb.addActionListener(this); add(choosePanel, BorderLayout.PAGE_START); add(optionPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); + choosenClassIndex = cb.getSelectedIndex(); + setReasoner(); } public void actionPerformed(ActionEvent e) { // read selected Class - choosenClassIndex = cb.getSelectedIndex(); + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitReasoner(false); + setReasoner(); + } - if (e.getSource() == getInstancesButton) - getInstances(); + if (e.getSource() == autoInitButton) + setReasoner(); - if (e.getSource() == initButton && config.getKnowledgeSource() != null) + if (e.getSource() == initButton) init(); } /** * after this, you can change widgets */ - public void getInstances() { + public void setReasoner() { + config.autoInit(); if (config.isInitKnowledgeSource()) { config.setReasoner(config.getComponentManager().reasoner( reasoners.get(choosenClassIndex), @@ -109,13 +117,7 @@ * after this, next tab can be used */ public void init() { - config.getReasoner().init(); - System.out.println("init Reasoner"); - // set ReasoningService - config.setReasoningService(config.getComponentManager() - .reasoningService(config.getReasoner())); - System.out.println("init ReasoningService"); - config.setInitReasoner(true); + config.autoInit(); } /** Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-07 09:40:38 UTC (rev 508) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-07 09:55:12 UTC (rev 509) @@ -26,7 +26,7 @@ import javax.swing.*; -//import org.dllearner.core.dl.Concept; +// import org.dllearner.core.dl.Concept; /** * OutputPanel @@ -38,13 +38,12 @@ private static final long serialVersionUID = 1643304576470046636L; - private JButton runButton, stopButton; + private JButton runButton, stopButton, testButton; private JTextArea infoArea; private Config config; - + private ThreadRun thread; - RunPanel(Config config) { super(new BorderLayout()); @@ -54,13 +53,17 @@ runButton.addActionListener(this); stopButton = new JButton("Stop"); stopButton.addActionListener(this); - + testButton = new JButton("TEST"); + testButton.addActionListener(this); + infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); JPanel showPanel = new JPanel(); showPanel.add(runButton); showPanel.add(stopButton); + showPanel.add(testButton); + JPanel infoPanel = new JPanel(); infoPanel.add(infoScroll); @@ -70,15 +73,24 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == runButton && config.getLearningAlgorithm() != null) { + config.autoInit(); thread = new ThreadRun(config); thread.start(); - //Concept solution = config.getLearningAlgorithm().getBestSolution(); - //infoArea.setText(solution.toString()); + // Concept solution = + // config.getLearningAlgorithm().getBestSolution(); + // infoArea.setText(solution.toString()); } - if (e.getSource() == stopButton && config.getLearningAlgorithm() != null) { - //config.getLearningAlgorithm().stop(); + if (e.getSource() == stopButton + && config.getLearningAlgorithm() != null) { + // config.getLearningAlgorithm().stop(); thread.exit(); + } + if (e.getSource() == testButton + && config.getLearningAlgorithm() != null) { + config.getLearningAlgorithm().stop(); + } + } - + } Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-07 09:40:38 UTC (rev 508) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-07 09:55:12 UTC (rev 509) @@ -43,5 +43,6 @@ public void exit() { if (config.getLearningAlgorithm() != null) config.getLearningAlgorithm().stop(); + System.out.println("stop"); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-07 09:40:38 UTC (rev 508) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-07 09:55:12 UTC (rev 509) @@ -57,7 +57,7 @@ private Class<? extends Component> componentOption; private String value; - private JTextField stringField = new JTextField(15); + private JTextField stringField = new JTextField(35); public WidgetPanelString(Config config, Component component, Class<? extends Component> componentOption, @@ -86,9 +86,16 @@ value = fc.getSelectedFile().toString(); stringField.setText(value); config.setURI(value); // save variable + System.out.println("value: " + config.getURI()); } } setEntry(); + // if url and value not "" + // necessary for init knowledge source + if (configOption.getName().equalsIgnoreCase("url") + && !value.equalsIgnoreCase("")) { + config.setURI(value); + } } } @@ -164,10 +171,7 @@ * ActionPerformed */ private Boolean checkForFilename() { - if (configOption.getName().equalsIgnoreCase("filename")) - return true; - else - return false; + return configOption.getName().equalsIgnoreCase("filename"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-09 09:27:05
|
Revision: 530 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=530&view=rev Author: tonytacker Date: 2008-02-09 01:26:59 -0800 (Sat, 09 Feb 2008) Log Message: ----------- removed autoinit(), add colored tabs 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/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-08 10:25:23 UTC (rev 529) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-09 09:26:59 UTC (rev 530) @@ -185,6 +185,7 @@ isInit[3] = is; } + @Deprecated protected void autoInit() { // Knowledge Source if (!this.isInitKnowledgeSource() && this.getKnowledgeSource() != null Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-08 10:25:23 UTC (rev 529) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-09 09:26:59 UTC (rev 530) @@ -37,25 +37,27 @@ private static final long serialVersionUID = -7678275020058043937L; + private Config config; + private StartGUI startGUI; private JButton initButton; private String[] kbBoxItems = {}; private JComboBox cb = new JComboBox(kbBoxItems); private JPanel choosePanel = new JPanel(); private JPanel initPanel = new JPanel(); - private Config config; private int choosenClassIndex; private List<Class<? extends KnowledgeSource>> sources; private OptionPanel optionPanel; - KnowledgeSourcePanel(final Config config) { + KnowledgeSourcePanel(final Config config, StartGUI startGUI) { super(new BorderLayout()); this.config = config; + this.startGUI = startGUI; sources = config.getComponentManager().getKnowledgeSources(); initButton = new JButton("Init KnowledgeSource"); initButton.addActionListener(this); - initButton.setEnabled(false); + initButton.setEnabled(true); // add to comboBox for (int i = 0; i < sources.size(); i++) { @@ -104,12 +106,15 @@ * after this, next tab can be used */ public void init() { -/* if (config.getKnowledgeSource() != null && config.getURI() != null) { + if (/* + * !config.isInitKnowledgeSource() && + */config.getKnowledgeSource() != null && config.getURI() != null) { config.getKnowledgeSource().init(); config.setInitKnowledgeSource(true); System.out.println("init KnowledgeSource"); + startGUI.updateTabColors(); } -*/ config.autoInit(); + // config.autoInit(); } /** Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-08 10:25:23 UTC (rev 529) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-09 09:26:59 UTC (rev 530) @@ -37,7 +37,9 @@ public class LearningAlgorithmPanel extends JPanel implements ActionListener { private static final long serialVersionUID = 8721490771860452959L; + private Config config; + private StartGUI startGUI; private List<Class<? extends LearningAlgorithm>> learners; private JPanel choosePanel = new JPanel(); private OptionPanel optionPanel; @@ -47,17 +49,18 @@ private JComboBox cb = new JComboBox(cbItems); private int choosenClassIndex; - LearningAlgorithmPanel(Config config) { + LearningAlgorithmPanel(Config config, StartGUI startGUI) { super(new BorderLayout()); this.config = config; + this.startGUI = startGUI; learners = config.getComponentManager().getLearningAlgorithms(); initButton = new JButton("Init LearingAlgorithm"); initButton.addActionListener(this); initPanel.add(initButton); - initButton.setEnabled(false); - autoInitButton = new JButton("AutoInit"); + initButton.setEnabled(true); + autoInitButton = new JButton("Set"); autoInitButton.addActionListener(this); // add into comboBox @@ -91,7 +94,7 @@ if (e.getSource() == autoInitButton) setLearningAlgorithm(); - if (e.getSource() == initButton && config.isInitLearningProblem()) + if (e.getSource() == initButton) init(); } @@ -99,9 +102,10 @@ * after this, you can change widgets */ public void setLearningAlgorithm() { - config.autoInit(); - if (config.isInitLearningProblem() - && config.getLearningProblem() != null + // config.autoInit(); + if (/* + * config.isInitLearningProblem() && + */config.getLearningProblem() != null && config.getReasoningService() != null) { config.setLearningAlgorithm(config.getComponentManager() .learningAlgorithm(learners.get(choosenClassIndex), @@ -115,11 +119,13 @@ * after this, next tab can be used */ public void init() { - /* - * if (config.isInitLearningProblem()) { - * config.getLearningAlgorithm().init(); System.out.println("init - * LearningAlgorithm"); } - */config.autoInit(); + if (config.getLearningProblem() != null) { + config.getLearningAlgorithm().init(); + config.setLearningAlgorithm(true); + System.out.println("init LearningAlgorithm"); + startGUI.updateTabColors(); + } + // config.autoInit(); } /** Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-08 10:25:23 UTC (rev 529) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-09 09:26:59 UTC (rev 530) @@ -47,6 +47,8 @@ private static final long serialVersionUID = -3819627680918930203L; + private Config config; + private StartGUI startGUI; private List<Class<? extends LearningProblem>> problems; private String[] lpBoxItems = {}; private JComboBox cb = new JComboBox(lpBoxItems); @@ -62,19 +64,18 @@ private JList negList = new JList(); private OptionPanel optionPanel; - private Config config; - - LearningProblemPanel(final Config config) { + LearningProblemPanel(final Config config, StartGUI startGUI) { super(new BorderLayout()); this.config = config; + this.startGUI = startGUI; problems = config.getComponentManager().getLearningProblems(); initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); initPanel.add(initButton); - initButton.setEnabled(false); - autoInitButton = new JButton("AutoInit"); + initButton.setEnabled(true); + autoInitButton = new JButton("Set"); autoInitButton.addActionListener(this); choosePanel.add(cb); choosePanel.add(autoInitButton); @@ -143,6 +144,7 @@ config.getLearningProblem(), "positiveExamples", config.getPosExampleSet()); updateOptionPanel(); + System.out.println("POSSSSS"); } }); @@ -161,6 +163,7 @@ config.getLearningProblem(), "negativeExamples", config.getNegExampleSet()); updateOptionPanel(); + System.out.println("POSSSSS"); } }); @@ -176,19 +179,22 @@ add(initPanel, BorderLayout.PAGE_END); choosenClassIndex = cb.getSelectedIndex(); - setLearningProblem(); + //setLearningProblem(); } public void actionPerformed(ActionEvent e) { + System.out.println("index: " + cb.getSelectedIndex()); + // read selected LearningProblemClass // choosenClassIndex = cb.getSelectedIndex(); if (choosenClassIndex != cb.getSelectedIndex()) { - choosenClassIndex = cb.getSelectedIndex(); + this.choosenClassIndex = cb.getSelectedIndex(); config.setInitLearningProblem(false); setLearningProblem(); + System.out.println("new_index: " + cb.getSelectedIndex()); + } - if (e.getSource() == autoInitButton) setLearningProblem(); @@ -213,7 +219,7 @@ * after this, you can change widgets */ public void setLearningProblem() { - config.autoInit(); + // config.autoInit(); if (config.isInitReasoner()) { config.setLearningProblem(config.getComponentManager() .learningProblem(problems.get(choosenClassIndex), @@ -232,6 +238,7 @@ negList.setModel(listModel); } updateOptionPanel(); + startGUI.updateTabColors(); } } @@ -239,15 +246,22 @@ * after this, next tab can be used */ public void init() { -/* if (config.isInitReasoner()) { + if (/* !config.isInitLearningProblem() && */config.getReasoner() != null + && config.getLearningProblem() != null) { config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "positiveExamples", + config.getPosExampleSet()); + config.getComponentManager().applyConfigEntry( config.getLearningProblem(), "negativeExamples", config.getNegExampleSet()); + config.getLearningProblem().init(); config.setInitLearningProblem(true); System.out.println("init LearningProblem"); + startGUI.updateTabColors(); + } -*/ config.autoInit(); + // config.autoInit(); } /** Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-08 10:25:23 UTC (rev 529) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-09 09:26:59 UTC (rev 530) @@ -39,27 +39,29 @@ private static final long serialVersionUID = -7678275020058043937L; + private Config config; + private StartGUI startGUI; private List<Class<? extends ReasonerComponent>> reasoners; private JPanel choosePanel = new JPanel(); private JPanel initPanel = new JPanel(); private OptionPanel optionPanel; private JButton initButton, autoInitButton; - private Config config; private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); private int choosenClassIndex; - ReasonerPanel(final Config config) { + ReasonerPanel(final Config config, StartGUI startGUI) { super(new BorderLayout()); this.config = config; + this.startGUI = startGUI; reasoners = config.getComponentManager().getReasonerComponents(); initButton = new JButton("Init Reasoner"); initButton.addActionListener(this); initPanel.add(initButton); - initButton.setEnabled(false); - autoInitButton = new JButton("AutoInit"); + initButton.setEnabled(true); + autoInitButton = new JButton("Set"); autoInitButton.addActionListener(this); choosePanel.add(cb); @@ -90,6 +92,7 @@ if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); config.setInitReasoner(false); + setReasoner(); } @@ -104,12 +107,13 @@ * after this, you can change widgets */ public void setReasoner() { - config.autoInit(); + // config.autoInit(); if (config.isInitKnowledgeSource()) { config.setReasoner(config.getComponentManager().reasoner( reasoners.get(choosenClassIndex), config.getKnowledgeSource())); updateOptionPanel(); + startGUI.updateTabColors(); } } @@ -117,7 +121,19 @@ * after this, next tab can be used */ public void init() { - config.autoInit(); + if (/* !config.isInitReasoner() && */config.getKnowledgeSource() != null + && config.getReasoner() != null) { + config.getReasoner().init(); + System.out.println("init Reasoner"); + // set ReasoningService + config.setReasoningService(config.getComponentManager() + .reasoningService(config.getReasoner())); + System.out.println("init ReasoningService"); + config.setInitReasoner(true); + startGUI.updateTabColors(); + + } + // config.autoInit(); } /** Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-08 10:25:23 UTC (rev 529) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-09 09:26:59 UTC (rev 530) @@ -73,7 +73,7 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == runButton && config.getLearningAlgorithm() != null) { - config.autoInit(); + //config.autoInit(); thread = new ThreadRun(config); thread.start(); // Concept solution = Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-08 10:25:23 UTC (rev 529) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-09 09:26:59 UTC (rev 530) @@ -21,7 +21,9 @@ */ import javax.swing.*; +import javax.swing.event.*; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -44,11 +46,11 @@ private Config config = new Config(); - private JPanel tab1; - private JPanel tab2; - private JPanel tab3; - private JPanel tab4; - private JPanel tab5; + private KnowledgeSourcePanel tab0; + private ReasonerPanel tab1; + private LearningProblemPanel tab2; + private LearningAlgorithmPanel tab3; + private RunPanel tab4; private JMenuBar menuBar = new JMenuBar(); private JMenu menuFile = new JMenu("File"); @@ -61,16 +63,16 @@ this.setLocationByPlatform(true); this.setSize(800, 600); - tab1 = new KnowledgeSourcePanel(config); - tab2 = new ReasonerPanel(config); - tab3 = new LearningProblemPanel(config); - tab4 = new LearningAlgorithmPanel(config); - tab5 = 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); + tab0 = new KnowledgeSourcePanel(config, this); + tab1 = new ReasonerPanel(config, this); + tab2 = new LearningProblemPanel(config, this); + tab3 = new LearningAlgorithmPanel(config, this); + tab4 = new RunPanel(config); + tabPane.addTab("Knowledge Source", tab0); + tabPane.addTab("Reasoner", tab1); + tabPane.addTab("Learning Problem", tab2); + tabPane.addTab("Learning Algorithm", tab3); + tabPane.addTab("Run", tab4); this.setJMenuBar(menuBar); menuBar.add(menuFile); @@ -81,6 +83,16 @@ this.add(tabPane); this.setVisible(true); + updateTabColors(); + + // Register a change listener + tabPane.addChangeListener(new ChangeListener() { + // This method is called whenever the selected tab changes + public void stateChanged(ChangeEvent evt) { + + updateTabColors(); + } + }); } public static void main(String[] args) { @@ -104,4 +116,25 @@ } } + public void updateTabColors() { + if (config.isInitKnowledgeSource()) + tabPane.setForegroundAt(0, Color.BLACK); + else + tabPane.setForegroundAt(0, Color.RED); + if (config.isInitReasoner()) + tabPane.setForegroundAt(1, Color.BLACK); + else + tabPane.setForegroundAt(1, Color.RED); + if (config.isInitLearningProblem()) + tabPane.setForegroundAt(2, Color.BLACK); + else + tabPane.setForegroundAt(2, Color.RED); + if (config.isInitLearningAlgorithm()) { + tabPane.setForegroundAt(3, Color.BLACK); + tabPane.setForegroundAt(4, Color.BLACK); + } else { + tabPane.setForegroundAt(3, Color.RED); + tabPane.setForegroundAt(4, Color.RED); + } + } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-08 10:25:23 UTC (rev 529) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-09 09:26:59 UTC (rev 530) @@ -120,7 +120,7 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no instance (Boolean)"); + JLabel noConfigOptionLabel = new JLabel("no init (Boolean)"); 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-02-09 09:50:43
|
Revision: 531 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=531&view=rev Author: tonytacker Date: 2008-02-09 01:50:41 -0800 (Sat, 09 Feb 2008) Log Message: ----------- bugfix 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/StartGUI.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-09 09:26:59 UTC (rev 530) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-09 09:50:41 UTC (rev 531) @@ -181,7 +181,7 @@ /** * set true if you run LearningAlgorithm.init */ - protected void setLearningAlgorithm(Boolean is) { + protected void setInitLearningAlgorithm(Boolean is) { isInit[3] = is; } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-09 09:26:59 UTC (rev 530) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-09 09:50:41 UTC (rev 531) @@ -121,7 +121,7 @@ public void init() { if (config.getLearningProblem() != null) { config.getLearningAlgorithm().init(); - config.setLearningAlgorithm(true); + config.setInitLearningAlgorithm(true); System.out.println("init LearningAlgorithm"); startGUI.updateTabColors(); } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-09 09:26:59 UTC (rev 530) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-09 09:50:41 UTC (rev 531) @@ -36,7 +36,6 @@ * StartGUI * * @author Tilo Hielscher - * */ public class StartGUI extends JFrame implements ActionListener { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-11 14:19:03
|
Revision: 536 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=536&view=rev Author: tonytacker Date: 2008-02-11 06:18:59 -0800 (Mon, 11 Feb 2008) Log Message: ----------- widget stringset with special for positive/negative examples Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java Added: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-11 14:18:59 UTC (rev 536) @@ -0,0 +1,101 @@ +/** + * 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/>. + * + */ +package org.dllearner.gui; + +import javax.swing.*; + +import java.awt.BorderLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Set; + +/** + * CheckBoxList + * + * a list of CheckBoxes + * + * @author Tilo Hielscher + */ +public class CheckBoxList extends JPanel { + private static final long serialVersionUID = -7119007550662195455L; + private JPanel checkBoxPanel = new JPanel(); + private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); + private GridBagLayout gridbag = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); + private Set<String> selectionSet = new HashSet<String>(); + + /** + * get a JPanel + */ + public CheckBoxList() { + checkBoxPanel.setLayout(gridbag); + add(checkBoxPanel, BorderLayout.CENTER); + constraints.anchor = GridBagConstraints.WEST; + } + + /** + * add new entry + * + * @param label + */ + public void add(String label) { + list.add(new JCheckBox(label)); + update(); + } + + /** + * return a set of selected items + */ + public Set<String> getSelections() { + selectionSet.clear(); // remove all + for (int i = 0; i < list.size(); i++) { + if (list.get(i).isSelected()) + this.selectionSet.add(list.get(i).getText()); + } + return this.selectionSet; + } + + /** + * update JCheckBox's + */ + private void update() { + checkBoxPanel.removeAll(); + for (int i = 0; i < list.size(); i++) { + buildConstraints(constraints, 0, i, 1, 1, 100, 100); + gridbag.setConstraints(list.get(i), constraints); + checkBoxPanel.add(list.get(i), constraints); + } + } + + /** + * 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; + } +} \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-10 17:52:40 UTC (rev 535) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-11 14:18:59 UTC (rev 536) @@ -183,7 +183,7 @@ } public void actionPerformed(ActionEvent e) { - System.out.println("index: " + cb.getSelectedIndex()); + //System.out.println("index: " + cb.getSelectedIndex()); // read selected LearningProblemClass // choosenClassIndex = cb.getSelectedIndex(); @@ -191,7 +191,7 @@ this.choosenClassIndex = cb.getSelectedIndex(); config.setInitLearningProblem(false); setLearningProblem(); - System.out.println("new_index: " + cb.getSelectedIndex()); + //System.out.println("new_index: " + cb.getSelectedIndex()); } Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-10 17:52:40 UTC (rev 535) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-11 14:18:59 UTC (rev 536) @@ -44,6 +44,11 @@ private ThreadRun thread; + private JPanel showPanel = new JPanel(); + private JPanel infoPanel = new JPanel(); + private JPanel testPanel = new JPanel(); + + RunPanel(Config config) { super(new BorderLayout()); @@ -59,16 +64,15 @@ infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); - JPanel showPanel = new JPanel(); showPanel.add(runButton); showPanel.add(stopButton); showPanel.add(testButton); - JPanel infoPanel = new JPanel(); infoPanel.add(infoScroll); add(showPanel, BorderLayout.PAGE_START); add(infoPanel, BorderLayout.CENTER); + add(testPanel, BorderLayout.PAGE_END); } public void actionPerformed(ActionEvent e) { @@ -85,9 +89,7 @@ // config.getLearningAlgorithm().stop(); thread.exit(); } - if (e.getSource() == testButton - && config.getLearningAlgorithm() != null) { - config.getLearningAlgorithm().stop(); + if (e.getSource() == testButton) { } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-10 17:52:40 UTC (rev 535) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-11 14:18:59 UTC (rev 536) @@ -42,6 +42,7 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.StringSetConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.dl.Individual; /** * WidgetPanelStringSet @@ -72,6 +73,9 @@ private JList stringList = new JList(); private DefaultListModel listModel = new DefaultListModel(); + private JButton setButton = new JButton("set"); + private CheckBoxList cBL = new CheckBoxList(); + public WidgetPanelStringSet(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { @@ -85,46 +89,54 @@ add(widgetPanel, BorderLayout.CENTER); showLabel(); // name of option and tooltip showThingToChange(); // textfield, setbutton - stringList.setModel(listModel); - + // ActionListeners addButton.addActionListener(this); removeButton.addActionListener(this); clearButton.addActionListener(this); + setButton.addActionListener(this); } - public JPanel getPanel() { - return this; - } - public void actionPerformed(ActionEvent e) { - Set<String> exampleSet = new HashSet<String>(); - // add to list - if (e.getSource() == addButton - && !listModel.contains(stringField.getText())) { - listModel.addElement(stringField.getText()); + if (!isSpecial()) { + // NORMAL LAYOUT + Set<String> exampleSet = new HashSet<String>(); + // add to list + if (e.getSource() == addButton + && !listModel.contains(stringField.getText())) { + listModel.addElement(stringField.getText()); + } + // remove selection + if (e.getSource() == removeButton) { + int[] selectedIndices = stringList.getSelectedIndices(); + int count = 0; // remove i.e. index 2 and 4: after delete 2, 4 + // is + // now index 3 + for (int i : selectedIndices) + listModel.remove(i - count++); + } + // clear list + if (e.getSource() == clearButton) { + listModel.clear(); + } + // update + // stringList.setModel(listModel); + for (int i = 0; i < listModel.size(); i++) { + if (!listModel.get(i).toString().equalsIgnoreCase("")) + exampleSet.add(listModel.get(i).toString()); + } + // set entry + value = exampleSet; + setEntry(); + } else { + // SPECIAL LAYOUT + // setButton + if (e.getSource() == setButton) { + value = cBL.getSelections(); + setEntry(); + } } - // remove selection - if (e.getSource() == removeButton) { - int[] selectedIndices = stringList.getSelectedIndices(); - int count = 0; // remove i.e. index 2 and 4: after delete 2, 4 is - // now index 3 - for (int i : selectedIndices) - listModel.remove(i - count++); - } - // clear list - if (e.getSource() == clearButton) { - listModel.clear(); - } - // update - // stringList.setModel(listModel); - for (int i = 0; i < listModel.size(); i++) { - if (!listModel.get(i).toString().equalsIgnoreCase("")) - exampleSet.add(listModel.get(i).toString()); - } - // set entry - value = exampleSet; - setEntry(); + } @Override @@ -150,6 +162,7 @@ value = (Set<String>) config.getComponentManager() .getConfigOptionValue(component, configOption.getName()); + // fill list if (value != null) { for (Iterator<String> iterator = value.iterator(); iterator @@ -159,35 +172,59 @@ } } } - buildConstraints(constraints, 0, 1, 1, 1, 100, 100); - gridbag.setConstraints(stringField, constraints); - widgetPanel.add(stringField, constraints); - - buildConstraints(constraints, 1, 1, 1, 1, 100, 100); - gridbag.setConstraints(addButton, constraints); - widgetPanel.add(addButton, constraints); - - // list - stringList.setModel(listModel); - stringList.setLayoutOrientation(JList.VERTICAL); - stringList.setVisibleRowCount(-1); - JScrollPane stringListScroller = new JScrollPane(stringList); - stringListScroller.setPreferredSize(new Dimension(280, 100)); - - buildConstraints(constraints, 0, 2, 1, 2, 100, 100); - gridbag.setConstraints(stringListScroller, constraints); - widgetPanel.add(stringListScroller, constraints); - - buildConstraints(constraints, 1, 2, 1, 1, 100, 100); - gridbag.setConstraints(removeButton, constraints); - widgetPanel.add(removeButton, constraints); - - buildConstraints(constraints, 1, 3, 1, 1, 100, 100); - gridbag.setConstraints(clearButton, constraints); - widgetPanel.add(clearButton, constraints); - - // widgetPanel.add(setButton); - // setButton.addActionListener(this); + if (!isSpecial()) { + // NORMAL LAYOUT + // stringField + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(stringField, constraints); + widgetPanel.add(stringField, constraints); + // addButton + buildConstraints(constraints, 1, 1, 1, 1, 100, 100); + gridbag.setConstraints(addButton, constraints); + widgetPanel.add(addButton, constraints); + // list + stringList.setModel(listModel); + stringList.setLayoutOrientation(JList.VERTICAL); + stringList.setVisibleRowCount(-1); + JScrollPane stringListScroller = new JScrollPane(stringList); + stringListScroller + .setPreferredSize(new Dimension(280, 100)); + buildConstraints(constraints, 0, 2, 1, 2, 100, 100); + gridbag.setConstraints(stringListScroller, constraints); + widgetPanel.add(stringListScroller, constraints); + // removeButton + buildConstraints(constraints, 1, 2, 1, 1, 100, 100); + gridbag.setConstraints(removeButton, constraints); + widgetPanel.add(removeButton, constraints); + // clearButton + buildConstraints(constraints, 1, 3, 1, 1, 100, 100); + gridbag.setConstraints(clearButton, constraints); + widgetPanel.add(clearButton, constraints); + } else { + // SPECIAL LAYOUT + // ComboBoxList + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(cBL, constraints); + widgetPanel.add(cBL, constraints); + // setButton + buildConstraints(constraints, 1, 1, 1, 1, 100, 100); + gridbag.setConstraints(setButton, constraints); + widgetPanel.add(setButton, constraints); + // DEFINE LIST + // positiveExamples or negativeExamples + if (configOption.getName().equalsIgnoreCase( + "positiveExamples") + || configOption.getName().equalsIgnoreCase( + "negativeExamples")) { + // fill lists + Set<Individual> individualsSet = config + .getReasoningService().getIndividuals(); + LinkedList<Individual> individuals = new LinkedList<Individual>( + individualsSet); + for (Individual ind : individuals) + cBL.add(ind.getName()); + } + } } // UNKNOWN else { @@ -237,4 +274,15 @@ gbc.weighty = wy; } + /** + * special layout returns true if 2nd layout should used + */ + private boolean isSpecial() { + if (configOption.getName().equalsIgnoreCase("positiveExamples") + || configOption.getName().equalsIgnoreCase("negativeExamples")) + return true; + else + return false; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-12 09:15:23
|
Revision: 544 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=544&view=rev Author: tonytacker Date: 2008-02-12 01:15:20 -0800 (Tue, 12 Feb 2008) Log Message: ----------- new method for selecting checkbox's Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-11 19:01:36 UTC (rev 543) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-12 09:15:20 UTC (rev 544) @@ -41,7 +41,6 @@ private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); private GridBagLayout gridbag = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); - private Set<String> selectionSet = new HashSet<String>(); /** * get a JPanel @@ -53,9 +52,9 @@ } /** - * add new entry + * Add new entry and make a new JCheckBox. * - * @param label + * @param label This text will be shown. */ public void add(String label) { list.add(new JCheckBox(label)); @@ -63,18 +62,33 @@ } /** - * return a set of selected items + * Return a set of selected items. */ public Set<String> getSelections() { + Set<String> selectionSet = new HashSet<String>(); selectionSet.clear(); // remove all for (int i = 0; i < list.size(); i++) { if (list.get(i).isSelected()) - this.selectionSet.add(list.get(i).getText()); + selectionSet.add(list.get(i).getText()); } - return this.selectionSet; + return selectionSet; } /** + * Select items. + * + * @param selectionSet Is a Set of Strings. + */ + public void setSelections(Set<String> selectionSet) { + for (int i = 0; i < list.size(); i++) { + if (selectionSet.contains(list.get(i).getText())) + list.get(i).setSelected(true); + else + list.get(i).setSelected(false); + } + } + + /** * update JCheckBox's */ private void update() { Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-11 19:01:36 UTC (rev 543) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-12 09:15:20 UTC (rev 544) @@ -111,9 +111,8 @@ // remove selection if (e.getSource() == removeButton) { int[] selectedIndices = stringList.getSelectedIndices(); - int count = 0; // remove i.e. index 2 and 4: after delete 2, 4 - // is - // now index 3 + int count = 0; + // remove i.e. 2 and 4: after delete 2: 4 is now 3 for (int i : selectedIndices) listModel.remove(i - count++); } @@ -212,6 +211,8 @@ buildConstraints(constraints, 1, 1, 1, 1, 100, 100); gridbag.setConstraints(setButton, constraints); widgetPanel.add(setButton, constraints); + // set selections + cBL.setSelections(value); // DEFINE LIST // positiveExamples or negativeExamples if (configOption.getName().equalsIgnoreCase( @@ -255,23 +256,24 @@ } // UNKNOWN else { - JLabel notImplementedLabel = new JLabel("not a set of strings"); + JLabel notImplementedLabel = new JLabel(" not a set of strings"); notImplementedLabel.setForeground(Color.RED); - buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + buildConstraints(constraints, 1, 0, 1, 1, 100, 100); gridbag.setConstraints(notImplementedLabel, constraints); widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init (StringSet)"); + JLabel noConfigOptionLabel = new JLabel(" no init (StringSet)"); noConfigOptionLabel.setForeground(Color.MAGENTA); - widgetPanel.add(noConfigOptionLabel); + buildConstraints(constraints, 1, 0, 1, 1, 100, 100); + gridbag.setConstraints(noConfigOptionLabel, constraints); + widgetPanel.add(noConfigOptionLabel, constraints); } } @Override protected void setEntry() { StringSetConfigOption specialOption; - // value = stringField.getText(); // get from input specialOption = (StringSetConfigOption) config.getComponentManager() .getConfigOption(componentOption, configOption.getName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-12 11:36:36
|
Revision: 546 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=546&view=rev Author: tonytacker Date: 2008-02-12 03:36:32 -0800 (Tue, 12 Feb 2008) Log Message: ----------- add an icon Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/icon.gif trunk/src/dl-learner/org/dllearner/gui/package.html Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-12 09:20:06 UTC (rev 545) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-12 11:36:32 UTC (rev 546) @@ -57,11 +57,14 @@ private JMenuItem saveItem = new JMenuItem("Save Config"); public StartGUI() { - this.setTitle("DL-Learner GUI"); + this.setTitle("DL-Learner"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationByPlatform(true); this.setSize(800, 600); - + + // set icon + setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("icon.gif"))); + tab0 = new KnowledgeSourcePanel(config, this); tab1 = new ReasonerPanel(config, this); tab2 = new LearningProblemPanel(config, this); Added: trunk/src/dl-learner/org/dllearner/gui/icon.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/gui/icon.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dl-learner/org/dllearner/gui/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/package.html (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/package.html 2008-02-12 11:36:32 UTC (rev 546) @@ -0,0 +1,7 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head></head> +<body bgcolor="white"> +<p>Classes for generating a Graphical User Interface for DL-Learner.</p> +</body> +</html> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-12 14:46:29
|
Revision: 548 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=548&view=rev Author: tonytacker Date: 2008-02-12 06:46:20 -0800 (Tue, 12 Feb 2008) Log Message: ----------- add/changed comments Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/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/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-02-12 14:46:20 UTC (rev 548) @@ -26,24 +26,22 @@ * AbstractWidgetPanel * * @author Tilo Hielscher - * */ public abstract class AbstractWidgetPanel extends JPanel { - - /* - * show label and tooltip + /** + * Show label and tooltip. */ - protected abstract void showLabel(); + public abstract void showLabel(); - /* - * show textfield, setbutton and so on + /** + * Show textfield, setbutton and so on, make layout. */ - protected abstract void showThingToChange(); + public abstract void showThingToChange(); - /* - * set entry you got from showThingToChange() + /** + * Set entry you got from showThingToChange(). */ - protected abstract void setEntry(); - + public abstract void setEntry(); + } Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-12 14:46:20 UTC (rev 548) @@ -29,10 +29,8 @@ import java.util.Set; /** - * CheckBoxList + * CheckBoxList is a list of CheckBox's * - * a list of CheckBoxes - * * @author Tilo Hielscher */ public class CheckBoxList extends JPanel { Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-12 14:46:20 UTC (rev 548) @@ -20,209 +20,219 @@ * */ -import java.util.HashSet; -import java.util.Set; - import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.ReasoningService; import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasoningService; /** - * config + * Config save all together used variables: ComponentManager, KnowledgeSource, + * Reasoner, ReasoningService, LearningProblem, LearningAlgorithm; also inits of + * these components * - * this class save all together used variables - * * @author Tilo Hielscher - * */ - 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 boolean[] isInit = new boolean[4]; - protected ComponentManager getComponentManager() { - return cm; + /** + * Get ComponentManager. + * + * @return ComponentManager + */ + public ComponentManager getComponentManager() { + return this.cm; } - protected void setComponentManager(ComponentManager input) { - cm = input; + /** + * It is necessary for init KnowledgeSource. + * + * @return URI + */ + public String getURI() { + return this.uri; } - protected String getURI() { - return uri; + /** + * Set an URI. + * + * @param uri + * it's a Link like "http://example.com" or "file://myfile" + */ + public void setURI(String uri) { + this.uri = uri; } - protected void setURI(String input) { - uri = input; + /** + * Get Reasoner. + * + * @return reasoner + */ + public ReasonerComponent getReasoner() { + return this.reasoner; } - protected ReasonerComponent getReasoner() { - return reasoner; + /** + * Set Reasoner. + * + * @param reasoner + */ + public void setReasoner(ReasonerComponent reasoner) { + this.reasoner = reasoner; } - protected void setReasoner(ReasonerComponent input) { - reasoner = input; + /** + * Get ReasoningService. + * + * @return ReasoningService + */ + public ReasoningService getReasoningService() { + return this.rs; } - protected ReasoningService getReasoningService() { - return rs; + /** + * Set ReasoningService. + * + * @param reasoningService + */ + public void setReasoningService(ReasoningService reasoningService) { + this.rs = reasoningService; } - protected void setReasoningService(ReasoningService input) { - rs = input; + /** + * Get KnowledgeSource. + * + * @return KnowledgeSource + */ + public KnowledgeSource getKnowledgeSource() { + return this.source; } - protected KnowledgeSource getKnowledgeSource() { - return source; + /** + * Set KnowledgeSource. + * + * @param knowledgeSource + */ + public void setKnowledgeSource(KnowledgeSource knowledgeSource) { + this.source = knowledgeSource; } - protected void setKnowledgeSource(KnowledgeSource input) { - source = input; + /** + * Set LearningProblem. + * + * @param learningProblem + */ + public void setLearningProblem(LearningProblem learningProblem) { + this.lp = learningProblem; } - protected void setPosExampleSet(Set<String> posExampleSet) { - this.posExampleSet = posExampleSet; + /** + * Get LearningProblem. + * + * @return learningProblem + */ + public LearningProblem getLearningProblem() { + return this.lp; } - protected Set<String> getPosExampleSet() { - return this.posExampleSet; + /** + * Set LearningAlgorithm. + * + * @param learningAlgorithm + */ + public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { + this.la = learningAlgorithm; } - protected void setNegExampleSet(Set<String> negExampleSet) { - this.negExampleSet = negExampleSet; + /** + * Get LearningAlgorithm. + * + * @return LearningAlgorithm + */ + public LearningAlgorithm getLearningAlgorithm() { + return this.la; } - 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; - } - /** - * KnowledgeSource.init has run? return true, if it was + * KnowledgeSource.init has run? + * + * @return true, if init was made, false if not */ - protected boolean isInitKnowledgeSource() { + public boolean isInitKnowledgeSource() { return isInit[0]; } /** - * set true if you run KnowwledgeSource.init + * Set true if you run KnowwledgeSource.init. The inits from other tabs + * behind will automatic set to false. */ - protected void setInitKnowledgeSource(Boolean is) { + public void setInitKnowledgeSource(Boolean is) { isInit[0] = is; for (int i = 1; i < 4; i++) isInit[i] = false; } /** - * Reasoner.init has run? return true, if it was + * Reasoner.init has run? + * + * @return true, if init was made, false if not */ - protected boolean isInitReasoner() { + public boolean isInitReasoner() { return isInit[1]; } /** - * set true if you run Reasoner.init + * Set true if you run Reasoner.init. The inits from other tabs behind will + * automatic set to false. */ - protected void setInitReasoner(Boolean is) { + public void setInitReasoner(Boolean is) { isInit[1] = is; for (int i = 2; i < 4; i++) isInit[i] = false; } /** - * LearningProblem.init has run? return true, if it was + * LearningProblem.init has run? + * + * @return true, if init was made, false if not */ - protected boolean isInitLearningProblem() { + public boolean isInitLearningProblem() { return isInit[2]; } /** - * set true if you run LearningProblem.init + * Set true if you run LearningProblem.init. The inits from other tabs + * behind will automatic set to false. */ - protected void setInitLearningProblem(Boolean is) { + public void setInitLearningProblem(Boolean is) { isInit[2] = is; for (int i = 3; i < 4; i++) isInit[i] = false; } /** - * LearningAlgorithm.init() has run? return true, if it was + * LearningAlgorithm.init() has run? + * + * @return true, if init was made, false if not */ - protected boolean isInitLearningAlgorithm() { + public boolean isInitLearningAlgorithm() { return isInit[3]; } /** * set true if you run LearningAlgorithm.init */ - protected void setInitLearningAlgorithm(Boolean is) { + public void setInitLearningAlgorithm(Boolean is) { isInit[3] = is; } - @Deprecated - protected void autoInit() { - // Knowledge Source - if (!this.isInitKnowledgeSource() && this.getKnowledgeSource() != null - && this.getURI() != null) { - this.getKnowledgeSource().init(); - this.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); - } - // Reasoner - if (!this.isInitReasoner() && this.getKnowledgeSource() != null - && this.getReasoner() != null) { - this.getReasoner().init(); - System.out.println("init Reasoner"); - // set ReasoningService - this.setReasoningService(this.getComponentManager() - .reasoningService(this.getReasoner())); - System.out.println("init ReasoningService"); - this.setInitReasoner(true); - } - // Learning Problem - if (!this.isInitLearningProblem() && this.getReasoner() != null - && this.getLearningProblem() != null) { - this.getComponentManager().applyConfigEntry( - this.getLearningProblem(), "negativeExamples", - this.getNegExampleSet()); - this.getLearningProblem().init(); - this.setInitLearningProblem(true); - System.out.println("init LearningProblem"); - } - // Learning Algorithm - if (!this.isInitLearningAlgorithm() - && this.getLearningProblem() != null - && this.getLearningAlgorithm() != null) { - this.getLearningAlgorithm().init(); - System.out.println("init LearningAlgorithm"); - } - - } - } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-12 14:46:20 UTC (rev 548) @@ -28,10 +28,10 @@ import org.dllearner.core.KnowledgeSource; /** - * KnowledgeSourcePanel + * KnowledgeSourcePanel, tab 1. Choose Source, change Options and final initiate + * KnowledgeSource. * * @author Tilo Hielscher - * */ public class KnowledgeSourcePanel extends JPanel implements ActionListener { Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-12 14:46:20 UTC (rev 548) @@ -29,10 +29,10 @@ import org.dllearner.core.LearningAlgorithm; /** - * LearningAlgorithmPanel + * LearningAlgorithmPanel, tab 4. Choose LearningAlgorithm, change Options and + * final initiate LearningAlgorithm. * * @author Tilo Hielscher - * */ public class LearningAlgorithmPanel extends JPanel implements ActionListener { Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-12 14:46:20 UTC (rev 548) @@ -28,7 +28,8 @@ import org.dllearner.core.LearningProblem; /** - * LearningProblemPanel + * LearningProblemPanel tab 3. Choose LearingProblem, change Options and final + * initiate LearningProblem. * * @author Tilo Hielscher */ Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-12 14:46:20 UTC (rev 548) @@ -35,7 +35,7 @@ import org.dllearner.core.config.*; /** - * OptionPanel + * OptionPanel reads all possible options and use all widgets. Definition map is here. * * @author Tilo Hielscher * Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-12 14:46:20 UTC (rev 548) @@ -30,10 +30,10 @@ import org.dllearner.core.ReasonerComponent; /** - * ReasonerPanel + * ReasonerPanel, tab 2. Choose Resoner, change Options and final initiate + * Reasoner and ReasoningService. * * @author Tilo Hielscher - * */ public class ReasonerPanel extends JPanel implements ActionListener { Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-12 14:46:20 UTC (rev 548) @@ -29,7 +29,7 @@ // import org.dllearner.core.dl.Concept; /** - * OutputPanel + * RunPanel let algorithm start and stop and show informations about. * * @author Tilo Hielscher * Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-12 14:46:20 UTC (rev 548) @@ -21,7 +21,7 @@ */ /** - * threadRun + * Start algorihtm in a new thread. * * @author Tilo Hielscher */ @@ -33,13 +33,18 @@ this.config = config; } - // method to start thread + /** + * method to start thread + */ @Override public void run() { if (config.getLearningAlgorithm() != null) config.getLearningAlgorithm().start(); } + /** + * stop thread + */ public void exit() { if (config.getLearningAlgorithm() != null) config.getLearningAlgorithm().stop(); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-12 14:46:20 UTC (rev 548) @@ -36,10 +36,10 @@ import org.dllearner.core.config.InvalidConfigOptionValueException; /** - * WidgetPanelInteger + * Panel for option Boolean, defined in + * org.dllearner.core.config.BooleanConfigOption. * * @author Tilo Hielscher - * */ public class WidgetPanelBoolean extends AbstractWidgetPanel implements ActionListener { @@ -69,23 +69,19 @@ add(widgetPanel, BorderLayout.CENTER); } - public JPanel getPanel() { - return this; - } - public void actionPerformed(ActionEvent e) { setEntry(); } @Override - protected void showLabel() { + public void showLabel() { nameLabel = new JLabel(configOption.getName()); nameLabel.setToolTipText(configOption.getDescription()); widgetPanel.add(nameLabel); } @Override - protected void showThingToChange() { + public void showThingToChange() { if (component != null) { // BooleanConfigOption if (configOption.getClass().toString().contains( @@ -127,7 +123,7 @@ } @Override - protected void setEntry() { + public void setEntry() { BooleanConfigOption specialOption; if (cb.getSelectedIndex() == 0) value = false; Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-02-12 14:46:20 UTC (rev 548) @@ -30,7 +30,7 @@ import org.dllearner.core.config.ConfigOption; /** - * WidgetPanelDefault + * Panel for not defined options. * * @author Tilo Hielscher * @@ -55,14 +55,14 @@ } @Override - protected void showLabel() { + public void showLabel() { nameLabel = new JLabel(configOption.getName()); nameLabel.setToolTipText(configOption.getDescription()); widgetPanel.add(nameLabel); } @Override - protected void showThingToChange() { + public void showThingToChange() { JLabel notImplementedLabel = new JLabel(configOption.getClass() .getSimpleName() + " not implemented"); @@ -72,7 +72,7 @@ } @Override - protected void setEntry() { + public void setEntry() { } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-12 14:46:20 UTC (rev 548) @@ -37,7 +37,8 @@ import org.dllearner.core.config.InvalidConfigOptionValueException; /** - * WidgetPanelDouble + * Panel for option Double, defined in + * org.dllearner.core.config.DoubleConfigOption. * * @author Tilo Hielscher * @@ -70,10 +71,6 @@ add(widgetPanel, BorderLayout.CENTER); } - public JPanel getPanel() { - return this; - } - public void actionPerformed(ActionEvent e) { if (e.getSource() == setButton) { setEntry(); @@ -81,14 +78,14 @@ } @Override - protected void showLabel() { + public void showLabel() { nameLabel = new JLabel(configOption.getName()); nameLabel.setToolTipText(configOption.getDescription()); widgetPanel.add(nameLabel); } @Override - protected void showThingToChange() { + public void showThingToChange() { if (component != null) { // DoubleConfigOption if (configOption.getClass().toString().contains( @@ -128,7 +125,7 @@ } @Override - protected void setEntry() { + public void setEntry() { DoubleConfigOption specialOption; value = Double.parseDouble(doubleField.getText()); // get from input specialOption = (DoubleConfigOption) config.getComponentManager() Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-12 14:46:20 UTC (rev 548) @@ -37,7 +37,8 @@ import org.dllearner.core.config.InvalidConfigOptionValueException; /** - * WidgetPanelInteger + * Panel for option Integer, defined in + * org.dllearner.core.config.IntegerConfigOption. * * @author Tilo Hielscher * @@ -71,10 +72,6 @@ add(widgetPanel, BorderLayout.CENTER); } - public JPanel getPanel() { - return this; - } - public void actionPerformed(ActionEvent e) { if (e.getSource() == setButton) { setEntry(); @@ -82,14 +79,14 @@ } @Override - protected void showLabel() { + public void showLabel() { nameLabel = new JLabel(configOption.getName()); nameLabel.setToolTipText(configOption.getDescription()); widgetPanel.add(nameLabel); } @Override - protected void showThingToChange() { + public void showThingToChange() { if (component != null) { // IntegerConfigOption if (configOption.getClass().toString().contains( @@ -129,7 +126,7 @@ } @Override - protected void setEntry() { + public void setEntry() { IntegerConfigOption specialOption; value = Integer.parseInt(integerField.getText()); // get from input specialOption = (IntegerConfigOption) config.getComponentManager() Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-12 14:46:20 UTC (rev 548) @@ -39,7 +39,8 @@ import org.dllearner.core.config.InvalidConfigOptionValueException; /** - * WidgetPanelString + * Panel for option String, defined in + * org.dllearner.core.config.StringConfigOption. * * @author Tilo Hielscher * @@ -72,10 +73,6 @@ add(widgetPanel, BorderLayout.CENTER); } - public JPanel getPanel() { - return this; - } - public void actionPerformed(ActionEvent e) { if (e.getSource() == setButton) { if (checkForFilename()) { @@ -86,7 +83,7 @@ value = fc.getSelectedFile().toString(); stringField.setText(value); config.setURI(value); // save variable - System.out.println("value: " + config.getURI()); + System.out.println("value: " + config.getURI()); } } setEntry(); @@ -100,14 +97,14 @@ } @Override - protected void showLabel() { + public void showLabel() { nameLabel = new JLabel(configOption.getName()); nameLabel.setToolTipText(configOption.getDescription()); widgetPanel.add(nameLabel); } @Override - protected void showThingToChange() { + public void showThingToChange() { if (component != null) { // StringConfigOption if (configOption.getClass().toString().contains( @@ -149,7 +146,7 @@ } @Override - protected void setEntry() { + public void setEntry() { StringConfigOption specialOption; value = stringField.getText(); // get from input specialOption = (StringConfigOption) config.getComponentManager() Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-12 12:10:53 UTC (rev 547) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-12 14:46:20 UTC (rev 548) @@ -47,8 +47,12 @@ import org.dllearner.core.owl.ObjectProperty; /** - * WidgetPanelStringSet + * Panel for option StringSet, defined in + * org.dllearner.core.config.StringSetConfigOption. * + * There are 2 layouts defined. First for normal option and a second for special + * options. Second layout shows a list of JCheckBox's. + * * @author Tilo Hielscher * */ @@ -141,7 +145,7 @@ } @Override - protected void showLabel() { + public void showLabel() { nameLabel = new JLabel(configOption.getName()); nameLabel.setToolTipText(configOption.getDescription()); buildConstraints(constraints, 0, 0, 1, 1, 100, 100); @@ -152,7 +156,7 @@ @SuppressWarnings("unchecked") @Override - protected void showThingToChange() { + public void showThingToChange() { if (component != null) { // StringSetConfigOption if (configOption.getClass().toString().contains( @@ -272,7 +276,7 @@ } @Override - protected void setEntry() { + public void setEntry() { StringSetConfigOption specialOption; specialOption = (StringSetConfigOption) config.getComponentManager() .getConfigOption(componentOption, configOption.getName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-12 15:33:08
|
Revision: 549 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=549&view=rev Author: tonytacker Date: 2008-02-12 07:32:56 -0800 (Tue, 12 Feb 2008) Log Message: ----------- renamed class and more comments Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelAbstract.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-02-12 14:46:20 UTC (rev 548) +++ trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-02-12 15:32:56 UTC (rev 549) @@ -1,47 +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 javax.swing.JPanel; - -/** - * AbstractWidgetPanel - * - * @author Tilo Hielscher - */ -public abstract class AbstractWidgetPanel extends JPanel { - - /** - * Show label and tooltip. - */ - public abstract void showLabel(); - - /** - * Show textfield, setbutton and so on, make layout. - */ - public abstract void showThingToChange(); - - /** - * Set entry you got from showThingToChange(). - */ - public abstract void setEntry(); - -} Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-12 14:46:20 UTC (rev 548) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-12 15:32:56 UTC (rev 549) @@ -29,7 +29,7 @@ import java.util.Set; /** - * CheckBoxList is a list of CheckBox's + * CheckBoxList constitute a list of CheckBox's * * @author Tilo Hielscher */ @@ -41,7 +41,7 @@ private GridBagConstraints constraints = new GridBagConstraints(); /** - * get a JPanel + * Make a JPanel with GridBagLayout. */ public CheckBoxList() { checkBoxPanel.setLayout(gridbag); @@ -52,7 +52,9 @@ /** * Add new entry and make a new JCheckBox. * - * @param label This text will be shown. + * @param label + * This text will be shown. It is the name of new JCheckBox + * and will add to list. */ public void add(String label) { list.add(new JCheckBox(label)); @@ -75,7 +77,8 @@ /** * Select items. * - * @param selectionSet Is a Set of Strings. + * @param selectionSet + * Is a Set of Strings. */ public void setSelections(Set<String> selectionSet) { for (int i = 0; i < list.size(); i++) { Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-12 14:46:20 UTC (rev 548) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-12 15:32:56 UTC (rev 549) @@ -21,7 +21,7 @@ */ /** - * Start algorihtm in a new thread. + * Start algorithm in a new thread. * * @author Tilo Hielscher */ Copied: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelAbstract.java (from rev 548, trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelAbstract.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelAbstract.java 2008-02-12 15:32:56 UTC (rev 549) @@ -0,0 +1,47 @@ +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; + +/** + * WidgetPanelAbstract defines all Widgets in an abstract way. + * + * @author Tilo Hielscher + */ +public abstract class WidgetPanelAbstract extends JPanel { + + /** + * Show label and tooltip. + */ + public abstract void showLabel(); + + /** + * Show textfield, setbutton and so on, make layout. + */ + public abstract void showThingToChange(); + + /** + * Set entry you got from showThingToChange(). + */ + public abstract void setEntry(); + +} Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-12 14:46:20 UTC (rev 548) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-12 15:32:56 UTC (rev 549) @@ -41,7 +41,7 @@ * * @author Tilo Hielscher */ -public class WidgetPanelBoolean extends AbstractWidgetPanel implements +public class WidgetPanelBoolean extends WidgetPanelAbstract implements ActionListener { private static final long serialVersionUID = -4800583253223939928L; Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-02-12 14:46:20 UTC (rev 548) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-02-12 15:32:56 UTC (rev 549) @@ -35,7 +35,7 @@ * @author Tilo Hielscher * */ -public class WidgetPanelDefault extends AbstractWidgetPanel { +public class WidgetPanelDefault extends WidgetPanelAbstract { private static final long serialVersionUID = 4059515858894036769L; Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-12 14:46:20 UTC (rev 548) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-12 15:32:56 UTC (rev 549) @@ -43,7 +43,7 @@ * @author Tilo Hielscher * */ -public class WidgetPanelDouble extends AbstractWidgetPanel implements +public class WidgetPanelDouble extends WidgetPanelAbstract implements ActionListener { private static final long serialVersionUID = 5238903690721116289L; Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-12 14:46:20 UTC (rev 548) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-12 15:32:56 UTC (rev 549) @@ -43,7 +43,7 @@ * @author Tilo Hielscher * */ -public class WidgetPanelInteger extends AbstractWidgetPanel implements +public class WidgetPanelInteger extends WidgetPanelAbstract implements ActionListener { private static final long serialVersionUID = -1802111225835164644L; Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-12 14:46:20 UTC (rev 548) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-12 15:32:56 UTC (rev 549) @@ -45,7 +45,7 @@ * @author Tilo Hielscher * */ -public class WidgetPanelString extends AbstractWidgetPanel implements +public class WidgetPanelString extends WidgetPanelAbstract implements ActionListener { private static final long serialVersionUID = -2169739820989891226L; Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-12 14:46:20 UTC (rev 548) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-12 15:32:56 UTC (rev 549) @@ -56,7 +56,7 @@ * @author Tilo Hielscher * */ -public class WidgetPanelStringSet extends AbstractWidgetPanel implements +public class WidgetPanelStringSet extends WidgetPanelAbstract implements ActionListener { private static final long serialVersionUID = 7832726987046601916L; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-13 11:15:55
|
Revision: 558 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=558&view=rev Author: tonytacker Date: 2008-02-13 03:15:53 -0800 (Wed, 13 Feb 2008) Log Message: ----------- include StringTupleList Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/package.html Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-13 11:02:08 UTC (rev 557) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-13 11:15:53 UTC (rev 558) @@ -35,7 +35,8 @@ import org.dllearner.core.config.*; /** - * OptionPanel reads all possible options and use all widgets. Definition map is here. + * OptionPanel reads all possible options and use all widgets. Definition map is + * here. * * @author Tilo Hielscher * @@ -113,6 +114,10 @@ "StringSetConfigOption")) { widgetPanel = new WidgetPanelStringSet(config, component, componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains( + "StringTupleListConfigOption")) { + widgetPanel = new WidgetPanelStringTupleList(config, component, + componentOption, optionList.get(i)); } else { widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-02-13 11:15:53 UTC (rev 558) @@ -0,0 +1,256 @@ +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.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.Color; + +import java.util.List; +import java.util.LinkedList; +import java.util.Iterator; + +import javax.swing.DefaultListModel; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.StringTupleListConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.utilities.StringTuple; + +/** + * Panel for option StringTupleList, defined in + * org.dllearner.core.config.StringTupleListConfigOption. + * + * @author Tilo Hielscher + */ +public class WidgetPanelStringTupleList extends WidgetPanelAbstract implements + ActionListener { + + private static final long serialVersionUID = 7832726987046601916L; + private Config config; + private ConfigOption<?> configOption; + private GridBagLayout gridbag = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); + + private JLabel nameLabel; + private JPanel widgetPanel = new JPanel(); + private JButton addButton = new JButton("add"); + private JButton removeButton = new JButton("remove"); + private JButton clearButton = new JButton("clear"); + private JTextField stringFieldA = new JTextField(10); + private JTextField stringFieldB = new JTextField(10); + private List<StringTuple> exampleList = new LinkedList<StringTuple>(); + + private Component component; + private Class<? extends Component> componentOption; + + private List<StringTuple> value = new LinkedList<StringTuple>(); + private JList stringList = new JList(); + private DefaultListModel listModel = new DefaultListModel(); + + private JButton setButton = new JButton("set"); + + public WidgetPanelStringTupleList(Config config, Component component, + Class<? extends Component> componentOption, + ConfigOption<?> configOption) { + + this.config = config; + this.configOption = configOption; + this.component = component; + this.componentOption = componentOption; + + widgetPanel.setLayout(gridbag); + add(widgetPanel, BorderLayout.CENTER); + showLabel(); // name of option and tooltip + showThingToChange(); // textfield, setbutton + stringList.setModel(listModel); + // ActionListeners + addButton.addActionListener(this); + removeButton.addActionListener(this); + clearButton.addActionListener(this); + setButton.addActionListener(this); + } + + public void actionPerformed(ActionEvent e) { + // add to list + if (e.getSource() == addButton + && !listModel.contains(stringFieldA.getText() + " --> " + + stringFieldB.getText()) + && !stringFieldA.getText().equalsIgnoreCase("") + && !stringFieldB.getText().equalsIgnoreCase("")) { + listModel.addElement(stringFieldA.getText() + " --> " + + stringFieldB.getText()); + exampleList.add(new StringTuple(stringFieldA.getText(), + stringFieldB.getText())); + } + // remove selection + if (e.getSource() == removeButton) { + int[] selectedIndices = stringList.getSelectedIndices(); + int count = 0; + // remove i.e. 2 and 4: after delete 2: 4 is now 3 + for (int i : selectedIndices) { + listModel.remove(i - count); + exampleList.remove(i - count++); + } + } + // clear list + if (e.getSource() == clearButton) { + listModel.clear(); + exampleList.clear(); + } + // set entry + value = exampleList; + setEntry(); + } + + @Override + public void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + buildConstraints(constraints, 0, 0, 1, 1, 100, 100); + constraints.anchor = GridBagConstraints.WEST; + gridbag.setConstraints(nameLabel, constraints); + widgetPanel.add(nameLabel, constraints); + } + + @SuppressWarnings("unchecked") + @Override + public void showThingToChange() { + if (component != null) { + // StringTupleListConfigOption + if (configOption.getClass().toString().contains( + "StringTupleListConfigOption")) { + // previous set value + if (configOption != null) { + // take list + value = (List<StringTuple>) config.getComponentManager() + .getConfigOptionValue(component, + configOption.getName()); + + // fill list + if (value != null) { + for (Iterator<StringTuple> iterator = value.iterator(); iterator + .hasNext();) { + StringTuple item = iterator.next(); + listModel.addElement(item); + } + } + } + // stringFieldA + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(stringFieldA, constraints); + widgetPanel.add(stringFieldA, constraints); + // arrow + JLabel arrowLabel = new JLabel(" --> "); + buildConstraints(constraints, 1, 1, 1, 1, 100, 100); + constraints.anchor = GridBagConstraints.WEST; + gridbag.setConstraints(arrowLabel, constraints); + widgetPanel.add(arrowLabel, constraints); + // stringFieldB + buildConstraints(constraints, 2, 1, 1, 1, 100, 100); + gridbag.setConstraints(stringFieldB, constraints); + widgetPanel.add(stringFieldB, constraints); + // addButton + buildConstraints(constraints, 3, 1, 1, 1, 100, 100); + gridbag.setConstraints(addButton, constraints); + widgetPanel.add(addButton, constraints); + // list + stringList.setModel(listModel); + stringList.setLayoutOrientation(JList.VERTICAL); + stringList.setVisibleRowCount(-1); + JScrollPane stringListScroller = new JScrollPane(stringList); + stringListScroller.setPreferredSize(new Dimension(280, 100)); + buildConstraints(constraints, 0, 2, 3, 2, 100, 100); + gridbag.setConstraints(stringListScroller, constraints); + widgetPanel.add(stringListScroller, constraints); + // removeButton + buildConstraints(constraints, 3, 2, 1, 1, 100, 100); + gridbag.setConstraints(removeButton, constraints); + widgetPanel.add(removeButton, constraints); + // clearButton + buildConstraints(constraints, 3, 3, 1, 1, 100, 100); + gridbag.setConstraints(clearButton, constraints); + widgetPanel.add(clearButton, constraints); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel( + " not a StringTupleList"); + notImplementedLabel.setForeground(Color.RED); + buildConstraints(constraints, 1, 0, 1, 1, 100, 100); + gridbag.setConstraints(notImplementedLabel, constraints); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel( + " no init (StringTupleList)"); + noConfigOptionLabel.setForeground(Color.MAGENTA); + buildConstraints(constraints, 1, 0, 1, 1, 100, 100); + gridbag.setConstraints(noConfigOptionLabel, constraints); + widgetPanel.add(noConfigOptionLabel, constraints); + } + } + + @Override + public void setEntry() { + StringTupleListConfigOption specialOption; + specialOption = (StringTupleListConfigOption) config + .getComponentManager().getConfigOption(componentOption, + configOption.getName()); + + try { + ConfigEntry<List<StringTuple>> specialEntry = new ConfigEntry<List<StringTuple>>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set StringTupleList: " + configOption.getName() + + " = " + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + } + + /** + * 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/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/package.html 2008-02-13 11:02:08 UTC (rev 557) +++ trunk/src/dl-learner/org/dllearner/gui/package.html 2008-02-13 11:15:53 UTC (rev 558) @@ -2,6 +2,6 @@ <html> <head></head> <body bgcolor="white"> -<p>Classes for generating a Graphical User Interface for DL-Learner.</p> +<p>Classes to generate a Graphical User Interface for DL-Learner.</p> </body> </html> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-13 19:28:35
|
Revision: 571 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=571&view=rev Author: tonytacker Date: 2008-02-13 11:28:25 -0800 (Wed, 13 Feb 2008) Log Message: ----------- please ignore - i'm thinking about a way to get old entry's Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-13 19:28:25 UTC (rev 571) @@ -20,28 +20,36 @@ * */ +import java.util.HashSet; +import java.util.Set; + import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.Component; /** * Config save all together used variables: ComponentManager, KnowledgeSource, * Reasoner, ReasoningService, LearningProblem, LearningAlgorithm; also inits of - * these components + * these components. * * @author Tilo Hielscher */ public class Config { private ComponentManager cm = ComponentManager.getInstance(); private KnowledgeSource source; + private Set<Component> oldKnowledgeSourceSet = new HashSet<Component>(); private String uri; private ReasonerComponent reasoner; + private Set<Component> oldReasonerSet = new HashSet<Component>(); private ReasoningService rs; private LearningProblem lp; + private Set<Component> oldLearningProblemSet = new HashSet<Component>(); private LearningAlgorithm la; + private Set<Component> oldLearningAlgorithmSet = new HashSet<Component>(); private boolean[] isInit = new boolean[4]; /** @@ -73,57 +81,77 @@ } /** - * Get Reasoner. + * Set KnowledgeSource. * - * @return reasoner + * @param knowledgeSource */ - public ReasonerComponent getReasoner() { - return this.reasoner; + public void setKnowledgeSource(KnowledgeSource knowledgeSource) { + this.oldKnowledgeSourceSet.add(this.source); + this.source = knowledgeSource; } /** + * Get KnowledgeSource. + * + * @return KnowledgeSource + */ + public KnowledgeSource getKnowledgeSource() { + return this.source; + } + + /** + * Get old KnowledgeSource. + * + * @return old KnowledgeSource + */ + public Set<Component> getOldKnowledgeSource() { + return this.oldKnowledgeSourceSet; + } + + /** * Set Reasoner. * * @param reasoner */ public void setReasoner(ReasonerComponent reasoner) { + this.oldReasonerSet.add(this.reasoner); this.reasoner = reasoner; } /** - * Get ReasoningService. + * Get Reasoner. * - * @return ReasoningService + * @return reasoner */ - public ReasoningService getReasoningService() { - return this.rs; + public ReasonerComponent getReasoner() { + return this.reasoner; } /** - * Set ReasoningService. + * Get old Reasoner as a set. * - * @param reasoningService + * @return oldReasonerSet. */ - public void setReasoningService(ReasoningService reasoningService) { - this.rs = reasoningService; + public Set<Component> getOldReasonerSet() { + return this.oldReasonerSet; } /** - * Get KnowledgeSource. + * Set ReasoningService. * - * @return KnowledgeSource + * @param reasoningService */ - public KnowledgeSource getKnowledgeSource() { - return this.source; + public void setReasoningService(ReasoningService reasoningService) { + this.rs = reasoningService; } /** - * Set KnowledgeSource. + * Get ReasoningService. * - * @param knowledgeSource + * @return ReasoningService */ - public void setKnowledgeSource(KnowledgeSource knowledgeSource) { - this.source = knowledgeSource; + public ReasoningService getReasoningService() { + return this.rs; } /** @@ -132,6 +160,7 @@ * @param learningProblem */ public void setLearningProblem(LearningProblem learningProblem) { + this.oldLearningProblemSet.add(this.lp); this.lp = learningProblem; } @@ -145,11 +174,21 @@ } /** + * Get old LearningProblem as a set. + * + * @return old learningProblemSet. + */ + public Set<Component> getOldLearningProblem() { + return this.oldLearningProblemSet; + } + + /** * Set LearningAlgorithm. * * @param learningAlgorithm */ public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { + this.oldLearningAlgorithmSet.add(this.la); this.la = learningAlgorithm; } @@ -163,6 +202,15 @@ } /** + * Get old LearningAlgorithmSet. + * + * @return old LearningAlgorithmSet + */ + public Set<Component> getOldLearningAlgorithm() { + return this.oldLearningAlgorithmSet; + } + + /** * KnowledgeSource.init has run? * * @return true, if init was made, false if not Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-13 19:28:25 UTC (rev 571) @@ -67,7 +67,9 @@ cb.addActionListener(this); choosePanel.add(cb); - optionPanel = new OptionPanel(config, config.getKnowledgeSource(), + optionPanel = new OptionPanel(config, + config.getKnowledgeSource(), + config.getOldKnowledgeSource(), sources.get(choosenClassIndex)); initPanel.add(initButton); @@ -121,7 +123,7 @@ * update OptionPanel with new selection */ public void updateOptionPanel() { - optionPanel.update(config.getKnowledgeSource(), sources - .get(choosenClassIndex)); + optionPanel.update(config.getKnowledgeSource(), config + .getOldKnowledgeSource(), sources.get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-13 19:28:25 UTC (rev 571) @@ -74,7 +74,8 @@ cb.addActionListener(this); optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), - learners.get(choosenClassIndex)); + config.getOldLearningAlgorithm(), learners + .get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); add(optionPanel, BorderLayout.CENTER); @@ -133,7 +134,7 @@ */ public void updateOptionPanel() { // update OptionPanel - optionPanel.update(config.getLearningAlgorithm(), learners - .get(choosenClassIndex)); + optionPanel.update(config.getLearningAlgorithm(), config + .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-13 19:28:25 UTC (rev 571) @@ -75,7 +75,7 @@ choosenClassIndex = cb.getSelectedIndex(); optionPanel = new OptionPanel(config, config.getLearningProblem(), - problems.get(choosenClassIndex)); + config.getOldLearningProblem(), problems.get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); add(optionPanel, BorderLayout.CENTER); @@ -108,8 +108,23 @@ config.setLearningProblem(config.getComponentManager() .learningProblem(problems.get(choosenClassIndex), config.getReasoningService())); + // TEST + // previous set value in old component + if (config.getLearningProblem() != null + && config.getOldLearningProblem() != null) { + System.out.println("NOW: " + + config.getLearningProblem().getClass()); + System.out.println("OLD: " + config.getOldLearningProblem()); + System.out.println("OLD contains?: " + + config.getOldLearningProblem().contains( + config.getLearningProblem().getClass())); + if (config.getLearningProblem().getClass().equals( + config.getOldLearningProblem().getClass())) { + System.out.println("--> THE SAME"); + } + } + startGUI.updateTabColors(); updateOptionPanel(); - startGUI.updateTabColors(); } } @@ -130,7 +145,7 @@ */ private void updateOptionPanel() { // update OptionPanel - optionPanel.update(config.getLearningProblem(), problems - .get(choosenClassIndex)); + optionPanel.update(config.getLearningProblem(), config + .getOldLearningProblem(), problems.get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-13 19:28:25 UTC (rev 571) @@ -25,7 +25,9 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -49,15 +51,18 @@ private List<ConfigOption<?>> optionList; private JPanel centerPanel = new JPanel(); private Component component; + private Set<Component> oldComponentSet = new HashSet<Component>(); private GridBagLayout gridBagLayout = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); public OptionPanel(Config config, Component component, + Set<Component> oldComponentSet, Class<? extends Component> componentOption) { super(new BorderLayout()); this.config = config; this.component = component; + this.oldComponentSet = oldComponentSet; this.componentOption = componentOption; optionList = ComponentManager.getConfigOptions(componentOption); @@ -71,17 +76,18 @@ centerScroller.setPreferredSize(new Dimension(400, 200)); // add Panels add(centerScroller, BorderLayout.CENTER); - + // show widgets showWidgets(); - } /** update this OptionPanel */ - public void update(Component component, + public void update(Component component, Set<Component> oldComponentSet, Class<? extends Component> componentOption) { + this.component = component; + this.oldComponentSet = oldComponentSet; this.componentOption = componentOption; - this.component = component; showWidgets(); + } /** @@ -101,7 +107,7 @@ } else if (optionList.get(i).getClass().toString().contains( "BooleanConfigOption")) { widgetPanel = new WidgetPanelBoolean(config, component, - componentOption, optionList.get(i)); + oldComponentSet, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "DoubleConfigOption")) { widgetPanel = new WidgetPanelDouble(config, component, Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-13 19:28:25 UTC (rev 571) @@ -72,8 +72,8 @@ reasoners.get(i))); } - optionPanel = new OptionPanel(config, config.getReasoner(), reasoners - .get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getReasoner(), config + .getOldReasonerSet(), reasoners.get(choosenClassIndex)); choosePanel.add(autoInitButton); cb.addActionListener(this); @@ -92,12 +92,13 @@ if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); config.setInitReasoner(false); - setReasoner(); } - if (e.getSource() == autoInitButton) + if (e.getSource() == autoInitButton) { + config.setInitReasoner(false); setReasoner(); + } if (e.getSource() == initButton) init(); @@ -121,7 +122,7 @@ * after this, next tab can be used */ public void init() { - if (/* !config.isInitReasoner() && */config.getKnowledgeSource() != null + if (config.getKnowledgeSource() != null && config.getReasoner() != null) { config.getReasoner().init(); System.out.println("init Reasoner"); @@ -140,8 +141,8 @@ * update OptionPanel with new selection */ public void updateOptionPanel() { - optionPanel.update(config.getReasoner(), reasoners - .get(choosenClassIndex)); + optionPanel.update(config.getReasoner(), config.getOldReasonerSet(), + reasoners.get(choosenClassIndex)); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-13 17:32:23 UTC (rev 570) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-13 19:28:25 UTC (rev 571) @@ -29,6 +29,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; +import java.util.Set; + import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; @@ -50,18 +52,20 @@ private JLabel nameLabel; private JPanel widgetPanel = new JPanel(); private Component component; + private Set<Component> oldComponentSet; private Class<? extends Component> componentOption; - private Boolean value; private String[] kbBoxItems = { "false", "true" }; private JComboBox cb = new JComboBox(kbBoxItems); public WidgetPanelBoolean(Config config, Component component, + Set<Component> oldComponentSet, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponentSet = oldComponentSet; this.componentOption = componentOption; showLabel(); // name of option and tooltip @@ -70,6 +74,7 @@ } public void actionPerformed(ActionEvent e) { + setEntry(); } @@ -92,11 +97,34 @@ .getConfigOptionValue(component, configOption.getName()); } + // previous set value from old + /* + * if (component != null && componentOld != null) { if + * (component.getClass().equals(componentOld.getClass())) { + * value = (Boolean) config.getComponentManager() + * .getConfigOptionValue(componentOld, configOption.getName()); + */ + if (component != null && oldComponentSet != null) { + if (oldComponentSet.contains(component)) { + System.out.println("oldComponentSet: " + + oldComponentSet); + // value = (Boolean) + // config.getComponentManager().getConfigOptionValue(componentOld, + // configOption.getName()); + + // set cb-index + if (value == false) + cb.setSelectedIndex(0); + else + cb.setSelectedIndex(1); + setEntry(); + } + } // default value - else if (configOption.getDefaultValue() != null) { + if (value != null && configOption.getDefaultValue() != null) { value = (Boolean) configOption.getDefaultValue(); } - // value == null + // value == null? if (value == null) { value = false; } @@ -142,4 +170,5 @@ s.printStackTrace(); } } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-14 15:08:52
|
Revision: 572 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=572&view=rev Author: tonytacker Date: 2008-02-14 07:08:47 -0800 (Thu, 14 Feb 2008) Log Message: ----------- "Set"-button on top reloads now previous made entry from last component. You can change i.e. KnowledgeSource and can initiate the other tabulators (Reasoner, LerningProblem, LearningAlgorithm) without setting your options again. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-14 15:08:47 UTC (rev 572) @@ -81,11 +81,11 @@ * Is a Set of Strings. */ public void setSelections(Set<String> selectionSet) { - for (int i = 0; i < list.size(); i++) { + for (int i = 0; i < this.list.size(); i++) { if (selectionSet.contains(list.get(i).getText())) list.get(i).setSelected(true); else - list.get(i).setSelected(false); + this.list.get(i).setSelected(false); } } Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-14 15:08:47 UTC (rev 572) @@ -20,16 +20,12 @@ * */ -import java.util.HashSet; -import java.util.Set; - import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.Component; /** * Config save all together used variables: ComponentManager, KnowledgeSource, @@ -41,15 +37,15 @@ public class Config { private ComponentManager cm = ComponentManager.getInstance(); private KnowledgeSource source; - private Set<Component> oldKnowledgeSourceSet = new HashSet<Component>(); + private KnowledgeSource oldSource; private String uri; private ReasonerComponent reasoner; - private Set<Component> oldReasonerSet = new HashSet<Component>(); + private ReasonerComponent oldReasoner; private ReasoningService rs; private LearningProblem lp; - private Set<Component> oldLearningProblemSet = new HashSet<Component>(); + private LearningProblem oldLearningProblem; private LearningAlgorithm la; - private Set<Component> oldLearningAlgorithmSet = new HashSet<Component>(); + private LearningAlgorithm oldLearningAlgorithm; private boolean[] isInit = new boolean[4]; /** @@ -86,7 +82,7 @@ * @param knowledgeSource */ public void setKnowledgeSource(KnowledgeSource knowledgeSource) { - this.oldKnowledgeSourceSet.add(this.source); + this.oldSource = this.source; this.source = knowledgeSource; } @@ -104,8 +100,8 @@ * * @return old KnowledgeSource */ - public Set<Component> getOldKnowledgeSource() { - return this.oldKnowledgeSourceSet; + public KnowledgeSource getOldKnowledgeSource() { + return this.oldSource; } /** @@ -114,7 +110,7 @@ * @param reasoner */ public void setReasoner(ReasonerComponent reasoner) { - this.oldReasonerSet.add(this.reasoner); + this.oldReasoner = this.reasoner; this.reasoner = reasoner; } @@ -132,8 +128,8 @@ * * @return oldReasonerSet. */ - public Set<Component> getOldReasonerSet() { - return this.oldReasonerSet; + public ReasonerComponent getOldReasonerSet() { + return this.oldReasoner; } /** @@ -160,7 +156,7 @@ * @param learningProblem */ public void setLearningProblem(LearningProblem learningProblem) { - this.oldLearningProblemSet.add(this.lp); + this.oldLearningProblem = this.lp; this.lp = learningProblem; } @@ -178,8 +174,8 @@ * * @return old learningProblemSet. */ - public Set<Component> getOldLearningProblem() { - return this.oldLearningProblemSet; + public LearningProblem getOldLearningProblem() { + return this.oldLearningProblem; } /** @@ -188,7 +184,7 @@ * @param learningAlgorithm */ public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { - this.oldLearningAlgorithmSet.add(this.la); + this.oldLearningAlgorithm = this.la; this.la = learningAlgorithm; } @@ -206,8 +202,8 @@ * * @return old LearningAlgorithmSet */ - public Set<Component> getOldLearningAlgorithm() { - return this.oldLearningAlgorithmSet; + public LearningAlgorithm getOldLearningAlgorithm() { + return this.oldLearningAlgorithm; } /** Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-14 15:08:47 UTC (rev 572) @@ -40,6 +40,7 @@ private Config config; private StartGUI startGUI; private JButton initButton; + private JButton setButton; private String[] kbBoxItems = {}; private JComboBox cb = new JComboBox(kbBoxItems); private JPanel choosePanel = new JPanel(); @@ -55,6 +56,8 @@ this.startGUI = startGUI; sources = config.getComponentManager().getKnowledgeSources(); + setButton = new JButton ("Set"); + setButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); initButton.addActionListener(this); initButton.setEnabled(true); @@ -67,10 +70,9 @@ cb.addActionListener(this); choosePanel.add(cb); - optionPanel = new OptionPanel(config, - config.getKnowledgeSource(), - config.getOldKnowledgeSource(), - sources.get(choosenClassIndex)); + choosePanel.add(setButton); + optionPanel = new OptionPanel(config, config.getKnowledgeSource(), + config.getOldKnowledgeSource(), sources.get(choosenClassIndex)); initPanel.add(initButton); add(choosePanel, BorderLayout.PAGE_START); @@ -91,6 +93,9 @@ setSource(); } + if (e.getSource() == setButton) + setSource(); + if (e.getSource() == initButton) init(); } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-14 15:08:47 UTC (rev 572) @@ -108,21 +108,6 @@ config.setLearningProblem(config.getComponentManager() .learningProblem(problems.get(choosenClassIndex), config.getReasoningService())); - // TEST - // previous set value in old component - if (config.getLearningProblem() != null - && config.getOldLearningProblem() != null) { - System.out.println("NOW: " - + config.getLearningProblem().getClass()); - System.out.println("OLD: " + config.getOldLearningProblem()); - System.out.println("OLD contains?: " - + config.getOldLearningProblem().contains( - config.getLearningProblem().getClass())); - if (config.getLearningProblem().getClass().equals( - config.getOldLearningProblem().getClass())) { - System.out.println("--> THE SAME"); - } - } startGUI.updateTabColors(); updateOptionPanel(); } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-14 15:08:47 UTC (rev 572) @@ -25,9 +25,7 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; -import java.util.HashSet; import java.util.List; -import java.util.Set; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -51,18 +49,17 @@ private List<ConfigOption<?>> optionList; private JPanel centerPanel = new JPanel(); private Component component; - private Set<Component> oldComponentSet = new HashSet<Component>(); + private Component oldComponent; private GridBagLayout gridBagLayout = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); public OptionPanel(Config config, Component component, - Set<Component> oldComponentSet, - Class<? extends Component> componentOption) { + Component oldComponent, Class<? extends Component> componentOption) { super(new BorderLayout()); this.config = config; this.component = component; - this.oldComponentSet = oldComponentSet; + this.oldComponent = oldComponent; this.componentOption = componentOption; optionList = ComponentManager.getConfigOptions(componentOption); @@ -81,10 +78,10 @@ } /** update this OptionPanel */ - public void update(Component component, Set<Component> oldComponentSet, + public void update(Component component, Component oldComponent, Class<? extends Component> componentOption) { this.component = component; - this.oldComponentSet = oldComponentSet; + this.oldComponent = oldComponent; this.componentOption = componentOption; showWidgets(); @@ -103,30 +100,30 @@ if (optionList.get(i).getClass().toString().contains( "IntegerConfigOption")) { widgetPanel = new WidgetPanelInteger(config, component, - componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "BooleanConfigOption")) { widgetPanel = new WidgetPanelBoolean(config, component, - oldComponentSet, componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "DoubleConfigOption")) { widgetPanel = new WidgetPanelDouble(config, component, - componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "StringConfigOption")) { widgetPanel = new WidgetPanelString(config, component, - componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "StringSetConfigOption")) { widgetPanel = new WidgetPanelStringSet(config, component, - componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( "StringTupleListConfigOption")) { widgetPanel = new WidgetPanelStringTupleList(config, component, - componentOption, optionList.get(i)); + oldComponent, componentOption, optionList.get(i)); } else { widgetPanel = new WidgetPanelDefault(config, component, - componentOption, optionList.get(i)); + /* oldComponent, */componentOption, optionList.get(i)); } gridBagLayout.setConstraints(widgetPanel, constraints); centerPanel.add(widgetPanel); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-14 15:08:47 UTC (rev 572) @@ -29,8 +29,6 @@ import javax.swing.JLabel; import javax.swing.JPanel; -import java.util.Set; - import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; @@ -52,20 +50,19 @@ private JLabel nameLabel; private JPanel widgetPanel = new JPanel(); private Component component; - private Set<Component> oldComponentSet; + private Component oldComponent; private Class<? extends Component> componentOption; private Boolean value; private String[] kbBoxItems = { "false", "true" }; private JComboBox cb = new JComboBox(kbBoxItems); public WidgetPanelBoolean(Config config, Component component, - Set<Component> oldComponentSet, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; - this.oldComponentSet = oldComponentSet; + this.oldComponent = oldComponent; this.componentOption = componentOption; showLabel(); // name of option and tooltip @@ -98,26 +95,20 @@ configOption.getName()); } // previous set value from old - /* - * if (component != null && componentOld != null) { if - * (component.getClass().equals(componentOld.getClass())) { - * value = (Boolean) config.getComponentManager() - * .getConfigOptionValue(componentOld, configOption.getName()); - */ - if (component != null && oldComponentSet != null) { - if (oldComponentSet.contains(component)) { - System.out.println("oldComponentSet: " - + oldComponentSet); - // value = (Boolean) - // config.getComponentManager().getConfigOptionValue(componentOld, - // configOption.getName()); - + if (component != null && oldComponent != null) { + if (oldComponent.getClass().equals(component.getClass())) { + value = (Boolean) config.getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value == null) + value = false; + else + setEntry(); // set cb-index if (value == false) cb.setSelectedIndex(0); else cb.setSelectedIndex(1); - setEntry(); } } // default value Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-14 15:08:47 UTC (rev 572) @@ -53,17 +53,19 @@ private JPanel widgetPanel = new JPanel(); private JButton setButton = new JButton("Set"); private Component component; + private Component oldComponent; private Class<? extends Component> componentOption; private Double value; private JTextField doubleField = new JTextField(5); public WidgetPanelDouble(Config config, Component component, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponent = oldComponent; this.componentOption = componentOption; showLabel(); // name of option and tooltip @@ -96,6 +98,20 @@ .getConfigOptionValue(component, configOption.getName()); } + // previous set value from old + if (component != null && oldComponent != null) { + if (oldComponent.getClass().equals(component.getClass())) { + value = (Double) config.getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value == null) + value = 0.0; + else { + doubleField.setText(value.toString()); + setEntry(); + } + } + } // default value else if (configOption.getDefaultValue() != null) { value = (Double) configOption.getDefaultValue(); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-14 15:08:47 UTC (rev 572) @@ -54,17 +54,19 @@ private JPanel widgetPanel = new JPanel(); private JButton setButton = new JButton("Set"); private Component component; + private Component oldComponent; private Class<? extends Component> componentOption; private Integer value; private JTextField integerField = new JTextField(3); public WidgetPanelInteger(Config config, Component component, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponent = oldComponent; this.componentOption = componentOption; showLabel(); // name of option and tooltip @@ -97,6 +99,20 @@ .getConfigOptionValue(component, configOption.getName()); } + // previous set value from old + if (component != null && oldComponent != null) { + if (oldComponent.getClass().equals(component.getClass())) { + value = (Integer) config.getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value == null) + value = 0; + else { + integerField.setText(value.toString()); + setEntry(); + } + } + } // default value else if (configOption.getDefaultValue() != null) { value = (Integer) configOption.getDefaultValue(); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-14 15:08:47 UTC (rev 572) @@ -55,17 +55,19 @@ private JPanel widgetPanel = new JPanel(); private JButton setButton = new JButton("Set"); private Component component; + private Component oldComponent; private Class<? extends Component> componentOption; private String value; private JTextField stringField = new JTextField(35); public WidgetPanelString(Config config, Component component, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponent = oldComponent; this.componentOption = componentOption; showLabel(); // name of option and tooltip @@ -115,6 +117,18 @@ .getConfigOptionValue(component, configOption.getName()); } + // previous set value from old + if (component != null && oldComponent != null) { + if (oldComponent.getClass().equals(component.getClass())) { + value = (String) config.getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value != null) { + stringField.setText(value.toString()); + setEntry(); + } + } + } // default value else if (configOption.getDefaultValue() != null) { value = (String) configOption.getDefaultValue(); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-14 15:08:47 UTC (rev 572) @@ -73,6 +73,7 @@ private JTextField stringField = new JTextField(25); private Component component; + private Component oldComponent; private Class<? extends Component> componentOption; private Set<String> value = new HashSet<String>(); @@ -83,12 +84,13 @@ private CheckBoxList cBL = new CheckBoxList(); public WidgetPanelStringSet(Config config, Component component, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponent = oldComponent; this.componentOption = componentOption; widgetPanel.setLayout(gridbag); @@ -167,7 +169,18 @@ value = (Set<String>) config.getComponentManager() .getConfigOptionValue(component, configOption.getName()); - + // previous set value from old + if (component != null && oldComponent != null) { + if (oldComponent.getClass() + .equals(component.getClass())) { + value = (Set<String>) config.getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value != null) { + setEntry(); + } + } + } // fill list if (value != null) { for (Iterator<String> iterator = value.iterator(); iterator @@ -177,6 +190,7 @@ } } } + if (!isSpecial()) { // NORMAL LAYOUT // stringField @@ -215,8 +229,6 @@ buildConstraints(constraints, 1, 1, 1, 1, 100, 100); gridbag.setConstraints(setButton, constraints); widgetPanel.add(setButton, constraints); - // set selections - cBL.setSelections(value); // DEFINE LIST // positiveExamples or negativeExamples if (configOption.getName().equalsIgnoreCase( @@ -256,6 +268,9 @@ for (ObjectProperty ind : atomicRoles) cBL.add(ind.getName()); } + // set selections + if (value != null) + cBL.setSelections(value); } } // UNKNOWN Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-02-13 19:28:25 UTC (rev 571) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-02-14 15:08:47 UTC (rev 572) @@ -72,6 +72,7 @@ private List<StringTuple> exampleList = new LinkedList<StringTuple>(); private Component component; + private Component oldComponent; private Class<? extends Component> componentOption; private List<StringTuple> value = new LinkedList<StringTuple>(); @@ -81,12 +82,13 @@ private JButton setButton = new JButton("set"); public WidgetPanelStringTupleList(Config config, Component component, - Class<? extends Component> componentOption, + Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; + this.oldComponent = oldComponent; this.componentOption = componentOption; widgetPanel.setLayout(gridbag); @@ -156,7 +158,20 @@ value = (List<StringTuple>) config.getComponentManager() .getConfigOptionValue(component, configOption.getName()); - + // previous set value from old + if (component != null && oldComponent != null) { + if (oldComponent.getClass() + .equals(component.getClass())) { + value = (List<StringTuple>) config + .getComponentManager() + .getConfigOptionValue(oldComponent, + configOption.getName()); + if (value != null) { + setEntry(); + exampleList = value; + } + } + } // fill list if (value != null) { for (Iterator<StringTuple> iterator = value.iterator(); iterator This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-14 16:47:57
|
Revision: 574 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=574&view=rev Author: tonytacker Date: 2008-02-14 08:47:52 -0800 (Thu, 14 Feb 2008) Log Message: ----------- come more colors for init-buttons 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-02-14 15:58:45 UTC (rev 573) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-14 16:47:52 UTC (rev 574) @@ -23,6 +23,7 @@ import java.util.List; import javax.swing.*; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import org.dllearner.core.KnowledgeSource; @@ -81,6 +82,7 @@ choosenClassIndex = cb.getSelectedIndex(); setSource(); + updateInitButtonColor(); } public void actionPerformed(ActionEvent e) { @@ -113,15 +115,12 @@ * after this, next tab can be used */ public void init() { - if (/* - * !config.isInitKnowledgeSource() && - */config.getKnowledgeSource() != null && config.getURI() != null) { + if (config.getKnowledgeSource() != null && config.getURI() != null) { config.getKnowledgeSource().init(); config.setInitKnowledgeSource(true); System.out.println("init KnowledgeSource"); startGUI.updateTabColors(); } - // config.autoInit(); } /** @@ -131,4 +130,14 @@ optionPanel.update(config.getKnowledgeSource(), config .getOldKnowledgeSource(), sources.get(choosenClassIndex)); } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitKnowledgeSource()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-14 15:58:45 UTC (rev 573) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-14 16:47:52 UTC (rev 574) @@ -22,6 +22,7 @@ import javax.swing.*; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; @@ -81,6 +82,7 @@ add(optionPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); + updateInitButtonColor(); } public void actionPerformed(ActionEvent e) { @@ -103,10 +105,7 @@ * after this, you can change widgets */ public void setLearningAlgorithm() { - // config.autoInit(); - if (/* - * config.isInitLearningProblem() && - */config.getLearningProblem() != null + if (config.getLearningProblem() != null && config.getReasoningService() != null) { config.setLearningAlgorithm(config.getComponentManager() .learningAlgorithm(learners.get(choosenClassIndex), @@ -120,13 +119,13 @@ * after this, next tab can be used */ public void init() { + setLearningAlgorithm(); if (config.getLearningProblem() != null) { config.getLearningAlgorithm().init(); config.setInitLearningAlgorithm(true); System.out.println("init LearningAlgorithm"); startGUI.updateTabColors(); } - // config.autoInit(); } /** @@ -137,4 +136,14 @@ optionPanel.update(config.getLearningAlgorithm(), config .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitLearningAlgorithm()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-14 15:58:45 UTC (rev 573) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-14 16:47:52 UTC (rev 574) @@ -21,6 +21,7 @@ */ import java.awt.BorderLayout; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; @@ -83,6 +84,7 @@ choosenClassIndex = cb.getSelectedIndex(); // setLearningProblem(); + updateInitButtonColor(); } public void actionPerformed(ActionEvent e) { @@ -117,6 +119,7 @@ * after this, next tab can be used */ private void init() { + setLearningProblem(); if (config.getReasoner() != null && config.getLearningProblem() != null) { config.getLearningProblem().init(); config.setInitLearningProblem(true); @@ -133,4 +136,14 @@ optionPanel.update(config.getLearningProblem(), config .getOldLearningProblem(), problems.get(choosenClassIndex)); } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitLearningProblem()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-14 15:58:45 UTC (rev 573) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-14 16:47:52 UTC (rev 574) @@ -21,6 +21,7 @@ */ import java.awt.BorderLayout; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; @@ -45,7 +46,7 @@ private JPanel choosePanel = new JPanel(); private JPanel initPanel = new JPanel(); private OptionPanel optionPanel; - private JButton initButton, autoInitButton; + private JButton initButton, setButton; private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); private int choosenClassIndex; @@ -61,8 +62,8 @@ initButton.addActionListener(this); initPanel.add(initButton); initButton.setEnabled(true); - autoInitButton = new JButton("Set"); - autoInitButton.addActionListener(this); + setButton = new JButton("Set"); + setButton.addActionListener(this); choosePanel.add(cb); @@ -75,7 +76,7 @@ optionPanel = new OptionPanel(config, config.getReasoner(), config .getOldReasonerSet(), reasoners.get(choosenClassIndex)); - choosePanel.add(autoInitButton); + choosePanel.add(setButton); cb.addActionListener(this); add(choosePanel, BorderLayout.PAGE_START); @@ -84,6 +85,7 @@ choosenClassIndex = cb.getSelectedIndex(); setReasoner(); + updateInitButtonColor(); } public void actionPerformed(ActionEvent e) { @@ -95,7 +97,7 @@ setReasoner(); } - if (e.getSource() == autoInitButton) { + if (e.getSource() == setButton) { config.setInitReasoner(false); setReasoner(); } @@ -108,13 +110,14 @@ * after this, you can change widgets */ public void setReasoner() { - // config.autoInit(); if (config.isInitKnowledgeSource()) { config.setReasoner(config.getComponentManager().reasoner( reasoners.get(choosenClassIndex), config.getKnowledgeSource())); updateOptionPanel(); startGUI.updateTabColors(); + config.setInitReasoner(false); + updateInitButtonColor(); } } @@ -122,8 +125,8 @@ * after this, next tab can be used */ public void init() { - if (config.getKnowledgeSource() != null - && config.getReasoner() != null) { + setReasoner(); + if (config.getKnowledgeSource() != null && config.getReasoner() != null) { config.getReasoner().init(); System.out.println("init Reasoner"); // set ReasoningService @@ -132,9 +135,7 @@ System.out.println("init ReasoningService"); config.setInitReasoner(true); startGUI.updateTabColors(); - } - // config.autoInit(); } /** @@ -145,4 +146,13 @@ reasoners.get(choosenClassIndex)); } + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitReasoner()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-14 15:58:45 UTC (rev 573) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-14 16:47:52 UTC (rev 574) @@ -138,5 +138,10 @@ tabPane.setForegroundAt(3, Color.RED); tabPane.setForegroundAt(4, Color.RED); } + tab0.updateInitButtonColor(); + tab1.updateInitButtonColor(); + tab2.updateInitButtonColor(); + tab3.updateInitButtonColor(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-15 12:44:12
|
Revision: 576 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=576&view=rev Author: tonytacker Date: 2008-02-15 04:44:08 -0800 (Fri, 15 Feb 2008) Log Message: ----------- add isValidValue(value) to all widgets Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-15 10:14:14 UTC (rev 575) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-02-15 12:44:08 UTC (rev 576) @@ -150,16 +150,19 @@ value = true; 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(); - } + if (specialOption.isValidValue(value)) { + 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(); + } + } else + System.out.println("Boolean: not valid value"); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-15 10:14:14 UTC (rev 575) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-02-15 12:44:08 UTC (rev 576) @@ -146,15 +146,18 @@ 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(); - } + if (specialOption.isValidValue(value)) { + 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(); + } + } else + System.out.println("Double: not valid value"); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-15 10:14:14 UTC (rev 575) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-02-15 12:44:08 UTC (rev 576) @@ -147,15 +147,18 @@ 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(); - } + if (specialOption.isValidValue(value)) { + 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(); + } + } else + System.out.println("Integer: not valid value"); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-15 10:14:14 UTC (rev 575) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-15 12:44:08 UTC (rev 576) @@ -123,7 +123,7 @@ value = (String) config.getComponentManager() .getConfigOptionValue(oldComponent, configOption.getName()); - if (value != null) { + if (value != null) { stringField.setText(value.toString()); setEntry(); } @@ -165,16 +165,19 @@ 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(); - } + if (specialOption.isValidValue(value)) { + 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(); + } + } else + System.out.println("String: not valid value"); } /* Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-15 10:14:14 UTC (rev 575) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-15 12:44:08 UTC (rev 576) @@ -295,18 +295,20 @@ StringSetConfigOption specialOption; specialOption = (StringSetConfigOption) config.getComponentManager() .getConfigOption(componentOption, configOption.getName()); + if (specialOption.isValidValue(value)) { + try { + ConfigEntry<Set<String>> specialEntry = new ConfigEntry<Set<String>>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set StringSet: " + configOption.getName() + + " = " + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + } else + System.out.println("StringSet: not valid value"); - try { - ConfigEntry<Set<String>> specialEntry = new ConfigEntry<Set<String>>( - specialOption, value); - config.getComponentManager().applyConfigEntry(component, - specialEntry); - System.out.println("set StringSet: " + configOption.getName() - + " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } - } /** Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-02-15 10:14:14 UTC (rev 575) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-02-15 12:44:08 UTC (rev 576) @@ -242,17 +242,19 @@ specialOption = (StringTupleListConfigOption) config .getComponentManager().getConfigOption(componentOption, configOption.getName()); - - try { - ConfigEntry<List<StringTuple>> specialEntry = new ConfigEntry<List<StringTuple>>( - specialOption, value); - config.getComponentManager().applyConfigEntry(component, - specialEntry); - System.out.println("set StringTupleList: " + configOption.getName() - + " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } + if (specialOption.isValidValue(value)) { + try { + ConfigEntry<List<StringTuple>> specialEntry = new ConfigEntry<List<StringTuple>>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set StringTupleList: " + + configOption.getName() + " = " + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + } else + System.out.println("StringTupleList: not valid value"); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-17 15:55:17
|
Revision: 591 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=591&view=rev Author: tonytacker Date: 2008-02-17 07:55:11 -0800 (Sun, 17 Feb 2008) Log Message: ----------- try-catch for init 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 Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-17 13:08:46 UTC (rev 590) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-17 15:55:11 UTC (rev 591) @@ -59,7 +59,7 @@ this.startGUI = startGUI; sources = config.getComponentManager().getKnowledgeSources(); - setButton = new JButton ("Set"); + setButton = new JButton("Set"); setButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); initButton.addActionListener(this); @@ -99,7 +99,7 @@ if (e.getSource() == setButton) setSource(); - + if (e.getSource() == initButton) init(); } @@ -119,14 +119,13 @@ public void init() { if (config.getKnowledgeSource() != null && config.getURI() != null) { try { - config.getKnowledgeSource().init(); - } catch (ComponentInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); - startGUI.updateTabColors(); + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } } } @@ -137,7 +136,7 @@ optionPanel.update(config.getKnowledgeSource(), config .getOldKnowledgeSource(), sources.get(choosenClassIndex)); } - + /** * make init-button red if you have to click */ Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-17 13:08:46 UTC (rev 590) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-17 15:55:11 UTC (rev 591) @@ -110,15 +110,14 @@ if (config.getLearningProblem() != null && config.getReasoningService() != null) { try { - config.setLearningAlgorithm(config.getComponentManager() - .learningAlgorithm(learners.get(choosenClassIndex), - config.getLearningProblem(), - config.getReasoningService())); - } catch (LearningProblemUnsupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - updateOptionPanel(); + config.setLearningAlgorithm(config.getComponentManager() + .learningAlgorithm(learners.get(choosenClassIndex), + config.getLearningProblem(), + config.getReasoningService())); + updateOptionPanel(); + } catch (LearningProblemUnsupportedException e) { + e.printStackTrace(); + } } } @@ -129,11 +128,11 @@ setLearningAlgorithm(); if (config.getLearningProblem() != null) { try { - config.getLearningAlgorithm().init(); - } catch (ComponentInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + config.getLearningAlgorithm().init(); + } catch (ComponentInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } config.setInitLearningAlgorithm(true); System.out.println("init LearningAlgorithm"); startGUI.updateTabColors(); Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-17 13:08:46 UTC (rev 590) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-17 15:55:11 UTC (rev 591) @@ -124,14 +124,13 @@ setLearningProblem(); if (config.getReasoner() != null && config.getLearningProblem() != null) { try { - config.getLearningProblem().init(); - } catch (ComponentInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - config.setInitLearningProblem(true); - System.out.println("init LearningProblem"); - startGUI.updateTabColors(); + config.getLearningProblem().init(); + config.setInitLearningProblem(true); + System.out.println("init LearningProblem"); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-17 13:08:46 UTC (rev 590) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-17 15:55:11 UTC (rev 591) @@ -129,18 +129,18 @@ setReasoner(); if (config.getKnowledgeSource() != null && config.getReasoner() != null) { try { - config.getReasoner().init(); - } catch (ComponentInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.out.println("init Reasoner"); - // set ReasoningService - config.setReasoningService(config.getComponentManager() - .reasoningService(config.getReasoner())); - System.out.println("init ReasoningService"); - config.setInitReasoner(true); - startGUI.updateTabColors(); + config.getReasoner().init(); + System.out.println("init Reasoner"); + // set ReasoningService + config.setReasoningService(config.getComponentManager() + .reasoningService(config.getReasoner())); + System.out.println("init ReasoningService"); + config.setInitReasoner(true); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-19 15:04:42
|
Revision: 612 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=612&view=rev Author: tonytacker Date: 2008-02-19 07:04:01 -0800 (Tue, 19 Feb 2008) Log Message: ----------- first try to load *.config 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 trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-19 15:04:01 UTC (rev 612) @@ -27,6 +27,8 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasonerComponent; +// import org.dllearner.core.Component; + /** * Config save all together used variables: ComponentManager, KnowledgeSource, * Reasoner, ReasoningService, LearningProblem, LearningAlgorithm; also inits of @@ -38,7 +40,6 @@ private ComponentManager cm = ComponentManager.getInstance(); private KnowledgeSource source; private KnowledgeSource oldSource; - private String uri; private ReasonerComponent reasoner; private ReasonerComponent oldReasoner; private ReasoningService rs; @@ -60,23 +61,18 @@ /** * It is necessary for init KnowledgeSource. * - * @return URI + * @return true, if url was set otherwise false */ - public String getURI() { - return this.uri; + public Boolean isSetURL() { + // return this.isURL; + // String value = (String) cm.getConfigOptionValue(source, "url"); + if (cm.getConfigOptionValue(source, "url") != null) + return true; + else + return false; } /** - * Set an URI. - * - * @param uri - * it's a Link like "http://example.com" or "file://myfile" - */ - public void setURI(String uri) { - this.uri = uri; - } - - /** * Set KnowledgeSource. * * @param knowledgeSource Added: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-19 15:04:01 UTC (rev 612) @@ -0,0 +1,161 @@ +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.io.File; // import java.net.URL; +// import java.util.List; +// import java.util.Map; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.KnowledgeSource; // import +// org.dllearner.core.LearningProblem; +// import org.dllearner.core.ReasoningService; +// import org.dllearner.core.LearningAlgorithm; +// import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.config.StringConfigOption; +import org.dllearner.parser.ConfParser; +import org.dllearner.kb.KBFile; +import org.dllearner.kb.OWLFile; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.core.Component; + +/** + * Open a config file. + * + * @author Tilo Hielscher + */ +public class ConfigLoad { + + private File file; + private Config config; + private StartGUI startGUI; + + private Class<? extends KnowledgeSource> componentOption; + + /** + * set config and startGUI + * + * @param config + * @param startGUI + */ + public ConfigLoad(Config config, StartGUI startGUI) { + this.config = config; + this.startGUI = startGUI; + } + + /** + * set your file to read + * + * @param file + * @return true if file exist + */ + public boolean openFile(File file) { + this.file = file; + return file.exists(); + } + + /** + * parse file + */ + public void startParser() { + if (this.file.exists()) { + ConfParser parser = ConfParser.parseFile(file); + // KNOWLEDGE SOURCE + // filename + String value = parser.getFunctionCalls().get("import").get(0) + .get(0); + // only first of imported files + if (value.endsWith(".kb")) { + componentOption = KBFile.class; + } else if (value.endsWith(".owl")) { + componentOption = OWLFile.class; + } else if (parser.getFunctionCalls().get("import").get(0).size() > 1) { + if (parser.getFunctionCalls().get("import").get(0).get(1) + .equalsIgnoreCase("sparql")) { + System.out.println("IT IS SPARQL"); + componentOption = SparqlKnowledgeSource.class; + } + } + // check if class was set + if (componentOption != null) + config.setKnowledgeSource(config.getComponentManager() + .knowledgeSource(componentOption)); + // set url + // value = parser.getFunctionCalls().get("import").get(0).get(0); + value = makeURL(value); + Component component = config.getKnowledgeSource(); + StringConfigOption specialOption = (StringConfigOption) config + .getComponentManager().getConfigOption(componentOption, + "url"); + try { + ConfigEntry<String> specialEntry = new ConfigEntry<String>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set String: " + "url" + " = " + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + // startGUI.updateTabColors(); + // init + if (config.getKnowledgeSource() != null && config.isSetURL()) { + try { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + + // update + startGUI.updateTabColors(); + + System.out.println("reasoner: " + + parser.getConfOptionsByName("reasoner")); + System.out.println("confoptions: " + parser.getConfOptions()); + System.out.println("posExamples: " + parser.getPositiveExamples()); + System.out.println("confoptionbyname: " + + parser.getConfOptionsByName()); + + // do it + // only url from first entry, ignore others + // parser.getFunctionCalls().get("import").get(0); + } + } + + /** + * If value is not a valid url and starts with "http://" or "file://" then + * add "file://" + * + * @param value + * is a string + * @return a valid url made from value + */ + public String makeURL(String value) { + if (!value.startsWith("http://") && !value.startsWith("file://")) + value = "file://".concat(file.getPath().replace(file.getName(), "") + .concat(value)); + return value; + } + +} Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-19 15:04:01 UTC (rev 612) @@ -29,9 +29,10 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.KnowledgeSource; +import org.dllearner.kb.*; /** - * KnowledgeSourcePanel, tab 1. Choose Source, change Options and final initiate + * KnowledgeSourcePanel, tab 0. Choose Source, change Options and final initiate * KnowledgeSource. * * @author Tilo Hielscher @@ -59,6 +60,8 @@ this.startGUI = startGUI; sources = config.getComponentManager().getKnowledgeSources(); + System.out.println("SOURCES: " + sources); + setButton = new JButton("Set"); setButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); @@ -74,6 +77,8 @@ choosePanel.add(cb); choosePanel.add(setButton); + choosenClassIndex = cb.getSelectedIndex(); + optionPanel = new OptionPanel(config, config.getKnowledgeSource(), config.getOldKnowledgeSource(), sources.get(choosenClassIndex)); initPanel.add(initButton); @@ -82,9 +87,8 @@ add(optionPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); - choosenClassIndex = cb.getSelectedIndex(); - setSource(); - updateInitButtonColor(); + // setSource(); + updateAll(); } public void actionPerformed(ActionEvent e) { @@ -92,13 +96,13 @@ // choosenClassIndex = cb.getSelectedIndex(); if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); - config.setURI(null); // default null config.setInitKnowledgeSource(false); setSource(); } - if (e.getSource() == setButton) + if (e.getSource() == setButton) { setSource(); + } if (e.getSource() == initButton) init(); @@ -108,16 +112,31 @@ * after this, you can change widgets */ public void setSource() { - config.setKnowledgeSource(config.getComponentManager().knowledgeSource( - sources.get(choosenClassIndex))); - updateOptionPanel(); + System.out.println("cm: " + config.getComponentManager()); + System.out.println("setSOURCE :" + sources.get(choosenClassIndex)); + + config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); +// KBFile.class doesn't work +// config.setKnowledgeSource(config.getComponentManager().knowledgeSource(KBFile.class)); + + + System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); + System.out + .println("ABC: " + + config.getComponentManager().getComponentName( + sources.get(0))); + + config.setInitKnowledgeSource(false); + updateAll(); } /** * after this, next tab can be used */ public void init() { - if (config.getKnowledgeSource() != null && config.getURI() != null) { + System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); + System.out.println("isSetURL: " + config.isSetURL()); + if (config.getKnowledgeSource() != null && config.isSetURL()) { try { config.getKnowledgeSource().init(); config.setInitKnowledgeSource(true); @@ -130,6 +149,29 @@ } /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } + + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getKnowledgeSource() != null) + for (int i = 0; i < sources.size(); i++) + if (config.getKnowledgeSource().getClass().equals( + config.getComponentManager().getKnowledgeSources().get( + i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + + /** * update OptionPanel with new selection */ public void updateOptionPanel() { @@ -146,4 +188,5 @@ } else initButton.setForeground(Color.BLACK); } + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-19 15:04:01 UTC (rev 612) @@ -32,7 +32,7 @@ import org.dllearner.core.LearningProblemUnsupportedException; /** - * LearningAlgorithmPanel, tab 4. Choose LearningAlgorithm, change Options and + * LearningAlgorithmPanel, tab 3. Choose LearningAlgorithm, change Options and * final initiate LearningAlgorithm. * * @author Tilo Hielscher Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-19 15:04:01 UTC (rev 612) @@ -31,7 +31,7 @@ import org.dllearner.core.LearningProblem; /** - * LearningProblemPanel tab 3. Choose LearingProblem, change Options and final + * LearningProblemPanel tab 2. Choose LearingProblem, change Options and final * initiate LearningProblem. * * @author Tilo Hielscher Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-19 15:04:01 UTC (rev 612) @@ -32,7 +32,7 @@ import org.dllearner.core.ReasonerComponent; /** - * ReasonerPanel, tab 2. Choose Resoner, change Options and final initiate + * ReasonerPanel, tab 1. Choose Resoner, change Options and final initiate * Reasoner and ReasoningService. * * @author Tilo Hielscher Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-19 15:04:01 UTC (rev 612) @@ -32,6 +32,9 @@ import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; +import java.io.File; +import javax.swing.filechooser.FileFilter; + /** * StartGUI * @@ -44,6 +47,7 @@ private JTabbedPane tabPane = new JTabbedPane(); private Config config = new Config(); + private ConfigLoad configLoad = new ConfigLoad(config, this);; private KnowledgeSourcePanel tab0; private ReasonerPanel tab1; @@ -61,10 +65,11 @@ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationByPlatform(true); this.setSize(800, 600); - + // set icon - setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("icon.gif"))); - + setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( + this.getClass().getResource("icon.gif"))); + tab0 = new KnowledgeSourcePanel(config, this); tab1 = new ReasonerPanel(config, this); tab2 = new LearningProblemPanel(config, this); @@ -110,14 +115,37 @@ } public void actionPerformed(ActionEvent e) { + // open config file if (e.getSource() == openItem) { - System.out.println("openItem was pressed"); + // file dialog + JFileChooser fc = new JFileChooser(new File("examples/")); + // FileFilter only *.conf + fc.addChoosableFileFilter(new FileFilter() { + public boolean accept(File f) { + if (f.isDirectory()) + return true; + return f.getName().toLowerCase().endsWith(".conf"); + } + + public String getDescription() { + return "*.conf"; // name for filter + } + }); + if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + System.out.println("FILE: " + fc.getSelectedFile()); + configLoad.openFile(fc.getSelectedFile()); + configLoad.startParser(); + } } + // save config file if (e.getSource() == saveItem) { System.out.println("saveItem was pressed"); } } + /** + * Update colors of tabulators; red should be clicked, black for OK. + */ public void updateTabColors() { if (config.isInitKnowledgeSource()) tabPane.setForegroundAt(0, Color.BLACK); @@ -138,7 +166,7 @@ tabPane.setForegroundAt(3, Color.RED); tabPane.setForegroundAt(4, Color.RED); } - tab0.updateInitButtonColor(); + tab0.updateAll(); tab1.updateInitButtonColor(); tab2.updateInitButtonColor(); tab3.updateInitButtonColor(); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-19 15:04:01 UTC (rev 612) @@ -84,8 +84,6 @@ if (returnVal == JFileChooser.APPROVE_OPTION) { value = fc.getSelectedFile().toString(); stringField.setText(value); - config.setURI(value); // save variable - System.out.println("value: " + config.getURI()); } } setEntry(); @@ -93,7 +91,6 @@ // necessary for init knowledge source if (configOption.getName().equalsIgnoreCase("url") && !value.equalsIgnoreCase("")) { - config.setURI(value); } } } @@ -180,7 +177,7 @@ System.out.println("String: not valid value"); } - /* + /** * Widget filename getName() == filename you should open a file dialog in * ActionPerformed */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-19 15:54:29
|
Revision: 613 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=613&view=rev Author: tonytacker Date: 2008-02-19 07:54:02 -0800 (Tue, 19 Feb 2008) Log Message: ----------- formated Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelAbstract.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-19 15:54:02 UTC (rev 613) @@ -34,83 +34,83 @@ * @author Tilo Hielscher */ public class CheckBoxList extends JPanel { - private static final long serialVersionUID = -7119007550662195455L; - private JPanel checkBoxPanel = new JPanel(); - private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); - private GridBagLayout gridbag = new GridBagLayout(); - private GridBagConstraints constraints = new GridBagConstraints(); + private static final long serialVersionUID = -7119007550662195455L; + private JPanel checkBoxPanel = new JPanel(); + private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); + private GridBagLayout gridbag = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); - /** - * Make a JPanel with GridBagLayout. - */ - public CheckBoxList() { - checkBoxPanel.setLayout(gridbag); - add(checkBoxPanel, BorderLayout.CENTER); - constraints.anchor = GridBagConstraints.WEST; - } + /** + * Make a JPanel with GridBagLayout. + */ + public CheckBoxList() { + checkBoxPanel.setLayout(gridbag); + add(checkBoxPanel, BorderLayout.CENTER); + constraints.anchor = GridBagConstraints.WEST; + } - /** - * Add new entry and make a new JCheckBox. - * - * @param label - * This text will be shown. It is the name of new JCheckBox - * and will add to list. - */ - public void add(String label) { - list.add(new JCheckBox(label)); - update(); - } + /** + * Add new entry and make a new JCheckBox. + * + * @param label + * This text will be shown. It is the name of new JCheckBox and + * will add to list. + */ + public void add(String label) { + list.add(new JCheckBox(label)); + update(); + } - /** - * Return a set of selected items. - */ - public Set<String> getSelections() { - Set<String> selectionSet = new HashSet<String>(); - selectionSet.clear(); // remove all - for (int i = 0; i < list.size(); i++) { - if (list.get(i).isSelected()) - selectionSet.add(list.get(i).getText()); + /** + * Return a set of selected items. + */ + public Set<String> getSelections() { + Set<String> selectionSet = new HashSet<String>(); + selectionSet.clear(); // remove all + for (int i = 0; i < list.size(); i++) { + if (list.get(i).isSelected()) + selectionSet.add(list.get(i).getText()); + } + return selectionSet; } - return selectionSet; - } - /** - * Select items. - * - * @param selectionSet - * Is a Set of Strings. - */ - public void setSelections(Set<String> selectionSet) { - for (int i = 0; i < this.list.size(); i++) { - if (selectionSet.contains(list.get(i).getText())) - list.get(i).setSelected(true); - else - this.list.get(i).setSelected(false); + /** + * Select items. + * + * @param selectionSet + * Is a Set of Strings. + */ + public void setSelections(Set<String> selectionSet) { + for (int i = 0; i < this.list.size(); i++) { + if (selectionSet.contains(list.get(i).getText())) + list.get(i).setSelected(true); + else + this.list.get(i).setSelected(false); + } } - } - /** - * update JCheckBox's - */ - private void update() { - checkBoxPanel.removeAll(); - for (int i = 0; i < list.size(); i++) { - buildConstraints(constraints, 0, i, 1, 1, 100, 100); - gridbag.setConstraints(list.get(i), constraints); - checkBoxPanel.add(list.get(i), constraints); + /** + * update JCheckBox's + */ + private void update() { + checkBoxPanel.removeAll(); + for (int i = 0; i < list.size(); i++) { + buildConstraints(constraints, 0, i, 1, 1, 100, 100); + gridbag.setConstraints(list.get(i), constraints); + checkBoxPanel.add(list.get(i), constraints); + } } - } - /** - * 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; - } + /** + * 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; + } } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-19 15:54:02 UTC (rev 613) @@ -37,242 +37,242 @@ * @author Tilo Hielscher */ public class Config { - private ComponentManager cm = ComponentManager.getInstance(); - private KnowledgeSource source; - private KnowledgeSource oldSource; - private ReasonerComponent reasoner; - private ReasonerComponent oldReasoner; - private ReasoningService rs; - private LearningProblem lp; - private LearningProblem oldLearningProblem; - private LearningAlgorithm la; - private LearningAlgorithm oldLearningAlgorithm; - private boolean[] isInit = new boolean[4]; + private ComponentManager cm = ComponentManager.getInstance(); + private KnowledgeSource source; + private KnowledgeSource oldSource; + private ReasonerComponent reasoner; + private ReasonerComponent oldReasoner; + private ReasoningService rs; + private LearningProblem lp; + private LearningProblem oldLearningProblem; + private LearningAlgorithm la; + private LearningAlgorithm oldLearningAlgorithm; + private boolean[] isInit = new boolean[4]; - /** - * Get ComponentManager. - * - * @return ComponentManager - */ - public ComponentManager getComponentManager() { - return this.cm; - } + /** + * Get ComponentManager. + * + * @return ComponentManager + */ + public ComponentManager getComponentManager() { + return this.cm; + } - /** - * It is necessary for init KnowledgeSource. - * - * @return true, if url was set otherwise false - */ - public Boolean isSetURL() { - // return this.isURL; - // String value = (String) cm.getConfigOptionValue(source, "url"); - if (cm.getConfigOptionValue(source, "url") != null) - return true; - else - return false; - } + /** + * It is necessary for init KnowledgeSource. + * + * @return true, if url was set otherwise false + */ + public Boolean isSetURL() { + // return this.isURL; + // String value = (String) cm.getConfigOptionValue(source, "url"); + if (cm.getConfigOptionValue(source, "url") != null) + return true; + else + return false; + } - /** - * Set KnowledgeSource. - * - * @param knowledgeSource - */ - public void setKnowledgeSource(KnowledgeSource knowledgeSource) { - this.oldSource = this.source; - this.source = knowledgeSource; - } + /** + * Set KnowledgeSource. + * + * @param knowledgeSource + */ + public void setKnowledgeSource(KnowledgeSource knowledgeSource) { + this.oldSource = this.source; + this.source = knowledgeSource; + } - /** - * Get KnowledgeSource. - * - * @return KnowledgeSource - */ - public KnowledgeSource getKnowledgeSource() { - return this.source; - } + /** + * Get KnowledgeSource. + * + * @return KnowledgeSource + */ + public KnowledgeSource getKnowledgeSource() { + return this.source; + } - /** - * Get old KnowledgeSource. - * - * @return old KnowledgeSource - */ - public KnowledgeSource getOldKnowledgeSource() { - return this.oldSource; - } + /** + * Get old KnowledgeSource. + * + * @return old KnowledgeSource + */ + public KnowledgeSource getOldKnowledgeSource() { + return this.oldSource; + } - /** - * Set Reasoner. - * - * @param reasoner - */ - public void setReasoner(ReasonerComponent reasoner) { - this.oldReasoner = this.reasoner; - this.reasoner = reasoner; - } + /** + * Set Reasoner. + * + * @param reasoner + */ + public void setReasoner(ReasonerComponent reasoner) { + this.oldReasoner = this.reasoner; + this.reasoner = reasoner; + } - /** - * Get Reasoner. - * - * @return reasoner - */ - public ReasonerComponent getReasoner() { - return this.reasoner; - } + /** + * Get Reasoner. + * + * @return reasoner + */ + public ReasonerComponent getReasoner() { + return this.reasoner; + } - /** - * Get old Reasoner as a set. - * - * @return oldReasonerSet. - */ - public ReasonerComponent getOldReasonerSet() { - return this.oldReasoner; - } + /** + * Get old Reasoner as a set. + * + * @return oldReasonerSet. + */ + public ReasonerComponent getOldReasonerSet() { + return this.oldReasoner; + } - /** - * Set ReasoningService. - * - * @param reasoningService - */ - public void setReasoningService(ReasoningService reasoningService) { - this.rs = reasoningService; - } + /** + * Set ReasoningService. + * + * @param reasoningService + */ + public void setReasoningService(ReasoningService reasoningService) { + this.rs = reasoningService; + } - /** - * Get ReasoningService. - * - * @return ReasoningService - */ - public ReasoningService getReasoningService() { - return this.rs; - } + /** + * Get ReasoningService. + * + * @return ReasoningService + */ + public ReasoningService getReasoningService() { + return this.rs; + } - /** - * Set LearningProblem. - * - * @param learningProblem - */ - public void setLearningProblem(LearningProblem learningProblem) { - this.oldLearningProblem = this.lp; - this.lp = learningProblem; - } + /** + * Set LearningProblem. + * + * @param learningProblem + */ + public void setLearningProblem(LearningProblem learningProblem) { + this.oldLearningProblem = this.lp; + this.lp = learningProblem; + } - /** - * Get LearningProblem. - * - * @return learningProblem - */ - public LearningProblem getLearningProblem() { - return this.lp; - } + /** + * Get LearningProblem. + * + * @return learningProblem + */ + public LearningProblem getLearningProblem() { + return this.lp; + } - /** - * Get old LearningProblem as a set. - * - * @return old learningProblemSet. - */ - public LearningProblem getOldLearningProblem() { - return this.oldLearningProblem; - } + /** + * Get old LearningProblem as a set. + * + * @return old learningProblemSet. + */ + public LearningProblem getOldLearningProblem() { + return this.oldLearningProblem; + } - /** - * Set LearningAlgorithm. - * - * @param learningAlgorithm - */ - public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { - this.oldLearningAlgorithm = this.la; - this.la = learningAlgorithm; - } + /** + * Set LearningAlgorithm. + * + * @param learningAlgorithm + */ + public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { + this.oldLearningAlgorithm = this.la; + this.la = learningAlgorithm; + } - /** - * Get LearningAlgorithm. - * - * @return LearningAlgorithm - */ - public LearningAlgorithm getLearningAlgorithm() { - return this.la; - } + /** + * Get LearningAlgorithm. + * + * @return LearningAlgorithm + */ + public LearningAlgorithm getLearningAlgorithm() { + return this.la; + } - /** - * Get old LearningAlgorithmSet. - * - * @return old LearningAlgorithmSet - */ - public LearningAlgorithm getOldLearningAlgorithm() { - return this.oldLearningAlgorithm; - } + /** + * Get old LearningAlgorithmSet. + * + * @return old LearningAlgorithmSet + */ + public LearningAlgorithm getOldLearningAlgorithm() { + return this.oldLearningAlgorithm; + } - /** - * KnowledgeSource.init has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitKnowledgeSource() { - return isInit[0]; - } + /** + * KnowledgeSource.init has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitKnowledgeSource() { + return isInit[0]; + } - /** - * Set true if you run KnowwledgeSource.init. The inits from other tabs - * behind will automatic set to false. - */ - public void setInitKnowledgeSource(Boolean is) { - isInit[0] = is; - for (int i = 1; i < 4; i++) - isInit[i] = false; - } + /** + * Set true if you run KnowwledgeSource.init. The inits from other tabs + * behind will automatic set to false. + */ + public void setInitKnowledgeSource(Boolean is) { + isInit[0] = is; + for (int i = 1; i < 4; i++) + isInit[i] = false; + } - /** - * Reasoner.init has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitReasoner() { - return isInit[1]; - } + /** + * Reasoner.init has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitReasoner() { + return isInit[1]; + } - /** - * Set true if you run Reasoner.init. The inits from other tabs behind will - * automatic set to false. - */ - public void setInitReasoner(Boolean is) { - isInit[1] = is; - for (int i = 2; i < 4; i++) - isInit[i] = false; - } + /** + * Set true if you run Reasoner.init. The inits from other tabs behind will + * automatic set to false. + */ + public void setInitReasoner(Boolean is) { + isInit[1] = is; + for (int i = 2; i < 4; i++) + isInit[i] = false; + } - /** - * LearningProblem.init has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitLearningProblem() { - return isInit[2]; - } + /** + * LearningProblem.init has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitLearningProblem() { + return isInit[2]; + } - /** - * Set true if you run LearningProblem.init. The inits from other tabs - * behind will automatic set to false. - */ - public void setInitLearningProblem(Boolean is) { - isInit[2] = is; - for (int i = 3; i < 4; i++) - isInit[i] = false; - } + /** + * Set true if you run LearningProblem.init. The inits from other tabs + * behind will automatic set to false. + */ + public void setInitLearningProblem(Boolean is) { + isInit[2] = is; + for (int i = 3; i < 4; i++) + isInit[i] = false; + } - /** - * LearningAlgorithm.init() has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitLearningAlgorithm() { - return isInit[3]; - } + /** + * LearningAlgorithm.init() has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitLearningAlgorithm() { + return isInit[3]; + } - /** - * set true if you run LearningAlgorithm.init - */ - public void setInitLearningAlgorithm(Boolean is) { - isInit[3] = is; - } + /** + * set true if you run LearningAlgorithm.init + */ + public void setInitLearningAlgorithm(Boolean is) { + isInit[3] = is; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-19 15:54:02 UTC (rev 613) @@ -45,117 +45,110 @@ */ public class ConfigLoad { - private File file; - private Config config; - private StartGUI startGUI; + private File file; + private Config config; + private StartGUI startGUI; - private Class<? extends KnowledgeSource> componentOption; + private Class<? extends KnowledgeSource> componentOption; - /** - * set config and startGUI - * - * @param config - * @param startGUI - */ - public ConfigLoad(Config config, StartGUI startGUI) { - this.config = config; - this.startGUI = startGUI; - } + /** + * set config and startGUI + * + * @param config + * @param startGUI + */ + public ConfigLoad(Config config, StartGUI startGUI) { + this.config = config; + this.startGUI = startGUI; + } - /** - * set your file to read - * - * @param file - * @return true if file exist - */ - public boolean openFile(File file) { - this.file = file; - return file.exists(); - } + /** + * set your file to read + * + * @param file + * @return true if file exist + */ + public boolean openFile(File file) { + this.file = file; + return file.exists(); + } - /** - * parse file - */ - public void startParser() { - if (this.file.exists()) { - ConfParser parser = ConfParser.parseFile(file); - // KNOWLEDGE SOURCE - // filename - String value = parser.getFunctionCalls().get("import").get(0) - .get(0); - // only first of imported files - if (value.endsWith(".kb")) { - componentOption = KBFile.class; - } else if (value.endsWith(".owl")) { - componentOption = OWLFile.class; - } else if (parser.getFunctionCalls().get("import").get(0).size() > 1) { - if (parser.getFunctionCalls().get("import").get(0).get(1) - .equalsIgnoreCase("sparql")) { - System.out.println("IT IS SPARQL"); - componentOption = SparqlKnowledgeSource.class; - } - } - // check if class was set - if (componentOption != null) - config.setKnowledgeSource(config.getComponentManager() - .knowledgeSource(componentOption)); - // set url - // value = parser.getFunctionCalls().get("import").get(0).get(0); - value = makeURL(value); - Component component = config.getKnowledgeSource(); - StringConfigOption specialOption = (StringConfigOption) config - .getComponentManager().getConfigOption(componentOption, - "url"); - try { - ConfigEntry<String> specialEntry = new ConfigEntry<String>( - specialOption, value); - config.getComponentManager().applyConfigEntry(component, - specialEntry); - System.out.println("set String: " + "url" + " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } - // startGUI.updateTabColors(); - // init - if (config.getKnowledgeSource() != null && config.isSetURL()) { - try { - config.getKnowledgeSource().init(); - config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); - } catch (ComponentInitException e) { - e.printStackTrace(); - } - } + /** + * parse file + */ + public void startParser() { + if (this.file.exists()) { + ConfParser parser = ConfParser.parseFile(file); + // KNOWLEDGE SOURCE + // filename + String value = parser.getFunctionCalls().get("import").get(0).get(0); + // only first of imported files + if (value.endsWith(".kb")) { + componentOption = KBFile.class; + } else if (value.endsWith(".owl")) { + componentOption = OWLFile.class; + } else if (parser.getFunctionCalls().get("import").get(0).size() > 1) { + if (parser.getFunctionCalls().get("import").get(0).get(1) + .equalsIgnoreCase("sparql")) { + System.out.println("IT IS SPARQL"); + componentOption = SparqlKnowledgeSource.class; + } + } + // check if class was set + if (componentOption != null) + config.setKnowledgeSource(config.getComponentManager().knowledgeSource( + componentOption)); + // set url + // value = parser.getFunctionCalls().get("import").get(0).get(0); + value = makeURL(value); + Component component = config.getKnowledgeSource(); + StringConfigOption specialOption = (StringConfigOption) config.getComponentManager() + .getConfigOption(componentOption, "url"); + try { + ConfigEntry<String> specialEntry = new ConfigEntry<String>(specialOption, value); + config.getComponentManager().applyConfigEntry(component, specialEntry); + System.out.println("set String: " + "url" + " = " + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + // startGUI.updateTabColors(); + // init + if (config.getKnowledgeSource() != null && config.isSetURL()) { + try { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } - // update - startGUI.updateTabColors(); + // update + startGUI.updateTabColors(); - System.out.println("reasoner: " - + parser.getConfOptionsByName("reasoner")); - System.out.println("confoptions: " + parser.getConfOptions()); - System.out.println("posExamples: " + parser.getPositiveExamples()); - System.out.println("confoptionbyname: " - + parser.getConfOptionsByName()); + System.out.println("reasoner: " + parser.getConfOptionsByName("reasoner")); + System.out.println("confoptions: " + parser.getConfOptions()); + System.out.println("posExamples: " + parser.getPositiveExamples()); + System.out.println("confoptionbyname: " + parser.getConfOptionsByName()); - // do it - // only url from first entry, ignore others - // parser.getFunctionCalls().get("import").get(0); + // do it + // only url from first entry, ignore others + // parser.getFunctionCalls().get("import").get(0); + } } - } - /** - * If value is not a valid url and starts with "http://" or "file://" then - * add "file://" - * - * @param value - * is a string - * @return a valid url made from value - */ - public String makeURL(String value) { - if (!value.startsWith("http://") && !value.startsWith("file://")) - value = "file://".concat(file.getPath().replace(file.getName(), "") - .concat(value)); - return value; - } + /** + * If value is not a valid url and starts with "http://" or "file://" then + * add "file://" + * + * @param value + * is a string + * @return a valid url made from value + */ + public String makeURL(String value) { + if (!value.startsWith("http://") && !value.startsWith("file://")) + value = "file://".concat(file.getPath().replace(file.getName(), "").concat(value)); + return value; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -29,8 +29,9 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.KnowledgeSource; -import org.dllearner.kb.*; +// import org.dllearner.kb.*; + /** * KnowledgeSourcePanel, tab 0. Choose Source, change Options and final initiate * KnowledgeSource. @@ -39,154 +40,149 @@ */ public class KnowledgeSourcePanel extends JPanel implements ActionListener { - private static final long serialVersionUID = -7678275020058043937L; + private static final long serialVersionUID = -7678275020058043937L; - private Config config; - private StartGUI startGUI; - private JButton initButton; - private JButton setButton; - private String[] kbBoxItems = {}; - private JComboBox cb = new JComboBox(kbBoxItems); - private JPanel choosePanel = new JPanel(); - private JPanel initPanel = new JPanel(); - private int choosenClassIndex; - private List<Class<? extends KnowledgeSource>> sources; - private OptionPanel optionPanel; + private Config config; + private StartGUI startGUI; + private JButton initButton; + private JButton setButton; + private String[] kbBoxItems = {}; + private JComboBox cb = new JComboBox(kbBoxItems); + private JPanel choosePanel = new JPanel(); + private JPanel initPanel = new JPanel(); + private int choosenClassIndex; + private List<Class<? extends KnowledgeSource>> sources; + private OptionPanel optionPanel; - KnowledgeSourcePanel(final Config config, StartGUI startGUI) { - super(new BorderLayout()); + KnowledgeSourcePanel(final Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - sources = config.getComponentManager().getKnowledgeSources(); + this.config = config; + this.startGUI = startGUI; + sources = config.getComponentManager().getKnowledgeSources(); - System.out.println("SOURCES: " + sources); + System.out.println("SOURCES: " + sources); - setButton = new JButton("Set"); - setButton.addActionListener(this); - initButton = new JButton("Init KnowledgeSource"); - initButton.addActionListener(this); - initButton.setEnabled(true); + setButton = new JButton("Set"); + setButton.addActionListener(this); + initButton = new JButton("Init KnowledgeSource"); + initButton.addActionListener(this); + initButton.setEnabled(true); - // add to comboBox - for (int i = 0; i < sources.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - sources.get(i))); - } - cb.addActionListener(this); + // add to comboBox + for (int i = 0; i < sources.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(sources.get(i))); + } + cb.addActionListener(this); - choosePanel.add(cb); - choosePanel.add(setButton); - choosenClassIndex = cb.getSelectedIndex(); + choosePanel.add(cb); + choosePanel.add(setButton); + choosenClassIndex = cb.getSelectedIndex(); - optionPanel = new OptionPanel(config, config.getKnowledgeSource(), - config.getOldKnowledgeSource(), sources.get(choosenClassIndex)); - initPanel.add(initButton); + optionPanel = new OptionPanel(config, config.getKnowledgeSource(), config + .getOldKnowledgeSource(), sources.get(choosenClassIndex)); + initPanel.add(initButton); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - // setSource(); - updateAll(); - } - - public void actionPerformed(ActionEvent e) { - // read selected KnowledgeSourceClass - // choosenClassIndex = cb.getSelectedIndex(); - if (choosenClassIndex != cb.getSelectedIndex()) { - choosenClassIndex = cb.getSelectedIndex(); - config.setInitKnowledgeSource(false); - setSource(); + // setSource(); + updateAll(); } - if (e.getSource() == setButton) { - setSource(); + public void actionPerformed(ActionEvent e) { + // read selected KnowledgeSourceClass + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitKnowledgeSource(false); + setSource(); + } + + if (e.getSource() == setButton) { + setSource(); + } + + if (e.getSource() == initButton) + init(); } - if (e.getSource() == initButton) - init(); - } + /** + * after this, you can change widgets + */ + public void setSource() { + System.out.println("cm: " + config.getComponentManager()); + System.out.println("setSOURCE :" + sources.get(choosenClassIndex)); - /** - * after this, you can change widgets - */ - public void setSource() { - System.out.println("cm: " + config.getComponentManager()); - System.out.println("setSOURCE :" + sources.get(choosenClassIndex)); - - config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); -// KBFile.class doesn't work -// config.setKnowledgeSource(config.getComponentManager().knowledgeSource(KBFile.class)); - - - System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); - System.out - .println("ABC: " - + config.getComponentManager().getComponentName( - sources.get(0))); + config.setKnowledgeSource(config.getComponentManager().knowledgeSource( + sources.get(choosenClassIndex))); + // KBFile.class doesn't work + // config.setKnowledgeSource(config.getComponentManager().knowledgeSource(KBFile.class)); - config.setInitKnowledgeSource(false); - updateAll(); - } + System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); + System.out.println("ABC: " + config.getComponentManager().getComponentName(sources.get(0))); - /** - * after this, next tab can be used - */ - public void init() { - System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); - System.out.println("isSetURL: " + config.isSetURL()); - if (config.getKnowledgeSource() != null && config.isSetURL()) { - try { - config.getKnowledgeSource().init(); - config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); - startGUI.updateTabColors(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } + config.setInitKnowledgeSource(false); + updateAll(); } - } - /** - * updateAll - */ - public void updateAll() { - updateComboBox(); - updateOptionPanel(); - updateInitButtonColor(); - } - - /** - * set ComboBox to selected class - */ - public void updateComboBox() { - if (config.getKnowledgeSource() != null) - for (int i = 0; i < sources.size(); i++) - if (config.getKnowledgeSource().getClass().equals( - config.getComponentManager().getKnowledgeSources().get( - i))) { - cb.setSelectedIndex(i); + /** + * after this, next tab can be used + */ + public void init() { + System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); + System.out.println("isSetURL: " + config.isSetURL()); + if (config.getKnowledgeSource() != null && config.isSetURL()) { + try { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } } - this.choosenClassIndex = cb.getSelectedIndex(); - } + } - /** - * update OptionPanel with new selection - */ - public void updateOptionPanel() { - optionPanel.update(config.getKnowledgeSource(), config - .getOldKnowledgeSource(), sources.get(choosenClassIndex)); - } + /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } - /** - * make init-button red if you have to click - */ - public void updateInitButtonColor() { - if (!config.isInitKnowledgeSource()) { - initButton.setForeground(Color.RED); - } else - initButton.setForeground(Color.BLACK); - } + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getKnowledgeSource() != null) + for (int i = 0; i < sources.size(); i++) + if (config.getKnowledgeSource().getClass().equals( + config.getComponentManager().getKnowledgeSources().get(i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + /** + * update OptionPanel with new selection + */ + public void updateOptionPanel() { + optionPanel.update(config.getKnowledgeSource(), config.getOldKnowledgeSource(), sources + .get(choosenClassIndex)); + } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitKnowledgeSource()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -39,122 +39,118 @@ */ public class LearningAlgorithmPanel extends JPanel implements ActionListener { - private static final long serialVersionUID = 8721490771860452959L; + private static final long serialVersionUID = 8721490771860452959L; - private Config config; - private StartGUI startGUI; - private List<Class<? extends LearningAlgorithm>> learners; - private JPanel choosePanel = new JPanel(); - private OptionPanel optionPanel; - private JPanel initPanel = new JPanel(); - private JButton initButton, autoInitButton; - private String[] cbItems = {}; - private JComboBox cb = new JComboBox(cbItems); - private int choosenClassIndex; + private Config config; + private StartGUI startGUI; + private List<Class<? extends LearningAlgorithm>> learners; + private JPanel choosePanel = new JPanel(); + private OptionPanel optionPanel; + private JPanel initPanel = new JPanel(); + private JButton initButton, autoInitButton; + private String[] cbItems = {}; + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; - LearningAlgorithmPanel(Config config, StartGUI startGUI) { - super(new BorderLayout()); + LearningAlgorithmPanel(Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - learners = config.getComponentManager().getLearningAlgorithms(); + this.config = config; + this.startGUI = startGUI; + learners = config.getComponentManager().getLearningAlgorithms(); - initButton = new JButton("Init LearingAlgorithm"); - initButton.addActionListener(this); - initPanel.add(initButton); - initButton.setEnabled(true); - autoInitButton = new JButton("Set"); - autoInitButton.addActionListener(this); + initButton = new JButton("Init LearingAlgorithm"); + initButton.addActionListener(this); + initPanel.add(initButton); + initButton.setEnabled(true); + autoInitButton = new JButton("Set"); + autoInitButton.addActionListener(this); - // add into comboBox - for (int i = 0; i < learners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - learners.get(i))); - } + // add into comboBox + for (int i = 0; i < learners.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(learners.get(i))); + } - choosePanel.add(cb); - choosePanel.add(autoInitButton); - cb.addActionListener(this); + choosePanel.add(cb); + choosePanel.add(autoInitButton); + cb.addActionListener(this); - optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), - config.getOldLearningAlgorithm(), learners - .get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), config + .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - updateInitButtonColor(); - } - - public void actionPerformed(ActionEvent e) { - // read selected Class - // choosenClassIndex = cb.getSelectedIndex(); - if (choosenClassIndex != cb.getSelectedIndex()) { - choosenClassIndex = cb.getSelectedIndex(); - config.setInitLearningAlgorithm(false); - setLearningAlgorithm(); + updateInitButtonColor(); } - if (e.getSource() == autoInitButton) - setLearningAlgorithm(); + public void actionPerformed(ActionEvent e) { + // read selected Class + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitLearningAlgorithm(false); + setLearningAlgorithm(); + } - if (e.getSource() == initButton) - init(); - } + if (e.getSource() == autoInitButton) + setLearningAlgorithm(); - /** - * after this, you can change widgets - */ - public void setLearningAlgorithm() { - if (config.getLearningProblem() != null - && config.getReasoningService() != null) { - try { - config.setLearningAlgorithm(config.getComponentManager() - .learningAlgorithm(learners.get(choosenClassIndex), - config.getLearningProblem(), - config.getReasoningService())); - updateOptionPanel(); - } catch (LearningProblemUnsupportedException e) { - e.printStackTrace(); - } + if (e.getSource() == initButton) + init(); } - } - /** - * after this, next tab can be used - */ - public void init() { - setLearningAlgorithm(); - if (config.getLearningProblem() != null) { - try { - config.getLearningAlgorithm().init(); - } catch (ComponentInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - config.setInitLearningAlgorithm(true); - System.out.println("init LearningAlgorithm"); - startGUI.updateTabColors(); + /** + * after this, you can change widgets + */ + public void setLearningAlgorithm() { + if (config.getLearningProblem() != null && config.getReasoningService() != null) { + try { + config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm( + learners.get(choosenClassIndex), config.getLearningProblem(), + config.getReasoningService())); + updateOptionPanel(); + } catch (LearningProblemUnsupportedException e) { + e.printStackTrace(); + } + } } - } - /** - * update OptionPanel with new selection - */ - public void updateOptionPanel() { - // update OptionPanel - optionPanel.update(config.getLearningAlgorithm(), config - .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); - } + /** + * after this, next tab can be used + */ + public void init() { + setLearningAlgorithm(); + if (config.getLearningProblem() != null) { + try { + config.getLearningAlgorithm().init(); + } catch (ComponentInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + config.setInitLearningAlgorithm(true); + System.out.println("init LearningAlgorithm"); + startGUI.updateTabColors(); + } + } - /** - * make init-button red if you have to click - */ - public void updateInitButtonColor() { - if (!config.isInitLearningAlgorithm()) { - initButton.setForeground(Color.RED); - } else - initButton.setForeground(Color.BLACK); - } + /** + * update OptionPanel with new selection + */ + public void updateOptionPanel() { + // update OptionPanel + optionPanel.update(config.getLearningAlgorithm(), config.getOldLearningAlgorithm(), + learners.get(choosenClassIndex)); + } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitLearningAlgorithm()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -38,118 +38,116 @@ */ public class LearningProblemPanel extends JPanel implements ActionListener { - private static final long serialVersionUID = -3819627680918930203L; + private static final long serialVersionUID = -3819627680918930203L; - private Config config; - private StartGUI startGUI; - private List<Class<? extends LearningProblem>> problems; - private String[] lpBoxItems = {}; - private JComboBox cb = new JComboBox(lpBoxItems); - private JPanel choosePanel = new JPanel(); - private OptionPanel optionPanel; - private JPanel initPanel = new JPanel(); - private JButton initButton, setButton; - private int choosenClassIndex; + private Config config; + private StartGUI startGUI; + private List<Class<? extends LearningProblem>> problems; + private String[] lpBoxItems = {}; + private JComboBox cb = new JComboBox(lpBoxItems); + private JPanel choosePanel = new JPanel(); + private OptionPanel optionPanel; + private JPanel initPanel = new JPanel(); + private JButton initButton, setButton; + private int choosenClassIndex; - LearningProblemPanel(final Config config, StartGUI startGUI) { - super(new BorderLayout()); + LearningProblemPanel(final Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - problems = config.getComponentManager().getLearningProblems(); + this.config = config; + this.startGUI = startGUI; + problems = config.getComponentManager().getLearningProblems(); - initButton = new JButton("Init LearningProblem"); - initButton.addActionListener(this); - initPanel.add(initButton); - initButton.setEnabled(true); - setButton = new JButton("Set"); - setButton.addActionListener(this); - choosePanel.add(cb); - choosePanel.add(setButton); - cb.addActionListener(this); + initButton = new JButton("Init LearningProblem"); + initButton.addActionListener(this); + initPanel.add(initButton); + initButton.setEnabled(true); + setButton = new JButton("Set"); + setButton.addActionListener(this); + choosePanel.add(cb); + choosePanel.add(setButton); + cb.addActionListener(this); - // add into comboBox - for (int i = 0; i < problems.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - problems.get(i))); - } + // add into comboBox + for (int i = 0; i < problems.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(problems.get(i))); + } - // read choosen LearningProblem - choosenClassIndex = cb.getSelectedIndex(); + // read choosen LearningProblem + choosenClassIndex = cb.getSelectedIndex(); - optionPanel = new OptionPanel(config, config.getLearningProblem(), - config.getOldLearningProblem(), problems.get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getLearningProblem(), config + .getOldLearningProblem(), problems.get(choosenClassIndex)); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - choosenClassIndex = cb.getSelectedIndex(); - // setLearningProblem(); - updateInitButtonColor(); - } - - public void actionPerformed(ActionEvent e) { - // read selected LearningProblemClass - if (choosenClassIndex != cb.getSelectedIndex()) { - this.choosenClassIndex = cb.getSelectedIndex(); - config.setInitLearningProblem(false); - setLearningProblem(); + choosenClassIndex = cb.getSelectedIndex(); + // setLearningProblem(); + updateInitButtonColor(); } - if (e.getSource() == setButton) - setLearningProblem(); + public void actionPerformed(ActionEvent e) { + // read selected LearningProblemClass + if (choosenClassIndex != cb.getSelectedIndex()) { + this.choosenClassIndex = cb.getSelectedIndex(); + config.setInitLearningProblem(false); + setLearningProblem(); + } - if (e.getSource() == initButton) - init(); - } + if (e.getSource() == setButton) + setLearningProblem(); - /** - * after this, you can change widgets - */ - private void setLearningProblem() { - if (config.isInitReasoner()) { - config.setLearningProblem(config.getComponentManager() - .learningProblem(problems.get(choosenClassIndex), - config.getReasoningService())); - startGUI.updateTabColors(); - updateOptionPanel(); + if (e.getSource() == initButton) + init(); } - } - /** - * after this, next tab can be used - */ - private void init() { - setLearningProblem(); - if (config.getReasoner() != null && config.getLearningProblem() != null) { - try { - config.getLearningProblem().init(); - config.setInitLearningProblem(true); - System.out.println("init LearningProblem"); - startGUI.updateTabColors(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } + /** + * after this, you can change widgets + */ + private void setLearningProblem() { + if (config.isInitReasoner()) { + config.setLearningProblem(config.getComponentManager().learningProblem( + problems.get(choosenClassIndex), config.getReasoningService())); + startGUI.updateTabColors(); + updateOptionPanel(); + } } - } - /** - * update OptionPanel with new selection - */ - private void updateOptionPanel() { - // update OptionPanel - optionPanel.update(config.getLearningProblem(), config - .getOldLearningProblem(), problems.get(choosenClassIndex)); - } + /** + * after this, next tab can be used + */ + private void init() { + setLearningProblem(); + if (config.getReasoner() != null && config.getLearningProblem() != null) { + try { + config.getLearningProblem().init(); + config.setInitLearningProblem(true); + System.out.println("init LearningProblem"); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + } - /** - * make init-button red if you have to click - */ - public void updateInitButtonColor() { - if (!config.isInitLearningProblem()) { - initButton.setForeground(Color.RED); - } else - initButton.setForeground(Color.BLACK); - } + /** + * update OptionPanel with new selection + */ + private void updateOptionPanel() { + // update OptionPanel + optionPanel.update(config.getLearningProblem(), config.getOldLearningProblem(), problems + .get(choosenClassIndex)); + } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitLearningProblem()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -43,105 +43,100 @@ */ 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 Component oldComponent; - 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 Component oldComponent; + private GridBagLayout gridBagLayout = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); - public OptionPanel(Config config, Component component, - Component oldComponent, Class<? extends Component> componentOption) { - super(new BorderLayout()); + public OptionPanel(Config config, Component component, Component oldComponent, + Class<? extends Component> componentOption) { + super(new BorderLayout()); - this.config = config; - this.component = component; - this.oldComponent = oldComponent; - this.componentOption = componentOption; + this.config = config; + this.component = component; + this.oldComponent = oldComponent; + this.componentOption = componentOption; - optionList = ComponentManager.getConfigOptions(componentOption); + optionList = ComponentManager.getConfigOptions(componentOption); - // define GridBagLayout - centerPanel.setLayout(gridBagLayout); - constraints.anchor = GridBagConstraints.NORTHWEST; + // 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); - // show widgets - showWidgets(); - } + // add scrollPane + JScrollPane centerScroller = new JScrollPane(centerPanel); + centerScroller.setPreferredSize(new Dimension(400, 200)); + // add Panels + add(centerScroller, BorderLayout.CENTER); + // show widgets + showWidgets(); + } - /** update this OptionPanel */ - public void update(Component component, Component oldComponent, - Class<? extends Component> componentOption) { - this.component = component; - this.oldComponent = oldComponent; - this.componentOption = componentOption; - showWidgets(); + /** update this OptionPanel */ + public void update(Component component, Component oldComponent, + Class<? extends Component> componentOption) { + this.component = component; + this.oldComponent = oldComponent; + 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); - 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, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "BooleanConfigOption")) { - widgetPanel = new WidgetPanelBoolean(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "DoubleConfigOption")) { - widgetPanel = new WidgetPanelDouble(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "StringConfigOption")) { - widgetPanel = new WidgetPanelString(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "StringSetConfigOption")) { - widgetPanel = new WidgetPanelStringSet(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "StringTupleListConfigOption")) { - widgetPanel = new WidgetPanelStringTupleList(config, component, - oldComponent, componentOption, optionList.get(i)); - } else { - widgetPanel = new WidgetPanelDefault(config, component, - /* oldComponent, */componentOption, optionList.get(i)); - } - gridBagLayout.setConstraints(widgetPanel, constraints); - centerPanel.add(widgetPanel); + /** + * 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); + 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, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("BooleanConfigOption")) { + widgetPanel = new WidgetPanelBoolean(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("DoubleConfigOption")) { + widgetPanel = new WidgetPanelDouble(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("StringConfigOption")) { + widgetPanel = new WidgetPanelString(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("StringSetConfigOption")) { + widgetPanel = new WidgetPanelStringSet(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains( + "StringTupleListConfigOption")) { + widgetPanel = new WidgetPanelStringTupleList(config, component, oldComponent, + componentOption, optionList.get(i)); + } else { + widgetPanel = new WidgetPanelDefault(config, component, + /* oldComponent, */componentOption, optionList.get(i)); + } + gridBagLayout.setConstraints(widgetPanel, constraints); + centerPanel.add(widgetPanel); + } + centerPanel.updateUI(); // update graphic } - 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; - } + /** + * 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-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -39,126 +39,124 @@ */ public class ReasonerPanel extends JPanel implements ActionListener { - private static final long serialVersionUID = -7678275020058043937L; + private static final long serialVersionUID = -7678275020058043937L; - private Config config; - private StartGUI startGUI; - private List<Class<? extends ReasonerComponent>> reasoners; - private JPanel choosePanel = new JPanel(); - private JPanel initPanel = new JPanel(); - private OptionPanel optionPanel; - private JButton initButton, setButton; - private String[] cbItems = {}; - private JComboBox cb = new JComboBox(cbItems); - private int choosenClassIndex; + private Config config; + private StartGUI startGUI; + private List<Class<? extends ReasonerComponent>> reasoners; + private JPanel choosePanel = new JPanel(); + private JPanel initPanel = new JPanel(); + private OptionPanel optionPanel; + private JButton initButton, setButton; + private String[] cbItems = {}; + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; - ReasonerPanel(final Config config, StartGUI startGUI) { - super(new BorderLayout()); + ReasonerPanel(final Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - reasoners = config.getComponentManager().getReasonerComponents(); + this.config = config; + this.startGUI = startGUI; + reasoners = config.getComponentManager().getReasonerComponents(); - initButton = new JButton("Init Reasoner"); - initButton.addActionListener(this); - initPanel.add(initButton); - initButton.setEnabled(true); - setButton = new JButton("Set"); - setButton.addActionListener(this); + initButton = new JButton("Init Reasoner"); + initButton.addActionListener(this); + initPanel.add(initButton); + initButton.setEnabled(true); + setButton = new JButton("Set"); + setButton.addActionListener(this); - choosePanel.add(cb); + choosePanel.add(cb); - // add into comboBox - for (int i = 0; i < reasoners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - reasoners.get(i))); - } + // add into comboBox + for (int i = 0; i < reasoners.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(reasoners.get(i))); + } - optionPanel = new OptionPanel(config, config.getReasoner(), config - .getOldReasonerSet(), reasoners.get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getReasoner(), config.getOldReasonerSet(), + reasoners.get(choosenClassIndex)); - choosePanel.add(setButton); - cb.addActionListener(this); + choosePanel.add(setButton); + cb.addActionListener(this); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - choosenClassIndex = cb.getSelectedIndex(); - setReasoner(); - updateInitButtonColor(); - } + choosenClassIndex = cb.getSelectedIndex(); + setReasoner(); + updateInitButtonColor(); + } - public void actionPerformed(ActionEvent e) { - // read selected Class - // choosenClassIndex = cb.getSelectedIndex(); - if (choosenClassIndex != cb.getSelectedIndex()) { - choosenClassIndex = cb.getSelectedIndex(); - config.setInitReasoner(false); - setReasoner(); + public void actionPerformed(ActionEvent e) { + // read selected Class + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitReasoner(false); + setReasoner(); + } + + if (e.getSource() == setButton) { + config.setInitReasoner(false); + setReasoner(); + } + + if (e.getSource() == initButton) + init(); } - if (e.getSource() == setButton) { - config.setInitReasoner(false); - setReasoner(); + /** + * after this, you can change widgets + */ + public void setReasoner() { + if (config.isInitKnowledgeSource()) { + config.setReasoner(config.getComponentManager().reasoner( + reasoners.get(choosenClassIndex), config.getKnowledgeSource())); + updateOptionPanel(); + startGUI.updateTabColors(); + config.setInitReasoner(false); + updateInitButtonColor(); + } } - if (e.getSource() == initButton) - init(); - } + /** + * after this, next tab can be used + */ + public void init() { + setReasoner(); + if (config.getKnowledgeSource() != null && config.getReasoner() != null) { + try { + config.getReasoner().init(); + System.out.println("init Reasoner"); + // set ReasoningService + config.setReasoningService(config.getComponentManager().reasoningService( + config.getReasoner())); + System.out.println("init ReasoningService"); + config.setInitReasoner(true); + startGUI.update... [truncated message content] |
From: <ton...@us...> - 2008-02-21 16:21:16
|
Revision: 619 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=619&view=rev Author: tonytacker Date: 2008-02-21 08:21:05 -0800 (Thu, 21 Feb 2008) Log Message: ----------- fixed bug on loading *.kb file Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.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-02-21 15:42:21 UTC (rev 618) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-21 16:21:05 UTC (rev 619) @@ -64,9 +64,8 @@ * @return true, if url was set otherwise false */ public Boolean isSetURL() { - // return this.isURL; - // String value = (String) cm.getConfigOptionValue(source, "url"); - if (cm.getConfigOptionValue(source, "url") != null) + if (cm.getConfigOptionValue(source, "url") != null + || cm.getConfigOptionValue(source, "filename") != null) return true; else return false; Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-21 15:42:21 UTC (rev 618) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-21 16:21:05 UTC (rev 619) @@ -94,12 +94,11 @@ componentOption = SparqlKnowledgeSource.class; } } - // check if class was set + // check if class was set and set knwoledgeSource if (componentOption != null) config.setKnowledgeSource(config.getComponentManager().knowledgeSource( componentOption)); // set url - // value = parser.getFunctionCalls().get("import").get(0).get(0); value = makeURL(value); Component component = config.getKnowledgeSource(); StringConfigOption specialOption = (StringConfigOption) config.getComponentManager() @@ -111,6 +110,9 @@ } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } + // widgets + + // startGUI.updateTabColors(); // init if (config.getKnowledgeSource() != null && config.isSetURL()) { Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-21 15:42:21 UTC (rev 618) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-21 16:21:05 UTC (rev 619) @@ -61,8 +61,6 @@ this.startGUI = startGUI; sources = config.getComponentManager().getKnowledgeSources(); - System.out.println("SOURCES: " + sources); - setButton = new JButton("Set"); setButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); @@ -87,7 +85,7 @@ add(optionPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); - // setSource(); + setSource(); updateAll(); } @@ -112,17 +110,8 @@ * after this, you can change widgets */ public void setSource() { - System.out.println("cm: " + config.getComponentManager()); - System.out.println("setSOURCE :" + sources.get(choosenClassIndex)); - config.setKnowledgeSource(config.getComponentManager().knowledgeSource( sources.get(choosenClassIndex))); - // KBFile.class doesn't work - // config.setKnowledgeSource(config.getComponentManager().knowledgeSource(KBFile.class)); - - System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); - System.out.println("ABC: " + config.getComponentManager().getComponentName(sources.get(0))); - config.setInitKnowledgeSource(false); updateAll(); } @@ -131,8 +120,6 @@ * after this, next tab can be used */ public void init() { - System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); - System.out.println("isSetURL: " + config.isSetURL()); if (config.getKnowledgeSource() != null && config.isSetURL()) { try { config.getKnowledgeSource().init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-21 21:13:38
|
Revision: 621 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=621&view=rev Author: tonytacker Date: 2008-02-21 13:13:33 -0800 (Thu, 21 Feb 2008) Log Message: ----------- using startCLI to load a config file Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.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/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-21 16:25:48 UTC (rev 620) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-21 21:13:33 UTC (rev 621) @@ -21,22 +21,41 @@ */ import java.io.File; // import java.net.URL; -// import java.util.List; +import java.net.URL; // import java.util.HashSet; +import java.util.Map; // import java.util.Set; +import java.util.SortedSet; // import java.util.List; // import java.util.Map; +import org.dllearner.algorithms.BruteForceLearner; +import org.dllearner.algorithms.RandomGuesser; +import org.dllearner.algorithms.gp.GP; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.algorithms.refinement.ROLearner; import org.dllearner.core.ComponentInitException; import org.dllearner.core.KnowledgeSource; // import -// org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasonerComponent; // org.dllearner.core.LearningProblem; // import org.dllearner.core.ReasoningService; // import org.dllearner.core.LearningAlgorithm; // import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.config.ConfigEntry; -import org.dllearner.core.config.InvalidConfigOptionValueException; -import org.dllearner.core.config.StringConfigOption; +// import org.dllearner.core.config.ConfigEntry; +// import org.dllearner.core.config.InvalidConfigOptionValueException; +// import org.dllearner.core.config.StringConfigOption; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegInclusionLP; +import org.dllearner.learningproblems.PosOnlyDefinitionLP; import org.dllearner.parser.ConfParser; -import org.dllearner.kb.KBFile; -import org.dllearner.kb.OWLFile; -import org.dllearner.kb.sparql.SparqlKnowledgeSource; -import org.dllearner.core.Component; +import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.reasoning.FastRetrievalReasoner; +import org.dllearner.reasoning.OWLAPIReasoner; // import +// org.dllearner.kb.KBFile; +// import org.dllearner.kb.OWLFile; +// import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.core.Component; // import +// org.dllearner.cli.ConfFileOption; +import org.dllearner.cli.ConfFileOption; +import org.dllearner.cli.Start; /** * Open a config file. @@ -49,8 +68,10 @@ private Config config; private StartGUI startGUI; - private Class<? extends KnowledgeSource> componentOption; + // private Start cli; + // private Class<? extends KnowledgeSource> componentOption; + /** * set config and startGUI * @@ -79,63 +100,146 @@ public void startParser() { if (this.file.exists()) { ConfParser parser = ConfParser.parseFile(file); + // create a mapping between components and prefixes in the conf file + Map<Class<? extends Component>, String> componentPrefixMapping = Start + .createComponentPrefixMapping(); + // KNOWLEDGE SOURCE - // filename - String value = parser.getFunctionCalls().get("import").get(0).get(0); - // only first of imported files - if (value.endsWith(".kb")) { - componentOption = KBFile.class; - } else if (value.endsWith(".owl")) { - componentOption = OWLFile.class; - } else if (parser.getFunctionCalls().get("import").get(0).size() > 1) { - if (parser.getFunctionCalls().get("import").get(0).get(1) - .equalsIgnoreCase("sparql")) { - System.out.println("IT IS SPARQL"); - componentOption = SparqlKnowledgeSource.class; + Map<URL, Class<? extends KnowledgeSource>> importedFiles = Start.getImportedFiles( + parser, file.getParentFile().getPath()); + for (Map.Entry<URL, Class<? extends KnowledgeSource>> entry : importedFiles.entrySet()) { + config.setKnowledgeSource(config.getComponentManager().knowledgeSource( + entry.getValue())); + config.getComponentManager().applyConfigEntry(config.getKnowledgeSource(), "url", + entry.getKey().toString()); + // sources.add(ks); + // TODO more then 1 KnowledgeSource + config.setKnowledgeSource(config.getKnowledgeSource()); + Start.configureComponent(config.getComponentManager(), config.getKnowledgeSource(), + componentPrefixMapping, parser); + // init + if (config.getKnowledgeSource() != null && config.isSetURL()) { + try { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + } catch (ComponentInitException e) { + e.printStackTrace(); + } } } - // check if class was set and set knwoledgeSource - if (componentOption != null) - config.setKnowledgeSource(config.getComponentManager().knowledgeSource( - componentOption)); - // set url - value = makeURL(value); - Component component = config.getKnowledgeSource(); - StringConfigOption specialOption = (StringConfigOption) config.getComponentManager() - .getConfigOption(componentOption, "url"); - try { - ConfigEntry<String> specialEntry = new ConfigEntry<String>(specialOption, value); - config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set String: " + "url" + " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); + + // REASONER + ConfFileOption reasonerOption = parser.getConfOptionsByName("reasoner"); + Class<? extends ReasonerComponent> reasonerClass = null; + // default value + if (reasonerOption == null || reasonerOption.getStringValue().equals("dig")) + reasonerClass = DIGReasoner.class; + else if (reasonerOption.getStringValue().equals("owlAPI")) + reasonerClass = OWLAPIReasoner.class; + else if (reasonerOption.getStringValue().equals("fastRetrieval")) + reasonerClass = FastRetrievalReasoner.class; + else { + Start.handleError("Unknown value " + reasonerOption.getStringValue() + + " for option \"reasoner\"."); } - // widgets - - - // startGUI.updateTabColors(); - // init - if (config.getKnowledgeSource() != null && config.isSetURL()) { + config.setReasoner(config.getComponentManager().reasoner(reasonerClass, + config.getKnowledgeSource())); + Start.configureComponent(config.getComponentManager(), config.getReasoner(), + componentPrefixMapping, parser); + if (config.getKnowledgeSource() != null && config.getReasoner() != null) { try { - config.getKnowledgeSource().init(); - config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); + config.getReasoner().init(); + System.out.println("init Reasoner"); + // set ReasoningService + config.setReasoningService(config.getComponentManager().reasoningService( + config.getReasoner())); + System.out.println("init ReasoningService"); + config.setInitReasoner(true); + startGUI.updateTabColors(); } catch (ComponentInitException e) { e.printStackTrace(); } } - // update + // LEARNING PROBLEM + ConfFileOption problemOption = parser.getConfOptionsByName("problem"); + Class<? extends LearningProblem> lpClass = null; + if (problemOption == null || problemOption.getStringValue().equals("posNegDefinition")) + lpClass = PosNegDefinitionLP.class; + else if (problemOption.getStringValue().equals("posNegInclusion")) + lpClass = PosNegInclusionLP.class; + else if (problemOption.getStringValue().equals("posOnlyDefinition")) + lpClass = PosOnlyDefinitionLP.class; + else + Start.handleError("Unknown value " + problemOption.getValue() + + " for option \"problem\"."); + config.setLearningProblem(config.getComponentManager().learningProblem(lpClass, + config.getReasoningService())); + SortedSet<String> posExamples = parser.getPositiveExamples(); + SortedSet<String> negExamples = parser.getNegativeExamples(); + config.getComponentManager().applyConfigEntry(config.getLearningProblem(), + "positiveExamples", posExamples); + if (lpClass != PosOnlyDefinitionLP.class) + config.getComponentManager().applyConfigEntry(config.getLearningProblem(), + "negativeExamples", negExamples); + Start.configureComponent(config.getComponentManager(), config.getLearningProblem(), + componentPrefixMapping, parser); + if (config.getReasoner() != null && config.getLearningProblem() != null) { + try { + config.getLearningProblem().init(); + config.setInitLearningProblem(true); + System.out.println("init LearningProblem"); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + + // LEARNING ALGORITHM + ConfFileOption algorithmOption = parser.getConfOptionsByName("algorithm"); + Class<? extends LearningAlgorithm> laClass = null; + if (algorithmOption == null || algorithmOption.getStringValue().equals("refinement")) + laClass = ROLearner.class; + else if(algorithmOption.getStringValue().equals("refexamples")) + laClass = ExampleBasedROLComponent.class; + else if(algorithmOption.getStringValue().equals("gp")) + laClass = GP.class; + else if(algorithmOption.getStringValue().equals("bruteForce")) + laClass = BruteForceLearner.class; + else if(algorithmOption.getStringValue().equals("randomGuesser")) + laClass = RandomGuesser.class; + else + Start.handleError("Unknown value in " + algorithmOption); + + if (config.getLearningProblem() != null && config.getReasoningService() != null) { + try { + config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm( + laClass, config.getLearningProblem(), + config.getReasoningService())); + } catch (LearningProblemUnsupportedException e) { + e.printStackTrace(); + } + } + Start.configureComponent(config.getComponentManager(), config.getLearningAlgorithm(), componentPrefixMapping, parser); + if (config.getLearningProblem() != null) { + try { + config.getLearningAlgorithm().init(); + config.setInitLearningAlgorithm(true); + System.out.println("init LearningAlgorithm"); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + + // update graphic startGUI.updateTabColors(); - System.out.println("reasoner: " + parser.getConfOptionsByName("reasoner")); - System.out.println("confoptions: " + parser.getConfOptions()); - System.out.println("posExamples: " + parser.getPositiveExamples()); - System.out.println("confoptionbyname: " + parser.getConfOptionsByName()); + //System.out.println("reasoner: " + parser.getConfOptionsByName("reasoner")); + //System.out.println("confoptions: " + parser.getConfOptions()); + //System.out.println("posExamples: " + parser.getPositiveExamples()); + //System.out.println("confoptionbyname: " + parser.getConfOptionsByName()); - // do it - // only url from first entry, ignore others - // parser.getFunctionCalls().get("import").get(0); } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-21 16:25:48 UTC (rev 620) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-21 21:13:33 UTC (rev 621) @@ -43,7 +43,7 @@ private Config config; private StartGUI startGUI; - private List<Class<? extends LearningAlgorithm>> learners; + private List<Class<? extends LearningAlgorithm>> learner; private JPanel choosePanel = new JPanel(); private OptionPanel optionPanel; private JPanel initPanel = new JPanel(); @@ -57,7 +57,7 @@ this.config = config; this.startGUI = startGUI; - learners = config.getComponentManager().getLearningAlgorithms(); + learner = config.getComponentManager().getLearningAlgorithms(); initButton = new JButton("Init LearingAlgorithm"); initButton.addActionListener(this); @@ -67,8 +67,8 @@ autoInitButton.addActionListener(this); // add into comboBox - for (int i = 0; i < learners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName(learners.get(i))); + for (int i = 0; i < learner.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(learner.get(i))); } choosePanel.add(cb); @@ -76,7 +76,7 @@ cb.addActionListener(this); optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), config - .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); + .getOldLearningAlgorithm(), learner.get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); add(optionPanel, BorderLayout.CENTER); @@ -108,7 +108,7 @@ if (config.getLearningProblem() != null && config.getReasoningService() != null) { try { config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm( - learners.get(choosenClassIndex), config.getLearningProblem(), + learner.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); updateOptionPanel(); } catch (LearningProblemUnsupportedException e) { @@ -126,7 +126,6 @@ try { config.getLearningAlgorithm().init(); } catch (ComponentInitException e) { - // TODO Auto-generated catch block e.printStackTrace(); } config.setInitLearningAlgorithm(true); @@ -136,12 +135,34 @@ } /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } + + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getLearningAlgorithm() != null) + for (int i = 0; i < learner.size(); i++) + if (config.getLearningAlgorithm().getClass().equals( + config.getComponentManager().getLearningAlgorithms().get(i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + + /** * update OptionPanel with new selection */ public void updateOptionPanel() { // update OptionPanel - optionPanel.update(config.getLearningAlgorithm(), config.getOldLearningAlgorithm(), - learners.get(choosenClassIndex)); + optionPanel.update(config.getLearningAlgorithm(), config.getOldLearningAlgorithm(), learner + .get(choosenClassIndex)); } /** Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-21 16:25:48 UTC (rev 620) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-21 21:13:33 UTC (rev 621) @@ -42,7 +42,7 @@ private Config config; private StartGUI startGUI; - private List<Class<? extends LearningProblem>> problems; + private List<Class<? extends LearningProblem>> problem; private String[] lpBoxItems = {}; private JComboBox cb = new JComboBox(lpBoxItems); private JPanel choosePanel = new JPanel(); @@ -56,7 +56,7 @@ this.config = config; this.startGUI = startGUI; - problems = config.getComponentManager().getLearningProblems(); + problem = config.getComponentManager().getLearningProblems(); initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); @@ -69,15 +69,15 @@ cb.addActionListener(this); // add into comboBox - for (int i = 0; i < problems.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName(problems.get(i))); + for (int i = 0; i < problem.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(problem.get(i))); } // read choosen LearningProblem choosenClassIndex = cb.getSelectedIndex(); optionPanel = new OptionPanel(config, config.getLearningProblem(), config - .getOldLearningProblem(), problems.get(choosenClassIndex)); + .getOldLearningProblem(), problem.get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); add(optionPanel, BorderLayout.CENTER); @@ -109,7 +109,7 @@ private void setLearningProblem() { if (config.isInitReasoner()) { config.setLearningProblem(config.getComponentManager().learningProblem( - problems.get(choosenClassIndex), config.getReasoningService())); + problem.get(choosenClassIndex), config.getReasoningService())); startGUI.updateTabColors(); updateOptionPanel(); } @@ -133,11 +133,33 @@ } /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } + + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getLearningProblem() != null) + for (int i = 0; i < problem.size(); i++) + if (config.getLearningProblem().getClass().equals( + config.getComponentManager().getLearningProblems().get(i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + + /** * update OptionPanel with new selection */ private void updateOptionPanel() { // update OptionPanel - optionPanel.update(config.getLearningProblem(), config.getOldLearningProblem(), problems + optionPanel.update(config.getLearningProblem(), config.getOldLearningProblem(), problem .get(choosenClassIndex)); } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-21 16:25:48 UTC (rev 620) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-21 21:13:33 UTC (rev 621) @@ -43,7 +43,7 @@ private Config config; private StartGUI startGUI; - private List<Class<? extends ReasonerComponent>> reasoners; + private List<Class<? extends ReasonerComponent>> reasoner; private JPanel choosePanel = new JPanel(); private JPanel initPanel = new JPanel(); private OptionPanel optionPanel; @@ -57,7 +57,7 @@ this.config = config; this.startGUI = startGUI; - reasoners = config.getComponentManager().getReasonerComponents(); + reasoner = config.getComponentManager().getReasonerComponents(); initButton = new JButton("Init Reasoner"); initButton.addActionListener(this); @@ -69,12 +69,12 @@ choosePanel.add(cb); // add into comboBox - for (int i = 0; i < reasoners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName(reasoners.get(i))); + for (int i = 0; i < reasoner.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(reasoner.get(i))); } optionPanel = new OptionPanel(config, config.getReasoner(), config.getOldReasonerSet(), - reasoners.get(choosenClassIndex)); + reasoner.get(choosenClassIndex)); choosePanel.add(setButton); cb.addActionListener(this); @@ -112,7 +112,7 @@ public void setReasoner() { if (config.isInitKnowledgeSource()) { config.setReasoner(config.getComponentManager().reasoner( - reasoners.get(choosenClassIndex), config.getKnowledgeSource())); + reasoner.get(choosenClassIndex), config.getKnowledgeSource())); updateOptionPanel(); startGUI.updateTabColors(); config.setInitReasoner(false); @@ -143,10 +143,32 @@ } /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } + + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getReasoner() != null) + for (int i = 0; i < reasoner.size(); i++) + if (config.getKnowledgeSource().getClass().equals( + config.getComponentManager().getKnowledgeSources().get(i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + + /** * update OptionPanel with new selection */ public void updateOptionPanel() { - optionPanel.update(config.getReasoner(), config.getOldReasonerSet(), reasoners + optionPanel.update(config.getReasoner(), config.getOldReasonerSet(), reasoner .get(choosenClassIndex)); } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-21 16:25:48 UTC (rev 620) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-21 21:13:33 UTC (rev 621) @@ -169,9 +169,9 @@ tabPane.setForegroundAt(4, Color.RED); } tab0.updateAll(); - tab1.updateInitButtonColor(); - tab2.updateInitButtonColor(); - tab3.updateInitButtonColor(); + tab1.updateAll(); + tab2.updateAll(); + tab3.updateAll(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-02 15:41:07
|
Revision: 671 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=671&view=rev Author: tonytacker Date: 2008-03-02 07:40:29 -0800 (Sun, 02 Mar 2008) Log Message: ----------- some statistics for algorithm Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-03-02 15:40:29 UTC (rev 671) @@ -48,6 +48,9 @@ private LearningAlgorithm la; private LearningAlgorithm oldLearningAlgorithm; private boolean[] isInit = new boolean[4]; + private Boolean threadIsRunning = false; + private Long algorithmRunStartTime = null; + private Long algorithmRunStopTime = null; /** * Get ComponentManager. @@ -274,4 +277,38 @@ isInit[3] = is; } + /** + * Set true if you start the algorithm. + * + * @param isThreadRunning + */ + public void setThreadIsRunning(Boolean isThreadRunning) { + if (isThreadRunning) + algorithmRunStartTime = System.nanoTime(); + else if (algorithmRunStartTime != null) + if (algorithmRunStartTime < System.nanoTime()) + algorithmRunStopTime = System.nanoTime(); + this.threadIsRunning = isThreadRunning; + } + + /** + * Get true if algorithm has started, false if not. + * + * @return true if algorithm is running, false if not. + */ + public Boolean getThreadIsRunning() { + return this.threadIsRunning; + } + + /** + * Get time in ns for run of algorithm. + * + * @return time in ns + */ + public Long getAlgorithmRunTime() { + if (algorithmRunStartTime != null && algorithmRunStopTime != null) + if (algorithmRunStartTime < algorithmRunStopTime) + return algorithmRunStopTime - algorithmRunStartTime; + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-03-02 15:40:29 UTC (rev 671) @@ -34,7 +34,7 @@ import java.io.PrintWriter; /** - * Open a config file. + * Save a config file. * * @author Tilo Hielscher */ Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-02 15:40:29 UTC (rev 671) @@ -25,6 +25,7 @@ import java.awt.event.ActionListener; import javax.swing.*; +import java.lang.Long; /** * RunPanel let algorithm start and stop and show informations about. @@ -36,7 +37,8 @@ private static final long serialVersionUID = 1643304576470046636L; - private JButton runButton, stopButton, getBestSolutionButton, getSolutionScoreButton; + private JButton runButton, stopButton, getBestSolutionButton, getSolutionScoreButton, + getReasonerStatsButton; private JTextArea infoArea; private Config config; @@ -63,6 +65,9 @@ getSolutionScoreButton = new JButton("GetSolutionScore"); getSolutionScoreButton.addActionListener(this); + getReasonerStatsButton = new JButton("GetReasonerStats"); + getReasonerStatsButton.addActionListener(this); + infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); @@ -73,6 +78,7 @@ solutionPanel.add(getBestSolutionButton); solutionPanel.add(getSolutionScoreButton); + solutionPanel.add(getReasonerStatsButton); add(showPanel, BorderLayout.PAGE_START); add(infoPanel, BorderLayout.CENTER); @@ -98,6 +104,58 @@ if (e.getSource() == getSolutionScoreButton && runBoolean) { infoArea.setText(config.getLearningAlgorithm().getSolutionScore().toString()); } + // ReasonerStats + if (e.getSource() == getReasonerStatsButton && runBoolean) { + infoArea.setText(""); + infoArea.append("Algorithm Runtime: " + + makeTime(config.getAlgorithmRunTime()) + "\n"); + infoArea.append("OverallReasoningTime: " + + makeTime(config.getReasoningService().getOverallReasoningTimeNs()) + "\n"); + infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() + + "): "); + if (config.getReasoningService().getNrOfInstanceChecks() > 0) + infoArea.append(makeTime(config.getReasoningService().getTimePerInstanceCheckNs()) + + "\n"); + else + infoArea.append(" - \n"); + infoArea.append("Retrieval (" + config.getReasoningService().getNrOfRetrievals() + + "): "); + if (config.getReasoningService().getNrOfRetrievals() > 0) + infoArea.append(makeTime(config.getReasoningService().getTimePerRetrievalNs()) + + "\n"); + else + infoArea.append(" - \n"); + infoArea.append("Subsumption (" + + config.getReasoningService().getNrOfSubsumptionChecks() + "): " + + makeTime(config.getReasoningService().getTimePerSubsumptionCheckNs()) + "\n"); + } } + /** + * Build a String form nanoSeconds. + * + * @param nanoSeconds + * is type of Long and represent a time interval in ns + * @return a string like this: 3h 12min 46s 753ms + */ + public String makeTime(Long nanoSeconds) { + String time = ""; + Integer hours = 0, minutes = 0, seconds = 0, miliSeconds = 0; + nanoSeconds /= 1000000; // miliSeconds + hours = Math.round(nanoSeconds / 1000 / 60 / 60); + minutes = Math.round(nanoSeconds / 1000 / 60); + seconds = Math.round(nanoSeconds / 1000); + miliSeconds = Math.round(nanoSeconds - (hours * 1000 * 60 * 60) - (minutes * 1000 * 60) + - (seconds * 1000)); + if (hours > 0) + time += hours + "h "; + if (minutes > 0) + time += minutes + "min "; + if (seconds > 0) + time += seconds + "s "; + if (miliSeconds > 0) + time += miliSeconds + "ms "; + // System.out.println("time: " + time); + return time; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-03-02 15:40:29 UTC (rev 671) @@ -38,8 +38,11 @@ */ @Override public void run() { - if (config.getLearningAlgorithm() != null) + if (config.getLearningAlgorithm() != null) { + config.setThreadIsRunning(true); config.getLearningAlgorithm().start(); + config.setThreadIsRunning(false); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |