From 49dbfa2c6ddcba5339363d82a110f4d3854c462a Mon Sep 17 00:00:00 2001 From: Philipp Spohr <spohr.philipp@web.de> Date: Sun, 13 Aug 2017 18:20:13 +0200 Subject: [PATCH] preparing for time limit and generic argument passing --- .../java/de/hhu/ba/yoshikoWrapper/core/Core.java | 7 +++---- .../de/hhu/ba/yoshikoWrapper/gui/MainPanel.java | 15 +++++---------- .../ba/yoshikoWrapper/gui/NumberInputField.java | 3 +++ .../ba/yoshikoWrapper/gui/TimeLimitSetter.java | 3 ++- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/Core.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/Core.java index 04a3c68..6a18e92 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/Core.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/Core.java @@ -1,7 +1,4 @@ package de.hhu.ba.yoshikoWrapper.core; - -import java.util.HashMap; - //TODO: ADD LOGGER SYSTEM import org.cytoscape.application.CyApplicationManager; @@ -21,12 +18,14 @@ public class Core { cy = cyApplicationManager; } - public static void performYoshiko() { + public static void performYoshiko(int timeLimit) { CyNetwork currentNetwork = cy.getCurrentNetwork(); if (currentNetwork == null) { //TODO } + LibraryInterface.setTimeLimit(timeLimit); + NodeMap nodeMap = new NodeMap(currentNetwork); SWIGTYPE_p_yskInput__LibraryInput input = NetworkParser.parseNetwork(currentNetwork,nodeMap); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java index 9a817bd..6a4a110 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java @@ -3,26 +3,19 @@ package de.hhu.ba.yoshikoWrapper.gui; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.HashMap; +import javax.swing.BoxLayout; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; import org.cytoscape.application.swing.CytoPanelComponent; import org.cytoscape.application.swing.CytoPanelName; -import org.cytoscape.model.CyNode; - import de.hhu.ba.yoshikoWrapper.core.Core; -import de.hhu.ba.yoshikoWrapper.core.NetworkParser; -import de.hhu.ba.yoshikoWrapper.core.NodeMap; import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; -import de.hhu.ba.yoshikoWrapper.gui.TimeLimitSetter; +import de.hhu.ba.yoshikoWrapper.gui.*; import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface; -import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_yskInput__LibraryInput; -import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_ysk__ClusterEditingSolutions; /**This class describes the Swing Panel that the user interacts with in cytoscape * @author Philipp Spohr, Aug 6, 2017 @@ -50,6 +43,8 @@ public class MainPanel extends JPanel implements CytoPanelComponent { */ public MainPanel() { + + this.setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS)); //SWING COMPONENT INITIALIZATION libStatusPanel = new LibStatusPanel(); @@ -83,7 +78,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent { @Override public void actionPerformed(ActionEvent e) { if (yoshikoLoader.isLibraryLoaded()){ - Core.performYoshiko(); + Core.performYoshiko(timeLimitSetter.getTimeLimit()); } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/NumberInputField.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/NumberInputField.java index c876695..dfd8065 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/NumberInputField.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/NumberInputField.java @@ -20,4 +20,7 @@ public class NumberInputField extends JFormattedTextField{ super(FormatHelper.getIntegerFormatter()); } + public int getTimeLimit() { + return Integer.parseInt(getText()); + } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java index 7bb6cb5..1c8a3a8 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java @@ -20,6 +20,7 @@ public class TimeLimitSetter extends JPanel{ checkBox = new JCheckBox(); numberField = new NumberInputField(); numberField.setEnabled(false); //By default time limit is turned off + numberField.setSize(40, 10); checkBox.addActionListener( new ActionListener() { @@ -39,7 +40,7 @@ public class TimeLimitSetter extends JPanel{ if (checkBox.isSelected()) { return -1; } - return (int)numberField.getValue(); + return numberField.getTimeLimit(); } } -- GitLab