From: <lor...@us...> - 2009-08-04 20:02:49
|
Revision: 1817 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1817&view=rev Author: lorenz_b Date: 2009-08-04 20:02:34 +0000 (Tue, 04 Aug 2009) Log Message: ----------- refactored package structure, since developing and maintaining became to ineffective Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ClassificationProgressMonitor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ColorListCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ColumnListCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/DescriptionLabel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/DescriptionMenuItem.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTableModel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTableModel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/OWLSyntaxTableCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairDialog.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTableModel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/UndoLabel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/UnsatClassesListCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/Wizard.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardController.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardModel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardPanelNotFoundException.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ClassPanelOWLDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ClassPanelSparqlDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/InconsistencyExplanationPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/IntroductionPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/KnowledgeSourcePanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/LearningPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/RepairPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/SavePanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/UnsatisfiableExplanationPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ChangePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ChangesPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ClassPanelOWL.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ClassPanelSparql.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/DescriptionPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ExplanationTablePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/IntroductionPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/LearningPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/LeftPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/RepairPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/RepairPlanPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/SavePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/StatsPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ClassificationProgressMonitor.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/ClassificationProgressMonitor.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ClassificationProgressMonitor.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ClassificationProgressMonitor.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,117 @@ +package org.dllearner.tools.ore.ui; + +import java.awt.Cursor; +import java.awt.Dimension; + +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingUtilities; + +import org.mindswap.pellet.utils.progress.ProgressMonitor; + +public class ClassificationProgressMonitor extends JPanel implements ProgressMonitor{ + + /** + * + */ + private static final long serialVersionUID = -4913267621100462227L; + private javax.swing.ProgressMonitor monitor; + private JProgressBar progressBar; + private String progressMessage = ""; + private String progressTitle = ""; + private int progress = 0; + private int progressLength = 0; + private int progressPercent = -1; + private long startTime = -1; + private boolean canceled = false; + + + public ClassificationProgressMonitor(){ + super(); + monitor = new javax.swing.ProgressMonitor(this, progressTitle, progressMessage, 0 ,progressLength); + progressBar = new JProgressBar(0, progressLength); + progressBar.setValue(progress); + progressBar.setStringPainted(true); + add(progressBar); + setSize(new Dimension(200, 200)); + + } + + @Override + public int getProgress() { + return progress; + } + + @Override + public int getProgressPercent() { + return progressPercent; + } + + @Override + public void incrementProgress() { + setProgress(progress + 1); + + } + + @Override + public boolean isCanceled() { + return monitor.isCanceled(); + } + + @Override + public void setProgress(int progress) { + this.progress = progress; + updateProgress(); + + } + + @Override + public void setProgressLength(int length) { + progressLength = length; + monitor.setMaximum(length); + progressBar.setMaximum(length); + + } + + @Override + public void setProgressMessage(String message) { + progressMessage = message; + monitor.setNote(message); + + } + + @Override + public void setProgressTitle(String title) { + progressTitle = title; + + } + + @Override + public void taskFinished() { + monitor.close(); + setCursor(null); + + } + + @Override + public void taskStarted() { + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + } + + private void updateProgress(){ + SwingUtilities.invokeLater(new Runnable(){ + + @Override + public void run() { + monitor.setProgress(progress); + progressBar.setValue(progress); + + } + + }); + } + + + +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ColorListCellRenderer.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/ColorListCellRenderer.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ColorListCellRenderer.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ColorListCellRenderer.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,79 @@ +/** + * Copyright (C) 2007-2008, 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.ore.ui; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.ListCellRenderer; + +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.tools.ore.ORE; + +/** + * List cell renderer for colored lines to provide better view on list values. + * @author Lorenz Buehmann + * + */ +public class ColorListCellRenderer extends JLabel implements ListCellRenderer { + + private static final long serialVersionUID = -7592805113197759247L; + private ORE ore; + + public ColorListCellRenderer(ORE ore) { + setOpaque(true); + this.ore = ore; + } + + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + if(value instanceof NamedClass){ + setText(((NamedClass) value).toManchesterSyntaxString(ore.getBaseURI(), ore.getPrefixes())); + } else if(value instanceof Individual){ + setText(((Individual) value).toManchesterSyntaxString(ore.getBaseURI(), ore.getPrefixes())); + } + Color background; + Color foreground; + + if (index % 2 == 0 && !isSelected) { + background = new Color(242, 242, 242); + foreground = Color.BLACK; + + } else if(isSelected){ + + background = Color.LIGHT_GRAY; + foreground = Color.BLACK; + }else{ + background = Color.WHITE; + foreground = Color.BLACK; + } + + setForeground(foreground); + setBackground(background); + + return this; + } + +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ColumnListCellRenderer.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/ColumnListCellRenderer.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ColumnListCellRenderer.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ColumnListCellRenderer.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,94 @@ +/** + * Copyright (C) 2007-2008, 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.ore.ui; + +import java.awt.Color; +import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.math.BigDecimal; + +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; + +import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.dllearner.tools.ore.ORE; + +/** + * List cell renderer for 2 columns. + * @author Lorenz Buehmann + * + */ +public class ColumnListCellRenderer extends JPanel implements ListCellRenderer { + + private static final long serialVersionUID = 3024913291199515567L; + private ORE ore; + + + public ColumnListCellRenderer(ORE ore) { + this.ore = ore; + setOpaque(true); + } + + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + removeAll(); + + JLabel cor = new JLabel(); + JLabel desc = new JLabel(); + setLayout(new GridBagLayout()); + desc.setText(((EvaluatedDescriptionClass) value).getDescription().toManchesterSyntaxString(ore.getBaseURI(), ore.getPrefixes())); + //round accuracy to 2 digits + double accuracy = ((EvaluatedDescriptionClass) value).getAccuracy(); + + BigDecimal roundedAccuracy = new BigDecimal(accuracy * 100); + roundedAccuracy = roundedAccuracy.setScale(2, BigDecimal.ROUND_HALF_UP); + cor.setText(String.valueOf(roundedAccuracy)); + add(cor, new GridBagConstraints(0, 0, 1, 1, 0.1, 0.0, GridBagConstraints.LINE_END, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));//, BorderLayout.WEST); + add(desc, new GridBagConstraints(1, 0, 1, 1, 0.8, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));//, BorderLayout.EAST); + + Color background; + Color foreground; + + if (index % 2 == 0 && !isSelected) { + background = new Color(242, 242, 242); + foreground = Color.BLACK; + + } else if(isSelected){ + + background = Color.LIGHT_GRAY; + foreground = Color.WHITE; + }else{ + background = Color.WHITE; + foreground = Color.BLACK; + } + + setForeground(foreground); + setBackground(background); + + return this; + } + +} \ No newline at end of file Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/DescriptionLabel.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/DescriptionLabel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/DescriptionLabel.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,316 @@ +/** + * Copyright (C) 2007-2008, 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.ore.ui; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.Map; +import java.util.Set; + +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JPopupMenu; +import javax.swing.ToolTipManager; + +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Negation; +import org.dllearner.core.owl.ObjectAllRestriction; +import org.dllearner.core.owl.ObjectCardinalityRestriction; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.Thing; +import org.dllearner.tools.ore.ORE; + +/** + * Label that might have menu items when clicked on it. + * @author Lorenz Buehmann + * + */ +public class DescriptionLabel extends JLabel implements MouseListener{ + /** + * + */ + private static final long serialVersionUID = 1L; + + private static final int MOVE_TO_CLASS = 0; + private static final int MOVE_FROM_CLASS = 1; + private static final int ADD_CLASS = 2; + private static final int REMOVE_CLASS = 3; + private static final int ADD_PROPERTY = 4; + private static final int REMOVE_RANGE_PROPERTY = 5; + private static final int DELETE_PROPERTY = 6; + private static final int REMOVE_NOT_RANGE_PROPERTY = 7; + + private final Description desc; + private Individual ind; + private ORE ore; + private JPopupMenu menu; + private String mode; + private String descriptionLabel; + + private String baseURI; + private Map<String, String> prefixes; + + /** + * constructor. + * + * @param d + * @param mode + */ + public DescriptionLabel(Description d, String mode) { + super(); + this.desc = d; + this.mode = mode; + setForeground(Color.red); + addMouseListener(this); + + } + + /** + * initialize description label with solution. + */ + public void init(){ + baseURI = ore.getBaseURI(); + prefixes = ore.getPrefixes(); + + setText(((Description) desc).toManchesterSyntaxString(ore.getBaseURI(), ore.getPrefixes())); + menu = new JPopupMenu(); + ToolTipManager.sharedInstance().setDismissDelay(7000); + //negative example solutions + if(mode.equals("neg")){ + if(!(desc instanceof Negation)){ + if(desc instanceof NamedClass){ //1. description is a named class + descriptionLabel = desc.toManchesterSyntaxString(baseURI, prefixes); + menu.add(new DescriptionMenuItem(REMOVE_CLASS, descriptionLabel, desc)); //1.a remove class assertion + + JMenu dme = new JMenu("move class assertion " + descriptionLabel + " to ..."); //1.b move individual + for(NamedClass nc : ore.getpossibleClassesMoveTo(ind)){ + DescriptionMenuItem move = new DescriptionMenuItem(MOVE_TO_CLASS, nc.toManchesterSyntaxString(baseURI, prefixes), (NamedClass) desc); + move.setName(nc.toString()); + dme.add(move); + Set<NamedClass> complements = ore.getComplements(nc, ind); //check for complement error + if(!(complements.isEmpty() || (complements.size() == 1 && complements.toArray()[0].toString().equals(desc.toString())))){ + move.setEnabled(false); + StringBuffer strBuf = new StringBuffer(); + strBuf.append("<html>class assertion not possible because individual<br> " + + "is still asserted to its complements:<br><BLOCKQUOTE>"); + + for(NamedClass n: complements){ + strBuf.append("<br><b>" + n + "</b>"); + } + strBuf.append("</BLOCKQUOTE></html>"); + + + move.setToolTipText(strBuf.toString()); + } + } + menu.add(dme); + } else if(desc instanceof ObjectSomeRestriction){ //2. description is a object some restriction + String propertyName = ((ObjectSomeRestriction) desc).getRole().toString(baseURI, prefixes); + String propertyRange = ((ObjectSomeRestriction) desc).getChild(0).toManchesterSyntaxString(baseURI, prefixes); + menu.add(new DescriptionMenuItem(DELETE_PROPERTY, propertyName , desc)); //2.a remove all property assertions + if (!(desc.getChild(0) instanceof Thing)){ + menu.add(new DescriptionMenuItem(REMOVE_RANGE_PROPERTY, propertyRange, desc)); //2.b remove property assertions with objects in range + } + } else if(desc instanceof ObjectAllRestriction){ //3. description is a object all restriction + if (!(desc.getChild(0) instanceof Thing)) { + JMenu dme = new JMenu("add property assertion " + ((ObjectAllRestriction) desc).getRole().toKBSyntaxString(baseURI, prefixes) //3.a add property assertion with object not in range + + " with object ..."); + for (Individual i : ore.getIndividualsNotInPropertyRange((ObjectAllRestriction) desc, ind)){ + dme.add(new DescriptionMenuItem(ADD_PROPERTY, i.toManchesterSyntaxString(baseURI, prefixes), desc)); + } + menu.add(dme); + } + } + + } else if(desc instanceof Negation){ + if(desc.getChild(0) instanceof NamedClass){ //4. description is a negated named class + DescriptionMenuItem addItem = new DescriptionMenuItem(ADD_CLASS, desc.getChild(0).toManchesterSyntaxString(baseURI, prefixes), desc.getChild(0)); + menu.add(addItem); //4.a add class assertion + Set<NamedClass> complements = ore.getComplements(desc.getChild(0), ind); //check for complement errors + if(!complements.isEmpty()){ + addItem.setEnabled(false); + StringBuffer strBuf = new StringBuffer(); + strBuf.append("<html>class assertion not possible because individual<br> " + + "is still asserted to its complements:<br><BLOCKQUOTE>"); + + for(NamedClass n: complements){ + strBuf.append("<br><b>" + n + "</b>"); + } + strBuf.append("</BLOCKQUOTE></html>"); + + + addItem.setToolTipText(strBuf.toString()); + } + } + } + } else if(mode.equals("pos")){//positive example solutions + if(!(desc instanceof Negation)){ + if(desc instanceof NamedClass){ + DescriptionMenuItem add = new DescriptionMenuItem(ADD_CLASS, desc.toManchesterSyntaxString(baseURI, prefixes), desc); + Set<NamedClass> complements = ore.getComplements(desc, ind); + if(!(complements.isEmpty())){ + add.setEnabled(false); + StringBuffer strBuf = new StringBuffer(); + strBuf.append("<html>class assertion not possible because individual<br> " + + "is still asserted to its complements:<br><BLOCKQUOTE>"); + + for(NamedClass n: complements){ + strBuf.append("<br><b>" + n + "</b>"); + } + strBuf.append("</BLOCKQUOTE></html>"); + + + add.setToolTipText(strBuf.toString()); + } + menu.add(add); + + Set<NamedClass> moveClasses = ore.getpossibleClassesMoveFrom(ind); + if(moveClasses.size() > 0){ + JMenu move = new JMenu("move to " + desc.toManchesterSyntaxString(baseURI, prefixes) + " from ..."); + for (NamedClass m : moveClasses){System.out.println("hier" + m); + DescriptionMenuItem item = new DescriptionMenuItem(MOVE_FROM_CLASS, m.toManchesterSyntaxString(baseURI, prefixes), desc); + item.setName(m.toString()); + move.add(item); + + if(!(complements.isEmpty() || (complements.size() == 1 && complements.toArray()[0].toString().equals(m.toString())))){ + move.setEnabled(false); + StringBuffer strBuf = new StringBuffer(); + strBuf.append("<html>moving class is not possible because individual<br> " + + "is still asserted to its complements:<br><BLOCKQUOTE>"); + + for(NamedClass n: complements){ + strBuf.append("<br><b>" + n + "</b>"); + } + strBuf.append("</BLOCKQUOTE></html>"); + + + move.setToolTipText(strBuf.toString()); + } + } + menu.add(move); + + } + + + } else if(desc instanceof ObjectSomeRestriction){ + JMenu dme = new JMenu("add property assertion " + ((ObjectSomeRestriction) desc).getRole() + + " with object ..."); + for (Individual i : ore.getIndividualsInPropertyRange((ObjectSomeRestriction) desc, ind)){ + dme.add(new DescriptionMenuItem(ADD_PROPERTY, i.toManchesterSyntaxString(baseURI, prefixes), desc)); + } + menu.add(dme); + + } else if(desc instanceof ObjectAllRestriction){ + if (!(desc.getChild(0) instanceof Thing)) { + menu.add(new DescriptionMenuItem(REMOVE_NOT_RANGE_PROPERTY, ((ObjectAllRestriction) desc).getChild(0).toString(baseURI, prefixes), desc)); + menu.add(new DescriptionMenuItem(DELETE_PROPERTY, ((ObjectAllRestriction) desc).getRole().toString(baseURI, prefixes), desc)); + } + } + + + } + + } else if(desc instanceof Negation){ + if(desc.getChild(0) instanceof NamedClass){ + descriptionLabel = desc.toManchesterSyntaxString(baseURI, prefixes); + menu.add(new DescriptionMenuItem(REMOVE_CLASS, descriptionLabel, desc)); + } + } + } + + + /** + * returns actual description. + * @return desc Description + */ + public Description getDescription(){ + return desc; + } + + /** + * adds action listeners to menu items. + * @param aL ActionListener + */ + public void addActionListeners(ActionListener aL){ + for(Component c : menu.getComponents()){ + if(c instanceof DescriptionMenuItem){ + ((DescriptionMenuItem) c).addActionListener(aL); + } else if(c instanceof JMenu){ + for(int i = 0; i < ((JMenu) c).getItemCount(); i++){ + ((JMenu) c).getItem(i).addActionListener(aL); + } + } + + + } + + + } + + public void setIndOre(ORE ore, Individual ind) { + this.ore = ore; + this.ind = ind; + } + + public void mouseClicked(MouseEvent e) { + menu.show(this.getParent(), getLocation().x, getLocation().y + 50); + + } + + /** + * Underlining label when mouse over. + */ + public void mouseEntered(MouseEvent e) { + setText("<html><u>" + + ((Description) desc).toManchesterSyntaxString(ore + .getBaseURI(), ore.getPrefixes()) + "</u></html>"); + setCursor(new Cursor(Cursor.HAND_CURSOR)); + if(desc instanceof ObjectCardinalityRestriction){ + setToolTipText("ObjectCardinality repair not available at present"); + } + + } + + /** + * Removing underlining when mosue relased. + */ + public void mouseExited(MouseEvent e) { + setText(((Description) desc).toManchesterSyntaxString(ore.getBaseURI(), + ore.getPrefixes())); + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/DescriptionMenuItem.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/DescriptionMenuItem.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/DescriptionMenuItem.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2007-2008, 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.ore.ui; + +import javax.swing.JMenuItem; + +import org.dllearner.core.owl.Description; + +/** + * Item for possible repair action. + * @author Lorenz Buehmann + * + */ +public class DescriptionMenuItem extends JMenuItem { + + /** + * + */ + private static final long serialVersionUID = 6784086889435854440L; + + private Description desc; + private int action; + + public DescriptionMenuItem(int action, String text, Description d){ + super(); + if(action == 3){ + setText("remove class assertion to " + text); + } else if(action == 0){ + setText(text); + } else if(action == 2){ + setText("add class assertion to " + text); + } else if(action == 4){ + setText(text); + } else if(action == 6){ + setText("delete complete property " + text); + }else if(action == 5){ + setText("remove all property assertions to " + text); + } else if(action == 7){ + setText("remove all property assertions with range not in " + text); + } else if(action == 1){ + setText(text); + } + + this.desc = d; + this.action = action; + } + + /** + * Returns the description part where item is asserted to. + * @return description + */ + public Description getDescription(){ + return desc; + } + + /** + * Returns action type represented as number.. + * @return number + */ + public int getActionID(){ + return action; + } + + + +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTable.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/ExplanationTable.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTable.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTable.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,215 @@ +package org.dllearner.tools.ore.ui; + +import java.awt.Color; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.AbstractCellEditor; +import javax.swing.JButton; +import javax.swing.JTable; +import javax.swing.UIManager; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +import org.dllearner.tools.ore.ExplanationManager; +import org.dllearner.tools.ore.ImpactManager; +import org.dllearner.tools.ore.RepairManager; +import org.dllearner.tools.ore.RepairManagerListener; +import org.jdesktop.swingx.JXTable; +import org.semanticweb.owl.model.OWLAxiom; +import org.semanticweb.owl.model.OWLClass; + +public class ExplanationTable extends JXTable implements RepairManagerListener{ + + /** + * + */ + private static final long serialVersionUID = 5580730282611559609L; + + private List<OWLAxiom> explanation; + private RepairManager repMan; + private ImpactManager impMan; + + public ExplanationTable(List<OWLAxiom> explanation, RepairManager repMan,ImpactManager impMan, ExplanationManager expMan, OWLClass cl) { + this.explanation = explanation; + this.repMan = repMan; + this.impMan = impMan; + repMan.addListener(this); + setBackground(Color.WHITE); + setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + setModel(new ExplanationTableModel(explanation, expMan,impMan, repMan, cl)); + getColumn(0).setCellRenderer(new OWLSyntaxTableCellRenderer(repMan)); + TableColumn column4 = getColumn(3); + column4.setCellRenderer(new ButtonCellRenderer()); + column4.setCellEditor(new ButtonCellEditor()); + column4.setResizable(false); + setColumnSizes(); + getSelectionModel().addListSelectionListener(new ListSelectionListener(){ + + + final ExplanationTable table; + + @Override + public void valueChanged(ListSelectionEvent e) { + + table.changeSelection(); + + } + { + table = ExplanationTable.this; + + } + + }); + + addFocusListener(new FocusListener() { + + final ExplanationTable table; + + public void focusGained(FocusEvent focusevent) + { + } + + public void focusLost(FocusEvent e) + { + table.clearSelection(); + table.changeSelection(); + + } + + + + + { + + table = ExplanationTable.this; + + } + }); + + addMouseListener(new MouseAdapter() { + + final ExplanationTable table; + { + table = ExplanationTable.this; + } + public void mouseClicked(MouseEvent e){ + if(e.getClickCount() == 2){ + System.out.println(getValueAt(table.rowAtPoint(e.getPoint()), 0)); + } + } + }); + } + + private OWLAxiom getOWLAxiomAtRow(int rowIndex){ + return ((ExplanationTableModel)getModel()).getOWLAxiomAtRow(rowIndex); + } + + private void setColumnSizes(){ + getColumn(1).setMaxWidth(30); + getColumn(2).setMaxWidth(30); + getColumn(3).setMaxWidth(80); + } + + private void changeSelection() { + +// +// if(getSelectedRow() >=0){ +// OWLAxiom rowAxiom = getOWLAxiomAtRow(getSelectedRow()); +// impMan.setActualAxiom(rowAxiom); +// } else { +// impMan.setActualAxiom(null); +// } + + } + + class ButtonCellRenderer extends JButton implements TableCellRenderer{ + + /** + * + */ + private static final long serialVersionUID = 1962950956976967243L; + + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + if (isSelected) { + setForeground(table.getSelectionForeground()); + setBackground(table.getSelectionBackground()); + } else { + setForeground(table.getForeground()); + setBackground(UIManager.getColor("Button.background")); + } + setText( (value ==null) ? "" : value.toString() ); + return this; + } + + + } + + class ButtonCellEditor extends AbstractCellEditor implements + TableCellEditor, ActionListener { + /** + * + */ + private static final long serialVersionUID = 9017452102605141646L; + JTable table; + JButton editButton; + String text; + + + public ButtonCellEditor() { + super(); + + editButton = new JButton(); + editButton.setFocusPainted(false); + editButton.addActionListener(this); + } + + + @Override + public Component getTableCellEditorComponent(JTable table, + Object value, boolean isSelected, int row, int column) { + text = (value == null) ? "" : value.toString(); + editButton.setText(text); + return editButton; + } + + @Override + public Object getCellEditorValue() { + return text; + } + + @Override + public void actionPerformed(ActionEvent e) { + fireEditingStopped(); + } + } + + + @Override + public void repairPlanExecuted() { + // TODO Auto-generated method stub + + } + + @Override + public void repairPlanChanged() { + repaint(); + + } + + + + +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTableModel.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/ExplanationTableModel.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTableModel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTableModel.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,106 @@ +package org.dllearner.tools.ore.ui; + +import java.util.ArrayList; +import java.util.List; + +import javax.swing.table.AbstractTableModel; + +import org.dllearner.tools.ore.ExplanationManager; +import org.dllearner.tools.ore.ImpactManager; +import org.dllearner.tools.ore.RepairManager; +import org.semanticweb.owl.model.OWLAxiom; +import org.semanticweb.owl.model.OWLClass; + +public class ExplanationTableModel extends AbstractTableModel { + + + /** + * + */ + private static final long serialVersionUID = -4537633628250304813L; + private List<OWLAxiom> axioms; + private List<Boolean> remove; + private ExplanationManager expMan; + private ImpactManager impMan; + private RepairManager repMan; + private OWLClass unsat; + + public ExplanationTableModel(List<OWLAxiom> axioms, ExplanationManager expMan, ImpactManager impMan, RepairManager repMan, OWLClass cl){ + this.axioms = axioms; + this.expMan = expMan; + this.impMan = impMan; + this.repMan = repMan; + this.unsat = cl; + remove = new ArrayList<Boolean>(); + for(int i = 0; i < axioms.size(); i++){ + remove.add(false); + } + } + + @Override + public int getColumnCount() { + return 4; + } + + @Override + public int getRowCount() { + return axioms.size(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if(columnIndex == 0 && rowIndex >=0){ + return axioms.get(rowIndex); + } else if(columnIndex == 1){ + return expMan.getArity(unsat, axioms.get(rowIndex)); + } else if(columnIndex == 2) { + return Boolean.valueOf(impMan.isSelected(getOWLAxiomAtRow(rowIndex))); + } else { + return "rewrite"; + } + + } + + + @Override + public void setValueAt(Object value, int rowIndex, int columnIndex) { + if(columnIndex == 2){ + OWLAxiom ax = getOWLAxiomAtRow(rowIndex); + if(impMan.isSelected(ax)){ + repMan.removeAxiom2Remove(ax); + impMan.removeAxiomFromImpactList(ax); + } else { + impMan.addAxiom2ImpactList(ax); + repMan.addAxiom2Remove(ax); + } + } + super.setValueAt(value, rowIndex, columnIndex); + } + + @Override + public Class<? extends Object> getColumnClass(int columnIndex){ + if(columnIndex == 0) { + return OWLAxiom.class; + } else if(columnIndex == 1){ + return int.class; + } else if(columnIndex == 2) { + return Boolean.class; + } else { + return String.class; + } + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + if(columnIndex == 2 || columnIndex == 3) + return true; + return false; + } + + public OWLAxiom getOWLAxiomAtRow(int rowIndex){ + return axioms.get(rowIndex); + } + + + +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTable.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/ImpactTable.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTable.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTable.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,28 @@ +package org.dllearner.tools.ore.ui; + +import java.awt.Color; + +import org.dllearner.tools.ore.ImpactManager; +import org.jdesktop.swingx.JXTable; + +public class ImpactTable extends JXTable { + + /** + * + */ + private static final long serialVersionUID = 4146762679753151490L; + + public ImpactTable(ImpactManager manager){ + super(new ImpactTableModel(manager)); + + setShowHorizontalLines(true); + setGridColor(Color.LIGHT_GRAY); + setTableHeader(null); + getColumnModel().getColumn(0).setCellRenderer(new OWLSyntaxTableCellRenderer()); + setRowHeight(getRowHeight() + 4); + + } + + + +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTableModel.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/ImpactTableModel.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTableModel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTableModel.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,71 @@ +package org.dllearner.tools.ore.ui; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.table.AbstractTableModel; + +import org.dllearner.tools.ore.ImpactManager; +import org.dllearner.tools.ore.ImpactManagerListener; +import org.semanticweb.owl.model.OWLAxiom; + +public class ImpactTableModel extends AbstractTableModel implements ImpactManagerListener +{ + + /** + * + */ + private static final long serialVersionUID = 6109818990550020196L; + private ImpactManager impMan; + private List<OWLAxiom> impact; + + public ImpactTableModel(ImpactManager impMan) + { + + impact = new ArrayList<OWLAxiom>(); + this.impMan = impMan; + impMan.addListener(this); + rebuildData(); + } + + private void rebuildData() + { + impact.clear(); + impact.addAll(impMan.getImpactForAxioms2Remove()); + Collections.sort(impact); + fireTableDataChanged(); + } + + + + public int getRowCount() + { + return impact.size(); + } + + public int getColumnCount() + { + return 1; + } + + public Object getValueAt(int rowIndex, int columnIndex) + { + return impact.get(rowIndex); + } + + + @Override + public void axiomForImpactChanged() { + rebuildData(); + + } + + @Override + public void repairPlanExecuted() { + rebuildData(); + + } + + +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/OWLSyntaxTableCellRenderer.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/OWLSyntaxTableCellRenderer.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/OWLSyntaxTableCellRenderer.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/OWLSyntaxTableCellRenderer.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,131 @@ +package org.dllearner.tools.ore.ui; + +import java.io.StringWriter; +import java.util.StringTokenizer; + +import javax.swing.table.DefaultTableCellRenderer; + +import org.dllearner.tools.ore.RepairManager; +import org.semanticweb.owl.model.OWLAxiom; + +import com.clarkparsia.explanation.io.manchester.Keyword; +import com.clarkparsia.explanation.io.manchester.ManchesterSyntaxObjectRenderer; +import com.clarkparsia.explanation.io.manchester.TextBlockWriter; + +public class OWLSyntaxTableCellRenderer extends DefaultTableCellRenderer { + + /** + * + */ + private static final long serialVersionUID = 6528440084244154347L; + + + private StringWriter buffer; + private TextBlockWriter writer; + private ManchesterSyntaxObjectRenderer renderer; + private RepairManager repMan; +// private List<String> oldAxioms; + + public OWLSyntaxTableCellRenderer(RepairManager repMan){ + super(); + this.repMan = repMan; + buffer = new StringWriter(); + writer = new TextBlockWriter(buffer); + renderer = new ManchesterSyntaxObjectRenderer(writer); + renderer.setWrapLines( false ); + renderer.setSmartIndent( true ); +// oldAxioms = new ArrayList<String>(); + + } + + public OWLSyntaxTableCellRenderer(){ + super(); + buffer = new StringWriter(); + writer = new TextBlockWriter(buffer); + renderer = new ManchesterSyntaxObjectRenderer(writer); + renderer.setWrapLines( false ); + renderer.setSmartIndent( true ); + } + + @Override + protected void setValue(Object value) { + + if(value instanceof OWLAxiom){ + boolean striked = false; + if(repMan != null && repMan.isSelected((OWLAxiom)value)){ + striked = true; + } + ((OWLAxiom)value).accept(renderer); + + writer.flush(); + String newAxiom = buffer.toString(); +// System.out.println("new axiom " + newAxiom); +// if(!oldAxioms.isEmpty()){ +// StringTokenizer st = new StringTokenizer(newAxiom); +// int index; +// String token = st.nextToken(); +// for(String s : oldAxioms){System.out.println("old axiom " + s); +// +// +// if(s.contains(token)){ +// index = s.indexOf(token); +// if(index>0){ +// StringBuffer bf = new StringBuffer(); +// for(int i = 0;i<=index+10;i++){ +// bf.append(" "); +// } +// bf.append(newAxiom); +// newAxiom = bf.toString(); +// break; +// } +// } +// +// } +// } + StringTokenizer st = new StringTokenizer(newAxiom); + + StringBuffer bf = new StringBuffer(); + bf.append("<html>"); + if(striked){ + bf.append("<strike>"); + } + + String token; + while(st.hasMoreTokens()){ + token = st.nextToken(); + String color = "black"; + boolean isReserved = false; + for(Keyword key : Keyword.values()){ + if(token.equals(key.getLabel())){ + color = key.getColor(); + isReserved = true;break; + } + } + if(isReserved){ + bf.append("<font color=" + color + ">" + token + " </font>"); + } else { + bf.append(" " + token + " "); + } + } + if(striked){ + bf.append("</strike>"); + } + bf.append("</html>"); + newAxiom = bf.toString(); + + setText(newAxiom); +// oldAxioms.add(buffer.toString()); + buffer.getBuffer().delete(0, buffer.toString().length()); + } else { + super.setValue(value); + } + +// ManchesterOWLSyntaxOWLObjectRendererImpl renderer = new ManchesterOWLSyntaxOWLObjectRendererImpl(); + + +//// DLSyntaxObjectRenderer renderer = new DLSyntaxObjectRenderer(); +// setText(renderer.render((OWLAxiom) value)); + + + } +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairDialog.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/RepairDialog.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairDialog.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairDialog.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,388 @@ +/** + * Copyright (C) 2007-2008, 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.ore.ui; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSeparator; +import javax.swing.border.EmptyBorder; + +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectQuantorRestriction; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.tools.ore.ORE; +import org.dllearner.tools.ore.OntologyModifier; +import org.dllearner.tools.ore.ui.wizard.panels.ChangePanel; +import org.dllearner.tools.ore.ui.wizard.panels.ChangesPanel; +import org.dllearner.tools.ore.ui.wizard.panels.DescriptionPanel; +import org.dllearner.tools.ore.ui.wizard.panels.StatsPanel; +import org.semanticweb.owl.model.OWLOntologyChange; + +/** + * The repair dialog where the learned class description (including error parts), + * the statistics and the undo options are shown. + * @author Lorenz Buehmann + * + */ +public class RepairDialog extends JDialog implements ActionListener, MouseListener{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + + public static final int CANCEL_RETURN_CODE = 1; + public static final int OK_RETURN_CODE = 2; + public static final int VALID_RETURN_CODE = 3; + + private int returncode; + + private StatsPanel statsPanel; + private DescriptionPanel descPanel; + private JPanel okCancelPanel; + private JPanel actionStatsPanel; + + private ChangesPanel changesPanel; + private JScrollPane changesScroll; + + private JButton okButton; + private JButton cancelButton; + + private String mode; + + private OntologyModifier modifier; + private ORE ore; + private Individual ind; + private Description actualDesc; + private Description newDesc; + private Set<OWLOntologyChange> allChanges; + private String baseURI; + private Map<String, String> prefixes; + + + public RepairDialog(Individual ind, JDialog dialog, final ORE ore, String mode){ + super(dialog, true); + final Component dialogd = this.getParent(); + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent we) { + if(allChanges.size() > 0){ + if (JOptionPane.showConfirmDialog(dialogd, + "All changes will be lost!", "Warning!", + JOptionPane.YES_NO_OPTION) + == JOptionPane.YES_OPTION){ + + modifier.undoChanges(allChanges); + ore.updateReasoner(); + allChanges.clear(); + returncode = CANCEL_RETURN_CODE; + setVisible(false); + dispose(); + } + } else{ + returncode = CANCEL_RETURN_CODE; + setVisible(false); + dispose(); + } + + } + + }); + + + this.ind = ind; + this.ore = ore; + this.modifier = ore.getModifier(); + this.mode = mode; + allChanges = new HashSet<OWLOntologyChange>(); + + } + + /** + * Initializing and making dialog visible. + * @return integer value + */ + public int showDialog(){ + baseURI = ore.getBaseURI(); + prefixes = ore.getPrefixes(); + if(mode.equals("neg")){ + this.setTitle("Repair negative example"); + } else if(mode.equals("pos")){ + this.setTitle("Repair positive example"); + } + this.setSize(700, 700); + this.setLayout(new BorderLayout()); + + descPanel = new DescriptionPanel(ore, ind, this, mode); + JScrollPane descScroll = new JScrollPane(); + descScroll.setViewportView(descPanel); + + statsPanel = new StatsPanel(ore, ind); + statsPanel.init(); + JScrollPane statsScroll = new JScrollPane(); + statsScroll.setViewportView(statsPanel); + + + changesPanel = new ChangesPanel(); + changesScroll = new JScrollPane(); + changesScroll.setViewportView(changesPanel); + + actionStatsPanel = new JPanel(); + + GridBagLayout gbl = new GridBagLayout(); + gbl.rowWeights = new double[] {0.0, 0.1, 0.1}; + gbl.rowHeights = new int[] {64, 7, 7}; + gbl.columnWeights = new double[] {0.1}; + gbl.columnWidths = new int[] {7}; + actionStatsPanel.setLayout(gbl); + + + actionStatsPanel.add(descScroll, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); + actionStatsPanel.add(statsScroll, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 0, 5), 0, 0)); + actionStatsPanel.add(changesScroll, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 0, 5), 0, 0)); + + + JSeparator separator = new JSeparator(); + Box buttonBox = new Box(BoxLayout.X_AXIS); + + okCancelPanel = new JPanel(); + okCancelPanel.setLayout(new BorderLayout()); + okCancelPanel.add(separator, BorderLayout.NORTH); + okButton = new JButton("Ok"); + okButton.addActionListener(this); + cancelButton = new JButton("Cancel"); + cancelButton.addActionListener(this); + + + getContentPane().add(actionStatsPanel, java.awt.BorderLayout.CENTER); + + + buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); + buttonBox.add(okButton); + buttonBox.add(Box.createHorizontalStrut(10)); + buttonBox.add(cancelButton); + okCancelPanel.add(buttonBox, BorderLayout.EAST); + + getContentPane().add(okCancelPanel, BorderLayout.SOUTH); + + + this.setModal(true); + this.setVisible(true); + + return returncode; + + } + + /** + * Method controls action events triggered by clicking on red labels in class description at the top of the dialog. + */ + public void actionPerformed(ActionEvent e) { + + if(e.getSource() instanceof DescriptionMenuItem){ + DescriptionMenuItem item =(DescriptionMenuItem) e.getSource(); + actualDesc = item.getDescription(); + int action = item.getActionID(); + if(action == 4){ + Individual obj = new Individual(e.getActionCommand()); + + List<OWLOntologyChange> changes = modifier.addObjectProperty(ind, (ObjectQuantorRestriction) actualDesc, obj); + allChanges.addAll(changes); + + descPanel.updatePanel(); + + statsPanel.updatePanel(); + changesPanel.add(new ChangePanel("added property assertion " + ((ObjectQuantorRestriction) actualDesc).getRole().toKBSyntaxString(baseURI, prefixes) + + " to " + obj.toManchesterSyntaxString(baseURI, prefixes), changes, this)); + changesScroll.updateUI(); + } else if(action == 5){ + ObjectQuantorRestriction property = (ObjectQuantorRestriction) actualDesc; + List<OWLOntologyChange> changes = null; + for(Individual i : ore.getIndividualsInPropertyRange(property, ind)){ + changes = modifier.removeObjectPropertyAssertion(ind, property, i); + allChanges.addAll(changes); + } + + descPanel.updatePanel(); + statsPanel.updatePanel(); + changesPanel.add(new ChangePanel("removed property assertions " + + ((ObjectSomeRestriction) actualDesc).getRole().toKBSyntaxString(baseURI, prefixes) + + " to range " + ((ObjectSomeRestriction) actualDesc).getChild(0).toManchesterSyntaxString(baseURI, prefixes), changes, this)); + changesScroll.updateUI(); + } else if(action == 6){ + List<OWLOntologyChange> changes = modifier.deleteObjectProperty(ind, (ObjectQuantorRestriction) actualDesc); + allChanges.addAll(changes); + descPanel.updatePanel(); + statsPanel.updatePanel(); + changesPanel.add(new ChangePanel("deleted property " + ((ObjectQuantorRestriction) actualDesc).getRole().toKBSyntaxString(baseURI, prefixes), changes, this)); + changesScroll.updateUI(); + } else if(action == 0){ + newDesc = new NamedClass(item.getName()); + List<OWLOntologyChange> changes = modifier.moveIndividual(ind, actualDesc, newDesc); + allChanges.addAll(changes); + descPanel.updatePanel(); + statsPanel.updatePanel(); + changesPanel.add(new ChangePanel("moved class assertion from " + actualDesc.toManchesterSyntaxString(baseURI, prefixes) + + " to " + newDesc.toManchesterSyntaxString(baseURI, prefixes), changes, this)); + changesScroll.updateUI(); + } else if(action == 3){ + List<OWLOntologyChange> changes = modifier.removeClassAssertion(ind, actualDesc); + allChanges.addAll(changes); + descPanel.updatePanel(); + statsPanel.updatePanel(); + changesPanel.add(new ChangePanel("removed class assertion to " + actualDesc.toManchesterSyntaxString(baseURI, prefixes), changes, this)); + changesScroll.updateUI(); + } else if(action == 2){ + List<OWLOntologyChange> changes = modifier.addClassAssertion(ind, actualDesc); + allChanges.addAll(changes); + descPanel.updatePanel(); + statsPanel.updatePanel(); + changesPanel.add(new ChangePanel("added class assertion to " + actualDesc.toManchesterSyntaxString(baseURI, prefixes), changes, this)); + changesScroll.updateUI(); + } else if(action == 7){ + ObjectQuantorRestriction property = (ObjectQuantorRestriction) actualDesc; + List<OWLOntologyChange> changes = null; + for(Individual i : ore.getIndividualsNotInPropertyRange(property, ind)){ + changes = modifier.removeObjectPropertyAssertion(ind, property, i); + allChanges.addAll(changes); + } + + + descPanel.updatePanel(); + statsPanel.updatePanel(); + changesPanel.add(new ChangePanel("removed property assertion " + property.getRole().toKBSyntaxString(baseURI, prefixes) + + " to " + ind.toManchesterSyntaxString(baseURI, prefixes), changes, this)); + changesScroll.updateUI(); + } else if(action == 1){ + Description oldDesc = new NamedClass(item.getName()); + List<OWLOntologyChange> changes = modifier.moveIndividual(ind, oldDesc, actualDesc); + allChanges.addAll(changes); + descPanel.updatePanel(); + statsPanel.updatePanel(); + changesPanel.add(new ChangePanel("moved class assertion from " + oldDesc.toManchesterSyntaxString(baseURI, prefixes) + + " to " + actualDesc.toManchesterSyntaxString(baseURI, prefixes), changes, this)); + changesScroll.updateUI(); + } + } else if(e.getActionCommand().equals("Ok")){ + if(descPanel.isCorrect()){ + returncode = VALID_RETURN_CODE; + } else{ + returncode = OK_RETURN_CODE; + } + ore.updateReasoner(); + setVisible(false); + dispose(); + } else if(e.getActionCommand().equals("Cancel")){ + if(allChanges.size() > 0){ + if (JOptionPane.showConfirmDialog(this, + "All changes will be lost!", "Warning!", + JOptionPane.YES_NO_OPTION) + == JOptionPane.YES_OPTION){ + + modifier.undoChanges(allChanges); + ore.updateReasoner(); + allChanges.clear(); + returncode = CANCEL_RETURN_CODE; + setVisible(false); + dispose(); + } + } else{ + returncode = CANCEL_RETURN_CODE; + setVisible(false); + dispose(); + } + + } + + + } + + + public void mouseClicked(MouseEvent e) { + if(e.getSource() instanceof UndoLabel){ + List<OWLOntologyChange> changes = ((UndoLabel) e.getSource()).getChanges(); + modifier.undoChanges(changes); + allChanges.removeAll(changes); + descPanel.updatePanel(); + statsPanel.updatePanel(); + changesPanel.updatePanel(((UndoLabel) e.getSource()).getParent()); + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + } + } + + public void mouseEntered(MouseEvent e) { + if(e.getSource() instanceof UndoLabel){ + ((UndoLabel) e.getSource()).setText("<html><u>Undo</u></html>"); + setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + } + + public void mouseExited(MouseEvent e) { + if(e.getSource() instanceof UndoLabel){ + ((UndoLabel) e.getSource()).setText("Undo"); + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + + } + + public void mousePressed(MouseEvent e) { + + } + + public void mouseReleased(MouseEvent e) { + + } + + public Set<OWLOntologyChange> getAllChanges() { + return allChanges; + } + + + + +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTable.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/RepairTable.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTable.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTable.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,25 @@ +package org.dllearner.tools.ore.ui; + +import java.awt.Color; + +import org.dllearner.tools.ore.RepairManager; +import org.jdesktop.swingx.JXTable; + +public class RepairTable extends JXTable { + + /** + * + */ + private static final long serialVersionUID = -621497634521668635L; + + public RepairTable(RepairManager manager){ + super(new RepairTableModel(manager)); + + setShowHorizontalLines(true); + setGridColor(Color.LIGHT_GRAY); + setTableHeader(null); + getColumnModel().getColumn(0).setCellRenderer(new OWLSyntaxTableCellRenderer()); + setRowHeight(getRowHeight() + 4); + + } +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTableModel.java (from rev 1816, trunk/src/dl-learner/org/dllearner/tools/ore/RepairTableModel.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTableModel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTableModel.java 2009-08-04 20:02:34 UTC (rev 1817) @@ -0,0 +1,69 @@ +package org.dllearner.tools.ore.ui; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.table.AbstractTableModel; + +import org.dllearner.tools.ore.RepairManager; +import org.dllearner.tools.ore.RepairManagerListener; +import org.semanticweb.owl.model.OWLAxiom; + +public class RepairTableModel extends AbstractTableModel implements RepairManagerListener{ + + /** + * + */ + private static final long serialVersionUID = -5898900692701380258L; + private RepairManager repMan; + private List<OWLAxiom> axioms2Remove; + + public RepairTableModel(RepairManager impMan) + { + + axioms2Remove = new ArrayList<OWLAxiom>(); + this.repMan = impMan; + repMan.addListener(this); + rebuildData(); + } + + private void rebuildData() + { + axioms2Remove.clear(); + axioms2Remove.addAll(repMan.getAxioms2Remove()); + Collections.sort(axioms2Remove); + fireTableDataChanged(); + } + + + + public int getRowCount() + { + ... [truncated message content] |