From: <hee...@us...> - 2008-11-14 15:04:17
|
Revision: 1513 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1513&view=rev Author: heeroyuy Date: 2008-11-14 15:04:06 +0000 (Fri, 14 Nov 2008) Log Message: ----------- -fixed updateproblem of the suggest panel after learning Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -19,6 +19,7 @@ */ package org.dllearner.tools.protege; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -26,7 +27,14 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.Iterator; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ExecutionException; +import javax.swing.DefaultListModel; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import javax.swing.event.ListSelectionEvent; @@ -37,7 +45,8 @@ import org.protege.editor.owl.OWLEditorKit; /** - * This class processes input from the user. + * This class processes input from the user. + * * @author Christian Koetteritzsch * */ @@ -59,6 +68,7 @@ private EvaluatedDescription evaluatedDescription; // This is the view of the DL-Learner tab. private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; + private Timer timer; /** * This is the constructor for the action handler. @@ -71,7 +81,8 @@ * DLlearner tab * @param i * id if it is a subclass or an equivalent class - * @param editor OWLEditorKit + * @param editor + * OWLEditorKit */ public ActionHandler(ActionHandler a, DLLearnerModel m, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view, @@ -86,34 +97,36 @@ /** * When a Button is pressed this method select the right. - * @param z ActionEvent + * + * @param z + * ActionEvent */ public void actionPerformed(ActionEvent z) { - if (z.getActionCommand().equals("Suggest " + id)) { if (model.getAlreadyLearned()) { model.unsetListModel(); } - view.getPosAndNegSelectPanel().setCheckBoxesEnable(false); - model.setKnowledgeSource(); - model.setReasoner(); - model.setPositiveAndNegativeExamples(); - model.setLearningProblem(); - model.setLearningAlgorithm(); - this.dlLearner = new Thread(model); - dlLearner.start(); - view.getRunButton().setEnabled(false); - view.renderErrorMessage("Learning started"); - //view.getPosAndNegSelectPanel().unsetCheckBoxes(); - + view.getRunButton().setEnabled(false); + view.renderErrorMessage("Learning started"); + view.getPosAndNegSelectPanel().setCheckBoxesEnable(false); + final SuggestionRetriever retriever = new SuggestionRetriever(); + // + // dlLearner.start(); + retriever.execute(); + } if (z.getActionCommand().equals("ADD")) { if (evaluatedDescription != null) { - model.changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription.getDescription()); + model + .changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription + .getDescription()); } else { - model.changeDLLearnerDescriptionsToOWLDescriptions((Description) view.getSuggestClassPanel().getSuggestList().getSelectedValue()); + model + .changeDLLearnerDescriptionsToOWLDescriptions((Description) view + .getSuggestClassPanel().getSuggestList() + .getSelectedValue()); } String message = "Concept added"; view.renderErrorMessage(message); @@ -144,47 +157,21 @@ return id; } - /** * select/deselect the Check boxes. - * @param i ItemEvent + * + * @param i + * ItemEvent */ public void itemStateChanged(ItemEvent i) { - if (i.getItem().toString().contains("Positive")) { - for (int j = 0; j < model.getPosVector().size(); j++) { - if (i.getItem().toString().contains( - model.getPosVector().get(j).getText().toString())) { - if (!model.getPosVector().get(j).isSelected()) { - model.getPosVector().get(j).setSelected(true); - break; - } - if (model.getPosVector().get(j).isSelected()) { - model.getPosVector().get(j).setSelected(false); - break; - } - } - } - } - if (i.getItem().toString().contains("Negative")) { - for (int j = 0; j < model.getNegVector().size(); j++) { - if (i.getItem().toString().contains( - model.getNegVector().get(j).getText().toString())) { - if (!model.getNegVector().get(j).isSelected()) { - model.getNegVector().get(j).setSelected(true); - break; - } - if (model.getNegVector().get(j).isSelected()) { - model.getNegVector().get(j).setSelected(false); - break; - } - } - } - } + } - + /** * Nothing happens here. - * @param e ListSelectionEvent + * + * @param e + * ListSelectionEvent */ public void valueChanged(ListSelectionEvent e) { @@ -192,30 +179,37 @@ /** * Nothing happens here. - * @param m MouseEvent + * + * @param m + * MouseEvent */ public void mouseReleased(MouseEvent m) { } - /** + /** * Nothing happens here. - * @param m MouseEvent + * + * @param m + * MouseEvent */ public void mouseEntered(MouseEvent m) { } /** - * Choses the right EvaluatedDescription object after a concept is chosen in the list. - * @param m MouseEvent + * Choses the right EvaluatedDescription object after a concept is chosen in + * the list. + * + * @param m + * MouseEvent */ public void mouseClicked(MouseEvent m) { EvaluatedDescription eDescription = null; - if (view.getSuggestClassPanel().getSuggestList() - .getSelectedValue() != null) { - SuggestListItem item = (SuggestListItem) view.getSuggestClassPanel().getSuggestList() - .getSelectedValue(); + + if (view.getSuggestClassPanel().getSuggestList().getSelectedValue() != null) { + SuggestListItem item = (SuggestListItem) view + .getSuggestClassPanel().getSuggestList().getSelectedValue(); String desc = item.getValue(); if (model.getEvaluatedDescriptionList() != null) { for (Iterator<EvaluatedDescription> i = model @@ -223,28 +217,29 @@ eDescription = i.next(); if (desc.equals(eDescription.getDescription() .toManchesterSyntaxString( - editorKit.getModelManager().getActiveOntology().getURI() + editorKit.getModelManager() + .getActiveOntology().getURI() + "#", null))) { evaluatedDescription = eDescription; + break; } } } - - - if(m.getClickCount()==2) { - view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel( - evaluatedDescription); + + if (m.getClickCount() == 2) { + view.getMoreDetailForSuggestedConceptsPanel() + .renderDetailPanel(evaluatedDescription); + } } - } else { - } - } /** * Nothing happens here. - * @param m MouseEvent + * + * @param m + * MouseEvent */ public void mouseExited(MouseEvent m) { @@ -252,15 +247,16 @@ /** * Sets the ADD button enable after a concept is chosen. - * @param m MouseEvent + * + * @param m + * MouseEvent */ public void mousePressed(MouseEvent m) { - if (view.getSuggestClassPanel().getSuggestList() - .getSelectedValue()!= null) { + if (view.getSuggestClassPanel().getSuggestList().getSelectedValue() != null) { if (!view.getAddButton().isEnabled()) { view.getAddButton().setEnabled(true); - } - } + } + } } /** @@ -271,7 +267,7 @@ } /** - * Resets the toggled Button after the plugin is closed. + * Resets the toggled Button after the plugin is closed. */ public void resetToggled() { toggled = false; @@ -280,19 +276,131 @@ @Override public void contentsChanged(ListDataEvent listEvent) { System.out.println(listEvent); - + } @Override public void intervalAdded(ListDataEvent listEvent) { // TODO Auto-generated method stub - + } @Override public void intervalRemoved(ListDataEvent listEvent) { // TODO Auto-generated method stub - + } + class SuggestionRetriever extends + SwingWorker<List<EvaluatedDescription>, List<EvaluatedDescription>> { + + public SuggestionRetriever() { + + } + + @Override + protected List<EvaluatedDescription> doInBackground() throws Exception { + // DefaultListModel descriptions = new DefaultListModel(); + // List<Description> descriptionList = + // model.getLearningAlgorithm().getCurrentlyBestDescriptions(); + // Iterator<Description> it = descriptionList.iterator(); + timer = new Timer(); + timer.schedule(new TimerTask() { + + @SuppressWarnings("unchecked") + @Override + public void run() { + if (model.getLearningAlgorithm() != null) { + publish(model.getLearningAlgorithm() + .getCurrentlyBestEvaluatedDescriptions(30, 0.0, + true)); + } + } + + }, 1000, 2000); + + dlLearner = new Thread(new Runnable() { + + @Override + public void run() { + + model.run(); + } + + }); + dlLearner.start(); + + try { + dlLearner.join(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + List<EvaluatedDescription> result = model.getLearningAlgorithm() + .getCurrentlyBestEvaluatedDescriptions( + view.getPosAndNegSelectPanel().getOptionPanel() + .getNrOfConcepts(), + view.getPosAndNegSelectPanel().getOptionPanel() + .getMinAccuracy(), true); + + + return result; + } + + @Override + public void done() { + + timer.cancel(); + List<EvaluatedDescription> result = null; + try { + result = get(); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + + view.getRunButton().setEnabled(true); + updateList(result); + } + + @Override + protected void process(List<List<EvaluatedDescription>> resultLists) { + + // panel4.getModel().clear(); + + for (List<EvaluatedDescription> list : resultLists) { + updateList(list); + } + } + + private void updateList(final List<EvaluatedDescription> result) { + + Runnable doUpdateList = new Runnable() { + + DefaultListModel dm = new DefaultListModel(); + + public void run() { + model.setSuggestList(result); + // learnPanel.getListModel().clear(); + Iterator<EvaluatedDescription> it = result.iterator(); + //it.next().getDescription().toManchesterSyntaxString(baseURI, prefixes); + while (it.hasNext()) { + EvaluatedDescription eval = it.next(); + if(model.isConsistent(eval)) { + dm.add(0, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null))); + } else { + dm.add(0, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null))); + } + } + view.getSuggestClassPanel().getSuggestList().setModel(dm); + + } + }; + SwingUtilities.invokeLater(doUpdateList); + + } + + } + } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -32,7 +32,6 @@ import java.util.Vector; import javax.swing.DefaultListModel; -import javax.swing.JCheckBox; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.core.ComponentInitException; @@ -86,14 +85,7 @@ "org.dllearner.algorithms.refexamples.ExampleBasedROLComponent", "org.dllearner.algorithms.gp.GP" }; - // This Vector stores the check boxes for the view. - private Vector<JCheckBox> positiv; - - // This Vector stores the negative Examples. - - private Vector<JCheckBox> negativ; - // Component Manager that manages the components of the DL-Learner private ComponentManager cm; @@ -204,7 +196,6 @@ // This is a List of evaluated descriptions to get more information of the // suggested concept private List<EvaluatedDescription> evalDescriptions; - private Vector<String> normalIndividuals; /** * This is the constructor for DL-Learner model. @@ -227,11 +218,8 @@ this.view = view; ontologyURI = editor.getModelManager().getActiveOntology().getURI().toString()+"#"; owlDescription = new HashSet<OWLDescription>(); - positiv = new Vector<JCheckBox>(); posListModel = new DefaultListModel(); negListModel = new DefaultListModel(); - negativ = new Vector<JCheckBox>(); - normalIndividuals = new Vector<String>(); ComponentManager.setComponentClasses(componenten); individualVector = new Vector<IndividualObject>(); cm = ComponentManager.getInstance(); @@ -351,12 +339,12 @@ if (id.equals("equivalent classes")) { // sets the learning problem to PosNegDefinitionLP when the // dllearner should suggest an equivalent class - lp = cm.learningProblem(PosNegDefinitionLP.class, rs); + lp = cm.learningProblem(PosNegDefinitionLP.class, reasoner); } if (id.equals("super classes")) { // sets the learning problem to PosNegInclusionLP when the dllearner // should suggest a subclass - lp = cm.learningProblem(PosNegInclusionLP.class, rs); + lp = cm.learningProblem(PosNegInclusionLP.class, reasoner); } // adds the positive examples cm.applyConfigEntry(lp, "positiveExamples", positiveExamples); @@ -376,7 +364,7 @@ try { // sets the learning algorithm to ROlearner this.la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, - rs); + reasoner); } catch (LearningProblemUnsupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -397,21 +385,25 @@ */ public void run() { error = "Learning succesful"; - + setKnowledgeSource(); + setReasoner(); + setPositiveAndNegativeExamples(); + setLearningProblem(); + setLearningAlgorithm(); String message = "To view details about why a class description was suggested, please doubleclick on it."; // start the algorithm and print the best concept found la.start(); - description = new Description[la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts()) - .size()]; - addToListModel(); + //description = new Description[la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts()) + // .size()]; + //addToListModel(); // renders the errormessage view.renderErrorMessage(error); view.setHintMessage(message); // reenables the run button - view.getRunButton().setEnabled(true); + //view.getRunButton().setEnabled(true); // disables the cancel button - view.getPosAndNegSelectPanel().setCheckBoxesEnable(true); - view.getSuggestClassPanel().setSuggestList(suggestModel); + //view.getPosAndNegSelectPanel().setCheckBoxesEnable(true); + //view.getSuggestClassPanel().setSuggestList(suggestModel); } /** @@ -424,24 +416,6 @@ } /** - * This method returns the check boxes for the positive examples. - * - * @return Vector of check boxes for positive examples - */ - public Vector<JCheckBox> getPosVector() { - return positiv; - } - - /** - * This method returns the check boxes for the negative examples. - * - * @return Vector of check boxes for negative examples - */ - public Vector<JCheckBox> getNegVector() { - return negativ; - } - - /** * This method gets an error message and storess it. * * @param err @@ -457,10 +431,10 @@ */ public void setPosVector() { setPositiveConcept(); - for (Iterator<Individual> j = rs.getIndividuals().iterator(); j + + for (Iterator<Individual> j = reasoner.getIndividuals().iterator(); j .hasNext();) { Individual ind = j.next(); - normalIndividuals.add(ind.toString()); String indiv = ind.toString(); // checks if individual belongs to the selected concept if (setPositivExamplesChecked(indiv)) { @@ -486,6 +460,10 @@ } } + /** + * This method returns the Vector of IndividualObjects. + * @return individualVector Vector + */ public Vector<IndividualObject> getIndividualVector() { return individualVector; } @@ -495,11 +473,12 @@ */ public void setPositiveConcept() { SortedSet<Individual> individuals = null; + //System.out.println("TEST: " + rs.getNamedClasses()); // checks if selected concept is thing when yes then it selects all // individuals if (!current.getRootObject().toString().equals("Thing")) { - - for (Iterator<NamedClass> i = rs.getNamedClasses().iterator(); i + + for (Iterator<NamedClass> i = reasoner.getAtomicConceptsList().iterator(); i .hasNext();) { // if individuals is null if (individuals == null) { @@ -509,31 +488,35 @@ "#" + current.getRootObject().toString())) { // if individuals is not null it gets all individuals of // the concept - if (rs.getIndividuals(concept) != null) { - individual = rs.getIndividuals(concept); + if (reasoner.getIndividuals(concept) != null) { + individual = reasoner.getIndividuals(concept); break; } } } } } else { - individual = rs.getIndividuals(); + individual = reasoner.getIndividuals(); } } - public boolean hasIndividuals(OWLClass OWLConcept) { + + /** + * This Method checks if the selected class has any individuals. + * @param owlConcept OWLClass + * @return boolean hasIndividuals + */ + public boolean hasIndividuals(OWLClass owlConcept) { boolean hasIndividuals = false; NamedClass concept = null; NamedClass selectedConcept = null; Iterator<NamedClass> it = reasoner.getNamedClasses().iterator(); while(it.hasNext()) { concept = it.next(); - if (concept.toManchesterSyntaxString(ontologyURI, prefixes).equals(OWLConcept.toString())) { + if (concept.toManchesterSyntaxString(ontologyURI, prefixes).equals(owlConcept.toString())) { selectedConcept = concept; break; } } - System.out.println("CON: "+ concept); - System.out.println("SIZE: "+ reasoner.getIndividuals(concept).size()); if (reasoner.getIndividuals(selectedConcept).size() > 0) { hasIndividuals = true; } @@ -572,8 +555,6 @@ individualVector.removeAllElements(); posListModel.removeAllElements(); negListModel.removeAllElements(); - positiv.removeAllElements(); - negativ.removeAllElements(); } /** @@ -587,10 +568,18 @@ description = list; } + /** + * This method returns the PosListModel. + * @return DefaultListModel posListModel + */ public DefaultListModel getPosListModel() { return posListModel; } + /** + * This method returns the NegListModel. + * @return DefaultListModel negListModel + */ public DefaultListModel getNegListModel() { return negListModel; } @@ -605,30 +594,6 @@ } /** - * This method gets an integer to return the positive examples check box on - * that position. - * - * @param i - * integer for the position in the vector - * @return Positive examples check box on position i. - */ - public JCheckBox getPositivJCheckBox(int i) { - return positiv.get(i); - } - - /** - * This method gets an integer to return the negative examples check box on - * that position. - * - * @param i - * integer for the position in the vector - * @return Negative examples check box on position i. - */ - public JCheckBox getNegativJCheckBox(int i) { - return negativ.get(i); - } - - /** * This method resets the array of concepts from the DL_Learner. It is * called after the DL-Learner tab is closed. */ @@ -639,27 +604,6 @@ } /** - * This method unchecks the checkboxes that are checked after the process of - * learning. - */ - public void unsetJCheckBoxen() { - for (int j = 0; j < positiv.size(); j++) { - // unselect all check poxes of the positive examples - if (positiv.get(j).isSelected()) { - JCheckBox i = positiv.get(j); - i.setSelected(false); - positiv.set(j, i); - } - // unselect all check boxes of the negative examples - if (negativ.get(j).isSelected()) { - JCheckBox i = negativ.get(j); - i.setSelected(false); - negativ.set(j, i); - } - } - } - - /** * This method resets the model for the suggest panel. It is called befor * the DL-Learner learns the second time or when the DL-Learner tab is * closed. @@ -750,7 +694,7 @@ */ private void setOldConceptOWLAPI() { // gets all individuals - SortedSet<Individual> indi = rs.getIndividuals(); + SortedSet<Individual> indi = reasoner.getIndividuals(); // Iterator of Individuals for (Iterator<Individual> i = indi.iterator(); i.hasNext();) { Individual indi2 = i.next(); @@ -823,7 +767,7 @@ return alreadyLearned; } - private boolean isConsistent(EvaluatedDescription eDescription) { + public boolean isConsistent(EvaluatedDescription eDescription) { boolean isConsistent = false; if (eDescription.getNotCoveredPositives().isEmpty()) { isConsistent = true; @@ -841,4 +785,8 @@ public URI getURI() { return editor.getModelManager().getActiveOntology().getURI(); } + + public void setSuggestList(List<EvaluatedDescription> list) { + evalDescriptions = list; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -1,29 +1,74 @@ +/** + * 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.tools.protege; - +/** + * This Class handles the manchester String, the normal string and if the Individual is a positive Individual. + * @author Christian Koetteritzsch + * + */ public class IndividualObject { private String normalIndividual; private String manchesterIndividual; private boolean isPos; + /** + * Constructor for the IndividualObject. + * @param normal String + * @param manchester String + * @param pos boolean + */ public IndividualObject(String normal, String manchester, boolean pos) { normalIndividual = normal; manchesterIndividual = manchester; isPos = pos; } + /** + * This method returns the String of the Individual. + * @return String normalIndividual + */ public String getIndividualString() { return normalIndividual; } + /** + * This method returns the manchester String of the Individual. + * @return String manchesterIndividual + */ public String getManchesterIndividual() { return manchesterIndividual; } + /** + * This method returns if the Example is a positive Example. + * @return boolean isPos + */ public boolean isPositiveExample() { return isPos; } + /** + * This method sets the example positive or negative if changed to the othe list. + * @param pos boolean + */ public void setExamplePositive(boolean pos) { isPos = pos; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -71,10 +71,6 @@ private JDialog detailPopup; - // Panel where the informations of the selected panel are rendered - - //private JPanel examplePanel; - // Text area that shows the covered positive examples private JTextArea posCoveredText; @@ -135,8 +131,8 @@ */ public void renderDetailPanel(EvaluatedDescription desc) { eval = desc; - JPanel posBox = new JPanel(new GridLayout(0,2)); - JPanel negBox = new JPanel(new GridLayout(0,2)); + JPanel posBox = new JPanel(new GridLayout(0, 2)); + JPanel negBox = new JPanel(new GridLayout(0, 2)); Box exampleBox = Box.createVerticalBox(); concept = new JTextArea("Class Description:"); concept.setEditable(false); @@ -148,12 +144,12 @@ coveredNegativeExamples.setForeground(colorRed); notCoveredNegativeExamples = new JLabel("Not Covered Negative Examples"); notCoveredNegativeExamples.setForeground(colorGreen); - conceptPanel = new JPanel(new GridLayout(0,1)); - accuracyPanel = new JPanel(new GridLayout(0,1)); - posCoveredPanel = new JPanel(new GridLayout(0,1)); - posNotCoveredPanel = new JPanel(new GridLayout(0,1)); - negCoveredPanel = new JPanel(new GridLayout(0,1)); - negNotCoveredPanel = new JPanel(new GridLayout(0,1)); + conceptPanel = new JPanel(new GridLayout(0, 1)); + accuracyPanel = new JPanel(new GridLayout(0, 1)); + posCoveredPanel = new JPanel(new GridLayout(0, 1)); + posNotCoveredPanel = new JPanel(new GridLayout(0, 1)); + negCoveredPanel = new JPanel(new GridLayout(0, 1)); + negNotCoveredPanel = new JPanel(new GridLayout(0, 1)); accuracy = new JTextArea("Accuracy:"); accuracy.setEditable(false); conceptText = new JTextArea(); @@ -178,7 +174,6 @@ //sets accuracy text area not editable accuracyText.setEditable(false); //panel for the informations of the selected concept - //examplePanel = new JPanel(new GridLayout(0,2)); //this method adds the informations for the selected concept to the panel setInformation(); @@ -225,28 +220,24 @@ JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); posLabel.setForeground(colorGreen); posCoveredPanel.add(posLabel); - //posCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } //sets the positive examples that are not covered for(Iterator<Individual> i = eval.getNotCoveredPositives().iterator(); i.hasNext();) { JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); posLabel.setForeground(colorRed); posNotCoveredPanel.add(posLabel); - //posNotCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } //sets the negative examples that are covered for(Iterator<Individual> i = eval.getCoveredNegatives().iterator(); i.hasNext();) { JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); posLabel.setForeground(colorRed); negCoveredPanel.add(posLabel); - //negCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } //sets the negative examples that are not covered for(Iterator<Individual> i = eval.getNotCoveredNegatives().iterator(); i.hasNext();) { JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); posLabel.setForeground(colorGreen); negNotCoveredPanel.add(posLabel); - //negNotCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -315,8 +315,6 @@ private JButton run; - // private JButton why; - // This is the label for the advanced button. private JLabel adv; @@ -360,7 +358,7 @@ private JTextArea hint; // This is the Panel for more details of the suggested concept private MoreDetailForSuggestedConceptsPanel detail; - OWLFrame<OWLClass> frame; + //private OWLFrame<OWLClass> frame; private URL pluginURL; /** @@ -374,7 +372,7 @@ public DLLearnerView(OWLFrame<OWLClass> current, String label, OWLClassDescriptionEditorWithDLLearnerTab dlLearner) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); mainWindow = dlLearner; - frame = current; + //frame = current; try { pluginURL = new URL("http://dl-learner.org/wiki/ProtegePlugin"); } catch (MalformedURLException e) { @@ -549,7 +547,6 @@ */ public void updateWindow() { mainWindow.getHandler().handleEditingFinished(mainWindow.getEditedObjects()); - mainWindow.dispose(); } /** * Returns all added descriptions. @@ -579,15 +576,8 @@ posPanel.unsetPosAndNegPanel(); learner.removeAll(); } + /** - * This method returns the nummers of Individuals present in the Ontology. - * @return int amount of Individuals in the Ontology - */ - public int getNrOfIndividuals() { - int counter = model.getPosVector().size(); - return counter; - } - /** * Renders the error message when an error occured. * @param s String */ @@ -615,7 +605,6 @@ * Destroys the view after the plugin is closed. */ public void dispose() { - System.out.println("hier"); run.removeActionListener(action); accept.removeActionListener(action); advanced.removeActionListener(action); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -1,3 +1,22 @@ +/** + * 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.tools.protege; import java.awt.Dimension; @@ -28,8 +47,8 @@ public OptionPanel() { setPreferredSize(new Dimension(490, 120)); - setLayout(new GridLayout(0,1)); - optionPanel = new JPanel(new GridLayout(0,2)); + setLayout(new GridLayout(0, 1)); + optionPanel = new JPanel(new GridLayout(0, 2)); minAccuracyLabel = new JLabel("minimum accuracy"); maxExecutionTimeLabel = new JLabel("maximum execution time"); nrOfConceptsLabel = new JLabel("maximum number of results"); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -41,11 +41,6 @@ private static final long serialVersionUID = 23632947283479L; - // This is the Panel here the check boxes, the labels, and the help buttons - // are in. - - //private JPanel posAndNegPanel; - // this is the Panel where the check boxes are. private JPanel posAndNegSelectPanel; @@ -93,9 +88,6 @@ // This is the Text area where the help message is displayed. private OptionPanel optionPanel; - //private JComboBox optionBox; - //private JPanel optionBoxPanel; - //private ActionHandler action; private DefaultListModel posListModel; private DefaultListModel negListModel; private JPanel examplePanel; @@ -109,6 +101,7 @@ * DLLearnerModel * @param act * ActionHandler + * @param v DLLearnerView */ public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView v) { //set layout for parent Panel @@ -191,6 +184,8 @@ /** * This method adds the check boxes, the labels and the help buttons for * positive and negative examples. + * @param posData DefaultListModel + * @param negData DefaultListModel */ public void setExampleList(DefaultListModel posData, DefaultListModel negData) { posListModel = posData; @@ -199,10 +194,18 @@ negList.setModel(negListModel); } + /** + * This method returns the pos button. + * @return JButton + */ public JButton getAddToPosPanelButton() { return addToPosExamples; } + /** + * This method returns the neg button. + * @return JButton + */ public JButton getAddToNegPanelButton() { return addToNegExamples; } @@ -226,10 +229,18 @@ } + /** + * Nothing. + * @param act ActionHandler + */ public void removeListeners(ActionHandler act) { } + /** + * Nothing. + * @param enable boolean + */ public void setCheckBoxesEnable(boolean enable) { } @@ -244,14 +255,6 @@ } /** - * This method unselect the selected check boxes after learning. - */ - public void unsetCheckBoxes() { - // after the learning the check boxes will be unset. - model.unsetJCheckBoxen(); - } - - /** * This message displays the help message after the help button is pressed. * * @param assistance String @@ -262,12 +265,17 @@ } + /** + * this method sets the example to the other list when button is pressed. + * @param toPos boolean + * @param example String + */ public void setExampleToOtherList(boolean toPos, String example) { if (toPos) { for(int i = 0; i < negListModel.size(); i++) { if(negListModel.get(i).equals(example)) { negListModel.remove(i); - for (int j = 0; j < model.getIndividualVector().size(); j++ ) { + for (int j = 0; j < model.getIndividualVector().size(); j++) { if (model.getIndividualVector().get(j).getManchesterIndividual().equals(example)) { model.getIndividualVector().get(j).setExamplePositive(true); break; @@ -281,7 +289,7 @@ for(int i = 0; i < posListModel.size(); i++) { if(posListModel.get(i).equals(example)) { posListModel.remove(i); - for (int j = 0; j < model.getIndividualVector().size(); j++ ) { + for (int j = 0; j < model.getIndividualVector().size(); j++) { if (model.getIndividualVector().get(j).getManchesterIndividual().equals(example)) { model.getIndividualVector().get(j).setExamplePositive(false); } @@ -300,8 +308,8 @@ /** * This method adds the Action listener to the help buttons. * - * @param a - * ActionHandler + * @param handle + * PosAndNegSelectPanelHandler */ public void addHelpButtonListener(PosAndNegSelectPanelHandler handle) { // adds listener to the help button for the positive examples @@ -309,19 +317,35 @@ // adds listener to the help button for the negative examples helpForNegExamples.addActionListener(handle); } - + /** + * This Method removes the listeners for the help button. + * @param a ActionHandler + */ public void removeHelpButtonListener(ActionHandler a) { helpForPosExamples.removeActionListener(a); helpForNegExamples.removeActionListener(a); } + + /** + * This method returns the option panel. + * @return OptionPanel + */ public OptionPanel getOptionPanel() { return optionPanel; } + /** + * This method returns the list of positive examples. + * @return JList posExampleList + */ public JList getPosExampleList() { return posList; } + /** + * This method returns the list of negative examples. + * @return JList negExampleList + */ public JList getNegExampleList() { return negList; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -1,3 +1,22 @@ +/** + * 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.tools.protege; import java.awt.event.ActionEvent; @@ -2,7 +21,10 @@ import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; - +/** + * This class handles the commands for the example panel. + * @author christian Koetteritzsch + * + */ public class PosAndNegSelectPanelHandler implements ActionListener, MouseListener { @@ -12,33 +34,29 @@ // This is the DLLearnerModel. -private DLLearnerModel model; +//private DLLearnerModel model; private PosAndNegSelectPanel panel; // This is the view of the DL-Learner tab. private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; /** - * This is the constructor for the action handler. - * - * @param a - * ActionHandler + * This is the constructor for the PosAndNegSelectPanelHandler. * @param m * DLLearnerModel - * @param view - * DLlearner tab - * @param i - * id if it is a subclass or an equivalent class - * @param editor OWLEditorKit + * @param v + * OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView + * @param p + * PosAndNegSelectPanel */ public PosAndNegSelectPanelHandler(DLLearnerModel m, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView v, PosAndNegSelectPanel p) { - model = m; + //model = m; panel = p; view = v; } /** * When a Button is pressed this method select the right. - * @param z ActionEvent + * @param action ActionEvent */ public void actionPerformed(ActionEvent action) { @@ -66,44 +84,9 @@ } } -/** - * select/deselect the Check boxes. - * @param i ItemEvent - */ -public void itemStateChanged(ItemEvent i) { - if (i.getItem().toString().contains("Positive")) { - for (int j = 0; j < model.getPosVector().size(); j++) { - if (i.getItem().toString().contains( - model.getPosVector().get(j).getText().toString())) { - if (!model.getPosVector().get(j).isSelected()) { - model.getPosVector().get(j).setSelected(true); - break; - } - if (model.getPosVector().get(j).isSelected()) { - model.getPosVector().get(j).setSelected(false); - break; - } - } - } - } - if (i.getItem().toString().contains("Negative")) { - for (int j = 0; j < model.getNegVector().size(); j++) { - if (i.getItem().toString().contains( - model.getNegVector().get(j).getText().toString())) { - if (!model.getNegVector().get(j).isSelected()) { - model.getNegVector().get(j).setSelected(true); - break; - } - if (model.getNegVector().get(j).isSelected()) { - model.getNegVector().get(j).setSelected(false); - break; - } - } - } - } -} + /** * Nothing happens here. * @param m MouseEvent This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |