receive a Reader to obtain the data to import, \sa setReader;
+ *
returns a container, \sa getContainer;
+ *
update a progress bar, \sa setProgressTicket;
+ *
fill a log file, \sa getReport.
+ *
+ * @author edemairy
+ */
+public class SemanticWebImporter implements FileImporter, LongTask {
+
+ private static final Logger LOGGER = Logger.getLogger(SemanticWebImporter.class.getName());
+ private Reader reader;
+ private ContainerLoader container;
+ private Report report;
+ private ProgressTicket progressTicket;
+ private boolean cancel = false;
+ private String sparqlRequest;
+ private SemanticWebImportParser rdfParser;
+ private final CoreseDriver sparqlDriver;
+
+ public SemanticWebImporter() {
+ sparqlDriver = new CoreseDriver();
+ }
+
+ @Override
+ public final boolean execute(final ContainerLoader loader) {
+ this.container = loader;
+ this.report = new Report();
+
+ progressTicket.setDisplayName("SemanticWebImporter");
+ progressTicket.start();
+
+ LOGGER.info("Beginning the import");
+ final SemanticWebImportParser.RequestParameters requestParameters =
+ new SemanticWebImportParser.RequestParameters(getSparqlRequest());
+ rdfParser = new SemanticWebImportParser(requestParameters);
+
+ LOGGER.info("Starting the RDF importer for Gephi");
+
+ rdfParser.populateRDFGraph(sparqlDriver, new Properties(), new NullLongTaskListener());
+ try {
+ rdfParser.waitEndpopulateRDFGraph();
+ } catch (InterruptedException ex) {
+ Exceptions.printStackTrace(ex);
+ LOGGER.log(Level.WARNING, "Interrupted!", ex);
+ Thread.currentThread().interrupt();
+ }
+ LOGGER.info("Finished the import");
+
+ ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
+ Workspace dataWorkspace = pc.getCurrentWorkspace();
+ GraphController currentGraphController = Lookup.getDefault().lookup(GraphController.class);
+ GraphModel model = currentGraphController.getGraphModel(dataWorkspace);
+
+ Factory draftFactory = container.factory();
+ for (Node currentNode : model.getGraph().getNodes()) {
+ String nodeDraftLabel = currentNode.getLabel();
+ NodeDraft nodeDraft = draftFactory.newNodeDraft(nodeDraftLabel);
+ nodeDraft.setLabel(nodeDraftLabel);
+ LOGGER.log(Level.INFO, "Adding new node: {0}", nodeDraftLabel);
+ loader.addNode(nodeDraft);
+ }
+
+ for (Edge currentEdge: model.getGraph().getEdges()) {
+ EdgeDraft edgeDraft = draftFactory.newEdgeDraft();
+ edgeDraft.setLabel(currentEdge.getLabel());
+
+ String nodeDraftSourceLabel = currentEdge.getSource().getLabel();
+ NodeDraft nodeDraftSource = loader.getNode(nodeDraftSourceLabel);
+
+ String nodeDraftTargetLabel = currentEdge.getTarget().getLabel();
+ NodeDraft nodeDraftTarget = loader.getNode(nodeDraftTargetLabel);
+
+ edgeDraft.setSource(nodeDraftSource);
+ edgeDraft.setTarget(nodeDraftTarget);
+ LOGGER.log(Level.INFO, "Adding edge from {0} to {1}", new Object[]{nodeDraftSourceLabel, nodeDraftTargetLabel});
+ loader.addEdge(edgeDraft);
+ }
+
+ progressTicket.finish();
+ return !cancel;
+ }
+
+ @Override
+ public final ContainerLoader getContainer() {
+ return container;
+ }
+
+ @Override
+ public final Report getReport() {
+ return report;
+ }
+
+ @Override
+ public final boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ @Override
+ public final void setProgressTicket(final ProgressTicket newProgressTicket) {
+ this.progressTicket = newProgressTicket;
+ }
+
+ @Override
+ public final void setReader(Reader reader) {
+ this.reader = reader;
+ }
+
+ public final String getSparqlRequest() {
+ return sparqlRequest;
+ }
+
+ public final void setSparqlRequest(final String newSparqlRequest) {
+ this.sparqlRequest = newSparqlRequest;
+ }
+
+ public final CoreseDriver getDriver() {
+ return sparqlDriver;
+ }
+
+ void setResources(List resourceList) {
+ sparqlDriver.getParameters().addResources( resourceList.toArray(new String[]{}) );
+ }
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/importer/SemanticWebImporterPanel.form b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/importer/SemanticWebImporterPanel.form
new file mode 100644
index 0000000000..4f9161c45c
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/importer/SemanticWebImporterPanel.form
@@ -0,0 +1,81 @@
+
+
+
\ No newline at end of file
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/importer/SemanticWebImporterPanel.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/importer/SemanticWebImporterPanel.java
new file mode 100644
index 0000000000..50cd4ee841
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/importer/SemanticWebImporterPanel.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+
+package fr.inria.edelweiss.semantic.importer;
+
+import fr.inria.edelweiss.sparql.corese.CoreseDriver;
+
+import java.util.List;
+
+/**
+ *
+ * @author edemairy
+ */
+
+
+public class SemanticWebImporterPanel extends javax.swing.JPanel {
+ private static final long serialVersionUID = -5564063032941454007L;
+ private CoreseDriver driver;
+
+ /** Creates new form SemanticWebImporterPanel */
+ public SemanticWebImporterPanel() {
+ initComponents();
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ jSplitPane1 = new javax.swing.JSplitPane();
+ sparqlQueryEditor = new fr.inria.corese.gui.query.SparqlQueryEditor();
+ coreseDriverParametersPanel = new fr.inria.edelweiss.sparql.corese.CoreseDriverParametersPanel();
+
+ jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
+ jSplitPane1.setRightComponent(sparqlQueryEditor);
+ jSplitPane1.setLeftComponent(coreseDriverParametersPanel);
+
+ var jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
+ );
+ jPanel1Layout.setVerticalGroup(
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE))
+ );
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addContainerGap())
+ );
+ }// //GEN-END:initComponents
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private fr.inria.edelweiss.sparql.corese.CoreseDriverParametersPanel coreseDriverParametersPanel;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JSplitPane jSplitPane1;
+ private fr.inria.corese.gui.query.SparqlQueryEditor sparqlQueryEditor;
+ // End of variables declaration//GEN-END:variables
+
+ public void addResource(String lastFileName) {
+ coreseDriverParametersPanel.addResource(lastFileName);
+ }
+
+ public void setSparqlRequest(final String request) {
+ sparqlQueryEditor.setQueryText(request);
+ }
+
+ String getSparqlRequest() {
+ return ""; //sparqlQueryEditor.getQueryText();
+ }
+
+ public List getResourceList() {
+ return coreseDriverParametersPanel.getResourceList();
+ }
+
+ void setDriver(CoreseDriver driver) {
+ this.driver = driver;
+ coreseDriverParametersPanel.setParameters(driver.getParameters());
+ }
+
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/importer/SemanticWebImporterUI.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/importer/SemanticWebImporterUI.java
new file mode 100644
index 0000000000..18b091d38d
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/importer/SemanticWebImporterUI.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+
+package fr.inria.edelweiss.semantic.importer;
+
+import fr.inria.edelweiss.sparql.corese.CoreseDriver;
+import javax.swing.JPanel;
+import org.gephi.io.importer.spi.Importer;
+import org.gephi.io.importer.spi.ImporterUI;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author edemairy
+ */
+@ServiceProvider(service = ImporterUI.class)
+public class SemanticWebImporterUI implements ImporterUI {
+
+ private SemanticWebImporterPanel panel;
+ private SemanticWebImporter importer;
+ private CoreseDriver driver;
+
+ @Override
+ public void setup(Importer[] importers) {
+ this.importer = (SemanticWebImporter) importers[0];
+ }
+
+ @Override
+ public JPanel getPanel() {
+ driver = new CoreseDriver();
+ panel = new SemanticWebImporterPanel();
+ panel.setDriver(driver);
+ panel.addResource(SemanticWebImportBuilder.getLastFileName());
+ panel.setSparqlRequest("construct \n{?x ?r ?y } \nwhere\n{?x ?r ?y}");
+ return panel;
+ }
+
+ /*
+ * Called when the user press ok.
+ */
+ @Override
+ public void unsetup(boolean bln) {
+ importer.setResources(panel.getResourceList());
+ importer.setSparqlRequest(panel.getSparqlRequest());
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "SemanticWebImporter";
+ }
+
+ @Override
+ public boolean isUIForImporter(Importer importer) {
+ return importer instanceof SemanticWebImporter;
+ }
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatistics.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatistics.java
new file mode 100644
index 0000000000..40e2129b45
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatistics.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+package fr.inria.edelweiss.semantic.statistics;
+
+import fr.com.hp.hpl.jena.rdf.arp.MalformedURIException;
+import fr.com.hp.hpl.jena.rdf.arp.URI;
+import fr.inria.edelweiss.semantic.SemanticWebImportMainWindowTopComponent;
+import fr.inria.edelweiss.semantic.statistics.gui.JTreeTable;
+import fr.inria.edelweiss.semantic.statistics.gui.TypeTreeModel;
+import fr.inria.edelweiss.semantic.statistics.gui.TypeTreeNode;
+import fr.inria.edelweiss.sparql.SparqlRequester;
+import org.gephi.graph.api.GraphModel;
+import org.gephi.statistics.spi.Statistics;
+
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.tree.TreeNode;
+import java.awt.BorderLayout;
+import java.awt.HeadlessException;
+import java.io.IOException;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * @author edemairy
+ */
+public class SemanticWebStatistics implements Statistics {
+
+ public static final String GET_SUBCLASSES = "select ?x ?t where { ?x rdfs:subClassOf ?t } group by ?x";
+ public static final String COUNT_TYPES = "select ?t (count(?x) as ?total) where { ?x rdf:type ?t } group by ?t";
+ public static final String DRIVER_TYPE = "fr.inria.edelweiss.sparql.corese.CoreseDriver";
+ private static final Logger logger = Logger.getLogger(SemanticWebStatistics.class.getName());
+ private final StringBuilder summary = new StringBuilder();
+ private final StringBuilder report = new StringBuilder();
+
+ /*
+ * Turn the exception mechanism in a boolean function.
+ */
+ static protected boolean isURILegal(final String uri) {
+ try {
+ URI newUri = new URI(uri);
+ } catch (NullPointerException e) {
+ return false;
+ } catch (MalformedURIException e) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Computes the statistics. The resulting report can be obtained from the {@link Statistics#getReport() getReport} method.
+ *
+ * @param gm The input.
+ */
+ @Override
+ public void execute(GraphModel gm) {
+ try {
+ SparqlRequester sparqlRequester = SemanticWebImportMainWindowTopComponent.getSparqlRequester();
+ Map countTypes = countTypes(sparqlRequester.selectOnGraph(COUNT_TYPES));
+ TypeTreeModel typeModel = buildTreeModel(sparqlRequester.selectOnGraph(GET_SUBCLASSES));
+ updateModelCount(typeModel, countTypes);
+ displayTypeTree(typeModel);
+ summary.append(countTypes.size()).append(" types found");
+ report.append("
").append(countTypes.size()).append(" types were found :
");
+ for (String key : countTypes.keySet()) {
+ report.append("
").append(key).append(": found ").append(countTypes.get(key)).append(" times
");
+ }
+ } catch (HeadlessException ex) {
+ report.append("An exception occurred: ").append(ex.getMessage());
+ }
+ }
+
+ @Override
+ public String getReport() {
+ return report.toString();
+ }
+
+ public String getSummary() {
+ return summary.toString();
+ }
+
+ /**
+ * Display the model in a JTreeTable.
+ *
+ * @param typeModel to display.
+ */
+ protected void displayTypeTree(TypeTreeModel typeModel) {
+ JPanel frame = new JPanel(new BorderLayout());
+ JTreeTable treeTable = new JTreeTable(typeModel);
+ frame.add(new JScrollPane(treeTable), BorderLayout.CENTER);
+ try {
+ SemanticWebImportMainWindowTopComponent.getDefault().addTab("Tree Type", frame);
+ } catch (IOException ex) {
+ logger.log(Level.SEVERE, "An exception occurred when attempting to display the type tree: ", ex.getMessage());
+ }
+ }
+
+ /**
+ * Convert the result returned by a select counting the types into a
+ * map.
+ *
+ * @param selectOnGraph Result obtained with a select request. The first
+ * column must contain the name of the type, the second column must
+ * contain the number of occurrences found for this type.
+ * @return The counted types.
+ */
+ protected Map countTypes(String[][] selectOnGraph) {
+ HashMap result = new HashMap();
+ for (int i = 0; i < selectOnGraph.length; ++i) {
+ String name = selectOnGraph[i][0];
+ Integer count = Integer.parseInt(selectOnGraph[i][1]);
+ result.put(name, count);
+ }
+ return result;
+ }
+
+ /**
+ * Register for each node who are its fathers and children. Note that a
+ * node can have several children and/or father.
+ *
+ * @param selectOnGraph
+ * @return
+ */
+ protected TypeTreeModel buildTreeModel(String[][] selectOnGraph) {
+ TypeTreeNode root = new TypeTreeNode("Root", 0, 0);
+ TypeTreeModel result = new TypeTreeModel(root);
+ HashMap builtNodes = new HashMap();
+
+ for (int i = 0; i < selectOnGraph.length; ++i) {
+ String childTypeName = selectOnGraph[i][0];
+ String fatherTypeName = selectOnGraph[i][1];
+ TypeTreeNode fatherNode;
+ if (builtNodes.containsKey(fatherTypeName)) {
+ fatherNode = builtNodes.get(fatherTypeName);
+ } else {
+ fatherNode = new TypeTreeNode(fatherTypeName, 0, 0);
+ builtNodes.put(fatherTypeName, fatherNode);
+ }
+ TypeTreeNode childNode;
+ if (builtNodes.containsKey(childTypeName)) {
+ childNode = builtNodes.get(childTypeName);
+ } else {
+ childNode = new TypeTreeNode(childTypeName, 0, 0);
+ builtNodes.put(childTypeName, childNode);
+ }
+ fatherNode.add(childNode);
+ }
+ for (String nodeName : builtNodes.keySet()) {
+ TypeTreeNode currentNode = builtNodes.get(nodeName);
+ if (!currentNode.hasFather()) {
+ result.getRoot().add(currentNode);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Add the count for each node of typeModel, and add nodes if they are
+ * present in countTypes, but not in typeModel. It can happen that a
+ * type is known with rdf:type (used to obtain countTypes), but that
+ * there is no known rdfs:subClassOf relationship with it (letting the
+ * typeModel unaware of this type).
+ *
+ * @param typeModel
+ * @param countTypes
+ */
+ protected void updateModelCount(TypeTreeModel typeModel, final Map countTypes) {
+ var seenTypes = new HashSet();
+ int total = 0;
+ for (Integer count : countTypes.values()) {
+ total += count;
+ }
+ if (total == 0) {
+ throw new IllegalArgumentException("total count must not be 0.");
+ }
+
+ TypeTreeNode node = typeModel.getRoot();
+ var queue = new LinkedList();
+ queue.add(node);
+ while (!queue.isEmpty()) {
+ TypeTreeNode currentNode = queue.pollLast();
+ String nodeName = currentNode.getName();
+ int countType = (countTypes.get(nodeName) != null) ? countTypes.get(nodeName) : 0;
+ currentNode.setNumber(countType);
+ currentNode.setPercentage(100.0 * countType / total);
+ seenTypes.add(nodeName);
+
+ Enumeration childs = currentNode.children();
+ while (childs.hasMoreElements()) {
+ queue.addFirst((TypeTreeNode) childs.nextElement());
+ }
+ }
+ Set unseenTypes = countTypes.keySet();
+ unseenTypes.removeAll(seenTypes);
+ for (String unseenType : unseenTypes) {
+ typeModel.getRoot().add(new TypeTreeNode(unseenType, countTypes.get(unseenType), 100.0 * countTypes.get(unseenType) / total));
+ }
+ }
+}
+
+/**
+ * Compares by ascending count of successors, then by alphabetical order if
+ * there is counts are equal.
+ *
+ * @author Erwan Demairy
+ */
+class SuccessorComparator implements Comparator {
+
+ private Map> successors;
+
+ public SuccessorComparator(Map> successors) {
+ this.successors = successors;
+ }
+
+ @Override
+ public int compare(String o1, String o2) {
+
+ if (successors.get(o1).size() < successors.get(o2).size()) {
+ return -1;
+ } else if (successors.get(o1).size() > successors.get(o2).size()) {
+ return 1;
+ } else {
+ return o1.compareTo(o2);
+ }
+ }
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsBuilder.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsBuilder.java
new file mode 100644
index 0000000000..be88e7c53d
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsBuilder.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+package fr.inria.edelweiss.semantic.statistics;
+
+import org.gephi.statistics.spi.Statistics;
+import org.gephi.statistics.spi.StatisticsBuilder;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author edemairy
+ */
+
+@ServiceProvider(service=StatisticsBuilder.class)
+public class SemanticWebStatisticsBuilder implements StatisticsBuilder {
+
+ private SemanticWebStatistics statistics;
+
+ @Override
+ public String getName() {
+ return SemanticWebStatisticsBuilder.class.getSimpleName();
+ }
+
+ @Override
+ public Statistics getStatistics() {
+ this.statistics = new SemanticWebStatistics();
+ return statistics;
+ }
+
+ @Override
+ public Class extends Statistics> getStatisticsClass() {
+ return SemanticWebStatistics.class;
+ }
+
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsPanel.form b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsPanel.form
new file mode 100644
index 0000000000..b7a90e2fab
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsPanel.form
@@ -0,0 +1,31 @@
+
+
+
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsPanel.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsPanel.java
new file mode 100644
index 0000000000..2c023d196b
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsPanel.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+
+/*
+ * SemanticWebStatisticsPanel.java
+ *
+ * Created on Dec 13, 2011, 4:14:31 PM
+ */
+package fr.inria.edelweiss.semantic.statistics;
+
+import org.gephi.statistics.spi.Statistics;
+
+/**
+ *
+ * @author edemairy
+ */
+public class SemanticWebStatisticsPanel extends javax.swing.JPanel {
+ private static final long serialVersionUID = 191053265603936122L;
+ private Statistics statistics;
+
+ /** Creates new form SemanticWebStatisticsPanel */
+ public SemanticWebStatisticsPanel() {
+ initComponents();
+ }
+
+ SemanticWebStatisticsPanel(Statistics statistics) {
+ this.statistics = statistics;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jLabel1 = new javax.swing.JLabel();
+
+ setLayout(new java.awt.BorderLayout());
+
+ jLabel1.setText(org.openide.util.NbBundle.getMessage(SemanticWebStatisticsPanel.class, "SemanticWebStatisticsPanel.jLabel1.text")); // NOI18N
+ add(jLabel1, java.awt.BorderLayout.CENTER);
+ }// //GEN-END:initComponents
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel jLabel1;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsUI.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsUI.java
new file mode 100644
index 0000000000..698eefe9d2
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/SemanticWebStatisticsUI.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+package fr.inria.edelweiss.semantic.statistics;
+
+import javax.swing.JPanel;
+import org.gephi.statistics.spi.Statistics;
+import org.gephi.statistics.spi.StatisticsUI;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author edemairy
+ */
+@ServiceProvider(service=StatisticsUI.class)
+public class SemanticWebStatisticsUI implements StatisticsUI{
+ private final String DISPLAY_NAME = "SW Type Statistics";
+ private final int POSITION = 666;
+ private SemanticWebStatistics statistics;
+
+ public JPanel getSettingsPanel() {
+ return new SemanticWebStatisticsPanel(statistics);
+ }
+
+ public void setup(Statistics ststcs) {
+ statistics = (SemanticWebStatistics) ststcs;
+ }
+
+ public void unsetup() {
+ statistics = null;
+ }
+
+ public Class extends Statistics> getStatisticsClass() {
+ return SemanticWebStatistics.class;
+ }
+
+ public String getValue() {
+ return statistics.getSummary();
+ }
+
+ public String getDisplayName() {
+ return DISPLAY_NAME;
+ }
+
+ public String getCategory() {
+ return CATEGORY_NODE_OVERVIEW;
+ }
+
+ public int getPosition() {
+ return POSITION;
+ }
+
+ @Override
+ public String getShortDescription() {
+ return "Compute the number of types and relationships in the current dataset.";
+ }
+
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/AbstractCellEditor.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/AbstractCellEditor.java
new file mode 100644
index 0000000000..14ba94b83e
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/AbstractCellEditor.java
@@ -0,0 +1,111 @@
+package fr.inria.edelweiss.semantic.statistics.gui;
+
+/*
+ * %W% %E%
+ *
+ * Copyright 1997, 1998 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
+ * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
+ * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE OR
+ * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
+ * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
+ * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
+ * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
+ * THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
+ * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ */
+
+import java.util.EventObject;
+import javax.swing.CellEditor;
+import javax.swing.event.CellEditorListener;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.EventListenerList;
+
+/**
+ * @version %I% %G%
+ *
+ * A base class for CellEditors, providing default implementations for all
+ * methods in the CellEditor interface and support for managing a series
+ * of listeners.
+ *
+ * @author Philip Milne
+ */
+
+public class AbstractCellEditor implements CellEditor {
+
+ protected EventListenerList listenerList = new EventListenerList();
+
+ public Object getCellEditorValue() { return null; }
+ public boolean isCellEditable(EventObject e) { return true; }
+ public boolean shouldSelectCell(EventObject anEvent) { return false; }
+ public boolean stopCellEditing() { return true; }
+ public void cancelCellEditing() {}
+
+ public void addCellEditorListener(CellEditorListener l) {
+ listenerList.add(CellEditorListener.class, l);
+ }
+
+ public void removeCellEditorListener(CellEditorListener l) {
+ listenerList.remove(CellEditorListener.class, l);
+ }
+
+ /**
+ * Notify all listeners that have registered interest for
+ * notification on this event type.
+ * @see EventListenerList
+ */
+ protected void fireEditingStopped() {
+ // Guaranteed to return a non-null array
+ Object[] listeners = listenerList.getListenerList();
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length-2; i>=0; i-=2) {
+ if (listeners[i]==CellEditorListener.class) {
+ ((CellEditorListener)listeners[i+1]).editingStopped(new ChangeEvent(this));
+ }
+ }
+ }
+
+ /**
+ * Notify all listeners that have registered interest for
+ * notification on this event type.
+ * @see EventListenerList
+ */
+ protected void fireEditingCanceled() {
+ // Guaranteed to return a non-null array
+ Object[] listeners = listenerList.getListenerList();
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length-2; i>=0; i-=2) {
+ if (listeners[i]==CellEditorListener.class) {
+ ((CellEditorListener)listeners[i+1]).editingCanceled(new ChangeEvent(this));
+ }
+ }
+ }
+}
+
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/AbstractTreeTableModel.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/AbstractTreeTableModel.java
new file mode 100644
index 0000000000..0bcfeb2301
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/AbstractTreeTableModel.java
@@ -0,0 +1,234 @@
+/*
+ *
+ * Copyright 1997, 1998 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
+ * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
+ * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE OR
+ * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
+ * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
+ * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
+ * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
+ * THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
+ * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ */
+package fr.inria.edelweiss.semantic.statistics.gui;
+
+import javax.swing.event.EventListenerList;
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.tree.TreePath;
+
+
+/**
+ * An abstract implementation of the TreeTableModel interface, handling
+ * the list of listeners.
+ *
+ * @author Philip Milne
+ * @version %I% %G%
+ */
+
+public abstract class AbstractTreeTableModel implements TreeTableModel {
+ protected Object root;
+ protected EventListenerList listenerList = new EventListenerList();
+
+ protected AbstractTreeTableModel(Object root) {
+ this.root = root;
+ }
+
+ //
+ // Default implmentations for methods in the TreeModel interface.
+ //
+
+ public Object getRoot() {
+ return root;
+ }
+
+ public boolean isLeaf(Object node) {
+ return getChildCount(node) == 0;
+ }
+
+ public void valueForPathChanged(TreePath path, Object newValue) {
+ }
+
+ // This is not called in the JTree's default mode: use a naive implementation.
+ public int getIndexOfChild(Object parent, Object child) {
+ for (int i = 0; i < getChildCount(parent); i++) {
+ if (getChild(parent, i).equals(child)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public void addTreeModelListener(TreeModelListener l) {
+ listenerList.add(TreeModelListener.class, l);
+ }
+
+ public void removeTreeModelListener(TreeModelListener l) {
+ listenerList.remove(TreeModelListener.class, l);
+ }
+
+ /*
+ * Notify all listeners that have registered interest for
+ * notification on this event type. The event instance
+ * is lazily created using the parameters passed into
+ * the fire method.
+ * @see EventListenerList
+ */
+ protected void fireTreeNodesChanged(Object source, Object[] path,
+ int[] childIndices,
+ Object[] children) {
+ // Guaranteed to return a non-null array
+ Object[] listeners = listenerList.getListenerList();
+ TreeModelEvent e = null;
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == TreeModelListener.class) {
+ // Lazily create the event:
+ if (e == null) {
+ e = new TreeModelEvent(source, path,
+ childIndices, children);
+ }
+ ((TreeModelListener) listeners[i + 1]).treeNodesChanged(e);
+ }
+ }
+ }
+
+ /*
+ * Notify all listeners that have registered interest for
+ * notification on this event type. The event instance
+ * is lazily created using the parameters passed into
+ * the fire method.
+ * @see EventListenerList
+ */
+ protected void fireTreeNodesInserted(Object source, Object[] path,
+ int[] childIndices,
+ Object[] children) {
+ // Guaranteed to return a non-null array
+ Object[] listeners = listenerList.getListenerList();
+ TreeModelEvent e = null;
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == TreeModelListener.class) {
+ // Lazily create the event:
+ if (e == null) {
+ e = new TreeModelEvent(source, path,
+ childIndices, children);
+ }
+ ((TreeModelListener) listeners[i + 1]).treeNodesInserted(e);
+ }
+ }
+ }
+
+ /*
+ * Notify all listeners that have registered interest for
+ * notification on this event type. The event instance
+ * is lazily created using the parameters passed into
+ * the fire method.
+ * @see EventListenerList
+ */
+ protected void fireTreeNodesRemoved(Object source, Object[] path,
+ int[] childIndices,
+ Object[] children) {
+ // Guaranteed to return a non-null array
+ Object[] listeners = listenerList.getListenerList();
+ TreeModelEvent e = null;
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == TreeModelListener.class) {
+ // Lazily create the event:
+ if (e == null)
+ e = new TreeModelEvent(source, path,
+ childIndices, children);
+ ((TreeModelListener) listeners[i + 1]).treeNodesRemoved(e);
+ }
+ }
+ }
+
+ /*
+ * Notify all listeners that have registered interest for
+ * notification on this event type. The event instance
+ * is lazily created using the parameters passed into
+ * the fire method.
+ * @see EventListenerList
+ */
+ protected void fireTreeStructureChanged(Object source, Object[] path,
+ int[] childIndices,
+ Object[] children) {
+ // Guaranteed to return a non-null array
+ Object[] listeners = listenerList.getListenerList();
+ TreeModelEvent e = null;
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == TreeModelListener.class) {
+ // Lazily create the event:
+ if (e == null)
+ e = new TreeModelEvent(source, path,
+ childIndices, children);
+ ((TreeModelListener) listeners[i + 1]).treeStructureChanged(e);
+ }
+ }
+ }
+
+ //
+ // Default impelmentations for methods in the TreeTableModel interface.
+ //
+
+ public Class getColumnClass(int column) {
+ return Object.class;
+ }
+
+ /**
+ * By default, make the column with the Tree in it the only editable one.
+ * Making this column editable causes the JTable to forward mouse
+ * and keyboard events in the Tree column to the underlying JTree.
+ */
+ public boolean isCellEditable(Object node, int column) {
+ return getColumnClass(column) == TreeTableModel.class;
+ }
+
+ public void setValueAt(Object aValue, Object node, int column) {
+ }
+
+
+ // Left to be implemented in the subclass:
+
+ /*
+ * public Object getChild(Object parent, int index)
+ * public int getChildCount(Object parent)
+ * public int getColumnCount()
+ * public String getColumnName(Object node, int column)
+ * public Object getValueAt(Object node, int column)
+ */
+
+}
+
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/JTreeTable.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/JTreeTable.java
new file mode 100644
index 0000000000..eae19f2c9f
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/JTreeTable.java
@@ -0,0 +1,155 @@
+/*
+ * %W% %E%
+ *
+ * Copyright 1997, 1998 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
+ * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
+ * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE OR
+ * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
+ * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
+ * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
+ * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
+ * THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
+ * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ */
+package fr.inria.edelweiss.semantic.statistics.gui;
+
+import javax.swing.*;
+import java.awt.Dimension;
+import java.awt.Component;
+import java.awt.Graphics;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.tree.DefaultTreeSelectionModel;
+import javax.swing.tree.TreeModel;
+
+/**
+ * This example shows how to create a simple JTreeTable component,
+ * by using a JTree as a renderer (and editor) for the cells in a
+ * particular column in the JTable.
+ *
+ * @version %I% %G%
+ *
+ * @author Philip Milne
+ * @author Scott Violet
+ */
+public class JTreeTable extends JTable {
+
+ private static final long serialVersionUID = 4435181815819049703L;
+ protected TreeTableCellRenderer tree;
+
+ public JTreeTable(TreeTableModel treeTableModel) {
+ super();
+
+ // Create the tree. It will be used as a renderer and editor.
+ tree = new TreeTableCellRenderer(treeTableModel);
+
+ // Install a tableModel representing the visible rows in the tree.
+ super.setModel(
+ new TreeTableModelAdapter(treeTableModel, tree));
+
+ // Force the JTable and JTree to share their row selection models.
+ var selectionModel = new DefaultTreeSelectionModel();
+ tree.setSelectionModel( selectionModel );
+ // Make the tree and table row heights the same.
+ tree.setRowHeight(getRowHeight());
+
+ // Install the tree editor renderer and editor.
+ setDefaultRenderer(TreeTableModel.class, tree);
+ setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());
+
+ setShowGrid(true);
+ setIntercellSpacing(new Dimension(0, 0));
+
+ this.setDragEnabled(true);
+ this.setTransferHandler(new JTreeTableHandler());
+ }
+
+ /* Workaround for BasicTableUI anomaly. Make sure the UI never tries to
+ * paint the editor. The UI currently uses different techniques to
+ * paint the renderers and editors and overriding setBounds() below
+ * is not the right thing to do for an editor. Returning -1 for the
+ * editing row in this case, ensures the editor is never painted.
+ */
+ public int getEditingRow() {
+ return (getColumnClass(editingColumn) == TreeTableModel.class) ? -1 : editingRow;
+ }
+
+ //
+ // The renderer used to display the tree nodes, a JTree.
+ //
+ public class TreeTableCellRenderer extends JTree implements TableCellRenderer {
+
+ private static final long serialVersionUID = 1996621516702976415L;
+ protected int visibleRow;
+
+ public TreeTableCellRenderer(TreeModel model) {
+ super(model);
+ }
+
+ public void setBounds(int x, int y, int w, int h) {
+ super.setBounds(x, 0, w, JTreeTable.this.getHeight());
+ }
+
+ public void paint(Graphics g) {
+ g.translate(0, -visibleRow * getRowHeight());
+ super.paint(g);
+ }
+
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row, int column) {
+ if (isSelected) {
+ setBackground(table.getSelectionBackground());
+ } else {
+ setBackground(table.getBackground());
+ }
+
+ visibleRow = row;
+ return this;
+ }
+ }
+
+ //
+ // The editor used to interact with tree nodes, a JTree.
+ //
+ public class TreeTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected, int r, int c) {
+ return tree;
+ }
+ }
+
+ public String getCell(int row, int column) {
+ return getModel().getValueAt(row, column).toString();
+ }
+
+}
\ No newline at end of file
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/JTreeTableHandler.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/JTreeTableHandler.java
new file mode 100644
index 0000000000..36e1b86897
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/JTreeTableHandler.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+package fr.inria.edelweiss.semantic.statistics.gui;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+import javax.swing.JComponent;
+import javax.swing.TransferHandler;
+
+/**
+ *
+ * @author Erwan Demairy
+ */
+class JTreeTableHandler extends TransferHandler {
+
+ private static final long serialVersionUID = 2445967652825693813L;
+
+ public JTreeTableHandler() {
+ }
+
+ public boolean canImport(TransferHandler.TransferSupport info) {
+ // Check for String flavor
+ if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) {
+ return false;
+ }
+ return true;
+ }
+
+ public Transferable createTransferable(JComponent c) {
+ JTreeTable table = (JTreeTable) c;
+ int numRow = table.getSelectedRow();
+ String cellName = table.getCell(numRow, 0);
+ return new StringSelection(cellName);
+ }
+
+
+ public int getSourceActions(JComponent c) {
+ return TransferHandler.COPY_OR_MOVE;
+ }
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TreeTableModel.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TreeTableModel.java
new file mode 100644
index 0000000000..3085d0a8e4
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TreeTableModel.java
@@ -0,0 +1,82 @@
+/*
+ * %W% %E%
+ *
+ * Copyright 1997, 1998 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
+ * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
+ * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE OR
+ * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
+ * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
+ * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
+ * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
+ * THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
+ * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ */
+package fr.inria.edelweiss.semantic.statistics.gui;
+
+import javax.swing.tree.TreeModel;
+
+/**
+ *
+ * @author edemairy
+ */
+public interface TreeTableModel extends TreeModel
+{
+ /**
+ * Returns the number of available column.
+ */
+ int getColumnCount();
+
+ /**
+ * Returns the name for column number column.
+ */
+ String getColumnName(int column);
+
+ /**
+ * Returns the type for column number column.
+ */
+ Class getColumnClass(int column);
+
+ /**
+ * Returns the value to be displayed for node node,
+ * at column number column.
+ */
+ Object getValueAt(Object node, int column);
+
+ /**
+ * Indicates whether the the value for node node,
+ * at column number column is editable.
+ */
+ boolean isCellEditable(Object node, int column);
+
+ /**
+ * Sets the value for node node,
+ * at column number column.
+ */
+ void setValueAt(Object aValue, Object node, int column);
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TreeTableModelAdapter.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TreeTableModelAdapter.java
new file mode 100644
index 0000000000..cb212d190f
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TreeTableModelAdapter.java
@@ -0,0 +1,121 @@
+package fr.inria.edelweiss.semantic.statistics.gui;
+
+import javax.swing.JTree;
+import javax.swing.event.TreeExpansionEvent;
+import javax.swing.event.TreeExpansionListener;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.tree.TreePath;
+
+/**
+ * %W% %E%
+ *
+ * Copyright 1997, 1998 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
+ * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
+ * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE OR
+ * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
+ * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
+ * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
+ * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
+ * THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
+ * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ */
+
+
+/**
+ * This is a wrapper class takes a TreeTableModel and implements
+ * the table model interface. The implementation is trivial, with
+ * all of the event dispatching support provided by the superclass:
+ * the AbstractTableModel.
+ *
+ * @version %I% %G%
+ *
+ * @author Philip Milne
+ * @author Scott Violet
+ */
+
+
+public class TreeTableModelAdapter extends AbstractTableModel
+{
+ private static final long serialVersionUID = 3385620292461956860L;
+ JTree tree;
+ TreeTableModel treeTableModel;
+
+ public TreeTableModelAdapter(TreeTableModel treeTableModel, JTree tree) {
+ this.tree = tree;
+ this.treeTableModel = treeTableModel;
+
+ tree.addTreeExpansionListener(new TreeExpansionListener() {
+ // Don't use fireTableRowsInserted() here;
+ // the selection model would get updated twice.
+ public void treeExpanded(TreeExpansionEvent event) {
+ fireTableDataChanged();
+ }
+ public void treeCollapsed(TreeExpansionEvent event) {
+ fireTableDataChanged();
+ }
+ });
+ }
+
+ // Wrappers, implementing TableModel interface.
+
+ public int getColumnCount() {
+ return treeTableModel.getColumnCount();
+ }
+
+ public String getColumnName(int column) {
+ return treeTableModel.getColumnName(column);
+ }
+
+ public Class> getColumnClass(int column) {
+ return treeTableModel.getColumnClass(column);
+ }
+
+ public int getRowCount() {
+ return tree.getRowCount();
+ }
+
+ protected Object nodeForRow(int row) {
+ TreePath treePath = tree.getPathForRow(row);
+ return treePath.getLastPathComponent();
+ }
+
+ public Object getValueAt(int row, int column) {
+ return treeTableModel.getValueAt(nodeForRow(row), column);
+ }
+
+ public boolean isCellEditable(int row, int column) {
+ return treeTableModel.isCellEditable(nodeForRow(row), column);
+ }
+
+ public void setValueAt(Object value, int row, int column) {
+ treeTableModel.setValueAt(value, nodeForRow(row), column);
+ }
+}
+
+
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TypeTreeModel.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TypeTreeModel.java
new file mode 100644
index 0000000000..d23ab925ec
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TypeTreeModel.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+package fr.inria.edelweiss.semantic.statistics.gui;
+
+import java.util.*;
+
+/**
+ *
+ * @author edemairy
+ */
+public class TypeTreeModel extends AbstractTreeTableModel implements TreeTableModel {
+ // Names of the columns.
+
+ static protected String[] columnNames = {"Name", "Number", "Percentage"};
+ // Types of the columns.
+ static protected Class[] cTypes = {TreeTableModel.class, Integer.class, Float.class};
+ private TypeTreeNode rootNode;
+// private Map nodeTable;
+
+ public TypeTreeModel(TypeTreeNode root) {
+ super(root);
+// nodeTable = new TreeMap();
+ this.rootNode = root;
+ }
+
+ //
+ // Some convenience methods.
+ //
+ protected TypeTreeNode[] getChildren(TypeTreeNode node) {
+ return node.getChildren();
+ }
+
+ //
+ // The TreeModel interface
+ //
+ @Override
+ public int getChildCount(Object node) {
+ Object[] children = getChildren((TypeTreeNode) node);
+ return (children == null) ? 0 : children.length;
+ }
+
+ @Override
+ public Object getChild(Object node, int i) {
+ return getChildren((TypeTreeNode) node)[i];
+ }
+
+ @Override
+ public TypeTreeNode getRoot() {
+ return rootNode;
+ }
+
+ // The superclass's implementation would work, but this is more efficient.
+ @Override
+ public boolean isLeaf(Object node) {
+ return (getChildCount(node) == 0);
+ }
+
+ //
+ // The TreeTableNode interface.
+ //
+ @Override
+ public int getColumnCount() {
+ return columnNames.length;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ return columnNames[column];
+ }
+
+ @Override
+ public Class> getColumnClass(int column) {
+ return cTypes[column];
+ }
+
+ @Override
+ public Object getValueAt(Object objectNode, int column) {
+ TypeTreeNode node = (TypeTreeNode) objectNode;
+ try {
+ switch (column) {
+ case 0:
+ return node.getName();
+ case 1:
+ return node.getNumber();
+ case 2:
+ return node.getPercentage();
+ }
+ } catch (SecurityException se) {
+ }
+
+ return null;
+ }
+
+ public TypeTreeNode findNode(final String name) {
+ LinkedList queueNodes = new LinkedList();
+ queueNodes.add(rootNode);
+ while (!queueNodes.isEmpty()) {
+ TypeTreeNode currentNode = queueNodes.removeLast();
+ if (currentNode.getName().equals(name)) {
+ return currentNode;
+ } else {
+ for (TypeTreeNode node : currentNode.getChildren()) {
+ queueNodes.add(node);
+ }
+ }
+ }
+ return null;
+ }
+
+ public TypeTreeNode findCreateNode(final String name) {
+ TypeTreeNode result = findNode(name);
+ if (result == null) {
+ result = new TypeTreeNode(name, 0, 0);
+ }
+ return result;
+ }
+
+ public void removeLeaves() {
+ LinkedList queueNodes = new LinkedList();
+ queueNodes.add(getRoot());
+ while (!queueNodes.isEmpty()) {
+ TypeTreeNode currentNode = queueNodes.removeLast();
+ TypeTreeNode[] children = currentNode.getChildren();
+ for (TypeTreeNode child : children) {
+ if (child.isLeaf()) {
+ currentNode.remove(child);
+ } else {
+ queueNodes.add(child);
+ }
+ }
+ }
+ }
+
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TypeTreeNode.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TypeTreeNode.java
new file mode 100644
index 0000000000..86cb048666
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/statistics/gui/TypeTreeNode.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+package fr.inria.edelweiss.semantic.statistics.gui;
+
+import java.util.ArrayList;
+import java.util.Vector;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.MutableTreeNode;
+
+/**
+ *
+ * This class is a data container for the Tree.
+ */
+public class TypeTreeNode extends DefaultMutableTreeNode implements Comparable {
+
+ private static final long serialVersionUID = 5927002411753001709L;
+ private String name;
+ private int number;
+ private double percentage;
+ private ArrayList fathers = new ArrayList();
+
+ public TypeTreeNode(final String name, final int number, final double percentage) {
+ this.name = name;
+ this.number = number;
+ this.percentage = percentage;
+ }
+
+ @Override
+ public void add(MutableTreeNode node) {
+ if (children == null) {
+ children = new Vector<>();
+ }
+ children.insertElementAt(node, getChildCount());
+ TypeTreeNode typeTreeNode = (TypeTreeNode) node;
+ typeTreeNode.addFather(this);
+ }
+
+ /**
+ * Returns the the string to be used to display this leaf in the JTree.
+ */
+ @Override
+ public String toString() {
+ return getName();
+ }
+
+ /**
+ * Loads the children, caching the results in the children var.
+ */
+ protected TypeTreeNode[] getChildren() {
+ ArrayList result = new ArrayList();
+ for (int i = 0; i < getChildCount(); ++i) {
+ result.add((TypeTreeNode) getChildAt(i));
+ }
+ return result.toArray(new TypeTreeNode[0]);
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the number
+ */
+ public int getNumber() {
+ return number;
+ }
+
+ /**
+ * @return the percentage
+ */
+ public double getPercentage() {
+ return percentage;
+ }
+
+ @Override
+ public int compareTo(TypeTreeNode o) {
+ return getName().compareTo(o.getName());
+ }
+
+ public boolean hasFather() {
+ return (!fathers.isEmpty());
+ }
+
+ private void addFather(TypeTreeNode fatherNode) {
+ fathers.add(fatherNode);
+ }
+
+ @Override
+ public void remove(MutableTreeNode aChild) {
+ TypeTreeNode node = (TypeTreeNode) aChild;
+ int index = children.indexOf(aChild);
+ if (index != -1) {
+ node.removeFather(this);
+ children.remove(index);
+ } else {
+
+ }
+ }
+
+ private void removeFather(TypeTreeNode aThis) {
+ fathers.remove(aThis);
+ }
+
+ /**
+ * @param number the number to set
+ */
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ /**
+ * @param percentage the percentage to set
+ */
+ public void setPercentage(double percentage) {
+ this.percentage = percentage;
+ }
+}
\ No newline at end of file
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/tests/Utils.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/tests/Utils.java
new file mode 100644
index 0000000000..96b1ab932a
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/tests/Utils.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+package fr.inria.edelweiss.semantic.tests;
+
+import fr.inria.edelweiss.semantic.SemanticWebImportMainWindowTopComponent;
+import fr.inria.edelweiss.sparql.SparqlRequester;
+import java.io.IOException;
+
+import org.gephi.project.api.Project;
+import org.gephi.project.api.ProjectController;
+import org.gephi.project.api.Workspace;
+import org.gephi.project.api.WorkspaceProvider;
+import org.openide.util.Lookup;
+
+/**
+ *
+ * @author Erwan Demairy
+ */
+public class Utils {
+
+ private SemanticWebImportMainWindowTopComponent topComponent;
+ private static Workspace workspace;
+
+ public void initGephi() {
+ ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
+ projectController.newProject();
+ workspace = projectController.getCurrentWorkspace();
+ }
+
+ /**
+ *
+ * @param configurationName Name of a configuration, e.g. "Humans".
+ * @return
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public Workspace[] whenUsingConfiguration(final String configurationName) throws IOException, InterruptedException {
+ topComponent = new SemanticWebImportMainWindowTopComponent();
+ topComponent.setConfigurationAction(configurationName);
+ return whenCreatingGraphs(topComponent);
+ }
+
+ public Workspace[] whenCreatingGraphs(SemanticWebImportMainWindowTopComponent topComponent) throws InterruptedException {
+ topComponent.startCreateGraphs();
+ topComponent.waitCreateGraphs();
+
+ ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
+ Project project = projectController.getCurrentProject();
+ WorkspaceProvider workspaceprovider = project.getLookup().lookup(WorkspaceProvider.class);
+ return workspaceprovider.getWorkspaces();
+ }
+
+ public SparqlRequester getSparqlRequester() {
+ return (SparqlRequester)topComponent;
+ }
+
+ public SparqlRequester getDriver() {
+ return topComponent.getDriver();
+ }
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/utils/FilesUtils.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/utils/FilesUtils.java
new file mode 100644
index 0000000000..cb00e592e7
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/utils/FilesUtils.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+package fr.inria.edelweiss.semantic.utils;
+
+import java.awt.Component;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JFileChooser;
+
+/**
+ *
+ * @author Erwan Demairy
+ */
+public class FilesUtils {
+
+ static final private Logger logger = Logger.getLogger(FilesUtils.class.getName());
+
+ public static Properties readProperties(String fileName) {
+ InputStream is = readFile(fileName);
+
+ Properties result = new Properties();
+ try {
+ result.loadFromXML(is);
+ } catch (IOException ex) {
+ logger.log(Level.SEVERE, "exception occurred when loading the file: {0}", ex.getMessage());
+ throw new IllegalArgumentException(ex);
+ }
+ return result;
+ }
+
+ public static InputStream readFile(String fileName) {
+ try {
+ return new FileInputStream(fileName);
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Function to open a JFileChooser and set it properly.
+ *
+ * @return a File object if one has been chosen. Null otherwise.
+ */
+ public static File selectFile(final int openMode, final String title, final String buttonText, final String lastDirectoryUsed, final Component parent, final String suffix, final String description) {
+ JFileChooser chooser = new JFileChooser(lastDirectoryUsed);
+ chooser.setFileHidingEnabled(false);
+ chooser.setDialogTitle(title);
+ chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory()) {
+ return true;
+ }
+ return pathname.getName().endsWith(suffix);
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+ });
+
+ int returnVal = chooser.showDialog(parent, buttonText);
+ if (returnVal != JFileChooser.APPROVE_OPTION) {
+ return null;
+ }
+ return chooser.getSelectedFile();
+ }
+
+ public static InputStream getResourceOrFile(String fileName) throws IllegalArgumentException {
+ InputStream result = FilesUtils.class.getResourceAsStream(fileName);
+ if (result == null) {
+ try {
+ result = new FileInputStream(fileName);
+ } catch (FileNotFoundException ex) {
+ }
+ }
+ if (result == null) {
+ throw new IllegalArgumentException(fileName + " not found.");
+ }
+ return result;
+ }
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/utils/StopWatch.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/utils/StopWatch.java
new file mode 100644
index 0000000000..b79a5a019e
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/semantic/utils/StopWatch.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+package fr.inria.edelweiss.semantic.utils;
+
+/**
+ *
+ * @author Erwan Demairy
+ */
+public class StopWatch {
+
+ private long start;
+
+ public StopWatch() {
+ start = java.lang.System.currentTimeMillis();
+ }
+
+ public long elapsedMillis() {
+ long end = java.lang.System.currentTimeMillis();
+ return end-start;
+ }
+}
diff --git a/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/sparql/DriverParametersPanel.java b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/sparql/DriverParametersPanel.java
new file mode 100644
index 0000000000..d644863cf8
--- /dev/null
+++ b/modules/SemanticWebImport/src/main/java/fr/inria/edelweiss/sparql/DriverParametersPanel.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2011, INRIA
+ * All rights reserved.
+ */
+package fr.inria.edelweiss.sparql;
+
+import java.util.Observer;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author Erwan Demairy
+ */
+public abstract class DriverParametersPanel