From: <lor...@us...> - 2010-03-05 14:03:33
|
Revision: 2092 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2092&view=rev Author: lorenz_b Date: 2010-03-05 14:03:25 +0000 (Fri, 05 Mar 2010) Log Message: ----------- Some improvements in plugin design. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/ModelsIcon.java trunk/src/dl-learner/org/dllearner/tools/protege/warning-icon.png Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -37,8 +37,6 @@ import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.owl.Description; -import org.dllearner.learningproblems.EvaluatedDescriptionClass; /** * This class processes input from the user. @@ -104,7 +102,7 @@ if (z.getActionCommand().equals(EQUIVALENT_CLASS_LEARNING_STRING) || z.getActionCommand().equals(SUPER_CLASS_LEARNING_STRING)) { model.setKnowledgeSource(); - view.getSuggestClassPanel().getSuggestModel().clear(); + view.getSuggestClassPanel().getSuggestionsTable().clear(); view.getSuggestClassPanel().repaint(); model.setLearningProblem(); model.setLearningAlgorithm(); @@ -124,16 +122,7 @@ } if (z.getActionCommand().equals(ADD_BUTTON_STRING)) { - if (evaluatedDescription != null) { - model - .changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription - .getDescription()); - } else { - model - .changeDLLearnerDescriptionsToOWLDescriptions((Description) view - .getSuggestClassPanel().getSuggestList() - .getSelectedValue()); - } + model.changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription.getDescription()); String message = "<html><font size=\"3\">class expression added</font></html>"; view.setHintMessage(message); view.setHelpButtonVisible(false); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -185,8 +185,6 @@ posPanel = new PosAndNegSelectPanel(model, action); detail = new MoreDetailForSuggestedConceptsPanel(model); sugPanelHandler = new SuggestClassPanelHandler(this, model, action); - sugPanel.addSuggestPanelMouseListener(sugPanelHandler); - sugPanel.getSuggestList().addListSelectionListener(sugPanelHandler); sugPanel.getSuggestionsTable().getSelectionModel().addListSelectionListener(sugPanelHandler); this.addAcceptButtonListener(this.action); this.addRunButtonListener(this.action); @@ -437,7 +435,6 @@ */ public void dispose() { this.unsetEverything(); - sugPanel.getSuggestList().removeAll(); sugPanel.getSuggestionsTable().clear(); learner.removeAll(); sugPanel = null; @@ -471,7 +468,7 @@ } /** - * This Method returns the run button. + * This method returns the run button. * @return JButton */ public JButton getRunButton() { @@ -487,7 +484,7 @@ } /** - * This methode returns if the ontology is inconsistent. + * This method returns if the ontology is inconsistent. * @return boolean if ontology is inconsistent */ public boolean getIsInconsistent() { @@ -545,7 +542,7 @@ } /** - * This methode sets the help button visible. + * This method sets the help button visible. * @param isVisible boolean if help button is visible */ public void setHelpButtonVisible(boolean isVisible) { @@ -569,21 +566,21 @@ } /** - * This Methode starts the status bar. + * This method starts the status bar. */ public void startStatusBar() { stat.showProgress(true); } /** - * This methode stops the status bar. + * This method stops the status bar. */ public void stopStatusBar() { stat.showProgress(false); } /** - * This methode returns the statusbar. + * This method returns the statusbar. * @return statusbar */ public StatusBar2 getStatusBar() { Added: trunk/src/dl-learner/org/dllearner/tools/protege/ModelsIcon.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ModelsIcon.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ModelsIcon.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -0,0 +1,30 @@ +package org.dllearner.tools.protege; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; + +import javax.swing.Icon; + +public class ModelsIcon implements Icon { + + @Override + public int getIconHeight() { + return 16; + } + + @Override + public int getIconWidth() { + return 16; + } + + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + g.setColor(Color.BLACK); + g.drawLine(3, y, 3, getIconHeight()); + g.drawLine(3, 7, getIconWidth() - 2, 7); + g.drawLine(3, 10,getIconWidth() - 2, 10); + + } + +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -142,28 +142,11 @@ } } - /** - * This method returns the current Description list. - * - * @return JList of Descriptions - */ - public JList getSuggestList() { - return descriptions; - } public SuggestionsTable getSuggestionsTable() { return suggestionTable; } - /** - * This method adds the suggest list to the Mouse Listener. - * - * @param action - * ActionHandler - */ - public void addSuggestPanelMouseListener(SuggestClassPanelHandler handle) { - descriptions.addMouseListener(handle); - } /** * Thsi method returns the list model for the suggest list. Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanelHandler.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -19,22 +19,16 @@ */ package org.dllearner.tools.protege; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.List; -import java.util.Set; - import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.learningproblems.EvaluatedDescriptionClass; /** * This is the MouseListener for the Suggest Panel. * @author Christian Koetteritzsch * */ -public class SuggestClassPanelHandler implements MouseListener, ListSelectionListener{ +public class SuggestClassPanelHandler implements ListSelectionListener{ private DLLearnerView view; private DLLearnerModel model; private ActionHandler action; @@ -51,88 +45,20 @@ this.action = a; } - @Override /** - * This methode sets the graphical coverage panel enable when a - * suggested class expression is selected. - */ - public void mouseClicked(MouseEvent e) { - if (view.getSuggestClassPanel().getSuggestList().getSelectedValue() != null) { - EvaluatedDescription evaluatedDescription = (EvaluatedDescription)view.getSuggestClassPanel().getSuggestList().getSelectedValue(); -// SuggestListItem item = (SuggestListItem) view -// .getSuggestClassPanel().getSuggestList().getSelectedValue(); -// String desc = item.getValue(); -// if (model.getEvaluatedDescriptionList() != null) { -// List<? extends EvaluatedDescription> evalList = model -// .getEvaluatedDescriptionList(); -// Set<String> onto = model.getOntologyURIString(); -// for (EvaluatedDescription eDescription : evalList) { -// for (String ont : onto) { -// if (desc.equals(eDescription.getDescription() -// .toManchesterSyntaxString(ont, null))) { -// evaluatedDescription = eDescription; -// action.setEvaluatedClassExpression(eDescription); -// break; -// } -// } -// } -// } - view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel(evaluatedDescription); - view.setGraphicalPanel(); - } - } - - @Override - /** - * Nothing happens here. - */ - public void mouseEntered(MouseEvent e) { - - } - - @Override - /** - * Nothing happens here. - */ - public void mouseExited(MouseEvent e) { - - } - - @Override - /** - * This methode sets the add button enable when - * a suggested class expression is selected. - */ - public void mousePressed(MouseEvent e) { - if (view.getSuggestClassPanel().getSuggestList().getSelectedValue() != null) { - if (!view.getAddButton().isEnabled()) { - view.getAddButton().setEnabled(true); - } - } - } - - @Override - /** - * Nothing happens here. - */ - public void mouseReleased(MouseEvent e) { - - } - - - @Override - /** * Nothing happens here. */ public void valueChanged(ListSelectionEvent e) { if(view.getSuggestClassPanel().getSuggestionsTable().getSelectedRow() >= 0){ - EvaluatedDescriptionClass ec = view.getSuggestClassPanel().getSuggestionsTable().getSelectedSuggestion(); - if(!e.getValueIsAdjusting() && ec != null){ + EvaluatedDescription newDesc = view.getSuggestClassPanel().getSuggestionsTable().getSelectedSuggestion(); +// evaluatedDescription = view.getSuggestClassPanel().getSuggestionsTable().getSelectedSuggestion(); + if(!e.getValueIsAdjusting() && (evaluatedDescription == null || !evaluatedDescription.equals(newDesc))){ + evaluatedDescription = newDesc; view.getMoreDetailForSuggestedConceptsPanel(). - renderDetailPanel(ec); + renderDetailPanel(evaluatedDescription); view.setGraphicalPanel(); - action.setEvaluatedClassExpression(ec); + action.setEvaluatedClassExpression(evaluatedDescription); view.getAddButton().setEnabled(true); } } Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -1,90 +0,0 @@ -/** - * Copyright (C) 2007-2009, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.tools.protege; - -import java.awt.Color; -import java.awt.Component; - -import javax.swing.BorderFactory; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JTextPane; - -import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.owl.Description; -import org.dllearner.learningproblems.EvaluatedDescriptionClass; -import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; -import org.protege.editor.owl.OWLEditorKit; -import org.protege.editor.owl.ui.renderer.OWLCellRenderer; -/** - * This is the class that is responsible for the rendering of the - * concepts that are shown in the SuggestPanel. - * @author Christian Koetteritzsch - * - */ -public class SuggestListCellRenderer extends OWLCellRenderer { - - private static final long serialVersionUID = 8040385703448641356L; - /** - * Constructor for the Cell Renderer for the Suggest List. - */ - public SuggestListCellRenderer(OWLEditorKit editorKit) { - super(editorKit); - setWrap(false); - setHighlightKeywords(true); - setOpaque(true); - } - - /** - * Renderer for the entries of the SuggestPanel. - * @param list JList - * @param value Object - * @param arg2 int - * @param arg4 boolean - * @param iss boolean boolean if current element is selected. - * @return Component Returns the currently rendered component of the suggest list - */ - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - EvaluatedDescriptionClass desc = (EvaluatedDescriptionClass)value; - Component c = super.getListCellRendererComponent(list, OWLAPIDescriptionConvertVisitor.getOWLDescription(desc.getDescription()), index, isSelected, cellHasFocus); - JTextPane pane = (JTextPane)((JPanel)c).getComponent(1); - if(!desc.isConsistent()){ - pane.setForeground(Color.RED); - } - - // Set the text and - // background color for rendering -// setText(((SuggestListItem) value).getValue() + " " + "Accuracy: " + Math.round(((SuggestListItem) value).getAccuracy())+"%"); -// setBackground(Color.WHITE); -// setForeground(((SuggestListItem) value).getColor()); -// // Set a border if the list -// // item is selected -// if (iss) { -// setBorder(BorderFactory.createLineBorder(Color.GRAY, 2)); -// } else { -// setBorder(BorderFactory.createLineBorder(list.getBackground(), 2)); -// } -// setEnabled(list.isEnabled()); - - return c; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -1,71 +0,0 @@ -/** - * Copyright (C) 2007-2009, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.tools.protege; - -import java.awt.Color; -/** - * This Class represents an entry of the suggest list. - * @author Christian Koetteritzsch - * - */ -public class SuggestListItem { - - private final Color color; - private String value; - private double accuracy; - /** - * Constructor for the SuggestListItem. - * @param c Color Color in which the text is painted. - * @param s String text that is shown. - * @param acc Accuracy of the concept - */ - public SuggestListItem( - Color c, String s, double acc) { - this.color = c; - this.value = s; - this.accuracy = acc; - - } - - /** - * This method returns the color of the current list item. - * @return Color Color of the current list item - */ - public Color getColor() { - return color; - } - - /** - * This Method returns the text of the current list item. - * @return String Text of the current list item - */ - public String getValue() { - return value; - } - - /** - * This method returns the accuracy of the current list item. - * @return accuracy - */ - public double getAccuracy() { - return accuracy; - } -} - Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -2,7 +2,10 @@ import java.util.List; +import javax.swing.table.DefaultTableCellRenderer; + import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.dllearner.tools.ore.ui.ResultTableModel; import org.jdesktop.swingx.JXTable; import org.protege.editor.owl.OWLEditorKit; import org.protege.editor.owl.ui.renderer.OWLCellRenderer; @@ -16,22 +19,27 @@ private final OWLCellRenderer owlRenderer; private final ProgressBarTableCellRenderer progressRenderer; + private EvaluatedDescriptionClass old; public SuggestionsTable(OWLEditorKit editorKit){ super(new SuggestionsTableModel()); + progressRenderer = new ProgressBarTableCellRenderer(); progressRenderer.setBackground(getBackground()); getColumn(0).setCellRenderer(progressRenderer); + owlRenderer = new OWLCellRenderer(editorKit, false, false); owlRenderer.setHighlightKeywords(true); owlRenderer.setWrap(false); - getColumn(1).setCellRenderer(owlRenderer); + getColumn(2).setCellRenderer(owlRenderer); + setColumnSizes(); } private void setColumnSizes(){ getColumn(0).setMaxWidth(100); - getColumn(1).setPreferredWidth(430); + getColumn(1).setMaxWidth(20); + getColumn(2).setPreferredWidth(430); } public void clear(){ @@ -39,7 +47,16 @@ } public void setSuggestions(List<EvaluatedDescriptionClass> suggestionList){ + if(getSelectedRow() >= 0){ + old = getSelectedSuggestion(); + } ((SuggestionsTableModel)getModel()).setSuggestions(suggestionList); + if(old != null){ + int newRowIndex = ((SuggestionsTableModel)getModel()).getSelectionIndex(old); + if(newRowIndex >= 0){ + getSelectionModel().setSelectionInterval(newRowIndex, newRowIndex); + } + } } public EvaluatedDescriptionClass getSelectedSuggestion(){ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java 2010-03-05 10:44:55 UTC (rev 2091) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTableModel.java 2010-03-05 14:03:25 UTC (rev 2092) @@ -3,6 +3,8 @@ import java.util.ArrayList; import java.util.List; +import javax.swing.Icon; +import javax.swing.ImageIcon; import javax.swing.table.AbstractTableModel; import org.dllearner.learningproblems.EvaluatedDescriptionClass; @@ -17,7 +19,9 @@ private static final long serialVersionUID = -6920806148989403795L; private List<EvaluatedDescriptionClass> suggestionList; - + private final Icon inconsistentIcon = new ImageIcon(this.getClass().getResource("warning-icon.png")); + private final Icon followsIcon = new ModelsIcon(); + public SuggestionsTableModel(){ super(); suggestionList = new ArrayList<EvaluatedDescriptionClass>(); @@ -29,7 +33,7 @@ @Override public int getColumnCount() { - return 2; + return 3; } @Override @@ -39,28 +43,44 @@ @Override public Object getValueAt(int rowIndex, int columnIndex) { - if(columnIndex == 0){ - return (int)(suggestionList.get(rowIndex).getAccuracy() * 100); - } else { - return OWLAPIDescriptionConvertVisitor.getOWLDescription(suggestionList.get(rowIndex).getDescription()); + switch (columnIndex) { + case 0: + return (int) (suggestionList.get(rowIndex).getAccuracy() * 100); + case 1: + if (!suggestionList.get(rowIndex).isConsistent()) { + return inconsistentIcon; + } else if(suggestionList.get(rowIndex).followsFromKB()){ + return followsIcon; + }break; + case 2: + return OWLAPIDescriptionConvertVisitor + .getOWLDescription(suggestionList.get(rowIndex) + .getDescription()); } - + return null; + } @Override - public Class<? extends Object> getColumnClass(int columnIndex){ - if(columnIndex == 0) { + public Class<? extends Object> getColumnClass(int columnIndex) { + switch (columnIndex) { + case 0: return String.class; - } else { + case 1: + return Icon.class; + case 2: return OWLDescription.class; } + return null; } @Override public String getColumnName(int column){ if(column == 0){ return "Accuracy"; + } else if (column == 2){ + return "Class expression"; } else { - return "Class expression"; + return ""; } } @@ -79,5 +99,8 @@ return suggestionList.get(rowIndex); } + public int getSelectionIndex(EvaluatedDescriptionClass e){ + return suggestionList.indexOf(e); + } } Added: trunk/src/dl-learner/org/dllearner/tools/protege/warning-icon.png =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/tools/protege/warning-icon.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |