From: <hee...@us...> - 2008-11-06 13:29:11
|
Revision: 1494 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1494&view=rev Author: heeroyuy Date: 2008-11-06 13:29:04 +0000 (Thu, 06 Nov 2008) Log Message: ----------- -some changes in GUI 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/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -257,8 +257,7 @@ evaluatedDescription); } } else { - String message = "No concept to select."; - view.renderErrorMessage(message); + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -25,6 +25,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -194,6 +195,8 @@ // This is necessary to get the details of the suggested concept private JXTaskPane detailPane; + private String ontologyURI; + private Map<String, String> prefixes; // This is a List of evaluated descriptions to get more information of the // suggested concept @@ -219,6 +222,7 @@ current = h; this.id = id; this.view = view; + ontologyURI = editor.getModelManager().getActiveOntology().getURI().toString()+"#"; owlDescription = new HashSet<OWLDescription>(); positiv = new Vector<JCheckBox>(); negativ = new Vector<JCheckBox>(); @@ -240,30 +244,25 @@ alreadyLearned = false; setKnowledgeSource(); setReasoner(); + prefixes = reasoner.getPrefixes(); + } /** * This method adds the solutions from the DL-Learner to the List Model. */ private void addToListModel() { + evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts(), view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy(), true); for (int j = 0; j < evalDescriptions.size(); j++) { if (isConsistent(evalDescriptions.get(j))) { suggestModel.add(j, new SuggestListItem(Color.GREEN, evalDescriptions.get(j).getDescription() - .toManchesterSyntaxString( - editor.getModelManager() - .getActiveOntology().getURI() - .toString() - + "#", null))); + .toManchesterSyntaxString(ontologyURI, prefixes))); } else { suggestModel.add(j, new SuggestListItem(Color.RED, evalDescriptions.get(j).getDescription() - .toManchesterSyntaxString( - editor.getModelManager() - .getActiveOntology().getURI() - .toString() - + "#", null))); + .toManchesterSyntaxString(ontologyURI, prefixes))); } } } @@ -351,7 +350,7 @@ // dllearner should suggest an equivalent class lp = cm.learningProblem(PosNegDefinitionLP.class, rs); } - if (id.equals("superclasses")) { + if (id.equals("super classes")) { // sets the learning problem to PosNegInclusionLP when the dllearner // should suggest a subclass lp = cm.learningProblem(PosNegInclusionLP.class, rs); @@ -379,6 +378,7 @@ // TODO Auto-generated catch block e.printStackTrace(); } + System.out.println("TIME: "+view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); try { // initializes the learning algorithm @@ -461,21 +461,21 @@ // checks if individual belongs to the selected concept if (setPositivExamplesChecked(indiv)) { // when yes then it sets the positive example checked - JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), true); + JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), true); box.setName("Positive"); positiv.add(box); // and ne genative examples unchecked - JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), false); + JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), false); box.setName("Negative"); negativ.add(box2); } else { // When no it unchecks the positive example - JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), false); + JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), false); box.setName("Positive"); positiv.add(box); // and checks the negative example - JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), true); + JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), true); box.setName("Negative"); negativ.add(box2); } @@ -524,7 +524,27 @@ individual = rs.getIndividuals(); } } - + public boolean hasIndividuals(OWLClass OWLConcept) { + boolean hasIndividuals = false; + NamedClass concept = null; + NamedClass selectedConcept = null; + Iterator<NamedClass> it = reasoner.getAtomicConcepts().iterator(); + while(it.hasNext()) { + concept = it.next(); + if (concept.toManchesterSyntaxString(ontologyURI, prefixes).equals(OWLConcept.toString())) { + selectedConcept = concept; + break; + } + } + System.out.println("CON: "+ concept); + System.out.println("SIZE: "+ reasoner.retrieval(concept).size()); + if (reasoner.retrieval(selectedConcept).size() > 0) { + hasIndividuals = true; + } + concept = null; + selectedConcept = null; + return hasIndividuals; + } /** * This method gets an Individual and checks if this individual belongs to * the concept chosen in protege. Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -24,6 +24,7 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collections; @@ -36,7 +37,6 @@ import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; -import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -127,14 +127,13 @@ editingComponent = new JPanel(new BorderLayout()); editingComponent.add(tabbedPane); editingComponent.setPreferredSize(new Dimension(600, 520)); - if(dllearner.getNrOfIndividuals()!=0) { if (label.equals("equivalent classes")) { tabbedPane.add(SUGGEST_EQUIVALENT_CLASS_LABEL, dllearner); } - if (label.equals("superclasses")) { + if (label.equals("super classes")) { tabbedPane.add(SUGGEST_SUBCLASS_LABEL, dllearner); } - } + // tabbedPane.add(CLASS_EXPRESSION_EDITOR_LABEL, new JScrollPane(editor)); if (description == null || !description.isAnonymous()) { @@ -356,11 +355,13 @@ // Picture of the advanced button when it is toggled private JPanel addButtonPanel; - private JTextArea wikiPane; + private JLabel wikiPane; private ImageIcon toggledIcon; private JTextArea hint; // This is the Panel for more details of the suggested concept private MoreDetailForSuggestedConceptsPanel detail; + OWLFrame<OWLClass> frame; + private URL pluginURL; /** * The constructor for the DL-Learner tab in the class description @@ -373,8 +374,16 @@ public DLLearnerView(OWLFrame<OWLClass> current, String label, OWLClassDescriptionEditorWithDLLearnerTab dlLearner) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); mainWindow = dlLearner; - wikiPane = new JTextArea("See http://dl-learner.org/wiki/ProtegePlugin for an introduction."); - wikiPane.setEditable(false); + frame = current; + try { + pluginURL = new URL("http://dl-learner.org/wiki/ProtegePlugin"); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + wikiPane = new JLabel("See " + pluginURL + " for an introduction."); + //wikiPane.setEditable(false); + classSelectorPanel.firePropertyChange("test", false, true); URL iconUrl = this.getClass().getResource("arrow.gif"); icon = new ImageIcon(iconUrl); @@ -387,6 +396,7 @@ adv = new JLabel("Advanced Settings"); advanced = new JToggleButton(icon); advanced.setVisible(true); + run = new JButton("Suggest " + label); accept = new JButton("ADD"); addButtonPanel = new JPanel(new BorderLayout()); @@ -435,6 +445,15 @@ * This Method renders the view of the plugin. */ public void makeView() { + System.out.println("CURRENT: "+ frame.getRootObject()); + System.out.println("MODEL: "+model.hasIndividuals(frame.getRootObject())); + if (model.hasIndividuals(frame.getRootObject())) { + run.setEnabled(true); + } else { + run.setEnabled(false); + String message ="There are no Instances for "+ frame.getRootObject()+" available. Please insert some Instances."; + renderErrorMessage(message); + } advanced.setIcon(icon); model.clearVector(); model.unsetListModel(); @@ -596,6 +615,12 @@ * Destroys the view after the plugin is closed. */ public void dispose() { + System.out.println("hier"); + run.removeActionListener(action); + accept.removeActionListener(action); + advanced.removeActionListener(action); + posPanel.removeListeners(action); + posPanel.removeHelpButtonListener(action); } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -57,6 +57,7 @@ private Set<OWLClass> added; private boolean inferredEquivalentClasses = true; + private OWLClassDescriptionEditorWithDLLearnerTab dlLearner; private OWLFrame<OWLClass> frame; /** @@ -146,8 +147,9 @@ public OWLFrameSectionRowObjectEditor<OWLDescription> getObjectEditor() { // Own OWLClassDescriptionEditor to integrate the dllearner in protege // This is to suggest equivalent classes - return new OWLClassDescriptionEditorWithDLLearnerTab(getOWLEditorKit(), + dlLearner = new OWLClassDescriptionEditorWithDLLearnerTab(getOWLEditorKit(), null, frame, LABEL); + return dlLearner; } @Override Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -51,11 +51,12 @@ public class OWLSubClassAxiomFrameSection extends AbstractOWLFrameSection<OWLClass, OWLSubClassAxiom, OWLDescription> { - private static final String LABEL = "superclasses"; + private static final String LABEL = "super classes"; private Set<OWLDescription> added = new HashSet<OWLDescription>(); private OWLFrame<OWLClass> frame; + private OWLClassDescriptionEditorWithDLLearnerTab dlLearner; /** * Constructor of the OWLSubClassesAxiomFrameSection. * @param editorKit OWLEditorKit @@ -121,8 +122,9 @@ public OWLFrameSectionRowObjectEditor<OWLDescription> getObjectEditor() { // Own OWLClassDescriptionEditor to integrate the dllearner in protege // this is to suggest subclasses - return new OWLClassDescriptionEditorWithDLLearnerTab(getOWLEditorKit(), + dlLearner = new OWLClassDescriptionEditorWithDLLearnerTab(getOWLEditorKit(), null, frame, LABEL); + return dlLearner; } @Override Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -207,6 +207,17 @@ } + public void removeListeners(ActionHandler act) { + // adds the listener for the checkboxes + for (int i = 0; i < model.getPosVector().size(); i++) { + // listener for the check boxes of the positive examples + model.getPositivJCheckBox(i).removeItemListener(act); + // listener for the check boxes of the negative examples + model.getNegativJCheckBox(i).removeItemListener(act); + } + + } + public void setCheckBoxesEnable(boolean enable) { for (int j = 0; j < model.getPosVector().size(); j++) { model.getPositivJCheckBox(j).setEnabled(enable); @@ -240,10 +251,8 @@ */ public void renderHelpMessage(String assistance) { // renders scroll bar if necessary - JOptionPane.showMessageDialog(null, - assistance, - "Help", - JOptionPane.OK_OPTION); + JOptionPane.showMessageDialog(null, assistance); + } /** @@ -259,6 +268,10 @@ helpForNegExamples.addActionListener(a); } + public void removeHelpButtonListener(ActionHandler a) { + helpForPosExamples.removeActionListener(a); + helpForNegExamples.removeActionListener(a); + } public OptionPanel getOptionPanel() { return optionPanel; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -65,6 +65,7 @@ } else { setBorder(BorderFactory.createLineBorder(list.getBackground(), 2)); } + setEnabled(list.isEnabled()); return this; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |