001 /**
002 * Copyright (C) 2007-2009, Jens Lehmann
003 *
004 * This file is part of DL-Learner.
005 *
006 * DL-Learner is free software; you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation; either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * DL-Learner is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program. If not, see <http://www.gnu.org/licenses/>.
018 *
019 */
020 package org.dllearner.tools.protege;
021 import java.awt.Dimension;
022 import java.awt.GridLayout;
023 import java.util.Set;
024
025 import javax.swing.JPanel;
026 import javax.swing.JTextArea;
027
028 import org.dllearner.core.EvaluatedDescription;
029 import org.dllearner.learningproblems.EvaluatedDescriptionClass;
030
031
032
033 /**
034 * This class shows more details of the suggested concepts. It shows the positive and negative examples
035 * that are covered and that are not covered by the suggested concepts. It also shows the accuracy of the
036 * selected concept.
037 * @author Christian Koetteritzsch
038 *
039 */
040
041 public class MoreDetailForSuggestedConceptsPanel extends JPanel {
042
043 private static final long serialVersionUID = 785272797932584581L;
044
045 // Model of the dllearner
046
047 private final DLLearnerModel model;
048
049 // Textarea to render the accuracy of the concept
050
051 private final JTextArea accuracy;
052
053
054 private final JTextArea accuracyText;
055 // Evaluated description of the selected concept
056 private final JPanel conceptPanel;
057
058 private EvaluatedDescription eval;
059 private final JTextArea concept;
060 private Set<String> ontologiesStrings;
061 private final JTextArea conceptText;
062 private static final int HEIGHT = 350;
063 private static final int WIDTH = 600;
064 private GraphicalCoveragePanel p;
065 private final MoreDetailForSuggestedConceptsPanelHandler handler;
066
067 /**
068 * This is the constructor for the Panel.
069 * @param model DLLearnerModel
070 */
071 public MoreDetailForSuggestedConceptsPanel(DLLearnerModel model) {
072 super();
073 setLayout(null);
074 setPreferredSize(new Dimension(WIDTH, HEIGHT));
075 this.model = model;
076 handler = new MoreDetailForSuggestedConceptsPanelHandler(this);
077 concept = new JTextArea("Class Description:");
078
079 concept.setEditable(false);
080
081
082 conceptPanel = new JPanel(new GridLayout(0, 2));
083 conceptPanel.setBounds(5, 0, 800, 50);
084
085 accuracy = new JTextArea("Accuracy:");
086 accuracy.setEditable(false);
087 conceptText = new JTextArea();
088 conceptText.setEditable(false);
089
090 accuracyText = new JTextArea();
091 //sets accuracy text area not editable
092 accuracyText.setEditable(false);
093 accuracy.setVisible(false);
094 accuracyText.setVisible(false);
095 concept.setVisible(false);
096 conceptText.setVisible(false);
097
098 }
099
100 /**
101 * This method renders the output for the detail panel.
102 * @param desc selected description
103 */
104 public void renderDetailPanel(EvaluatedDescription desc) {
105 accuracy.setVisible(false);
106 accuracyText.setVisible(false);
107 concept.setVisible(false);
108 conceptText.setVisible(false);
109 eval = desc;
110
111 //panel for the informations of the selected concept
112 //this method adds the informations for the selected concept to the panel
113 this.setInformation();
114 p = new GraphicalCoveragePanel(eval, model, conceptText.getText(), this);
115 p.setBounds(5, 0, 600, 350);
116 //adds all information to the example panel
117 unsetEverything();
118 conceptPanel.removeAll();
119 conceptPanel.add(concept);
120 conceptPanel.add(accuracy);
121 conceptPanel.add(conceptText);
122 conceptPanel.add(accuracyText);
123 conceptPanel.setVisible(true);
124 //this.add(conceptPanel);
125 this.add(p);
126 this.addPropertyChangeListener(handler);
127 //conceptPanel.addPropertyChangeListener(handler);
128 this.repaint();
129 }
130
131 private void unsetEverything() {
132 removeAll();
133 }
134 /**
135 * This method sets the Informations of the selected description.
136 */
137 public void setInformation() {
138 ontologiesStrings = model.getOntologyURIString();
139 if(eval!=null) {
140 //sets the accuracy of the selected concept
141 for(String ontoString : ontologiesStrings) {
142 if(eval.getDescription().toString().contains(ontoString)) {
143 conceptText.setText(eval.getDescription().toManchesterSyntaxString(ontoString, null));
144 break;
145 }
146 }
147
148 //sets the accuracy of the concept
149 double acc = ((EvaluatedDescriptionClass) eval).getAccuracy()*100;
150 accuracyText.setText(String.valueOf(acc)+"%");
151 }
152 accuracy.setVisible(true);
153 accuracyText.setVisible(true);
154 concept.setVisible(true);
155 conceptText.setVisible(true);
156 }
157
158
159 public GraphicalCoveragePanel getGraphicalCoveragePanel() {
160 return p;
161 }
162 public JPanel getConceptPanel() {
163 return conceptPanel;
164 }
165 public void unsetPanel() {
166 unsetEverything();
167 conceptPanel.removeAll();
168 accuracy.setVisible(false);
169 accuracyText.setVisible(false);
170 concept.setVisible(false);
171 conceptText.setVisible(false);
172 if(p != null) {
173 p.unsetPanel();
174 }
175 conceptPanel.add(concept);
176 conceptPanel.add(accuracy);
177 conceptPanel.add(conceptText);
178 conceptPanel.add(accuracyText);
179 conceptPanel.setVisible(false);
180 this.add(conceptPanel);
181
182 repaint();
183 }
184
185 }