Skip to content
Snippets Groups Projects
Commit f1853e5d authored by Philipp Spohr's avatar Philipp Spohr
Browse files

updated for latest yoshiko

parent 2e3eadf3
No related branches found
No related tags found
No related merge requests found
......@@ -2,12 +2,14 @@ package de.hhu.ba.yoshikoWrapper;
import java.util.Properties;
import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.application.swing.CyAction;
import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.service.util.AbstractCyActivator;
import org.osgi.framework.BundleContext;
import de.hhu.ba.yoshikoWrapper.core.GraphParser;
import de.hhu.ba.yoshikoWrapper.gui.MainPanel;
import de.hhu.ba.yoshikoWrapper.gui.MainPanelAction;
......@@ -21,6 +23,9 @@ public class CyActivator extends AbstractCyActivator {
@Override
public void start(BundleContext context) throws Exception {
//TODO: Load shared library if installed on startup
CyApplicationManager cyApplicationManager = getService(context, CyApplicationManager.class);
GraphParser.registerApplicationManager(cyApplicationManager);
CySwingApplication cytoscapeDesktopService = getService(context,CySwingApplication.class);
MainPanel mainPanel = new MainPanel();
......
package de.hhu.ba.yoshikoWrapper.core;
import java.util.List;
import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableUtil;
import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface;
import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_yskInput__LibraryInput;
public class GraphParser {
private static CyApplicationManager cy;
//**TODO MAKE DYNAMIC
private static String weightIndex = "weight";
public static SWIGTYPE_p_yskInput__LibraryInput parseGraph() {
if (cy == null) {
//TODO:
}
SWIGTYPE_p_yskInput__LibraryInput generatedInput = LibraryInterface.new_LibraryInput();
CyNetwork net = cy.getCurrentNetwork();
if (net != null){
LibraryInterface.LibraryInput_setSize(generatedInput, net.getNodeCount());
List<CyEdge> edges = net.getEdgeList();
CyTable edgeTable = net.getDefaultEdgeTable();
for (CyEdge e : edges) {
LibraryInterface.LibraryInput_addEdge(
generatedInput,
(e.getSource().getSUID()),
(e.getTarget().getSUID()),
0.0
);
}
}
return generatedInput;
}
public static void registerApplicationManager(CyApplicationManager cyApplicationManager) {
cy = cyApplicationManager;
}
}
......@@ -19,14 +19,28 @@ public class YoshikoLoader {
}
public void loadLibrary() {
if (libraryLoaded) {
return;
}
try {
System.loadLibrary("libyoshikoLibrary");
}
catch (Exception e) {
e.printStackTrace();
}
}
public void loadLibrary(String libPath) {
//TODO: IF ALREADY LOADED DON'T LOAD AGAIN!!!!
if (libraryLoaded) {
return;
}
try {
System.load(libPath);
libraryLoaded = true;
}
catch(UnsatisfiedLinkError e) {
System.out.print(System.getProperty("java.version")+System.getProperty("sun.arch.data.model"));
e.printStackTrace();
libraryLoaded = false;
}
......
......@@ -13,6 +13,7 @@ import javax.swing.JPanel;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
import de.hhu.ba.yoshikoWrapper.core.GraphParser;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface;
import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_yskInput__LibraryInput;
......@@ -76,25 +77,8 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
@Override
public void actionPerformed(ActionEvent e) {
if (yoshikoLoader.isLibraryLoaded()){
SWIGTYPE_p_yskInput__LibraryInput instance;
instance = LibraryInterface.new_LibraryInput();
LibraryInterface.LibraryInput_setSize(instance, 4);
LibraryInterface.LibraryInput_addEdge(instance, 0, 1, 2);
LibraryInterface.LibraryInput_addEdge(instance, 1, 3, 5);
SWIGTYPE_p_ysk__ClusterEditingSolutions solutions = LibraryInterface.processLibraryInput(instance);
long numberOfSolutions = LibraryInterface.ClusterEditingSolutions_getNumberOfSolutions(solutions);
double totalCost = LibraryInterface.ClusterEditingSolutions_getTotalCost(solutions);
System.out.println();
JOptionPane.showMessageDialog(
self,
"YOSHIKO FOUND "+numberOfSolutions+" solutions!\n"+
"YOSHIKO PAID THE CRUEL PRIZE OF: "+totalCost+"\n"
);
//IMPORTANT: DESTROY STUFF
LibraryInterface.delete_LibraryInput(instance);
LibraryInterface.delete_ClusterEditingSolutions(solutions);
SWIGTYPE_p_yskInput__LibraryInput input = GraphParser.parseGraph();
LibraryInterface.delete_LibraryInput(input);
}
}
......
......@@ -47,12 +47,16 @@ public class LibraryInterface {
LibraryInterfaceJNI.delete_LibraryInput(SWIGTYPE_p_yskInput__LibraryInput.getCPtr(self));
}
public static void LibraryInput_setSize(SWIGTYPE_p_yskInput__LibraryInput self, int id) {
public static void LibraryInput_setSize(SWIGTYPE_p_yskInput__LibraryInput self, long id) {
LibraryInterfaceJNI.LibraryInput_setSize(SWIGTYPE_p_yskInput__LibraryInput.getCPtr(self), id);
}
public static void LibraryInput_addEdge(SWIGTYPE_p_yskInput__LibraryInput self, int sourceID, int targetID, double cost, EdgeType edgeType) {
LibraryInterfaceJNI.LibraryInput_addEdge(SWIGTYPE_p_yskInput__LibraryInput.getCPtr(self), sourceID, targetID, cost, edgeType.swigValue());
public static void LibraryInput_addEdge(SWIGTYPE_p_yskInput__LibraryInput self, long sourceID, long targetID, double cost) {
LibraryInterfaceJNI.LibraryInput_addEdge__SWIG_0(SWIGTYPE_p_yskInput__LibraryInput.getCPtr(self), sourceID, targetID, cost);
}
public static void LibraryInput_addEdge(SWIGTYPE_p_yskInput__LibraryInput self, long sourceID, long targetID, double cost, boolean permanent, boolean forbidden) {
LibraryInterfaceJNI.LibraryInput_addEdge__SWIG_1(SWIGTYPE_p_yskInput__LibraryInput.getCPtr(self), sourceID, targetID, cost, permanent, forbidden);
}
public static String getVersionString() {
......
......@@ -18,8 +18,9 @@ public class LibraryInterfaceJNI {
public final static native void delete_ClusterEditingSolutions(long jarg1);
public final static native long new_LibraryInput();
public final static native void delete_LibraryInput(long jarg1);
public final static native void LibraryInput_setSize(long jarg1, int jarg2);
public final static native void LibraryInput_addEdge(long jarg1, int jarg2, int jarg3, double jarg4, int jarg5);
public final static native void LibraryInput_setSize(long jarg1, long jarg2);
public final static native void LibraryInput_addEdge__SWIG_0(long jarg1, long jarg2, long jarg3, double jarg4);
public final static native void LibraryInput_addEdge__SWIG_1(long jarg1, long jarg2, long jarg3, double jarg4, boolean jarg5, boolean jarg6);
public final static native String getVersionString();
public final static native long processLibraryInput(long jarg1);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment