From: <hee...@us...> - 2008-06-15 13:46:36
|
Revision: 962 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=962&view=rev Author: heeroyuy Date: 2008-06-15 06:46:32 -0700 (Sun, 15 Jun 2008) Log Message: ----------- -add picture for advanced button -continued to comment 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/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-06-14 15:49:20 UTC (rev 961) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-06-15 13:46:32 UTC (rev 962) @@ -1,15 +1,13 @@ package org.dllearner.tools.protege; - - -//import java.awt.event.*; import java.awt.event.ActionListener; import java.awt.event.ItemListener; import java.awt.event.MouseListener; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; import java.awt.event.MouseEvent; -import java.awt.event.TextEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.ListSelectionEvent; import org.dllearner.core.owl.Description; /** @@ -17,33 +15,34 @@ * @author Heero Yuy * */ -public class ActionHandler implements ActionListener, ItemListener, MouseListener{ +public class ActionHandler implements ActionListener, ItemListener, MouseListener, ListSelectionListener{ /** - * + * This is the DLLearnerModel. */ private DLLearnerModel model; /** - * + * This is the id that checks if the equivalent class or subclass button is + * pressed in protege */ private String id; /** - * + * 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 Thread dlLearner; /** - * + * This is the view of the DL-Learner tab. */ private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; /** - * - * @param a - * @param m - * @param view - * @param i + * This is the constructor for the action handler + * @param a ActionHandler + * @param m DLLearnerModel + * @param view DLlearner tab + * @param i id if it is a subclass oran equivalent class */ public ActionHandler(ActionHandler a,DLLearnerModel m,OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view ,String i) { @@ -65,7 +64,7 @@ { model.unsetListModel(); } - if(view.getPosAndNegSelectPanel().getPosAndNegSelectPanel().getComponentCount()<=0) + if(view.getPosAndNegSelectPanel().getPosAndNegSelectPanel().getComponentCount()<=2) { view.renderErrorMessage("Could not start learning. No Examples where available"); } @@ -185,6 +184,11 @@ } } } + + public void valueChanged(ListSelectionEvent e) + { + + } /** * */ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-06-14 15:49:20 UTC (rev 961) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-06-15 13:46:32 UTC (rev 962) @@ -11,8 +11,6 @@ import javax.swing.DefaultListModel; import javax.swing.JCheckBox; -import java.net.URI; - import org.dllearner.algorithms.refinement.ROLearner; import org.dllearner.algorithms.SimpleSuggestionLearningAlgorithm; @@ -39,23 +37,25 @@ import org.protege.editor.owl.OWLEditorKit; import org.protege.editor.owl.ui.frame.OWLFrame; +import org.semanticweb.owl.io.RDFXMLOntologyFormat; import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.model.OWLClass; +import org.semanticweb.owl.model.OWLOntologyChangeException; import org.semanticweb.owl.model.OWLOntologyCreationException; +import org.semanticweb.owl.model.OWLOntologyStorageException; import org.semanticweb.owl.model.AddAxiom; import org.semanticweb.owl.model.OWLOntologyFormat; import org.semanticweb.owl.model.OWLAxiom; import org.semanticweb.owl.model.OWLDataFactory; - import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.model.OWLOntologyManager; import org.semanticweb.owl.model.OWLDescription; +import org.semanticweb.owl.model.UnknownOWLOntologyException; - /** * This Class provides the necessary methods to learn Concepts from the DL-Learner. * @author Heero Yuy @@ -176,7 +176,10 @@ * */ private String error; - + /** + * + */ + private OWLAxiom axiomOWLAPI; /** * This is the constructor for DL-Learner model @@ -244,13 +247,11 @@ { if(positiv.get(i).isSelected()) { - System.out.println("blub"); positiveExamples.add(positiv.get(i).getText()); } if(negativ.get(i).isSelected()) { - System.out.println("bla"); negativeExamples.add(negativ.get(i).getText()); } } @@ -281,14 +282,6 @@ public void setKnowledgeSource() { this.source = new OWLAPIOntology(editor.getOWLModelManager().getActiveOntology()); - /*String uri=getUri(); - cm.applyConfigEntry(source, "url", new File(uri).toURI().toString()); - try{ - source.init(); - } - catch(ComponentInitException e){ - e.printStackTrace(); - }*/ } /** @@ -405,22 +398,6 @@ } /** - * This method gets an uri for an ontology and loads it. - * @param uri Uri for the Ontology - */ - /*public void loadOntology(URI uri) - { - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - try{ - ontology = manager.loadOntology(uri); - } - catch(OWLOntologyCreationException e) - { - System.out.println("Can't create Ontology: "+ e); - } - }*/ - - /** * This method sets the check boxes for the positive check boxes checked * if the individuals matches the concept that is chosen in protege. */ @@ -495,17 +472,6 @@ { isChecked = true; } - /*for(Iterator<Individual> j = individual.iterator(); j.hasNext();) - { - String indi1 = j.next().getName(); - System.out.println("Individuals: "+ indi1); - if(indi1.toString().equals(indi.toString())) - { - System.out.println(indi); - isChecked = true; - break; - } - }*/ return isChecked; } @@ -521,21 +487,6 @@ } /** - * This method returns the physical uri of the ontology which is currently loaded in protege. - * @return pysical uri of the loaded ontology - */ - /*public String getUri() - { - char[] test = editor.getOWLModelManager().getOntologyPhysicalURI(editor.getOWLModelManager().getActiveOntology()).toString().toCharArray(); - String uri=""; - for(int i =6; i<test.length;i++) - { - uri=uri+test[i]; - } - return uri; - }*/ - - /** * This method gets an array of concepts from the DL-Learner and stores it * in the description array. * @param list Array of concepts from DL-Learner @@ -714,29 +665,18 @@ OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLDataFactory factory = manager.getOWLDataFactory(); - System.out.println("Manager: "+manager); - OWLAxiom axiomOWLAPI = factory.getOWLEquivalentClassesAxiom(ds); - OWLOntologyFormat format = new OWLOntologyFormat(); - format = manager.getOntologyFormat(ontology); + + axiomOWLAPI = factory.getOWLEquivalentClassesAxiom(ds); + OWLOntology ontology = editor.getOWLModelManager().getActiveOntology(); - System.out.println("Format: "+format); AddAxiom axiom = new AddAxiom(ontology, axiomOWLAPI); - /*try { + try { manager.applyChange(axiom); } catch (OWLOntologyChangeException e) { // TODO Auto-generated catch block e.printStackTrace(); } - try { - manager.saveOntology(ontology,new RDFXMLOntologyFormat(),editor.getOWLModelManager().getActiveOntology().getURI()); - } catch (UnknownOWLOntologyException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (OWLOntologyStorageException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - }*/ } /** @@ -749,11 +689,13 @@ } /** - * - * @return + * 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; } - } \ No newline at end of file + +} \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-06-14 15:49:20 UTC (rev 961) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-06-15 13:46:32 UTC (rev 962) @@ -23,7 +23,6 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.net.URI; import java.util.*; import java.util.List; @@ -54,6 +53,7 @@ private JTabbedPane tabbedPane; private DLLearnerView dllearner; + private ActionHandler action; private OWLClassSelectorPanel classSelectorPanel; @@ -92,8 +92,8 @@ editor = new ExpressionEditor<OWLDescription>(editorKit, checker); dllearner = new DLLearnerView(frame,label); editor.setExpressionObject(description); + action = new ActionHandler(this.action,null,dllearner,null); editor.getDocument().addDocumentListener(editorListener); - tabbedPane = new JTabbedPane(); tabbedPane.setFocusable(false); if(label.equals("Equivalent classes")) @@ -122,7 +122,6 @@ tabbedPane.add(RESTRICTION_CREATOR_LABEL, restrictionCreatorPanel); restrictionCreatorPanel.classSelectorPanel.addSelectionListener(changeListener); restrictionCreatorPanel.objectPropertySelectorPanel.addSelectionListener(changeListener); - //dllearner.DLLearnerViewPanel.addChangeListener(changeListener); tabbedPane.addChangeListener(changeListener); } @@ -151,10 +150,10 @@ restrictionCreatorPanel.objectPropertySelectorPanel.getSelectedOWLObjectProperty() != null; } else if(selectedTabTitle.equals(SUGGEST_EQUIVALENT_CLASS_LABEL)){ - validated = dllearner.getSollution()!= null; + validated = true; } else if(selectedTabTitle.equals(SUGGEST_SUBCLASS_LABEL)){ - validated = dllearner.getSollution()!= null; + validated = true; } return validated; } @@ -180,11 +179,11 @@ System.out.println("Und jetzt bin ich hier :-)"); dllearner.unsetEverything(); dllearner.makeView(); + handleVerifyEditorContents(); initialDescription = null; editor.setText(""); } - @Override public Set<OWLDescription> getEditedObjects() { if (tabbedPane.getSelectedComponent() == classSelectorPanel) { @@ -195,6 +194,7 @@ } else if(tabbedPane.getSelectedComponent() == dllearner){ System.out.println("die loesungen:"+dllearner.getSollutions()); + return dllearner.getSollutions(); } return super.getEditedObjects(); @@ -262,10 +262,6 @@ /** * */ - // private JLabel pos; - /** - * - */ private final static long serialVersionUID = 624829578325729385L; /** * @@ -290,58 +286,18 @@ /** * */ - //private JPanel option; - - /** - * - */ - // private JLabel neg; - /** - * - */ - //private JDialog hilfe; - /** - * - */ - //private JTextArea help; - /** - * - */ private JLabel adv; /** * */ - //private JScrollPane scrollPane; - /** - * - */ private final Color Color_RED = Color.red; /** * - */; - /** - * */ private JButton cancel; /** * */ - // private JPanel posLabelPanel; - /** - * - */ - //private JPanel negLabelPanel; - /** - * - */ - //private JButton helpForPosExamples; - /** - * - */ - //private JButton helpForNegExamples; - /** - * - */ private JLabel errorMessage; /** * @@ -358,14 +314,14 @@ /** * */ - //private DefaultListModel descriptions; + + private SuggestClassPanel sugPanel; + private PosAndNegSelectPanel posPanel; + private ImageIcon icon; /** * * @return */ - private SuggestClassPanel sugPanel; - private PosAndNegSelectPanel posPanel; - private ImageIcon icon; public DLLearnerViewPanel getDLLearnerViewPanel() { return panel; @@ -377,15 +333,17 @@ */ public DLLearnerView(OWLFrame<OWLClass> aktuell,String label){ editor = editorKit; - icon = new ImageIcon("pfeil.gif"); - icon.getImage(); + classSelectorPanel = new OWLClassSelectorPanel(editorKit); + classSelectorPanel.firePropertyChange("test", false, true); + icon = new ImageIcon(OWLClassDescriptionEditorWithDLLearnerTab.class.getResource("/bilder/org/dllearner/tools/protege/pfeil.gif")); model = new DLLearnerModel(editorKit,aktuell, label,this); - //model.loadOntology(getUri()); panel = new DLLearnerViewPanel(editor); sugPanel = new SuggestClassPanel(); action = new ActionHandler(this.action, model,this,label); adv = new JLabel("Advanced"); advanced = new JToggleButton(icon); + advanced.setIcon(icon); + advanced.setVisible(true); run = new JButton("Suggest "+label); cancel = new JButton("Cancel"); accept = new JButton("ADD"); @@ -494,17 +452,9 @@ * * @return */ - /*public URI getUri() - { - URI uri = editor.getOWLModelManager().getOntologyPhysicalURI(editor.getOWLModelManager().getActiveOntology()); - return uri; - }*/ - /** - * - * @return - */ public Set<OWLDescription> getSollutions() { + return model.getNewOWLDescription(); } /** @@ -516,12 +466,7 @@ System.out.println(model.getSolution()); return model.getSolution(); } - /** - * - */ - private void setJCheckBoxen() - { - } + /** * */ @@ -543,14 +488,6 @@ errorMessage.setForeground(Color_RED); errorMessage.setText(s); } - - /** - * - */ - public void setDescriptionList(DefaultListModel model) - { - //this.descriptions = model; - } /** * @@ -574,18 +511,11 @@ public void dispose() { } + /** * * @param a */ - public void addSuggestListToChangeListener(ActionListener a) - { - - } - /** - * - * @param a - */ public void addRunButtonListener(ActionListener a) { run.addActionListener(a); @@ -610,15 +540,6 @@ * * @param a */ - public void addHelpButtonListener(ActionListener a) - { - //helpForPosExamples.addActionListener(a); - //helpForNegExamples.addActionListener(a); - } - /** - * - * @param a - */ public void addAdvancedButtonListener(ActionListener a) { advanced.addActionListener(a); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-06-14 15:49:20 UTC (rev 961) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-06-15 13:46:32 UTC (rev 962) @@ -13,24 +13,71 @@ import java.awt.FlowLayout; import java.awt.GridLayout; - +/** + * This class is the Panel for the Check boxes where the positive and negative + * examples are chosen. + * @author Heero Yuy + * + */ public class PosAndNegSelectPanel extends JPanel{ private static final long serialVersionUID = 23632947283479L; + /** + * This is the Panel here the check boxes, the labels, and the help buttons are in. + */ private JPanel posAndNegPanel; + /** + * this is the Panel where the check boxes are. + */ private JPanel posAndNegSelectPanel; + /** + * This is the DLLearner Model + */ private DLLearnerModel model; + /** + * This is the Scroll pane if there are more Check boxes than the view can show + */ private JScrollPane scrollPanel; + /** + * This is the Label that shows "Positive Examples" + */ private JLabel pos; + /** + * This is the Label that shows "Negative Examples" + */ private JLabel neg; + /** + * This is the Panel where the Label for Positive Examples and + * a help Button is in + */ private JPanel posLabelPanel; + /** + * This is the Panel where the Label for Negative Examples and + * a help Button is in + */ private JPanel negLabelPanel; + /** + * This is the Help button for positive examples + */ private JButton helpForPosExamples; + /** + * This is the Help button for negative examples + */ private JButton helpForNegExamples; + /** + * This is the Text area where the help message is displayed. + */ private JTextArea help; + /** + * This is the frame that pops up when the help button is pressed. + */ private JDialog hilfe; private final Color COLOR_BLACK = Color.black; - + /** + * This is the constructor for the Panel that shows the check boxes. + * @param model DLLearnerModel + * @param action ActionHandler + */ public PosAndNegSelectPanel(DLLearnerModel model,ActionHandler action) { super(); @@ -57,7 +104,6 @@ model.unsetListModel(); model.initReasoner(); model.setPosVector(); - //setJCheckBoxen(); posAndNegPanel = new JPanel(new GridLayout(0,1)); posAndNegPanel.add(posAndNegSelectPanel); scrollPanel = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); @@ -66,7 +112,10 @@ add(scrollPanel); addListeners(action); } - + /** + * This method adds the check boxes, the labels and the help buttons for + * positive and negative examples. + */ public void setJCheckBoxen() { posAndNegSelectPanel.add(posLabelPanel); @@ -78,10 +127,18 @@ } } + /** + * This method removes the Check boxes, the labels and the help buttons + * after the DL-Learner tab is closed. + */ public void unsetPosAndNegPanel() { posAndNegSelectPanel.removeAll(); } + /** + * This method adds the item listener for every check box + * @param action ActionHandler + */ public void addListeners(ActionHandler action) { for(int i=0;i<model.getPosVector().size();i++) @@ -91,16 +148,25 @@ } } + /** + * This method returns the Panel where the check boxes, labels and help buttons are in. + * @return JPanel where check boxes, labels and help buttons are in. + */ public JPanel getPosAndNegSelectPanel() { return posAndNegSelectPanel; } - + /** + * This method unselect the selected check boxes after learning + */ public void unsetCheckBoxes() { model.unsetJCheckBoxen(); } - + /** + * This message displays the help message after the help button is pressed. + * @param helfen hilfenachricht + */ public void renderHelpMessage(String helfen) { JScrollPane scrollHelp = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); @@ -119,7 +185,10 @@ scrollHelp.setBounds(0, 0, 300, 100); hilfe.add(scrollHelp); } - + /** + * This method adds the Action listener to the help buttons. + * @param a ActionHandler + */ public void addHelpButtonListener(ActionHandler a) { helpForPosExamples.addActionListener(a); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-06-14 15:49:20 UTC (rev 961) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-06-15 13:46:32 UTC (rev 962) @@ -3,20 +3,45 @@ import java.awt.Dimension; import javax.swing.*; +import javax.swing.event.ChangeListener; - +import org.protege.editor.core.ui.view.ViewComponent; +import org.protege.editor.owl.ui.clshierarchy.ToldOWLClassHierarchyViewComponent; +import org.protege.editor.owl.ui.view.ChangeListenerMediator; +/** + * This class is the panel for the suggest list. + * It shows the descriptions made by the DL-Learner. + * @author Heero Yuy + * + */ public class SuggestClassPanel extends JPanel { private static final long serialVersionUID = 724628423947230L; - + /** + * Description List + */ private JList descriptions; + /** + * Panel for the description list + */ private JPanel suggestPanel; + /** + * Date for the description list + */ private DefaultListModel model; + /** + * Scroll panel if the suggestions are longer than the Panel itself + * + */ private JScrollPane suggestScroll; - + /** + * This is the constructor for the suggest panel. + * It creates a new Scroll panel and puts the Suggest List in it. + */ public SuggestClassPanel() { super(); + suggestScroll = new JScrollPane(); suggestScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); model = new DefaultListModel(); @@ -29,27 +54,45 @@ add(suggestScroll); } - + /** + * this method adds an new Scroll Panel and returns the updated SuggestClassPanel. + * @return updated SuggestClassPanel + */ public SuggestClassPanel updateSuggestClassList() { add(suggestScroll); return this; } + /** + * This method is called after the model for the suggest list is updated. + * + * @param desc List model of descriptions made by the DL-Learner + */ public void setSuggestList(DefaultListModel desc) { descriptions.setModel(desc); } + /** + * This method returns the current Description list. + * @return JList of Descriptions + */ public JList getSuggestList() { return descriptions; } + /** + * this method adds the suggest list to the Mouse Listener. + * @param action ActionHandler + */ public void addSuggestPanelMouseListener(ActionHandler action) { descriptions.addMouseListener(action); + } + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |