Commit 10f18b8d authored by AnonymousAuthor2847's avatar AnonymousAuthor2847
Browse files

export functionality

parent 78563439
# Maven
chimp-plugin/target/
chimp-plugin/target/*
target/*
# IntelliJ
.idea
......
......@@ -85,4 +85,30 @@ public abstract class Metric {
return cumulative ? getChangePercentage(getFirstValue(), getValue()) : getChangePercentage(getPreviousValue(), getValue());
}
}
public static String getExportHeaderString(){
StringBuilder header = new StringBuilder();
header.append("Metric,");
header.append("FirstValue,");
header.append("NewValue,");
header.append("ChangeAbs,");
header.append("ChangePercentage");
return header.toString();
}
public String getExportString(){
StringBuilder export = new StringBuilder();
export.append(getDisplayName());
export.append(",");
export.append(getFirstValue());
export.append(",");
export.append(getValue());
export.append(",");
export.append(getChangeDifference(getFirstValue(),getValue()));
export.append(",");
export.append(getChangePercentage(getFirstValue(),getValue()));
return export.toString();
}
}
......@@ -27,6 +27,8 @@ public class ChimpReasoner {
private final Logger log = LoggerFactory.getLogger(ChimpReasoner.class);
private final OWLReasoner reasoner;
public String status;
private Set<OWLOntology> currentOntologies;
private Set<OWLAxiom> firstOntology;
......
......@@ -14,6 +14,12 @@ import viewcomponents.ChimpScrollPane;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class ChimpPlugin extends AbstractOWLViewComponent implements ChimpLayout {
......@@ -47,9 +53,118 @@ public class ChimpPlugin extends AbstractOWLViewComponent implements ChimpLayout
removeAll();
setLayout(new MigLayout("nogrid, flowy, fill, insets 0 0 0 5"));
lastChangePanel = new LastChangePanel(getOWLModelManager());
lastChangePanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(e.isPopupTrigger()){
handleChangePopupRequest(lastChangePanel,e);
}
}
@Override
public void mousePressed(MouseEvent e) {
if(e.isPopupTrigger()){
handleChangePopupRequest(lastChangePanel,e);
}
}
@Override
public void mouseReleased(MouseEvent e) {
if(e.isPopupTrigger()){
handleChangePopupRequest(lastChangePanel,e);
}
}
private void handleChangePopupRequest(LastChangePanel changesPanel, MouseEvent e){
JPopupMenu menu = new JPopupMenu();
menu.add(new AbstractAction("Copy changes to clipboard") {
@Override
public void actionPerformed(ActionEvent e) {
String msg = changesPanel.getExport();
Clipboard clb = Toolkit.getDefaultToolkit().getSystemClipboard();
clb.setContents(new StringSelection(msg),null);
}
});
menu.show(changesPanel,e.getX(),e.getY());
}
});
impactMetricsPanel = new ImpactMetricsPanel(getOWLWorkspace());
impactMetricsPanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(e.isPopupTrigger()){
handleRequest(impactMetricsPanel,e);
}
}
@Override
public void mousePressed(MouseEvent e) {
if(e.isPopupTrigger()){
handleRequest(impactMetricsPanel,e);
}
}
@Override
public void mouseReleased(MouseEvent e) {
if(e.isPopupTrigger()){
handleRequest(impactMetricsPanel,e);
}
}
private void handleRequest(ImpactMetricsPanel impactPanel, MouseEvent e){
JPopupMenu menu = new JPopupMenu();
menu.add(new AbstractAction("Copy impact to clipboard") {
@Override
public void actionPerformed(ActionEvent e) {
String msg = impactPanel.getExport();
Clipboard clb = Toolkit.getDefaultToolkit().getSystemClipboard();
clb.setContents(new StringSelection(msg),null);
}
});
menu.show(impactPanel,e.getX(),e.getY());
}
});
standardMetricsPanel = new StandardMetricsPanel(getOWLModelManager());
standardMetricsPanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(e.isPopupTrigger()){
handleRequest(standardMetricsPanel,e);
}
}
@Override
public void mousePressed(MouseEvent e) {
if(e.isPopupTrigger()){
handleRequest(standardMetricsPanel,e);
}
}
@Override
public void mouseReleased(MouseEvent e) {
if(e.isPopupTrigger()){
handleRequest(standardMetricsPanel,e);
}
}
private void handleRequest(StandardMetricsPanel metricsPanel, MouseEvent e){
JPopupMenu menu = new JPopupMenu();
menu.add(new AbstractAction("Copy metrics to clipboard") {
@Override
public void actionPerformed(ActionEvent e) {
String msg = metricsPanel.getExport();
Clipboard clb = Toolkit.getDefaultToolkit().getSystemClipboard();
clb.setContents(new StringSelection(msg),null);
}
});
menu.show(metricsPanel,e.getX(),e.getY());
}
});
JSplitPane innerSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
new ChimpScrollPane(lastChangePanel),
......
package view.impactmetrics;
import metrics.Metric;
import metrics.impact.*;
import net.miginfocom.swing.MigLayout;
import org.protege.editor.owl.model.OWLModelManager;
......@@ -17,6 +18,7 @@ import viewcomponents.TitleLabel;
import javax.swing.*;
import java.util.Arrays;
import java.util.List;
public class ImpactMetricsPanel extends JPanel implements ChimpLayout {
......@@ -27,6 +29,7 @@ public class ImpactMetricsPanel extends JPanel implements ChimpLayout {
private final OWLReasonerManager reasonerManager;
private final ImpactDisplayPanel displayPanel = new ImpactDisplayPanel();
private final JLabel reasonerStatusLabel = new JLabel();
private List<Metric> impactMetrics;
private ChimpReasoner reasoner;
private final OWLModelManagerListener owlModelManagerListener = event -> {
......@@ -61,8 +64,7 @@ public class ImpactMetricsPanel extends JPanel implements ChimpLayout {
ReasonerUtilities.warnUserIfReasonerIsNotConfigured(workspace, reasonerManager);
if (reasonerManager.getReasonerStatus() == ReasonerStatus.INITIALIZED) {
reasoner = new ChimpReasoner(reasonerManager.getCurrentReasoner(), modelManager.getActiveOntologies());
displayPanel.initPanel(Arrays.asList(
impactMetrics = Arrays.asList(
//new GraphDistanceImpact(reasoner)
//new AddedInferenceOldRatio(reasoner),
//new RemovedInferenceOldRatio(reasoner),
......@@ -75,14 +77,15 @@ public class ImpactMetricsPanel extends JPanel implements ChimpLayout {
//new HierarchyImpact(reasoner),
//new HierarchySizeImpact(reasoner),
//new GraphDistanceImpact(reasoner)
//new SizeSubclassImpact(reasoner),
new ChangeImpact(reasoner)
//new ChangeSubclassImpact(reasoner)
//new ChangeNoiseImpact(reasoner)
new SizeSubclassImpact(reasoner),
new ChangeImpact(reasoner),
new ChangeSubclassImpact(reasoner),
new ChangeNoiseImpact(reasoner)
//new ChangeImpact(reasoner,changes)
//new ChangeHierarchyImpact(reasoner,changes)
);
));
displayPanel.initPanel(impactMetrics);
} else {
log.warn("Not able to initialize Reasoner because it is not started yet.");
}
......@@ -102,6 +105,24 @@ public class ImpactMetricsPanel extends JPanel implements ChimpLayout {
}
}
public String getExport(){
ReasonerStatus reasonerStatus = reasonerManager.getReasonerStatus();
StringBuilder export = new StringBuilder();
export.append("Reasoner status: ");
export.append(reasonerStatus.toString());
if(reasonerStatus == ReasonerStatus.INITIALIZED && reasoner != null) {
export.append(" and ontology consistent\n\n");
export.append(Metric.getExportHeaderString());
export.append("\n");
for (Metric m : impactMetrics) {
export.append(m.getExportString());
export.append("\n");
}
}
return export.toString();
}
public void dispose() {
this.modelManager.removeListener(owlModelManagerListener);
}
......
......@@ -16,13 +16,13 @@ import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.util.ArrayList;
import java.util.*;
import java.util.List;
public class LastChangePanel extends JPanel implements ChimpLayout {
Logger log = LoggerFactory.getLogger(LastChangePanel.class);
public List<OWLOntologyChange> allChanges;
private final OWLModelManager modelManager;
private final OWLOntologyChangeListener changeListener = changes -> {
boolean realChange = true;
......@@ -33,6 +33,10 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
}
if (realChange) {
this.displayChanges(changes);
if(allChanges == null){
allChanges = new ArrayList<OWLOntologyChange>();
}
allChanges.addAll(changes);
}
};
......@@ -174,6 +178,17 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
}
}
public String getExport() {
StringBuilder export = new StringBuilder("List of changes (chronologically, first to last):\n");
Iterator iter = allChanges.iterator();
while(iter.hasNext()){
export.append(iter.next().toString());
export.append("\n");
}
return export.toString();
}
public void dispose() {
this.modelManager.removeOntologyChangeListener(this.changeListener);
}
......
......@@ -14,8 +14,14 @@ import viewcomponents.ChimpScrollPane;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class StandardMetricsPanel extends JTabbedPane implements ChimpLayout {
......@@ -73,6 +79,43 @@ public class StandardMetricsPanel extends JTabbedPane implements ChimpLayout {
listViewPanel.add(metricsTable, "growx");
listViewPanel.add(ratiosTable, "growx");
listViewPanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(e.isPopupTrigger()){
handleRequest(listViewPanel,e);
}
}
@Override
public void mousePressed(MouseEvent e) {
if(e.isPopupTrigger()){
handleRequest(listViewPanel,e);
}
}
@Override
public void mouseReleased(MouseEvent e) {
if(e.isPopupTrigger()){
handleRequest(listViewPanel,e);
}
}
private void handleRequest(JPanel metricsPanel, MouseEvent e){
JPopupMenu menu = new JPopupMenu();
menu.add(new AbstractAction("Copy metrics to clipboard") {
@Override
public void actionPerformed(ActionEvent e) {
String msg = getExport();
Clipboard clb = Toolkit.getDefaultToolkit().getSystemClipboard();
clb.setContents(new StringSelection(msg),null);
}
});
menu.show(metricsPanel,e.getX(),e.getY());
}
});
addTab("Listview", new ChimpScrollPane(listViewPanel));
addTab("Chartview", new ChimpScrollPane(metricsGraph));
}
......@@ -111,6 +154,18 @@ public class StandardMetricsPanel extends JTabbedPane implements ChimpLayout {
allMetrics.addAll(ratioMetrics);
}
public String getExport(){
StringBuilder export = new StringBuilder();
export.append(Metric.getExportHeaderString());
export.append("\n");
for (Metric m : allMetrics) {
export.append(m.getExportString());
export.append("\n");
}
return export.toString();
}
public void dispose() {
modelManager.removeOntologyChangeListener(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