Commit 6c2a08d0 authored by Romana Pernischova's avatar Romana Pernischova
Browse files

last change panel rewert

parent 218763b4
......@@ -5,7 +5,7 @@
<groupId>chimp</groupId>
<artifactId>chimp.plugin</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
<packaging>bundle</packaging>
<name>Chimp Plugin</name>
......
package view.lastchange;
import net.miginfocom.swing.MigLayout;
import org.knowm.xchart.XChartPanel;
import org.knowm.xchart.PieChart;
import org.knowm.xchart.PieChartBuilder;
import org.protege.editor.owl.model.OWLModelManager;
import org.semanticweb.owlapi.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import view.ChimpLayout;
import viewcomponents.ChimpIcons;
import viewcomponents.ChimpScrollPane;
import viewcomponents.TitleLabel;
import javax.annotation.Nonnull;
......@@ -21,16 +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;
......@@ -40,15 +32,11 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
}
}
if (realChange) {
// constructTree(changes);
this.displayChanges(changes);
// changeGraph.updateChart(changes);
}
};
// private JPanel changeListView;
private static final String title = "Changes";
private static final String title = "Last Change";
private final JLabel noChangesLabel = new JLabel("No changes yet");
private JTree tree;
......@@ -64,33 +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("");
......@@ -116,92 +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);
......@@ -228,8 +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);
this.remove(noChangesLabel);
this.add(tree, BorderLayout.CENTER);
remove(noChangesLabel);
add(tree, BorderLayout.CENTER);
} else {
defaultTreeModel.setRoot(root);
defaultTreeModel.reload();
......@@ -239,8 +126,35 @@ 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) {
return "&lt;" + change.getAxiom().toString() + "&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