Skip to content
Snippets Groups Projects
Commit 28680c05 authored by Porrmann, Maik's avatar Porrmann, Maik
Browse files

bugfixes

parent e82337c4
Branches master
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
......
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8
......@@ -87,8 +87,8 @@
</dependency>
</dependencies>
<properties>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
......@@ -15,8 +15,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
......
......@@ -6,19 +6,20 @@ import mp.Model.Model;
import mp.View.*;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import javax.swing.SwingUtilities;
public class App
{
public static void main( String[] args )
public static void main( String[] args ) throws InvocationTargetException, InterruptedException
{
SwingUtilities.invokeLater(new Runnable() {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
Model surface = new Model();
surface.addCurve("curve1");
surface.addCurve("curve3");
surface.addCurve("curve2");
Controller controller = new Controller(surface);
try{
controller.loadSettings("Settings.json");
......
package mp.Controller;
import mp.Model.*;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
......@@ -16,6 +18,7 @@ import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
......@@ -42,6 +45,15 @@ public class Controller implements ActionListener, FocusListener{
loadSettings(f);
}
public PathSettings getSettings(){return pathSettings;}
public void setPathSettings(PathSettings newSettings){
if(newSettings != null){
throw new NullPointerException();
}
pathSettings = newSettings;
}
public String getPathToExecutable(){
if (pathSettings == null)
......@@ -136,7 +148,7 @@ public class Controller implements ActionListener, FocusListener{
else if (p instanceof NumericParameter<?>){
Object s = act.getSource();
if (s instanceof JTextField) {
((NumericParameter) p).setValueFromString(((JTextField) s).getText());
((NumericParameter<?>) p).setValueFromString(((JTextField) s).getText());
} else
throw new UnsupportedOperationException();
......@@ -144,7 +156,7 @@ public class Controller implements ActionListener, FocusListener{
else if (p instanceof OptionParameter){
Object s = act.getSource();
if (s instanceof JComboBox){
((OptionParameter)p).choose(((JComboBox)s).getSelectedIndex());
((OptionParameter)p).choose(((JComboBox<?>)s).getSelectedIndex());
} else
throw new UnsupportedOperationException();
......@@ -160,14 +172,14 @@ public class Controller implements ActionListener, FocusListener{
model.writeFile(getPathToInitFile());
File initFile = new File(getPathToInitFile());
JDialog dialog = new JDialog(frame, "Waiting for processes to finish");
dialog.setBounds(100, 100, 300, 300);
JPanel panel = new JPanel();
JLabel label = new JLabel("Creating Curves");
panel.add(label);
dialog.add(panel);
dialog.setVisible(true);
Object[] options = { "Create Surface", "Cancel!" };
int n = JOptionPane.showOptionDialog(frame, "Create Surface with this parameterset? This might take a while", "Confirm surface creation",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, // do not use a custom Icon
options, // the titles of buttons
options[0]); // default button title
if (n == 1)
return;
// call elasticSurface
try{
File curveDir = new File(userDir+"/curves");
......@@ -196,7 +208,6 @@ public class Controller implements ActionListener, FocusListener{
}
// converting vtp file
label.setText("Running conversion script");
try {
......@@ -212,7 +223,6 @@ public class Controller implements ActionListener, FocusListener{
label.setText("Merging Curves into surface");
// call mergeFiles
try {
String surfaceName =userDir + "/surfaces/"
......@@ -256,8 +266,12 @@ public class Controller implements ActionListener, FocusListener{
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
dialog.dispose();
int n2 = JOptionPane.showConfirmDialog(frame, "Finished creation of surface. View it in paraview?",
"Finished!", JOptionPane.YES_NO_OPTION);
if (n2 == 0)
viewSurface();
}
public void viewSurface(){
......
......@@ -2,7 +2,6 @@ package mp.Controller;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import com.fasterxml.jackson.databind.ObjectMapper;
......
......@@ -33,6 +33,8 @@ public class ParameterGroup extends Parameters {
}
public String getDescription(){ return description;}
public Hashtable<String,String> getEntrys(){
Hashtable<String,String> table = new Hashtable<>();
......
......@@ -5,9 +5,11 @@ import java.util.Arrays;
public class ParameterGroupBuilder {
static public ParameterGroup buildSettings(){
ParameterGroup settings = new ParameterGroup("General", "General settings that apply to all curves");
settings.list.add(new IntegerParameter("numberOfElements",40));
settings.list.add(new IntegerParameter("numberOfElements",40, "Number of points that will make up the curve. Should be between 40 and 200 to limit computation time"));
settings.list.add(new IntegerParameter("numberOfTimesteps", 100, "Number of snapshots of evolution"));
settings.list.add(new StringParameter("UserDirectory", "Output"));
settings.list.add(new StringParameter("SurfaceName", "surface"));
settings.list.add(new StringParameter("SurfaceName", "evolution"));
File dataFiles = new File( "DataFiles");
settings.list.add(new StringParameter("DataFileDirectory",dataFiles.getAbsolutePath()));
return settings;
......@@ -17,11 +19,10 @@ public class ParameterGroupBuilder {
ParameterGroup curve = new ParameterGroup(name);
curve.list.add(new OptionParameter("boundaryConditions",
Arrays.asList(new Option("periodic", "Periodic curve."),
new Option("dirichlet","Curve has on fixed point.")),0));
new Option("dirichlet","Curve has on fixed point.")),0, "You should stay with periodic."));
curve.list.add(new BooleanParameter("selfAvoidance", false,"Curve avoid selfintersections. Drastically increases computation time!!"));
curve.list.add(new DoubleParameter("tStart", 0., "Start of virtual timeline"));
curve.list.add(new DoubleParameter("tEnd", 1., "End of virtual timeline"));
curve.list.add(new IntegerParameter("numberOfTimesteps",100, "Number of snapshots of evolution"));
curve.list.add(new OptionParameter("initialCurve",
Arrays.asList( new Option("trefoilKnot","Simplest nontrivial Knot"),
new Option("pringles", "Simple knot that resembles the shape of crisps"),
......@@ -30,22 +31,25 @@ public class ParameterGroupBuilder {
new Option("compoundQuadrupleKnot", "Complex, flowerlike knot"),
new Option("FigureEightInner", "First variation of the Figure Eight knot"),
new Option("FigureEightOuter", "Second variation of the Figure Eight knot"),
new Option("trigParametrization", "Complex formula that allows parametrization of 10 variables."+System.lineSeparator()+
"x = m * cos(p * x) + n * cos(q * x) + o * cos(r * x)"+System.lineSeparator()+
"y = m * sin(p * x) + n * sin(q * x) + o * cos (r * x)"+System.lineSeparator()+
"z = h * sin(s * x) + g * sin(t * x)")),
new Option("trigParametrization", "<html>Complex formula that allows parametrization of 10 variables.<br>"+
"x = m * cos(p * x) + n * cos(q * x) + o * cos(r * x)<br>"+
"y = m * sin(p * x) + n * sin(q * x) + o * cos (r * x)<br>"+
"z = h * sin(s * x) + g * sin(t * x)</html>")),
0, "Determines type of initial curve"));
ParameterGroup trig = new ParameterGroup("trigParametrization");
trig.list.add(new DoubleParameter("m",1.,"Variable 'm' for above formula"));
trig.list.add(new DoubleParameter("n",1.,"Variable 'n' for above formula"));
trig.list.add(new DoubleParameter("o",1.,"Variable 'o' for above formula"));
trig.list.add(new DoubleParameter("h",1.,"Variable 'h' for above formula"));
trig.list.add(new DoubleParameter("g",1.,"Variable 'g' for above formula"));
trig.list.add(new DoubleParameter("p",1.,"Variable 'p' for above formula"));
trig.list.add(new DoubleParameter("q",1.,"Variable 'q' for above formula"));
trig.list.add(new DoubleParameter("r",1.,"Variable 'r' for above formula"));
trig.list.add(new DoubleParameter("s",1.,"Variable 's' for above formula"));
trig.list.add(new DoubleParameter("t",1.,"Variable 't' for above formula"));
ParameterGroup trig = new ParameterGroup("trigParametrization", "<html>Only used if initialCurve is set to trigparametrization<br>Complex formula that allows parametrization of 10 variables.<br>"
+ "x = m * cos(p * x) + n * cos(q * x) + o * cos(r * x)<br>"
+ "y = m * sin(p * x) + n * sin(q * x) + o * cos (r * x)<br>"
+ "z = h * sin(s * x) + g * sin(t * x)</html>");
trig.list.add(new DoubleParameter("m",1.,"Variable 'm' for formula. See tooltip of <trigParametrization>"));
trig.list.add(new DoubleParameter("n",1.,"Variable 'n' for formula. See tooltip of <trigParametrization>"));
trig.list.add(new DoubleParameter("o",1.,"Variable 'o' for formula. See tooltip of <trigParametrization>"));
trig.list.add(new DoubleParameter("h",1.,"Variable 'h' for formula. See tooltip of <trigParametrization>"));
trig.list.add(new DoubleParameter("g",1.,"Variable 'g' for formula. See tooltip of <trigParametrization>"));
trig.list.add(new DoubleParameter("p",1.,"Variable 'p' for formula. See tooltip of <trigParametrization>"));
trig.list.add(new DoubleParameter("q",1.,"Variable 'q' for formula. See tooltip of <trigParametrization>"));
trig.list.add(new DoubleParameter("r",1.,"Variable 'r' for formula. See tooltip of <trigParametrization>"));
trig.list.add(new DoubleParameter("s",1.,"Variable 's' for formula. See tooltip of <trigParametrization>"));
trig.list.add(new DoubleParameter("t",1.,"Variable 't' for formula. See tooltip of <trigParametrization>"));
curve.list.add(trig);
curve.list.add(new OptionParameter("velocity",
......@@ -74,7 +78,7 @@ public class ParameterGroupBuilder {
velocity.list.add(new BooleanParameter("shift", false,"Shift velocity by time t, i.e. v(x) -> v(x+t)"));
curve.list.add(velocity);
ParameterGroup gaussian = new ParameterGroup("gaussian", "Parameters specifying velocity. Ignored for other velocities.");
ParameterGroup gaussian = new ParameterGroup("gaussian", "Parameters specifying gaussian velocity. Ignored for other velocities.");
gaussian.list.add(new DoubleParameter("expectedShift",1.,"Expectation of movement of point 'x'"));
gaussian.list.add(new DoubleParameter("varianceShift",1.,"Variance of movement of point 'x'"));
gaussian.list.add(new DoubleParameter("sigmaValues", 1.,"determines width of value distribution around point x"));
......
......@@ -4,9 +4,9 @@ import javax.swing.*;
import javax.swing.plaf.basic.BasicComboBoxRenderer;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Component;
import java.util.TimerTask;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import mp.Controller.Controller;
import mp.Model.*;
......@@ -17,7 +17,6 @@ public class View extends JFrame{
private static final long serialVersionUID = 5888598105780137807L;
private Model model;
private static final int SPACING = 10;
private JPanel pnlSettings;
private JTabbedPane pnlContent;
private Controller controller;
......@@ -33,14 +32,36 @@ public class View extends JFrame{
bigPanel.add(pnlContent);
JPanel actionPanel = new JPanel();
// Create Buttons
JButton btnRun = new JButton("Create surface");
btnRun.setActionCommand("RUN");
btnRun.addActionListener(controller);
JButton btnView = new JButton("View last surface");
btnView.setActionCommand("VIEW");
btnView.addActionListener(controller);
JButton btnAddCurve = new JButton("Add another Curve");
btnAddCurve.setActionCommand("ADDCURVE");;
// btnAddCurve.addActionListener(controller);
btnAddCurve.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent event) {
String newName = JOptionPane.showInputDialog(actionPanel, "Enter name for new curve");
try{
model.addCurve(newName);
update();
}
catch (IllegalArgumentException e){
JOptionPane.showMessageDialog(actionPanel, "There is already a curve with name " + newName);
}
}
});
// Add buttons
actionPanel.add(btnRun);
actionPanel.add(btnView);
actionPanel.add(btnAddCurve);
bigPanel.add(actionPanel);
setContentPane(bigPanel);
......@@ -67,7 +88,10 @@ public class View extends JFrame{
}
public void update(){
pnlContent.removeAll();
pnlContent.revalidate();
pnlContent.repaint();
pnlSettings = new JPanel();
pnlSettings.setLayout(new BoxLayout(pnlSettings,BoxLayout.Y_AXIS));
pnlContent.add("General Settings", pnlSettings);
......@@ -94,12 +118,18 @@ public class View extends JFrame{
newpanel.setLayout(new BoxLayout(newpanel, BoxLayout.Y_AXIS));
panel.add(newpanel);
newpanel.setBorder(BorderFactory.createTitledBorder(param.getKey()));
JPanel desPnl = new JPanel();
JLabel tf = new JLabel(param.getDescription());
desPnl.add(tf);
newpanel.add(desPnl);
for (Parameters p : ((ParameterGroup)param).list){
addParameter(p, newpanel, mergeKeypath(keypath, param.getKey()), strut + 20);
}
}
else {
JPanel newpanel = new JPanel();
Dimension dim = new Dimension(400, 30);
newpanel.setLayout(new BoxLayout(newpanel, BoxLayout.LINE_AXIS));
JLabel label = new JLabel(param.getKey());
label.setToolTipText(param.getDescription());
......@@ -119,10 +149,9 @@ public class View extends JFrame{
} else if (param instanceof StringParameter || param instanceof NumericParameter<?>) {
JTextField tf = new JTextField(((Parameter)param).getValue());
Dimension tfDim = new Dimension(300,20);
tf.setMaximumSize(tfDim);
tf.setPreferredSize(tfDim);
tf.setMinimumSize(tfDim);
tf.setMaximumSize(dim);
tf.setPreferredSize(dim);
tf.setMinimumSize(dim);
tf.setAlignmentX(RIGHT_ALIGNMENT);
tf.setActionCommand(mergeKeypath(keypath, param.getKey()));
tf.addActionListener(controller);
......@@ -133,6 +162,9 @@ public class View extends JFrame{
OptionParameter opParam = (OptionParameter)param;
JComboBox<Option> cb = new JComboBox<Option>();
cb.setMaximumSize(dim);
cb.setMinimumSize(dim);
cb.setPreferredSize(dim);
cb.setRenderer(new MyComboBoxRenderer());
for (Option op : opParam.options)
cb.addItem(op);
......@@ -154,7 +186,7 @@ public class View extends JFrame{
class MyComboBoxRenderer extends BasicComboBoxRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
if (isSelected) {
setBackground(list.getSelectionBackground());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment