Commit a5d44cfc authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Working on commands/ CyRest

parent cbe813f9
......@@ -39,15 +39,22 @@ import org.cytoscape.view.presentation.RenderingEngineFactory;
import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
import org.cytoscape.view.vizmap.VisualMappingManager;
import org.cytoscape.view.vizmap.VisualStyleFactory;
import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.swing.DialogTaskManager;
import org.osgi.framework.BundleContext;
import static org.cytoscape.work.ServiceProperties.COMMAND;
import static org.cytoscape.work.ServiceProperties.COMMAND_DESCRIPTION;
import de.hhu.ba.yoshikoWrapper.core.ConfigurationManager;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.core.YoshUtil;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.swing.components.MainPanel;
import de.hhu.ba.yoshikoWrapper.taskFactories.CommandTaskFactory;
import de.hhu.ba.yoshikoWrapper.taskFactories.YoshikoCommand;
/**
* Entry point for the application as required by the Cytoscape API
......@@ -55,13 +62,15 @@ import de.hhu.ba.yoshikoWrapper.swing.components.MainPanel;
*/
public class CyActivator extends AbstractCyActivator {
private static final String COMMAND_NAMESPACE = "yoshiko";
public CyActivator() {
super();
}
@Override
public void start(BundleContext context) throws Exception {
//Initialize cytoscape configuration system
//Initialize Cytoscape configuration system
//This is responsible for saving/loading configuration
ConfigurationManager cm = new ConfigurationManager("yoshikoWrapper", "yoshiko.props");
Properties propsReaderServiceProps = new Properties();
......@@ -83,17 +92,18 @@ public class CyActivator extends AbstractCyActivator {
CyCore.visualStyleFactory = getService(context,VisualStyleFactory.class);
CyCore.continuousMappingFactory = getService(context,VisualMappingFunctionFactory.class, "(mapping.type=continuous)");
CyCore.rootNetworkManager = getService(context,CyRootNetworkManager.class);
//Not sure how to correctly infer arguments here
//TODO: Not sure how to correctly infer arguments here
CyCore.renderingEngineFactory = getService(context,RenderingEngineFactory.class);
CyCore.cloneNetworkTaskFactory = getService(context,CloneNetworkTaskFactory.class);
//Store a reference to the Version
//Store a reference to the Version for easier access
YoshUtil.version = context.getBundle().getVersion();
//Set language according to settings -> Default to enUS
LocalizationManager.switchLanguage(cm.getProperties().getProperty("locale", "enUS"));
//Attempt to find the yoshiko lib in a previously stored location and load it
//Attempt to find the Yoshiko lib in a previously stored location and load it
//TODO: Move into a separate handler to keep CyActivator clean
if (!YoshikoLoader.isLibraryLoaded()){
String pathToYosh = cm.getProperties().getProperty("pathToYoshiko");
if (pathToYosh != null && pathToYosh != "null") {
......@@ -101,12 +111,20 @@ public class CyActivator extends AbstractCyActivator {
}
}
//Register commands / CyRest
TaskFactory commandTaskFactory = new CommandTaskFactory(YoshikoCommand.PERFORM_ALGORITHM);
Properties props = new Properties();
props.setProperty(COMMAND_NAMESPACE, "yoshiko");
props.setProperty(COMMAND, YoshikoCommand.PERFORM_ALGORITHM.toString());
props.setProperty(COMMAND_DESCRIPTION,"TEST PERFORM ALGORITHM");
registerService(context, commandTaskFactory, TaskFactory.class, props);
//Initialize and register main panel
MainPanel mainPanel = new MainPanel();
registerService(context,mainPanel,CytoPanelComponent.class, new Properties());
}
}
}
\ No newline at end of file
/*******************************************************************************
* Copyright (C) 2017 Philipp Spohr
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
......@@ -29,19 +29,21 @@ import org.cytoscape.util.swing.BasicCollapsiblePanel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.swing.components.LanguageSwitcher;
public class LanguageSwitcherPanelFactory{
public static BasicCollapsiblePanel createLanguageSwitcherPanel() {
@SuppressWarnings("serial")
public class LanguageSwitcherPanel extends BasicCollapsiblePanel{
public LanguageSwitcherPanel() {
super(LocalizationManager.get("switchLanguage"));
final LanguageSwitcher switcher;
final BasicCollapsiblePanel ret = new BasicCollapsiblePanel(LocalizationManager.get("switchLanguage"));
ret.getContentPane().setLayout(new BoxLayout(ret.getContentPane(),BoxLayout.X_AXIS));
//final BasicCollapsiblePanel ret = new BasicCollapsiblePanel();
getContentPane().setLayout(new BoxLayout(getContentPane(),BoxLayout.X_AXIS));
//SWING COMPONENTS INIT
switcher = new LanguageSwitcher();
SwingUtil.addAll(ret,
SwingUtil.addAll(this,
switcher
);
return ret;
}
}
......@@ -44,6 +44,11 @@ import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.swing.EnableWhenSelectedListener;
import de.hhu.ba.yoshikoWrapper.swing.SwingUtil;
/**
*
* @author Philipp Spohr, Nov 30, 2017
*
*/
@SuppressWarnings("serial") //will never be serialized
public class ColumnMapper extends JPanel
implements //everything
......@@ -208,24 +213,36 @@ SetCurrentNetworkListener
@Override
public void handleEvent(ColumnDeletedEvent e) {
if (
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultEdgeTable() ||
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultNetworkTable()
)
{
updateValues();
try {
if (
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultEdgeTable() ||
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultNetworkTable()
)
{
updateValues();
}
}
catch (Exception ex) {
//TODO:
}
}
@Override
public void handleEvent(ColumnCreatedEvent e) {
if (
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultEdgeTable() ||
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultNetworkTable()
)
{
updateValues();
try {
if (
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultEdgeTable() ||
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultNetworkTable()
)
{
updateValues();
}
}
catch (Exception ex) {
//TODO:
}
}
public CyColumn getEditingCostColumn() {
......
......@@ -59,7 +59,7 @@ import de.hhu.ba.yoshikoWrapper.core.ParameterSet;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.swing.AboutDialogFactory;
import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.swing.LanguageSwitcherPanelFactory;
import de.hhu.ba.yoshikoWrapper.swing.LanguageSwitcherPanel;
import de.hhu.ba.yoshikoWrapper.swing.LibraryPanelFactory;
import de.hhu.ba.yoshikoWrapper.swing.SwingUtil;
import de.hhu.ba.yoshikoWrapper.tasks.AlgorithmTask;
......@@ -125,7 +125,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
langPanel = LanguageSwitcherPanelFactory.createLanguageSwitcherPanel();
langPanel = new LanguageSwitcherPanel();
libraryPanel = LibraryPanelFactory.createLibraryPanel();
//If no library is loaded yet the obvious panel should be showing up
......
package de.hhu.ba.yoshikoWrapper.taskFactories;
import org.cytoscape.work.AbstractTaskFactory;
import org.cytoscape.work.TaskIterator;
import de.hhu.ba.yoshikoWrapper.tasks.AlgorithmTask;
public class CommandTaskFactory extends AbstractTaskFactory{
private final YoshikoCommand command;
/**
* Default constructor
*/
public CommandTaskFactory(YoshikoCommand command) {
super();
this.command = command;
}
@Override
public TaskIterator createTaskIterator() {
//We simply switch between the possible commands
if (command == YoshikoCommand.CREATE_CLUSTER_VIEW) {
return null;
}
else if (command == YoshikoCommand.CREATE_META_GRAPH) {
return null;
}
else if (command == YoshikoCommand.PERFORM_ALGORITHM) {
return new TaskIterator(
new AlgorithmTask(
null,
null,
null
)
);
}
else return null; //TODO: Might be useful to generate an error/ throw an exception here as this should never be invoked
}
public boolean isReady () { return true; } //TODO: Think about when that would actually make sense / prevent launching of multiple tasks
}
package de.hhu.ba.yoshikoWrapper.taskFactories;
/**
* Describes commands for the Yoshiko App that can be invoked via REST/CyREST
* @author Philipp Spohr, Nov 30, 2017
*
*/
public enum YoshikoCommand {
/**
* Creates a CV for a given Cluster found in a result
*/
CREATE_CLUSTER_VIEW,
CREATE_META_GRAPH,
PERFORM_ALGORITHM
}
/**
*
*/
/**
* @author Philipp Spohr, Nov 30, 2017
*
*/
package de.hhu.ba.yoshikoWrapper.taskFactories;
\ No newline at end of file
......@@ -32,6 +32,7 @@ import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
import org.cytoscape.work.AbstractTask;
import org.cytoscape.work.TaskMonitor;
import org.cytoscape.work.Tunable;
import org.slf4j.Logger;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
......@@ -54,17 +55,23 @@ import de.hhu.ba.yoshikoWrapper.swing.components.ResultPanel;
public class AlgorithmTask extends AbstractTask {
private String SOLUTION_COLUMN_PREFIX = "yoshikoSolution_";
//Constants
private static final String SOLUTION_COLUMN_PREFIX = "yoshikoSolution_"; //TODO: Make customizable?
//Symbolic links
private static Logger logger = YoshikoLogger.getInstance().getLogger();
private Window statusWindow;
private final Window statusWindow; //TODO: Make tunable?
//Parameters
@Tunable(description="Parameter Set determining the operation mode for Yoshiko", context="nogui")
private final ParameterSet parameterSet;
@Tunable(description="Network to analyze for clusters", context="nogui")
private final CyNetwork net;
//Temps, need to be freed in C++
//Temps, pointing to and need to be freed in C++
private LibraryInput input;
private ClusterEditingSolutions result;
private CoreAlgorithm ca;
......
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