From: <lor...@us...> - 2010-06-16 20:55:36
|
Revision: 2165 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2165&view=rev Author: lorenz_b Date: 2010-06-16 20:55:28 +0000 (Wed, 16 Jun 2010) Log Message: ----------- Continued refactoring Prot?\195?\169g?\195?\169 plugin. Rebuilt the GUI. Checking if a reasoner is selected. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-06-15 14:08:31 UTC (rev 2164) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-06-16 20:55:28 UTC (rev 2165) @@ -27,10 +27,10 @@ import java.util.TimerTask; import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; import org.protege.editor.core.ProtegeApplication; import org.protege.editor.core.ui.progress.BackgroundTask; @@ -42,18 +42,8 @@ */ public class ActionHandler implements ActionListener { - // This is the DLLearnerModel. - private final DLLearnerModel model; - - - // This is the id that checks if the equivalent class or subclass button is - // pressed in protege - // this is a boolean that checked if the advanced button was pressed or not. private boolean toggled; - // This is the Tread of the DL-Learner - private EvaluatedDescription evaluatedDescription; - // This is the view of the DL-Learner tab. private Timer timer; private SuggestionRetriever retriever; private HelpTextPanel helpPanel; @@ -63,8 +53,8 @@ private static final String HELP_BUTTON_STRING = "help"; private static final String ADD_BUTTON_STRING = "<html>ADD</html>"; private static final String ADVANCED_BUTTON_STRING = "Advanced"; - private static final String EQUIVALENT_CLASS_LEARNING_STRING = "<html>suggest equivalent class expression</html>"; - private static final String SUPER_CLASS_LEARNING_STRING = "<html>suggest super class expression</html>"; + private static final String EQUIVALENT_CLASS_LEARNING_STRING = "<html>suggest equivalent class expressions</html>"; + private static final String SUPER_CLASS_LEARNING_STRING = "<html>suggest super class expressions</html>"; private static JOptionPane optionPane; private BackgroundTask learningTask; @@ -78,14 +68,11 @@ * DLlearner tab * */ - public ActionHandler(DLLearnerModel m, DLLearnerView view) { + public ActionHandler(DLLearnerView view) { this.view = view; - this.model = m; toggled = false; helpPanel = new HelpTextPanel(view); optionPane = new JOptionPane(); - - } /** @@ -98,19 +85,19 @@ if (z.getActionCommand().equals(EQUIVALENT_CLASS_LEARNING_STRING) || z.getActionCommand().equals(SUPER_CLASS_LEARNING_STRING)) { - Manager manager = Manager.getInstance(model.getOWLEditorKit()); setLearningOptions(); - view.setBusyTaskStarted("Preparing ..."); - manager.initLearningProblem(); - manager.initLearningAlgorithm(); - view.setBusyTaskEnded(); + view.showGraphicalPanel(false); + view.getSuggestClassPanel().getSuggestionsTable().clear(); +// view.setBusyTaskStarted("Preparing ..."); +// manager.initLearningProblem(); +// manager.initLearningAlgorithm(); +// view.setBusyTaskEnded(); - learningTask = ProtegeApplication.getBackgroundTaskManager().startTask("Learning..."); - view.setLearningStarted(); - view.showHorizontalExpansionMessage(Manager.getInstance().getMinimumHorizontalExpansion(), - Manager.getInstance().getMaximumHorizontalExpansion()); +// view.setLearningStarted(); +// view.showHorizontalExpansionMessage(Manager.getInstance().getMinimumHorizontalExpansion(), +// Manager.getInstance().getMaximumHorizontalExpansion()); retriever = new SuggestionRetriever(); retriever.addPropertyChangeListener(view.getStatusBar()); @@ -119,8 +106,7 @@ } if (z.getActionCommand().equals(ADD_BUTTON_STRING)) { - Manager.getInstance().addAxiom(OWLAPIDescriptionConvertVisitor - .getOWLClassExpression(evaluatedDescription.getDescription())); + Manager.getInstance().addAxiom(view.getSuggestClassPanel().getSelectedSuggestion()); String message = "<html><font size=\"3\">class expression added</font></html>"; view.setHintMessage(message); view.setHelpButtonVisible(false); @@ -129,21 +115,16 @@ if (!toggled) { toggled = true; view.setIconToggled(toggled); - view.setExamplePanelVisible(toggled); + view.showOptionsPanel(toggled); } else { toggled = false; view.setIconToggled(toggled); - view.setExamplePanelVisible(toggled); + view.showOptionsPanel(toggled); } } if (z.toString().contains(HELP_BUTTON_STRING)) { String currentClass = Manager.getInstance().getCurrentlySelectedClassRendered(); - - //helpPanel.renderHelpTextMessage(currentClass); - //view.getLearnerView().add(); - //help = new JTextPane(); - //help.setText(helpText); optionPane.setPreferredSize(new Dimension(300, 200)); JOptionPane.showMessageDialog(view.getLearnerView(), helpPanel.renderHelpTextMessage(currentClass), "Help", JOptionPane.INFORMATION_MESSAGE); @@ -157,20 +138,10 @@ toggled = false; } - /** - * This Methode sets the evaluated class expression that is selected in the - * panel. - * - * @param desc - * evaluated descriptions - */ - public void setEvaluatedClassExpression(EvaluatedDescription desc) { - this.evaluatedDescription = desc; - } private void setLearningOptions(){ OptionPanel options = view.getOptionsPanel(); - Manager manager = Manager.getInstance(model.getOWLEditorKit()); + Manager manager = Manager.getInstance(); manager.setMaxExecutionTimeInSeconds(options.getMaxExecutionTimeInSeconds()); manager.setMaxNrOfResults(options.getMaxNumberOfResults()); manager.setNoisePercentage(options.getNoise()); @@ -196,6 +167,26 @@ protected List<? extends EvaluatedDescription> doInBackground() throws Exception { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + view.setBusyTaskStarted("Preparing ..."); + } + }); + + Manager manager = Manager.getInstance(); + manager.initLearningProblem(); + manager.initLearningAlgorithm(); + view.setBusyTaskEnded(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + view.setLearningStarted(); + view.showHorizontalExpansionMessage(Manager.getInstance().getMinimumHorizontalExpansion(), + Manager.getInstance().getMaximumHorizontalExpansion()); + } + }); + timer = new Timer(); timer.schedule(new TimerTask(){ int progress = 0; @@ -210,7 +201,7 @@ } } - }, 1000, 1000); + }, 1000, 500); Manager.getInstance().startLearning(); @@ -235,7 +226,6 @@ } private void updateList(final List<? extends EvaluatedDescription> result) { - model.setSuggestList(result); view.setSuggestions(result); view.showHorizontalExpansionMessage(Manager.getInstance().getMinimumHorizontalExpansion(), Manager.getInstance().getMaximumHorizontalExpansion()); Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2010-06-15 14:08:31 UTC (rev 2164) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2010-06-16 20:55:28 UTC (rev 2165) @@ -1,597 +0,0 @@ -/** - * Copyright (C) 2007-2009, 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.net.MalformedURLException; -import java.net.URL; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.swing.DefaultListModel; - -import org.dllearner.algorithms.celoe.CELOE; -import org.dllearner.core.ComponentInitException; -import org.dllearner.core.ComponentManager; -import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.LearningProblem; -import org.dllearner.core.LearningProblemUnsupportedException; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.kb.OWLAPIOntology; -import org.dllearner.learningproblems.ClassLearningProblem; -import org.dllearner.reasoning.ProtegeReasoner; -import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; -import org.protege.editor.core.Disposable; -import org.protege.editor.owl.OWLEditorKit; -import org.protege.editor.owl.model.event.EventType; -import org.protege.editor.owl.model.event.OWLModelManagerChangeEvent; -import org.protege.editor.owl.model.event.OWLModelManagerListener; -import org.semanticweb.owlapi.apibinding.OWLManager; -import org.semanticweb.owlapi.model.AddAxiom; -import org.semanticweb.owlapi.model.OWLAxiom; -import org.semanticweb.owlapi.model.OWLClassExpression; -import org.semanticweb.owlapi.model.OWLDataFactory; -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyChangeException; -import org.semanticweb.owlapi.model.OWLOntologyManager; -import org.semanticweb.owlapi.reasoner.InconsistentOntologyException; - -/** - * This Class provides the necessary methods to learn Concepts from the - * DL-Learner. - * - * @author Christian Koetteritzsch - * - */ -public class DLLearnerModel implements Runnable, OWLModelManagerListener, Disposable{ - - // The Sting is for components that are available in the DL-Learner - - private final String[] componenten = { "org.dllearner.kb.OWLFile", - "org.dllearner.reasoning.OWLAPIReasoner", - "org.dllearner.reasoning.FastInstanceChecker", - "org.dllearner.reasoning.ProtegeReasoner", - "org.dllearner.reasoning.FastRetrievalReasoner", - "org.dllearner.algorithms.RandomGuesser", - "org.dllearner.algorithms.refinement.ROLearner", - "org.dllearner.algorithms.celoe.CELOE", - "org.dllearner.algorithms.gp.GP", "org.dllearner.learningproblems.PosOnlyLP", - "org.dllearner.learningproblems.PosNegLPStandard", "org.dllearner.learningproblems.ClassLearningProblem"}; - - // Component Manager that manages the components of the DL-Learner - - private final ComponentManager cm; - - private static final String EQUIVALENT_CLASS_AXIOM_STRING = "equivalent class"; - private static final String SUPER_CLASS_AXIOM_STRING = "super class"; - private static final String EQUIVALENT_CLASS_LEARNING = "equivalence"; - private static final String SUPER_CLASS_LEARNING = "superClass"; - - // The View of the DL-Learner Plugin - - - // The Learning problem that is used to learn new concepts - - private LearningProblem lp; - - // This boolean is for clearing the suggest Panel - - private boolean alreadyLearned = false; - - // This is the learning algorithm - - private LearningAlgorithm la = null; - - // Necessary to get the currently loaded Ontology - - private final OWLEditorKit editor; - - // The Reasoner which is used to learn - - private ProtegeReasoner reasoner; - - // A Set of Descriptions in OWL Syntax which the DL-Learner suggested - - private final Set<OWLClassExpression> owlDescription; - - // The most fitting Description in OWL Syntax which the DL-Learner suggested - - private OWLClassExpression desc; - - // String to distinguish between Equivalent classes and sub classes - - private String id; - - // The new Concept which is learned by the DL-Learner - - private OWLClassExpression newConceptOWLAPI; - - // The old concept that is chosen in Protege - - private OWLClassExpression oldConceptOWLAPI; - - // A Set of Descriptions in OWL Syntax which the DL-Learner suggested - - private final Set<OWLClassExpression> ds; - - // The model for the suggested Descriptions - - private final DefaultListModel suggestModel; - - // The Individuals of the Ontology - - private Set<Individual> individual; - // The error message which is rendered when an error occured - - - // This is the new axiom which will be added to the Ontology - - private OWLAxiom axiomOWLAPI; - - // This is necessary to get the details of the suggested concept - - private final Set<KnowledgeSource> sources; - private boolean hasIndividuals; - private NamedClass currentConcept; - private Set<String> ontologieURI; - private final boolean ontologyConsistent; - private final DLLearnerView view; - - // This is a List of evaluated descriptions to get more information of the - // suggested concept - private List<? extends EvaluatedDescription> evalDescriptions; - private boolean isReasonerSet; - private boolean knowledgeSourceIsUpdated; - - /** - * This is the constructor for DL-Learner model. - * - * @param editorKit - * Editor Kit to get the currently loaded Ontology - * @param view - * current view of the DL-Learner tab - */ - public DLLearnerModel(OWLEditorKit editorKit, DLLearnerView view) { - editor = editorKit; - isReasonerSet = false; - this.view = view; - ontologyConsistent = true; - knowledgeSourceIsUpdated = false; - owlDescription = new HashSet<OWLClassExpression>(); - ComponentManager.setComponentClasses(componenten); - cm = ComponentManager.getInstance(); - ds = new HashSet<OWLClassExpression>(); - suggestModel = new DefaultListModel(); - ontologieURI = new HashSet<String>(); - sources = new HashSet<KnowledgeSource>(); - editor.getOWLModelManager().addListener(this); - } - - /** - * Sets the ID if an equivalent or a superclass must be suggested. - * @param d ID if it is an equivalent or a superclass - */ - public void setID(String d) { - this.id = d; - } - /** - * This method initializes the SimpleSuggestionLearningAlgorithm and adds - * the suggestions to the suggest panel model. - */ - public void initReasoner() { - alreadyLearned = false; - setKnowledgeSource(); - setReasoner(); - } - - /** - * This Method returns a List of evaluated descriptions suggested by the - * DL-Learner. - * - * @return list of evaluated descriptions - */ - public List<? extends EvaluatedDescription> getEvaluatedDescriptionList() { - return evalDescriptions; - } - - /** - * This method sets the knowledge source for the learning process. Only - * OWLAPIOntology will be available. - */ - public void setKnowledgeSource() { - sources.clear(); - Set<OWLOntology> ontologieSet = editor.getModelManager().getActiveOntologies(); - for(OWLOntology onto : ontologieSet) { - sources.add(new OWLAPIOntology(onto)); - } - } - - /** - * This method sets the reasoner. Only - * FastInstanceChecker is available. - */ - public void setReasoner() { - this.reasoner = cm.reasoner(ProtegeReasoner.class, sources); - reasoner.setOWLReasoner(editor.getOWLModelManager().getReasoner()); - reasoner.setProgressMonitor(view.getStatusBar()); -// this.reasoner = new ProtegeReasoner(sources, editor.getOWLModelManager().getReasoner()); - try { - reasoner.init(); - reasoner.isSatisfiable(); - view.setIsInconsistent(false); - isReasonerSet = true; - }catch (ComponentInitException e) { - view.setIsInconsistent(true); - } catch (InconsistentOntologyException incon) { - view.setIsInconsistent(true); - } - } - - /** - * This method returns the fast instance checker reasoner. - * @return fast instance checker reasoner - */ - public ProtegeReasoner getReasoner() { - return reasoner; - } - - /** - * This method returns the current concept. - * @return current concept - */ - public NamedClass getCurrentConcept() { - return currentConcept; - } - /** - * This method sets the Learning problem for the learning process. - * PosNegDefinitonLp for equivalent classes and PosNegInclusionLP for super - * classes. - */ - public void setLearningProblem() { - lp = cm.learningProblem(ClassLearningProblem.class, reasoner); - URL currentConceptURL = null; - try { - currentConceptURL = new URL(currentConcept.toString()); - } catch (MalformedURLException e1) { - String error = "<html><font size=\"3\" color=\"red\">Cannot convert to URL.</font></html>"; - view.setHintMessage(error); - e1.printStackTrace(); - } - cm.applyConfigEntry(lp, "classToDescribe", currentConceptURL); - if (id.equals(EQUIVALENT_CLASS_AXIOM_STRING)) { - // sets the learning problem to PosNegDefinitionLP when the - // dllearner should suggest an equivalent class - cm.applyConfigEntry(lp, "type", EQUIVALENT_CLASS_LEARNING); - } - if (id.equals(SUPER_CLASS_AXIOM_STRING)) { - // sets the learning problem to PosNegInclusionLP when the dllearner - // should suggest a subclass - cm.applyConfigEntry(lp, "type", SUPER_CLASS_LEARNING); - } - try { - lp.init(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } - } - - /** - * This method sets the learning algorithm for the learning process. - */ - public void setLearningAlgorithm() { - try { - this.la = cm.learningAlgorithm(CELOE.class, lp, - reasoner); - } catch (LearningProblemUnsupportedException e) { - e.printStackTrace(); - } - - //Config options set in the gui. - //config option if all is used for suggestions - cm.applyConfigEntry(la, "useAllConstructor", view.getOptionsPanel().isUseAllQuantor()); - //config option if exists is used for suggestions - cm.applyConfigEntry(la, "useExistsConstructor", view.getOptionsPanel().isUseExistsQuantor()); - //config option if hasValue is used for suggestions - cm.applyConfigEntry(la, "useHasValueConstructor", view.getOptionsPanel().isUseHasValue()); - //config option if negation is used for suggestions - cm.applyConfigEntry(la, "useNegation", view.getOptionsPanel().isUseNegation()); - //config option if cardinalitylimits is used for suggestions - cm.applyConfigEntry(la, "useCardinalityRestrictions", view.getOptionsPanel().isUseCardinalityRestrictions()); - if(view.getOptionsPanel().isUseCardinalityRestrictions()) { - //config option to set the cardinalityrestrictions - cm.applyConfigEntry(la, "cardinalityLimit", view.getOptionsPanel().getCardinalityLimit()); - } - //config option to set the noise - cm.applyConfigEntry(la, "noisePercentage", view.getOptionsPanel().getNoise()); - //config option to set the maximum execution time - cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view - .getOptionsPanel() - .getMaxExecutionTimeInSeconds()); - try { - // initializes the learning algorithm - la.init(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } - alreadyLearned = true; - } - - /** - * Starts the learning algorithm. - */ - public void run() { - la.start(); - } - - /** - * This method sets the positive examples for learning. - * @param ind Set of Individuals - */ - public void setIndividuals(Set<Individual> ind) { - individual = ind; - } - - /** - * This method sets the uri sting for the currently used - * for learning. - * @param uri Set of uris - */ - public void setOntologyURIString(Set<String> uri) { - this.ontologieURI = uri; - } - /** - * This Method checks if the selected class has any individuals. - * - * @return boolean hasIndividuals - */ - public boolean hasIndividuals() { - return hasIndividuals; - } - - /** - * Sets if the ontology has individuals. - * @param has boolean if concept has Individuals - */ - public void setHasIndividuals(boolean has) { - this.hasIndividuals = has; - } - - /** - * This method returns the current learning algorithm that is used to learn - * new concepts. - * - * @return Learning algorithm that is used for learning concepts. - */ - public LearningAlgorithm getLearningAlgorithm() { - return la; - } - - /** - * This method returns a set of concepts that are learned by the DL-Learner. - * They are already converted into the OWLClassExpression format. - * - * @return Set of learned concepts in OWLClassExpression format - */ - public Set<OWLClassExpression> getNewOWLDescription() { - return owlDescription; - } - - /** - * This method returns the old concept which is chosen in protege in - * OWLClassExpression format. - * - * @return Old Concept in OWLClassExpression format. - */ - public OWLClassExpression getOldConceptOWLAPI() { - oldConceptOWLAPI = OWLAPIDescriptionConvertVisitor - .getOWLClassExpression(currentConcept); - return oldConceptOWLAPI; - } - - /** - * This method returns the currently learned description in OWLClassExpression - * format. - * - * @return currently used description in OWLClassExpression format - */ - public OWLClassExpression getSolution() { - return desc; - } - - /** - * This method gets a description learned by the DL-Learner an converts it - * to the OWLClassExpression format. - * - * @param desc - * Description learned by the DL-Learner - */ - private void setNewConceptOWLAPI(Description des) { - // converts DL-Learner description into an OWL API Description - newConceptOWLAPI = OWLAPIDescriptionConvertVisitor - .getOWLClassExpression(des); - ds.add(newConceptOWLAPI); - owlDescription.add(newConceptOWLAPI); - this.desc = newConceptOWLAPI; - } - - /** - * This methode returns the Model for the suggested Concepts. - * - * @return DefaultListModel - */ - public DefaultListModel getSuggestModel() { - return suggestModel; - } - - /** - * This method stores the new concept learned by the DL-Learner in the - * Ontology. - * - * @param descript - * Description learn by the DL-Learner - */ - public void changeDLLearnerDescriptionsToOWLDescriptions( - Description descript) { - ds.clear(); - owlDescription.clear(); - setNewConceptOWLAPI(descript); - oldConceptOWLAPI = OWLAPIDescriptionConvertVisitor - .getOWLClassExpression(currentConcept); - ds.add(oldConceptOWLAPI); - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - - OWLDataFactory factory = manager.getOWLDataFactory(); - if (id.equals(EQUIVALENT_CLASS_AXIOM_STRING)) { - axiomOWLAPI = factory.getOWLEquivalentClassesAxiom(ds); - } else { - axiomOWLAPI = factory.getOWLSubClassOfAxiom(oldConceptOWLAPI, - newConceptOWLAPI); - } - OWLOntology onto = editor.getModelManager().getActiveOntology(); - AddAxiom axiom = new AddAxiom(onto, axiomOWLAPI); - try { - // adds the new concept to the ontology - manager.applyChange(axiom); - } catch (OWLOntologyChangeException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * This method gets the status if the DL-Learner has already learned. It is - * only for reseting the suggest panel. - * - * @return boolean if the learner has already learned - */ - public boolean getAlreadyLearned() { - return alreadyLearned; - } - - /** - * This method sets the suggestion list. - * - * @param list - * List(EvaluatedDescription) - */ - public void setSuggestList(List<? extends EvaluatedDescription> list) { - evalDescriptions = list; - } - - /** - * This method returns the Strings of the Ontology uri's that are currently used. - * @return ontologieURI - */ - public Set<String> getOntologyURIString() { - return ontologieURI; - } - /** - * This method returns a boolean if an ontology is inconsistent. - * @return ontologyInconsistent - */ - public boolean getOntologyConsistent() { - return ontologyConsistent; - } - - /** - * This sets the current concept. - * @param current currently selected class - */ - public void setCurrentConcept(NamedClass current) { - this.currentConcept = current; - } - - /** - * This method returns a set of individuals belonging to the - * currently selected class. - * @return the individual - */ - public Set<Individual> getIndividual() { - return individual; - } - - /** - * This method returns if the ID is an equivalent or a superclass. - * @return id if it is an equivalent or superclass - */ - public String getID() { - return id; - } - - /** - * Returns boolean if reasoner is already set. - * @return isReasonerSet - */ - public boolean isReasonerSet() { - return isReasonerSet; - } - - /** - * This method returns the currently selected class description as an evaluated description. - * @param index which class descriptions is selected - * @return selected class description - */ - public EvaluatedDescription getCurrentlySelectedClassDescription(int index) { - return evalDescriptions.get(index); - } - - /** - * This method sets if the knowledge source is updated or not. - * @param isUpdated boolean if knowledge source is updated - */ - public void setKnowledgeSourceIsUpdated(boolean isUpdated) { - knowledgeSourceIsUpdated = isUpdated; - } - - /** - * This methode returns a boolean if the knowledge - * source is updated. - * @return boolean if knowledge source is updated - */ - public boolean getIsKnowledgeSourceIsUpdated() { - return knowledgeSourceIsUpdated; - } - - public OWLEditorKit getOWLEditorKit() { - return editor; - } - - @Override - public void handleChange(OWLModelManagerChangeEvent event) { - if(event.isType(EventType.REASONER_CHANGED)){ - System.out.println("Current reasoner changed."); - setKnowledgeSource(); - setReasoner(); - } - } - - @Override - public void dispose() throws Exception { - editor.getOWLModelManager().removeListener(this); - - } -} - - Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-06-15 14:08:31 UTC (rev 2164) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-06-16 20:55:28 UTC (rev 2165) @@ -29,9 +29,7 @@ import java.awt.event.ActionListener; import java.net.URL; import java.util.List; -import java.util.Set; -import javax.swing.DefaultListModel; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JComponent; @@ -42,8 +40,8 @@ import javax.swing.JToggleButton; import org.dllearner.core.EvaluatedDescription; +import org.dllearner.tools.ore.LearningManager.LearningType; import org.protege.editor.owl.OWLEditorKit; -import org.semanticweb.owlapi.model.OWLClassExpression; /** * This class is responsible for the view of the dllearner. It renders the * output for the user and is the graphical component of the plugin. @@ -51,77 +49,68 @@ * @author Christian Koetteritzsch * */ -public class DLLearnerView { +public class DLLearnerView extends JPanel{ private static final long serialVersionUID = 624829578325729385L; //TODO: gucken wie geht private HyperLinkHandler hyperHandler; // this is the Component which shows the view of the dllearner - private final JComponent learner; + private JComponent learner; // Accept button to add the learned concept to the owl - private final JButton accept; + private JButton addButton; // Runbutton to start the learning algorithm - private final JButton run; + private JButton runButton; // This is the label for the advanced button. - private final JLabel adv; + private JLabel advancedLabel; // Advanced Button to activate/deactivate the example select panel - private final JToggleButton advanced; + private JToggleButton advancedButton; // Action Handler that manages the Button actions - private final ActionHandler action; + private ActionHandler actionHandler; - // This is the model of the dllearner plugin which includes all data - private final DLLearnerModel model; - // Panel for the suggested concepts private SuggestClassPanel sugPanel; // Selection panel for the positive and negative examples - private final OptionPanel posPanel; + private OptionPanel optionsPanel; // Picture for the advanced button when it is not toggled - private final ImageIcon icon; + private ImageIcon icon; // Picture of the advanced button when it is toggled - private final JPanel addButtonPanel; - private final JTextPane wikiPane; - private final ImageIcon toggledIcon; + private JTextPane wikiPane; + private ImageIcon toggledIcon; private ImageIcon helpIcon; - private final JTextPane hint; + private JTextPane hint; private JButton helpButton; - private final JPanel runPanel; - private final JPanel advancedPanel; + private JPanel advancedPanel; private JPanel hintPanel; private boolean isInconsistent; // This is the Panel for more details of the suggested concept - private final MoreDetailForSuggestedConceptsPanel detail; - private ReadingOntologyThread readThread; - private final OWLEditorKit editorKit; - private final JPanel learnerPanel; - private final JScrollPane learnerScroll; - private static final int SCROLL_SPEED = 10; + private MoreDetailForSuggestedConceptsPanel detail; + private OWLEditorKit editorKit; + private JScrollPane learnerScroll; + private static final int SCROLL_SPEED = 10; private static final int WIDTH = 575; private static final int HEIGHT = 350; private static final int OPTION_HEIGHT = 400; private static final int SCROLL_WIDTH = 600; private static final int SCROLL_HEIGHT = 400; private boolean toogled = false; - private String labels; - private int individualSize; private SuggestClassPanelHandler sugPanelHandler; private StatusBar statusBar; private static final String WIKI_STRING = "<html><font size=\"3\">See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">DL-Learner plugin page</a> for an introduction.</font></html>"; @@ -134,63 +123,7 @@ */ public DLLearnerView(OWLEditorKit editor) { editorKit = editor; - labels = ""; - individualSize = 0; - hyperHandler = new HyperLinkHandler(); - model = new DLLearnerModel(editorKit, this); - sugPanel = new SuggestClassPanel(model, this); - learnerPanel = new JPanel(); - hintPanel = new JPanel(new FlowLayout()); - learnerPanel.setLayout(new BorderLayout()); - learnerScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - action = new ActionHandler(model, this); - wikiPane = new JTextPane(); - wikiPane.setContentType("text/html"); - wikiPane.setBackground(learnerScroll.getBackground()); - wikiPane.setEditable(false); - wikiPane.setText(WIKI_STRING); - wikiPane.addHyperlinkListener(hyperHandler); - URL iconUrl = this.getClass().getResource("arrow.gif"); - icon = new ImageIcon(iconUrl); - URL toggledIconUrl = this.getClass().getResource("arrow2.gif"); - toggledIcon = new ImageIcon(toggledIconUrl); - adv = new JLabel("<html>Advanced Settings</html>"); - advanced = new JToggleButton(icon); - advanced.setVisible(true); - advancedPanel = new JPanel(); - run = new JButton(); - URL helpIconUrl = this.getClass().getResource("Help-16x16.png"); - helpIcon = new ImageIcon(helpIconUrl); - helpButton = new JButton(helpIcon); - helpButton.setPreferredSize(new Dimension(20, 20)); - helpButton.setName("help"); - helpButton.addActionListener(action); - runPanel = new JPanel(new FlowLayout()); - accept = new JButton("<html>ADD</html>"); - addButtonPanel = new JPanel(new BorderLayout()); - statusBar = new StatusBar(); - statusBar.setBackground(learnerScroll.getBackground()); - this.setStatusBarVisible(false); - hint = new JTextPane(); - hint.setBackground(learnerScroll.getBackground()); - hint.setContentType("text/html"); - hint.setEditable(false); -// hint.setText("<html><font size=\"3\">To get suggestions for class expression, please click the button above.</font></html>"); - learner = new JPanel(); - advanced.setSize(20, 20); - learner.setLayout(new GridBagLayout()); - accept.setPreferredSize(new Dimension(70, 40)); - run.setPreferredSize(new Dimension(260, 30)); - advanced.setName("Advanced"); - learnerScroll.setPreferredSize(new Dimension(SCROLL_WIDTH, SCROLL_HEIGHT)); - learnerScroll.getVerticalScrollBar().setUnitIncrement(SCROLL_SPEED); - posPanel = new OptionPanel(); - detail = new MoreDetailForSuggestedConceptsPanel(model); - sugPanelHandler = new SuggestClassPanelHandler(this, model, action); - sugPanel.getSuggestionsTable().getSelectionModel().addListSelectionListener(sugPanelHandler); - this.addAcceptButtonListener(this.action); - this.addRunButtonListener(this.action); - this.addAdvancedButtonListener(this.action); + createUI(); } @@ -206,123 +139,162 @@ * @return PosAndNegSelectPanel */ public OptionPanel getOptionsPanel() { - return posPanel; + return optionsPanel; } - /** - * This Method renders the view of the plugin. - * @param label label if it is an equivalent or superclass - */ - public void makeView(String label) { - run.setEnabled(false); - - helpButton.setVisible(false); - hint.setForeground(Color.BLACK); -// hint.setText("<html><font size=\"3\">To get suggestions for class expression, please click the button above.</font></html>"); - String currentConcept = editorKit.getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass().toString(); - if(!labels.equals(currentConcept) || individualSize != editorKit.getModelManager().getActiveOntology().getIndividualsInSignature(true).size()) { - if(individualSize != editorKit.getModelManager().getActiveOntology().getIndividualsInSignature(true).size()) { - model.setKnowledgeSourceIsUpdated(true); - } else { - model.setKnowledgeSourceIsUpdated(false); - } - readThread = new ReadingOntologyThread(editorKit, this, model); - } - if(!readThread.isAlive() && !labels.equals(currentConcept)|| individualSize != editorKit.getModelManager().getActiveOntology().getIndividualsInSignature(true).size()) { - readThread.start(); - } - if(readThread.hasIndividuals()) { - run.setEnabled(true); - } - individualSize = editorKit.getModelManager().getActiveOntology().getIndividualsInSignature(true).size(); - labels = currentConcept; - run.setText("<html>suggest " + label + " expression</html>"); + + private void createUI(){ + setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); - learner.remove(detail); - model.setID(label); - runPanel.add(BorderLayout.WEST, run); - runPanel.add(BorderLayout.EAST, wikiPane); + hyperHandler = new HyperLinkHandler(); + actionHandler = new ActionHandler(this); + learnerScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + learnerScroll.setPreferredSize(new Dimension(SCROLL_WIDTH, SCROLL_HEIGHT)); + learnerScroll.getVerticalScrollBar().setUnitIncrement(SCROLL_SPEED); + + JPanel addButtonPanel = new JPanel(new BorderLayout()); + addButton = new JButton("<html>ADD</html>"); + addButton.setPreferredSize(new Dimension(70, 40)); + addButton.setEnabled(false); + c.gridx = 2; + c.gridy = 1; + c.weightx = 0.0; + c.weighty = 0.0; + c.gridwidth = 1; + addButtonPanel.add("North", addButton); + add(addButtonPanel, c); + + JPanel runButtonPanel = new JPanel(new FlowLayout()); + runButton = new JButton(); + runButton.setPreferredSize(new Dimension(260, 30)); + runButton.setEnabled(false); + runButtonPanel.add(BorderLayout.WEST, runButton); + wikiPane = new JTextPane(); + wikiPane.setContentType("text/html"); + wikiPane.setBackground(learnerScroll.getBackground()); + wikiPane.setEditable(false); + wikiPane.setText(WIKI_STRING); + wikiPane.addHyperlinkListener(hyperHandler); + runButtonPanel.add(BorderLayout.EAST, wikiPane); c.anchor = GridBagConstraints.FIRST_LINE_START; c.gridx = 0; c.weightx = 0.0; c.weighty = 0.0; c.gridy = 0; c.gridwidth = 3; - learner.add(runPanel, c); + add(runButtonPanel, c); - sugPanel.setSuggestList(new DefaultListModel()); + sugPanel = new SuggestClassPanel(editorKit); + sugPanelHandler = new SuggestClassPanelHandler(this); + sugPanel.getSuggestionsTable().getSelectionModel().addListSelectionListener(sugPanelHandler); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 1; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = 2; - sugPanel.setSuggestList(model.getSuggestModel()); - learner.add(sugPanel, c); + add(sugPanel, c); - accept.setEnabled(false); - c.gridx = 2; - c.gridy = 1; - c.weightx = 0.0; - c.weighty = 0.0; - c.gridwidth = 1; - addButtonPanel.add("North", accept); - learner.add(addButtonPanel, c); - + statusBar = new StatusBar(); + statusBar.setBackground(learnerScroll.getBackground()); + showStatusBar(false); c.fill = GridBagConstraints.WEST; c.weightx = 0.0; c.weighty = 0.0; c.gridx = 0; c.gridy = 2; - learner.add(statusBar, c); + add(statusBar, c); + hintPanel = new JPanel(new FlowLayout()); + hint = new JTextPane(); + hint.setBackground(learnerScroll.getBackground()); + hint.setContentType("text/html"); + hint.setEditable(false); + hintPanel.add(BorderLayout.CENTER, hint); + URL helpIconUrl = this.getClass().getResource("Help-16x16.png"); + helpIcon = new ImageIcon(helpIconUrl); + helpButton = new JButton(helpIcon); + helpButton.setName("help"); + helpButton.addActionListener(actionHandler); + helpButton.setPreferredSize(new Dimension(30, 30)); + helpButton.setVisible(false); + hintPanel.add(BorderLayout.EAST, helpButton); c.fill = GridBagConstraints.BOTH; c.weightx = 0.0; c.weighty = 0.0; c.gridx = 0; c.gridy = 3; - helpButton.setPreferredSize(new Dimension(30, 30)); - hintPanel.add(BorderLayout.CENTER, hint); - hintPanel.add(BorderLayout.EAST, helpButton); - learner.add(hintPanel, c); + add(hintPanel, c); - advancedPanel.add(advanced); - advancedPanel.add(adv); - advanced.setIcon(icon); - advanced.setSelected(false); + detail = new MoreDetailForSuggestedConceptsPanel(editorKit); +// detail.unsetPanel(); + detail.setVisible(false); + c.fill = GridBagConstraints.VERTICAL; + c.gridx = 0; + c.gridy = 4; + c.weightx = 0.0; + c.weighty = 0.0; + add(detail, c); + + advancedPanel = new JPanel(); + URL iconUrl = this.getClass().getResource("arrow.gif"); + icon = new ImageIcon(iconUrl); + URL toggledIconUrl = this.getClass().getResource("arrow2.gif"); + toggledIcon = new ImageIcon(toggledIconUrl); + advancedLabel = new JLabel("<html>Advanced Settings</html>"); + advancedPanel.add(advancedLabel); + advancedButton = new JToggleButton(icon); + advancedButton.setName("Advanced"); + advancedButton.setIcon(icon); + advancedButton.setSelected(false); + advancedButton.setVisible(true); + advancedButton.setSize(20, 20); + advancedPanel.add(advancedButton); c.fill = GridBagConstraints.NONE; c.gridx = 0; c.weightx = 0.0; c.weighty = 0.0; - c.gridy = 4; - learner.add(advancedPanel, c); + c.gridy = 5; + add(advancedPanel, c); - posPanel.setVisible(false); + optionsPanel = new OptionPanel(); + optionsPanel.setVisible(false); c.fill = GridBagConstraints.BOTH; c.gridx = 0; - c.gridy = 5; + c.gridy = 6; c.weightx = 0.0; c.weighty = 0.0; c.gridwidth = 3; - learner.add(posPanel, c); + add(optionsPanel, c); + this.addAcceptButtonListener(this.actionHandler); + this.addRunButtonListener(this.actionHandler); + this.addAdvancedButtonListener(this.actionHandler); - detail.unsetPanel(); - learnerPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT)); - detail.setVisible(false); - isInconsistent = false; - - hint.setVisible(true); - action.resetToggled(); - detail.setVisible(true); - sugPanel.setVisible(true); - learnerScroll.setViewportView(learner); - this.getSuggestClassPanel().getSuggestModel().clear(); - + learnerScroll.setViewportView(this); } + public void reset(){ + String learningType = ""; + if(Manager.getInstance().getLearningType() == LearningType.EQUIVALENT){ + learningType = "equivalent class"; + } else { + learningType = "super class"; + } + runButton.setText("<html>suggest " + learningType + " expressions</html>"); + sugPanel.getSuggestionsTable().clear(); + showGraphicalPanel(false); + setHintMessage(""); + setHelpButtonVisible(false); + + } + + public JComponent getView(){ + return learnerScroll; + } + /** * This method sets the right icon for the advanced Panel. * @param toggled boolean @@ -330,67 +302,29 @@ public void setIconToggled(boolean toggled) { this.toogled = toggled; if (this.toogled) { - advanced.setIcon(toggledIcon); - learnerPanel.setPreferredSize(new Dimension(WIDTH, OPTION_HEIGHT)); - learnerScroll.setPreferredSize(new Dimension(SCROLL_WIDTH, SCROLL_HEIGHT)); + advancedButton.setIcon(toggledIcon); +// learnerPanel.setPreferredSize(new Dimension(WIDTH, OPTION_HEIGHT)); +// learnerScroll.setPreferredSize(new Dimension(SCROLL_WIDTH, SCROLL_HEIGHT)); } if (!this.toogled) { - advanced.setIcon(icon); - learnerPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT)); - learnerScroll.setPreferredSize(new Dimension(SCROLL_WIDTH, SCROLL_HEIGHT)); + advancedButton.setIcon(icon); +// learnerPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT)); +// learnerScroll.setPreferredSize(new Dimension(SCROLL_WIDTH, SCROLL_HEIGHT)); } } + /** - * This methode returns the help button. - * @return help button - */ - public JButton getHelpButton() { - return helpButton; - } - /** * This method sets the status bar visible when learning * is started. */ - public void setStatusBarVisible(boolean b) { - statusBar.setVisible(b); + public void showStatusBar(boolean show) { + statusBar.setVisible(show); } - /** - * This method enables the GraphicalCoveragePanel after a class expression is - * selected from the list. - */ - public void setGraphicalPanel() { - GridBagConstraints c = new GridBagConstraints(); - learner.remove(posPanel); - learner.remove(advancedPanel); - detail.setVisible(true); - - c.fill = GridBagConstraints.NONE; - c.gridwidth = GridBagConstraints.REMAINDER; - c.anchor = GridBagConstraints.LINE_START; - c.gridx = 0; - c.gridy = 4; - c.weightx = 0.0; - c.weighty = 0.0; - learner.add(detail, c); - - - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.LINE_START; - c.gridwidth = GridBagConstraints.REMAINDER; - c.gridx = 0; - c.gridy = 5; - learner.add(advancedPanel, c); - - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.LINE_START; - c.gridx = 0; - c.gridy = 6; - c.gridwidth = GridBagConstraints.REMAINDER; - learner.add(posPanel, c); - - learnerScroll.setPreferredSize(new Dimension(SCROLL_WIDTH, SCROLL_HEIGHT)); - learnerScroll.setViewportView(learner); + + public void showGraphicalPanel(boolean show){ + detail.setVisible(show); } + /** * This Method changes the hint message. * @param message String hintmessage @@ -411,26 +345,22 @@ * Sets the panel to select/deselect the examples visible/invisible. * @param visible boolean */ - public void setExamplePanelVisible(boolean visible) { - posPanel.setVisible(visible); + public void showOptionsPanel(boolean show) { + optionsPanel.setVisible(show); } + + public void showHintMessagePanel(boolean show){ + hintPanel.setVisible(show); + } /** * Returns the AddButton. * @return JButton */ public JButton getAddButton() { - return accept; + return addButton; } - /** - * Returns all added descriptions. - * @return Set(OWLClassExpression) - */ - public Set<OWLClassExpression> getSolutions() { - - return model.getNewOWLDescription(); - } /** * This method unsets all results after closing the plugin. @@ -440,25 +370,14 @@ sugPanel.getSuggestionsTable().clear(); learner.removeAll(); sugPanel = null; - model.getSuggestModel().clear(); - model.getIndividual().clear(); - model.dispose(); } - /** - * Returns the last added description. - * @return OWLClassExpression - */ - public OWLClassExpression getSolution() { - return model.getSolution(); - } /** * Destroys everything in the view after the plugin is closed. */ public void unsetEverything() { - run.setEnabled(true); - model.getNewOWLDescription().clear(); + runButton.setEnabled(true); learner.removeAll(); } @@ -466,21 +385,27 @@ * This Method returns the panel for more details for the chosen concept. * @return MoreDetailForSuggestedConceptsPanel */ - public MoreDetailForSuggestedConceptsPanel getMoreDetailForSuggestedConceptsPanel() { + public MoreDetailForSuggestedConceptsPanel getGraphicalPanel() { return detail; } - /** - * This method returns the run button. - * @return JButton - */ - public JButton getRunButton() { - return run; + + public void setLearningEnabled(){ + runButton.setEnabled(true); + setHintMessage("<html><font size=\"3\">To get suggestions for class descriptions," + + " please click the button above.</font></html>"); } + public void showNoInstancesMessage() { + String message = "<html><font size=\"3\" color=\"red\">There are no instances for " + + Manager.getInstance().getCurrentlySelectedClassRendered() + + " available. Please insert some instances.</font></html>"; + setHintMessage(message); + } + /** * This method sets if ontology is inconsistent or not. - * @param isIncon boolean if ontology is consisten + * @param isIncon boolean if ontology is consistent */ public void setIsInconsistent(boolean isIncon) { this.isInconsistent = isIncon; @@ -499,7 +424,7 @@ * @param a ActionListener */ public void addRunButtonListener(ActionListener a) { - run.addActionListener(a); + runButton.addActionListener(a); } /** @@ -507,7 +432,7 @@ * @param a ActionListener */ public void addAcceptButtonListener(ActionListener a) { - accept.addActionListener(a); + addButton.addActionListener(a); } /** @@ -515,14 +440,14 @@ * @param a ActionListener */ public void addAdvancedButtonListener(ActionListener a) { - advanced.addActionListener(a); + advancedButton.addActionListener(a); } /** * This method sets the run button enable after learning. */ public void showAlgorithmTerminatedMessage() { - this.setStatusBarVisible(false); + this.showStatusBar(false); String message = "<html><font size=\"3\" color=\"black\">Learning successful. All expressions up to length " + (Manager.getInstance().getMinimumHorizontalExpansion()-1) + " and some expressions up to <br>length " @@ -534,8 +459,7 @@ } else { message +="<br>To view details about why a class expression was suggested, please click on it.</font><html>"; } - run.setEnabled(true); - // start the algorithm and print the best concept found; + runButton.setEnabled(true); this.setHintMessage(message); } @@ -555,37 +479,8 @@ helpButton.setVisible(isVisible); } - /** - * This method returns the model of the DL-Learner plugin. - * @return model of the plugin - */ - public DLLearnerModel getDLLearnerModel() { - return model; - } /** - * This method returns the thread for initializing the reasoner and reading the ontology. - * @return thread that initializes the reasoner - */ - public ReadingOntologyThread getReadingOntologyThread() { - return readThread; - } - - /** - * This method starts the status bar. - */ - public void startStatusBar() { - statusBar.showProgress(true); - } - - /** - * This method stops the status bar. - */ - public void stopStatusBar() { - statusBar.showProgress(false); - } - - /** * This method returns the statusbar. * @return statusbar */ @@ -609,7 +504,7 @@ public void setBusyTaskStarted(String taskName){ setBusy(true); setHelpButtonVisible(true); - setStatusBarVisible(true); + showStatusBar(true); statusBar.showProgress(true); statusBar.setMessage(taskName); } @@ -617,7 +512,7 @@ public void setBusyTaskEnded(){ setBusy(false); setHelpButtonVisible(false); - setStatusBarVisible(false); + showStatusBar(false); statusBar.showProgress(false); statusBar.setMessage(""); } @@ -625,18 +520,22 @@ public void setLearningStarted(){ setBusy(true); setHelpButtonVisible(true); - setStatusBarVisible(true); - run.setEnabled(false); - statusBar.setMaximumValue(Manager.getInstance().getMaxExecutionTimeInSeconds()); + showStatusBar(true); + runButton.setEnabled(false); + statusBar.setMaximumValue(Manager.getInstance().getMaxExecutionTimeInSeconds() * 2); statusBar.setMessage("Learning ..."); } public void setLearningFinished(){ - stopStatusBar(); + statusBar.setProgress(0); setBusy(false); showAlgorithmTerminatedMessage(); } + public void setRunButtonEnabled(boolean enabled){ + runButton.setEnabled(enabled); + } + public void showHorizontalExpansionMessage(int min, int max){ StringBuffer sb = new StringBuffer(); sb.append("<html><font size=\"3\">Currently searching class expressions with length between "); Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2010-06-15 14:08:31 UTC (rev 2164) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2010-06-16 20:55:28 UTC (rev 2165) @@ -1,614 +0,0 @@ -/** - * Copyright (C) 2007-2009, 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.AlphaComposite; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.geom.Ellipse2D; -import java.util.Random; -import java.util.Set; -import java.util.Vector; - -import javax.swing.JPanel; - -import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.owl.Individual; -import org.dllearner.learningproblems.EvaluatedDescriptionClass; -import org.semanticweb.owlapi.model.IRI; -import org.semanticweb.owlapi.model.OWLDataFactory; - -/** - * This class draws the graphical coverage of a learned concept. - * - * @author Christian Koetteritzsch - * - */ -public class GraphicalCoveragePanel extends JPanel { - - private static final long serialVersionUID = 855436961912515267L; - private static final int HEIGHT = 150; - private static final int WIDTH = 150; - private static final int ELLIPSE_X_AXIS = 5; - private static final int ELLIPSE_Y_AXIS = 5; - private static final int MAX_NUMBER_OF_INDIVIDUAL_POINTS = 20; - private static final int PLUS_SIZE = 5; - private static final int SUBSTRING_SIZE = 25; - private static final int SPACE_SIZE = 7; - private static final int MAX_RANDOM_NUMBER = 300; - private static final String EQUI_STRING = "equivalent class"; - private final String id; - private int shiftXAxis; - private int distortionOld; - private Ellipse2D oldConcept; - private Ellipse2D newConcept; - - private EvaluatedDescription eval; - private String conceptNew; - private final Vector<IndividualPoint> posCovIndVector; - private final Vector<IndividualPoint> posNotCovIndVector; - private final Vector<IndividualPoint> additionalIndividuals; - private final Vector<IndividualPoint> points; - private final Vector<String> conceptVector; - private final GraphicalCoveragePanelHandler handler; - private int adjustment; - private int shiftOldConcept; - private int shiftNewConcept; - private int shiftNewConceptX; - private int shiftCovered; - private int coveredIndividualSize; - private int additionalIndividualSize; - private int x1; - private int x2; - private int y1; - private int y2; - private int centerX; - private int centerY; - private final Random random; - private final Color darkGreen; - private final Color darkRed; - private int notCoveredInd; - private OWLDataFactory factory; - - /** - * - * This is the constructor for the GraphicalCoveragePanel. - * - * @param desc - * EvaluatedDescription - * @param m - * DLLearnerModel - */ - public GraphicalCoveragePanel(EvaluatedDescription desc, DLLearnerModel m) { - this.setVisible(false); - this.setForeground(Color.GREEN); - eval = desc; -// id = model.getID(); - id = EQUI_STRING; - darkGreen = new Color(0, 100, 0); - darkRed = new Color(205, 0, 0); - random = new Random(); -// for(String uri : model.getOntologyURIString()) { -// if(eval.getDescription().toString().contains(uri)) { -// conceptNew = eval.getDescription().toManchesterSyntaxString(uri, null); -// } -// } - conceptNew = Manager.getInstance().getRendering(eval.getDescription()); - - conceptVector = new Vector<String>(); - posCovIndVector = new Vector<IndividualPoint>(); - posNotCovIndVector = new Vector<IndividualPoint>(); - additionalIndividuals = new Vector<IndividualPoint>(); - points = new Vector<IndividualPoint>(); - this.computeGraphics(); - handler = new GraphicalCoveragePanelHandler(this, desc); - if(shiftXAxis == 0) { - oldConcept = new Ellipse2D.Double(ELLIPSE_X_AXIS + (2 * adjustment)+3, - ELLIPSE_Y_AXIS+3, WIDTH, HEIGHT); - } else { - oldConcept = new Ellipse2D.Double(ELLIPSE_X_AXIS + (2 * adjustment), - ELLIPSE_Y_AXIS, WIDTH, HEIGHT); - } - - if(shiftXAxis == 0){ - newConcept = new Ellipse2D.Double(ELLIPSE_X_AXIS + shiftXAxis - + adjustment, ELLIPSE_Y_AXIS, WIDTH + distortionOld+6, HEIGHT - + distortionOld+6); - } else { - newConcept = new Ellipse2D.Double(ELLIPSE_X_AXIS + shiftXAxis - + adjustment, ELLIPSE_Y_AXIS, WIDTH + distortionOld, HEIGHT - + distortionOld); - } - factory = Manager.getInstance().getActiveOntology().getOWLOntologyManager().getOWLDataFactory(); - this.computeIndividualPoints(); - this.addMouseMotionListener(handler); - this.addMouseListener(handler); - } - - @Override - protected void paintComponent(Graphics g) { - if (eval != null) { - Graphics2D g2D; - g2D = (Graphics2D) g; - AlphaComposite ac = AlphaComposite.getInstance( - AlphaComposite.SRC_OVER, 0.5f); - - g2D.setColor(Color.YELLOW); - g2D.fill(oldConcept); - g2D.setColor(Color.ORANGE); - g2D.setComposite(ac); - g2D.fill(newConcept); - g2D.setColor(Color.BLACK); - - // Plus 1 - if (coveredIndividualSize != Manager.getInstance().getIndividuals().size() - && notCoveredInd != 0) { - g2D.drawLine(x1 - 1 - shiftOldConcept, y1 - 1, x2 + 1 - - shiftOldConcept, y1 - 1); - g2D.drawLine(x1 - shiftOldConcept, centerY - 1, x2 - - shiftOldConcept, centerY - 1); - g2D.drawLine(x1 - shiftOldConcept, centerY, x2 - - shiftOldConcept, centerY); - g2D.drawLine(x1 - shiftOldConcept, centerY + 1, x2 - - shiftOldConcept, centerY + 1); - g2D.drawLine(x1 - 1 - shiftOldConcept, y2 + 1, x2 + 1 - - shiftOldConcept, y2 + 1); - - g2D.drawLine(x1 - 1 - shiftOldConcept, y1 - 1, x1 - 1 - - shiftOldConcept, y2 + 1); - g2D.drawLine(centerX - 1 - shiftOldConcept, y1, centerX - 1 - - shiftOldConcept, y2); - g2D.drawLine(centerX - shiftOldConcept, y1, centerX - - shiftOldConcept, y2); - g2D.drawLine(centerX + 1 - shiftOldConcept, y1, centerX + 1 - - shiftOldConcept, y2); - g2D.drawLine(x2 + 1 - shiftOldConcept, y1 - 1, x2 + 1 - - shiftOldConcept, y2 + 1); - } - // Plus 2 - - g2D.drawLine(x1 - 1 + shiftCovered, y1 - 1, x2 + 1 + shiftCovered, - y1 - 1); - g2D.drawLine(x1 + shiftCovered, centerY - 1, x2 + shiftCovered, - centerY - 1); - g2D - .drawLine(x1 + shiftCovered, centerY, x2 + shiftCovered, - centerY); - g2D.drawLine(x1 + shiftCovered, centerY + 1, x2 + shiftCovered, - centerY + 1); - g2D.drawLine(x1 - 1 + shiftCovered, y2 + 1, x2 + 1 + shiftCovered, - y2 + 1); - - g2D.drawLine(x1 - 1 + shiftCovered, y1 - 1, x1 - 1 + shiftCovered, - y2 + 1); - g2D.drawLine(centerX - 1 + shiftCovered, y1, centerX - 1 - + shiftCovered, y2); - g2D - .drawLine(centerX + shiftCovered, y1, centerX - + shiftCovered, y2); - g2D.drawLine(centerX + 1 + shiftCovered, y1, centerX + 1 - + shiftCovered, y2); - g2D.drawLine(x2 + 1 + shiftCovered, y1 - 1, x2 + 1 + shiftCovered, - y2 + 1); - - // Plus 3 - if (coveredIndividualSize != Manager.getInstance().getIndividuals().size() && ((EvaluatedDescriptionClass) eval).getAdditionalInstances().size() != 0) { - g2D.drawLine(x1 - 1 + shiftNewConcept, y1 - 1, x2 + 1 - + shiftNewConcept, y1 - 1); - g2D.drawLine(x1 + shiftNewConcept, centerY - 1, x2 - + shiftNewConcept, centerY - 1); - g2D.drawLine(x1 + shiftNewConcept, centerY, x2 - + shiftNewConcept, centerY); - g2D.drawLine(x1 + shiftNewConcept, centerY + 1, x2 - + shiftNewConcept, centerY + 1); - g2D.drawLine(x1 - 1 + shiftNewConcept, y2 + 1, x2 + 1 - + shiftNewConcept, y2 + 1); - - g2D.drawLine(x1 - 1 + shiftNewConcept, y1 - 1, x1 - 1 - + shiftNewConcept, y2 + 1); - g2D.drawLine(centerX - 1 + shiftNewConcept, y1, centerX - 1 - + shiftNewConcept, y2); - g2D.drawLine(centerX + shiftNewConcept, y1, centerX - + shiftNewConcept, y2); - g2D.drawLine(centerX + 1 + shiftNewConcept, y1, centerX + 1 - + shiftNewConcept, y2); - g2D.drawLine(x2 + 1 + shiftNewConcept, y1 - 1, x2 + 1 - + shiftNewConcept, y2 + 1); - } - //Plus 4 - if (((EvaluatedDescriptionClass) eval).getAddition() != 1.0 - && ((EvaluatedDescriptionClass) eval).getCoverage() == 1.0) { - g2D.drawLine(x1 - 1 + shiftNewConceptX, y1 - 1 - + shiftNewConcept, x2 + 1 + shiftNewConceptX, y1 - 1 - + shiftNewConcept); - g2D.drawLine(x1 + shiftNewConceptX, centerY - 1 - + shiftNewConcept, x2 + shiftNewConceptX, centerY - 1 - + shiftNewConcept); - g2D.drawLine(x1 + shiftNewConceptX, centerY + shiftNewConcept, - x2 + shiftNewConceptX, centerY + shiftNewConcept); - g2D.drawLine(x1 + shiftNewConceptX, centerY + 1 - + shiftNewConcept, x2 + shiftNewConceptX, centerY + 1 - + shiftNewConcept); - g2D.drawLine(x1 - 1 + shiftNewConceptX, y2 + 1 - + shiftNewConcept, x2 + 1 + shiftNewConceptX, y2 + 1 - + shiftNewConcept); - - g2D.drawLine(x1 - 1 + shiftNewConceptX, y1 - 1 - + shiftNewConcept, x1 - 1 + shiftNewConceptX, y2 + 1 - + shiftNewConcept); - g2D.drawLine(centerX - 1 + shiftNewConceptX, y1 - + shiftNewConcept, centerX - 1 + shiftNewConceptX, y2 - + shiftNewConcep... [truncated message content] |