Commit cc77f34f authored by Romana Pernischova's avatar Romana Pernischova
Browse files

merging lastChange

parents c1677df6 6ea2e6e4
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<groupId>chimp</groupId> <groupId>chimp</groupId>
<artifactId>chimp.plugin</artifactId> <artifactId>chimp.plugin</artifactId>
<version>1.1.0</version> <version>1.2.0</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>Chimp Plugin</name> <name>Chimp Plugin</name>
......
...@@ -18,12 +18,10 @@ public class ChangeImpact extends Metric implements ImpactMetric { ...@@ -18,12 +18,10 @@ public class ChangeImpact extends Metric implements ImpactMetric {
public ChangeImpact(ChimpReasoner customReasoner) { public ChangeImpact(ChimpReasoner customReasoner) {
super("Change-based Impact", super("Change-based Impact",
"This measure signals the amount of changed axioms (added and removed) in the materialization" + "We divide the number of changed inferred axioms by the number of changed ontology axioms. " +
" with \\Delta_i^+ and \\Delta_i^- " + "This metrics gives an indication of how impactful each change is on the inferrence. " +
" in comparison to the number of changed axioms in the ontology, which are denoted with \\delta_i^+" + "A number close and above 1 signals that the number of changes to the ontology have an " +
" and \\delta_i^-." + "equivalent number of changes on the inferrence.",
" The changes to the materialization do not include the changes to the ontology, therefore," +
" \\Delta_i \backslash \\delta_i = {}",
"\\gamma = \\frac{|\\Delta_i^+| + |\\Delta_i^-|}{|\\delta_i^+| + |\\delta_i^-|}"); "\\gamma = \\frac{|\\Delta_i^+| + |\\Delta_i^-|}{|\\delta_i^+| + |\\delta_i^-|}");
this.customReasoner = customReasoner; this.customReasoner = customReasoner;
......
...@@ -16,14 +16,11 @@ public class SizeImpact extends Metric implements ImpactMetric { ...@@ -16,14 +16,11 @@ public class SizeImpact extends Metric implements ImpactMetric {
public SizeImpact(ChimpReasoner customReasoner) { public SizeImpact(ChimpReasoner customReasoner) {
super("Size-based Impact", super("Size-based Impact",
"This measure signals the amount of changed axioms (added and removed) in the materialization," + "We divide the number of changed inferred axioms by the unchanged inferred axioms. " +
" denoted with \\Delta_i^+ and \\Delta_i^-" + "The unchanged inferred axioms can therefore be seen as the size of the materialization. " +
"in comparison to the unchanged part of the materialization." + "This metric does not consider the size or changes on the ontology itself, but only to " +
"A materialization is denoted with M, therefore the intersection between the two versions " + "the inferrence. The number received can be interpreted as a percentage of how much the " +
"of the materialization with M_{i} \\cap M_{i+1}." + "materialization is changing.",
"This comparison occurs between the first materialization, when the reasoner was started " +
"and the last materialization when the reasoner was synchronized." +
"The materialization does not include the ontology itself.",
"\\sigma = \\frac{|\\Delta_i^+| + |\\Delta_i^-|}{|M_{i} \\cap M_{i+1}|}"); "\\sigma = \\frac{|\\Delta_i^+| + |\\Delta_i^-|}{|M_{i} \\cap M_{i+1}|}");
this.customReasoner = customReasoner; this.customReasoner = customReasoner;
} }
......
...@@ -52,7 +52,7 @@ public class ChimpPlugin extends AbstractOWLViewComponent implements ChimpLayout ...@@ -52,7 +52,7 @@ public class ChimpPlugin extends AbstractOWLViewComponent implements ChimpLayout
JSplitPane innerSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, JSplitPane innerSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
lastChangePanel, new ChimpScrollPane(lastChangePanel),
new ChimpScrollPane(impactMetricsPanel) new ChimpScrollPane(impactMetricsPanel)
); );
innerSplitPane.setDividerLocation(100); innerSplitPane.setDividerLocation(100);
......
...@@ -20,8 +20,8 @@ public class ImpactDisplayPanel extends JPanel implements ChimpLayout { ...@@ -20,8 +20,8 @@ public class ImpactDisplayPanel extends JPanel implements ChimpLayout {
private Metric chosenMetric; private Metric chosenMetric;
private final JComboBox<Object> dropdown = new JComboBox<>(); private final JComboBox<Object> dropdown = new JComboBox<>();
private final JLabel valueLabel = new JLabel(); private final JLabel valueLabel = new JLabel();
private final JLabel formulaLabel = new JLabel(); // private final JLabel formulaLabel = new JLabel();
private final JLabel descriptionLabel = new JLabel(); private final JTextArea descriptionLabel = new JTextArea();
public ImpactDisplayPanel() { public ImpactDisplayPanel() {
setLayout(new MigLayout("wrap 2, fill, insets 0", "[][fill]", "[fill]")); setLayout(new MigLayout("wrap 2, fill, insets 0", "[][fill]", "[fill]"));
...@@ -33,19 +33,36 @@ public class ImpactDisplayPanel extends JPanel implements ChimpLayout { ...@@ -33,19 +33,36 @@ public class ImpactDisplayPanel extends JPanel implements ChimpLayout {
chosenMetric = impactMetrics.get(0); chosenMetric = impactMetrics.get(0);
initDropdown(impactMetrics); initDropdown(impactMetrics);
JPanel innerPanel = new JPanel(new MigLayout("wrap, fill, insets 0", "", "15[]15[]15[][grow]")); // JPanel innerPanel = new JPanel(new MigLayout("wrap, fill, insets 0", "", "15[]15[]15[][grow]"));
innerPanel.add(dropdown, "wmin 210, alignx center"); // innerPanel.add(dropdown, "wmin 210, alignx center");
innerPanel.add(valueLabel, "alignx center"); // innerPanel.add(valueLabel, "alignx center");
innerPanel.add(formulaLabel, "alignx center"); //// innerPanel.add(formulaLabel, "alignx center");
innerPanel.setBackground(ChimpLayout.BACKGROUND_COLOR); // innerPanel.setBackground(ChimpLayout.BACKGROUND_COLOR);
//
add(innerPanel); // add(innerPanel);
descriptionLabel.setBorder(new EmptyBorder(15, 15, 0, 15)); // descriptionLabel.setBorder(new EmptyBorder(15, 15, 0, 15));
descriptionLabel.setVerticalAlignment(SwingConstants.TOP); // descriptionLabel.setVerticalAlignment(SwingConstants.TOP);
JPanel descriptionPanel = new JPanel(new MigLayout("fill, insets 0", "[fill, 100%]", "[fill]")); // JPanel descriptionPanel = new JPanel(new MigLayout("fill, insets 0", "[fill, 100%]", "[fill]"));
descriptionPanel.add(descriptionLabel, "aligny top"); // descriptionPanel.add(descriptionLabel, "aligny top");
descriptionPanel.setBackground(ChimpLayout.BACKGROUND_COLOR); // descriptionPanel.setBackground(ChimpLayout.BACKGROUND_COLOR);
add(descriptionPanel); // add(descriptionPanel);
JPanel panel = new JPanel(new MigLayout());
panel.add(dropdown,"wmin 200, alignx left");
panel.add(valueLabel, "wrap, wmin 100, alignx center");
panel.setBackground(ChimpLayout.BACKGROUND_COLOR);
descriptionLabel.setLineWrap(true);
descriptionLabel.setWrapStyleWord(true);
descriptionLabel.setEditable(false);
descriptionLabel.setBorder(null);
descriptionLabel.setPreferredSize(new Dimension(300,100));
descriptionLabel.setBackground(ChimpLayout.BACKGROUND_COLOR);
panel.add(descriptionLabel,"span, wmin 300");
add(panel);
} }
public void initDropdown(List<Metric> impactMetrics) { public void initDropdown(List<Metric> impactMetrics) {
...@@ -101,10 +118,10 @@ public class ImpactDisplayPanel extends JPanel implements ChimpLayout { ...@@ -101,10 +118,10 @@ public class ImpactDisplayPanel extends JPanel implements ChimpLayout {
valueLabel.setText("No changes yet"); valueLabel.setText("No changes yet");
} }
if (chosenMetric.getLatexFormula() != null) { // if (chosenMetric.getLatexFormula() != null) {
formulaLabel.setIcon(getLatexImage(chosenMetric.getLatexFormula())); // formulaLabel.setIcon(getLatexImage(chosenMetric.getLatexFormula()));
} // }
descriptionLabel.setText("<html>" + chosenMetric.getDescription() + "</html>"); descriptionLabel.setText(chosenMetric.getDescription()); //.setText("<html>" + chosenMetric.getDescription() + "</html>");
} }
private TeXIcon getLatexImage(String latexString) { private TeXIcon getLatexImage(String latexString) {
......
...@@ -7,7 +7,6 @@ import org.slf4j.Logger; ...@@ -7,7 +7,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import view.ChimpLayout; import view.ChimpLayout;
import viewcomponents.ChimpIcons; import viewcomponents.ChimpIcons;
import viewcomponents.ChimpScrollPane;
import viewcomponents.TitleLabel; import viewcomponents.TitleLabel;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
...@@ -18,17 +17,12 @@ import javax.swing.tree.DefaultTreeModel; ...@@ -18,17 +17,12 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.*; import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
public class LastChangePanel extends JPanel implements ChimpLayout { public class LastChangePanel extends JPanel implements ChimpLayout {
Logger log = LoggerFactory.getLogger(LastChangePanel.class); Logger log = LoggerFactory.getLogger(LastChangePanel.class);
// private PieChart changeGraph;
// private XChartPanel changeGraphPanel;
// private HashMap<String,Integer> changeMap;
private final OWLModelManager modelManager; private final OWLModelManager modelManager;
private final OWLOntologyChangeListener changeListener = changes -> { private final OWLOntologyChangeListener changeListener = changes -> {
boolean realChange = true; boolean realChange = true;
...@@ -38,11 +32,11 @@ public class LastChangePanel extends JPanel implements ChimpLayout { ...@@ -38,11 +32,11 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
} }
} }
if (realChange) { if (realChange) {
this.displayChanges(changes); this.displayChanges(changes);
} }
}; };
private static final String title = "Changes";
private final JLabel noChangesLabel = new JLabel("No changes yet"); private final JLabel noChangesLabel = new JLabel("No changes yet");
private JTree tree; private JTree tree;
...@@ -58,34 +52,18 @@ public class LastChangePanel extends JPanel implements ChimpLayout { ...@@ -58,34 +52,18 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
setLayout(new MigLayout("wrap 1")); setLayout(new MigLayout("wrap 1"));
setBackground(BACKGROUND_COLOR); setBackground(BACKGROUND_COLOR);
setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, PANEL_BORDER_COLOR)); setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, PANEL_BORDER_COLOR));
add(new TitleLabel(title));
add(noChangesLabel, "center"); add(noChangesLabel, "center");
// add(new TitleLabel(title));
// add(noChangesLabel, "center");
log.debug("LastChangePanel initialized"); log.debug("LastChangePanel initialized");
} }
// private void addPanels(){ private void displayChanges(@Nonnull List<? extends OWLOntologyChange> changes) {
//// changeGraph = new PieChartBuilder().width(100).height(10).build(); if (changes.size() > 0) {
//// changeGraph.setTitle("No changes yet."); DefaultMutableTreeNode root = constructTree(changes);
// displayTree(root);
//// changeGraphPanel = new XChartPanel<>(changeGraph); }
// }
// changeListView = new JPanel(new MigLayout("wrap 1"));
// changeListView.setLayout(new MigLayout("wrap 1"));
// changeListView.setBackground(BACKGROUND_COLOR);
// changeListView.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, PANEL_BORDER_COLOR));
// changeListView.add(new TitleLabel(title));
// changeListView.add(noChangesLabel, "center");
//// listViewPanel.setBackground(Color.WHITE);
//// listViewPanel.add(this);
//
// add(new ChimpScrollPane(changeListView));
//// addTab("Listview", new ChimpScrollPane(changeListView));
//// addTab("Chartview",new ChimpScrollPane(changeGraphPanel));
// }
private DefaultMutableTreeNode constructTree(List<? extends OWLOntologyChange> changes) { private DefaultMutableTreeNode constructTree(List<? extends OWLOntologyChange> changes) {
DefaultMutableTreeNode root = new DefaultMutableTreeNode(""); DefaultMutableTreeNode root = new DefaultMutableTreeNode("");
...@@ -111,94 +89,6 @@ public class LastChangePanel extends JPanel implements ChimpLayout { ...@@ -111,94 +89,6 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
return root; return root;
} }
private void displayChanges(@Nonnull List<? extends OWLOntologyChange> changes) {
if (changes.size() > 0) {
DefaultMutableTreeNode root = constructTree(changes);
// constructMap(changes);
displayTree(root);
// displayChart();
}
}
// private void constructMap(@Nonnull List<? extends OWLOntologyChange> changes) {
// if(changeMap==null){
// changeMap = new HashMap<>();
// }
// for (int i = 1; i < changes.size(); i++) {
// OWLOntologyChange change = changes.get(i);
// String key = "";
// if (change instanceof OWLAxiomChange) {
// key ="axiom";
// } else if (change instanceof AnnotationChange) {
// key ="annotation";
// } else {
// key = "other";
// }
//
// if(changeMap.containsKey(key)){
// int count = changeMap.get(key);
// count++;
// changeMap.put(key,count);
// }
// else {
// changeMap.put(key,1);
// }
// }
// }
// private void displayChart(){
// if(changeGraph==null){
// changeGraph = new PieChartBuilder().width(100).height(10).build();
// Color[] sliceColors = new Color[] { new Color(224, 68, 14), new Color(230, 105, 62), new Color(236, 143, 110), new Color(243, 180, 159), new Color(246, 199, 182) };
// changeGraph.getStyler().setSeriesColors(sliceColors);
// }
//
//
// changeGraph.updatePieSeries(changeMap.);
//
// chart.addSeries("Gold",24);
// chart.addSeries("Silver",47);
// chart.addSeries("Platinum",50);
// chartPanel = new XChartPanel<>(chart);
//
// }
private String getRootChangeString(OWLOntologyChange change) {
final String returnString;
if (change instanceof AddAxiom) {
returnString = "Added axiom: ";
} else if (change instanceof RemoveAxiom) {
returnString = "Removed axiom: ";
} else if (change instanceof AddImport) {
returnString = "Added import: ";
} else if (change instanceof RemoveImport) {
returnString = "Removed import: ";
} else if (change instanceof AddOntologyAnnotation) {
returnString = "Added annotation: ";
} else if (change instanceof RemoveOntologyAnnotation) {
returnString = "Removed annotation: ";
} else {
return "Unidentified change: " + change.getClass().getName();
}
return returnString + getChangeString(change);
}
private String getChangeString(OWLOntologyChange change) {
if (change instanceof OWLAxiomChange) {
return "&lt;" + change.getAxiom().toString() + "&gt;";
} else if (change instanceof AnnotationChange) {
return ((AnnotationChange) change).getAnnotation().toString();
} else {
return change.getClass().getName();
}
}
private void displayTree(DefaultMutableTreeNode root) { private void displayTree(DefaultMutableTreeNode root) {
if (tree == null) { if (tree == null) {
defaultTreeModel = new DefaultTreeModel(root); defaultTreeModel = new DefaultTreeModel(root);
...@@ -225,10 +115,8 @@ public class LastChangePanel extends JPanel implements ChimpLayout { ...@@ -225,10 +115,8 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
}); });
// the following line is needed to ensure that the multiline html has variable height // the following line is needed to ensure that the multiline html has variable height
tree.setRowHeight(0); tree.setRowHeight(0);
remove(noChangesLabel); remove(noChangesLabel);
add(tree, BorderLayout.CENTER); add(tree, BorderLayout.CENTER);
} else { } else {
defaultTreeModel.setRoot(root); defaultTreeModel.setRoot(root);
defaultTreeModel.reload(); defaultTreeModel.reload();
...@@ -238,9 +126,56 @@ public class LastChangePanel extends JPanel implements ChimpLayout { ...@@ -238,9 +126,56 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
} }
} }
private String getRootChangeString(OWLOntologyChange change) {
final String returnString;
if (change instanceof AddAxiom) {
returnString = "Added axiom: ";
} else if (change instanceof RemoveAxiom) {
returnString = "Removed axiom: ";
} else if (change instanceof AddImport) {
returnString = "Added import: ";
} else if (change instanceof RemoveImport) {
returnString = "Removed import: ";
} else if (change instanceof AddOntologyAnnotation) {
returnString = "Added annotation: ";
} else if (change instanceof RemoveOntologyAnnotation) {
returnString = "Removed annotation: ";
} else {
return "Unidentified change: " + change.getClass().getName();
}
return returnString + getChangeString(change);
}
private String getChangeString(OWLOntologyChange change) {
if (change instanceof OWLAxiomChange) {
String s = change.getAxiom().toString();
String iri = modelManager.getActiveOntology().getOntologyID().getOntologyIRI().get().toString();
// String name = s.replaceAll(iri,"");
// log.info(s);
// log.info(name);
String[] axiom = s.split("<");
String name = axiom[0];
for(int i=1; i<axiom.length;i++){
int index = axiom[i].indexOf("#");
String sub;
if(index>0){ sub = axiom[i].substring(index+1);
sub = "&lt;" + sub;}
else { sub = axiom[i]; }
name = name.concat(sub);
if(i != axiom.length-1){
name = name.concat(" ");}
}
return "&lt;" + name + "&gt;";
} else if (change instanceof AnnotationChange) {
return ((AnnotationChange) change).getAnnotation().toString();
} else {
return change.getClass().getName();
}
}
public void dispose() { public void dispose() {
this.modelManager.removeOntologyChangeListener(this.changeListener); this.modelManager.removeOntologyChangeListener(this.changeListener);
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment