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. |