-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from Asis2019/wip
Wip
- Loading branch information
Showing
23 changed files
with
756 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package com.asis.controllers; | ||
|
||
import com.asis.controllers.dialogs.DialogMessage; | ||
import com.asis.joi.model.entities.Group; | ||
import com.asis.joi.model.entities.GroupBridge; | ||
import com.asis.joi.model.entities.JOIComponent; | ||
import com.asis.ui.InfinityPane; | ||
import com.asis.ui.asis_node.node_functional_expansion.AddComponentNodeResolver; | ||
import com.asis.ui.asis_node.node_functional_expansion.CreateComponentConnectionsResolver; | ||
import com.asis.utilities.Config; | ||
import com.asis.utilities.StageManager; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.MenuBar; | ||
import javafx.stage.Stage; | ||
import org.json.JSONObject; | ||
|
||
public class NodeGroupWindow extends EditorWindow { | ||
|
||
private Group group; | ||
|
||
@FXML | ||
private InfinityPane infinityPane; | ||
@FXML | ||
public MenuBar mainMenuBar; | ||
|
||
public void initialize(Group group) { | ||
this.group = group; | ||
|
||
try { | ||
JSONObject object = (JSONObject) Config.get("ZOOM"); | ||
if (object.has("minimum")) getInfinityPane().setMinimumScale(object.getDouble("minimum")); | ||
if (object.has("maximum")) getInfinityPane().setMaximumScale(object.getDouble("maximum")); | ||
} catch (ClassCastException ignore) { | ||
} | ||
|
||
loadNodes(); | ||
} | ||
|
||
private void loadNodes() { | ||
try { | ||
resetEditorWindow(); | ||
|
||
//Create the input/output bridging nodes if needed | ||
loadGroupInternals(); | ||
|
||
//Create component nodes | ||
for (JOIComponent component : Controller.getInstance().getJoiPackage().getJoi().getJoiComponents()) { | ||
if (component.getGroupId() != getGroup().getComponentId()) continue; | ||
|
||
component.accept(new AddComponentNodeResolver(this)); | ||
} | ||
|
||
//Create connections | ||
for (JOIComponent component : Controller.getInstance().getJoiPackage().getJoi().getJoiComponents()) { | ||
if (component.getGroupId() != getGroup().getComponentId()) continue; | ||
|
||
component.accept(new CreateComponentConnectionsResolver(this)); | ||
} | ||
|
||
} catch (RuntimeException e) { | ||
e.printStackTrace(); | ||
DialogMessage.messageDialog("LOADING FAILED", "The editor was unable to load this group for the following reason:\n" + e.getMessage(), 600, 200); | ||
} | ||
} | ||
|
||
private void loadGroupInternals() { | ||
if (getGroup().getInputNodeData() == null) { | ||
final int componentId = Controller.getInstance().getJoiPackage().getJoi().getSceneIdCounter() + 1; | ||
|
||
Controller.getInstance().getJoiPackage().getJoi().addNewComponent(GroupBridge.class, componentId); | ||
GroupBridge groupBridge = (GroupBridge) Controller.getInstance().getJoiPackage().getJoi().getComponent(componentId); | ||
|
||
groupBridge.setInputBridge(true); | ||
groupBridge.setGroupId(getGroup().getComponentId()); | ||
getGroup().setInputNodeData(groupBridge); | ||
} | ||
|
||
if (getGroup().getOutputNodeData() == null) { | ||
final int componentId = Controller.getInstance().getJoiPackage().getJoi().getSceneIdCounter() + 1; | ||
|
||
Controller.getInstance().getJoiPackage().getJoi().addNewComponent(GroupBridge.class, componentId); | ||
GroupBridge groupBridge = (GroupBridge) Controller.getInstance().getJoiPackage().getJoi().getComponent(componentId); | ||
|
||
groupBridge.setLayoutXPosition(400); | ||
groupBridge.setInputBridge(false); | ||
groupBridge.setGroupId(getGroup().getComponentId()); | ||
getGroup().setOutputNodeData(groupBridge); | ||
} | ||
} | ||
|
||
@FXML | ||
private void actionClose() { | ||
Stage stage = (Stage) getInfinityPane().getScene().getWindow(); | ||
StageManager.getInstance().closeStage(stage); | ||
} | ||
|
||
// Getters and setters | ||
@Override | ||
public InfinityPane getInfinityPane() { | ||
return infinityPane; | ||
} | ||
|
||
public Group getGroup() { | ||
return group; | ||
} | ||
} |
Oops, something went wrong.