From: <hee...@us...> - 2009-11-25 10:59:23
|
Revision: 1920 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1920&view=rev Author: heeroyuy Date: 2009-11-25 10:59:10 +0000 (Wed, 25 Nov 2009) Log Message: ----------- -fixed bug that individuals in some classes where not recognized 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/GraphicalCoveragePanel.java trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2009-11-25 10:57:13 UTC (rev 1919) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2009-11-25 10:59:10 UTC (rev 1920) @@ -148,13 +148,21 @@ } } if (z.toString().contains(HELP_BUTTON_STRING)) { - String helpText = "<html><font size=\"3\">What does a sentence like 'Learning started. Currently searching class expressions with length between 4 and 7.' mean?<br>" - + "Length: In Manchester OWL Syntax (the syntax used for class expressions in Protege), we define length simply as the number of words needed to write down the class expression.<br><br>" - + "The learning algorithm (called CELOE) for suggesting class expressions starts with the most general expression owl:Thing and then further specializes it.<br>" - + "Those class expressions, which fit the existing instances of a given class ($currentClass in this case) get a high accuracy and are displayed as suggestions.<br>" - + "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<br>" - + "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<br>" - + "the maximum runtime setting (it is set to $defaultRuntime seconds by default).<br><br>" + + Set<String> uris = model.getOntologyURIString(); + String currentClass = ""; + for(String uri : uris) { + if(model.getCurrentConcept().toString().contains(uri)) { + currentClass = model.getCurrentConcept().toManchesterSyntaxString(uri, null); + } + } + String helpText = "<html><font size=\"3\">What does a sentence like 'Learning started. Currently searching class expressions with length between 4 and 7.' mean?<br><br>" + + "Length: In Manchester OWL Syntax (the syntax used for class expressions in Protege), we define length <br>simply as the number of words needed to write down the class expression.<br><br>" + + "The learning algorithm (called CELOE) for suggesting class expressions starts with the most general expression <br>owl:Thing and then further specializes it.<br>" + + "Those class expressions, which fit the existing instances of a given class (" + currentClass + " in this case) get <br>a high accuracy and are displayed as suggestions.<br>" + + "The learning algorithm prefers short expressions. 'Currently searching class expressions with length between 4 and 7.' <br>means that it has already evaluated all class expressions of length 1 to 3<br>" + + "or excluded them as possible suggestions. All the expressions currently evaluated have length between 4 and 7. If you <br>want to search for longer expressions, then you have to increase<br>" + + "the maximum runtime setting (it is set to " + view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime() + " <br>seconds by default).<br><br>" + "See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">Protege Plugin Wiki</a> for more details.</font></html>"; help = new JTextPane(); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2009-11-25 10:57:13 UTC (rev 1919) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2009-11-25 10:59:10 UTC (rev 1920) @@ -516,7 +516,7 @@ 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."; 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 double click on them to view detail information.</font></html>"; + 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>"; } else { message +="<br>To view details about why a class expression was suggested, please click on it.</font><html>"; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-11-25 10:57:13 UTC (rev 1919) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-11-25 10:59:10 UTC (rev 1920) @@ -164,7 +164,7 @@ Ellipse2D circlePoint = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); g2D.fill(circlePoint); g2D.setColor(Color.BLACK); - g2D.drawString("individuals covered by", 320, p); + g2D.drawString("<html>individuals covered by", 320, p); g2D.setColor(Color.ORANGE); g2D.fillOval(455, p - 9, 9, 9); g2D.setColor(Color.BLACK); @@ -173,51 +173,51 @@ g2D.fillOval(525, p - 9, 9, 9); g2D.setColor(Color.BLACK); p = p + 20; - g2D.drawString("(OK)", 320, p); + g2D.drawString("(OK)</html>", 320, p); p = p + 20; if(id.equals(EQUI_STRING)) { g2D.setColor(darkRed); Ellipse2D circlePoint2 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); g2D.fill(circlePoint2); g2D.setColor(Color.BLACK); - g2D.drawString("individuals covered by", 320, p); + g2D.drawString("<html>individuals covered by", 320, p); g2D.setColor(Color.ORANGE); g2D.fillOval(455, p - 9, 9, 9); g2D.setColor(Color.BLACK); p = p + 20; - g2D.drawString("(potential problem)", 320, p); + g2D.drawString("(potential problem)</html>", 320, p); p = p + 20; g2D.setColor(darkRed); Ellipse2D circlePoint3 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); g2D.fill(circlePoint3); g2D.setColor(Color.BLACK); - g2D.drawString("individuals covered by", 320, p); + g2D.drawString("<html>individuals covered by", 320, p); g2D.setColor(Color.YELLOW); g2D.fillOval(455, p - 9, 9, 9); g2D.setColor(Color.BLACK); p = p + 20; - g2D.drawString("(potential problem)", 320, p); + g2D.drawString("(potential problem)</html>", 320, p); } else { g2D.setColor(Color.BLACK); Ellipse2D circlePoint2 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); g2D.fill(circlePoint2); - g2D.drawString("individuals covered by", 320, p); + g2D.drawString("<html>individuals covered by", 320, p); g2D.setColor(Color.ORANGE); g2D.fillOval(455, p - 9, 9, 9); g2D.setColor(Color.BLACK); p = p + 20; - g2D.drawString("(no problem)", 320, p); + g2D.drawString("(no problem)</html>", 320, p); p = p + 20; g2D.setColor(darkRed); Ellipse2D circlePoint3 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); g2D.fill(circlePoint3); g2D.setColor(Color.BLACK); - g2D.drawString("individuals covered by", 320, p); + g2D.drawString("<html>individuals covered by", 320, p); g2D.setColor(Color.YELLOW); g2D.fillOval(455, p - 9, 9, 9); g2D.setColor(Color.BLACK); p = p + 20; - g2D.drawString("(potential problem)", 320, p); + g2D.drawString("(potential problem)</html>", 320, p); } g2D.setColor(Color.YELLOW); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java 2009-11-25 10:57:13 UTC (rev 1919) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java 2009-11-25 10:59:10 UTC (rev 1920) @@ -30,16 +30,15 @@ import org.dllearner.reasoning.FastInstanceChecker; import org.protege.editor.owl.OWLEditorKit; import org.semanticweb.owl.model.OWLClass; -import org.semanticweb.owl.model.OWLOntology; /** * This class reads the ontologie in a separate thread. + * * @author Christian Koetteritzsch - * + * */ public class ReadingOntologyThread extends Thread { - private boolean hasIndividuals; private FastInstanceChecker reasoner; private NamedClass currentConcept; @@ -50,52 +49,64 @@ private boolean isInconsistent; private OWLClass current; private DLLearnerView view; - + /** * This is the constructor of the ReadingOntologyThread. - * @param editorKit OWLEditorKit - * @param v DL-Learner view - * @param m DL-Learner model + * + * @param editorKit + * OWLEditorKit + * @param v + * DL-Learner view + * @param m + * DL-Learner model */ - public ReadingOntologyThread(OWLEditorKit editorKit, DLLearnerView v, DLLearnerModel m) { + public ReadingOntologyThread(OWLEditorKit editorKit, DLLearnerView v, + DLLearnerModel m) { this.editor = editorKit; this.view = v; this.model = m; } - + /** * This method sets the view of the DL-Learner plugin. - * @param v DLLearnerView + * + * @param v + * DLLearnerView */ public void setDLLearnerView(DLLearnerView v) { this.view = v; } - + /** * This method sets the model of the DL-Learner plugin. - * @param m DLLearnerModel + * + * @param m + * DLLearnerModel */ public void setDLLearnerModel(DLLearnerModel m) { this.model = m; } + /** * This method sets the individuals that belong to the concept which is * chosen in protege. */ private void setPositiveConcept() { - current = editor.getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass(); - if(current != null) { + current = editor.getOWLWorkspace().getOWLSelectionModel() + .getLastSelectedClass(); + if (current != null) { SortedSet<Individual> individuals = null; hasIndividuals = false; // checks if selected concept is thing when yes then it selects all // individuals if (!(current.toString().equals("Thing"))) { List<NamedClass> classList = reasoner.getAtomicConceptsList(); - for(NamedClass concept : classList) { + for (NamedClass concept : classList) { // if individuals is null if (individuals == null) { - // checks if the concept is the selected concept in protege - for(String onto : ontologieURI) { + // checks if the concept is the selected concept in + // protege + for (String onto : ontologieURI) { if (concept.toString().contains(onto)) { if (concept.toString().equals( onto + current.toString())) { @@ -104,10 +115,12 @@ // the concept currentConcept = concept; if (reasoner.getIndividuals(concept) != null) { - if (reasoner.getIndividuals(concept).size() > 0) { + if (reasoner.getIndividuals(concept) + .size() > 0) { hasIndividuals = true; } - individual = reasoner.getIndividuals(concept); + individual = reasoner + .getIndividuals(concept); model.setIndividuals(individual); model.setHasIndividuals(hasIndividuals); model.setCurrentConcept(currentConcept); @@ -122,7 +135,7 @@ } else { if (reasoner.getIndividuals().size() > 0) { hasIndividuals = true; - + } individual = reasoner.getIndividuals(); model.setIndividuals(individual); @@ -130,7 +143,7 @@ } } } - + /** * This Method checks if the selected class has any individuals. * @@ -139,66 +152,87 @@ public boolean hasIndividuals() { return hasIndividuals; } - + /** - * Checks the URI if a "#" is in it. + * Puts every base uri in a HashSet. */ private void checkURI() { ontologieURI = new HashSet<String>(); - Set<OWLOntology> ont = editor.getModelManager().getActiveOntologies(); Set<Individual> indi = reasoner.getIndividuals(); - for(OWLOntology onto : ont) { - String ontURI = onto.getURI().toString(); - for(Individual ind : indi) { - if(ind.toString().contains(ontURI)) { - if(ind.toString().contains("#")) { - ontologieURI.add(onto.getURI().toString()+"#"); + for (Individual ind : indi) { + int ontURI = ind.toString().lastIndexOf("/"); + int ontURI2 = ind.toString().lastIndexOf("#"); + String uriNeu = ""; + String uriAlt = ""; + if (ontURI2 != -1) { + uriNeu = ind.toString().substring(0, ontURI2 + 1); + if (uriNeu != uriAlt) { + ontologieURI.add(uriNeu); + uriAlt = uriNeu; + uriNeu = ""; + String uriTest = indi.toString().replace(uriAlt, ""); + if(!uriTest.contains("/") && !uriTest.contains("#")) { break; - } else { - ontologieURI.add(onto.getURI().toString()); - break; } } - } + } else { + uriNeu = ind.toString().substring(0, ontURI + 1); + if (uriNeu != uriAlt) { + ontologieURI.add(uriNeu); + uriAlt = uriNeu; + uriNeu = ""; + String uriTest = indi.toString().replace(uriAlt, ""); + if(!uriTest.contains("/") && !uriTest.contains("#")) { + break; + } + + } + } } model.setOntologyURIString(ontologieURI); } - + @Override public void run() { - String loading ="<html><font size=\"3\">loading instances...</font></html>"; + String loading = "<html><font size=\"3\">loading instances...</font></html>"; view.getHintPanel().setForeground(Color.RED); view.setHintMessage(loading); - if(!model.isReasonerSet() || model.getIsKnowledgeSourceIsUpdated() == true) { + if (!model.isReasonerSet() + || model.getIsKnowledgeSourceIsUpdated() == true) { model.setKnowledgeSource(); model.setReasoner(); } reasoner = model.getReasoner(); isInconsistent = view.getIsInconsistent(); - if(!isInconsistent) { + if (!isInconsistent) { this.checkURI(); this.setPositiveConcept(); if (this.hasIndividuals()) { view.getRunButton().setEnabled(true); view.getHintPanel().setForeground(Color.BLACK); - view.setHintMessage("<html><font size=\"3\">To get suggestions for class descriptions, please click the button above.</font></html>"); - + view + .setHintMessage("<html><font size=\"3\">To get suggestions for class descriptions, please click the button above.</font></html>"); + } else { view.getRunButton().setEnabled(false); view.getHintPanel().setVisible(true); - String message ="<html><font size=\"3\" color=\"red\">There are no Instances for " + current + " available. Please insert some Instances.</font></html>"; + String message = "<html><font size=\"3\" color=\"red\">There are no Instances for " + + current + + " available. Please insert some Instances.</font></html>"; view.getHintPanel().setForeground(Color.RED); view.setHintMessage(message); } } else { view.getHintPanel().setForeground(Color.RED); view.getRunButton().setEnabled(false); - view.setHintMessage("The ontology is inconsistent and suggestions for class descriptions can only \nbe computed on consistent ontologies. Please repair the ontology first"); + view + .setHintMessage("The ontology is inconsistent and suggestions for class descriptions can only \nbe computed on consistent ontologies. Please repair the ontology first"); } } - + /** * This method returns the NamedClass for the currently selected class. + * * @return NamedClass of the currently selected class */ public NamedClass getCurrentConcept() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2009-11-26 14:10:18
|
Revision: 1923 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1923&view=rev Author: heeroyuy Date: 2009-11-26 14:10:09 +0000 (Thu, 26 Nov 2009) Log Message: ----------- -added some additional information on graphical panel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/IndividualPoint.java trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2009-11-26 13:24:53 UTC (rev 1922) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2009-11-26 14:10:09 UTC (rev 1923) @@ -564,6 +564,10 @@ public boolean getIsKnowledgeSourceIsUpdated() { return knowledgeSourceIsUpdated; } + + public OWLEditorKit getOWLEditorKit() { + return editor; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-11-26 13:24:53 UTC (rev 1922) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-11-26 14:10:09 UTC (rev 1923) @@ -35,6 +35,7 @@ import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.owl.Individual; import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.semanticweb.owl.model.OWLDataFactory; /** * This class draws the graphical coverage of a learned concept. @@ -87,6 +88,7 @@ private final Color darkGreen; private final Color darkRed; private int notCoveredInd; + private OWLDataFactory factory; /** * @@ -137,6 +139,7 @@ + adjustment, ELLIPSE_Y_AXIS, WIDTH + distortionOld, HEIGHT + distortionOld); } + factory = model.getOWLEditorKit().getOWLModelManager().getOWLDataFactory(); this.computeIndividualPoints(); this.addMouseMotionListener(handler); this.addMouseListener(handler); @@ -497,7 +500,7 @@ for(String uri : uriString) { if(ind.toString().contains(uri)) { posCovIndVector.add(new IndividualPoint("*", - (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), ind, uri)); + (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), factory.getOWLIndividual(ind.getURI()), ind, uri)); } } i++; @@ -545,7 +548,7 @@ for(String uri : uriString) { if(ind.toString().contains(uri)) { posNotCovIndVector.add(new IndividualPoint("*", - (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), ind, uri)); + (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), factory.getOWLIndividual(ind.getURI()), ind, uri)); } } } else { @@ -553,7 +556,7 @@ for(String uri : uriString) { if(ind.toString().contains(uri)) { additionalIndividuals.add(new IndividualPoint("*", - (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), ind, uri)); + (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), factory.getOWLIndividual(ind.getURI()), ind, uri)); } } } @@ -594,7 +597,7 @@ for(String uri : uriString) { if(ind.toString().contains(uri)) { posNotCovIndVector.add(new IndividualPoint("*", - (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), ind, uri)); + (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), factory.getOWLIndividual(ind.getURI()), ind, uri)); } } k++; Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java 2009-11-26 13:24:53 UTC (rev 1922) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java 2009-11-26 14:10:09 UTC (rev 1923) @@ -37,6 +37,12 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.learningproblems.EvaluatedDescriptionClass; import org.dllearner.reasoning.FastInstanceChecker; +import org.semanticweb.owl.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owl.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owl.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owl.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.model.OWLSameIndividualsAxiom; /** * This class takes care of all events happening in the GraphicalCoveragePanel. @@ -55,6 +61,7 @@ private BasicComboPopup scrollPopup; private final Vector<String> individualComboBox; private JComboBox indiBox; + private OWLOntology ontology; /** * This is the constructor for the handler. @@ -71,6 +78,8 @@ this.panel = p; description = eval; model = m; + ontology = model.getOWLEditorKit().getOWLModelManager() + .getActiveOntology(); individualComboBox = new Vector<String>(); } @@ -113,12 +122,13 @@ && v.get(i).getXAxis() <= m.getX() + 5 && v.get(i).getYAxis() >= m.getY() - 5 && v.get(i).getYAxis() <= m.getY() + 5) { - String individualInformation = "<html><body>" - + v.get(i).getIndividualName().toString(); + String individualInformation = "<html><body><b>" + + v.get(i).getIndividualName().toString() + "</b>"; if (v.get(i).getDLLearnerIndividual() != null) { + Set<NamedClass> types = reasoner.getTypes(v.get(i) .getDLLearnerIndividual()); - individualInformation += "<br><b>Types:</b><br>"; + individualInformation += "<br><br><b>Types:</b><br>"; for (NamedClass dlLearnerClass : types) { individualInformation += dlLearnerClass .toManchesterSyntaxString( @@ -146,6 +156,43 @@ } individualInformation += "<br>"; } + if (v.get(i).getIndividualOWL() != null) { + Set<OWLDataPropertyAssertionAxiom> dataProperties = ontology + .getDataPropertyAssertionAxioms(v.get(i) + .getIndividualOWL()); + individualInformation += "<br><b>Dataproperties</b><br>"; + for (OWLDataPropertyAssertionAxiom dataProperty : dataProperties) { + individualInformation += dataProperty.toString() + + "<br>"; + } + + Set<OWLNegativeObjectPropertyAssertionAxiom> negObjects = ontology.getNegativeObjectPropertyAssertionAxioms(v.get(i).getIndividualOWL()); + individualInformation += "<br><b>negative ObjectProperties</b><br>"; + for (OWLNegativeObjectPropertyAssertionAxiom negObject : negObjects) { + individualInformation += negObject.toString() + + "<br>"; + } + + Set<OWLNegativeDataPropertyAssertionAxiom> negDatas = ontology.getNegativeDataPropertyAssertionAxioms(v.get(i).getIndividualOWL()); + individualInformation += "<br><b>negative Dataproperties</b><br>"; + for (OWLNegativeDataPropertyAssertionAxiom negData : negDatas) { + individualInformation += negData.toString() + + "<br>"; + } + Set<OWLSameIndividualsAxiom> sameIndies = ontology.getSameIndividualAxioms(v.get(i).getIndividualOWL()); + individualInformation += "<br><b>Same Individuals</b><br>"; + for (OWLSameIndividualsAxiom sameIndie : sameIndies) { + individualInformation += sameIndie.toString() + + "<br>"; + } + + Set<OWLDifferentIndividualsAxiom> differentIndies = ontology.getDifferentIndividualAxioms(v.get(i).getIndividualOWL()); + individualInformation += "<br><b>Different Individuals</b><br>"; + for (OWLDifferentIndividualsAxiom differentIndie : differentIndies) { + individualInformation += differentIndie.toString() + + "<br>"; + } + } } individualInformation += "</body></htlm>"; panel.getGraphicalCoveragePanel().setToolTipText( Modified: trunk/src/dl-learner/org/dllearner/tools/protege/IndividualPoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualPoint.java 2009-11-26 13:24:53 UTC (rev 1922) +++ trunk/src/dl-learner/org/dllearner/tools/protege/IndividualPoint.java 2009-11-26 14:10:09 UTC (rev 1923) @@ -22,6 +22,7 @@ import java.awt.geom.Ellipse2D; import org.dllearner.core.owl.Individual; +import org.semanticweb.owl.model.OWLIndividual; /** * This class is a datastructure for one individual shown in @@ -38,6 +39,7 @@ private final Ellipse2D circlePoint; private Individual individualDLLearner; private String baseUri; + private OWLIndividual individualOWL; /** * Constructor of the class. @@ -74,6 +76,27 @@ this.individualDLLearner = indi; this.baseUri = base; } + + /** + * + * @param p + * @param x + * @param y + * @param ind + * @param indi + * @param base + */ + public IndividualPoint(String p, int x, int y, String ind, OWLIndividual indi, Individual indiDLLearner, String base) { + this.point = p; + this.xAxis = x; + this.yAxis = y; + this.circlePoint = new Ellipse2D.Double(x-1, y-1, 4, 4); + this.individual = ind; + this.individualOWL = indi; + this.individualDLLearner = indiDLLearner; + this.baseUri = base; + + } /** * This method returns the display string of the individual. @@ -130,4 +153,12 @@ public String getBaseUri() { return baseUri; } + + /** + * + * @return + */ + public OWLIndividual getIndividualOWL() { + return individualOWL; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2009-11-26 13:24:53 UTC (rev 1922) +++ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2009-11-26 14:10:09 UTC (rev 1923) @@ -6,7 +6,7 @@ Bundle-Description: Protege DL-Learner Plugin Bundle-Vendor: DL-Learner Project Bundle-DocURL: http://dl-learner.org/wiki/ProtegePlugin -Bundle-ClassPath: .,lib/junit-4.4.jar,lib/jamon-2.7.jar,lib/pellet/pellet-core.jar,lib/pellet/pellet-datatypes.jar,lib/ore-tool/BrowserLauncher2-all-1_3.jar,lib/pellet/pellet-el.jar,lib/pellet/pellet-explanation.jar,lib/pellet/pellet-owlapi.jar,lib/pellet/pellet-rules.jar,lib/pellet/aterm-java-1.6.jar,lib/jena/json.jar,lib/pellet/relaxngDatatype.jar,lib/pellet/xsdlib.jar,lib/jena/commons-logging-1.1.1.jar,lib/ore-tool/swingx-0.9.2.jar +Bundle-ClassPath: .,lib/junit-4.4.jar,lib/jamon-2.7.jar,lib/pellet/pellet-core.jar,lib/pellet/pellet-datatypes.jar,lib/ore-tool/BrowserLauncher2-all-1_3.jar,lib/pellet/pellet-el.jar,lib/pellet/pellet-explanation.jar,lib/pellet/pellet-owlapi.jar,lib/pellet/pellet-rules.jar,lib/pellet/aterm-java-1.6.jar,lib/jena/json.jar,lib/pellet/relaxngDatatype.jar,lib/pellet/xsdlib.jar,lib/jena/commons-logging-1.1.1.jar,lib/ore-tool/swingx-0.9.2.jar,lib/owlapi/owlapiV3-bin.jar Import-Package: org.osgi.framework,org.apache.log4j Export-Package: lib Bundle-Version: 0.5.2 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2010-01-25 21:21:15
|
Revision: 1985 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1985&view=rev Author: heeroyuy Date: 2010-01-25 21:21:08 +0000 (Mon, 25 Jan 2010) Log Message: ----------- -seperate graphicalPanel from textfield -centered text for helpmessages Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-01-05 11:17:30 UTC (rev 1984) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-01-25 21:21:08 UTC (rev 1985) @@ -20,6 +20,7 @@ package org.dllearner.tools.protege; import java.awt.Color; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; @@ -30,7 +31,6 @@ import javax.swing.DefaultListModel; import javax.swing.JOptionPane; -import javax.swing.JTextPane; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; @@ -51,7 +51,7 @@ // This is the DLLearnerModel. private final DLLearnerModel model; - private HyperLinkHandler hyperHandler; + // This is the id that checks if the equivalent class or subclass button is // pressed in protege @@ -63,15 +63,16 @@ private Timer timer; private LearningAlgorithm la; private SuggestionRetriever retriever; + private HelpTextPanel helpPanel; private final Color colorRed = new Color(139, 0, 0); private final Color colorGreen = new Color(0, 139, 0); private final DLLearnerView view; private static final String HELP_BUTTON_STRING = "help"; - private JTextPane 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 JOptionPane optionPane; /** * This is the constructor for the action handler. @@ -86,7 +87,9 @@ this.view = view; this.model = m; toggled = false; - hyperHandler = view.getHyperLinkHandler(); + helpPanel = new HelpTextPanel(view); + optionPane = new JOptionPane(); + } @@ -99,8 +102,7 @@ public void actionPerformed(ActionEvent z) { if (z.getActionCommand().equals(EQUIVALENT_CLASS_LEARNING_STRING) - || z.getActionCommand() - .equals(SUPER_CLASS_LEARNING_STRING)) { + || z.getActionCommand().equals(SUPER_CLASS_LEARNING_STRING)) { model.setKnowledgeSource(); view.getSuggestClassPanel().getSuggestModel().clear(); view.getSuggestClassPanel().repaint(); @@ -148,32 +150,22 @@ } } if (z.toString().contains(HELP_BUTTON_STRING)) { - + Set<String> uris = model.getOntologyURIString(); String currentClass = ""; - for(String uri : uris) { - if(model.getCurrentConcept().toString().contains(uri)) { - currentClass = model.getCurrentConcept().toManchesterSyntaxString(uri, null); + for (String uri : uris) { + if (model.getCurrentConcept().toString().contains(uri)) { + currentClass = model.getCurrentConcept() + .toManchesterSyntaxString(uri, null); } } - String helpText = "<html><font size=\"3\">What does a sentence like 'Learning started. Currently searching class expressions with length between 4 and 7.' mean?<br><br>" - + "Length: In Manchester OWL Syntax (the syntax used for class expressions in Protege), we define length <br>simply as the number of words needed to write down the class expression.<br><br>" - + "The learning algorithm (called CELOE) for suggesting class expressions starts with the most general expression <br>owl:Thing and then further specializes it.<br>" - + "Those class expressions, which fit the existing instances of a given class (" + currentClass + " in this case) get <br>a high accuracy and are displayed as suggestions.<br>" - + "The learning algorithm prefers short expressions. 'Currently searching class expressions with length between 4 and 7.' <br>means that it has already evaluated all class expressions of length 1 to 3<br>" - + "or excluded them as possible suggestions. All the expressions currently evaluated have length between 4 and 7. If you <br>want to search for longer expressions, then you have to increase<br>" - + "the maximum runtime setting (it is set to " + view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime() + " <br>seconds by default).<br><br>" - + "See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">Protege Plugin Wiki</a> for more details.</font></html>"; - - help = new JTextPane(); - help.setEditable(false); - help.setContentType("text/html"); - help.setForeground(Color.black); - help.addHyperlinkListener(hyperHandler); - help.setBackground(view.getLearnerView().getBackground()); - help.setText(helpText); - - JOptionPane.showMessageDialog(null, help, "Help", + + //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); } } @@ -186,13 +178,16 @@ } /** - * This Methode sets the evaluated class expression that is selected - * in the panel. - * @param desc evaluated descriptions + * 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; } + /** * Inner Class that retrieves the concepts given by the DL-Learner. * @@ -212,13 +207,17 @@ throws Exception { setProgress(0); la = model.getLearningAlgorithm(); - view.getStatusBar().setMaximumValue(view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); + view.getStatusBar().setMaximumValue( + view.getPosAndNegSelectPanel().getOptionPanel() + .getMaxExecutionTime()); timer = new Timer(); timer.schedule(new TimerTask() { int progress = 0; + @Override public void run() { - progress += 1;setProgress(progress); + progress += 1; + setProgress(progress); if (la != null) { publish(la.getCurrentlyBestEvaluatedDescriptions(view .getPosAndNegSelectPanel().getOptionPanel() @@ -228,7 +227,8 @@ String moreInformationsMessage = "<html><font size=\"3\">Learning started. Currently searching class expressions with length between " + celoe.getMinimumHorizontalExpansion() + " and " - + celoe.getMaximumHorizontalExpansion() + ".</font></html>"; + + celoe.getMaximumHorizontalExpansion() + + ".</font></html>"; view.setHintMessage(moreInformationsMessage); } } @@ -266,7 +266,7 @@ public void done() { timer.cancel(); - + List<? extends EvaluatedDescription> result = null; try { result = get(); @@ -280,7 +280,6 @@ updateList(result); view.algorithmTerminated(); - } @Override @@ -291,7 +290,7 @@ updateList(list); } } - + private void updateList( final List<? extends EvaluatedDescription> result) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2010-01-05 11:17:30 UTC (rev 1984) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2010-01-25 21:21:08 UTC (rev 1985) @@ -21,8 +21,6 @@ import java.awt.AlphaComposite; import java.awt.Color; -import java.awt.Composite; -import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; @@ -102,7 +100,6 @@ public GraphicalCoveragePanel(EvaluatedDescription desc, DLLearnerModel m) { this.setVisible(false); this.setForeground(Color.GREEN); - this.setPreferredSize(new Dimension(540, 230)); eval = desc; model = m; id = model.getID(); @@ -150,82 +147,11 @@ if (eval != null) { Graphics2D g2D; g2D = (Graphics2D) g; - Composite original = g2D.getComposite(); AlphaComposite ac = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.5f); - g2D.setColor(Color.BLACK); - g2D.drawString(model.getOldConceptOWLAPI().toString(), 320, 10); - g2D.setColor(Color.ORANGE); - g2D.fillOval(310, 20, 9, 9); - g2D.setColor(Color.black); - int p = 30; - for (int i = 0; i < conceptVector.size(); i++) { - g2D.drawString(conceptVector.get(i), 320, p); - p = p + 20; - } - g2D.setColor(darkGreen); - Ellipse2D circlePoint = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); - g2D.fill(circlePoint); - g2D.setColor(Color.BLACK); - g2D.drawString("<html>individuals covered by", 320, p); - g2D.setColor(Color.ORANGE); - g2D.fillOval(455, p - 9, 9, 9); - g2D.setColor(Color.BLACK); - g2D.drawString("and", 485, p); - g2D.setColor(Color.YELLOW); - g2D.fillOval(525, p - 9, 9, 9); - g2D.setColor(Color.BLACK); - p = p + 20; - g2D.drawString("(OK)</html>", 320, p); - p = p + 20; - if(id.equals(EQUI_STRING)) { - g2D.setColor(darkRed); - Ellipse2D circlePoint2 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); - g2D.fill(circlePoint2); - g2D.setColor(Color.BLACK); - g2D.drawString("<html>individuals covered by", 320, p); - g2D.setColor(Color.ORANGE); - g2D.fillOval(455, p - 9, 9, 9); - g2D.setColor(Color.BLACK); - p = p + 20; - g2D.drawString("(potential problem)</html>", 320, p); - p = p + 20; - g2D.setColor(darkRed); - Ellipse2D circlePoint3 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); - g2D.fill(circlePoint3); - g2D.setColor(Color.BLACK); - g2D.drawString("<html>individuals covered by", 320, p); - g2D.setColor(Color.YELLOW); - g2D.fillOval(455, p - 9, 9, 9); - g2D.setColor(Color.BLACK); - p = p + 20; - g2D.drawString("(potential problem)</html>", 320, p); - } else { - g2D.setColor(Color.BLACK); - Ellipse2D circlePoint2 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); - g2D.fill(circlePoint2); - g2D.drawString("<html>individuals covered by", 320, p); - g2D.setColor(Color.ORANGE); - g2D.fillOval(455, p - 9, 9, 9); - g2D.setColor(Color.BLACK); - p = p + 20; - g2D.drawString("(no problem)</html>", 320, p); - p = p + 20; - g2D.setColor(darkRed); - Ellipse2D circlePoint3 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); - g2D.fill(circlePoint3); - g2D.setColor(Color.BLACK); - g2D.drawString("<html>individuals covered by", 320, p); - g2D.setColor(Color.YELLOW); - g2D.fillOval(455, p - 9, 9, 9); - g2D.setColor(Color.BLACK); - p = p + 20; - g2D.drawString("(potential problem)</html>", 320, p); - } g2D.setColor(Color.YELLOW); g2D.fill(oldConcept); - g2D.fillOval(310, 0, 9, 9); g2D.setColor(Color.ORANGE); g2D.setComposite(ac); g2D.fill(newConcept); @@ -356,22 +282,6 @@ g2D.setColor(Color.BLACK); g2D.fill(additionalIndividuals.get(i).getIndividualPoint()); } - if(!((EvaluatedDescriptionClass) eval).isConsistent()) { - g2D.setComposite(original); - g2D.setColor(darkRed); - g2D.drawString("Adding this class expression may lead to an inconsistent ontology.", 0, 220); - } - if(eval.getAccuracy() == 1.0) { - g2D.setComposite(original); - g2D.setColor(Color.ORANGE); - g2D.fillOval(0, 211, 9, 9); - g2D.setColor(darkRed); - g2D.drawString("and", 25, 220); - g2D.setColor(Color.YELLOW); - g2D.fillOval(65, 211, 9, 9); - g2D.setColor(darkRed); - g2D.drawString("cover the same instances.", 95, 220); - } this.setVisible(true); } } Added: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java 2010-01-25 21:21:08 UTC (rev 1985) @@ -0,0 +1,89 @@ +/** + * 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 javax.swing.JScrollPane; +import javax.swing.JTextPane; + +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.learningproblems.EvaluatedDescriptionClass; + +public class GraphicalCoverageTextField extends JTextPane{ + + private static final long serialVersionUID = 8971091768497004453L; + private static final String EQUI_STRING = "equivalent class"; + private final String id; + private DLLearnerModel model; + EvaluatedDescription description; + private String conceptNew; + private final JScrollPane textScroll; + + public GraphicalCoverageTextField(EvaluatedDescription desc, DLLearnerModel m) { + this.setContentType("text/html"); + this.setEditable(false); + this.model = m; + textScroll = new JScrollPane( + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + this.setBackground(model.getOWLEditorKit().getOWLWorkspace().getOWLComponentFactory().getOWLClassSelectorPanel().getBackground()); + this.id = model.getID(); + this.description = desc; + + for(String uri : model.getOntologyURIString()) { + if(description.getDescription().toString().contains(uri)) { + conceptNew = description.getDescription().toManchesterSyntaxString(uri, null); + } + } + this.setText(); + } + + private void setText() { + int coveredInstances = ((EvaluatedDescriptionClass) description).getCoveredInstances().size(); + int allInstances = coveredInstances + ((EvaluatedDescriptionClass) description).getNotCoveredInstances().size(); + int coverage = (int)(((EvaluatedDescriptionClass) description).getCoverage() * 100); + String text ="<html><p><font size=\"3\" color=\"yellow\">\u25cf</font><font size=\"3\" color=\"black\"> " + model.getOldConceptOWLAPI().toString() + "</font></p>" + + "<p style=\"max-width:50px;\"><font size=\"3\" color=\"EE9A00\">\u25cf</font><font size=\"3\" color=\"black\"> " + conceptNew + "</font></p>" + + "<p><font size=\"1\" color=\"green\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font> <font size=\"3\" color=\"EE9A00\">\u25cf</font>" + + "<font size=\"3\" color=\"black\"> and </font> <font size=\"3\" color=\"yellow\">\u25cf</font><font size=\"3\" color=\"black\"> (OK)</font></p> "; + if(id.equals(EQUI_STRING)) { + text += "<p><font size=\"1\" color=\"red\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"EE9A00\">\u25cf</font></font><font size=\"3\" color=\"black\"> (potential problem)</font></p>" + + "<p><font size=\"1\" color=\"red\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"yellow\">\u25cf</font></font><font size=\"3\" color=\"black\"> (potential problem)</font></p>"; + } else { + text += "<p><font size=\"1\" color=\"green\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"EE9A00\">\u25cf</font></font><font size=\"3\" color=\"black\"> (no problem)</font></p>" + + "<p><font size=\"1\" color=\"red\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"yellow\">\u25cf</font></font><font size=\"3\" color=\"black\"> (potential problem)</font></p>";; + } + text += "<p><font size=\"3\" color=\"black\">Covers " + coveredInstances + + " of " + allInstances + "(" + coverage + " %) of class instances</font></p>" + + "<p><font size=\"3\" color=\"black\">Covers " + ((EvaluatedDescriptionClass) description).getAdditionalInstances().size() + " additional instances</font></p>"; + if(!((EvaluatedDescriptionClass) description).isConsistent()) { + text += "<p style=\"max-width:100px;\"><font size=\"3\" color=\"red\">Adding this class expression may lead to an inconsistent ontology.</font></p>"; + } + if(description.getAccuracy() == 1.0) { + text += "<p><font size=\"3\" color=\"EE9A00\">\u25cf</font><font size=\"3\" color=\"black\"> and </font> <font size=\"3\" color=\"yellow\">\u25cf</font> cover the same instances.</p>"; + } + text += "</html>"; + this.setText(text); + textScroll.setViewportView(this); + } + + public JScrollPane getTextScroll() { + return textScroll; + } +} Added: trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java 2010-01-25 21:21:08 UTC (rev 1985) @@ -0,0 +1,63 @@ +/** + * 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.Color; +import java.awt.Dimension; + +import javax.swing.JTextPane; + +public class HelpTextPanel extends JTextPane{ + + private static final long serialVersionUID = 5077192574709760571L; + private HyperLinkHandler hyperHandler; + private DLLearnerView view; + public HelpTextPanel(DLLearnerView v) { + this.view = v; + hyperHandler = view.getHyperLinkHandler(); + } + + public JTextPane renderHelpTextMessage(String currentClass) { + String helpText = "<html><p style=\"text-align: justify;\">What does a sentence like 'Learning started. Currently searching class expressions with length between 4 and 7.' mean?</p>" + + "<p style=\"text-align: justify;\">Length: In Manchester OWL Syntax (the syntax used for class expressions in Protege), we define length simply as the" + + "number of words needed to write down the class expression.</p>" + + "<p style=\"text-align: justify;\">The learning algorithm (called CELOE) for suggesting class expressions starts with the most general expression owl:Thing" + + " and then further specializes it. Those class expressions, which fit the existing instances of a given class (" + + currentClass + + " in this case)" + + "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() + + " seconds by default).</p>" + + "<p>See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">Protege Plugin Wiki</a> for more details.</p></html>"; + this.setEditable(false); + this.setOpaque(true); + this.setPreferredSize(new Dimension(500, 370)); + this.setContentType("text/html"); + this.setForeground(Color.black); + this.addHyperlinkListener(hyperHandler); + this.setBackground(view.getLearnerView().getBackground()); + this.setText(helpText); + this.setVisible(true); + return this; + } +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2010-01-05 11:17:30 UTC (rev 1984) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2010-01-25 21:21:08 UTC (rev 1985) @@ -19,6 +19,7 @@ */ package org.dllearner.tools.protege; import java.awt.Dimension; +import java.awt.GridLayout; import javax.swing.JPanel; @@ -42,10 +43,10 @@ private final DLLearnerModel model; private EvaluatedDescription eval; - //private final JTextArea concept; private static final int HEIGHT = 230; private static final int WIDTH = 540; - private GraphicalCoveragePanel p; + private GraphicalCoveragePanel graphicalPanel; + private GraphicalCoverageTextField graphicalText; /** * This is the constructor for the Panel. @@ -53,7 +54,7 @@ */ public MoreDetailForSuggestedConceptsPanel(DLLearnerModel model) { super(); - setLayout(null); + setLayout(new GridLayout(1, 2)); setPreferredSize(new Dimension(WIDTH, HEIGHT)); this.model = model; } @@ -67,11 +68,13 @@ //panel for the informations of the selected concept //this method adds the informations for the selected concept to the panel - p = new GraphicalCoveragePanel(eval, model); - p.setBounds(5, 0, 600, 700); + graphicalPanel = new GraphicalCoveragePanel(eval, model); + graphicalText = new GraphicalCoverageTextField(eval, model); + graphicalPanel.setBounds(5, 0, 300, 350); //adds all information to the example panel unsetEverything(); - this.add(p); + this.add(graphicalPanel, "Center"); + this.add(graphicalText.getTextScroll(), "East"); } private void unsetEverything() { @@ -84,7 +87,7 @@ * @return graphical coverage panel */ public GraphicalCoveragePanel getGraphicalCoveragePanel() { - return p; + return graphicalPanel; } /** @@ -92,8 +95,8 @@ */ public void unsetPanel() { unsetEverything(); - if(p != null) { - p.unsetPanel(); + if(graphicalPanel != null) { + graphicalPanel.unsetPanel(); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2010-02-11 08:10:57
|
Revision: 2009 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2009&view=rev Author: heeroyuy Date: 2010-02-11 08:10:50 +0000 (Thu, 11 Feb 2010) Log Message: ----------- -fixed some spelling mistakes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-02-10 14:16:26 UTC (rev 2008) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-02-11 08:10:50 UTC (rev 2009) @@ -123,7 +123,7 @@ private int individualSize; private SuggestClassPanelHandler sugPanelHandler; private StatusBar stat; - private static final String WIKI_STRING = "<html><font size=\"3\">See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">Protege Plugin Wiki</a> for an introduction.</font></html>"; + 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>"; /** * The constructor for the DL-Learner tab in the class description Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java 2010-02-10 14:16:26 UTC (rev 2008) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java 2010-02-11 08:10:50 UTC (rev 2009) @@ -19,7 +19,7 @@ */ package org.dllearner.tools.protege; -import javax.swing.JScrollPane; +//import javax.swing.JScrollPane; import javax.swing.JTextPane; import org.dllearner.core.EvaluatedDescription; @@ -33,15 +33,15 @@ private DLLearnerModel model; EvaluatedDescription description; private String conceptNew; - private final JScrollPane textScroll; + //private final JScrollPane textScroll; public GraphicalCoverageTextField(EvaluatedDescription desc, DLLearnerModel m) { this.setContentType("text/html"); this.setEditable(false); this.model = m; - textScroll = new JScrollPane( - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + //textScroll = new JScrollPane( + // JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + // JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.setBackground(model.getOWLEditorKit().getOWLWorkspace().getOWLComponentFactory().getOWLClassSelectorPanel().getBackground()); this.id = model.getID(); this.description = desc; @@ -80,10 +80,10 @@ } text += "</html>"; this.setText(text); - textScroll.setViewportView(this); + //textScroll.setViewportView(this); } - public JScrollPane getTextScroll() { - return textScroll; + public JTextPane getTextScroll() { + return this; } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java 2010-02-10 14:16:26 UTC (rev 2008) +++ trunk/src/dl-learner/org/dllearner/tools/protege/HelpTextPanel.java 2010-02-11 08:10:50 UTC (rev 2009) @@ -36,19 +36,19 @@ public JTextPane renderHelpTextMessage(String currentClass) { String helpText = "<html><p style=\"text-align: justify;\">What does a sentence like 'Learning started. Currently searching class expressions with length between 4 and 7.' mean?</p>" - + "<p style=\"text-align: justify;\">Length: In Manchester OWL Syntax (the syntax used for class expressions in Protege), we define length simply as the" + + "<p style=\"text-align: justify;\">Length: In Manchester OWL Syntax (the syntax used for class expressions in Protege), we define length simply as the " + "number of words needed to write down the class expression.</p>" + "<p style=\"text-align: justify;\">The learning algorithm (called CELOE) for suggesting class expressions starts with the most general expression owl:Thing" + " and then further specializes it. Those class expressions, which fit the existing instances of a given class (" + currentClass - + " in this case)" + + " in this case) " + "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" + + " 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() + " seconds by default).</p>" - + "<p>See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">Protege Plugin Wiki</a> for more details.</p></html>"; + + "<p>See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">DL-Learner plugin page</a> for more details.</p></html>"; this.setEditable(false); this.setOpaque(true); this.setPreferredSize(new Dimension(500, 370)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2010-02-11 10:43:40
|
Revision: 2012 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2012&view=rev Author: heeroyuy Date: 2010-02-11 10:43:34 +0000 (Thu, 11 Feb 2010) Log Message: ----------- -set status bar visible only when learning process is started Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/StatusBar2.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-02-11 09:17:55 UTC (rev 2011) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-02-11 10:43:34 UTC (rev 2012) @@ -207,6 +207,7 @@ throws Exception { setProgress(0); la = model.getLearningAlgorithm(); + view.setStatusBarVisible(true); view.getStatusBar().setMaximumValue( view.getPosAndNegSelectPanel().getOptionPanel() .getMaxExecutionTime()); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-02-11 09:17:55 UTC (rev 2011) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-02-11 10:43:34 UTC (rev 2012) @@ -40,7 +40,6 @@ import javax.swing.JToggleButton; import org.dllearner.algorithms.celoe.CELOE; -import org.dllearner.tools.ore.ui.StatusBar; import org.protege.editor.owl.OWLEditorKit; import org.semanticweb.owl.model.OWLDescription; /** @@ -122,7 +121,7 @@ private String labels; private int individualSize; private SuggestClassPanelHandler sugPanelHandler; - private StatusBar stat; + private StatusBar2 stat; 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>"; /** @@ -167,7 +166,9 @@ runPanel = new JPanel(new FlowLayout()); accept = new JButton("<html>ADD</html>"); addButtonPanel = new JPanel(new BorderLayout()); - stat = new StatusBar(); + stat = new StatusBar2(); + stat.setBackground(learnerScroll.getBackground()); + this.setStatusBarVisible(false); hint = new JTextPane(); hint.setBackground(learnerScroll.getBackground()); hint.setContentType("text/html"); @@ -346,6 +347,13 @@ return helpButton; } /** + * This method sets the status bar visible when learning + * is started. + */ + public void setStatusBarVisible(boolean b) { + stat.setVisible(b); + } + /** * This method enables the GraphicalCoveragePanel after a class expression is * selected from the list. */ @@ -513,6 +521,7 @@ */ public void algorithmTerminated() { CELOE celoe = (CELOE) model.getLearningAlgorithm(); + 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."; hint.setForeground(Color.RED); if(isInconsistent) { @@ -575,7 +584,7 @@ * This methode returns the statusbar. * @return statusbar */ - public StatusBar getStatusBar() { + public StatusBar2 getStatusBar() { return stat; } Added: trunk/src/dl-learner/org/dllearner/tools/protege/StatusBar2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/StatusBar2.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/StatusBar2.java 2010-02-11 10:43:34 UTC (rev 2012) @@ -0,0 +1,214 @@ +package org.dllearner.tools.protege; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Set; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JSeparator; +import javax.swing.SwingUtilities; +import javax.swing.Timer; + +import org.mindswap.pellet.utils.progress.ProgressMonitor; +import org.semanticweb.owl.model.OWLAxiom; + +import com.clarkparsia.explanation.util.ExplanationProgressMonitor; + +public class StatusBar2 extends JPanel implements ProgressMonitor, ExplanationProgressMonitor, PropertyChangeListener { + /** + * + */ + private static final long serialVersionUID = 1L; + private JLabel infoLabel; + private JProgressBar progressBar; + + private boolean cancelled; + + private boolean indeterminate; + + private static final int CANCEL_TIMEOUT_MS = 5000; + + private Timer cancelTimeout; + + private int progress; + private int progressLength; + private String progressTitle; + + public StatusBar2() { + setLayout(new BorderLayout()); + + infoLabel = new JLabel(""); + progressBar = new JProgressBar(); + + JPanel rightPanel = new JPanel(new BorderLayout()); + rightPanel.setOpaque(false); + JPanel leftPanel = new JPanel(new FlowLayout()); + + leftPanel.add(progressBar); + leftPanel.add(new JSeparator(JSeparator.VERTICAL)); + leftPanel.add(infoLabel); + leftPanel.add(new JSeparator(JSeparator.VERTICAL)); + leftPanel.setOpaque(false); + add(leftPanel, BorderLayout.WEST); +// add(rightPanel, BorderLayout.EAST); +// setBackground(SystemColor.control); + + cancelTimeout = new Timer(CANCEL_TIMEOUT_MS, new ActionListener() { + public void actionPerformed(ActionEvent event) { + + } + }); + cancelTimeout.setRepeats(false); + } + + public void setMessage(String message) { + infoLabel.setText(message); + } + + public void showProgress(boolean b) { + cancelled = false; + indeterminate = b; + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + progressBar.setIndeterminate(indeterminate); + + } + }); + } + + public void setMaximumValue(int max) { + progressBar.setMaximum(max); + } + + @Override + public void foundAllExplanations() { + // TODO Auto-generated method stub + + } + + @Override + public void foundExplanation(Set<OWLAxiom> explanation) { + + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + setProgress(progress); + } + + } + + @Override + public int getProgress() { + return progress; + } + + @Override + public int getProgressPercent() { + return (int) (progress * 100.0) / progressBar.getMaximum(); + } + + @Override + public void incrementProgress() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + progressBar.setValue(progress++); + // double percentDone = (progress * 100.0) / + // progressBar.getMaximum(); + // if(percentDone / 100.0 == 0) { + // label.setText("Classifying ontology " + getProgressPercent() + // + " %"); + // } + } + }); + + } + + @Override + public boolean isCanceled() { + return cancelled; + } + + @Override + public void setProgress(int progr) { + this.progress = progr; + SwingUtilities.invokeLater(new Runnable() { + public void run() { + progressBar.setValue((int) progress); + } + }); + + } + + @Override + public void setProgressLength(int length) { + this.progressLength = length; + SwingUtilities.invokeLater(new Runnable() { + public void run() { + progressBar.setValue(0); + progressBar.setMaximum((int) progressLength); + } + }); + + } + + @Override + public void setProgressMessage(String message) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + // label.setText(message); + } + }); + + } + + @Override + public void setProgressTitle(String title) { + this.progressTitle = title; + SwingUtilities.invokeLater(new Runnable() { + public void run() { + infoLabel.setText(progressTitle + "..."); + } + }); + + } + + @Override + public void taskFinished() { + cancelTimeout.stop(); + progress = 0; + SwingUtilities.invokeLater(new Runnable() { + public void run() { + progressBar.setValue(progress); + } + }); + + } + + @Override + public void taskStarted() { + + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + progressBar.setIndeterminate(false); + } + }); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2010-03-01 16:37:56
|
Revision: 2079 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2079&view=rev Author: heeroyuy Date: 2010-03-01 16:37:49 +0000 (Mon, 01 Mar 2010) Log Message: ----------- -added a default profile for learning algorithm Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanelHandler.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2010-03-01 15:41:48 UTC (rev 2078) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2010-03-01 16:37:49 UTC (rev 2079) @@ -50,6 +50,7 @@ private JRadioButton owlRadioButton; private JRadioButton elProfileButton; + private JRadioButton defaultProfileButton; private JCheckBox allBox; private JCheckBox someBox; @@ -109,22 +110,24 @@ nrOfConcepts.setMinorTickSpacing(1); nrOfConcepts.setPaintLabels(true); - owlRadioButton = new JRadioButton("<html>OWL 2</html>", true); + owlRadioButton = new JRadioButton("<html>OWL 2</html>", false); elProfileButton = new JRadioButton("<html>EL Profile</html>", false); + defaultProfileButton = new JRadioButton("<html>Default</html>", true); owlRadioButton.setEnabled(true); - owlRadioButton.addItemListener(optionHandler); - elProfileButton.addItemListener(optionHandler); + owlRadioButton.addActionListener(optionHandler); + elProfileButton.addActionListener(optionHandler); + defaultProfileButton.addActionListener(optionHandler); allBox = new JCheckBox("<html>all</html>", true); - allBox.addItemListener(optionHandler); + //allBox.addItemListener(optionHandler); someBox = new JCheckBox("<html>some</html>", true); - someBox.addItemListener(optionHandler); - notBox = new JCheckBox("<html>not</html>", true); - notBox.addItemListener(optionHandler); - valueBox = new JCheckBox("<html>value</html>", true); - valueBox.addItemListener(optionHandler); + //someBox.addItemListener(optionHandler); + notBox = new JCheckBox("<html>not</html>", false); + //notBox.addItemListener(optionHandler); + valueBox = new JCheckBox("<html>value</html>", false); + //valueBox.addItemListener(optionHandler); moreBox = new JCheckBox("<html> ‹=x, ›=x with max.:</html>", true); - moreBox.addItemListener(optionHandler); + //moreBox.addItemListener(optionHandler); countMoreBox = new JComboBox(); countMoreBox.addItem(1); @@ -192,6 +195,7 @@ radioBoxPanel.add(owlRadioButton); radioBoxPanel.add(elProfileButton); + radioBoxPanel.add(defaultProfileButton); profilePanel.add(radioBoxPanel); profilePanel.add(checkBoxPanel); @@ -250,6 +254,10 @@ public JRadioButton getElProfileButton() { return elProfileButton; } + + public JRadioButton getDefaultProfileButton() { + return defaultProfileButton; + } /** * This methode returns if the allquantor box is selected. @@ -313,6 +321,9 @@ */ public void setToOWLProfile() { allBox.setSelected(true); + owlRadioButton.setSelected(true); + elProfileButton.setSelected(false); + defaultProfileButton.setSelected(false); someBox.setSelected(true); notBox.setSelected(true); valueBox.setSelected(true); @@ -330,9 +341,24 @@ notBox.setSelected(false); valueBox.setSelected(false); moreBox.setSelected(false); + owlRadioButton.setSelected(false); + elProfileButton.setSelected(true); + defaultProfileButton.setSelected(false); this.setCountMoreBoxEnabled(false); } + public void setToDefaultProfile() { + allBox.setSelected(true); + someBox.setSelected(true); + notBox.setSelected(false); + valueBox.setSelected(false); + moreBox.setSelected(true); + owlRadioButton.setSelected(false); + elProfileButton.setSelected(false); + defaultProfileButton.setSelected(true); + this.setCountMoreBoxEnabled(true); + } + /** * This methode sets the combo box for the cardinality restriction * enabled/disabled. Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanelHandler.java 2010-03-01 15:41:48 UTC (rev 2078) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanelHandler.java 2010-03-01 16:37:49 UTC (rev 2079) @@ -19,18 +19,19 @@ */ package org.dllearner.tools.protege; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * This class handles the all actions in the option panel. * @author Christian Koetteritzsch * */ -public class OptionPanelHandler implements ItemListener { +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 OptionPanel option; @@ -43,28 +44,23 @@ this.option = o; } - + @Override /** * This method handles the actions to be taken if a * radio button is selected/deselected. */ - public void itemStateChanged(ItemEvent e) { + public void actionPerformed(ActionEvent e) { if (e.toString().contains(OWL_RADIO_STRING)) { - if (option.getOwlRadioButton().isSelected()) { this.setToOWLProfile(); - } else { + } + if (e.toString().contains(EL_RADIO_STRING)) { this.setToELProfile(); - } - - } else if (e.toString().contains(EL_RADIO_STRING)) { - if (option.getElProfileButton().isSelected()) { - this.setToELProfile(); - } else { - this.setToOWLProfile(); - } - - } else if(e.toString().contains(VALUE_STRING)) { + } + if (e.toString().contains(DEFAULT_RADIO_STRING)) { + this.setToDefaultProfile(); + } + if(e.toString().contains(VALUE_STRING)) { if(option.getMoreBox()) { option.setCountMoreBoxEnabled(true); } else { @@ -74,17 +70,19 @@ } private void setToOWLProfile() { - option.getOwlRadioButton().setSelected(true); - option.getElProfileButton().setSelected(false); option.setToOWLProfile(); } private void setToELProfile() { - option.getOwlRadioButton().setSelected(false); - option.getElProfileButton().setSelected(true); option.setToELProfile(); } + + private void setToDefaultProfile() { + option.setToDefaultProfile(); + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2010-03-03 22:10:19
|
Revision: 2085 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2085&view=rev Author: lorenz_b Date: 2010-03-03 22:09:59 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Some changes in class expression rendering. 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/META-INF/MANIFEST.MF trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.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/SuggestListCellRenderer.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/ProgressBarTableCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-03-03 21:19:27 UTC (rev 2084) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-03-03 22:09:59 UTC (rev 2085) @@ -305,42 +305,45 @@ 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, new SuggestListItem(colorGreen, - eval.getDescription() - .toManchesterSyntaxString( - ontology, null), - ((EvaluatedDescriptionClass) eval) - .getAccuracy() * 100)); - i++; - break; - } else { - 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(); +// 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); } }; SwingUtilities.invokeLater(doUpdateList); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-03-03 21:19:27 UTC (rev 2084) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-03-03 22:09:59 UTC (rev 2085) @@ -187,6 +187,7 @@ sugPanelHandler = new SuggestClassPanelHandler(this, model, action); sugPanel.addSuggestPanelMouseListener(sugPanelHandler); sugPanel.getSuggestList().addListSelectionListener(sugPanelHandler); + sugPanel.getSuggestionsTable().getSelectionModel().addListSelectionListener(sugPanelHandler); this.addAcceptButtonListener(this.action); this.addRunButtonListener(this.action); this.addAdvancedButtonListener(this.action); @@ -437,6 +438,7 @@ public void dispose() { this.unsetEverything(); sugPanel.getSuggestList().removeAll(); + sugPanel.getSuggestionsTable().clear(); learner.removeAll(); sugPanel = null; model.getSuggestModel().clear(); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2010-03-03 21:19:27 UTC (rev 2084) +++ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2010-03-03 22:09:59 UTC (rev 2085) @@ -6,7 +6,7 @@ Bundle-Description: Protege DL-Learner Plugin Bundle-Vendor: DL-Learner Project Bundle-DocURL: http://dl-learner.org/wiki/ProtegePlugin -Bundle-ClassPath: .,lib/junit-4.4.jar,lib/jamon-2.7.jar,lib/pellet/pellet-core.jar,lib/pellet/pellet-datatypes.jar,lib/ore-tool/BrowserLauncher2-all-1_3.jar,lib/pellet/pellet-el.jar,lib/pellet/pellet-explanation.jar,lib/pellet/pellet-owlapi.jar,lib/pellet/pellet-rules.jar,lib/pellet/aterm-java-1.6.jar,lib/jena/json.jar,lib/pellet/relaxngDatatype.jar,lib/pellet/xsdlib.jar,lib/jena/commons-logging-1.1.1.jar,lib/ore-tool/swingx-0.9.2.jar,lib/owlapi/owlapiV3-bin.jar +Bundle-ClassPath: .,lib/junit-4.4.jar,lib/jamon-2.7.jar,lib/pellet/pellet-core.jar,lib/pellet/pellet-datatypes.jar,lib/ore-tool/BrowserLauncher2-all-1_3.jar,lib/ore-tool/swingx-1.6.jar,lib/pellet/pellet-el.jar,lib/pellet/pellet-explanation.jar,lib/pellet/pellet-owlapi.jar,lib/pellet/pellet-rules.jar,lib/pellet/aterm-java-1.6.jar,lib/jena/json.jar,lib/pellet/relaxngDatatype.jar,lib/pellet/xsdlib.jar,lib/jena/commons-logging-1.1.1.jar,lib/ore-tool/swingx-0.9.2.jar,lib/owlapi/owlapiV3-bin.jar Import-Package: org.osgi.framework,org.apache.log4j Export-Package: lib Bundle-Version: 0.6.0 Added: trunk/src/dl-learner/org/dllearner/tools/protege/ProgressBarTableCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProgressBarTableCellRenderer.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProgressBarTableCellRenderer.java 2010-03-03 22:09:59 UTC (rev 2085) @@ -0,0 +1,57 @@ +package org.dllearner.tools.protege; + +import java.awt.Component; + +import javax.swing.JProgressBar; +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; + +import org.protege.editor.owl.ui.renderer.OWLRendererPreferences; + +public class ProgressBarTableCellRenderer extends JProgressBar implements TableCellRenderer { + + + /** + * + */ + private static final long serialVersionUID = 8523710265306561978L; + + + public ProgressBarTableCellRenderer() { + super(JProgressBar.HORIZONTAL); + setBorderPainted(false); + setStringPainted(true); + setFont(OWLRendererPreferences.getInstance().getFont()); + } + + public ProgressBarTableCellRenderer(int min, int max) { + super(JProgressBar.HORIZONTAL, 0, 100); + setBorderPainted(false); + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + int n = 0; + if (! (value instanceof Number)) { + String str; + if (value instanceof String) { + str = (String)value; + } else { + str = value.toString(); + } + try { + n = Integer.valueOf(str).intValue(); + } catch (NumberFormatException ex) { + } + } else { + n = ((Number)value).intValue(); + } + + setValue(n); + return this; + } + + + +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2010-03-03 21:19:27 UTC (rev 2084) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2010-03-03 22:09:59 UTC (rev 2085) @@ -60,6 +60,7 @@ @Override public boolean isValidInput() { view.getSuggestClassPanel().getSuggestModel().clear(); + view.getSuggestClassPanel().getSuggestionsTable().clear(); //view.getSuggestClassPanel().repaint(); if(this.getAxiomType().toString().equals(EQUIVALENT_CLASS_STRING)) { view.makeView("equivalent class"); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2010-03-03 21:19:27 UTC (rev 2084) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2010-03-03 22:09:59 UTC (rev 2085) @@ -20,6 +20,7 @@ package org.dllearner.tools.protege; import java.awt.BorderLayout; +import java.util.List; import javax.swing.DefaultListModel; import javax.swing.JList; @@ -27,6 +28,10 @@ import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.dllearner.tools.evaluationplugin.EvaluationTable; + /** * This class is the panel for the suggest list. It shows the descriptions made * by the DL-Learner. @@ -41,6 +46,8 @@ // Description List private final JList descriptions; + + private final SuggestionsTable suggestionTable; // Panel for the description list @@ -72,12 +79,15 @@ descriptions = new JList(suggestModel); descriptions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); suggestPanel = new JPanel(); - descriptions.setVisible(true); - descriptions.setVisibleRowCount(6); - descriptions.getPreferredScrollableViewportSize(); - suggestPanel.add(descriptions); - suggestScroll.setViewportView(descriptions); - descriptions.setCellRenderer(new SuggestListCellRenderer()); +// descriptions.setVisible(true); +// descriptions.setVisibleRowCount(6); +// descriptions.getPreferredScrollableViewportSize(); +// suggestPanel.add(descriptions); +// suggestScroll.setViewportView(descriptions); +// descriptions.setCellRenderer(new SuggestListCellRenderer(m.getOWLEditorKit())); + suggestionTable = new SuggestionsTable(m.getOWLEditorKit()); + suggestionTable.setVisibleRowCount(6); + suggestScroll.setViewportView(suggestionTable); add(BorderLayout.CENTER, suggestScroll); } @@ -92,6 +102,10 @@ return this; } + + public void addSuggestions(List<? extends EvaluatedDescription> result){ + suggestionTable.setSuggestions((List<EvaluatedDescriptionClass>)result); + } /** * This method is called after the model for the suggest list is updated. @@ -107,8 +121,7 @@ } } else { for (int i = 0; i < suggestModel.size(); i++) { - if (!((SuggestListItem) suggestModel.get(i)).getValue() - .equals(((SuggestListItem) desc.get(i)).getValue())) { + if (!suggestModel.get(i).equals(desc.get(i))) { descriptions.getSelectedIndex(); suggestModel.set(i, desc.get(i)); if (descriptions.getSelectedIndex() == i) { @@ -137,6 +150,10 @@ public JList getSuggestList() { return descriptions; } + + public SuggestionsTable getSuggestionsTable() { + return suggestionTable; + } /** * This method adds the suggest list to the Mouse Listener. Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java 2010-03-03 21:19:27 UTC (rev 2084) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java 2010-03-03 22:09:59 UTC (rev 2085) @@ -28,6 +28,7 @@ import javax.swing.event.ListSelectionListener; import org.dllearner.core.EvaluatedDescription; +import org.dllearner.learningproblems.EvaluatedDescriptionClass; /** * This is the MouseListener for the Suggest Panel. * @author Christian Koetteritzsch @@ -58,24 +59,25 @@ */ public void mouseClicked(MouseEvent e) { if (view.getSuggestClassPanel().getSuggestList().getSelectedValue() != null) { - SuggestListItem item = (SuggestListItem) view - .getSuggestClassPanel().getSuggestList().getSelectedValue(); - String desc = item.getValue(); - if (model.getEvaluatedDescriptionList() != null) { - List<? extends EvaluatedDescription> evalList = model - .getEvaluatedDescriptionList(); - Set<String> onto = model.getOntologyURIString(); - for (EvaluatedDescription eDescription : evalList) { - for (String ont : onto) { - if (desc.equals(eDescription.getDescription() - .toManchesterSyntaxString(ont, null))) { - evaluatedDescription = eDescription; - action.setEvaluatedClassExpression(eDescription); - break; - } - } - } - } + EvaluatedDescription evaluatedDescription = (EvaluatedDescription)view.getSuggestClassPanel().getSuggestList().getSelectedValue(); +// SuggestListItem item = (SuggestListItem) view +// .getSuggestClassPanel().getSuggestList().getSelectedValue(); +// String desc = item.getValue(); +// if (model.getEvaluatedDescriptionList() != null) { +// List<? extends EvaluatedDescription> evalList = model +// .getEvaluatedDescriptionList(); +// Set<String> onto = model.getOntologyURIString(); +// for (EvaluatedDescription eDescription : evalList) { +// for (String ont : onto) { +// if (desc.equals(eDescription.getDescription() +// .toManchesterSyntaxString(ont, null))) { +// evaluatedDescription = eDescription; +// action.setEvaluatedClassExpression(eDescription); +// break; +// } +// } +// } +// } view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel(evaluatedDescription); view.setGraphicalPanel(); } @@ -124,7 +126,18 @@ * Nothing happens here. */ public void valueChanged(ListSelectionEvent e) { - + if(view.getSuggestClassPanel().getSuggestionsTable().getSelectedRow() >= 0){ + EvaluatedDescriptionClass ec = view.getSuggestClassPanel().getSuggestionsTable().getSelectedSuggestion(); + if(!e.getValueIsAdjusting() && ec != null){ + view.getMoreDetailForSuggestedConceptsPanel(). + renderDetailPanel(ec); + view.setGraphicalPanel(); + action.setEvaluatedClassExpression(ec); + view.getAddButton().setEnabled(true); + } + } + + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2010-03-03 21:19:27 UTC (rev 2084) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2010-03-03 22:09:59 UTC (rev 2085) @@ -23,22 +23,32 @@ import java.awt.Component; import javax.swing.BorderFactory; -import javax.swing.JLabel; import javax.swing.JList; -import javax.swing.ListCellRenderer; +import javax.swing.JPanel; +import javax.swing.JTextPane; + +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.owl.Description; +import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; +import org.protege.editor.owl.OWLEditorKit; +import org.protege.editor.owl.ui.renderer.OWLCellRenderer; /** * This is the class that is responsible for the rendering of the * concepts that are shown in the SuggestPanel. * @author Christian Koetteritzsch * */ -public class SuggestListCellRenderer extends JLabel implements ListCellRenderer { +public class SuggestListCellRenderer extends OWLCellRenderer { private static final long serialVersionUID = 8040385703448641356L; /** * Constructor for the Cell Renderer for the Suggest List. */ - public SuggestListCellRenderer() { + public SuggestListCellRenderer(OWLEditorKit editorKit) { + super(editorKit); + setWrap(false); + setHighlightKeywords(true); setOpaque(true); } @@ -52,22 +62,29 @@ * @return Component Returns the currently rendered component of the suggest list */ public Component getListCellRendererComponent(JList list, Object value, - int arg2, boolean iss, boolean arg4) { + int index, boolean isSelected, boolean cellHasFocus) { + EvaluatedDescriptionClass desc = (EvaluatedDescriptionClass)value; + Component c = super.getListCellRendererComponent(list, OWLAPIDescriptionConvertVisitor.getOWLDescription(desc.getDescription()), index, isSelected, cellHasFocus); + JTextPane pane = (JTextPane)((JPanel)c).getComponent(1); + if(!desc.isConsistent()){ + pane.setForeground(Color.RED); + } + // Set the text and // background color for rendering - setText(((SuggestListItem) value).getValue() + " " + "Accuracy: " + Math.round(((SuggestListItem) value).getAccuracy())+"%"); - setBackground(Color.WHITE); - setForeground(((SuggestListItem) value).getColor()); - // Set a border if the list - // item is selected - if (iss) { - setBorder(BorderFactory.createLineBorder(Color.GRAY, 2)); - } else { - setBorder(BorderFactory.createLineBorder(list.getBackground(), 2)); - } - setEnabled(list.isEnabled()); +// setText(((SuggestListItem) value).getValue() + " " + "Accuracy: " + Math.round(((SuggestListItem) value).getAccuracy())+"%"); +// setBackground(Color.WHITE); +// setForeground(((SuggestListItem) value).getColor()); +// // Set a border if the list +// // item is selected +// if (iss) { +// setBorder(BorderFactory.createLineBorder(Color.GRAY, 2)); +// } else { +// setBorder(BorderFactory.createLineBorder(list.getBackground(), 2)); +// } +// setEnabled(list.isEnabled()); - return this; + return c; } } Added: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java 2010-03-03 22:09:59 UTC (rev 2085) @@ -0,0 +1,48 @@ +package org.dllearner.tools.protege; + +import java.util.List; + +import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.jdesktop.swingx.JXTable; +import org.protege.editor.owl.OWLEditorKit; +import org.protege.editor.owl.ui.renderer.OWLCellRenderer; + +public class SuggestionsTable extends JXTable { + + /** + * + */ + private static final long serialVersionUID = -497294373160119210L; + + private final OWLCellRenderer owlRenderer; + private final ProgressBarTableCellRenderer progressRenderer; + + public SuggestionsTable(OWLEditorKit editorKit){ + super(new SuggestionsTableModel()); + progressRenderer = new ProgressBarTableCellRenderer(); + progressRenderer.setBackground(getBackground()); + getColumn(0).setCellRenderer(progressRenderer); + owlRenderer = new OWLCellRenderer(editorKit, false, false); + owlRenderer.setHighlightKeywords(true); + owlRenderer.setWrap(false); + getColumn(1).setCellRenderer(owlRenderer); + setColumnSizes(); + } + + private void setColumnSizes(){ + getColumn(0).setMaxWidth(100); + getColumn(1).setPreferredWidth(430); + } + + public void clear(){ + ((SuggestionsTableModel)getModel()).clear(); + } + + public void setSuggestions(List<EvaluatedDescriptionClass> suggestionList){ + ((SuggestionsTableModel)getModel()).setSuggestions(suggestionList); + } + + public EvaluatedDescriptionClass getSelectedSuggestion(){ + return ((SuggestionsTableModel)getModel()).getSelectedValue(getSelectedRow()); + } +} Added: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java 2010-03-03 22:09:59 UTC (rev 2085) @@ -0,0 +1,83 @@ +package org.dllearner.tools.protege; + +import java.util.ArrayList; +import java.util.List; + +import javax.swing.table.AbstractTableModel; + +import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; +import org.semanticweb.owl.model.OWLDescription; + +public class SuggestionsTableModel extends AbstractTableModel { + + /** + * + */ + private static final long serialVersionUID = -6920806148989403795L; + + private List<EvaluatedDescriptionClass> suggestionList; + + public SuggestionsTableModel(){ + super(); + suggestionList = new ArrayList<EvaluatedDescriptionClass>(); + } + + public SuggestionsTableModel(List<EvaluatedDescriptionClass> suggestionList){ + this.suggestionList = suggestionList; + } + + @Override + public int getColumnCount() { + return 2; + } + + @Override + public int getRowCount() { + return suggestionList.size(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if(columnIndex == 0){ + return (int)(suggestionList.get(rowIndex).getAccuracy() * 100); + } else { + return OWLAPIDescriptionConvertVisitor.getOWLDescription(suggestionList.get(rowIndex).getDescription()); + } + + } + + @Override + public Class<? extends Object> getColumnClass(int columnIndex){ + if(columnIndex == 0) { + return String.class; + } else { + return OWLDescription.class; + } + } + @Override + public String getColumnName(int column){ + if(column == 0){ + return "Accuracy"; + } else { + return "Class expression"; + } + } + + public void clear(){ + suggestionList.clear(); + fireTableDataChanged(); + } + + public void setSuggestions(List<EvaluatedDescriptionClass> suggestionList){ + this.suggestionList.clear(); + this.suggestionList.addAll(suggestionList); + fireTableDataChanged(); + } + + public EvaluatedDescriptionClass getSelectedValue(int rowIndex){ + return suggestionList.get(rowIndex); + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2010-03-05 14:03:33
|
Revision: 2092 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2092&view=rev Author: lorenz_b Date: 2010-03-05 14:03:25 +0000 (Fri, 05 Mar 2010) Log Message: ----------- Some improvements in plugin design. 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/SuggestClassPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/ModelsIcon.java trunk/src/dl-learner/org/dllearner/tools/protege/warning-icon.png Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -37,8 +37,6 @@ import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.owl.Description; -import org.dllearner.learningproblems.EvaluatedDescriptionClass; /** * This class processes input from the user. @@ -104,7 +102,7 @@ if (z.getActionCommand().equals(EQUIVALENT_CLASS_LEARNING_STRING) || z.getActionCommand().equals(SUPER_CLASS_LEARNING_STRING)) { model.setKnowledgeSource(); - view.getSuggestClassPanel().getSuggestModel().clear(); + view.getSuggestClassPanel().getSuggestionsTable().clear(); view.getSuggestClassPanel().repaint(); model.setLearningProblem(); model.setLearningAlgorithm(); @@ -124,16 +122,7 @@ } if (z.getActionCommand().equals(ADD_BUTTON_STRING)) { - if (evaluatedDescription != null) { - model - .changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription - .getDescription()); - } else { - model - .changeDLLearnerDescriptionsToOWLDescriptions((Description) view - .getSuggestClassPanel().getSuggestList() - .getSelectedValue()); - } + model.changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription.getDescription()); String message = "<html><font size=\"3\">class expression added</font></html>"; view.setHintMessage(message); view.setHelpButtonVisible(false); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -185,8 +185,6 @@ posPanel = new PosAndNegSelectPanel(model, action); detail = new MoreDetailForSuggestedConceptsPanel(model); sugPanelHandler = new SuggestClassPanelHandler(this, model, action); - sugPanel.addSuggestPanelMouseListener(sugPanelHandler); - sugPanel.getSuggestList().addListSelectionListener(sugPanelHandler); sugPanel.getSuggestionsTable().getSelectionModel().addListSelectionListener(sugPanelHandler); this.addAcceptButtonListener(this.action); this.addRunButtonListener(this.action); @@ -437,7 +435,6 @@ */ public void dispose() { this.unsetEverything(); - sugPanel.getSuggestList().removeAll(); sugPanel.getSuggestionsTable().clear(); learner.removeAll(); sugPanel = null; @@ -471,7 +468,7 @@ } /** - * This Method returns the run button. + * This method returns the run button. * @return JButton */ public JButton getRunButton() { @@ -487,7 +484,7 @@ } /** - * This methode returns if the ontology is inconsistent. + * This method returns if the ontology is inconsistent. * @return boolean if ontology is inconsistent */ public boolean getIsInconsistent() { @@ -545,7 +542,7 @@ } /** - * This methode sets the help button visible. + * This method sets the help button visible. * @param isVisible boolean if help button is visible */ public void setHelpButtonVisible(boolean isVisible) { @@ -569,21 +566,21 @@ } /** - * This Methode starts the status bar. + * This method starts the status bar. */ public void startStatusBar() { stat.showProgress(true); } /** - * This methode stops the status bar. + * This method stops the status bar. */ public void stopStatusBar() { stat.showProgress(false); } /** - * This methode returns the statusbar. + * This method returns the statusbar. * @return statusbar */ public StatusBar2 getStatusBar() { Added: trunk/src/dl-learner/org/dllearner/tools/protege/ModelsIcon.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ModelsIcon.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ModelsIcon.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -0,0 +1,30 @@ +package org.dllearner.tools.protege; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; + +import javax.swing.Icon; + +public class ModelsIcon implements Icon { + + @Override + public int getIconHeight() { + return 16; + } + + @Override + public int getIconWidth() { + return 16; + } + + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + g.setColor(Color.BLACK); + g.drawLine(3, y, 3, getIconHeight()); + g.drawLine(3, 7, getIconWidth() - 2, 7); + g.drawLine(3, 10,getIconWidth() - 2, 10); + + } + +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -142,28 +142,11 @@ } } - /** - * This method returns the current Description list. - * - * @return JList of Descriptions - */ - public JList getSuggestList() { - return descriptions; - } public SuggestionsTable getSuggestionsTable() { return suggestionTable; } - /** - * This method adds the suggest list to the Mouse Listener. - * - * @param action - * ActionHandler - */ - public void addSuggestPanelMouseListener(SuggestClassPanelHandler handle) { - descriptions.addMouseListener(handle); - } /** * Thsi method returns the list model for the suggest list. Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -19,22 +19,16 @@ */ package org.dllearner.tools.protege; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.List; -import java.util.Set; - import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.learningproblems.EvaluatedDescriptionClass; /** * This is the MouseListener for the Suggest Panel. * @author Christian Koetteritzsch * */ -public class SuggestClassPanelHandler implements MouseListener, ListSelectionListener{ +public class SuggestClassPanelHandler implements ListSelectionListener{ private DLLearnerView view; private DLLearnerModel model; private ActionHandler action; @@ -51,88 +45,20 @@ this.action = a; } - @Override /** - * This methode sets the graphical coverage panel enable when a - * suggested class expression is selected. - */ - public void mouseClicked(MouseEvent e) { - if (view.getSuggestClassPanel().getSuggestList().getSelectedValue() != null) { - EvaluatedDescription evaluatedDescription = (EvaluatedDescription)view.getSuggestClassPanel().getSuggestList().getSelectedValue(); -// SuggestListItem item = (SuggestListItem) view -// .getSuggestClassPanel().getSuggestList().getSelectedValue(); -// String desc = item.getValue(); -// if (model.getEvaluatedDescriptionList() != null) { -// List<? extends EvaluatedDescription> evalList = model -// .getEvaluatedDescriptionList(); -// Set<String> onto = model.getOntologyURIString(); -// for (EvaluatedDescription eDescription : evalList) { -// for (String ont : onto) { -// if (desc.equals(eDescription.getDescription() -// .toManchesterSyntaxString(ont, null))) { -// evaluatedDescription = eDescription; -// action.setEvaluatedClassExpression(eDescription); -// break; -// } -// } -// } -// } - view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel(evaluatedDescription); - view.setGraphicalPanel(); - } - } - - @Override - /** - * Nothing happens here. - */ - public void mouseEntered(MouseEvent e) { - - } - - @Override - /** - * Nothing happens here. - */ - public void mouseExited(MouseEvent e) { - - } - - @Override - /** - * This methode sets the add button enable when - * a suggested class expression is selected. - */ - public void mousePressed(MouseEvent e) { - if (view.getSuggestClassPanel().getSuggestList().getSelectedValue() != null) { - if (!view.getAddButton().isEnabled()) { - view.getAddButton().setEnabled(true); - } - } - } - - @Override - /** - * Nothing happens here. - */ - public void mouseReleased(MouseEvent e) { - - } - - - @Override - /** * Nothing happens here. */ public void valueChanged(ListSelectionEvent e) { if(view.getSuggestClassPanel().getSuggestionsTable().getSelectedRow() >= 0){ - EvaluatedDescriptionClass ec = view.getSuggestClassPanel().getSuggestionsTable().getSelectedSuggestion(); - if(!e.getValueIsAdjusting() && ec != null){ + EvaluatedDescription newDesc = view.getSuggestClassPanel().getSuggestionsTable().getSelectedSuggestion(); +// evaluatedDescription = view.getSuggestClassPanel().getSuggestionsTable().getSelectedSuggestion(); + if(!e.getValueIsAdjusting() && (evaluatedDescription == null || !evaluatedDescription.equals(newDesc))){ + evaluatedDescription = newDesc; view.getMoreDetailForSuggestedConceptsPanel(). - renderDetailPanel(ec); + renderDetailPanel(evaluatedDescription); view.setGraphicalPanel(); - action.setEvaluatedClassExpression(ec); + action.setEvaluatedClassExpression(evaluatedDescription); view.getAddButton().setEnabled(true); } } Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -1,90 +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.Color; -import java.awt.Component; - -import javax.swing.BorderFactory; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JTextPane; - -import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.owl.Description; -import org.dllearner.learningproblems.EvaluatedDescriptionClass; -import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; -import org.protege.editor.owl.OWLEditorKit; -import org.protege.editor.owl.ui.renderer.OWLCellRenderer; -/** - * This is the class that is responsible for the rendering of the - * concepts that are shown in the SuggestPanel. - * @author Christian Koetteritzsch - * - */ -public class SuggestListCellRenderer extends OWLCellRenderer { - - private static final long serialVersionUID = 8040385703448641356L; - /** - * Constructor for the Cell Renderer for the Suggest List. - */ - public SuggestListCellRenderer(OWLEditorKit editorKit) { - super(editorKit); - setWrap(false); - setHighlightKeywords(true); - setOpaque(true); - } - - /** - * Renderer for the entries of the SuggestPanel. - * @param list JList - * @param value Object - * @param arg2 int - * @param arg4 boolean - * @param iss boolean boolean if current element is selected. - * @return Component Returns the currently rendered component of the suggest list - */ - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - EvaluatedDescriptionClass desc = (EvaluatedDescriptionClass)value; - Component c = super.getListCellRendererComponent(list, OWLAPIDescriptionConvertVisitor.getOWLDescription(desc.getDescription()), index, isSelected, cellHasFocus); - JTextPane pane = (JTextPane)((JPanel)c).getComponent(1); - if(!desc.isConsistent()){ - pane.setForeground(Color.RED); - } - - // Set the text and - // background color for rendering -// setText(((SuggestListItem) value).getValue() + " " + "Accuracy: " + Math.round(((SuggestListItem) value).getAccuracy())+"%"); -// setBackground(Color.WHITE); -// setForeground(((SuggestListItem) value).getColor()); -// // Set a border if the list -// // item is selected -// if (iss) { -// setBorder(BorderFactory.createLineBorder(Color.GRAY, 2)); -// } else { -// setBorder(BorderFactory.createLineBorder(list.getBackground(), 2)); -// } -// setEnabled(list.isEnabled()); - - return c; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -1,71 +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.Color; -/** - * This Class represents an entry of the suggest list. - * @author Christian Koetteritzsch - * - */ -public class SuggestListItem { - - private final Color color; - private String value; - private double accuracy; - /** - * Constructor for the SuggestListItem. - * @param c Color Color in which the text is painted. - * @param s String text that is shown. - * @param acc Accuracy of the concept - */ - public SuggestListItem( - Color c, String s, double acc) { - this.color = c; - this.value = s; - this.accuracy = acc; - - } - - /** - * This method returns the color of the current list item. - * @return Color Color of the current list item - */ - public Color getColor() { - return color; - } - - /** - * This Method returns the text of the current list item. - * @return String Text of the current list item - */ - public String getValue() { - return value; - } - - /** - * This method returns the accuracy of the current list item. - * @return accuracy - */ - public double getAccuracy() { - return accuracy; - } -} - Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -2,7 +2,10 @@ import java.util.List; +import javax.swing.table.DefaultTableCellRenderer; + import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.dllearner.tools.ore.ui.ResultTableModel; import org.jdesktop.swingx.JXTable; import org.protege.editor.owl.OWLEditorKit; import org.protege.editor.owl.ui.renderer.OWLCellRenderer; @@ -16,22 +19,27 @@ private final OWLCellRenderer owlRenderer; private final ProgressBarTableCellRenderer progressRenderer; + private EvaluatedDescriptionClass old; public SuggestionsTable(OWLEditorKit editorKit){ super(new SuggestionsTableModel()); + progressRenderer = new ProgressBarTableCellRenderer(); progressRenderer.setBackground(getBackground()); getColumn(0).setCellRenderer(progressRenderer); + owlRenderer = new OWLCellRenderer(editorKit, false, false); owlRenderer.setHighlightKeywords(true); owlRenderer.setWrap(false); - getColumn(1).setCellRenderer(owlRenderer); + getColumn(2).setCellRenderer(owlRenderer); + setColumnSizes(); } private void setColumnSizes(){ getColumn(0).setMaxWidth(100); - getColumn(1).setPreferredWidth(430); + getColumn(1).setMaxWidth(20); + getColumn(2).setPreferredWidth(430); } public void clear(){ @@ -39,7 +47,16 @@ } public void setSuggestions(List<EvaluatedDescriptionClass> suggestionList){ + if(getSelectedRow() >= 0){ + old = getSelectedSuggestion(); + } ((SuggestionsTableModel)getModel()).setSuggestions(suggestionList); + if(old != null){ + int newRowIndex = ((SuggestionsTableModel)getModel()).getSelectionIndex(old); + if(newRowIndex >= 0){ + getSelectionModel().setSelectionInterval(newRowIndex, newRowIndex); + } + } } public EvaluatedDescriptionClass getSelectedSuggestion(){ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -3,6 +3,8 @@ import java.util.ArrayList; import java.util.List; +import javax.swing.Icon; +import javax.swing.ImageIcon; import javax.swing.table.AbstractTableModel; import org.dllearner.learningproblems.EvaluatedDescriptionClass; @@ -17,7 +19,9 @@ private static final long serialVersionUID = -6920806148989403795L; private List<EvaluatedDescriptionClass> suggestionList; - + private final Icon inconsistentIcon = new ImageIcon(this.getClass().getResource("warning-icon.png")); + private final Icon followsIcon = new ModelsIcon(); + public SuggestionsTableModel(){ super(); suggestionList = new ArrayList<EvaluatedDescriptionClass>(); @@ -29,7 +33,7 @@ @Override public int getColumnCount() { - return 2; + return 3; } @Override @@ -39,28 +43,44 @@ @Override public Object getValueAt(int rowIndex, int columnIndex) { - if(columnIndex == 0){ - return (int)(suggestionList.get(rowIndex).getAccuracy() * 100); - } else { - return OWLAPIDescriptionConvertVisitor.getOWLDescription(suggestionList.get(rowIndex).getDescription()); + switch (columnIndex) { + case 0: + return (int) (suggestionList.get(rowIndex).getAccuracy() * 100); + case 1: + if (!suggestionList.get(rowIndex).isConsistent()) { + return inconsistentIcon; + } else if(suggestionList.get(rowIndex).followsFromKB()){ + return followsIcon; + }break; + case 2: + return OWLAPIDescriptionConvertVisitor + .getOWLDescription(suggestionList.get(rowIndex) + .getDescription()); } - + return null; + } @Override - public Class<? extends Object> getColumnClass(int columnIndex){ - if(columnIndex == 0) { + public Class<? extends Object> getColumnClass(int columnIndex) { + switch (columnIndex) { + case 0: return String.class; - } else { + case 1: + return Icon.class; + case 2: return OWLDescription.class; } + return null; } @Override public String getColumnName(int column){ if(column == 0){ return "Accuracy"; + } else if (column == 2){ + return "Class expression"; } else { - return "Class expression"; + return ""; } } @@ -79,5 +99,8 @@ return suggestionList.get(rowIndex); } + public int getSelectionIndex(EvaluatedDescriptionClass e){ + return suggestionList.indexOf(e); + } } Added: trunk/src/dl-learner/org/dllearner/tools/protege/warning-icon.png =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/tools/protege/warning-icon.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
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] |
From: <lor...@us...> - 2010-08-02 08:55:33
|
Revision: 2221 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2221&view=rev Author: lorenz_b Date: 2010-08-02 08:55:24 +0000 (Mon, 02 Aug 2010) Log Message: ----------- Some changes to show errors in editor. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.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/ReadingOntologyThread.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-07-27 11:46:45 UTC (rev 2220) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-08-02 08:55:24 UTC (rev 2221) @@ -32,6 +32,7 @@ import org.dllearner.core.EvaluatedDescription; import org.protege.editor.core.ProtegeApplication; +import org.protege.editor.core.ui.error.ErrorLogPanel; import org.protege.editor.core.ui.progress.BackgroundTask; /** @@ -174,35 +175,42 @@ } }); - 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; - List<? extends EvaluatedDescription> result; - @Override - public void run() { - progress++; - setProgress(progress); - if(!isCancelled() && Manager.getInstance().isLearning()){ - result = Manager.getInstance().getCurrentlyLearnedDescriptions(); - publish(result); + try { + 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()); } - } + }); - }, 1000, 500); - Manager.getInstance().startLearning(); + timer = new Timer(); + timer.schedule(new TimerTask(){ + int progress = 0; + List<? extends EvaluatedDescription> result; + @Override + public void run() { + progress++; + setProgress(progress); + if(!isCancelled() && Manager.getInstance().isLearning()){ + result = Manager.getInstance().getCurrentlyLearnedDescriptions(); + publish(result); + } + } + + }, 1000, 500); + Manager.getInstance().startLearning(); + } catch (Exception e) { + ErrorLogPanel.showErrorDialog(e); + cancel(true); + view.setBusyTaskEnded(); + } return null; @@ -210,11 +218,13 @@ @Override public void done() { - timer.cancel(); - List<? extends EvaluatedDescription> result = Manager.getInstance().getCurrentlyLearnedDescriptions(); - updateList(result); - setProgress(0); - view.setLearningFinished(); + if(!isCancelled()){ + timer.cancel(); + List<? extends EvaluatedDescription> result = Manager.getInstance().getCurrentlyLearnedDescriptions(); + updateList(result); + setProgress(0); + view.setLearningFinished(); + } ProtegeApplication.getBackgroundTaskManager().endTask(learningTask); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java 2010-07-27 11:46:45 UTC (rev 2220) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java 2010-08-02 08:55:24 UTC (rev 2221) @@ -76,7 +76,7 @@ sb.append("<p><font size=\"1\" color=\"red\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"yellow\">\u25cf</font></font><font size=\"3\" color=\"black\"> (potential problem)</font></p>"); } sb.append("<p><font size=\"3\" color=\"black\">Covers ").append(coveredInstancesCount).append(" of ").append(allInstancesCount).append("(").append(coverage).append(" %) of class instances</font></p>"); - sb.append("<p><font size=\"3\" color=\"black\">Covers ").append(additionalInstancesCount).append(" additional instances</font></p>"); + sb.append("<p><font size=\"3\" color=\"black\">Covers ").append(additionalInstancesCount).append(additionalInstancesCount == 1 ? " additional instance" : " additional instances").append("</font></p>"); if(!((EvaluatedDescriptionClass) description).isConsistent()) { sb.append("<p style=\"max-width:100px;\"><font size=\"3\" color=\"red\">Adding this class expression may lead to an inconsistent ontology.</font></p>"); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java 2010-07-27 11:46:45 UTC (rev 2220) +++ trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java 2010-08-02 08:55:24 UTC (rev 2221) @@ -1,6 +1,5 @@ package org.dllearner.tools.protege; -import java.net.MalformedURLException; import java.util.Collections; import java.util.List; import java.util.SortedSet; @@ -12,7 +11,6 @@ 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.kb.OWLAPIOntology; @@ -44,10 +42,7 @@ "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"}; private static Manager instance; @@ -102,7 +97,7 @@ return reinitNecessary; } - public void init(){ + public void init() throws Exception{ initKnowledgeSource(); if(reinitNecessary){ initReasoner(); @@ -112,66 +107,51 @@ reinitNecessary = false; } - public void initLearningAlgorithm(){ - try { - la = cm.learningAlgorithm(CELOE.class, lp, reasoner); - cm.applyConfigEntry(la, "useAllConstructor", useAllConstructor); - cm.applyConfigEntry(la, "useExistsConstructor", useExistsConstructor); - cm.applyConfigEntry(la, "useHasValueConstructor", useHasValueConstructor); - cm.applyConfigEntry(la, "useNegation", useNegation); - cm.applyConfigEntry(la, "useCardinalityRestrictions", useCardinalityRestrictions); - if(useCardinalityRestrictions) { - cm.applyConfigEntry(la, "cardinalityLimit", cardinalityLimit); - } - cm.applyConfigEntry(la, "noisePercentage", noisePercentage); - cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); - - la.init(); - } catch (LearningProblemUnsupportedException e) { - e.printStackTrace(); - } catch (ComponentInitException e) { - e.printStackTrace(); + public void initLearningAlgorithm() throws Exception { + la = cm.learningAlgorithm(CELOE.class, lp, reasoner); + cm.applyConfigEntry(la, "useAllConstructor", useAllConstructor); + cm.applyConfigEntry(la, "useExistsConstructor", useExistsConstructor); + cm.applyConfigEntry(la, "useHasValueConstructor", + useHasValueConstructor); + cm.applyConfigEntry(la, "useNegation", useNegation); + cm.applyConfigEntry(la, "useCardinalityRestrictions", + useCardinalityRestrictions); + if (useCardinalityRestrictions) { + cm.applyConfigEntry(la, "cardinalityLimit", cardinalityLimit); } - + cm.applyConfigEntry(la, "noisePercentage", noisePercentage); + cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", + maxExecutionTimeInSeconds); + + la.init(); + } - public void initLearningProblem(){ + public void initLearningProblem() throws Exception { lp = cm.learningProblem(ClassLearningProblem.class, reasoner); - try { - cm.applyConfigEntry(lp, "classToDescribe", editorKit.getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass().getIRI().toURI().toURL()); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } + cm.applyConfigEntry(lp, "classToDescribe", editorKit.getOWLWorkspace() + .getOWLSelectionModel().getLastSelectedClass().getIRI().toURI() + .toURL()); if (learningType == LearningType.EQUIVALENT) { cm.applyConfigEntry(lp, "type", "equivalence"); - } else if(learningType == LearningType.SUPER){ + } else if (learningType == LearningType.SUPER) { cm.applyConfigEntry(lp, "type", "superClass"); } - try { - lp.init(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } + + lp.init(); + } - public void initKnowledgeSource(){ + public void initKnowledgeSource() throws Exception{ ks = new OWLAPIOntology(editorKit.getOWLModelManager().getActiveOntology()); - try { - ks.init(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } + ks.init(); } - public void initReasoner(){ + public void initReasoner() throws Exception{ reasoner = cm.reasoner(ProtegeReasoner.class, ks); reasoner.setOWLReasoner(editorKit.getOWLModelManager().getReasoner()); reasoner.setProgressMonitor(progressMonitor); - try { - reasoner.init(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } + reasoner.init(); } public void initReasonerAsynchronously(){ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2010-07-27 11:46:45 UTC (rev 2220) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2010-08-02 08:55:24 UTC (rev 2221) @@ -44,7 +44,7 @@ // Model of the dllearner private EvaluatedDescription eval; - private static final int HEIGHT = 230; + private static final int HEIGHT = 300; private static final int WIDTH = 540; private GraphicalCoveragePanel graphicalPanel; private GraphicalCoverageTextField graphicalText; @@ -59,7 +59,7 @@ setPreferredSize(new Dimension(WIDTH, HEIGHT)); graphicalPanel = new GraphicalCoveragePanel(eval); graphicalText = new GraphicalCoverageTextField(eval, editorKit); - graphicalPanel.setBounds(5, 0, 300, 350); + graphicalPanel.setBounds(5, 0, 300, 370); add(graphicalPanel, BorderLayout.CENTER); add(graphicalText.getTextScroll(), BorderLayout.EAST); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java 2010-07-27 11:46:45 UTC (rev 2220) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java 2010-08-02 08:55:24 UTC (rev 2221) @@ -19,7 +19,9 @@ */ package org.dllearner.tools.protege; +import org.protege.editor.core.ui.error.ErrorLogPanel; + /** * This class reads the ontology in a separate thread. * @@ -48,15 +50,19 @@ Manager.getInstance().setIsPreparing(true); view.showStatusBar(true); view.setBusy(true); - Manager.getInstance().initKnowledgeSource(); - Manager.getInstance().initReasoner(); + try { + Manager.getInstance().initKnowledgeSource(); + Manager.getInstance().initReasoner(); + if(Manager.getInstance().canLearn()){ + view.setLearningEnabled(); + } else { + view.showNoInstancesMessage(); + } + } catch (Exception e) { + ErrorLogPanel.showErrorDialog(e); + } view.showStatusBar(false); view.setBusy(false); - if(Manager.getInstance().canLearn()){ - view.setLearningEnabled(); - } else { - view.showNoInstancesMessage(); - } Manager.getInstance().setIsPreparing(false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2010-08-03 08:36:10
|
Revision: 2230 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2230&view=rev Author: lorenz_b Date: 2010-08-03 08:36:04 +0000 (Tue, 03 Aug 2010) Log Message: ----------- Added dependency to pellet reasoner plugin. Changed warning message, which occurs when no reasoner is selected. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2010-08-02 19:48:11 UTC (rev 2229) +++ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2010-08-03 08:36:04 UTC (rev 2230) @@ -52,4 +52,5 @@ org.eclipse.equinox.common, org.protege.editor.core.application;bundle-version="4.1.0", org.protege.editor.owl;bundle-version="4.1.0", - org.semanticweb.owl.owlapi;bundle-version="3.0.0" + org.semanticweb.owl.owlapi;bundle-version="3.0.0", + com.clarkparsia.protege.plugin.pellet Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2010-08-02 19:48:11 UTC (rev 2229) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2010-08-03 08:36:04 UTC (rev 2230) @@ -63,7 +63,7 @@ view.reset(); OWLReasoner r = getOWLEditorKit().getModelManager().getReasoner(); if(r instanceof NoOpReasoner){ - view.setHintMessage("<html><font size=\"3\" color=\"red\">You have to select a reasoner first.</font></html>"); + view.setHintMessage("<html><font size=\"3\" color=\"red\">You have to select a reasoner (click on menu \"Reasoner\"). We recommend to use Pellet. </font></html>"); view.setRunButtonEnabled(false); } else { if(!Manager.getInstance().isPreparing() && Manager.getInstance().isReinitNecessary()){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2010-08-04 15:30:13
|
Revision: 2239 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2239&view=rev Author: lorenz_b Date: 2010-08-04 15:30:05 +0000 (Wed, 04 Aug 2010) Log Message: ----------- Prepared auto-update function for next Protege plugin release. Some layout changes in the options panel. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.properties Modified: trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2010-08-04 14:49:49 UTC (rev 2238) +++ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2010-08-04 15:30:05 UTC (rev 2239) @@ -6,6 +6,7 @@ Bundle-Description: Protege DL-Learner Plugin Bundle-Vendor: DL-Learner Project Bundle-DocURL: http://dl-learner.org/wiki/ProtegePlugin +Update-Url: http://dl-learner.svn.sourceforge.net/viewvc/dl-learner/trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/update.properties Bundle-ClassPath: ., lib/junit-4.4.jar, lib/jamon-2.7.jar, Added: trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.properties =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.properties (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.properties 2010-08-04 15:30:05 UTC (rev 2239) @@ -0,0 +1,7 @@ +id=org.dllearner.tools.protege +version=0.6.0 +download=http://sourceforge.net/projects/dl-learner/files/Protege%20DL-Learner%20Plugin/0.6/Protege-DL-Learner-plugin-0.6.zip/download +name=DL-Learner Plugin +readme=http://dl-learner.svn.sourceforge.net/viewvc/dl-learner/trunk/src/dl-learner/org/dllearner/tools/protege/README +license=http://dl-learner.svn.sourceforge.net/viewvc/dl-learner/trunk/LICENSE +author=AKSW, The University of Leipzig Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2010-08-04 14:49:49 UTC (rev 2238) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2010-08-04 15:30:05 UTC (rev 2239) @@ -20,10 +20,12 @@ package org.dllearner.tools.protege; import java.awt.BorderLayout; +import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; @@ -69,6 +71,9 @@ * Constructor for the Option Panel. */ public OptionPanel() { + + setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5), + BorderFactory.createTitledBorder("Options"))); setLayout(new BorderLayout()); optionHandler = new OptionPanelHandler(this); labelPanel = new JPanel(); @@ -78,7 +83,7 @@ profilePanel = new JPanel(); profilePanel.setLayout(new GridLayout(0, 1)); radioBoxPanel = new JPanel(); - radioBoxPanel.setLayout(new GridLayout(1, 3)); + radioBoxPanel.setLayout(new FlowLayout()); checkBoxPanel = new JPanel(); checkBoxPanel.setLayout(new GridBagLayout()); @@ -189,6 +194,7 @@ radioBoxPanel.add(elProfileButton); radioBoxPanel.add(defaultProfileButton); + profilePanel.setBorder(BorderFactory.createTitledBorder("OWL Profile")); profilePanel.add(radioBoxPanel); profilePanel.add(checkBoxPanel); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2010-09-10 09:39:31
|
Revision: 2282 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2282&view=rev Author: lorenz_b Date: 2010-09-10 09:39:25 +0000 (Fri, 10 Sep 2010) Log Message: ----------- Small fix to get notified when the active ontology changed. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java 2010-09-10 09:38:25 UTC (rev 2281) +++ trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java 2010-09-10 09:39:25 UTC (rev 2282) @@ -72,19 +72,14 @@ private volatile boolean isPreparing = false; - public static synchronized Manager getInstance(OWLEditorKit editorKit){ + public static synchronized Manager getInstance(){ if(instance == null){ - instance = new Manager(editorKit); + instance = new Manager(); } return instance; } - public static synchronized Manager getInstance(){ - return instance; - } - - private Manager(OWLEditorKit editorKit){ - this.editorKit = editorKit; + private Manager(){ ComponentManager.setComponentClasses(components); cm = ComponentManager.getInstance(); } @@ -360,9 +355,6 @@ public void dispose() throws Exception { reasoner.releaseKB(); cm.freeAllComponents(); - editorKit.getOWLModelManager().removeListener(this); - editorKit.getOWLWorkspace().getOWLSelectionModel().removeListener(this); - } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2010-09-10 09:38:25 UTC (rev 2281) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2010-09-10 09:39:25 UTC (rev 2282) @@ -56,9 +56,9 @@ @Override public boolean isValidInput() { if(getAxiomType() == AxiomType.EQUIVALENT_CLASSES) { - Manager.getInstance(getOWLEditorKit()).setLearningType(LearningType.EQUIVALENT); + Manager.getInstance().setLearningType(LearningType.EQUIVALENT); } else if(getAxiomType() == AxiomType.SUBCLASS_OF) { - Manager.getInstance(getOWLEditorKit()).setLearningType(LearningType.SUPER); + Manager.getInstance().setLearningType(LearningType.SUPER); } view.reset(); OWLReasoner r = getOWLEditorKit().getModelManager().getReasoner(); @@ -80,7 +80,7 @@ @Override public void initialise() throws Exception { - Manager.getInstance(getOWLEditorKit()); + Manager.getInstance().setOWLEditorKit(getOWLEditorKit()); view = new DLLearnerView(super.getOWLEditorKit()); Manager.getInstance().setProgressMonitor(view.getStatusBar()); System.out.println("Initializing DL-Learner plugin..."); @@ -106,12 +106,12 @@ } private void addListeners(){ - getOWLEditorKit().getOWLModelManager().addListener(Manager.getInstance(getOWLEditorKit())); - getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().addListener(Manager.getInstance(getOWLEditorKit())); + getOWLEditorKit().getOWLModelManager().addListener(Manager.getInstance()); + getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().addListener(Manager.getInstance()); } private void removeListeners(){ - getOWLEditorKit().getOWLModelManager().removeListener(Manager.getInstance(getOWLEditorKit())); - getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().removeListener(Manager.getInstance(getOWLEditorKit())); + getOWLEditorKit().getOWLModelManager().removeListener(Manager.getInstance()); + getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().removeListener(Manager.getInstance()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |