How to print all the rules using modelmanager using eclipse?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to print all the rules using modelmanager using eclipse?

vandita bhatnagar
I have tried this code but there is no error but the way I am getting the
result is not upto mark.
Can anybody guide me for how to access and display all rules in a nice
manner as I am develping a plugin which will display the rules.Please guide
me.

Set<SWRLRule> setOfRules =
modelManager.getActiveOntology().getAxioms(AxiomType.SWRL_RULE);
    SWRLRule rule = null;
    for(Iterator<?> it = setOfRules.iterator(); it.hasNext(); )
        {
        rule = (SWRLRule) it.next();
        label.setText(rule.toString());
            label.setBounds(0, 20, 200, 50);
        }

I want to display rules on a JPanel using an active ontology using
owlmodelmanager .


Please guide me for this.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to print all the rules using modelmanager using eclipse?

Lorenz Buehmann
Looks more like you have problems with Java Swing...



I have tried this code but there is no error but the way I am getting the
result is not upto mark.
Can anybody guide me for how to access and display all rules in a nice
manner as I am develping a plugin which will display the rules.Please guide
me.

Set<SWRLRule> setOfRules =
modelManager.getActiveOntology().getAxioms(AxiomType.SWRL_RULE);
    	SWRLRule rule = null;
    	for(Iterator<?> it = setOfRules.iterator(); it.hasNext(); )
        {
        	rule = (SWRLRule) it.next();
        	label.setText(rule.toString());
            label.setBounds(0, 20, 200, 50);
        }

You're always overwriting the "label" here. If you want to display all rules, you should add separate JLabel objects (or whatever you use for rendering a single rule) to the container object. Or append a rules to a single String object and use a JTextArea. Or ...
It all depends on you.

In any case, the code you showed should at least get all rules as long as you call this method after the ontology was loaded (try to print them via System.out.println() for debugging) - or you have to listen to changes. It's unclear what kind of plugin you create.



_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev