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

some basic work on implementing time limit

parent e8d3a88e
No related branches found
No related tags found
No related merge requests found
package de.hhu.ba.yoshikoWrapper.gui;
import java.text.NumberFormat;
import javax.swing.text.NumberFormatter;
public class FormatHelper {
public static NumberFormatter getIntegerFormatter() {
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setMaximum(Integer.MAX_VALUE);
formatter.setAllowsInvalid(false);
formatter.setCommitsOnValidEdit(true);
return formatter;
}
}
...@@ -19,6 +19,7 @@ import de.hhu.ba.yoshikoWrapper.core.Core; ...@@ -19,6 +19,7 @@ import de.hhu.ba.yoshikoWrapper.core.Core;
import de.hhu.ba.yoshikoWrapper.core.NetworkParser; import de.hhu.ba.yoshikoWrapper.core.NetworkParser;
import de.hhu.ba.yoshikoWrapper.core.NodeMap; import de.hhu.ba.yoshikoWrapper.core.NodeMap;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.gui.TimeLimitSetter;
import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface; 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_yskInput__LibraryInput;
import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_ysk__ClusterEditingSolutions; import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_ysk__ClusterEditingSolutions;
...@@ -42,6 +43,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -42,6 +43,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
private LibStatusPanel libStatusPanel; private LibStatusPanel libStatusPanel;
private JButton searchLibButton; private JButton searchLibButton;
private JLabel yoshikoVersionLabel; private JLabel yoshikoVersionLabel;
private TimeLimitSetter timeLimitSetter;
/** /**
* Main constructor, creates a new Panel and initializes subcomponents * Main constructor, creates a new Panel and initializes subcomponents
...@@ -91,6 +93,9 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -91,6 +93,9 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
// //
// //
// //
timeLimitSetter = new TimeLimitSetter();
this.add(timeLimitSetter);
yoshikoVersionLabel = new JLabel("YOSHIKO VERSION"); yoshikoVersionLabel = new JLabel("YOSHIKO VERSION");
this.add(yoshikoVersionLabel); this.add(yoshikoVersionLabel);
......
package de.hhu.ba.yoshikoWrapper.gui;
import java.text.NumberFormat;
import javax.swing.JFormattedTextField;
import javax.swing.text.NumberFormatter;
/**
* Provides a more strict input field that only accepts integers
*/
public class NumberInputField extends JFormattedTextField{
/**
* SerialVersionUID
*/
private static final long serialVersionUID = -1144461027491991050L;
public NumberInputField() {
super(FormatHelper.getIntegerFormatter());
}
}
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
public class TimeLimitSetter extends JPanel{
/**
* Unique UID for serialization
*/
private static final long serialVersionUID = 6617497954814566334L;
private JCheckBox checkBox;
private NumberInputField numberField;
public TimeLimitSetter() {
checkBox = new JCheckBox();
numberField = new NumberInputField();
numberField.setEnabled(false); //By default time limit is turned off
checkBox.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
numberField.setEnabled(checkBox.isSelected());
}
}
);
//REGISTER COMPONENTS
this.add(checkBox);
this.add(numberField);
}
public int getTimeLimit() {
if (checkBox.isSelected()) {
return -1;
}
return (int)numberField.getValue();
}
}
...@@ -114,4 +114,8 @@ public class LibraryInterface { ...@@ -114,4 +114,8 @@ public class LibraryInterface {
return (cPtr == 0) ? null : new SWIGTYPE_p_ysk__ClusterEditingSolutions(cPtr, false); return (cPtr == 0) ? null : new SWIGTYPE_p_ysk__ClusterEditingSolutions(cPtr, false);
} }
public static void setTimeLimit(int limit) {
LibraryInterfaceJNI.setTimeLimit(limit);
}
} }
...@@ -34,4 +34,5 @@ public class LibraryInterfaceJNI { ...@@ -34,4 +34,5 @@ public class LibraryInterfaceJNI {
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 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 String getVersionString();
public final static native long processLibraryInput(long jarg1); public final static native long processLibraryInput(long jarg1);
public final static native void setTimeLimit(int jarg1);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment