From: <hee...@us...> - 2008-03-31 14:04:21
|
Revision: 739 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=739&view=rev Author: heeroyuy Date: 2008-03-31 07:04:17 -0700 (Mon, 31 Mar 2008) Log Message: ----------- first hello world protege plugin Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerComponentListener.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerConfig.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerOptionTab.java trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassButton.java Added: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-03-31 14:04:17 UTC (rev 739) @@ -0,0 +1,38 @@ +package org.dllearner.tools.protege; + +import java.awt.event.*; + +public class ActionHandler implements ActionListener, ComponentListener{ + private ActionHandler action; + + + public ActionHandler(ActionHandler a) + { + action = a; + } + public void actionPerformed(ActionEvent z){ + System.out.println("hihihi: "+ z.getActionCommand()); + } + + public void componentHidden(ComponentEvent e) + { + System.out.println("1: "+e.getID()); + } + + public void componentMoved(ComponentEvent e) + { + System.out.println("2: "+ e.getComponent().getClass().getName()); + } + + public void componentResized(ComponentEvent e) + { + //System.out.println("3: "+ e.getComponent().getClass().getName()); + } + + public void componentShown(ComponentEvent e) + { + System.out.println("4: "+ e.getID()); + } + + +} Added: trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java 2008-03-31 14:04:17 UTC (rev 739) @@ -0,0 +1,25 @@ +package org.dllearner.tools.protege; + +import org.protege.editor.owl.ui.frame.AbstractOWLFrame; +import org.protege.editor.owl.ui.frame.InheritedAnonymousClassesFrameSection; +import org.protege.editor.owl.ui.frame.OWLClassAssertionAxiomIndividualSection; +import org.protege.editor.owl.ui.frame.OWLDisjointClassesAxiomFrameSection; +import org.protege.editor.owl.ui.frame.OWLEquivalentClassesAxiomFrameSection; +import org.protege.editor.owl.ui.frame.OWLSubClassAxiomFrameSection; +import org.semanticweb.owl.model.OWLClass; +import org.protege.editor.owl.OWLEditorKit; + +public class ButtonList extends AbstractOWLFrame<OWLClass>{ + + public ButtonList(OWLEditorKit editorKit) + { + super(editorKit.getOWLModelManager().getOWLOntologyManager()); + addSection(new OWLEquivalentClassesAxiomFrameSection(editorKit, this)); + addSection(new SuggestClassButton(editorKit, this)); + addSection(new OWLSubClassAxiomFrameSection(editorKit, this)); + //addSection(new SuggestClassButton(editorKit, this)); + addSection(new InheritedAnonymousClassesFrameSection(editorKit, this)); + addSection(new OWLClassAssertionAxiomIndividualSection(editorKit, this)); + addSection(new OWLDisjointClassesAxiomFrameSection(editorKit, this)); + } +} Added: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerComponentListener.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerComponentListener.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerComponentListener.java 2008-03-31 14:04:17 UTC (rev 739) @@ -0,0 +1,16 @@ +package org.dllearner.tools.protege; + +import java.awt.event.*; + +public class DLLearnerComponentListener implements ItemListener { + + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + + System.out.println("JUHU "+e.getStateChange()); + + } else { + + } + } +} Added: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerConfig.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerConfig.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerConfig.java 2008-03-31 14:04:17 UTC (rev 739) @@ -0,0 +1,54 @@ +package org.dllearner.tools.protege; + +import org.protege.editor.owl.OWLEditorKit; + +public class DLLearnerConfig { + + + + public void DLLearnerStart() + { + System.out.println("blub"); + /*ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource source = cm.knowledgeSource(OWLFile.class); + String example = "examples/family/father.owl"; + cm.applyConfigEntry(source, "url", new File(example).toURI().toString()); + source.init(); + + // create DIG reasoning service with standard settings + ReasonerComponent reasoner = cm.reasoner(DIGReasoner.class, source); + // ReasoningService rs = cm.reasoningService(DIGReasonerNew.class, source); + reasoner.init(); + ReasoningService rs = cm.reasoningService(reasoner); + + // create a learning problem and set positive and negative examples + LearningProblem lp = cm.learningProblem(PosNegDefinitionLP.class, rs); + Set<String> positiveExamples = new TreeSet<String>(); + positiveExamples.add("http://example.com/father#stefan"); + positiveExamples.add("http://example.com/father#markus"); + positiveExamples.add("http://example.com/father#martin"); + Set<String> negativeExamples = new TreeSet<String>(); + negativeExamples.add("http://example.com/father#heinz"); + negativeExamples.add("http://example.com/father#anna"); + negativeExamples.add("http://example.com/father#michelle"); + cm.applyConfigEntry(lp, "positiveExamples", positiveExamples); + cm.applyConfigEntry(lp, "negativeExamples", negativeExamples); + lp.init(); + + // create the learning algorithm + LearningAlgorithm la = null; + try { + la = cm.learningAlgorithm(RandomGuesser.class, lp, rs); + } catch (LearningProblemUnsupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + cm.applyConfigEntry(la, "numberOfTrees", 100); + cm.applyConfigEntry(la, "maxDepth", 5); + la.init(); + + // start the algorithm and print the best concept found + la.start(); + System.out.println(la.getBestSolution());*/ + } +} Added: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerOptionTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerOptionTab.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerOptionTab.java 2008-03-31 14:04:17 UTC (rev 739) @@ -0,0 +1,175 @@ +package org.dllearner.tools.protege; + +import org.protege.editor.owl.OWLEditorKit; + +import org.semanticweb.owl.model.OWLClass; +import org.semanticweb.owl.model.OWLDescription; +import org.semanticweb.owl.model.OWLException; +import org.protege.editor.owl.ui.frame.*; +import org.protege.editor.owl.ui.framelist.OWLFrameList2; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.*; + +import org.dllearner.algorithms.RandomGuesser; +import org.dllearner.core.ComponentInitException; +import org.dllearner.algorithms.refexamples.ExampleBasedROLearner; +import org.dllearner.core.ComponentManager; +import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.algorithms.RandomGuesser; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; +import org.dllearner.kb.OWLFile; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.kb.OWLFile; +import org.semanticweb.owl.model.*; + + + +public class DLLearnerOptionTab extends AbstractOWLFrameSectionRowObjectEditor<OWLDescription> + { + + private JLabel pos; + private JComponent learner; + private JSplitPane split; + private JButton accept; + private JButton config; + private OWLEditorKit editor; + private JPanel option; + private JScrollPane suggest; + private JPanel vorschlag; + private Object[] blub; + private OWLDescription initialDescription; + private JLabel neg; + private String test; + private ActionHandler action; + private DLLearnerComponentListener listen; + private DLLearnerConfig dlLearnerConfig; + private JCheckBox hi; + + + //TODO: Layout selber festlegen denn die standartlayouts sind scheisse + //TODO: ActionListener implementieren + //TODO: Reasoner, learningproblems und algos direkt vom dl-learner beziehen + //TODO: instanz vom DLLearnerOptionTab wieder zuruecksetzen damit beim laden neue Ontologie erkannt wird + public DLLearnerOptionTab(OWLEditorKit editorKit, OWLDescription description) { + + dlLearnerConfig = new DLLearnerConfig(); + editor = editorKit; + initialDescription = description; + split = new JSplitPane(split.HORIZONTAL_SPLIT,false); + suggest = new JScrollPane(); + vorschlag = new JPanel(new GridLayout(3,1)); + learner = new JPanel(); + option = new JPanel(new GridLayout(20,1)); + init(); + hi= new JCheckBox("Test", true); + //buildLearnerOption(); + } + + public void startDLLearner() + { + new DLLearnerConfig().DLLearnerStart(); + + + } + public void init() + { + action = new ActionHandler(this.action); + listen = new DLLearnerComponentListener(); + } + + public OWLDescription getEditedObject() + { + String expression = "JUHU"; + try { + return editor.getOWLModelManager().getOWLDescriptionParser().createOWLDescription(expression); + } + catch (OWLException e){ + return null; + } + + } + + private void buildLearnerOption() + { + learner.setPreferredSize(new Dimension(500, 400)); + split = new JSplitPane(split.HORIZONTAL_SPLIT,false); + split.setResizeWeight(0.5); + + pos = new JLabel("Positive Examples"); + option.add(pos); + blub=editor.getOWLModelManager().getActiveOntology().getReferencedIndividuals().toArray(); + for(int j = 0; j<editor.getOWLModelManager().getActiveOntology().getReferencedIndividuals().size();j++) + { + option.add(new JCheckBox(editor.getOWLModelManager().getActiveOntology().getURI().toString()+"#"+blub[j], true)).addComponentListener(action); + } + neg = new JLabel("Negative Examples"); + option.add(neg); + for(int j = 0; j<editor.getOWLModelManager().getActiveOntology().getReferencedIndividuals().size();j++) + { + option.add(new JCheckBox(editor.getOWLModelManager().getActiveOntology().getURI().toString()+"#"+blub[j], true)).addComponentListener(action); + } + config = new JButton("Config"); + config.addActionListener(this.action); + option.add(config); + option.add(hi); + accept = new JButton("RUN"); + accept.addActionListener(this.action); + vorschlag.add(suggest); + vorschlag.add(accept); + split.setLeftComponent(option); + split.setRightComponent(vorschlag); + learner.add(split); + System.out.println(""); + //System.out.println("hi: "+hi.get); + startDLLearner(); + + } + +public void actionPerformed(ActionEvent a) +{ + System.out.println(a.getSource()); +} + public JComponent getEditorComponent() + { + buildLearnerOption(); + return learner; + } + + public void clear() + { + if(split!=null) + { + split.removeAll(); + option.removeAll(); + vorschlag.removeAll(); + } + } + + public void dispose(){ + } + + public Set<OWLDescription> getEditedObjects() + { + return super.getEditedObjects(); + } + } \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2008-03-31 14:04:17 UTC (rev 739) @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Hallo Welt +Bundle-SymbolicName: org.dllearner.tools.protege;singleton:=true +Bundle-Category: protege +Bundle-Description: blablabla +Bundle-Vendor: blablabla +Bundle-DocURL: blablabla +Bundle-ClassPath: .,lib/xbean.jar,lib/dig1.1-xmlbeans.jar,lib/junit-4.4.jar,log4j.jar,lib/components.ini +Import-Package: org.osgi.framework,org.apache.log4j +Export-Package: lib +Bundle-Version: 1.0.0 +Bundle-Activator: org.protege.editor.core.plugin.DefaultPluginActivator +Require-Bundle: org.eclipse.equinox.registry,org.eclipse.equinox.common,org.protege.editor.core.application,org.protege.editor.owl,org.semanticweb.owl.owlapi Added: trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml 2008-03-31 14:04:17 UTC (rev 739) @@ -0,0 +1,10 @@ +<?xml version="1.0" ?> + <plugin> + <extension id="org.dllearner.tools.protege.ProtegePlugin" + point="org.protege.editor.core.application.ViewComponent"> + <label value="Hallo Welt"/> + <class value="org.dllearner.tools.protege.ProtegePlugin"/> + <headerColor value="@org.protege.classcolor"/> + <category value="@org.protege.classcategory"/> + </extension> + </plugin> \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2008-03-31 14:04:17 UTC (rev 739) @@ -0,0 +1,34 @@ +package org.dllearner.tools.protege; + +import org.protege.editor.owl.ui.view.AbstractOWLClassViewComponent; +import org.semanticweb.owl.model.OWLClass; +import org.protege.editor.owl.ui.framelist.OWLFrameList2; +import javax.swing.*; +import java.awt.*; + + +public class ProtegePlugin extends AbstractOWLClassViewComponent +{ + +private OWLFrameList2<OWLClass> list; + + public void initialiseClassView() throws Exception { + list = new OWLFrameList2<OWLClass>(getOWLEditorKit(), new ButtonList(getOWLEditorKit())); + setLayout(new BorderLayout()); + JScrollPane hallo = new JScrollPane(list); + add(hallo); + + + } + + + protected OWLClass updateView(OWLClass selectedClass) { + list.setRootObject(selectedClass); + return selectedClass; + } + + + public void disposeView() { + list.dispose(); + } +} \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassButton.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassButton.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassButton.java 2008-03-31 14:04:17 UTC (rev 739) @@ -0,0 +1,64 @@ +package org.dllearner.tools.protege; + +import java.util.Comparator; + +import org.protege.editor.owl.OWLEditorKit; +import org.protege.editor.owl.ui.frame.AbstractOWLFrameSection; +import org.protege.editor.owl.ui.frame.OWLFrame; +import org.protege.editor.owl.ui.frame.OWLFrameSectionRow; +import org.protege.editor.owl.ui.frame.OWLFrameSectionRowObjectEditor; +import org.semanticweb.owl.model.OWLClass; +import org.semanticweb.owl.model.OWLDescription; +import org.semanticweb.owl.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.util.CollectionFactory; + + +public class SuggestClassButton extends AbstractOWLFrameSection<OWLClass, OWLEquivalentClassesAxiom, OWLDescription> { + + private static final String LABEL = "Suggest a class"; + + + public SuggestClassButton(OWLEditorKit editorKit, OWLFrame<OWLClass> frame) + { + super(editorKit, LABEL, frame); + } + + protected void clear() { + + } + + + + protected void refill(OWLOntology ontology) { + + } + + + protected void refillInferred() { + + } + + + public void visit(SuggestClassButton axiom) { + + + } + + + protected OWLEquivalentClassesAxiom createAxiom(OWLDescription object) { + return getOWLDataFactory().getOWLEquivalentClassesAxiom(CollectionFactory.createSet(getRootObject(), object)); + } + + + public OWLFrameSectionRowObjectEditor<OWLDescription> getObjectEditor() { + + return new DLLearnerOptionTab(getOWLEditorKit(), null); + + } + + + public Comparator<OWLFrameSectionRow<OWLClass, OWLEquivalentClassesAxiom, OWLDescription>> getRowComparator() { + return null; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |