|
@@ -60,7 +60,6 @@ public class Module extends Group implements IGUIEventClient, ChangeListener<Bou
|
|
|
public boolean isSelected = false;
|
|
|
|
|
|
public Module(JSONObject json){
|
|
|
-
|
|
|
setFocusTraversable(true);
|
|
|
_eventHandler = GUIEventHandler.getEventHandler();
|
|
|
_eventHandler.addEventListener(this, 5);
|
|
@@ -85,7 +84,7 @@ public class Module extends Group implements IGUIEventClient, ChangeListener<Bou
|
|
|
titlebar.setArcWidth(10.0f);
|
|
|
titlebar.setArcHeight(10.0f);
|
|
|
|
|
|
- //ackground = new Rectangle(0.0f, 0.0f, 150-20, 150 + 40);
|
|
|
+ //background = new Rectangle(0.0f, 0.0f, 150-20, 150 + 40);
|
|
|
background = new Rectangle(0.0f, 0.0f, 1.0, 1.0);
|
|
|
background.setArcWidth(10.0f);
|
|
|
background.setArcHeight(10.0f);
|
|
@@ -96,8 +95,13 @@ public class Module extends Group implements IGUIEventClient, ChangeListener<Bou
|
|
|
caption.setX(10);
|
|
|
caption.setY(15);
|
|
|
|
|
|
+ Color color = Color.DARKCYAN;
|
|
|
+ titlebar.setFill(color);
|
|
|
configure(json);
|
|
|
|
|
|
+ getChildren().clear();
|
|
|
+ getChildren().addAll( background, titlebar, caption, vlayout);
|
|
|
+
|
|
|
addEventHandler(MouseEvent.MOUSE_PRESSED, e -> {
|
|
|
if(e.getButton() == MouseButton.PRIMARY) {
|
|
|
isSelected = true;
|
|
@@ -152,7 +156,11 @@ public class Module extends Group implements IGUIEventClient, ChangeListener<Bou
|
|
|
}
|
|
|
|
|
|
public void configure(JSONObject json){
|
|
|
- Type = json.get("type").toString();
|
|
|
+ int test = 0;
|
|
|
+ if (json.containsKey("type")){
|
|
|
+ Type = json.get("type").toString();
|
|
|
+ }
|
|
|
+
|
|
|
if (json.containsKey("ID")){
|
|
|
jID = (JSONObject)json.get("ID");
|
|
|
|
|
@@ -166,9 +174,12 @@ public class Module extends Group implements IGUIEventClient, ChangeListener<Bou
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- updateConnectable(ConnectableType.INPUT,json);
|
|
|
- updateConnectable(ConnectableType.OUTPUT,json);
|
|
|
-
|
|
|
+ if (json.containsKey("inputs")){
|
|
|
+ updateConnectable(ConnectableType.INPUT,json);
|
|
|
+ }
|
|
|
+ if (json.containsKey("outputs")){
|
|
|
+ updateConnectable(ConnectableType.OUTPUT,json);
|
|
|
+ }
|
|
|
|
|
|
if (json.containsKey("configure")) {
|
|
|
configs.getChildren().clear();
|
|
@@ -181,16 +192,15 @@ public class Module extends Group implements IGUIEventClient, ChangeListener<Bou
|
|
|
int counter = 0;
|
|
|
while (itr.hasNext()){
|
|
|
String key = itr.next();
|
|
|
- if(!key.equals("name")){
|
|
|
- JSONObject jconfig = (JSONObject) jconfigs.get(key);
|
|
|
- Label clabel = new Label(key);
|
|
|
- configs.add(clabel,0,counter);
|
|
|
- configs.add(new Configuration("configure", this, key, jconfig),1,counter);
|
|
|
- ++counter;
|
|
|
- }
|
|
|
+ JSONObject jconfig = (JSONObject) jconfigs.get(key);
|
|
|
+ Label clabel = new Label(key);
|
|
|
+ configs.add(clabel,0,counter);
|
|
|
+ configs.add(new Configuration("configure", this, key, jconfig),1,counter);
|
|
|
+ ++counter;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if (json.containsKey("GUI")) {
|
|
|
JSONObject jgui = (JSONObject) json.get("GUI");
|
|
|
if (jgui.containsKey("name")) {
|
|
@@ -202,6 +212,9 @@ public class Module extends Group implements IGUIEventClient, ChangeListener<Bou
|
|
|
caption.setText(Name);
|
|
|
}
|
|
|
caption.setText(Name);
|
|
|
+ if (jgui.containsKey("color")) {
|
|
|
+ titlebar.setFill(Color.web(((JSONObject)jgui.get("color")).get("value").toString()));
|
|
|
+ }
|
|
|
if (jgui.containsKey("posX")){
|
|
|
setTranslateX((double)jgui.get("posX"));
|
|
|
}
|
|
@@ -209,12 +222,6 @@ public class Module extends Group implements IGUIEventClient, ChangeListener<Bou
|
|
|
setTranslateY((double) jgui.get("posY"));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- Color color = Color.DARKCYAN;
|
|
|
- titlebar.setFill(color);
|
|
|
-
|
|
|
- getChildren().clear();
|
|
|
- getChildren().addAll( background, titlebar, caption, vlayout);
|
|
|
}
|
|
|
|
|
|
protected void updateConnectable(ConnectableType ctype,JSONObject json){
|
|
@@ -336,26 +343,7 @@ public class Module extends Group implements IGUIEventClient, ChangeListener<Bou
|
|
|
JSONObject jobj = (JSONObject) jargs.get("object");
|
|
|
switch((String) args.get("operation")){
|
|
|
case "change":
|
|
|
- if (jobj.containsKey("GUI")){
|
|
|
- JSONObject jgui = (JSONObject) jobj.get("GUI");
|
|
|
- if (jgui.containsKey("name")) {
|
|
|
- try {
|
|
|
- Name = ((JSONObject)jgui.get("name")).get("value").toString();
|
|
|
- }catch(ClassCastException e){
|
|
|
- Name= jgui.get("name").toString();
|
|
|
- }
|
|
|
- caption.setText(Name);
|
|
|
- }
|
|
|
- if (jgui.containsKey("posX")){
|
|
|
- setTranslateX((double)jgui.get("posX"));
|
|
|
- }
|
|
|
- if (jgui.containsKey("posY")) {
|
|
|
- setTranslateY((double) jgui.get("posY"));
|
|
|
- }
|
|
|
- }
|
|
|
- if (jobj.containsKey("configure")){
|
|
|
- configure((JSONObject) jobj.get("configure"));
|
|
|
- }
|
|
|
+ configure(jobj);
|
|
|
}
|
|
|
return;
|
|
|
}
|