Commit f74d19df authored by legoc's avatar legoc
Browse files

Moved ReferenceAxisList

parent 2d268b9b
......@@ -20,9 +20,9 @@ import fr.ill.ics.n3d.model.Axis.Type;
import fr.ill.ics.n3d.model.Component;
import fr.ill.ics.n3d.model.ConfigParams;
import fr.ill.ics.n3d.model.ReferenceAxis;
import fr.ill.ics.n3d.model.ReferenceAxisList;
import fr.ill.ics.n3d.operations.Operations;
import fr.ill.ics.n3d.operations.OperationsSerializer;
import fr.ill.ics.n3d.utils.ReferenceAxisList;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
......
package fr.ill.ics.n3d.utils;
import java.util.ArrayList;
import java.util.List;
import fr.ill.ics.n3d.model.Component;
import fr.ill.ics.n3d.model.Model;
import fr.ill.ics.n3d.model.ReferenceAxis;
/**
* Class storing the list of reference axis.
*/
public class ReferenceAxisList {
private static ReferenceAxisList instance = new ReferenceAxisList();
private ArrayList<ReferenceAxis> list = new ArrayList<ReferenceAxis>();
/**
* Gets the instance of the ReferenceAxisList class.
* @return The single instance.
*/
public static ReferenceAxisList getInstance() {
return instance;
}
/**
* Initializes the list.
* @param model The model.
*/
public void init(Model model) {
// Reset the list.
list.clear();
// Traverse all the components.
init(model.getRoot());
}
/**
* Gets the list of reference axes.
* @return The list of reference axes.
*/
public ArrayList<ReferenceAxis> get() {
return list;
}
/**
* Gets the reference axis with name.
* @return The reference axis.
*/
public ReferenceAxis getAxis(String name) {
for (ReferenceAxis axis : list) {
if (name.equals(axis.getName())) {
return axis;
}
}
return null;
}
/**
* Gets the list of the names of reference axes.
* @return The list of names.
*/
public ArrayList<String> getNames() {
ArrayList<String> result = new ArrayList<String>();
// Get the names.
for (ReferenceAxis axis : list) {
result.add(axis.getName());
}
return result;
}
/**
* Initializes the list recursively.
* @param component The component.
*/
private void init(Component component) {
// Add all the reference axes of the component.
list.addAll(component.getReferenceAxes());
// Traverse the children.
List<Component> children = component.getChildren();
for (Component child : children) {
init(child);
}
}
}
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