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

last change panel rewert

parent 218763b4
...@@ -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.1.1</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>Chimp Plugin</name> <name>Chimp Plugin</name>
......
package view.lastchange; package view.lastchange;
import net.miginfocom.swing.MigLayout; 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.protege.editor.owl.model.OWLModelManager;
import org.semanticweb.owlapi.model.*; import org.semanticweb.owlapi.model.*;
import org.slf4j.Logger; 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;
...@@ -21,16 +17,12 @@ import javax.swing.tree.DefaultTreeModel; ...@@ -21,16 +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;
...@@ -40,15 +32,11 @@ public class LastChangePanel extends JPanel implements ChimpLayout { ...@@ -40,15 +32,11 @@ public class LastChangePanel extends JPanel implements ChimpLayout {
} }
} }
if (realChange) { if (realChange) {
// constructTree(changes);
this.displayChanges(changes); this.displayChanges(changes);
// changeGraph.updateChart(changes);
} }
}; };
// private JPanel changeListView; private static final String title = "Last Change";
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;
...@@ -64,33 +52,18 @@ public class LastChangePanel extends JPanel implements ChimpLayout { ...@@ -64,33 +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("");
...@@ -116,92 +89,6 @@ public class LastChangePanel extends JPanel implements ChimpLayout { ...@@ -116,92 +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);
...@@ -228,8 +115,8 @@ public class LastChangePanel extends JPanel implements ChimpLayout { ...@@ -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 // the following line is needed to ensure that the multiline html has variable height
tree.setRowHeight(0); tree.setRowHeight(0);
this.remove(noChangesLabel); remove(noChangesLabel);
this.add(tree, BorderLayout.CENTER); add(tree, BorderLayout.CENTER);
} else { } else {
defaultTreeModel.setRoot(root); defaultTreeModel.setRoot(root);
defaultTreeModel.reload(); defaultTreeModel.reload();
...@@ -239,8 +126,35 @@ public class LastChangePanel extends JPanel implements ChimpLayout { ...@@ -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() { 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