From: <hee...@us...> - 2008-11-07 17:46:44
|
Revision: 1496 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1496&view=rev Author: heeroyuy Date: 2008-11-07 17:46:34 +0000 (Fri, 07 Nov 2008) Log Message: ----------- -changes in panel where the examples are set 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/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-07 14:31:10 UTC (rev 1495) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -124,20 +124,6 @@ view.renderErrorMessage(message); view.updateWindow(); } - - if (z.getActionCommand().equals("?")) { - if (z.getSource().toString().contains("PosHelpButton")) { - String help = "An individual that should be an instance of the learned class description.\n" - +"Per Default all that belongs to the class."; - view.getPosAndNegSelectPanel().renderHelpMessage(help); - } - - if (z.getSource().toString().contains("NegHelpButton")) { - String help = "A Instance tht doesn't follow from the classdescription."; - view.getPosAndNegSelectPanel().renderHelpMessage(help); - } - - } if (z.getActionCommand().equals("")) { if (!toggled) { toggled = true; Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-07 14:31:10 UTC (rev 1495) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -197,6 +197,9 @@ private JXTaskPane detailPane; private String ontologyURI; private Map<String, String> prefixes; + private DefaultListModel posListModel; + private DefaultListModel negListModel; + private Vector<IndividualObject> individualVector; // This is a List of evaluated descriptions to get more information of the // suggested concept @@ -225,9 +228,12 @@ ontologyURI = editor.getModelManager().getActiveOntology().getURI().toString()+"#"; owlDescription = new HashSet<OWLDescription>(); positiv = new Vector<JCheckBox>(); + posListModel = new DefaultListModel(); + negListModel = new DefaultListModel(); negativ = new Vector<JCheckBox>(); normalIndividuals = new Vector<String>(); ComponentManager.setComponentClasses(componenten); + individualVector = new Vector<IndividualObject>(); cm = ComponentManager.getInstance(); ds = new HashSet<OWLDescription>(); suggestModel = new DefaultListModel(); @@ -461,23 +467,13 @@ // 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(ontologyURI, prefixes), true); - box.setName("Positive"); - positiv.add(box); - // and ne genative examples unchecked - JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), false); - box.setName("Negative"); - negativ.add(box2); + posListModel.add(0, ind.toManchesterSyntaxString(ontologyURI, prefixes)); + individualVector.add(new IndividualObject(indiv, ind.toManchesterSyntaxString(ontologyURI, prefixes), true)); } else { // When no it unchecks the positive example - 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(ontologyURI, prefixes), true); - box.setName("Negative"); - negativ.add(box2); + negListModel.add(0, ind.toManchesterSyntaxString(ontologyURI, prefixes)); + individualVector.add(new IndividualObject(indiv, ind.toManchesterSyntaxString(ontologyURI, prefixes), false)); } } } @@ -492,7 +488,9 @@ } } - + public Vector<IndividualObject> getIndividualVector() { + return individualVector; + } /** * This method sets the individuals that belong to the concept which is * chosen in protege. @@ -573,6 +571,9 @@ * closed. */ public void clearVector() { + individualVector.removeAllElements(); + posListModel.removeAllElements(); + negListModel.removeAllElements(); positiv.removeAllElements(); negativ.removeAllElements(); } @@ -587,7 +588,14 @@ public void setDescriptionList(Description[] list) { description = list; } - + + public DefaultListModel getPosListModel() { + return posListModel; + } + + public DefaultListModel getNegListModel() { + return negListModel; + } /** * This method returns the current learning algorithm that is used to learn * new concepts. Added: trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -0,0 +1,30 @@ +package org.dllearner.tools.protege; + +public class IndividualObject { + + private String normalIndividual; + private String manchesterIndividual; + private boolean isPos; + + public IndividualObject(String normal, String manchester, boolean pos) { + normalIndividual = normal; + manchesterIndividual = manchester; + isPos = pos; + } + + public String getIndividualString() { + return normalIndividual; + } + + public String getManchesterIndividual() { + return manchesterIndividual; + } + + public boolean isPositiveExample() { + return isPos; + } + + public void setExamplePositive(boolean pos) { + isPos = pos; + } +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-07 14:31:10 UTC (rev 1495) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -73,7 +73,7 @@ // Panel where the informations of the selected panel are rendered - private JPanel examplePanel; + //private JPanel examplePanel; // Text area that shows the covered positive examples @@ -178,7 +178,7 @@ //sets accuracy text area not editable accuracyText.setEditable(false); //panel for the informations of the selected concept - examplePanel = new JPanel(new GridLayout(0,2)); + //examplePanel = new JPanel(new GridLayout(0,2)); //this method adds the informations for the selected concept to the panel setInformation(); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-07 14:31:10 UTC (rev 1495) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -412,7 +412,7 @@ learner.setPreferredSize(new Dimension(600, 520)); accept.setPreferredSize(new Dimension(290, 50)); advanced.setName("Advanced"); - posPanel = new PosAndNegSelectPanel(model, action); + posPanel = new PosAndNegSelectPanel(model, action, this); addAcceptButtonListener(this.action); addRunButtonListener(this.action); addAdvancedButtonListener(this.action); @@ -445,21 +445,21 @@ * 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(); - //model.initReasoner(); + model.initReasoner(); model.setPosVector(); - posPanel.setJCheckBoxes(); + System.out.println(model.getPosListModel()); + posPanel.setExampleList(model.getPosListModel(), model.getNegListModel()); accept.setEnabled(false); action.resetToggled(); addButtonPanel.add("North", accept); @@ -487,7 +487,6 @@ learner.add(hint); learner.add(errorMessage); learner.add(posPanel); - posPanel.addHelpButtonListener(action); detail = new MoreDetailForSuggestedConceptsPanel(model); add(learner); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-07 14:31:10 UTC (rev 1495) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -20,12 +20,12 @@ package org.dllearner.tools.protege; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.GridLayout; +import javax.swing.DefaultListModel; import javax.swing.JButton; -import javax.swing.JComboBox; import javax.swing.JLabel; +import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -44,7 +44,7 @@ // This is the Panel here the check boxes, the labels, and the help buttons // are in. - private JPanel posAndNegPanel; + //private JPanel posAndNegPanel; // this is the Panel where the check boxes are. @@ -57,7 +57,19 @@ // This is the Scroll pane if there are more Check boxes than the view can // show - private JScrollPane scrollPanel; + private JScrollPane posScrollList; + + private JScrollPane negScrollList; + + private JList posList; + private JList negList; + private JPanel posPanel; + private JPanel negPanel; + private JPanel buttonPanel; + private JButton addToNegExamples; + private JButton addToPosExamples; + private JPanel posLabelPanel; + private JPanel negLabelPanel; // This is the Label that shows "Positive Examples" @@ -70,13 +82,7 @@ // 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; @@ -87,9 +93,14 @@ // This is the Text area where the help message is displayed. private OptionPanel optionPanel; - private JComboBox optionBox; - private JPanel optionBoxPanel; - private ActionHandler action; + //private JComboBox optionBox; + //private JPanel optionBoxPanel; + //private ActionHandler action; + private DefaultListModel posListModel; + private DefaultListModel negListModel; + private JPanel examplePanel; + private PosAndNegSelectPanelHandler handler; + private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; /** * This is the constructor for the Panel that shows the check boxes. @@ -99,95 +110,107 @@ * @param act * ActionHandler */ - public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act) { + public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView v) { + //set layout for parent Panel super(); - setLayout(new GridLayout(0,1)); + setLayout(new GridLayout(0, 1)); setPreferredSize(new Dimension(490, 250)); + view = v; + this.model = model; + handler = new PosAndNegSelectPanelHandler(model, view, this); + //Instantiate all objects needed optionPanel = new OptionPanel(); + examplePanel = new JPanel(null); + posLabelPanel = new JPanel(null); + negLabelPanel = new JPanel(null); + posListModel = new DefaultListModel(); + negListModel = new DefaultListModel(); pos = new JLabel("Positive Examples"); + pos.setBounds(0, 0, 100, 30); neg = new JLabel("Negative Examples"); - optionBoxPanel = new JPanel(new GridLayout(0, 1)); - action = act; - optionBox = new JComboBox(); - optionBox.addItem("min. accuracy"); - optionBox.addItem("max. nr. of results"); - optionBox.addItem("max. executiontime"); - optionBoxPanel.add(optionBox); - setComboBoxListener(); - // help button for positive examples + neg.setBounds(0, 0, 100, 30); + posList = new JList(posListModel); + negList = new JList(negListModel); + addToPosExamples = new JButton("pos"); + addToNegExamples = new JButton("neg"); helpForPosExamples = new JButton("?"); - helpForPosExamples.setSize(10, 10); - // help button for negative examples + helpForPosExamples.setBounds(100, 5, 20, 20); helpForNegExamples = new JButton("?"); - helpForNegExamples.setSize(10, 10); - posLabelPanel = new JPanel(new GridLayout(0, 1)); - negLabelPanel = new JPanel(new GridLayout(0, 1)); - // panel for the positive check boxes with flow layout - posLabelPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); - // panel for the negative check boxes with flow layout - negLabelPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); - // sets the name for the positive examples help button to - // differ which button is pressed + helpForNegExamples.setBounds(100, 5, 20, 20); helpForPosExamples.setName("PosHelpButton"); + helpForNegExamples.setName("NegHelpButton"); + //set size for components that have no layout. + posPanel = new JPanel(null); + posPanel.setPreferredSize(new Dimension(200, 100)); + negPanel = new JPanel(null); + negPanel.setPreferredSize(new Dimension(200, 100)); + buttonPanel = new JPanel(null); + buttonPanel.setPreferredSize(new Dimension(90, 85)); + addToPosExamples.setBounds(0, 50, 70, 30); + addToNegExamples.setBounds(0, 80, 70, 30); + addToPosExamples.setEnabled(false); + addToNegExamples.setEnabled(false); + buttonPanel.add(addToPosExamples); + buttonPanel.add(addToNegExamples); posLabelPanel.add(pos); posLabelPanel.add(helpForPosExamples); - // sets the name for the negative examples help button to - // differ which button is pressed - helpForNegExamples.setName("NegHelpButton"); negLabelPanel.add(neg); negLabelPanel.add(helpForNegExamples); - this.model = model; - // panel for the check boxes - posAndNegSelectPanel = new JPanel(new GridLayout(0, 2)); - - model.clearVector(); - model.unsetListModel(); - model.initReasoner(); + posScrollList = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + posScrollList.setViewportView(posList); - model.setPosVector(); - posAndNegPanel = new JPanel(new GridLayout(0, 1)); - posAndNegPanel.add(posAndNegSelectPanel); - // renders scroll bars if necessary - scrollPanel = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + negScrollList = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - scrollPanel.setViewportView(posAndNegPanel); - optionPanel.setPreferredSize(new Dimension(490, 100)); - scrollPanel.setPreferredSize(new Dimension(490, 140)); + negScrollList.setViewportView(negList); + + posLabelPanel.setBounds(0, 0, 200, 30); + posScrollList.setBounds(0, 40, 190, 85); + + posPanel.add(posScrollList); + posPanel.add(posLabelPanel); + + negLabelPanel.setBounds(0, 0, 200, 30); + negScrollList.setBounds(0, 40, 185, 85); + negPanel.add(negLabelPanel); + negPanel.add(negScrollList); + + posPanel.setBounds(0, 0, 200, 250); + buttonPanel.setBounds(210, 0, 90, 250); + negPanel.setBounds(300, 0, 200, 250); + examplePanel.add(posPanel); + examplePanel.add(buttonPanel); + examplePanel.add(negPanel); + addHelpButtonListener(handler); add(optionPanel); - add(scrollPanel); - addListeners(action); + add(examplePanel); } /** * This method adds the check boxes, the labels and the help buttons for * positive and negative examples. */ - public void setJCheckBoxes() { - posAndNegSelectPanel.add(posLabelPanel); - posAndNegSelectPanel.add(negLabelPanel); - // adds check boxes for all examples of the ontology - for (int j = 0; j < model.getPosVector().size(); j++) { - // this is for the check boxes of the positive examples - posAndNegSelectPanel.add(model.getPositivJCheckBox(j)); - // this is for the check boxes of the negative examples - posAndNegSelectPanel.add(model.getNegativJCheckBox(j)); - } - + public void setExampleList(DefaultListModel posData, DefaultListModel negData) { + posListModel = posData; + negListModel = negData; + posList.setModel(posListModel); + negList.setModel(negListModel); } - /** - * This method adds the ActionListener to the Option Combo Box. - */ - private void setComboBoxListener() { - optionBox.addActionListener(action); + public JButton getAddToPosPanelButton() { + return addToPosExamples; } + public JButton getAddToNegPanelButton() { + return addToNegExamples; + } + /** * This method removes the Check boxes, the labels and the help buttons * after the DL-Learner tab is closed. */ public void unsetPosAndNegPanel() { - posAndNegSelectPanel.removeAll(); + } /** @@ -198,32 +221,14 @@ */ public void addListeners(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).addItemListener(act); - // listener for the check boxes of the negative examples - model.getNegativJCheckBox(i).addItemListener(act); - } } 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); - model.getNegativJCheckBox(j).setEnabled(enable); - } - } /** @@ -261,11 +266,11 @@ * @param a * ActionHandler */ - public void addHelpButtonListener(ActionHandler a) { + public void addHelpButtonListener(PosAndNegSelectPanelHandler handle) { // adds listener to the help button for the positive examples - helpForPosExamples.addActionListener(a); + helpForPosExamples.addActionListener(handle); // adds listener to the help button for the negative examples - helpForNegExamples.addActionListener(a); + helpForNegExamples.addActionListener(handle); } public void removeHelpButtonListener(ActionHandler a) { Added: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -0,0 +1,151 @@ +package org.dllearner.tools.protege; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + + +public class PosAndNegSelectPanelHandler implements ActionListener, MouseListener { + + +// This is the DLLearnerModel. + +private DLLearnerModel model; +//private PosAndNegSelectPanel panel; +// This is the view of the DL-Learner tab. +private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; + +/** + * 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 or an equivalent class + * @param editor OWLEditorKit + */ +public PosAndNegSelectPanelHandler(DLLearnerModel m, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView v, PosAndNegSelectPanel p) { + model = m; + //panel = p; + view = v; +} + +/** + * When a Button is pressed this method select the right. + * @param z ActionEvent + */ +public void actionPerformed(ActionEvent action) { + + + if (action.getActionCommand().equals("pos")) { + + } + + if (action.getActionCommand().equals("neg")) { + + } + + if (action.getActionCommand().equals("?")) { + if (action.getSource().toString().contains("PosHelpButton")) { + String help = "An individual that should be an instance of the learned class description.\n" + +"Per Default all that belongs to the class."; + view.getPosAndNegSelectPanel().renderHelpMessage(help); + } + + if (action.getSource().toString().contains("NegHelpButton")) { + String help = "A Instance tht doesn't follow from the classdescription."; + view.getPosAndNegSelectPanel().renderHelpMessage(help); + } + + } +} + +/** + * select/deselect the Check boxes. + * @param i ItemEvent + */ +public void itemStateChanged(ItemEvent i) { + if (i.getItem().toString().contains("Positive")) { + for (int j = 0; j < model.getPosVector().size(); j++) { + if (i.getItem().toString().contains( + model.getPosVector().get(j).getText().toString())) { + if (!model.getPosVector().get(j).isSelected()) { + model.getPosVector().get(j).setSelected(true); + break; + } + if (model.getPosVector().get(j).isSelected()) { + model.getPosVector().get(j).setSelected(false); + break; + } + } + } + } + if (i.getItem().toString().contains("Negative")) { + for (int j = 0; j < model.getNegVector().size(); j++) { + if (i.getItem().toString().contains( + model.getNegVector().get(j).getText().toString())) { + if (!model.getNegVector().get(j).isSelected()) { + model.getNegVector().get(j).setSelected(true); + break; + } + if (model.getNegVector().get(j).isSelected()) { + model.getNegVector().get(j).setSelected(false); + break; + } + } + } + } +} + + +/** + * Nothing happens here. + * @param m MouseEvent + */ +public void mouseReleased(MouseEvent m) { + +} + + /** + * Nothing happens here. + * @param m MouseEvent + */ +public void mouseEntered(MouseEvent m) { + +} + +/** + * Choses the right EvaluatedDescription object after a concept is chosen in the list. + * @param m MouseEvent + */ +public void mouseClicked(MouseEvent m) { + if (view.getSuggestClassPanel().getSuggestList() + .getSelectedValue() != null) { + } else { + +} +} + +/** + * Nothing happens here. + * @param m MouseEvent + */ +public void mouseExited(MouseEvent m) { + +} + +/** + * Sets the ADD button enable after a concept is chosen. + * @param m MouseEvent + */ +public void mousePressed(MouseEvent m) { +} + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |