From: <lor...@us...> - 2010-06-14 09:10:46
|
Revision: 2163 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2163&view=rev Author: lorenz_b Date: 2010-06-14 09:10:38 +0000 (Mon, 14 Jun 2010) Log Message: ----------- Continued refactoring Prot?\195?\169g?\195?\169 plugin. Changing the active reasoner now should work, but the plugin code is very ugly. 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/DLLearnerView.java trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanelHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-06-13 14:06:21 UTC (rev 2162) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-06-14 09:10:38 UTC (rev 2163) @@ -19,7 +19,7 @@ */ package org.dllearner.tools.protege; -import java.awt.Color; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -27,15 +27,12 @@ import java.util.Set; import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.ExecutionException; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; -import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.LearningAlgorithm; /** * This class processes input from the user. @@ -58,7 +55,6 @@ private EvaluatedDescription evaluatedDescription; // This is the view of the DL-Learner tab. private Timer timer; - private LearningAlgorithm la; private SuggestionRetriever retriever; private HelpTextPanel helpPanel; // private final Color colorRed = new Color(139, 0, 0); @@ -100,24 +96,48 @@ if (z.getActionCommand().equals(EQUIVALENT_CLASS_LEARNING_STRING) || z.getActionCommand().equals(SUPER_CLASS_LEARNING_STRING)) { -// model.setKnowledgeSource(); - view.getSuggestClassPanel().getSuggestionsTable().clear(); - view.getSuggestClassPanel().repaint(); - model.setLearningProblem(); - model.setLearningAlgorithm(); + + setLearningOptions(); + + Manager manager = Manager.getInstance(model.getOWLEditorKit()); +// manager.initKnowledgeSource(); +// manager.initReasoner(); +// manager.initLearningProblem(); +// manager.initLearningAlgorithm(); + view.setBusy(true); + manager.init(); + view.getRunButton().setEnabled(false); - view.getHintPanel().setForeground(Color.RED); - CELOE celoe = (CELOE) model.getLearningAlgorithm(); - String moreInformationsMessage = "<html><font size=\"3\">Learning started. Currently searching class expressions with length between " - + celoe.getMinimumHorizontalExpansion() + + manager.getMinimumHorizontalExpansion() + " and " - + celoe.getMaximumHorizontalExpansion() + ".</font></html>"; + + manager.getMaximumHorizontalExpansion() + ".</font></html>"; view.setHelpButtonVisible(true); view.setHintMessage(moreInformationsMessage); retriever = new SuggestionRetriever(); retriever.addPropertyChangeListener(view.getStatusBar()); retriever.execute(); + + //######################################################################### +// model.setKnowledgeSource(); + +// view.getSuggestClassPanel().getSuggestionsTable().clear(); +// view.getSuggestClassPanel().repaint(); +// model.setLearningProblem(); +// model.setLearningAlgorithm(); +// view.getRunButton().setEnabled(false); +// view.getHintPanel().setForeground(Color.RED); +// CELOE celoe = (CELOE) model.getLearningAlgorithm(); +// +// String moreInformationsMessage = "<html><font size=\"3\">Learning started. Currently searching class expressions with length between " +// + celoe.getMinimumHorizontalExpansion() +// + " and " +// + celoe.getMaximumHorizontalExpansion() + ".</font></html>"; +// view.setHelpButtonVisible(true); +// view.setHintMessage(moreInformationsMessage); +// retriever = new SuggestionRetriever(); +// retriever.addPropertyChangeListener(view.getStatusBar()); +// retriever.execute(); } if (z.getActionCommand().equals(ADD_BUTTON_STRING)) { @@ -175,6 +195,19 @@ public void setEvaluatedClassExpression(EvaluatedDescription desc) { this.evaluatedDescription = desc; } + + private void setLearningOptions(){ + OptionPanel options = view.getOptionsPanel(); + Manager manager = Manager.getInstance(model.getOWLEditorKit()); + manager.setMaxExecutionTimeInSeconds(options.getMaxExecutionTimeInSeconds()); + manager.setMaxNrOfResults(options.getMaxNumberOfResults()); + manager.setNoisePercentage(options.getNoise()); + manager.setUseAllConstructor(options.isUseAllQuantor()); + manager.setUseNegation(options.isUseNegation()); + manager.setUseCardinalityRestrictions(options.isUseCardinalityRestrictions()); + manager.setUseExistsConstructor(options.isUseExistsQuantor()); + manager.setUseHasValueConstructor(options.isUseHasValue()); + } /** * Inner Class that retrieves the concepts given by the DL-Learner. @@ -186,87 +219,44 @@ extends SwingWorker<List<? extends EvaluatedDescription>, List<? extends EvaluatedDescription>> { - private Thread dlLearner; - @SuppressWarnings("unchecked") @Override protected List<? extends EvaluatedDescription> doInBackground() throws Exception { - setProgress(0); - la = model.getLearningAlgorithm(); + view.setStatusBarVisible(true); - view.getStatusBar().setMaximumValue( - view.getPosAndNegSelectPanel().getOptionPanel() - .getMaxExecutionTime()); + view.getStatusBar().setMaximumValue(Manager.getInstance().getMaxExecutionTimeInSeconds()); timer = new Timer(); - timer.schedule(new TimerTask() { + timer.schedule(new TimerTask(){ int progress = 0; - + List<? extends EvaluatedDescription> result; @Override public void run() { progress += 1; setProgress(progress); - if (la != null) { - publish(la.getCurrentlyBestEvaluatedDescriptions(view - .getPosAndNegSelectPanel().getOptionPanel() - .getNrOfConcepts())); - CELOE celoe = (CELOE) model.getLearningAlgorithm(); - view.getHintPanel().setForeground(Color.RED); - String moreInformationsMessage = "<html><font size=\"3\">Learning started. Currently searching class expressions with length between " - + celoe.getMinimumHorizontalExpansion() - + " and " - + celoe.getMaximumHorizontalExpansion() - + ".</font></html>"; - view.setHintMessage(moreInformationsMessage); + if(!isCancelled() && Manager.getInstance().isLearning()){ + result = Manager.getInstance().getCurrentlyLearnedDescriptions(); + publish(result); } } - + }, 1000, 1000); - - dlLearner = new Thread(new Runnable() { - - @Override - public void run() { - try { - model.run(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - }); - dlLearner.start(); - - try { - dlLearner.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - List<? extends EvaluatedDescription> result = la - .getCurrentlyBestEvaluatedDescriptions(view - .getPosAndNegSelectPanel().getOptionPanel() - .getNrOfConcepts()); - - return result; + Manager.getInstance().startLearning(); + + + return null; } @Override public void done() { timer.cancel(); - - List<? extends EvaluatedDescription> result = null; - try { - result = get(); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); - } + List<? extends EvaluatedDescription> result = Manager.getInstance().getCurrentlyLearnedDescriptions(); setProgress(0); view.stopStatusBar(); + view.setBusy(false); updateList(result); - view.algorithmTerminated(); + view.showAlgorithmTerminatedMessage(); } @@ -286,45 +276,13 @@ public void run() { model.setSuggestList(result); -// dm.clear(); -// int i = 0; -// for (EvaluatedDescription eval : result) { -// Set<String> ont = model.getOntologyURIString(); -// for (String ontology : ont) { -// if (eval.getDescription().toString().contains( -// ontology)) { -// if (((EvaluatedDescriptionClass) eval) -// .isConsistent()) { -// dm.add(i, eval); -//// dm.add(i, new SuggestListItem(colorGreen, -//// eval.getDescription() -//// .toManchesterSyntaxString( -//// ontology, null), -//// ((EvaluatedDescriptionClass) eval) -//// .getAccuracy() * 100)); -// i++; -// break; -// } else { -// dm.add(i, eval); -//// dm.add(i, new SuggestListItem(colorRed, -//// eval.getDescription() -//// .toManchesterSyntaxString( -//// ontology, null), -//// ((EvaluatedDescriptionClass) eval) -//// .getAccuracy() * 100)); -// if(isFinished) { -// view.setIsInconsistent(true); -// } -// i++; -// break; -// } -// } -// } -// } -// -// view.getSuggestClassPanel().setSuggestList(dm); -// view.getLearnerView().repaint(); view.getSuggestClassPanel().addSuggestions(result); + String moreInformationsMessage = "<html><font size=\"3\">Learning started. Currently searching class expressions with length between " + + Manager.getInstance().getMinimumHorizontalExpansion() + + " and " + + Manager.getInstance().getMaximumHorizontalExpansion() + + ".</font></html>"; + view.setHintMessage(moreInformationsMessage); } }; SwingUtilities.invokeLater(doUpdateList); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2010-06-13 14:06:21 UTC (rev 2162) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2010-06-14 09:10:38 UTC (rev 2163) @@ -43,6 +43,7 @@ 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; @@ -64,7 +65,7 @@ * @author Christian Koetteritzsch * */ -public class DLLearnerModel implements Runnable, OWLModelManagerListener{ +public class DLLearnerModel implements Runnable, OWLModelManagerListener, Disposable{ // The Sting is for components that are available in the DL-Learner @@ -308,25 +309,25 @@ //Config options set in the gui. //config option if all is used for suggestions - cm.applyConfigEntry(la, "useAllConstructor", view.getPosAndNegSelectPanel().getOptionPanel().getAllBox()); + cm.applyConfigEntry(la, "useAllConstructor", view.getOptionsPanel().isUseAllQuantor()); //config option if exists is used for suggestions - cm.applyConfigEntry(la, "useExistsConstructor", view.getPosAndNegSelectPanel().getOptionPanel().getSomeBox()); + cm.applyConfigEntry(la, "useExistsConstructor", view.getOptionsPanel().isUseExistsQuantor()); //config option if hasValue is used for suggestions - cm.applyConfigEntry(la, "useHasValueConstructor", view.getPosAndNegSelectPanel().getOptionPanel().getValueBox()); + cm.applyConfigEntry(la, "useHasValueConstructor", view.getOptionsPanel().isUseHasValue()); //config option if negation is used for suggestions - cm.applyConfigEntry(la, "useNegation", view.getPosAndNegSelectPanel().getOptionPanel().getNotBox()); + cm.applyConfigEntry(la, "useNegation", view.getOptionsPanel().isUseNegation()); //config option if cardinalitylimits is used for suggestions - cm.applyConfigEntry(la, "useCardinalityRestrictions", view.getPosAndNegSelectPanel().getOptionPanel().getMoreBox()); - if(view.getPosAndNegSelectPanel().getOptionPanel().getMoreBox()) { + cm.applyConfigEntry(la, "useCardinalityRestrictions", view.getOptionsPanel().isUseCardinalityRestrictions()); + if(view.getOptionsPanel().isUseCardinalityRestrictions()) { //config option to set the cardinalityrestrictions - cm.applyConfigEntry(la, "cardinalityLimit", view.getPosAndNegSelectPanel().getOptionPanel().getCountMoreBox()); + cm.applyConfigEntry(la, "cardinalityLimit", view.getOptionsPanel().getCardinalityLimit()); } //config option to set the noise - cm.applyConfigEntry(la, "noisePercentage", view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy()); + cm.applyConfigEntry(la, "noisePercentage", view.getOptionsPanel().getNoise()); //config option to set the maximum execution time cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view - .getPosAndNegSelectPanel().getOptionPanel() - .getMaxExecutionTime()); + .getOptionsPanel() + .getMaxExecutionTimeInSeconds()); try { // initializes the learning algorithm la.init(); @@ -584,6 +585,12 @@ 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-13 14:06:21 UTC (rev 2162) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-06-14 09:10:38 UTC (rev 2163) @@ -21,6 +21,7 @@ import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridBagConstraints; @@ -39,7 +40,6 @@ import javax.swing.JTextPane; import javax.swing.JToggleButton; -import org.dllearner.algorithms.celoe.CELOE; import org.protege.editor.owl.OWLEditorKit; import org.semanticweb.owlapi.model.OWLClassExpression; /** @@ -88,7 +88,7 @@ // Selection panel for the positive and negative examples - private final PosAndNegSelectPanel posPanel; + private final OptionPanel posPanel; // Picture for the advanced button when it is not toggled @@ -182,7 +182,7 @@ advanced.setName("Advanced"); learnerScroll.setPreferredSize(new Dimension(SCROLL_WIDTH, SCROLL_HEIGHT)); learnerScroll.getVerticalScrollBar().setUnitIncrement(SCROLL_SPEED); - posPanel = new PosAndNegSelectPanel(model, action); + posPanel = new OptionPanel(); detail = new MoreDetailForSuggestedConceptsPanel(model); sugPanelHandler = new SuggestClassPanelHandler(this, model, action); sugPanel.getSuggestionsTable().getSelectionModel().addListSelectionListener(sugPanelHandler); @@ -203,7 +203,7 @@ * This method returns the PosAndNegSelectPanel. * @return PosAndNegSelectPanel */ - public PosAndNegSelectPanel getPosAndNegSelectPanel() { + public OptionPanel getOptionsPanel() { return posPanel; } @@ -433,13 +433,14 @@ /** * This method unsets all results after closing the plugin. */ - public void dispose() { + public void dispose() throws Exception{ this.unsetEverything(); sugPanel.getSuggestionsTable().clear(); learner.removeAll(); sugPanel = null; model.getSuggestModel().clear(); model.getIndividual().clear(); + model.dispose(); } /** @@ -518,10 +519,13 @@ /** * This method sets the run button enable after learning. */ - public void algorithmTerminated() { - CELOE celoe = (CELOE) model.getLearningAlgorithm(); + public void showAlgorithmTerminatedMessage() { this.setStatusBarVisible(false); - String message = "<html><font size=\"3\" color=\"black\">Learning successful. All expressions up to length " + (celoe.getMinimumHorizontalExpansion()-1) + " and some expressions up to <br>length " + celoe.getMaximumHorizontalExpansion() + " searched."; + 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 " + + Manager.getInstance().getMaximumHorizontalExpansion() + + " searched."; hint.setForeground(Color.RED); if(isInconsistent) { message +="<font size=\"3\" color=\"red\"><br>Class expressions marked red will lead to an inconsistent ontology. <br>Please click on them to view detail information.</font></html>"; @@ -591,4 +595,13 @@ return hyperHandler; } + public void setBusy(boolean busy){ + if(busy){ + getLearnerView().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + } else { + getLearnerView().setCursor(Cursor.getDefaultCursor()); + } + + } + } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java 2010-06-13 14:06:21 UTC (rev 2162) +++ trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java 2010-06-14 09:10:38 UTC (rev 2163) @@ -45,8 +45,7 @@ + "get a high accuracy and are displayed as suggestions. The learning algorithm prefers short expressions. 'Currently searching class expressions with length" + " between 4 and 7.' means that it has already evaluated all class expressions of length 1 to 3 or excluded them as possible suggestions. All the expressions" + " currently evaluated have length between 4 and 7. If you want to search for longer expressions, then you have to increase the maximum runtime setting (it is " - + "set to " + view.getPosAndNegSelectPanel().getOptionPanel() - .getMaxExecutionTime() + + "set to " + view.getOptionsPanel().getMaxExecutionTimeInSeconds() + " seconds by default).</p>" + "<p>See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">DL-Learner plugin page</a> for more details.</p></html>"; this.setEditable(false); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java 2010-06-13 14:06:21 UTC (rev 2162) +++ trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java 2010-06-14 09:10:38 UTC (rev 2163) @@ -1,6 +1,8 @@ package org.dllearner.tools.protege; import java.net.MalformedURLException; +import java.util.Collections; +import java.util.List; import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.core.ComponentInitException; @@ -11,6 +13,7 @@ import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.kb.OWLAPIOntology; import org.dllearner.learningproblems.ClassLearningProblem; +import org.dllearner.learningproblems.EvaluatedDescriptionClass; import org.dllearner.reasoning.ProtegeReasoner; import org.dllearner.tools.ore.LearningManager.LearningType; import org.protege.editor.owl.OWLEditorKit; @@ -38,7 +41,6 @@ private double noisePercentage; private double threshold; private int maxNrOfResults; - private int minInstanceCount; private boolean useAllConstructor; private boolean useExistsConstructor; private boolean useHasValueConstructor; @@ -53,15 +55,33 @@ return instance; } + public static synchronized Manager getInstance(){ + return instance; + } + private Manager(OWLEditorKit editorKit){ this.editorKit = editorKit; cm = ComponentManager.getInstance(); } + + public void setOWLEditorKit(OWLEditorKit editorKit){ + this.editorKit = editorKit; + } public boolean isReinitNecessary(){ return reinitNecessary; } + public void init(){ + initKnowledgeSource(); + if(reinitNecessary){ + initReasoner(); + } + initLearningProblem(); + initLearningAlgorithm(); + reinitNecessary = false; + } + public void initLearningAlgorithm(){ try { la = cm.learningAlgorithm(CELOE.class, lp, reasoner); @@ -123,6 +143,18 @@ } } + public void startLearning(){ + la.start(); + } + + public void stopLearning(){ + la.stop(); + } + + public boolean isLearning(){ + return la != null && la.isRunning(); + } + public LearningType getLearningType() { return learningType; } @@ -139,18 +171,10 @@ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds; } - public double getNoisePercentage() { - return noisePercentage; - } - public void setNoisePercentage(double noisePercentage) { this.noisePercentage = noisePercentage; } - public double getThreshold() { - return threshold; - } - public void setThreshold(double threshold) { this.threshold = threshold; } @@ -163,61 +187,49 @@ this.maxNrOfResults = maxNrOfResults; } - public int getMinInstanceCount() { - return minInstanceCount; - } - - public void setMinInstanceCount(int minInstanceCount) { - this.minInstanceCount = minInstanceCount; - } - - public boolean isUseAllConstructor() { - return useAllConstructor; - } - public void setUseAllConstructor(boolean useAllConstructor) { this.useAllConstructor = useAllConstructor; } - public boolean isUseExistsConstructor() { - return useExistsConstructor; - } - public void setUseExistsConstructor(boolean useExistsConstructor) { this.useExistsConstructor = useExistsConstructor; } - public boolean isUseHasValueConstructor() { - return useHasValueConstructor; - } - public void setUseHasValueConstructor(boolean useHasValueConstructor) { this.useHasValueConstructor = useHasValueConstructor; } - public boolean isUseNegation() { - return useNegation; - } - public void setUseNegation(boolean useNegation) { this.useNegation = useNegation; } - public boolean isUseCardinalityRestrictions() { - return useCardinalityRestrictions; - } - public void setUseCardinalityRestrictions(boolean useCardinalityRestrictions) { this.useCardinalityRestrictions = useCardinalityRestrictions; } - public int getCardinalityLimit() { - return cardinalityLimit; - } - public void setCardinalityLimit(int cardinalityLimit) { this.cardinalityLimit = cardinalityLimit; } + + @SuppressWarnings("unchecked") + public synchronized List<EvaluatedDescriptionClass> getCurrentlyLearnedDescriptions() { + List<EvaluatedDescriptionClass> result; + if (la != null) { + result = Collections.unmodifiableList((List<EvaluatedDescriptionClass>) la + .getCurrentlyBestEvaluatedDescriptions(maxNrOfResults, threshold, true)); + } else { + result = Collections.emptyList(); + } + return result; + } + + public int getMinimumHorizontalExpansion(){ + return ((CELOE)la).getMinimumHorizontalExpansion(); + } + + public int getMaximumHorizontalExpansion(){ + return ((CELOE)la).getMaximumHorizontalExpansion(); + } @Override public void handleChange(OWLModelManagerChangeEvent event) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2010-06-13 14:06:21 UTC (rev 2162) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2010-06-14 09:10:38 UTC (rev 2163) @@ -40,14 +40,10 @@ private static final long serialVersionUID = 2190682281812478244L; - private final JLabel minAccuracyLabel; - private final JLabel maxExecutionTimeLabel; - private final JLabel nrOfConceptsLabel; + private final JSlider noiseInPercentage; + private final JSlider maxExecutionTimeInSeconds; + private final JSlider maxNumberOfResults; - private final JSlider minAccuracy; - private final JSlider maxExecutionTime; - private final JSlider nrOfConcepts; - private JRadioButton owlRadioButton; private JRadioButton elProfileButton; private JRadioButton defaultProfileButton; @@ -56,9 +52,9 @@ private JCheckBox someBox; private JCheckBox notBox; private JCheckBox valueBox; - private JCheckBox moreBox; + private JCheckBox cardinalityBox; - private JComboBox countMoreBox; + private JComboBox cardinalityLimitBox; private JPanel profilePanel; private JPanel radioBoxPanel; @@ -86,29 +82,29 @@ checkBoxPanel = new JPanel(); checkBoxPanel.setLayout(new GridBagLayout()); - minAccuracyLabel = new JLabel("<html>noise in %: </html>"); - maxExecutionTimeLabel = new JLabel("<html>maximum execution time: </html>"); - nrOfConceptsLabel = new JLabel("<html>max. number of results: </html>"); + JLabel noiseInPercentageLabel = new JLabel("<html>noise in %: </html>"); + JLabel maxExecutionTimeLabel = new JLabel("<html>maximum execution time: </html>"); + JLabel nrOfConceptsLabel = new JLabel("<html>max. number of results: </html>"); - minAccuracy = new JSlider(0, 50, 5); - minAccuracy.setPaintTicks(true); - minAccuracy.setMajorTickSpacing(10); - minAccuracy.setMinorTickSpacing(1); - minAccuracy.setPaintLabels(true); + noiseInPercentage = new JSlider(0, 50, 5); + noiseInPercentage.setPaintTicks(true); + noiseInPercentage.setMajorTickSpacing(10); + noiseInPercentage.setMinorTickSpacing(1); + noiseInPercentage.setPaintLabels(true); - maxExecutionTime = new JSlider(0, 40, 8); - maxExecutionTime.setPaintTicks(true); - maxExecutionTime.setMajorTickSpacing(10); - maxExecutionTime.setMinorTickSpacing(1); - maxExecutionTime.setPaintLabels(true); + maxExecutionTimeInSeconds = new JSlider(0, 40, 8); + maxExecutionTimeInSeconds.setPaintTicks(true); + maxExecutionTimeInSeconds.setMajorTickSpacing(10); + maxExecutionTimeInSeconds.setMinorTickSpacing(1); + maxExecutionTimeInSeconds.setPaintLabels(true); - nrOfConcepts = new JSlider(2, 20, 10); - nrOfConcepts.setPaintTicks(true); - nrOfConcepts.setMajorTickSpacing(2); - nrOfConcepts.setMinorTickSpacing(1); - nrOfConcepts.setPaintLabels(true); + maxNumberOfResults = new JSlider(2, 20, 10); + maxNumberOfResults.setPaintTicks(true); + maxNumberOfResults.setMajorTickSpacing(2); + maxNumberOfResults.setMinorTickSpacing(1); + maxNumberOfResults.setPaintLabels(true); owlRadioButton = new JRadioButton("<html>OWL 2</html>", false); elProfileButton = new JRadioButton("<html>EL Profile</html>", false); @@ -118,6 +114,7 @@ elProfileButton.addActionListener(optionHandler); defaultProfileButton.addActionListener(optionHandler); + allBox = new JCheckBox("<html>all</html>", true); //allBox.addItemListener(optionHandler); someBox = new JCheckBox("<html>some</html>", true); @@ -126,22 +123,17 @@ //notBox.addItemListener(optionHandler); valueBox = new JCheckBox("<html>value</html>", false); //valueBox.addItemListener(optionHandler); - moreBox = new JCheckBox("<html> ‹=x, ›=x with max.:</html>", true); + cardinalityBox = new JCheckBox("<html> ‹=x, ›=x with max.:</html>", true); + cardinalityBox.setActionCommand("Cardinality"); + cardinalityBox.addActionListener(optionHandler); //moreBox.addItemListener(optionHandler); - countMoreBox = new JComboBox(); - countMoreBox.addItem(1); - countMoreBox.addItem(2); - countMoreBox.addItem(3); - countMoreBox.addItem(4); - countMoreBox.addItem(5); - countMoreBox.addItem(6); - countMoreBox.addItem(7); - countMoreBox.addItem(8); - countMoreBox.addItem(9); - countMoreBox.addItem(10); - countMoreBox.setSelectedItem(5); - countMoreBox.setEditable(false); + cardinalityLimitBox = new JComboBox(); + for(int i = 1; i <= 10; i++){ + cardinalityLimitBox.addItem(i); + } + cardinalityLimitBox.setSelectedItem(5); + cardinalityLimitBox.setEditable(false); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; @@ -182,7 +174,7 @@ c.gridx = 8; c.gridy = 0; c.gridwidth = 1; - checkBoxPanel.add(moreBox, c); + checkBoxPanel.add(cardinalityBox, c); c.fill = GridBagConstraints.BOTH; c.weightx = 0.0; @@ -190,7 +182,7 @@ c.gridx = 9; c.gridy = 0; c.gridwidth = 1; - checkBoxPanel.add(countMoreBox, c); + checkBoxPanel.add(cardinalityLimitBox, c); radioBoxPanel.add(owlRadioButton); @@ -200,13 +192,13 @@ profilePanel.add(radioBoxPanel); profilePanel.add(checkBoxPanel); - labelPanel.add(minAccuracyLabel); + labelPanel.add(noiseInPercentageLabel); labelPanel.add(maxExecutionTimeLabel); labelPanel.add(nrOfConceptsLabel); - sliderPanel.add(minAccuracy); - sliderPanel.add(maxExecutionTime); - sliderPanel.add(nrOfConcepts); + sliderPanel.add(noiseInPercentage); + sliderPanel.add(maxExecutionTimeInSeconds); + sliderPanel.add(maxNumberOfResults); add(BorderLayout.SOUTH, profilePanel); add(BorderLayout.WEST, labelPanel); @@ -217,30 +209,30 @@ * This method returns the min accuracy chosen in the slider. * @return double minAccuracy */ - public double getMinAccuracy() { - double acc = minAccuracy.getValue(); + public double getNoise() { + double acc = noiseInPercentage.getValue(); accuracy = (acc/100.0); return accuracy; } /** - * This method returns the max executiontime chosen in the slider. + * This method returns the max execution time chosen in the slider. * @return int maxExecutionTime */ - public int getMaxExecutionTime() { - return maxExecutionTime.getValue(); + public int getMaxExecutionTimeInSeconds() { + return maxExecutionTimeInSeconds.getValue(); } /** - * This method returns the nr. of concepts chosen in the slider. + * This method returns the number of concepts chosen in the slider. * @return int nrOfConcepts */ - public int getNrOfConcepts() { - return nrOfConcepts.getValue(); + public int getMaxNumberOfResults() { + return maxNumberOfResults.getValue(); } /** - * This methode returns the OWLRadioButton. + * This method returns the OWLRadioButton. * @return OWLRAdioButton */ public JRadioButton getOwlRadioButton() { @@ -263,7 +255,7 @@ * This methode returns if the allquantor box is selected. * @return boolean if allquantor box is selected */ - public boolean getAllBox() { + public boolean isUseAllQuantor() { return allBox.isSelected(); } @@ -271,7 +263,7 @@ * This methode returns if the some box is selected. * @return boolean if some box is selected */ - public boolean getSomeBox() { + public boolean isUseExistsQuantor() { return someBox.isSelected(); } @@ -279,7 +271,7 @@ * This methode returns if the not box is selected. * @return boolean if not box is selected */ - public boolean getNotBox() { + public boolean isUseNegation() { return notBox.isSelected(); } @@ -287,7 +279,7 @@ * This methode returns if the value box is selected. * @return boolean if value box is selected */ - public boolean getValueBox() { + public boolean isUseHasValue() { return valueBox.isSelected(); } @@ -303,16 +295,16 @@ * This methode returns the int of the cardinality restriction. * @return cardinality restriction int */ - public int getCountMoreBox() { - return Integer.parseInt(countMoreBox.getSelectedItem().toString()); + public int getCardinalityLimit() { + return Integer.parseInt(cardinalityLimitBox.getSelectedItem().toString()); } /** * This methode returns if the cardinality restiction box is selected. * @return boolean if cardinality restiction box is selected */ - public boolean getMoreBox() { - return moreBox.isSelected(); + public boolean isUseCardinalityRestrictions() { + return cardinalityBox.isSelected(); } /** @@ -327,7 +319,7 @@ someBox.setSelected(true); notBox.setSelected(true); valueBox.setSelected(true); - moreBox.setSelected(true); + cardinalityBox.setSelected(true); this.setCountMoreBoxEnabled(true); } @@ -340,7 +332,7 @@ someBox.setSelected(true); notBox.setSelected(false); valueBox.setSelected(false); - moreBox.setSelected(false); + cardinalityBox.setSelected(false); owlRadioButton.setSelected(false); elProfileButton.setSelected(true); defaultProfileButton.setSelected(false); @@ -352,7 +344,7 @@ someBox.setSelected(true); notBox.setSelected(false); valueBox.setSelected(false); - moreBox.setSelected(true); + cardinalityBox.setSelected(true); owlRadioButton.setSelected(false); elProfileButton.setSelected(false); defaultProfileButton.setSelected(true); @@ -365,7 +357,7 @@ * @param isEnabled */ public void setCountMoreBoxEnabled(boolean isEnabled) { - countMoreBox.setEnabled(isEnabled); + cardinalityLimitBox.setEnabled(isEnabled); } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanelHandler.java 2010-06-13 14:06:21 UTC (rev 2162) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanelHandler.java 2010-06-14 09:10:38 UTC (rev 2163) @@ -29,10 +29,10 @@ */ public class OptionPanelHandler implements ActionListener { - private static final String OWL_RADIO_STRING = "OWL 2"; - private static final String EL_RADIO_STRING = "EL Profile"; - private static final String DEFAULT_RADIO_STRING = "Default"; - private static final String VALUE_STRING = "<=x, >=x with max.:"; + private static final String OPTION_PROFILE_OWL = "OWL 2"; + private static final String OPTION_PROFILE_EL = "EL Profile"; + private static final String OPTION_PROFILE_DEFAULT = "Default"; + private static final String OPTION_CARDINALITY = "Cardinality"; private OptionPanel option; @@ -51,21 +51,17 @@ * radio button is selected/deselected. */ public void actionPerformed(ActionEvent e) { - if (e.toString().contains(OWL_RADIO_STRING)) { + if (e.toString().contains(OPTION_PROFILE_OWL)) { this.setToOWLProfile(); } - if (e.toString().contains(EL_RADIO_STRING)) { + if (e.toString().contains(OPTION_PROFILE_EL)) { this.setToELProfile(); } - if (e.toString().contains(DEFAULT_RADIO_STRING)) { + if (e.toString().contains(OPTION_PROFILE_DEFAULT)) { this.setToDefaultProfile(); } - if(e.toString().contains(VALUE_STRING)) { - if(option.getMoreBox()) { - option.setCountMoreBoxEnabled(true); - } else { - option.setCountMoreBoxEnabled(false); - } + if(e.getActionCommand().equals(OPTION_CARDINALITY)) { + option.setCountMoreBoxEnabled(option.isUseCardinalityRestrictions()); } } Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2010-06-13 14:06:21 UTC (rev 2162) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2010-06-14 09:10:38 UTC (rev 2163) @@ -1,65 +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.Dimension; -import java.awt.GridLayout; - -import javax.swing.JPanel; - -/** - * This class is the Panel for the Check boxes where the positive and negative - * examples are chosen. - * - * @author Christian Koetteritzsch - * - */ -public class PosAndNegSelectPanel extends JPanel { - - private static final long serialVersionUID = 23632947283479L; - - private final OptionPanel optionPanel; - - /** - * This is the constructor for the Panel that shows the check boxes. - * - * @param model - * DLLearnerModel - * @param act - * ActionHandler - */ - public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act) { - //set layout for parent Panel - super(); - setLayout(new GridLayout(0, 1)); - setPreferredSize(new Dimension(485, 170)); - optionPanel = new OptionPanel(); - add(optionPanel); - } - - /** - * This method returns the option panel. - * @return OptionPanel - */ - public OptionPanel getOptionPanel() { - return optionPanel; - } - -} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2010-06-13 14:06:21 UTC (rev 2162) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2010-06-14 09:10:38 UTC (rev 2163) @@ -23,6 +23,7 @@ import javax.swing.JComponent; +import org.dllearner.tools.ore.LearningManager.LearningType; import org.protege.editor.core.ui.util.InputVerificationStatusChangedListener; import org.protege.editor.owl.ui.editor.AbstractOWLClassExpressionEditor; import org.semanticweb.owlapi.model.AxiomType; @@ -38,9 +39,6 @@ public class ProtegePlugin extends AbstractOWLClassExpressionEditor { private static final long serialVersionUID = 728362819273927L; private DLLearnerView view; - private static final String EQUIVALENT_CLASS_STRING = "Equivalent classes axiom"; - private static final String SUPERCLASS_STRING = "SubClass axiom"; - @Override public JComponent getComponent() { @@ -63,9 +61,11 @@ view.getSuggestClassPanel().getSuggestModel().clear(); view.getSuggestClassPanel().getSuggestionsTable().clear(); if(getAxiomType() == AxiomType.EQUIVALENT_CLASSES) { + Manager.getInstance(getOWLEditorKit()).setLearningType(LearningType.EQUIVALENT); view.makeView("equivalent class"); } else if(getAxiomType() == AxiomType.SUBCLASS_OF) { view.makeView("super class"); + Manager.getInstance(getOWLEditorKit()).setLearningType(LearningType.SUPER); } view.getMoreDetailForSuggestedConceptsPanel().unsetPanel(); return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |