The code.ill.fr has been recreated and upgraded with the latest version this weekend, If you encounter any problem please inform the Helpdesk.

Commit 472985fd authored by legoc's avatar legoc
Browse files

Move axes from axis properties.

parent c7d1e30d
......@@ -2,8 +2,6 @@ package fr.ill.ics.n3d.gui;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -14,8 +12,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.logging.Logger;
import org.apache.commons.io.FilenameUtils;
import fr.ill.ics.n3d.Nomad3DEditor;
import fr.ill.ics.n3d.io.Nomad3DExporter;
import fr.ill.ics.n3d.io.Nomad3DImporter;
......@@ -24,7 +20,6 @@ import fr.ill.ics.n3d.link.NomadLinker;
import fr.ill.ics.n3d.model.Axis;
import fr.ill.ics.n3d.model.Component;
import fr.ill.ics.n3d.model.Component.AxisInfo;
import fr.ill.ics.n3d.model.ConfigParams;
import fr.ill.ics.n3d.model.PathName;
import fr.ill.ics.n3d.model.ReferenceAxis;
import fr.ill.ics.n3d.model.ReferenceAxisList;
......@@ -39,6 +34,7 @@ import fr.ill.ics.n3d.operations.RenameComponentOperation;
import fr.ill.ics.n3d.operations.SetAxisOperation;
import fr.ill.ics.n3d.operations.SetMaterialOperation;
import javafx.application.Platform;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
......@@ -66,9 +62,11 @@ import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.Slider;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellEditEvent;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
......@@ -81,6 +79,7 @@ import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.converter.DoubleStringConverter;
/**
* Menu bar of the Nomad3DEditor.getInstance().
......@@ -154,17 +153,44 @@ public class EditorMenuBar extends MenuBar {
LinkedList<SubdividedChild> subdividedChilds;
public static class CustomDoubleStringConverter extends DoubleStringConverter {
private final DoubleStringConverter converter = new DoubleStringConverter();
@Override
public String toString(Double object) {
try {
return converter.toString(object);
} catch (NumberFormatException e) {
//showAlert(e);
}
return null;
}
@Override
public Double fromString(String string) {
try {
return converter.fromString(string);
} catch (NumberFormatException e) {
//showAlert(e);
}
return 0.0;
}
}
public static class AxisTableEntry {
private final SimpleStringProperty axisName;
private final SimpleStringProperty componentName;
private final SimpleStringProperty type;
private final SimpleDoubleProperty currentValue;
private AxisTableEntry(String axisName, String componentName, String type) {
super();
this.axisName = new SimpleStringProperty(axisName);
this.componentName = new SimpleStringProperty(componentName);
this.type = new SimpleStringProperty(type);
this.currentValue = new SimpleDoubleProperty(0);
}
private AxisTableEntry(String axisName, String componentName) {
......@@ -172,6 +198,7 @@ public class EditorMenuBar extends MenuBar {
this.axisName = new SimpleStringProperty(axisName);
this.componentName = new SimpleStringProperty(componentName);
this.type = new SimpleStringProperty("");
this.currentValue = new SimpleDoubleProperty(0);
}
public String getAxisName() {
......@@ -185,6 +212,14 @@ public class EditorMenuBar extends MenuBar {
public String getType() {
return type.get();
}
public Double getCurrentValue() {
return currentValue.get();
}
public void setCurrentValue(double value) {
currentValue.set(value);
}
}
private static boolean isAxisDefined(String controllerName, List<AxisInfo> axisInfos) {
......@@ -322,7 +357,7 @@ public class EditorMenuBar extends MenuBar {
command += c + " ";
}
Logger.getLogger("nomad-3d").info("Merge script launched: " + command);
Logger.getLogger("nomad-3d").info("Merge script to launch: " + command);
//try {
// do not wait for termination, can take a long time and it may be wise to close
......@@ -1041,14 +1076,14 @@ public class EditorMenuBar extends MenuBar {
GridPane scenePane = new GridPane();
Scene displayScene = new Scene(scenePane);
Stage displayStage = new Stage(StageStyle.UTILITY);
displayStage.setWidth(500);
displayStage.setWidth(1000);
displayStage.setTitle(displayAxisItem.getText());
displayStage.setScene(displayScene);
displayStage.initOwner(Nomad3DEditor.getInstance().getStage());
TableView<AxisTableEntry> tableView = new TableView();
tableView.setEditable(false);
tableView.setEditable(true);
TableColumn axisNameColumn = new TableColumn<>("Name");
axisNameColumn.setMinWidth(200);
......@@ -1062,6 +1097,24 @@ public class EditorMenuBar extends MenuBar {
typeColumn.setMinWidth(100);
typeColumn.setCellValueFactory(new PropertyValueFactory<AxisTableEntry, String>("type"));
TableColumn currentValueColumn = new TableColumn("Current Value");
currentValueColumn.setMinWidth(100);
currentValueColumn.setCellValueFactory(new PropertyValueFactory<AxisTableEntry, Double>("currentValue"));
currentValueColumn.setCellFactory(TextFieldTableCell.forTableColumn(new CustomDoubleStringConverter()));
currentValueColumn.setOnEditCommit(new EventHandler<CellEditEvent<AxisTableEntry, Double>>() {
@Override
public void handle(CellEditEvent<AxisTableEntry, Double> cellEvent) {
System.out.println("new value");
AxisTableEntry entry = cellEvent.getRowValue();
double value = cellEvent.getNewValue();
entry.setCurrentValue(value);
System.out.println("Moving axes...");
Nomad3DEditor.getInstance().getModel().moveAxes(entry.getAxisName(), value);
}
});
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<AxisTableEntry>() {
@Override
......@@ -1097,7 +1150,7 @@ public class EditorMenuBar extends MenuBar {
}
tableView.setItems(data);
tableView.getColumns().addAll(axisNameColumn, componentNameColumn, typeColumn);
tableView.getColumns().addAll(axisNameColumn, componentNameColumn, typeColumn, currentValueColumn);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
......
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