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

merging lastChange

parents c1677df6 6ea2e6e4
......@@ -5,7 +5,7 @@
<groupId>chimp</groupId>
<artifactId>chimp.plugin</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<packaging>bundle</packaging>
<name>Chimp Plugin</name>
......
......@@ -18,12 +18,10 @@ public class ChangeImpact extends Metric implements ImpactMetric {
public ChangeImpact(ChimpReasoner customReasoner) {
super("Change-based Impact",
"This measure signals the amount of changed axioms (added and removed) in the materialization" +
" with \\Delta_i^+ and \\Delta_i^- " +
" in comparison to the number of changed axioms in the ontology, which are denoted with \\delta_i^+" +
" and \\delta_i^-." +
" The changes to the materialization do not include the changes to the ontology, therefore," +
" \\Delta_i \backslash \\delta_i = {}",
"We divide the number of changed inferred axioms by the number of changed ontology axioms. " +
"This metrics gives an indication of how impactful each change is on the inferrence. " +
"A number close and above 1 signals that the number of changes to the ontology have an " +
"equivalent number of changes on the inferrence.",
"\\gamma = \\frac{|\\Delta_i^+| + |\\Delta_i^-|}{|\\delta_i^+| + |\\delta_i^-|}");
this.customReasoner = customReasoner;
......
......@@ -16,14 +16,11 @@ public class SizeImpact extends Metric implements ImpactMetric {
public SizeImpact(ChimpReasoner customReasoner) {
super("Size-based Impact",
"This measure signals the amount of changed axioms (added and removed) in the materialization," +
" denoted with \\Delta_i^+ and \\Delta_i^-" +
"in comparison to the unchanged part of the materialization." +
"A materialization is denoted with M, therefore the intersection between the two versions " +
"of the materialization with M_{i} \\cap M_{i+1}." +
"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.",
"We divide the number of changed inferred axioms by the unchanged inferred axioms. " +
"The unchanged inferred axioms can therefore be seen as the size of the materialization. " +
"This metric does not consider the size or changes on the ontology itself, but only to " +
"the inferrence. The number received can be interpreted as a percentage of how much the " +
"materialization is changing.",
"\\sigma = \\frac{|\\Delta_i^+| + |\\Delta_i^-|}{|M_{i} \\cap M_{i+1}|}");
this.customReasoner = customReasoner;
}
......
......@@ -52,7 +52,7 @@ public class ChimpPlugin extends AbstractOWLViewComponent implements ChimpLayout
JSplitPane innerSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
lastChangePanel,
new ChimpScrollPane(lastChangePanel),
new ChimpScrollPane(impactMetricsPanel)
);
innerSplitPane.setDividerLocation(100);
......
......@@ -20,8 +20,8 @@ public class ImpactDisplayPanel extends JPanel implements ChimpLayout {
private Metric chosenMetric;
private final JComboBox<Object> dropdown = new JComboBox<>();
private final JLabel valueLabel = new JLabel();
private final JLabel formulaLabel = new JLabel();
private final JLabel descriptionLabel = new JLabel();
// private final JLabel formulaLabel = new JLabel();
private final JTextArea descriptionLabel = new JTextArea();
public ImpactDisplayPanel() {
setLayout(new MigLayout("wrap 2, fill, insets 0", "[][fill]", "[fill]"));
......@@ -33,19 +33,36 @@ public class ImpactDisplayPanel extends JPanel implements ChimpLayout {
chosenMetric = impactMetrics.get(0);
initDropdown(impactMetrics);
JPanel innerPanel = new JPanel(new MigLayout("wrap, fill, insets 0", "", "15[]15[]15[][grow]"));
innerPanel.add(dropdown, "wmin 210, alignx center");
innerPanel.add(valueLabel, "alignx center");
innerPanel.add(formulaLabel, "alignx center");
innerPanel.setBackground(ChimpLayout.BACKGROUND_COLOR);
add(innerPanel);
descriptionLabel.setBorder(new EmptyBorder(15, 15, 0, 15));
descriptionLabel.setVerticalAlignment(SwingConstants.TOP);
JPanel descriptionPanel = new JPanel(new MigLayout("fill, insets 0", "[fill, 100%]", "[fill]"));
descriptionPanel.add(descriptionLabel, "aligny top");
descriptionPanel.setBackground(ChimpLayout.BACKGROUND_COLOR);
add(descriptionPanel);
// JPanel innerPanel = new JPanel(new MigLayout("wrap, fill, insets 0", "", "15[]15[]15[][grow]"));
// innerPanel.add(dropdown, "wmin 210, alignx center");
// innerPanel.add(valueLabel, "alignx center");
//// innerPanel.add(formulaLabel, "alignx center");
// innerPanel.setBackground(ChimpLayout.BACKGROUND_COLOR);
//
// add(innerPanel);
// descriptionLabel.setBorder(new EmptyBorder(15, 15, 0, 15));
// descriptionLabel.setVerticalAlignment(SwingConstants.TOP);
// JPanel descriptionPanel = new JPanel(new MigLayout("fill, insets 0", "[fill, 100%]", "[fill]"));
// descriptionPanel.add(descriptionLabel, "aligny top");
// descriptionPanel.setBackground(ChimpLayout.BACKGROUND_COLOR);
// 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) {
......@@ -101,10 +118,10 @@ public class ImpactDisplayPanel extends JPanel implements ChimpLayout {
valueLabel.setText("No changes yet");
}
if (chosenMetric.getLatexFormula() != null) {
formulaLabel.setIcon(getLatexImage(chosenMetric.getLatexFormula()));
}
descriptionLabel.setText("<html>" + chosenMetric.getDescription() + "</html>");
// if (chosenMetric.getLatexFormula() != null) {
// formulaLabel.setIcon(getLatexImage(chosenMetric.getLatexFormula()));
// }
descriptionLabel.setText(chosenMetric.getDescription()); //.setText("<html>" + chosenMetric.getDescription() + "</html>");
}
private TeXIcon getLatexImage(String latexString) {
......
......@@ -7,7 +7,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import view.ChimpLayout;
import viewcomponents.ChimpIcons;
import viewcomponents.ChimpScrollPane;
import viewcomponents.TitleLabel;
import javax.annotation.Nonnull;
......@@ -18,17 +17,12 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class LastChangePanel extends JPanel implements ChimpLayout {
Logger log = LoggerFactory.getLogger(LastChangePanel.class);
// private PieChart changeGraph;
// private XChartPanel changeGraphPanel;
// private HashMap<String,Integer> changeMap;
private final OWLModelManager modelManager;
private final OWLOntologyChangeListener changeListener = changes -> {
boolean realChange = true;
......@@ -38,11 +32,11 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
}
}
if (realChange) {
this.displayChanges(changes);
}
};
private static final String title = "Changes";
private final JLabel noChangesLabel = new JLabel("No changes yet");
private JTree tree;
......@@ -58,34 +52,18 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
setLayout(new MigLayout("wrap 1"));
setBackground(BACKGROUND_COLOR);
setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, PANEL_BORDER_COLOR));
add(new TitleLabel(title));
add(noChangesLabel, "center");
// add(new TitleLabel(title));
// add(noChangesLabel, "center");
log.debug("LastChangePanel initialized");
}
// private void addPanels(){
//// changeGraph = new PieChartBuilder().width(100).height(10).build();
//// changeGraph.setTitle("No changes yet.");
//
//// 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 void displayChanges(@Nonnull List<? extends OWLOntologyChange> changes) {
if (changes.size() > 0) {
DefaultMutableTreeNode root = constructTree(changes);
displayTree(root);
}
}
private DefaultMutableTreeNode constructTree(List<? extends OWLOntologyChange> changes) {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("");
......@@ -111,94 +89,6 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
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) {
if (tree == null) {
defaultTreeModel = new DefaultTreeModel(root);
......@@ -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
tree.setRowHeight(0);
remove(noChangesLabel);
add(tree, BorderLayout.CENTER);
} else {
defaultTreeModel.setRoot(root);
defaultTreeModel.reload();
......@@ -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() {
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