From 2b26c693a92d6f63655ad61bbadc359f4e0bccf0 Mon Sep 17 00:00:00 2001 From: aalmiray Date: Tue, 29 Nov 2016 11:26:41 +0100 Subject: [PATCH 1/8] Remove redundant visibility modifiers from interfaces --- VWorkflows-Core/gradle.properties | 2 +- .../eu/mihosoft/vrl/workflow/ClickEvent.java | 2 - .../vrl/workflow/CompatibilityResult.java | 3 + .../eu/mihosoft/vrl/workflow/Connection.java | 42 +- .../mihosoft/vrl/workflow/ConnectionBase.java | 62 +- .../vrl/workflow/ConnectionEvent.java | 2 +- .../vrl/workflow/ConnectionResult.java | 9 +- .../vrl/workflow/ConnectionResultImpl.java | 4 +- .../eu/mihosoft/vrl/workflow/Connections.java | 57 +- .../vrl/workflow/ConnectionsImpl.java | 28 +- .../eu/mihosoft/vrl/workflow/Connector.java | 58 +- .../mihosoft/vrl/workflow/ConnectorImpl.java | 12 +- .../workflow/DefaultConnectorValueObject.java | 32 +- .../vrl/workflow/DefaultValueObject.java | 13 +- .../eu/mihosoft/vrl/workflow/FlowFactory.java | 18 +- .../eu/mihosoft/vrl/workflow/FlowModel.java | 69 +- .../mihosoft/vrl/workflow/FlowModelImpl.java | 31 +- .../vrl/workflow/FlowNodeSkinLookupImpl.java | 44 +- .../eu/mihosoft/vrl/workflow/IOConnector.java | 5 +- .../eu/mihosoft/vrl/workflow/IdGenerator.java | 17 +- .../vrl/workflow/IdGeneratorImpl.java | 8 +- .../java/eu/mihosoft/vrl/workflow/Lookup.java | 3 +- .../eu/mihosoft/vrl/workflow/MouseButton.java | 3 +- .../NoDefaultConnectorValueObject.java | 4 +- .../eu/mihosoft/vrl/workflow/NodeFactory.java | 9 +- .../eu/mihosoft/vrl/workflow/NodeLookup.java | 3 +- .../mihosoft/vrl/workflow/NodeLookupImpl.java | 22 +- .../eu/mihosoft/vrl/workflow/PathUtil.java | 10 +- .../vrl/workflow/PropertyStorage.java | 26 +- .../vrl/workflow/PropertyStorageImpl.java | 15 +- .../eu/mihosoft/vrl/workflow/Selectable.java | 1 + .../mihosoft/vrl/workflow/ThruConnector.java | 9 +- .../vrl/workflow/ThruConnectorImpl.java | 16 +- .../mihosoft/vrl/workflow/VConnections.java | 5 +- .../java/eu/mihosoft/vrl/workflow/VFlow.java | 151 +- .../eu/mihosoft/vrl/workflow/VFlowImpl.java | 134 +- .../eu/mihosoft/vrl/workflow/VFlowModel.java | 20 +- .../mihosoft/vrl/workflow/VFlowModelImpl.java | 113 +- .../java/eu/mihosoft/vrl/workflow/VNode.java | 125 +- .../eu/mihosoft/vrl/workflow/VNodeImpl.java | 232 ++-- .../eu/mihosoft/vrl/workflow/ValueObject.java | 24 +- .../mihosoft/vrl/workflow/VisibleState.java | 7 +- .../vrl/workflow/VisualizationRequest.java | 26 +- .../workflow/VisualizationRequestImpl.java | 1 - .../mihosoft/vrl/workflow/WorkflowUtil.java | 103 +- .../workflow/incubating/LayoutGenerator.java | 60 +- .../incubating/LayoutGeneratorNaive.java | 492 ++++--- .../incubating/LayoutGeneratorSmart.java | 1225 +++++++++-------- .../vrl/workflow/io/ConnectorIOImpl.java | 3 +- .../vrl/workflow/io/PersistentConnection.java | 7 +- .../vrl/workflow/io/PersistentConnector.java | 27 +- .../vrl/workflow/io/PersistentFlow.java | 13 +- .../vrl/workflow/io/PersistentNode.java | 36 +- .../workflow/io/PersistentValueObject.java | 1 - .../mihosoft/vrl/workflow/io/WorkflowIO.java | 312 ++--- .../workflow/skin/ConnectionSkinFactory.java | 10 +- .../mihosoft/vrl/workflow/skin/Constants.java | 11 +- .../vrl/workflow/skin/FlowNodeSkinLookup.java | 10 +- .../eu/mihosoft/vrl/workflow/skin/Skin.java | 36 +- .../vrl/workflow/skin/SkinFactory.java | 7 +- .../mihosoft/vrl/workflow/skin/VNodeSkin.java | 5 +- .../vrl/workflow/skin/VNodeSkinFactory.java | 10 +- .../vrl/workflow/ConnectionEventTest.java | 20 +- .../vrl/workflow/ConnectionImplClassTest.java | 18 +- .../mihosoft/vrl/workflow/ConnectorTest.java | 37 +- .../eu/mihosoft/vrl/workflow/FlowUtil.java | 7 +- .../eu/mihosoft/vrl/workflow/SkinTest.java | 98 +- .../mihosoft/vrl/workflow/VFlowDiffTest.java | 31 +- .../eu/mihosoft/vrl/workflow/VFlowIOTest.java | 33 +- .../mihosoft/vrl/workflow/VFlowMergeTest.java | 3 +- .../eu/mihosoft/vrl/workflow/VFlowTest.java | 29 +- .../vrl/workflow/WorkflowUtilTest.java | 50 +- .../workflow/demo/CustomContextMenuDemo.java | 2 +- .../eu/mihosoft/vrl/workflow/demo/Main.java | 24 +- .../demo/MainWindowFXMLController.java | 810 +++++------ .../demo/NodeControlFXMLController.java | 2 +- .../demo/OptionsWindowFXMLController.java | 120 +- .../OptionsWindowNaiveFXMLController.java | 69 +- .../vrl/workflow/demo/MainWindowFXML.fxml | 145 +- .../vrl/workflow/demo/NodeControlFXML.fxml | 5 +- .../vrl/workflow/demo/OptionsWindowFXML.fxml | 86 +- .../workflow/demo/OptionsWindowNaiveFXML.fxml | 54 +- .../eu/mihosoft/vrl/workflow/fx/default.css | 32 +- VWorkflows-Demo/vworkflows-demo.gradle | 4 +- VWorkflows-FX/gradle.properties | 2 +- .../workflow/fx/AbstractFXConnectionSkin.java | 29 +- .../vrl/workflow/fx/ConnectionListener.java | 1 - .../vrl/workflow/fx/ConnectorCircle.java | 34 +- .../fx/DefaultConnectionListener.java | 12 +- .../workflow/fx/DefaultFXConnectionSkin.java | 183 ++- .../vrl/workflow/fx/FXConnectorUtil.java | 51 +- .../vrl/workflow/fx/FXFlowNodeSkin.java | 340 +++-- .../vrl/workflow/fx/FXFlowNodeSkinBase.java | 18 +- .../vrl/workflow/fx/FXNewConnectionSkin.java | 177 ++- .../eu/mihosoft/vrl/workflow/fx/FXSkin.java | 19 +- .../vrl/workflow/fx/FXSkinFactory.java | 10 +- .../vrl/workflow/fx/FXValueSkinFactory.java | 88 +- .../vrl/workflow/fx/FlowNodeWindow.java | 217 ++- .../mihosoft/vrl/workflow/fx/InnerCanvas.java | 7 +- .../eu/mihosoft/vrl/workflow/fx/NodeUtil.java | 75 +- .../workflow/fx/OptimizableContentPane.java | 30 +- .../vrl/workflow/fx/OptimizationRule.java | 9 +- .../eu/mihosoft/vrl/workflow/fx/Pair.java | 15 +- .../eu/mihosoft/vrl/workflow/fx/RootPane.java | 5 +- .../vrl/workflow/fx/ScalableContentPane.java | 2 +- .../vrl/workflow/fx/SelectedConnector.java | 1 - .../vrl/workflow/fx/TranslateBehavior.java | 1 - .../eu/mihosoft/vrl/workflow/fx/VCanvas.java | 22 +- .../skin/window/DefaultWindowIconSkin.java | 3 +- .../skin/window/DefaultWindowSkin.java | 565 ++++---- .../window/DefaultWindowSkinSimplified.java | 379 +++-- .../labs/util/event/EventHandlerGroup.java | 10 +- .../labs/util/event/MouseControlUtil.java | 151 +- .../scene/control/window/Clipboard.java | 10 +- .../scene/control/window/CloseIcon.java | 1 - .../scene/control/window/MinimizeIcon.java | 5 +- .../scene/control/window/NodeUtil.java | 52 +- .../scene/control/window/RotateIcon.java | 1 - .../scene/control/window/SelectableNode.java | 8 +- .../jfxtras/scene/control/window/Window.java | 149 +- .../scene/control/window/WindowIcon.java | 4 +- .../scene/control/window/WindowUtil.java | 33 +- .../eu/mihosoft/vrl/workflow/fx/default.css | 32 +- .../jfxtras/scene/control/window/default.css | 13 +- .../jfxtras/scene/control/window/icons.svg | 131 +- VWorkflows-FX/src/test/java/DummyTest.java | 1 + 126 files changed, 4375 insertions(+), 4045 deletions(-) diff --git a/VWorkflows-Core/gradle.properties b/VWorkflows-Core/gradle.properties index ea7ad798..67c5c240 100644 --- a/VWorkflows-Core/gradle.properties +++ b/VWorkflows-Core/gradle.properties @@ -1 +1 @@ -publishJars = true +publishJars=true diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ClickEvent.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ClickEvent.java index 624f7324..3c5adc45 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ClickEvent.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ClickEvent.java @@ -41,7 +41,6 @@ import javafx.event.EventType; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class ClickEvent extends Event { @@ -80,6 +79,5 @@ public Object getEvent() { return event; } - } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/CompatibilityResult.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/CompatibilityResult.java index c6a30bca..012fe93f 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/CompatibilityResult.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/CompatibilityResult.java @@ -35,10 +35,13 @@ /** * This interface describes whether two connectors are compatible for a connection. + * * @author Michael Hoffer <info@michaelhoffer.de> */ public interface CompatibilityResult { boolean isCompatible(); + String getMessage(); + String getStatus(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connection.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connection.java index b5cfe177..81e586ad 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connection.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connection.java @@ -35,27 +35,33 @@ /** * This interface defines a connection between two connectors. + * * @author Michael Hoffer <info@michaelhoffer.de> */ -public interface Connection extends Model{ -// public String getSenderId(); -// public void setSenderId(String id); -// public String getReceiverId(); -// public void setReceiverId(String id); - public void setSender(Connector s); - public void setReceiver(Connector r); - public Connector getReceiver(); - public Connector getSender(); - - public String getId(); - public void setId(String id); - - public String getType(); - - public Connections getConnections(); +public interface Connection extends Model { + // String getSenderId(); + // void setSenderId(String id); + // String getReceiverId(); + // void setReceiverId(String id); + void setSender(Connector s); + + void setReceiver(Connector r); + + Connector getReceiver(); + + Connector getSender(); + + String getId(); + + void setId(String id); + + String getType(); + + Connections getConnections(); @Override - public void setVisualizationRequest(VisualizationRequest vReq); + void setVisualizationRequest(VisualizationRequest vReq); + @Override - public VisualizationRequest getVisualizationRequest(); + VisualizationRequest getVisualizationRequest(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionBase.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionBase.java index b31f8d37..22fb1a80 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionBase.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionBase.java @@ -55,17 +55,17 @@ class ConnectionBase implements Connection { private Connector sender; private Connector receiver; -// private ObjectProperty skinProperty = new SimpleObjectProperty<>(); + // private ObjectProperty skinProperty = new SimpleObjectProperty<>(); public ConnectionBase() { } -// public ConnectionBase(Connections connections, String id, String senderId, String receiverId, String type) { -// this.connections = connections; -// this.id = id; -// this.senderId = senderId; -// this.receiverId = receiverId; -// this.type = type; -// } + // public ConnectionBase(Connections connections, String id, String senderId, String receiverId, String type) { + // this.connections = connections; + // this.id = id; + // this.senderId = senderId; + // this.receiverId = receiverId; + // this.type = type; + // } public ConnectionBase(Connections connections, String id, Connector sender, Connector receiver, String type) { this.connections = connections; this.id = id; @@ -74,10 +74,10 @@ public ConnectionBase(Connections connections, String id, Connector sender, Conn this.type = type; } -// @Override -// public String getSenderId() { -// return senderId; -// } + // @Override + // public String getSenderId() { + // return senderId; + // } @Override public void setSender(Connector s) { this.senderId = s.getId(); @@ -95,10 +95,10 @@ private void updateConnection() { } } -// @Override -// public String getReceiverId() { -// return receiverId; -// } + // @Override + // public String getReceiverId() { + // return receiverId; + // } @Override public void setReceiver(Connector r) { this.receiverId = r.getId(); @@ -153,20 +153,20 @@ private ObjectProperty _visualizationRequestProperty() { public ReadOnlyProperty visualizationRequestProperty() { return _visualizationRequestProperty(); } -// @Override -// public void setSkin(Skin skin) { -// skinProperty.set(skin); -// } -// -// @Override -// public Skin getSkin() { -// return skinProperty.get(); -// } -// -// @Override -// public ObjectProperty skinProperty() { -// return skinProperty; -// } + // @Override + // public void setSkin(Skin skin) { + // skinProperty.set(skin); + // } + // + // @Override + // public Skin getSkin() { + // return skinProperty.get(); + // } + // + // @Override + // public ObjectProperty skinProperty() { + // return skinProperty; + // } /** * @return the connections @@ -233,7 +233,7 @@ public Connector getSender() { public Connector getReceiver() { return receiver; } - + @Override public boolean isVisualizationRequestInitialized() { return vReqProperty != null; diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionEvent.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionEvent.java index f1b64de4..a1bc4b5d 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionEvent.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionEvent.java @@ -43,6 +43,7 @@ /** * This class defines a connection event. A connection event is fired when a * connection is made between two connectors. + * * @author Michael Hoffer <info@michaelhoffer.de> */ public class ConnectionEvent extends Event { @@ -76,7 +77,6 @@ public Connector getReceiverConnector() { } /** - * * @return the connection */ public Connection getConnection() { diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionResult.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionResult.java index ed2354db..2e5390c5 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionResult.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionResult.java @@ -35,20 +35,23 @@ /** * This interface defines the result of an attempt to connect two {@code Connector}s + * * @author Michael Hoffer <info@michaelhoffer.de> */ public interface ConnectionResult { /** * Get the connection object for the connection being attempted + * * @return the connection */ Connection getConnection(); - -// List getPath(); + + // List getPath(); /** - * Get the status of the connection. + * Get the status of the connection. + * * @return the status of the connection */ CompatibilityResult getStatus(); diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionResultImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionResultImpl.java index 37781dea..b70df680 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionResultImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionResultImpl.java @@ -36,7 +36,7 @@ /** * This class provides a default implementation of {@code ConnectionResult} * //TODO add documentation about the possible connection results. - * + * * @author Michael Hoffer <info@michaelhoffer.de> */ @@ -46,7 +46,7 @@ class ConnectionResultImpl implements ConnectionResult { public ConnectionResultImpl(CompatibilityResult status, Connection connection) { this.status = status; - + this.connection = connection; } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connections.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connections.java index 1076d254..4029416f 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connections.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connections.java @@ -49,63 +49,67 @@ public interface Connections extends Model { * * @param c the connection to add */ - public void add(Connection c); + void add(Connection c); /** * Adds the connection defined by the specified connectors. * * @param s sender connector * @param r receiver connector + * * @return connection that has been added */ - public Connection add(Connector s, Connector r); + Connection add(Connector s, Connector r); /** * Adds the connection defined by the specified connectors. * - * @param id the id of the connection that shall be added - * @param s the sender connector - * @param r the receiver connector + * @param id the id of the connection that shall be added + * @param s the sender connector + * @param r the receiver connector * @param vReq the visualization request of the connection + * * @return connection that has been added */ - public Connection add(String id, Connector s, Connector r, VisualizationRequest vReq); + Connection add(String id, Connector s, Connector r, VisualizationRequest vReq); /** * Removes the specified connection from this collection * * @param c connection to remove */ - public void remove(Connection c); + void remove(Connection c); /** * Returns the specified connection. * * @param id id of the connection to be returned - * @param s sender connector - * @param r receiver connector + * @param s sender connector + * @param r receiver connector + * * @return the requested connection or null if no such * connection exists */ - public Connection get(String id, Connector s, Connector r); + Connection get(String id, Connector s, Connector r); /** * Returns all connections betwenn the specified connectors. * * @param s sender connector * @param r receiver connector + * * @return all connections betwenn the specified connectors */ - public Collection getAll(Connector s, Connector r); + Collection getAll(Connector s, Connector r); /** * Removes the specified connection from this collection. * * @param id connection id - * @param s sender connector - * @param r receiver connector + * @param s sender connector + * @param r receiver connector */ - public void remove(String id, Connector s, Connector r); + void remove(String id, Connector s, Connector r); /** * Removes all connections between the specified connectors from this @@ -114,72 +118,77 @@ public interface Connections extends Model { * @param s sender connector * @param r receiver connector */ - public void removeAll(Connector s, Connector r); + void removeAll(Connector s, Connector r); /** * Defines the connection implementation class that shall be used. * * @param cls connection implementation class */ - public void setConnectionClass(Class cls); + void setConnectionClass(Class cls); /** * Returns the connection implementation class. * * @return the connection implementation class */ - public Class getConnectionClass(); + Class getConnectionClass(); /** * Returns the connections defined by this collection. * * @return the connections defined by this collection */ - public ObservableList getConnections(); + ObservableList getConnections(); /** * Returns all connections that are connected to the specified connector. * * @param c connector + * * @return all connections that are connected to the specified connector */ - public Collection getAllWith(Connector c); + Collection getAllWith(Connector c); /** * Returns all connections that are connected to the specified node. * * @param n node + * * @return all connections that are connected to the specified node */ - public Collection getAllWithNode(VNode n); + Collection getAllWithNode(VNode n); /** * Determines whether the specified input connector is connected. * * @param id connector id + * * @return true if the specified input connector is connected; * false otherwise */ - public boolean isInputConnected(Connector id); + boolean isInputConnected(Connector id); /** * Determines whether the specified output connector is connected. * * @param id connector id + * * @return true if the specified output connector is connected; * false otherwise */ - public boolean isOutputConnected(Connector id); + boolean isOutputConnected(Connector id); /** * Determines if a connection exists between the specified connectors. * * @param s sender connector * @param r receiver connector + * * @return true if a connection between the specified * connectors exists; false otherwise */ - public boolean contains(Connector s, Connector r); + boolean contains(Connector s, Connector r); /** * Returns the connection type of this collection. @@ -187,5 +196,5 @@ public interface Connections extends Model { * @return connection type (e.g. "control" or * "data") */ - public String getType(); + String getType(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionsImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionsImpl.java index 1cb6e35a..06c0f5b9 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionsImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionsImpl.java @@ -59,10 +59,10 @@ class ConnectionsImpl implements Connections { private String type; private Map connections = new HashMap<>(); private Class connectionClass = ConnectionBase.class; -// Map senders = new HashMap<>(); -// Map receivers = new HashMap<>(); + // Map senders = new HashMap<>(); + // Map receivers = new HashMap<>(); private ObservableList observableConnections - = FXCollections.observableArrayList(); + = FXCollections.observableArrayList(); private ObjectProperty vReqProperty; // private ObjectProperty skinProperty = new SimpleObjectProperty<>(); @@ -120,8 +120,8 @@ public void remove(Connection c) { observableConnections.remove(c); -// decSenderCounter(c.getSenderId()); -// decReceiverCounter(c.getReceiverId()); + // decSenderCounter(c.getSenderId()); + // decReceiverCounter(c.getReceiverId()); } @Override @@ -136,15 +136,15 @@ public void remove(String id, Connector s, Connector r) { connections.remove(connectionId(id, s.getId(), r.getId())); -// decSenderCounter(s); -// decReceiverCounter(r); + // decSenderCounter(s); + // decReceiverCounter(r); } @Override public void setConnectionClass(Class cls) { try { Constructor constructor = cls.getConstructor(Connections.class, String.class, Connector.class, Connector.class, String.class); - + } catch (NoSuchMethodException | SecurityException ex) { Logger.getLogger(ConnectionsImpl.class.getName()).log(Level.SEVERE, null, ex); throw new IllegalArgumentException("constructor missing: (Connections, String, Connector, Connector, String)"); @@ -159,11 +159,11 @@ public Class getConnectionClass() { } private Connection createConnection(String id, Connector s, Connector r) { - + if (s == null) { throw new IllegalArgumentException("Sender must not be null."); } - + if (r == null) { throw new IllegalArgumentException("Receiver must not be null."); } @@ -196,7 +196,7 @@ public Collection getAllWith(Connector c) { for (Connection conn : getConnections()) { if (conn.getSender().getId().equals(c.getId()) - || conn.getReceiver().getId().equals(c.getId())) { + || conn.getReceiver().getId().equals(c.getId())) { result.add(conn); } } @@ -223,7 +223,7 @@ private void checkUniqueness(Connection c) { if (connections.containsKey(connectionId(c))) { throw new IllegalStateException( - "Cannot add connection: a connection with equal id already added!"); + "Cannot add connection: a connection with equal id already added!"); } } @@ -235,7 +235,7 @@ public Collection getAll(Connector s, Connector r) { for (Connection c : connections.values()) { if (c.getSender().getId().equals(s.getId()) - && c.getReceiver().getId().equals(r.getId())) { + && c.getReceiver().getId().equals(r.getId())) { result.add(c); } } @@ -250,7 +250,7 @@ public void removeAll(Connector s, Connector r) { for (Connection c : connections.values()) { if (c.getSender().getId().equals(s.getId()) - && c.getReceiver().getId().equals(r.getId())) { + && c.getReceiver().getId().equals(r.getId())) { delList.add(c); } } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connector.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connector.java index 7ceba0ff..b9ff0b8e 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connector.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Connector.java @@ -52,7 +52,7 @@ public interface Connector extends Model { * @return connection type (e.g. "control" or * "data") */ - public String getType(); + String getType(); /** * Determines whether this connector is an input connector. @@ -60,7 +60,7 @@ public interface Connector extends Model { * @return true if this connector is an input connector; * false otherwise */ - public boolean isInput(); + boolean isInput(); /** * Determines whether this connector is an output connector. @@ -68,42 +68,42 @@ public interface Connector extends Model { * @return true if this connector is an output connector; * false otherwise */ - public boolean isOutput(); + boolean isOutput(); /** * Returns the global id of this connector. * * @return global connector id */ - public String getId(); + String getId(); /** * Returns the local id of this connector. * * @return local connector id */ - public String getLocalId(); + String getLocalId(); /** * Defines the local id of this connector. * * @param id the id to set */ - public void setLocalId(String id); + void setLocalId(String id); /** * Returns the parent node of this connector. * * @return parent node of this connector */ - public VNode getNode(); + VNode getNode(); /** * Defines the value object of this connector. * * @param obj value object to set */ - public void setValueObject(ValueObject obj); + void setValueObject(ValueObject obj); /** * Returns the value object of this connector. @@ -111,61 +111,69 @@ public interface Connector extends Model { * @return value object or null if no value object has been * defined */ - public ValueObject getValueObject(); + ValueObject getValueObject(); /** * Returns the value object property (can be used to get notified if the value object changes). + * * @return value object property */ - public ObjectProperty valueObjectProperty(); + ObjectProperty valueObjectProperty(); /** * Adds the specified connection-event listener to this connector. - * + * * @param handler the listener to add */ - public void addConnectionEventListener(EventHandler handler); + void addConnectionEventListener(EventHandler handler); /** * Removes the specified connection-event listener from this connector. + * * @param handler the listener to remove */ - public void removeConnectionEventListener(EventHandler handler); + void removeConnectionEventListener(EventHandler handler); /** * Adds the specified click-event listener to this connector. + * * @param handler the listener to add */ - public void addClickEventListener(EventHandler handler); + void addClickEventListener(EventHandler handler); /** * Removes the specified click-event listener from this connector. + * * @param handler the listener to remove */ - public void removeClickEventListener(EventHandler handler); + void removeClickEventListener(EventHandler handler); /** * Perform a mouse click on this connector. - * @param btn the click button + * + * @param btn the click button * @param event the event (e.g. javafx mouse-event) */ - public void click(MouseButton btn, Object event); - + void click(MouseButton btn, Object event); + /** * Defines the maximum allowed number of connections. + * * @param numConnections maximum allowed number of connections ({@code [0,MAX_INT]}) */ - public void setMaxNumberOfConnections(int numConnections); - + void setMaxNumberOfConnections(int numConnections); + /** - * Returns the maximum allowed number of connections. + * Returns the maximum allowed number of connections. + * * @return maximum allowed number of connections ({@code [0,MAX_INT]}) */ - public int getMaxNumberOfConnections(); - + int getMaxNumberOfConnections(); + /** - * Returns the property of the maximum allowed number of connections. + * Returns the property of the maximum allowed number of connections. + * * @return maximum allowed number of connections ({@code [0,MAX_INT]}) */ - public ObjectProperty maxNumberOfConnectionsProperty(); + ObjectProperty maxNumberOfConnectionsProperty(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectorImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectorImpl.java index 90e6cf1a..f526283b 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectorImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectorImpl.java @@ -55,11 +55,11 @@ class ConnectorImpl implements Connector { private ObjectProperty vReqProperty; private boolean input; private boolean output; - private final ObjectProperty valueObjectProperty = - new SimpleObjectProperty<>(); + private final ObjectProperty valueObjectProperty = + new SimpleObjectProperty<>(); private transient List> connectionEventHandlers; private transient List> clickEventHandlers; - + private final int maxNumberOfConnectionsDefault = Integer.MAX_VALUE; private ObjectProperty maxNumberOfConnectionsProperty; @@ -245,7 +245,7 @@ public void setMaxNumberOfConnections(int numConnections) { @Override public int getMaxNumberOfConnections() { - if (maxNumberOfConnectionsProperty==null) { + if (maxNumberOfConnectionsProperty == null) { return maxNumberOfConnectionsDefault; } else { return maxNumberOfConnectionsProperty().get(); @@ -256,9 +256,9 @@ public int getMaxNumberOfConnections() { public ObjectProperty maxNumberOfConnectionsProperty() { if (maxNumberOfConnectionsProperty == null) { maxNumberOfConnectionsProperty = new SimpleObjectProperty<>( - maxNumberOfConnectionsDefault); + maxNumberOfConnectionsDefault); } - + return maxNumberOfConnectionsProperty; } } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/DefaultConnectorValueObject.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/DefaultConnectorValueObject.java index cf2f5b11..7ddf7af0 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/DefaultConnectorValueObject.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/DefaultConnectorValueObject.java @@ -88,13 +88,13 @@ public ObjectProperty valueProperty() { public CompatibilityResult compatible(final ValueObject sender, final String flowType) { return new CompatibilityResult() { - + private boolean compatible; { compatible = computeCompatibility(); } - + private boolean computeCompatibility() { // System.out.println(" -> isCompatible: "); boolean differentObjects = sender != DefaultConnectorValueObject.this; @@ -102,7 +102,7 @@ private boolean computeCompatibility() { boolean compatibleType = false; int numConnectionsOfReceiver = getParent().getFlow(). - getConnections(flowType).getAllWith(c).size(); + getConnections(flowType).getAllWith(c).size(); boolean lessThanMaxNumberOfConnections = true; @@ -110,35 +110,35 @@ private boolean computeCompatibility() { if (sender instanceof DefaultConnectorValueObject) { - DefaultConnectorValueObject senderConnectorVObj = - (DefaultConnectorValueObject) sender; + DefaultConnectorValueObject senderConnectorVObj = + (DefaultConnectorValueObject) sender; compatibleType = getConnector().getType(). - equals(senderConnectorVObj.getConnector().getType()) - && getConnector().isInput() && senderConnectorVObj. - getConnector().isOutput(); + equals(senderConnectorVObj.getConnector().getType()) + && getConnector().isInput() && senderConnectorVObj. + getConnector().isOutput(); int numConnectionsOfSender = senderConnectorVObj.parent. - getFlow().getConnections(flowType). - getAllWith(senderConnectorVObj.c).size(); + getFlow().getConnections(flowType). + getAllWith(senderConnectorVObj.c).size(); maxNumConnections = Math.min(c.getMaxNumberOfConnections(), - senderConnectorVObj.c.getMaxNumberOfConnections()); + senderConnectorVObj.c.getMaxNumberOfConnections()); lessThanMaxNumberOfConnections - = numConnectionsOfReceiver < maxNumConnections - && numConnectionsOfSender < maxNumConnections; + = numConnectionsOfReceiver < maxNumConnections + && numConnectionsOfSender < maxNumConnections; } if (!differentObjects) { errorMessage = "Connections can only established between different nodes." - + " Sender node cannot be equal to receiver node."; + + " Sender node cannot be equal to receiver node."; } else if (!compatibleType) { errorMessage = "Connections can only established between" - + " connectors of the same connection/flow type."; + + " connectors of the same connection/flow type."; } else if (!lessThanMaxNumberOfConnections) { errorMessage = "Trying to creating more than " + maxNumConnections - + " number of connections is not allowed."; + + " number of connections is not allowed."; } return differentObjects && compatibleType && lessThanMaxNumberOfConnections; diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/DefaultValueObject.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/DefaultValueObject.java index 2c5d71de..5cfa194f 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/DefaultValueObject.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/DefaultValueObject.java @@ -37,7 +37,8 @@ import javafx.beans.property.SimpleObjectProperty; /** - * This class defines a value object you can assign a value. + * This class defines a value object you can assign a value. + * * @author Michael Hoffer <info@michaelhoffer.de> */ public class DefaultValueObject implements ValueObject { @@ -79,8 +80,8 @@ public CompatibilityResult compatible(final ValueObject sender, final String flo @Override public boolean isCompatible() { boolean differentObjects = sender != DefaultValueObject.this; -// boolean compatibleType = getParent().isInputOfType(flowType) -// && sender.getParent().isOutputOfType(flowType); + // boolean compatibleType = getParent().isInputOfType(flowType) + // && sender.getParent().isOutputOfType(flowType); return differentObjects /*&& compatibleType*/; } @@ -99,14 +100,14 @@ public String getStatus() { @Override public VisualizationRequest getVisualizationRequest() { - + if (vReq == null) { vReq = new VisualizationRequestImpl(); } - + return vReq; } - + @Override public void setVisualizationRequest(VisualizationRequest vReq) { this.vReq = vReq; diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowFactory.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowFactory.java index d28d5938..e1896589 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowFactory.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowFactory.java @@ -39,50 +39,56 @@ /** * A factory class to create {@code VFlow}s. + * * @author Michael Hoffer <info@michaelhoffer.de> */ public class FlowFactory { /** * Creates a new instance of a flow + * * @return the newly created {@code VFlow} */ public static VFlow newFlow() { VFlowModel model = FlowFactory.newFlowModel(); - - VFlow flow = new VFlowImpl(null,model); + + VFlow flow = new VFlowImpl(null, model); return flow; } /** * Creates a new instance of a flow and specify its skin + * * @param skinFactory Defines the skin factory used to render the workflow + * * @return the newly created {@code VFlow} */ public static VFlow newFlow( - SkinFactory skinFactory) { + SkinFactory skinFactory) { VFlowModel model = FlowFactory.newFlowModel(); - VFlow flow = new VFlowImpl(null,model, skinFactory); + VFlow flow = new VFlowImpl(null, model, skinFactory); return flow; } /** * Creates a new flow model - * @return + * + * @return */ public static VFlowModel newFlowModel() { VFlowModel result = new VFlowModelImpl(null); result.setId("ROOT"); return result; } - + /** * Returns a new id generator. + * * @return id generator */ public static IdGenerator newIdGenerator() { diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowModel.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowModel.java index 39077ddb..90df1507 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowModel.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowModel.java @@ -41,32 +41,34 @@ * * @author Michael Hoffer <info@michaelhoffer.de> */ -interface FlowModel extends Model, VisibleState { +public interface FlowModel extends Model, VisibleState { /** * Attempts to create the specified connection. This method never creates an * actual connection. It only checks whether the requested connection is * valid. * - * @param s sender node (uses main output connector of this node if - * specified) - * @param r receiver node (uses main input connector of this node if - * specified) + * @param s sender node (uses main output connector of this node if + * specified) + * @param r receiver node (uses main input connector of this node if + * specified) * @param flowType connection type + * * @return connection result */ - public ConnectionResult tryConnect(VNode s, VNode r, String flowType); + ConnectionResult tryConnect(VNode s, VNode r, String flowType); /** * Requests the specified connection. If the specified connection can be * established it will be created. * - * @param s sender node - * @param r receiver node + * @param s sender node + * @param r receiver node * @param flowType connection type + * * @return connection result */ - public ConnectionResult connect(VNode s, VNode r, String flowType); + ConnectionResult connect(VNode s, VNode r, String flowType); /** * Attempts to create the specified connection. This method never creates an @@ -75,9 +77,10 @@ interface FlowModel extends Model, VisibleState { * * @param s sender connector * @param r receiver connector + * * @return connection result */ - public ConnectionResult tryConnect(Connector s, Connector r); + ConnectionResult tryConnect(Connector s, Connector r); /** * Requests the specified connection. If the specified connection can be @@ -85,102 +88,116 @@ interface FlowModel extends Model, VisibleState { * * @param s sender node * @param r receiver node + * * @return connection result */ - public ConnectionResult connect(Connector s, Connector r); + ConnectionResult connect(Connector s, Connector r); /** * Removes the specified node from this flow. * * @param n the node to remove + * * @return the removed node or null if no node has been removed */ - public VNode remove(VNode n); + VNode remove(VNode n); /** * Clears this flow, i.e., removes all nodes and connections. */ - public void clear(); + void clear(); /** * Returns the nodes of this flow. * * @return nodes of this flow */ - public ObservableList getNodes(); + ObservableList getNodes(); /** * Returns the sender of the specified connection. * * @param c connection + * * @return the sender of the specified connection or null if * the node does not exist */ - public VNode getSender(Connection c); + VNode getSender(Connection c); /** * Returns the receiver of the specified connection. * * @param c connection + * * @return the receiver of the specified connection or null if * the node does not exist */ - public VNode getReceiver(Connection c); + VNode getReceiver(Connection c); /** * Adds the specified connections to this flow. + * * @param connections connections to add - * @param flowType connection type + * @param flowType connection type */ - public void addConnections(Connections connections, String flowType); + void addConnections(Connections connections, String flowType); /** * Returns the all connections of the specified flow/connection type + * * @param flowType connection type + * * @return all connections of the specified flow/connection type */ - public Connections getConnections(String flowType); + Connections getConnections(String flowType); /** * Returns all connections of this flow. + * * @return all connections of this flow */ - public ObservableMap getAllConnections(); + ObservableMap getAllConnections(); /** * Defines the flow node implementation class used by this flow model. + * * @param cls flow node implementation class */ - public void setFlowNodeClass(Class cls); + void setFlowNodeClass(Class cls); /** * Returns the flow node implementation class used by this flow. + * * @return the flow node implementation class used by this flow */ - public Class getFlowNodeClass(); + Class getFlowNodeClass(); /** * Defines the id generator that shall be used by this flow. + * * @param generator id generator */ - public void setIdGenerator(IdGenerator generator); + void setIdGenerator(IdGenerator generator); /** * Returns the id generator used by this flow. + * * @return id generator */ - public IdGenerator getIdGenerator(); + IdGenerator getIdGenerator(); /** * Defines the node lookup that shall be used by this flow. + * * @param nodeLookup node lookup */ - public void setNodeLookup(NodeLookup nodeLookup); + void setNodeLookup(NodeLookup nodeLookup); /** * Returns the node lookup that is used by this flow. + * * @return node lookup */ - public NodeLookup getNodeLookup(); + NodeLookup getNodeLookup(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowModelImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowModelImpl.java index 85f1182c..24f36475 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowModelImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowModelImpl.java @@ -58,13 +58,13 @@ public class FlowModelImpl implements FlowModel { private final ObservableMap connections - = FXCollections.observableHashMap(); + = FXCollections.observableHashMap(); private final ObservableMap readOnlyObservableConnections - = FXCollections.unmodifiableObservableMap(connections); + = FXCollections.unmodifiableObservableMap(connections); private final ObservableList observableNodes - = FXCollections.observableArrayList(); + = FXCollections.observableArrayList(); private final ObservableList readOnlyObservableNodes - = FXCollections.unmodifiableObservableList(observableNodes); + = FXCollections.unmodifiableObservableList(observableNodes); private final Map nodes = new HashMap<>(); private Class flowNodeClass = VNodeImpl.class; private final BooleanProperty visibleProperty = new SimpleBooleanProperty(); @@ -111,7 +111,7 @@ public ConnectionResult tryConnect(VNode s, VNode r, String type) { } CompatibilityResult result = receiverValObj. - compatible(senderValObj, type); + compatible(senderValObj, type); return new ConnectionResultImpl(result, null); } @@ -136,10 +136,9 @@ public ConnectionResult connect(VNode s, VNode r, String type) { receiver = r.getMainInput(type); } -// System.out.println("ADD: " + sender + ", " + receiver); + // System.out.println("ADD: " + sender + ", " + receiver); Connection connection = getConnections(type).add(sender, receiver); - - + return new ConnectionResultImpl(result.getStatus(), connection); } @@ -147,7 +146,7 @@ public ConnectionResult connect(VNode s, VNode r, String type) { @Override public ConnectionResult tryConnect(Connector s, Connector r) { CompatibilityResult result = r.getValueObject(). - compatible(s.getValueObject(), s.getType()); + compatible(s.getValueObject(), s.getType()); return new ConnectionResultImpl(result, null); } @@ -183,21 +182,21 @@ public void clear() { @Override public VNode remove(VNode n) { -// if (n instanceof FlowModel) { -// ((FlowModel)n).clear(); -// } + // if (n instanceof FlowModel) { + // ((FlowModel)n).clear(); + // } VNode result = nodes.remove(n.getId()); observableNodes.remove(n); -// removeNodeSkin(n); + // removeNodeSkin(n); for (Connections cns : getAllConnections().values()) { Collection connectionsToRemove - = cns.getAllWithNode(n); + = cns.getAllWithNode(n); for (Connection c : connectionsToRemove) { cns.remove(c); -// removeConnectionSkin(c); + // removeConnectionSkin(c); } } @@ -257,7 +256,7 @@ VNode newNode(VNode result, ValueObject obj, String parentId) { throw new IllegalStateException("Please define an idgenerator before creating nodes!"); } - String id = getIdGenerator().newId(parentId+":"); + String id = getIdGenerator().newId(parentId + ":"); result.setId(id); diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowNodeSkinLookupImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowNodeSkinLookupImpl.java index 919db2dc..e76a1b32 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowNodeSkinLookupImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/FlowNodeSkinLookupImpl.java @@ -35,18 +35,16 @@ package eu.mihosoft.vrl.workflow; - import eu.mihosoft.vrl.workflow.skin.ConnectionSkin; import eu.mihosoft.vrl.workflow.skin.FlowNodeSkinLookup; import eu.mihosoft.vrl.workflow.skin.SkinFactory; import eu.mihosoft.vrl.workflow.skin.VNodeSkin; -import java.util.ArrayList; +import java.util.ArrayList; import java.util.Collection; import java.util.List; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class FlowNodeSkinLookupImpl implements FlowNodeSkinLookup { @@ -78,7 +76,7 @@ private List getNodeByGlobalId(VFlow parent, String id) { private VNodeSkin getNodeByGlobalId(SkinFactory skinFactory, VFlow parent, String id) { -// System.out.println("id: " + id); + // System.out.println("id: " + id); // find flow that contains the requested node VFlow flow; @@ -91,8 +89,8 @@ private VNodeSkin getNodeByGlobalId(SkinFactory skinFactory, VFlow parent, Strin if (flow == null) { return null; } -// -// System.out.println("found flow: " + flow.getModel().getId()); + // + // System.out.println("found flow: " + flow.getModel().getId()); for (SkinFactory sF : flow.getSkinFactories()) { if (getRootSkinFactoryOf(skinFactory) == getRootSkinFactoryOf(sF)) { @@ -100,8 +98,8 @@ private VNodeSkin getNodeByGlobalId(SkinFactory skinFactory, VFlow parent, Strin return getBySkinFactory(sF, s2); } } -// -// System.out.println(" --> nothing found :("); + // + // System.out.println(" --> nothing found :("); return null; } @@ -164,11 +162,11 @@ public VNodeSkin getById(SkinFactory skinFactory, String globalId) { VNodeSkin result = getNodeByGlobalId(skinFactory, root, globalId); -// if (result != null) { -// System.out.println("getById(): " + result); -// } else { -// System.out.println("NOT FOUND: getById(): " + null); -// } + // if (result != null) { + // System.out.println("getById(): " + result); + // } else { + // System.out.println("NOT FOUND: getById(): " + null); + // } return result; } @@ -183,7 +181,7 @@ public ConnectionSkin getById(SkinFactory skinFactory, Connection c) { if (senderFlow != receiverFlow) { throw new UnsupportedOperationException( - "Only skins for connections that share the same parent can be searched"); + "Only skins for connections that share the same parent can be searched"); } VFlow flow = root.getFlowById(senderFlow.getId()); @@ -191,7 +189,7 @@ public ConnectionSkin getById(SkinFactory skinFactory, Connection c) { if (!(flow instanceof VFlowImpl)) { System.err.println("flow: " + flow); throw new UnsupportedOperationException( - "Unsupported flow class '" + "Unsupported flow class '" + flow.getClass() + "', should implement '" + VFlowImpl.class + "'"); } @@ -199,14 +197,14 @@ public ConnectionSkin getById(SkinFactory skinFactory, Connection c) { VFlowImpl flowImpl = (VFlowImpl) flow; ConnectionSkin skin = flowImpl.getConnectionSkinMap(skinFactory).get( - VFlowImpl.connectionId(c)); - -// for (String key : flowImpl.getConnectionSkinMap(skinFactory).keySet()) { -// ConnectionSkin skinI = flowImpl.getConnectionSkinMap(skinFactory).get(key); -// System.out.println(" --> skin " + skinI + ": " + key + "==" + VFlowImpl.connectionId(c)); -// } -// -// System.out.println("skin for connection " + c + ": " + skin); + VFlowImpl.connectionId(c)); + + // for (String key : flowImpl.getConnectionSkinMap(skinFactory).keySet()) { + // ConnectionSkin skinI = flowImpl.getConnectionSkinMap(skinFactory).get(key); + // System.out.println(" --> skin " + skinI + ": " + key + "==" + VFlowImpl.connectionId(c)); + // } + // + // System.out.println("skin for connection " + c + ": " + skin); return skin; } } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IOConnector.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IOConnector.java index 8c80748c..d987fc8c 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IOConnector.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IOConnector.java @@ -34,13 +34,12 @@ package eu.mihosoft.vrl.workflow; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ -public final class IOConnector extends ConnectorImpl{ +public final class IOConnector extends ConnectorImpl { public IOConnector(VNode node, String type, String localId, boolean input) { super(node, type, localId, input); } - + } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IdGenerator.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IdGenerator.java index b4027246..777d83f2 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IdGenerator.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IdGenerator.java @@ -50,40 +50,43 @@ public interface IdGenerator { * * @param id id to add */ - public void addId(String id); + void addId(String id); /** * Adds all ids from the specified id generator. * * @param generator id generator that contains the ids that shall be added */ - public void addIds(IdGenerator generator); + void addIds(IdGenerator generator); /** * Generates a new id and adds it to this id generator. * * @return the generated id */ - public String newId(); + String newId(); /** * Generates a new id with the specified prefix and adds it to rhis id * generator. * * @param prefix id prefix + * * @return the generated id */ - public String newId(String prefix); + String newId(String prefix); /** * Returns the ids created/managed by this id generator - * @return + * + * @return */ - public Set getIds(); + Set getIds(); /** * Returns a new child id generator. + * * @return child id generator */ - public IdGenerator newChild(); + IdGenerator newChild(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IdGeneratorImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IdGeneratorImpl.java index 10103f9c..a787eafa 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IdGeneratorImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/IdGeneratorImpl.java @@ -44,7 +44,7 @@ class IdGeneratorImpl implements IdGenerator { private Set ids = new HashSet<>(); -// private int lastId = 0; + // private int lastId = 0; public IdGeneratorImpl() { // @@ -66,8 +66,8 @@ public String newId(String prefix) { // TODO improve id generation // Question: do we really want strings as id? int counter = 0;//lastId + 1; - - + + if (prefix != null && !prefix.isEmpty() && !prefix.endsWith(":")) { prefix = prefix + "-"; } @@ -81,7 +81,7 @@ public String newId(String prefix) { ids.add(id); -// lastId = counter; + // lastId = counter; return id; } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Lookup.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Lookup.java index 3fe94167..68c59fef 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Lookup.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Lookup.java @@ -45,8 +45,9 @@ public interface Lookup { * Returns the element with the specified id. * * @param id id of the requested element + * * @return the requested element or null if the requested * element does not exist */ - public T getById(String id); + T getById(String id); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/MouseButton.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/MouseButton.java index 80c05c4d..7e009eb2 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/MouseButton.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/MouseButton.java @@ -40,8 +40,9 @@ /** * This enum encapsulates the different mouse buttons that can be detected. - * @see ClickEvent + * * @author Michael Hoffer <info@michaelhoffer.de> + * @see ClickEvent */ public enum MouseButton { /** diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NoDefaultConnectorValueObject.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NoDefaultConnectorValueObject.java index dd283af3..d661b2e2 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NoDefaultConnectorValueObject.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NoDefaultConnectorValueObject.java @@ -34,7 +34,6 @@ package eu.mihosoft.vrl.workflow; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class NoDefaultConnectorValueObject extends DefaultValueObject { @@ -45,8 +44,7 @@ public NoDefaultConnectorValueObject() { public NoDefaultConnectorValueObject(VNode parent) { super(parent); } - - + @Override public CompatibilityResult compatible(final ValueObject sender, final String flowType) { diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeFactory.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeFactory.java index 8d105352..2c8bef0e 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeFactory.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeFactory.java @@ -37,15 +37,18 @@ /** * Node factory. - * @author Michael Hoffer <info@michaelhoffer.de> + * * @param node type * @param skin type + * + * @author Michael Hoffer <info@michaelhoffer.de> */ public interface NodeFactory> { - + /** * Creates a new node. + * * @return new node */ - public T newNode(); + T newNode(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeLookup.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeLookup.java index 6e9324a7..7e1b0021 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeLookup.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeLookup.java @@ -44,8 +44,9 @@ public interface NodeLookup extends Lookup { * Returns the connector with the specified id. * * @param id global connector id + * * @return connector with the specified global id or null if no * such connector exists */ - public Connector getConnectorById(String id); + Connector getConnectorById(String id); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeLookupImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeLookupImpl.java index f44d72b1..bf97b1e5 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeLookupImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/NodeLookupImpl.java @@ -38,7 +38,7 @@ /** * This class allows nodes to be looked up by id. * Ids have the format {@code :}. - * + *

* The class can also be used to look up connectors. * * @author Michael Hoffer <info@michaelhoffer.de> @@ -46,7 +46,7 @@ public class NodeLookupImpl implements NodeLookup { private final VFlowModel root; -// private final Map cache = new HashMap<>(); + // private final Map cache = new HashMap<>(); public NodeLookupImpl(VFlowModel root) { this.root = root; @@ -58,7 +58,7 @@ public Connector getConnectorById(String globalId) { if (ids.length < 2) { throw new IllegalArgumentException("wrong connector id format: " - + globalId + ", correct format: node-id:c:connector-id"); + + globalId + ", correct format: node-id:c:connector-id"); } String nodeId = ids[0]; @@ -75,21 +75,21 @@ public Connector getConnectorById(String globalId) { @Override public VNode getById(String globalId) { - -// VNode result = cache.get(globalId); - -// if (result!=null)return result; + + // VNode result = cache.get(globalId); + + // if (result!=null)return result; VNode result = getNodeByGlobalId(root, globalId); - -// cache.put(globalId, result); + + // cache.put(globalId, result); return result; } private VNode getNodeByGlobalId(VFlowModel parent, String id) { - - if (Objects.equals(parent.getId(),id)) { + + if (Objects.equals(parent.getId(), id)) { return parent; } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PathUtil.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PathUtil.java index 94ae1673..1df59416 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PathUtil.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PathUtil.java @@ -38,7 +38,6 @@ import java.util.Optional; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class PathUtil { @@ -51,21 +50,20 @@ private static List computeSendersAndReceivers(Connector s, Connector List result = new ArrayList<>(); Optional commonAncestorResult = WorkflowUtil. - getCommonAncestor(s.getNode(), r.getNode()); + getCommonAncestor(s.getNode(), r.getNode()); if (!commonAncestorResult.isPresent()) { return result; } - + VFlowModel commonAncestor = commonAncestorResult.get(); List ancestorsOfS = WorkflowUtil.getAncestors(s.getNode()); List ancestorsOfR = WorkflowUtil.getAncestors(r.getNode()); - + int indexOfCommonAncestorInS = ancestorsOfS.indexOf(commonAncestor); int indexOfCommonAncestorInR = ancestorsOfR.indexOf(commonAncestor); - - + return result; } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PropertyStorage.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PropertyStorage.java index 15af345a..914cf1e9 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PropertyStorage.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PropertyStorage.java @@ -39,13 +39,12 @@ package eu.mihosoft.vrl.workflow; -import java.util.Collection; import javafx.collections.MapChangeListener; +import java.util.Collection; import java.util.Optional; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public interface PropertyStorage { @@ -54,6 +53,7 @@ public interface PropertyStorage { * Indicates whether this storage contains the requested property. * * @param key key + * * @return {@code true} if this storage contains the requested property; * {@code false} */ @@ -71,6 +71,7 @@ public interface PropertyStorage { * * @param property type * @param key key + * * @return the property; an empty {@link java.util.Optional} will be * returned if the property does not exist or the type does not match */ @@ -79,27 +80,30 @@ public interface PropertyStorage { /** * Sets a property. Existing properties are overwritten. * - * @param key key + * @param key key * @param property property */ void set(String key, T property); - /** - * Adds the specified listener to the property map. + /** + * Adds the specified listener to the property map. + * * @param l change listener */ - public void addListener(MapChangeListener l); - + void addListener(MapChangeListener l); + /** * Removes the specified listener from the property map. + * * @param l change listener */ - public void removeListener(MapChangeListener l); - + void removeListener(MapChangeListener l); + /** * Returns the keys that are currently used by the property storage. + * * @return keys used by the property storage */ - public Collection getKeys(); - + Collection getKeys(); + } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PropertyStorageImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PropertyStorageImpl.java index bd35d06b..988f4b4b 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PropertyStorageImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/PropertyStorageImpl.java @@ -33,12 +33,11 @@ */ package eu.mihosoft.vrl.workflow; -import java.util.Collection; - import javafx.collections.FXCollections; import javafx.collections.MapChangeListener; import javafx.collections.ObservableMap; +import java.util.Collection; import java.util.Optional; /** @@ -60,7 +59,7 @@ public PropertyStorageImpl() { /** * Sets a property. Existing properties are overwritten. * - * @param key key + * @param key key * @param property property */ @Override @@ -73,6 +72,7 @@ public void set(String key, T property) { * * @param property type * @param key key + * * @return the property; an empty {@link java.util.Optional} will be * returned if the property does not exist or the type does not match */ @@ -102,6 +102,7 @@ public void remove(String key) { * Indicates whether this storage contains the requested property. * * @param key key + * * @return {@code true} if this storage contains the requested property; * {@code false} */ @@ -109,18 +110,20 @@ public void remove(String key) { public boolean contains(String key) { return map.containsKey(key); } - + /** - * Adds the specified listener to the property map. + * Adds the specified listener to the property map. + * * @param l change listener */ @Override public void addListener(MapChangeListener l) { map.addListener(l); } - + /** * Removes the specified listener from the property map. + * * @param l change listener */ @Override diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Selectable.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Selectable.java index d77978ca..84fe85ea 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Selectable.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/Selectable.java @@ -66,6 +66,7 @@ public interface Selectable { * Requests (de-)selection of this object. * * @param b selection state (true or false) + * * @return true if this object has been selected; * false otherwise */ diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ThruConnector.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ThruConnector.java index 10635849..f815f44f 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ThruConnector.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ThruConnector.java @@ -36,18 +36,21 @@ /** * A passthru connector. Passthru connectors are used to establish connections * between nodes in different hierarchy levels. + * * @author Michael Hoffer <info@michaelhoffer.de> */ -public interface ThruConnector extends Connector{ - +public interface ThruConnector extends Connector { + /** * Returns the inner connector node. + * * @return inner connector node */ VNode getInnerNode(); - + /** * Returns the inner connector. + * * @return inner connector */ Connector getInnerConnector(); diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ThruConnectorImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ThruConnectorImpl.java index 8848f9f6..5c109217 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ThruConnectorImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ThruConnectorImpl.java @@ -39,21 +39,21 @@ * * @author Michael Hoffer <info@michaelhoffer.de> */ -public class ThruConnectorImpl extends ConnectorImpl implements ThruConnector{ - +public class ThruConnectorImpl extends ConnectorImpl implements ThruConnector { + private VNode innerNode; private Connector innerConnector; public ThruConnectorImpl(VNode node, String type, String localId, boolean input, VNode innerNode, Connector innerConnector) { super(node, type, localId, input); - + this.innerNode = innerNode; this.innerConnector = innerConnector; } -// -// public ThruConnectorImpl(VNode node, Connector c) { -// super(node, c); -// } + // + // public ThruConnectorImpl(VNode node, Connector c) { + // super(node, c); + // } @Override public VNode getInnerNode() { @@ -65,5 +65,5 @@ public Connector getInnerConnector() { return this.innerConnector; } - + } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VConnections.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VConnections.java index 06b931df..95838043 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VConnections.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VConnections.java @@ -34,15 +34,14 @@ package eu.mihosoft.vrl.workflow; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class VConnections { - + public static Connections newConnections(String type) { return new ConnectionsImpl(type); } - + public static void printConnections(Connections connections) { for (Connection c : connections.getConnections()) { System.out.println(c.toString()); diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlow.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlow.java index ccdf7230..35a22f12 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlow.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlow.java @@ -60,35 +60,35 @@ public interface VFlow { * * @param flow flow model */ - public void setModel(VFlowModel flow); + void setModel(VFlowModel flow); /** * Defines the node lookup that shall be used by this flow controller. * * @param nodeLookup */ - public void setNodeLookup(NodeLookup nodeLookup); + void setNodeLookup(NodeLookup nodeLookup); /** * Returns the node lookup that is used by this flow controller. * * @return */ - public NodeLookup getNodeLookup(); + NodeLookup getNodeLookup(); /** * Returns the model that is used by this flow controller. * * @return the model that is used by this flow controller */ - public VFlowModel getModel(); + VFlowModel getModel(); /** * Returns the property of the model that is used by this flow controller. * * @return the property of the model that is used by this flow controller */ - public ObjectProperty modelProperty(); + ObjectProperty modelProperty(); /** * Attempts to create the specified connection. This method never creates an @@ -97,9 +97,10 @@ public interface VFlow { * * @param s sender connector * @param r receiver connector + * * @return connection result */ - public ConnectionResult tryConnect(Connector s, Connector r); + ConnectionResult tryConnect(Connector s, Connector r); /** * Requests the specified connection. If the specified connection can be @@ -107,151 +108,160 @@ public interface VFlow { * * @param s sender node * @param r receiver node + * * @return connection result */ - public ConnectionResult connect(Connector s, Connector r); + ConnectionResult connect(Connector s, Connector r); /** * Attempts to create the specified connection. This method never creates an * actual connection. It only checks whether the requested connection is * valid. * - * @param s sender node (uses main output connector of this node if - * specified) - * @param r receiver node (uses main input connector of this node if - * specified) + * @param s sender node (uses main output connector of this node if + * specified) + * @param r receiver node (uses main input connector of this node if + * specified) * @param flowType connection type + * * @return connection result */ - public ConnectionResult tryConnect(VNode s, VNode r, String flowType); + ConnectionResult tryConnect(VNode s, VNode r, String flowType); /** * Requests the specified connection. If the specified connection can be * established it will be created. * - * @param s sender node - * @param r receiver node + * @param s sender node + * @param r receiver node * @param flowType connection type + * * @return connection result */ - public ConnectionResult connect(VNode s, VNode r, String flowType); + ConnectionResult connect(VNode s, VNode r, String flowType); - public ConnectionResult tryConnect(VFlow s, VNode r, String flowType); + ConnectionResult tryConnect(VFlow s, VNode r, String flowType); - public ConnectionResult tryConnect(VNode s, VFlow r, String flowType); + ConnectionResult tryConnect(VNode s, VFlow r, String flowType); - public ConnectionResult tryConnect(VFlow s, VFlow r, String flowType); + ConnectionResult tryConnect(VFlow s, VFlow r, String flowType); - public ConnectionResult connect(VFlow s, VNode r, String flowType); + ConnectionResult connect(VFlow s, VNode r, String flowType); - public ConnectionResult connect(VNode s, VFlow r, String flowType); + ConnectionResult connect(VNode s, VFlow r, String flowType); - public ConnectionResult connect(VFlow s, VFlow r, String flowType); + ConnectionResult connect(VFlow s, VFlow r, String flowType); /** * Removes the specified node from this flow. * * @param n the node to remove + * * @return the removed node or null if no node has been removed */ - public VNode remove(VNode n); + VNode remove(VNode n); /** * Returns the nodes of this flow. * * @return nodes of this flow */ - public ObservableList getNodes(); + ObservableList getNodes(); /** * Clears this flow, i.e., removes all nodes and connections. */ - public void clear(); + void clear(); /** * Returns the sender of the specified connection. * * @param c connection + * * @return the sender of the specified connection or null if * the node does not exist */ - public VNode getSender(Connection c); + VNode getSender(Connection c); /** * Returns the receiver of the specified connection. * * @param c connection + * * @return the receiver of the specified connection or null if * the node does not exist */ - public VNode getReceiver(Connection c); + VNode getReceiver(Connection c); /** * Adds the specified connections to this flow controller. * * @param connections connections to add - * @param flowType connection type + * @param flowType connection type */ - public void addConnections(Connections connections, String flowType); + void addConnections(Connections connections, String flowType); /** * Returns the all connections of the specified flow/connection type * * @param flowType connection type + * * @return all connections of the specified flow/connection type */ - public Connections getConnections(String flowType); + Connections getConnections(String flowType); /** * Returns all connections of this flow controller. * * @return all connections of this flow controller */ - public ObservableMap getAllConnections(); + ObservableMap getAllConnections(); /** * Defines the flow node implementation class used by this flow controller. * * @param cls flow node implementation class */ - public void setFlowNodeClass(Class cls); + void setFlowNodeClass(Class cls); /** * Returns the flow node implementation class used by this flow controller. * * @return the flow node implementation class used by this flow controller */ - public Class getFlowNodeClass(); + Class getFlowNodeClass(); /** * Adds a new node to this flow. * * @param obj value object that shall be used for the requested node + * * @return new node */ - public VNode newNode(ValueObject obj); + VNode newNode(ValueObject obj); /** * Adds a new node to this flow. * * @return new node */ - public VNode newNode(); + VNode newNode(); /** * Adds a new subflow to this flow. * * @param obj value object that shall be used for the requested subflow + * * @return new subflow */ - public VFlow newSubFlow(ValueObject obj); + VFlow newSubFlow(ValueObject obj); /** * Adds a new subflow to this flow. * * @return new subflow */ - public VFlow newSubFlow(); + VFlow newSubFlow(); /** * Returns all direct subcontrollers of this flow controller. Subcontrollers @@ -260,97 +270,95 @@ public interface VFlow { * * @return all direct subcontrollers of this flow controller */ - public Collection getSubControllers(); + Collection getSubControllers(); /** * Defines the skin factories for this flow controller. * * @param skinFactories skin factories that shall be used by this flow - * controller - * - * Doesn't use Generics because generic arrays are not supported. GENERICS - * ARE CRAPPY! - * {@link http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6227971} - * + * controller + *

+ * Doesn't use Generics because generic arrays are not supported. GENERICS + * ARE CRAPPY! + * {@link http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6227971} */ - public void setSkinFactories(SkinFactory... skinFactories); + void setSkinFactories(SkinFactory... skinFactories); /** * Defines the skin factories for this flow controller. * * @param skinFactories skin factories that shall be used by this flow - * controller + * controller */ - public void setSkinFactories(Collection> skinFactories); + void setSkinFactories(Collection> skinFactories); /** * Returns the skin factories that are used by this flow controller. * * @return the skin factories that are used by this flow controller */ - public Collection> getSkinFactories(); + Collection> getSkinFactories(); /** * Adds the specified skin factories to this flow controller. * * @param skinFactories skin factories that shall be added to this flow - * controller - * - * Doesn't use Generics because generic arrays are not supported. GENERICS - * ARE CRAPPY! - * {@link http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6227971} - * + * controller + *

+ * Doesn't use Generics because generic arrays are not supported. GENERICS + * ARE CRAPPY! + * {@link http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6227971} */ - public void addSkinFactories(SkinFactory... skinFactories); + void addSkinFactories(SkinFactory... skinFactories); /** * Adds the specified skin factories to this flow controller. * * @param skinFactories skin factories that shall be added to this flow - * controller + * controller */ - public void addSkinFactories(Collection> skinFactories); + void addSkinFactories(Collection> skinFactories); /** * Removes the specified skin factories from this flow controller. * * @param skinFactories skin factories to be removed */ - public void removeSkinFactories(SkinFactory... skinFactories); + void removeSkinFactories(SkinFactory... skinFactories); /** * Removes the specified skin factories from this flow controller. * * @param skinFactories skin factories to be removed */ - public void removeSkinFactories(Collection> skinFactories); + void removeSkinFactories(Collection> skinFactories); /** * Defines the id generator that shall be used by this flow controller. * * @param generator id generator */ - public void setIdGenerator(IdGenerator generator); + void setIdGenerator(IdGenerator generator); /** * Returns the id generator used by this flow controller. * * @return id generator */ - public IdGenerator getIdGenerator(); + IdGenerator getIdGenerator(); - public List getNodeSkinsById(String id); + List getNodeSkinsById(String id); - public FlowNodeSkinLookup getNodeSkinLookup(); + FlowNodeSkinLookup getNodeSkinLookup(); - public void setNodeSkinLookup(FlowNodeSkinLookup skinLookup); + void setNodeSkinLookup(FlowNodeSkinLookup skinLookup); - public void setVisible(boolean state); + void setVisible(boolean state); - public boolean isVisible(); + boolean isVisible(); - public BooleanProperty visibleState(); + BooleanProperty visibleState(); Connector addInput(String type); @@ -360,10 +368,11 @@ public interface VFlow { * Returns child flow by id. * * @param id the id that specifies the requested flow + * * @return the requested child flow or null if no such flow * exists */ - public VFlow getFlowById(String id); + VFlow getFlowById(String id); VFlow getParent(); @@ -371,11 +380,11 @@ public interface VFlow { VFlow getRootFlow(); - public ThruConnector addThruInput(String type); + ThruConnector addThruInput(String type); - public ThruConnector addThruOutput(String type); + ThruConnector addThruOutput(String type); - public ObservableList getThruInputs(); + ObservableList getThruInputs(); - public ObservableList getThruOutputs(); + ObservableList getThruOutputs(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowImpl.java index deafddad..a8fbe461 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowImpl.java @@ -158,25 +158,25 @@ public void onChanged(ListChangeListener.Change change) { } else if (change.wasRemoved()) { // removed for (VNode n : change.getRemoved()) { -// if (nodeSkins.containsKey(n.getId())) { + // if (nodeSkins.containsKey(n.getId())) { if (!getNodeSkinsById(n.getId()).isEmpty()) { removeNodeSkinFromAllSkinFactories(n); for (Connector connector : n.getConnectors()) { -// System.out.println("conn: " + connector); + // System.out.println("conn: " + connector); Collection connections - = getConnections(connector.getType()). - getAllWith(connector); + = getConnections(connector.getType()). + getAllWith(connector); for (Connection connection : connections) { VFlowImpl.this.getConnections(connector.getType()). - remove(connection); + remove(connection); } } -// System.out.println("remove node: " + n.getId()); + // System.out.println("remove node: " + n.getId()); } if (n instanceof FlowModel) { @@ -187,13 +187,13 @@ public void onChanged(ListChangeListener.Change change) { } else if (change.wasAdded()) { // added for (VNode n : change.getAddedSubList()) { -// if (!nodeSkins.containsKey(n.getId())) { + // if (!nodeSkins.containsKey(n.getId())) { if (getNodeSkinsById(n.getId()).isEmpty()) { createNodeSkins(n, skinFactories); -// System.out.println("add node: " + n.getId() + ", title: " + n.getTitle()); + // System.out.println("add node: " + n.getId() + ", title: " + n.getTitle()); } else { String action = "handle error"; // TODO: implement -// System.out.println("can't add node: " + n.getId() + ", title: " + n.getTitle()); + // System.out.println("can't add node: " + n.getId() + ", title: " + n.getTitle()); } } } @@ -223,8 +223,8 @@ public void onChanged(ListChangeListener.Change change) { // 07.09.2013 // TODO add connector references to connections // reason: lookup is too expensive -// Connector s = getNodeLookup().getConnectorById(c.getSenderId()); -// Connector r = getNodeLookup().getConnectorById(c.getReceiverId()); + // Connector s = getNodeLookup().getConnectorById(c.getSenderId()); + // Connector r = getNodeLookup().getConnectorById(c.getReceiverId()); Connector s = c.getSender(); Connector r = c.getReceiver(); @@ -233,7 +233,7 @@ public void onChanged(ListChangeListener.Change change) { if (s != null) { Collection> eventHandlersS - = ((ConnectorImpl) s).getConnectionEventHandlers(); + = ((ConnectorImpl) s).getConnectionEventHandlers(); if (eventHandlersS != null) { for (EventHandler evtHandler : eventHandlersS) { @@ -249,7 +249,7 @@ public void onChanged(ListChangeListener.Change change) { if (r != null) { Collection> eventHandlersR - = ((ConnectorImpl) r).getConnectionEventHandlers(); + = ((ConnectorImpl) r).getConnectionEventHandlers(); if (eventHandlersR != null) { for (EventHandler evtHandler : eventHandlersR) { @@ -266,7 +266,7 @@ public void onChanged(ListChangeListener.Change change) { // remove skins for each connection // that have been removed removeConnectionSkinFromAllSkinFactories(c); -// System.out.println("remove skin: " + c); + // System.out.println("remove skin: " + c); } } else if (change.wasAdded()) { // added @@ -276,15 +276,15 @@ public void onChanged(ListChangeListener.Change change) { // 07.09.2013 // TODO add connector references to connections // reason: lookup is too expensive -// Connector s = getNodeLookup().getConnectorById(c.getSenderId()); -// Connector r = getNodeLookup().getConnectorById(c.getReceiverId()); + // Connector s = getNodeLookup().getConnectorById(c.getSenderId()); + // Connector r = getNodeLookup().getConnectorById(c.getReceiverId()); Connector s = c.getSender(); Connector r = c.getReceiver(); ConnectionEvent evt = new ConnectionEvent(ConnectionEvent.ADD, s, r, c); Collection> eventHandlersS - = ((ConnectorImpl) s).getConnectionEventHandlers(); + = ((ConnectorImpl) s).getConnectionEventHandlers(); if (eventHandlersS != null) { for (EventHandler evtHandler : eventHandlersS) { @@ -297,7 +297,7 @@ public void onChanged(ListChangeListener.Change change) { } Collection> eventHandlersR - = ((ConnectorImpl) r).getConnectionEventHandlers(); + = ((ConnectorImpl) r).getConnectionEventHandlers(); if (eventHandlersR != null) { for (EventHandler evtHandler : eventHandlersR) { @@ -312,7 +312,7 @@ public void onChanged(ListChangeListener.Change change) { // fire events // create skins for added connections createConnectionSkins(c, c.getType(), getSkinFactories()); -// System.out.println("add skin: " + c); + // System.out.println("add skin: " + c); } } } @@ -324,7 +324,7 @@ public void onChanged(ListChangeListener.Change change) { @Override public void changed(ObservableValue ov, Boolean t, Boolean t1) { -// System.out.println("visible: " + t1 + " : " + getModel().isVisible() + " : " + getModel().getId()); + // System.out.println("visible: " + t1 + " : " + getModel().isVisible() + " : " + getModel().getId()); if (t1) { setSkinFactories(getSkinFactories()); } else { @@ -337,7 +337,7 @@ public void changed(ObservableValue ov, Boolean t, Boolean t1 @Override public void changed(ObservableValue ov, FlowModel t, FlowModel t1) { -// removeUIFromAllSkinFactories(); + // removeUIFromAllSkinFactories(); Collection> tmpFactories = new ArrayList<>(); tmpFactories.addAll(getSkinFactories()); removeSkinFactories(getSkinFactories()); @@ -526,10 +526,10 @@ private List> createNodeSkins(VNode n, SkinFactory> creating skins for node: " + n.getId()); + // System.out.println(">> creating skins for node: " + n.getId()); List> skins = new ArrayList<>(); -// System.out.println(" --> #skinFactories: " + skinFactories.length); + // System.out.println(" --> #skinFactories: " + skinFactories.length); for (SkinFactory skinFactory : skinFactories) { if (skinFactory == null) { @@ -537,10 +537,10 @@ private List> createNodeSkins(VNode n, SkinFactory adding to skinfsctory: " + skinFactory); + // System.out.println(" --> adding to skinfsctory: " + skinFactory); VNodeSkin skin = skinFactory.createSkin(n, this); -// nodeSkins.put(n.getId(), skin); + // nodeSkins.put(n.getId(), skin); putNodeSkin(skinFactory, skin); skin.add(); @@ -555,7 +555,7 @@ private List> createNodeSkins(VNode n, SkinFactory skin) { Map nodeSkinMap = getNodeSkinMap(skinFactory); -// System.out.println("put skin " + skin + "for: " + skin.getModel().getId() + ", factory: " + skinFactory); + // System.out.println("put skin " + skin + "for: " + skin.getModel().getId() + ", factory: " + skinFactory); nodeSkinMap.put(skin.getModel().getId(), skin); } @@ -564,7 +564,7 @@ private VNodeSkin getNodeSkin(SkinFactory skinFactory, String id) { VNodeSkin nodeSkin = nodeSkinMap.get(id); -// System.out.println("skin for " + id + " = " + nodeSkin + ", factory: " + skinFactory + ", controller: " + getModel().getId()); + // System.out.println("skin for " + id + " = " + nodeSkin + ", factory: " + skinFactory + ", controller: " + getModel().getId()); return nodeSkin; } @@ -666,7 +666,7 @@ private List createConnectionSkins(Connection c, String type, Sk ConnectionSkin skin = skinFactory.createSkin(c, this, type); -// connectionSkins.put(connectionId(c), skin); + // connectionSkins.put(connectionId(c), skin); putConnectionSkin(skinFactory, skin); skin.add(); @@ -787,7 +787,7 @@ public final void addSkinFactories(SkinFactory... skinFactories) { if (sF != null) { childNodeSkinFactory = sF.createChild( - getNodeSkin(sF, fC.getModel().getId())); + getNodeSkin(sF, fC.getModel().getId())); } childSkinFactories.add(childNodeSkinFactory); @@ -799,9 +799,9 @@ public final void addSkinFactories(SkinFactory... skinFactories) { @Override public void removeSkinFactories(SkinFactory... skinFactories) { -// if (getModel() != null) { -// System.out.println(">> remove skinfactories from " + getModel().getId() + ", #sf: " + getSkinFactories().size()); -// } + // if (getModel() != null) { + // System.out.println(">> remove skinfactories from " + getModel().getId() + ", #sf: " + getSkinFactories().size()); + // } for (SkinFactory skinFactory : skinFactories) { @@ -821,7 +821,7 @@ public void removeSkinFactories(SkinFactory #skinFactories: " + getSkinFactories().size()); + // System.out.println(" --> #skinFactories: " + getSkinFactories().size()); } @Override @@ -876,7 +876,7 @@ private VFlow newSubFlow(VFlowModel flowNode) { VNodeSkin skin = getNodeSkin(skinFactory, flowNode.getId());//nodeSkins.get(flowNode.getId()); -// System.out.println("skin: " + skin + ", node: " + flowNode.getId()); + // System.out.println("skin: " + skin + ", node: " + flowNode.getId()); SkinFactory childFactory = null; if (skinFactory != null) { @@ -895,8 +895,8 @@ private VFlow newSubFlow(VFlowModel flowNode) { for (String connectionType : getAllConnections().keySet()) { if (flowNode.getConnections(connectionType) == null) { controller.addConnections( - VConnections.newConnections(connectionType), - connectionType); + VConnections.newConnections(connectionType), + connectionType); } } @@ -979,37 +979,37 @@ public BooleanProperty visibleState() { return getModel().visibleProperty(); } -// @Override -// public boolean isInputOfType(String type) { -// return getModel().isInputOfType(type); -// } -// -// @Override -// public boolean isOutputOfType(String type) { -// return getModel().isOutputOfType(type); -// } -// -// @Override -// public boolean isInput() { -// return getModel().isInput(); -// } -// -// @Override -// public boolean isOutput() { -// return getModel().isOutput(); -// } -// -// -// -// @Override -// public ObservableList getInputTypes() { -// return getModel().getInputTypes(); -// } -// -// @Override -// public ObservableList getOutputTypes() { -// return getModel().getOutputTypes(); -// } + // @Override + // public boolean isInputOfType(String type) { + // return getModel().isInputOfType(type); + // } + // + // @Override + // public boolean isOutputOfType(String type) { + // return getModel().isOutputOfType(type); + // } + // + // @Override + // public boolean isInput() { + // return getModel().isInput(); + // } + // + // @Override + // public boolean isOutput() { + // return getModel().isOutput(); + // } + // + // + // + // @Override + // public ObservableList getInputTypes() { + // return getModel().getInputTypes(); + // } + // + // @Override + // public ObservableList getOutputTypes() { + // return getModel().getOutputTypes(); + // } public synchronized Map getNodeSkinMap(SkinFactory skinFactory) { Map nodeSkinMap = nodeSkins.get(skinFactory); if (nodeSkinMap == null) { diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowModel.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowModel.java index ba781f54..294c5df8 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowModel.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowModel.java @@ -36,24 +36,24 @@ import javafx.collections.ObservableList; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public interface VFlowModel extends FlowModel, VNode { - public VFlowModel newFlowNode(ValueObject obj); + VFlowModel newFlowNode(ValueObject obj); + + VFlowModel newFlowNode(); + + VNode newNode(ValueObject obj); - public VFlowModel newFlowNode(); + VNode newNode(); - public VNode newNode(ValueObject obj); + ThruConnector addThruInput(String type); - public VNode newNode(); + ThruConnector addThruOutput(String type); - public ThruConnector addThruInput(String type); + ObservableList getThruInputs(); - public ThruConnector addThruOutput(String type); - - public ObservableList getThruInputs(); - public ObservableList getThruOutputs(); + ObservableList getThruOutputs(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowModelImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowModelImpl.java index 032d037a..d437dd72 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowModelImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowModelImpl.java @@ -51,7 +51,6 @@ import java.util.logging.Logger; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ class VFlowModelImpl implements VFlowModel { @@ -60,13 +59,13 @@ class VFlowModelImpl implements VFlowModel { private final FlowModelImpl flow; private ObservableList thruInputs - = FXCollections.observableArrayList(); + = FXCollections.observableArrayList(); private ObservableList thruOutputs - = FXCollections.observableArrayList(); + = FXCollections.observableArrayList(); private final ObservableList unmodifiableThruInputs - = FXCollections.unmodifiableObservableList(thruInputs); + = FXCollections.unmodifiableObservableList(thruInputs); private final ObservableList unmodifiableThruOutputs - = FXCollections.unmodifiableObservableList(thruOutputs); + = FXCollections.unmodifiableObservableList(thruOutputs); @Override public BooleanProperty visibleProperty() { @@ -106,25 +105,25 @@ public VFlowModelImpl(FlowModel parentFlow) { setTitle("Node"); node.getConnectors().addListener( - (ListChangeListener.Change c) -> { - while (c.next()) { - for (Connector connector : c.getRemoved()) { - if (connector instanceof ThruConnector) { - - ThruConnector tC = (ThruConnector) connector; + (ListChangeListener.Change c) -> { + while (c.next()) { + for (Connector connector : c.getRemoved()) { + if (connector instanceof ThruConnector) { - if (tC.isInput()) { - thruInputs.remove(tC); - } else if (tC.isOutput()) { - thruOutputs.remove(tC); - } + ThruConnector tC = (ThruConnector) connector; - flow.remove(tC.getInnerNode()); + if (tC.isInput()) { + thruInputs.remove(tC); + } else if (tC.isOutput()) { + thruOutputs.remove(tC); } - } + flow.remove(tC.getInnerNode()); + } } - }); + + } + }); } @@ -323,15 +322,15 @@ public VFlowModel getFlow() { return node.getFlow(); } -// @Override -// public boolean isInput() { -// return node.isInput(); -// } -// -// @Override -// public boolean isOutput() { -// return node.isOutput(); -// } + // @Override + // public boolean isInput() { + // return node.isInput(); + // } + // + // @Override + // public boolean isOutput() { + // return node.isOutput(); + // } @Override public VFlowModel newFlowNode(ValueObject obj) { VFlowModel flowNode = new VFlowModelImpl(this); @@ -386,10 +385,10 @@ public VNode newNode() { return result; } -// @Override -// public String getGlobalId() { -// return node.getGlobalId(); -// } + // @Override + // public String getGlobalId() { + // return node.getGlobalId(); + // } @Override public final void setIdGenerator(IdGenerator generator) { flow.setIdGenerator(generator); @@ -410,25 +409,25 @@ public NodeLookup getNodeLookup() { return flow.getNodeLookup(); } -// @Override -// public ObservableList getInputTypes() { -// return node.getInputTypes(); -// } -// -// @Override -// public ObservableList getOutputTypes() { -// return node.getOutputTypes(); -// } -// -// @Override -// public boolean isInputOfType(String type) { -// return node.isInputOfType(type); -// } -// -// @Override -// public boolean isOutputOfType(String type) { -// return node.isOutputOfType(type); -// } + // @Override + // public ObservableList getInputTypes() { + // return node.getInputTypes(); + // } + // + // @Override + // public ObservableList getOutputTypes() { + // return node.getOutputTypes(); + // } + // + // @Override + // public boolean isInputOfType(String type) { + // return node.isInputOfType(type); + // } + // + // @Override + // public boolean isOutputOfType(String type) { + // return node.isOutputOfType(type); + // } @Override public Connector getMainInput(String type) { return this.node.getMainInput(type); @@ -532,13 +531,13 @@ public ThruConnector addThruInput(String type) { VNode innerNode = newNode(); innerNode.getVisualizationRequest(). - set(VisualizationRequest.KEY_NODE_NOT_REMOVABLE, true); + set(VisualizationRequest.KEY_NODE_NOT_REMOVABLE, true); Connector innerConnector = innerNode. - setMainOutput(innerNode.addOutput(type)); + setMainOutput(innerNode.addOutput(type)); ThruConnector tC = node.addThruInput( - node, type, innerNode, innerConnector); + node, type, innerNode, innerConnector); thruInputs.add(tC); @@ -551,13 +550,13 @@ public ThruConnector addThruOutput(String type) { VNode innerNode = newNode(); innerNode.getVisualizationRequest(). - set(VisualizationRequest.KEY_NODE_NOT_REMOVABLE, true); + set(VisualizationRequest.KEY_NODE_NOT_REMOVABLE, true); Connector innerConnector = innerNode. - setMainInput(innerNode.addInput(type)); + setMainInput(innerNode.addInput(type)); ThruConnector tC = node.addThruOutput( - node, type, innerNode, innerConnector); + node, type, innerNode, innerConnector); thruOutputs.add(tC); diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VNode.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VNode.java index 067bcd34..88410138 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VNode.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VNode.java @@ -42,126 +42,127 @@ import java.util.Collection; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public interface VNode extends Model, Selectable { - public StringProperty titleProperty(); + StringProperty titleProperty(); - public void setTitle(String title); + void setTitle(String title); - public String getTitle(); + String getTitle(); - public StringProperty idProperty(); + StringProperty idProperty(); /** * Defines the local id of this node. * * @param id id to set */ - public void setId(String id); + void setId(String id); /** * Returns the local id of this node. * * @return */ - public String getId(); + String getId(); /** * Returns the global id of this node * * @return global id of this node */ -// public String getGlobalId(); - public DoubleProperty xProperty(); + // String getGlobalId(); + DoubleProperty xProperty(); + + DoubleProperty yProperty(); + + void setX(double x); + + void setY(double x); + + double getX(); - public DoubleProperty yProperty(); + double getY(); - public void setX(double x); + DoubleProperty widthProperty(); - public void setY(double x); + DoubleProperty heightProperty(); - public double getX(); + void setWidth(double w); - public double getY(); + void setHeight(double h); - public DoubleProperty widthProperty(); + double getWidth(); - public DoubleProperty heightProperty(); + double getHeight(); - public void setWidth(double w); + // ObservableList getChildren(); + // ObservableList> getInputs(); + // ObservableList> getOutputs(); + void setValueObject(ValueObject obj); - public void setHeight(double h); + ValueObject getValueObject(); - public double getWidth(); + ObjectProperty valueObjectProperty(); - public double getHeight(); + VFlowModel getFlow(); -// public ObservableList getChildren(); -// public ObservableList> getInputs(); -// public ObservableList> getOutputs(); - public void setValueObject(ValueObject obj); + // boolean isInputOfType(String type); + // + // boolean isOutputOfType(String type); + // boolean isInput(); + // + // boolean isOutput(); + // void setInput(boolean state, String type); + // void setOutput(boolean state, String type); + Connector addInput(String type); - public ValueObject getValueObject(); + Connector addOutput(String type); - public ObjectProperty valueObjectProperty(); + Connector addConnector(Connector c); - public VFlowModel getFlow(); + boolean removeConnector(Connector c); -// boolean isInputOfType(String type); -// -// boolean isOutputOfType(String type); -// boolean isInput(); -// -// boolean isOutput(); -// void setInput(boolean state, String type); -// void setOutput(boolean state, String type); - public Connector addInput(String type); + // ObservableList getInputTypes(); + // + // ObservableList getOutputTypes(); + Collection getMainInputTypes(); - public Connector addOutput(String type); + Collection getMainOutputTypes(); - public Connector addConnector(Connector c); - - public boolean removeConnector(Connector c); + Connector getMainInput(String type); -// ObservableList getInputTypes(); -// -// ObservableList getOutputTypes(); - public Collection getMainInputTypes(); + Connector getMainOutput(String type); - public Collection getMainOutputTypes(); + Connector setMainInput(Connector connector); - public Connector getMainInput(String type); + Connector setMainOutput(Connector connector); - public Connector getMainOutput(String type); + Connector getConnector(String localId); - public Connector setMainInput(Connector connector); + ObservableList getConnectors(); - public Connector setMainOutput(Connector connector); + ObservableList getInputs(); - public Connector getConnector(String localId); + ObservableList getOutputs(); - public ObservableList getConnectors(); + BooleanProperty selectableProperty(); + + boolean isSelectable(); - public ObservableList getInputs(); - public ObservableList getOutputs(); - - public BooleanProperty selectableProperty(); - public boolean isSelectable(); - - /** * Returns the distance to the root element. */ - public int getDepth(); - + int getDepth(); + /** * Returns the root element of this flow. + * * @return root element */ - public FlowModel getRoot(); - + FlowModel getRoot(); + } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VNodeImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VNodeImpl.java index 1b3541e4..fb2f6d42 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VNodeImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VNodeImpl.java @@ -54,21 +54,20 @@ import java.util.Map; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ class VNodeImpl implements VNode { private final ObservableList connectors - = FXCollections.observableArrayList(); + = FXCollections.observableArrayList(); private ObservableList inputs - = FXCollections.observableArrayList(); + = FXCollections.observableArrayList(); private ObservableList outputs - = FXCollections.observableArrayList(); + = FXCollections.observableArrayList(); private final ObservableList unmodifiableInputs - = FXCollections.unmodifiableObservableList(inputs); + = FXCollections.unmodifiableObservableList(inputs); private final ObservableList unmodifiableOutputs - = FXCollections.unmodifiableObservableList(outputs); + = FXCollections.unmodifiableObservableList(outputs); private final StringProperty idProperty = new SimpleStringProperty(); private final StringProperty titleProperty = new SimpleStringProperty(); private final DoubleProperty xProperty = new SimpleDoubleProperty(); @@ -80,7 +79,7 @@ class VNodeImpl implements VNode { private final BooleanProperty selectableProperty = new SimpleBooleanProperty(true); private final ObjectProperty valueObjectProperty - = new SimpleObjectProperty<>(); + = new SimpleObjectProperty<>(); private VFlowModel flow; private IdGenerator connectorIdGenerator = new IdGeneratorImpl(); @@ -118,10 +117,10 @@ public void onChanged(Change change) { String action = "permutate"; // TODO: implement } } -// else if (change.wasUpdated()) { -// //TODO: update item -// -// } + // else if (change.wasUpdated()) { + // //TODO: update item + // + // } else if (change.wasRemoved()) { for (Connector connector : change.getRemoved()) { if (connector.isInput()) { @@ -142,12 +141,12 @@ else if (change.wasRemoved()) { for (Connector connector : change.getAddedSubList()) { if (connector.isInput()) { inputs.add(connector); -// System.out.println("added input:" + unmodifiableInputs.size()); + // System.out.println("added input:" + unmodifiableInputs.size()); } if (connector.isOutput()) { outputs.add(connector); -// System.out.println("added output:" + unmodifiableOutputs.size()); + // System.out.println("added output:" + unmodifiableOutputs.size()); } if (connector instanceof ThruConnector) { @@ -161,24 +160,24 @@ else if (change.wasRemoved()) { } }); -// -// outputs.addListener(new ListChangeListener>() { -// @Override -// public void onChanged(Change> change) { -// throw new UnsupportedOperationException("Not supported yet."); -// } -// }); - } - -// @Override -// public ObservableList> getInputs() { -// return inputs; -// } -// -// @Override -// public ObservableList> getOutputs() { -// return outputs; -// } + // + // outputs.addListener(new ListChangeListener>() { + // @Override + // public void onChanged(Change> change) { + // throw new UnsupportedOperationException("Not supported yet."); + // } + // }); + } + + // @Override + // public ObservableList> getInputs() { + // return inputs; + // } + // + // @Override + // public ObservableList> getOutputs() { + // return outputs; + // } @Override public StringProperty titleProperty() { return titleProperty; @@ -269,10 +268,10 @@ public double getHeight() { return heightProperty.get(); } -// @Override -// public ObservableList getChildren() { -// return children; -// } + // @Override + // public ObservableList getChildren() { + // return children; + // } @Override public ValueObject getValueObject() { return valueObjectProperty.get(); @@ -322,20 +321,21 @@ public ReadOnlyProperty visualizationRequestProperty() { return _visualizationRequestProperty(); } -// @Override -// public void setSkin(Skin skin) { -// skinProperty.set(skin); -// } -// -// @Override -// public Skin getSkin() { -// return skinProperty.get(); -// } -// -// @Override -// public ObjectProperty skinProperty() { -// return skinProperty; -// } + // @Override + // public void setSkin(Skin skin) { + // skinProperty.set(skin); + // } + // + // @Override + // public Skin getSkin() { + // return skinProperty.get(); + // } + // + // @Override + // public ObjectProperty skinProperty() { + // return skinProperty; + // } + /** * @return the flow */ @@ -344,23 +344,23 @@ public VFlowModel getFlow() { return flow; } -// @Override -// public void setOutput(boolean state, String type) { -// if (state && !outputTypes.contains(type)) { -// outputTypes.add(type); -// } else if (!state) { -// outputTypes.remove(type); -// } -// } -// -// @Override -// public void setInput(boolean state, String type) { -// if (state && !inputTypes.contains(type)) { -// inputTypes.add(type); -// } else if (!state) { -// inputTypes.remove(type); -// } -// } + // @Override + // public void setOutput(boolean state, String type) { + // if (state && !outputTypes.contains(type)) { + // outputTypes.add(type); + // } else if (!state) { + // outputTypes.remove(type); + // } + // } + // + // @Override + // public void setInput(boolean state, String type) { + // if (state && !inputTypes.contains(type)) { + // inputTypes.add(type); + // } else if (!state) { + // inputTypes.remove(type); + // } + // } @Override public Connector addInput(String type) { return addInput(this, type); @@ -378,28 +378,28 @@ public Connector addConnector(Connector c) { Connector addInput(VNode node, String type) { Connector c = new ConnectorImpl( - node, type, null, true); + node, type, null, true); connectors.add(c); return c; } Connector addOutput(VNode node, String type) { Connector c = new ConnectorImpl( - node, type, null, false); + node, type, null, false); connectors.add(c); return c; } ThruConnector addThruInput(VNode node, String type, VNode innerNode, Connector innerConnector) { ThruConnector c = new ThruConnectorImpl( - node, type, null, true, innerNode, innerConnector); + node, type, null, true, innerNode, innerConnector); connectors.add(c); return c; } ThruConnector addThruOutput(VNode node, String type, VNode innerNode, Connector innerConnector) { ThruConnector c = new ThruConnectorImpl( - node, type, null, false, innerNode, innerConnector); + node, type, null, false, innerNode, innerConnector); connectors.add(c); return c; } @@ -409,7 +409,7 @@ Connector addConnector(VNode node, Connector c) { if (connectorIdGenerator.getIds().contains(localId)) { throw new IllegalArgumentException( - "Cannot add connector: id \"" + localId + "\" already in use"); + "Cannot add connector: id \"" + localId + "\" already in use"); } Connector result = new ConnectorImpl(node, c); @@ -420,51 +420,51 @@ Connector addConnector(VNode node, Connector c) { return result; } -// @Override -// public boolean isInputOfType(String type) { -// return inputTypes.contains(type); -// } -// -// @Override -// public boolean isOutputOfType(String type) { -// return outputTypes.contains(type); -// } -// -// @Override -// public boolean isOutput() { -// return !outputTypes.isEmpty(); -// } -// -// @Override -// public boolean isInput() { -// return !inputTypes.isEmpty(); -// } -// @Override -// public String getGlobalId() { -// String id = getId(); -// -// if (getFlow() ==null) { -// return id; -// } -// -// FlowNode parent = getFlow(); -// -// while (parent.getFlow()!=null) { -// id = parent.getGlobalId() + ":" + id; -// parent = parent.getFlow(); -// } -// -// return id; -// } -// @Override -// public ObservableList getInputTypes() { -// return inputTypes; -// } -// -// @Override -// public ObservableList getOutputTypes() { -// return outputTypes; -// } + // @Override + // public boolean isInputOfType(String type) { + // return inputTypes.contains(type); + // } + // + // @Override + // public boolean isOutputOfType(String type) { + // return outputTypes.contains(type); + // } + // + // @Override + // public boolean isOutput() { + // return !outputTypes.isEmpty(); + // } + // + // @Override + // public boolean isInput() { + // return !inputTypes.isEmpty(); + // } + // @Override + // public String getGlobalId() { + // String id = getId(); + // + // if (getFlow() ==null) { + // return id; + // } + // + // FlowNode parent = getFlow(); + // + // while (parent.getFlow()!=null) { + // id = parent.getGlobalId() + ":" + id; + // parent = parent.getFlow(); + // } + // + // return id; + // } + // @Override + // public ObservableList getInputTypes() { + // return inputTypes; + // } + // + // @Override + // public ObservableList getOutputTypes() { + // return outputTypes; + // } @Override public Connector getMainInput(String type) { return mainInputs.get(type); diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ValueObject.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ValueObject.java index 96c313ac..2959ed61 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ValueObject.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ValueObject.java @@ -36,17 +36,23 @@ import javafx.beans.property.ObjectProperty; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public interface ValueObject { - public VNode getParent(); - public void setParent(VNode p); - public Object getValue(); - public void setValue(Object o); - public ObjectProperty valueProperty(); + VNode getParent(); + + void setParent(VNode p); + + Object getValue(); + + void setValue(Object o); + + ObjectProperty valueProperty(); + // assumes we are receiver - public CompatibilityResult compatible(ValueObject sender, String flowTpe); - public VisualizationRequest getVisualizationRequest(); - public void setVisualizationRequest(VisualizationRequest vReq); + CompatibilityResult compatible(ValueObject sender, String flowTpe); + + VisualizationRequest getVisualizationRequest(); + + void setVisualizationRequest(VisualizationRequest vReq); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisibleState.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisibleState.java index d03cca1e..8511603a 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisibleState.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisibleState.java @@ -36,14 +36,13 @@ import javafx.beans.property.BooleanProperty; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public interface VisibleState { - public BooleanProperty visibleProperty(); + BooleanProperty visibleProperty(); - public boolean isVisible(); + boolean isVisible(); - public void setVisible(boolean b); + void setVisible(boolean b); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisualizationRequest.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisualizationRequest.java index e2d1f896..8c442c8f 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisualizationRequest.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisualizationRequest.java @@ -34,34 +34,34 @@ package eu.mihosoft.vrl.workflow; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ -public interface VisualizationRequest extends PropertyStorage{ - - static final String KEY_STYLE = "visualization-request:style"; +public interface VisualizationRequest extends PropertyStorage { + + String KEY_STYLE = "visualization-request:style"; /** * Defines the maximum connector size. */ - static final String KEY_MAX_CONNECTOR_SIZE = "visualization-request:connector:max-size"; + String KEY_MAX_CONNECTOR_SIZE = "visualization-request:connector:max-size"; /** * Defines whether connectors can change their layout position (switch edges). */ - static final String KEY_CONNECTOR_AUTO_LAYOUT = "visualization-request:connector:auto-layout"; + String KEY_CONNECTOR_AUTO_LAYOUT = "visualization-request:connector:auto-layout"; /** * Defines whether to disable editing, i.e., changes to nodes and connections. */ - static final String KEY_DISABLE_EDITING = "visualization-request:skin:disable-editing"; + String KEY_DISABLE_EDITING = "visualization-request:skin:disable-editing"; /** * Defines whether nodes can be removed. */ - static final String KEY_NODE_NOT_REMOVABLE = "visualization-request:skin:node-not-removable"; - + String KEY_NODE_NOT_REMOVABLE = "visualization-request:skin:node-not-removable"; + /** * Defines whether connector prefers top-down layout. */ - static final String KEY_CONNECTOR_PREFER_TOP_DOWN = "visualization-request:connector:prefer-top-down"; - - public void setStyle(String style); - public String getStyle(); + String KEY_CONNECTOR_PREFER_TOP_DOWN = "visualization-request:connector:prefer-top-down"; + + void setStyle(String style); + + String getStyle(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisualizationRequestImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisualizationRequestImpl.java index ca9c2183..d962a07d 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisualizationRequestImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VisualizationRequestImpl.java @@ -39,7 +39,6 @@ package eu.mihosoft.vrl.workflow; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ class VisualizationRequestImpl extends PropertyStorageImpl implements VisualizationRequest { diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/WorkflowUtil.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/WorkflowUtil.java index 516bb410..d9a68f8a 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/WorkflowUtil.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/WorkflowUtil.java @@ -45,11 +45,11 @@ * @author Michael Hoffer <info@michaelhoffer.de> */ public class WorkflowUtil { - + public static final String CONTROL_FLOW = "control"; public static final String DATA_FLOW = "data"; public static final String EVENT_FLOW = "event"; - + private WorkflowUtil() { throw new AssertionError(); @@ -58,10 +58,11 @@ private WorkflowUtil() { /** * Returns a predicate that indicates whether a connector is connected with * the specified connection type. - * + *

* Note: the predicate can be used to filter streams and collections. * * @param connectionType connection type (e.g. "data" or "control") + * * @return a predicate that indicates whether a connector is connected with * the specified connection type * @@ -70,9 +71,9 @@ private WorkflowUtil() { public static Predicate connectorConnected(String connectionType) { return (Connector c) -> { return c.getType().equals(connectionType) - && !c.getNode().getFlow(). - getConnections(connectionType). - getAllWith(c).isEmpty(); + && !c.getNode().getFlow(). + getConnections(connectionType). + getAllWith(c).isEmpty(); }; } @@ -81,13 +82,14 @@ public static Predicate connectorConnected(String connectionType) { * with the specified connection type. * * @param connectionType connection type (e.g. "data" or "control") + * * @return a predicate that indicates whether a connector is not connected * with the specified connection type * * @see java.util.stream.Stream */ public static Predicate connectorNotConnected( - String connectionType) { + String connectionType) { return connectorConnected(connectionType).negate(); } @@ -96,6 +98,7 @@ public static Predicate connectorNotConnected( * specified connection type. * * @param connectionType connection type (e.g. "data" or "control") + * * @return a predicate that indicates whether a node is connected with the * specified connection type * @@ -104,7 +107,7 @@ public static Predicate connectorNotConnected( public static Predicate nodeConnected(String connectionType) { return (VNode n) -> { return !n.getInputs().filtered(connectorConnected(connectionType)). - isEmpty(); + isEmpty(); }; } @@ -113,6 +116,7 @@ public static Predicate nodeConnected(String connectionType) { * the specified connection type. * * @param connectionType connection type (e.g. "data" or "control") + * * @return a predicate that indicates whether a node is not connected with * the specified connection type * @@ -128,19 +132,20 @@ public static Predicate nodeNotConnected(String connectionType) { * connections. Only connections of the specifed type are counted. * * @param expectedNumConn expected number of connections - * @param connectionType connection type (e.g. "data" or "control") + * @param connectionType connection type (e.g. "data" or "control") + * * @return a predicate that indicates whether the number of connections of * the specified connector is bigger than the expected number of connections * * @see java.util.stream.Stream */ public static Predicate moreThanConnections(int expectedNumConn, - String connectionType) { + String connectionType) { return (Connector c) -> { return c.getType().equals(connectionType) - && c.getNode().getFlow(). - getConnections(connectionType). - getAllWith(c).size() > expectedNumConn; + && c.getNode().getFlow(). + getConnections(connectionType). + getAllWith(c).size() > expectedNumConn; }; } @@ -150,7 +155,8 @@ public static Predicate moreThanConnections(int expectedNumConn, * connections. Only connections of the specifed type are counted. * * @param expectedNumConn expected number of connections - * @param connectionType connection type (e.g. "data" or "control") + * @param connectionType connection type (e.g. "data" or "control") + * * @return a predicate that indicates whether the number of connections of * the specified connector is smaller than the expected number of * connections @@ -158,12 +164,12 @@ public static Predicate moreThanConnections(int expectedNumConn, * @see java.util.stream.Stream */ public static Predicate lessThanConnections(int expectedNumConn, - String connectionType) { + String connectionType) { return (Connector c) -> { return c.getType().equals(connectionType) - && c.getNode().getFlow(). - getConnections(connectionType). - getAllWith(c).size() < expectedNumConn; + && c.getNode().getFlow(). + getConnections(connectionType). + getAllWith(c).size() < expectedNumConn; }; } @@ -173,29 +179,30 @@ public static Predicate lessThanConnections(int expectedNumConn, * Only connections of the specifed type are counted. * * @param expectedNumConn expected number of connections - * @param connectionType connection type (e.g. "data" or "control") + * @param connectionType connection type (e.g. "data" or "control") + * * @return a predicate that indicates whether the number of connections of * the specified connector is equal to the expected number of connections * * @see java.util.stream.Stream */ public static Predicate numberOfConnections(int expectedNumConn, - String connectionType) { + String connectionType) { return (Connector c) -> { return c.getType().equals(connectionType) - && c.getNode().getFlow(). - getConnections(connectionType). - getAllWith(c).size() == expectedNumConn; + && c.getNode().getFlow(). + getConnections(connectionType). + getAllWith(c).size() == expectedNumConn; }; } - + public static boolean isRoot(VNode node, String connectionType) { Predicate notConnected = (Connector c) -> { return c.getType().equals(connectionType) - && !c.getNode().getFlow(). - getConnections(connectionType). - getAllWith(c).isEmpty(); + && !c.getNode().getFlow(). + getConnections(connectionType). + getAllWith(c).isEmpty(); }; Predicate rootNode = (VNode n) -> { @@ -204,12 +211,12 @@ public static boolean isRoot(VNode node, String connectionType) { return rootNode.test(node); } - + public static List getPathInLayerFromRoot(VNode sender, String connectionType) { List result = new ArrayList<>(); - - if (sender.getMainOutput(connectionType)==null) { + + if (sender.getMainOutput(connectionType) == null) { return result; } @@ -222,7 +229,7 @@ public static List getPathInLayerFromRoot(VNode sender, String connection Connections connections = sender.getFlow().getConnections(connectionType); Collection connectionsWithSender - = connections.getAllWith(sender.getMainOutput(connectionType)); + = connections.getAllWith(sender.getMainOutput(connectionType)); while (!connectionsWithSender.isEmpty()) { @@ -243,8 +250,8 @@ public static List getPathInLayerFromRoot(VNode sender, String connection if (newSender != null) { connectionsWithSender - = connections.getAllWith( - newSender.getMainOutput(connectionType)); + = connections.getAllWith( + newSender.getMainOutput(connectionType)); } else { connectionsWithSender.clear(); } @@ -252,55 +259,59 @@ public static List getPathInLayerFromRoot(VNode sender, String connection return result; } - - + + public static List connect(Connector s, Connector r) { List result = new ArrayList<>(); if (s.getNode().getFlow() == r.getNode().getFlow()) { result.add(s.getNode().getFlow().connect(s, r)); } - + return result; } - + /** * Returns the ancestors of the specified node. + * * @param n node + * * @return the ancestors of the specified node */ public static List getAncestors(VNode n) { List result = new ArrayList<>(); - + VFlowModel parent = n.getFlow(); - - while(parent!=null) { + + while (parent != null) { result.add(parent); parent = parent.getFlow(); } - + return result; } - + /** * Returns the first common ancestor of the specified nodes if such a parent node * exists. + * * @param n1 first node * @param n2 second node + * * @return the common ancestor of the specified nodes if such a parent node * exists */ public static Optional getCommonAncestor(VNode n1, VNode n2) { List ancestorsOfN1 = getAncestors(n1); List ancestorsOfN2 = getAncestors(n2); - - for(VFlowModel a1 : ancestorsOfN1) { - for(VFlowModel a2 : ancestorsOfN2) { + + for (VFlowModel a1 : ancestorsOfN1) { + for (VFlowModel a2 : ancestorsOfN2) { if (a1.equals(a2)) { return Optional.of(a1); } } } - + return Optional.empty(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGenerator.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGenerator.java index e51a455a..14143e26 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGenerator.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGenerator.java @@ -36,68 +36,76 @@ import eu.mihosoft.vrl.workflow.VFlowModel; /** - * This interface describes a layout generator. A layout generator is used to + * This interface describes a layout generator. A layout generator is used to * calculate an aesthetically pleasing arrangement of nodes. - * + * * @author Tobias Mertz */ public interface LayoutGenerator { - + /** * Returns the workflow to be laid out. + * * @return VFlowModel */ - public VFlowModel getWorkflow(); - + VFlowModel getWorkflow(); + /** - * If set to true, the layout is applied to all subflows of the given + * If set to true, the layout is applied to all subflows of the given * workflow recursively. + * * @return boolean */ - public boolean getRecursive(); - + boolean getRecursive(); + /** - * If set to true, subflow nodes in the given workflow are automatically + * If set to true, subflow nodes in the given workflow are automatically * scaled to fit their contents. + * * @return boolean */ - public boolean getAutoscaleNodes(); - + boolean getAutoscaleNodes(); + /** * If set to true, debugging output will be printed in the command line. - * @return + * + * @return */ - public boolean getDebug(); - + boolean getDebug(); + /** * Sets the workflow to be laid out. + * * @param pworkflow VFlowModel */ - public void setWorkflow(VFlowModel pworkflow); - + void setWorkflow(VFlowModel pworkflow); + /** - * If set to true, the layout is applied to all subflows of the given + * If set to true, the layout is applied to all subflows of the given * workflow recursively. + * * @param precursive boolean */ - public void setRecursive(boolean precursive); - + void setRecursive(boolean precursive); + /** - * If set to true, subflow nodes in the given workflow are automatically + * If set to true, subflow nodes in the given workflow are automatically * scaled to fit their contents. + * * @param pautoscaleNodes boolean */ - public void setAutoscaleNodes(boolean pautoscaleNodes); - + void setAutoscaleNodes(boolean pautoscaleNodes); + /** * If set to true, debugging output will be printed in the command line. + * * @param pdebug boolean */ - public void setDebug(boolean pdebug); - + void setDebug(boolean pdebug); + /** * Generates the Layout. */ - public void generateLayout() ; - + void generateLayout(); + } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGeneratorNaive.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGeneratorNaive.java index 18e6c719..5e2021fb 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGeneratorNaive.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGeneratorNaive.java @@ -39,24 +39,25 @@ import eu.mihosoft.vrl.workflow.Connections; import eu.mihosoft.vrl.workflow.VFlowModel; import eu.mihosoft.vrl.workflow.VNode; +import javafx.collections.ObservableList; +import javafx.collections.ObservableMap; + import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.Objects; import java.util.Set; -import javafx.collections.ObservableList; -import javafx.collections.ObservableMap; /** * This class provides a naive implementation for the LayoutGenerator interface. - * Nodes will be positioned in a layered arrangement, but there is no process + * Nodes will be positioned in a layered arrangement, but there is no process * for the minimization of line-crossings. - * + * * @author Tobias Mertz */ public class LayoutGeneratorNaive implements LayoutGenerator { - + // parameters: private VFlowModel workflow; private LinkedList> connectionList; @@ -70,7 +71,7 @@ public class LayoutGeneratorNaive implements LayoutGenerator { private double scaling; private double subflowscale; private boolean debug; - + // internal fields: private VNode[] nodes; private int nodecount; @@ -78,7 +79,7 @@ public class LayoutGeneratorNaive implements LayoutGenerator { private boolean cycle; private int[] layering; private int layercount; - + /** * Default constructor. * Debug is set to false. @@ -87,19 +88,20 @@ public LayoutGeneratorNaive() { this.debug = false; initialize(); } - + /** * Constructor with debug-functionality. - * Debug parameter can be set, all other parameters are initialized with + * Debug parameter can be set, all other parameters are initialized with * default values. + * * @param pdebug boolean */ public LayoutGeneratorNaive(boolean pdebug) { this.debug = pdebug; initialize(); - if(this.debug) System.out.println("Creating layout generator"); + if (this.debug) { System.out.println("Creating layout generator"); } } - + /** * Initializes the fields of the class needed in future methods. */ @@ -115,338 +117,369 @@ private void initialize() { this.scaling = -1.5; this.subflowscale = 2.0; } - + // + /** * Returns the workflow to be laid out. + * * @return VFlowModel */ @Override public VFlowModel getWorkflow() { return this.workflow; } - + /** * Returns a list of the nodes to be laid out. * default: the nodelist is gathered from the given workflow. + * * @return Collection */ public Collection getNodelist() { Collection nodelist = new ArrayList<>(); int i; - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { nodelist.add(this.nodes[i]); } return nodelist; } - + /** - * If set to true, the layout is applied to all subflows of the given + * If set to true, the layout is applied to all subflows of the given * workflow recursively. * default: true + * * @return boolean */ @Override public boolean getRecursive() { return this.recursive; } - + /** - * If set to true, subflow nodes in the given workflow are automatically + * If set to true, subflow nodes in the given workflow are automatically * scaled to fit their contents. * default: true + * * @return boolean */ @Override public boolean getAutoscaleNodes() { return this.autoscaleNodes; } - + /** * Returns the set input type. * 0 - VFlowModel (setWorkflow) * 2 - nodelist (setNodelist) - * The input must be delivered via the corresponding setter method before + * The input must be delivered via the corresponding setter method before * the call of generateLayout(). * default: 0 + * * @return int */ public int getGraphmode() { return this.graphmode; } - + /** - * If set to true, a depth-first-search is performed and all back edges are - * removed from the model graph. The layout is then applied without these + * If set to true, a depth-first-search is performed and all back edges are + * removed from the model graph. The layout is then applied without these * edges. * Is only run if the graph contains cycles. * default: true + * * @return boolean */ public boolean getLaunchRemoveCycles() { return this.launchRemoveCycles; } - + /** * If set to true, a new layering for the given graph is created. * default: true + * * @return boolean */ public boolean getLaunchCreateLayering() { return this.launchCreateLayering; } - + /** - * If set to true, the vertical position for each node is calculated and + * If set to true, the vertical position for each node is calculated and * changed. * Does not change the order of nodes on each layer. * default: true + * * @return boolean */ public boolean getLaunchCalculateVerticalPositions() { return this.launchCalculateVerticalPositions; } - + /** - * If set to true, the horizontal position for each layer is calculated and + * If set to true, the horizontal position for each layer is calculated and * changed. * default: true + * * @return boolean */ public boolean getLaunchCalculateHorizontalPositions() { return this.launchCalculateHorizontalPositions; } - + /** - * Returns the scaling parameter of the algorithm. + * Returns the scaling parameter of the algorithm. * Determines the distance between nodes. * default: -1.5 + * * @return double */ public double getScaling() { return this.scaling; } - + /** - * Returns the scaling factor that is used to scale subflow-nodes in the + * Returns the scaling factor that is used to scale subflow-nodes in the * autoscaleNodes procedure. * default: 2.0 + * * @return double */ public double getSubflowscale() { return this.subflowscale; } - + /** * If set to true, debugging output will be printed in the command line. * default: false + * * @return boolean */ @Override public boolean getDebug() { return this.debug; } - + /** * Returns the Graph modeled after the workflow. + * * @return LinkedList> */ public LinkedList> getModelGraph() { return this.connectionList; } - + /** * Returns the layering of the current graph as an array of layer indices. + * * @return int[] */ public int[] getLayering() { return this.layering; } // - + // + /** * Sets the workflow to be laid out. + * * @param pworkflow VFlowModel */ @Override public void setWorkflow(VFlowModel pworkflow) { this.workflow = pworkflow; } - + /** * Sets the list of nodes to be laid out. * default: the nodelist is gathered from the given workflow. + * * @param pnodelist Collection */ public void setNodelist(Collection pnodelist) { this.nodes = new VNode[pnodelist.size()]; int i = 0; Iterator it = pnodelist.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { this.nodes[i] = it.next(); i++; } } - + /** - * If set to true, the layout is applied to all subflows of the given + * If set to true, the layout is applied to all subflows of the given * workflow recursively. * default: true + * * @param precursive boolean */ @Override public void setRecursive(boolean precursive) { this.recursive = precursive; } - + /** - * If set to true, subflow nodes in the given workflow are automatically + * If set to true, subflow nodes in the given workflow are automatically * scaled to fit their contents. * default: true + * * @param pautoscaleNodes boolean */ @Override public void setAutoscaleNodes(boolean pautoscaleNodes) { this.autoscaleNodes = pautoscaleNodes; } - + /** * Sets the input type. * 0 - VFlowModel (setWorkflow) * 2 - nodelist (setNodelist) - * The input must be delivered via the corresponding setter method before + * The input must be delivered via the corresponding setter method before * the call of generateLayout(). * default: 0 + * * @param pgraphmode int */ public void setGraphmode(int pgraphmode) { this.graphmode = pgraphmode; } - + /** - * If set to true, a depth-first-search is performed and all back edges are - * removed from the model graph. The layout is then applied without these + * If set to true, a depth-first-search is performed and all back edges are + * removed from the model graph. The layout is then applied without these * edges. * Is only run if the graph contains cycles. - * default: true + * default: true + * * @param plaunchRemoveCycles boolean */ public void setLaunchRemoveCycles(boolean plaunchRemoveCycles) { this.launchRemoveCycles = plaunchRemoveCycles; } - - + + /** * If set to true, a new layering for the given graph is created. * default: true + * * @param plaunchCreateLayering boolean */ public void setLaunchCreateLayering(boolean plaunchCreateLayering) { this.launchCreateLayering = plaunchCreateLayering; } - + /** - * If set to true, the vertical position for each node is calculated and + * If set to true, the vertical position for each node is calculated and * changed. * Does not change the order of nodes on each layer. * default: true + * * @param plaunchCalculateVerticalPositions boolean */ public void setLaunchCalculateVerticalPositions( - boolean plaunchCalculateVerticalPositions) { - this.launchCalculateVerticalPositions = - plaunchCalculateVerticalPositions; + boolean plaunchCalculateVerticalPositions) { + this.launchCalculateVerticalPositions = + plaunchCalculateVerticalPositions; } - + /** - * If set to true, the horizontal position for each layer is calculated and + * If set to true, the horizontal position for each layer is calculated and * changed. * default: true + * * @param plaunchCalculateHorizontalPositions boolean */ public void setLaunchCalculateHorizontalPositions( - boolean plaunchCalculateHorizontalPositions) { - this.launchCalculateHorizontalPositions = - plaunchCalculateHorizontalPositions; + boolean plaunchCalculateHorizontalPositions) { + this.launchCalculateHorizontalPositions = + plaunchCalculateHorizontalPositions; } - + /** - * Sets the scaling parameter of the algorithm. + * Sets the scaling parameter of the algorithm. * Determines the distance between nodes. * default: -1.5 + * * @param pscaling double */ public void setScaling(double pscaling) { this.scaling = pscaling; } - + /** - * Sets the scaling factor that is used to scale subflow-nodes in the + * Sets the scaling factor that is used to scale subflow-nodes in the * autoscaleNodes procedure. * default: 2.0 + * * @param psubflowscale double */ public void setSubflowscale(double psubflowscale) { this.subflowscale = psubflowscale; } - + /** * If set to true, debugging output will be printed in the command line. * default: false + * * @param pdebug boolean */ @Override public void setDebug(boolean pdebug) { this.debug = pdebug; } - + /** * Sets the model graph. + * * @param pconnectionList LinkedList> */ public void setModelGraph(LinkedList> pconnectionList) { this.connectionList = pconnectionList; } - + /** * Sets the layering of the current graph as an array of layer indices. + * * @param playering int[] */ public void setLayering(int[] playering) { this.layering = playering; } // - + /** - * Sets up the model-fields. This includes nodearray, nodecount and the + * Sets up the model-fields. This includes nodearray, nodecount and the * model graph. * Uses either a VFlowModel or a nodelist depending on the graphmode * parameter. + * * @return boolean */ public boolean setUp() { int i; - switch(this.graphmode) { + switch (this.graphmode) { // VFlowModel: case 0: - if(this.workflow == null) return false; + if (this.workflow == null) { return false; } // gather nodelist from workflow - ObservableList nodesTemp = this.workflow.getNodes(); - if(nodesTemp == null) return false; + ObservableList nodesTemp = this.workflow.getNodes(); + if (nodesTemp == null) { return false; } this.nodecount = nodesTemp.size(); this.nodes = new VNode[this.nodecount]; // copy nodelist into nodearray for better performance in the future - for(i = 0; i < nodesTemp.size(); i++) { + for (i = 0; i < nodesTemp.size(); i++) { this.nodes[i] = nodesTemp.get(i); } break; // nodelist: case 2: - if(this.debug) System.out.println("laying out with nodelist"); - if(this.nodes == null) return false; + if (this.debug) { System.out.println("laying out with nodelist"); } + if (this.nodes == null) { return false; } this.nodecount = this.nodes.length; - if(this.nodecount == 0) return false; + if (this.nodecount == 0) { return false; } this.workflow = this.nodes[0].getFlow(); break; // default: @@ -457,77 +490,79 @@ public boolean setUp() { // get all edges this.connectionList = new LinkedList<>(); this.conncount = 0; - ObservableMap allConnections = - this.workflow.getAllConnections(); + ObservableMap allConnections = + this.workflow.getAllConnections(); // get all types of connections Set keys = allConnections.keySet(); Iterator it = keys.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { // get all connections for current type String currType = it.next(); Connections currConns = allConnections.get(currType); ObservableList connections = currConns.getConnections(); int currConnCount = connections.size(); - for(i = 0; i < currConnCount; i++) { + for (i = 0; i < currConnCount; i++) { Connection currConn = connections.get(i); // create a tuple of the sender and receiver of the current // connection and add it to the connectionlist Integer out = getNodeID(currConn.getSender().getNode()); Integer in = getNodeID(currConn.getReceiver().getNode()); - if((out != -1) && (in != -1)) { + if ((out != -1) && (in != -1)) { this.connectionList.add(new Pair<>(out, in)); this.conncount++; } } } this.cycle = checkCycles(); - if(this.debug) System.out.println("Setup complete with " + if (this.debug) { + System.out.println("Setup complete with " + this.nodecount + " nodes and " + this.conncount + " edges."); + } return true; } - + /** * Checks if the graph contains cycles. + * * @return boolean */ private boolean checkCycles() { int i; boolean[] checked = new boolean[this.nodecount]; - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { int j; // initialize checked with all entries set to false - for(j = 0; j < this.nodecount; j++) { + for (j = 0; j < this.nodecount; j++) { checked[j] = false; } LinkedList succs = new LinkedList<>(); - for(j = 0; j < this.conncount; j++) { - if(this.connectionList.get(j).getFirst() == i) { + for (j = 0; j < this.conncount; j++) { + if (this.connectionList.get(j).getFirst() == i) { succs.add(this.connectionList.get(j).getSecond()); } } Iterator it = succs.iterator(); // iterate through all successors of start node - while(it.hasNext()) { + while (it.hasNext()) { Integer currNode = it.next(); // if current node is the start node, the start node can be // reached -> there is a cycle - if(currNode == i) { - if(this.debug) System.out.println("graph contains cycles"); + if (currNode == i) { + if (this.debug) { System.out.println("graph contains cycles"); } return true; - } - else { + } else { // if current node is not the start node and has not yet // been checked, add all successors of current node to the // list, reset the iterator, set checked for current // node true. // -> all nodes that are reacheable from start node will // be checked once. - if(!checked[currNode]) { - for(j = 0; j < this.conncount; j++) { - if(Objects.equals(this.connectionList.get(j) - .getFirst(), currNode)) { + if (!checked[currNode]) { + for (j = 0; j < this.conncount; j++) { + if (Objects.equals(this.connectionList.get(j) + .getFirst(), currNode)) { succs.add(this.connectionList.get(j) - .getSecond()); + .getSecond()); it = succs.iterator(); checked[currNode] = true; } @@ -536,73 +571,76 @@ private boolean checkCycles() { } } } - if(this.debug) System.out.println("graph contains no cycles."); + if (this.debug) { System.out.println("graph contains no cycles."); } return false; } - + /** - * Performs a depth-first search and removes all back edges so that the + * Performs a depth-first search and removes all back edges so that the * resulting graph is cycle free. */ private void removeCycles() { int i; boolean[] checked = new boolean[this.nodecount]; // initialize checked with all entries set to false - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { checked[i] = false; } LinkedList path = new LinkedList<>(); // iterate through all nodes - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { // start recursive search with current node as startingpoint remCycR(i, path, checked); } } - + /** * Recursive helper-function to be used by removeCycles(). - * @param VNode curr: current node - * @param path LinkedList: the path from the root-node to the - * current node - * @param checked boolean[]: array of length nodecount showing which nodes - * were already checked - */ - private void remCycR(Integer curr, LinkedList path, - boolean[] checked) { - if(!checked[curr]) { + * + * @param VNode curr: current node + * @param path LinkedList: the path from the root-node to the + * current node + * @param checked boolean[]: array of length nodecount showing which nodes + * were already checked + */ + private void remCycR(Integer curr, LinkedList path, + boolean[] checked) { + if (!checked[curr]) { // add current node to path path.addFirst(curr); checked[curr] = true; int i; LinkedList succs = new LinkedList<>(); // get successors to current node - for(i = 0; i < this.conncount; i++) { - if(Objects.equals(this.connectionList.get(i).getFirst(), curr)) { + for (i = 0; i < this.conncount; i++) { + if (Objects.equals(this.connectionList.get(i).getFirst(), curr)) { succs.add(this.connectionList.get(i).getSecond()); } } // perform search on all successors. - if(!succs.isEmpty()) { + if (!succs.isEmpty()) { Iterator it = succs.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { Integer currSucc = it.next(); // if edge from curr to currSucc is a back edge - if(path.contains(currSucc)) { + if (path.contains(currSucc)) { // remove all edges from curr to currSucc Iterator> its = this.connectionList - .iterator(); - while(its.hasNext()) { + .iterator(); + while (its.hasNext()) { Pair currConn = its.next(); - if(Objects.equals(currConn.getFirst(), curr) - && Objects.equals(currConn.getSecond(), - currSucc)) { + if (Objects.equals(currConn.getFirst(), curr) + && Objects.equals(currConn.getSecond(), + currSucc)) { this.connectionList.remove(currConn); its = this.connectionList.iterator(); this.conncount--; } } - if(this.debug) System.out.println("removing edge from " + if (this.debug) { + System.out.println("removing edge from " + curr + " to " + currSucc); + } } // if edge from curr to currSucc is not a back edge else { @@ -614,60 +652,59 @@ private void remCycR(Integer curr, LinkedList path, path.removeFirst(); } } - + /** * Applies all steps of the layout, whose launch-parameters are set to true. */ @Override public void generateLayout() { - if(this.debug) System.out.println("Generating layout."); + if (this.debug) { System.out.println("Generating layout."); } // setup and check for errors - if(this.setUp()) { + if (this.setUp()) { // get origin point double minx = Double.POSITIVE_INFINITY; double miny = Double.POSITIVE_INFINITY; int i; - for(i = 0; i < this.nodecount; i++) { - if(this.nodes[i].getX() < minx) minx = this.nodes[i].getX(); - if(this.nodes[i].getY() < miny) miny = this.nodes[i].getY(); + for (i = 0; i < this.nodecount; i++) { + if (this.nodes[i].getX() < minx) { minx = this.nodes[i].getX(); } + if (this.nodes[i].getY() < miny) { miny = this.nodes[i].getY(); } } - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { this.nodes[i].setX(this.nodes[i].getX() - minx); this.nodes[i].setY(this.nodes[i].getY() - miny); } - - if(this.cycle) { - if(this.launchRemoveCycles) { + + if (this.cycle) { + if (this.launchRemoveCycles) { removeCycles(); - } - else { - if(this.debug) System.out.println("Cycles in graph. please " + } else { + if (this.debug) { + System.out.println("Cycles in graph. please " + "run with launchRemoveCycles set to true."); + } return; } } // apply layout to subflows - if(this.recursive) { + if (this.recursive) { runSubflows(); } // scale nodes according to their contents. - if(this.autoscaleNodes) { + if (this.autoscaleNodes) { autoscaleNodes(); } // apply layout - if(this.launchCreateLayering) createLayering(); - if(this.launchCalculateVerticalPositions) - calculateVerticalPositions(); - if(this.launchCalculateHorizontalPositions) - calculateHorizontalPositions(); + if (this.launchCreateLayering) { createLayering(); } + if (this.launchCalculateVerticalPositions) { calculateVerticalPositions(); } + if (this.launchCalculateHorizontalPositions) { calculateHorizontalPositions(); } // displace by origin point - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { this.nodes[i].setX(this.nodes[i].getX() + minx); this.nodes[i].setY(this.nodes[i].getY() + miny); } } } - + /** * Applies the layout with the same parameters to each subflow. */ @@ -679,30 +716,32 @@ private void runSubflows() { subgen.setLaunchRemoveCycles(this.launchRemoveCycles); // apply layout to each subflow int i; - for(i = 0; i < this.nodecount; i++) { - if(this.nodes[i] instanceof VFlowModel) { + for (i = 0; i < this.nodecount; i++) { + if (this.nodes[i] instanceof VFlowModel) { subgen.setWorkflow((VFlowModel) this.nodes[i]); subgen.generateLayout(); } } } - + /** * Scales subflow-nodes according to their contents. */ private void autoscaleNodes() { int i; - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { VFlowModel subflow; - if(!(this.nodes[i] instanceof VFlowModel)) continue; + if (!(this.nodes[i] instanceof VFlowModel)) { continue; } subflow = (VFlowModel) this.nodes[i]; // get node representation of the current subflow VNode flownode = this.nodes[i]; - if(this.debug) System.out.println("Resizing subflow-node " + if (this.debug) { + System.out.println("Resizing subflow-node " + flownode.getId()); + } // get nodes from the subflow Collection subnodes = subflow.getNodes(); - if(subnodes.isEmpty()) continue; + if (subnodes.isEmpty()) { continue; } Iterator nodeit = subnodes.iterator(); double minx = Double.POSITIVE_INFINITY; double maxx = Double.NEGATIVE_INFINITY; @@ -710,38 +749,48 @@ private void autoscaleNodes() { double maxy = Double.NEGATIVE_INFINITY; // iterate over all subflow nodes to get outermost coordinates of // subflow - while(nodeit.hasNext()) { + while (nodeit.hasNext()) { VNode currNode = nodeit.next(); double x = currNode.getX(); double y = currNode.getY(); - if(this.debug) System.out.println(currNode.getId() + " has " + if (this.debug) { + System.out.println(currNode.getId() + " has " + "position (" + x + "|" + y + ")"); - if(minx > x) minx = x; - if(maxx < (x + currNode.getWidth())) maxx = x + } + if (minx > x) { minx = x; } + if (maxx < (x + currNode.getWidth())) { + maxx = x + currNode.getWidth(); - if(miny > y) miny = y; - if(maxy < (y + currNode.getHeight())) maxy = y + } + if (miny > y) { miny = y; } + if (maxy < (y + currNode.getHeight())) { + maxy = y + currNode.getHeight(); + } } - if(this.debug) System.out.println("extreme positions of " - + flownode.getId() + " are min: (" + minx + "|" + miny + if (this.debug) { + System.out.println("extreme positions of " + + flownode.getId() + " are min: (" + minx + "|" + miny + ") max: (" + maxx + "|" + maxy + ")"); + } // calculate size of subflow double width = maxx - minx; double height = maxy - miny; - if(this.debug) System.out.println("Resizing subflow-node " + if (this.debug) { + System.out.println("Resizing subflow-node " + flownode.getId() + " from size (" + flownode.getWidth() + "|" + flownode.getHeight() + ") to size (" - + (width / subnodes.size() * this.subflowscale) + "|" + + (width / subnodes.size() * this.subflowscale) + "|" + (height / subnodes.size() * this.subflowscale) + ")"); + } // set size of node representing current subflow flownode.setWidth(width / subnodes.size() * this.subflowscale); flownode.setHeight(height / subnodes.size() * this.subflowscale); } } - + /** - * Creates a new layering, assigning each node the lowest layer possible, + * Creates a new layering, assigning each node the lowest layer possible, * while still having all of its preceeding nodes on a lower layer. */ private void createLayering() { @@ -750,30 +799,32 @@ private void createLayering() { this.layering = new int[this.nodecount]; int lockable = 0; boolean[] locked = new boolean[this.nodecount]; - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { this.layering[i] = 0; locked[i] = false; } - while(!allLocked(locked)) { + while (!allLocked(locked)) { Iterator> it = this.connectionList.iterator(); // iterate over all connections - while(it.hasNext()) { + while (it.hasNext()) { Pair curr = it.next(); // set all receivers of the current connection to the layer of // their receiver + 1 - if((!locked[curr.getSecond()]) - && (this.layering[curr.getSecond()] - < (this.layering[curr.getFirst()] + 1))) { - this.layering[curr.getSecond()] = - this.layering[curr.getFirst()] + 1; + if ((!locked[curr.getSecond()]) + && (this.layering[curr.getSecond()] + < (this.layering[curr.getFirst()] + 1))) { + this.layering[curr.getSecond()] = + this.layering[curr.getFirst()] + 1; } } - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { // layers that have been finalized - if(this.layering[i] == lockable) { + if (this.layering[i] == lockable) { locked[i] = true; - if(this.debug) System.out.println(this.nodes[i].getId() + if (this.debug) { + System.out.println(this.nodes[i].getId() + " locked on layer " + lockable); + } } } // each iteration, the next layer can be locked @@ -781,23 +832,25 @@ private void createLayering() { } this.layercount = lockable; } - + /** * Returns true if all nodes are on a locked layer. + * * @param locked boolean[] + * * @return boolean */ private boolean allLocked(boolean[] locked) { boolean result = true; int i; - for(i = 0; i < locked.length; i++) { - if(!locked[i]) result = false; + for (i = 0; i < locked.length; i++) { + if (!locked[i]) { result = false; } } return result; } - + /** - * Calculates the vertical positions of the nodes in each layer depending on + * Calculates the vertical positions of the nodes in each layer depending on * their height and the scaling parameter. * Does not sort nodes to reduce edge crossings. */ @@ -805,45 +858,46 @@ private void calculateVerticalPositions() { int i; int currlayer; int[] layer; - if(this.layering == null) return; - if(this.layercount == 0) return; - for(currlayer = 0; currlayer < this.layercount; currlayer++) { + if (this.layering == null) { return; } + if (this.layercount == 0) { return; } + for (currlayer = 0; currlayer < this.layercount; currlayer++) { // create array of the layer int nodeson = 0; // find number of nodes on current layer - for(i = 0; i < this.nodecount; i++) { - if(this.layering[i] == currlayer) nodeson++; + for (i = 0; i < this.nodecount; i++) { + if (this.layering[i] == currlayer) { nodeson++; } } int layeri = 0; layer = new int[nodeson]; // find nodes on current layer - for(i = 0; i < this.nodecount; i++) { - if(this.layering[i] == currlayer) { + for (i = 0; i < this.nodecount; i++) { + if (this.layering[i] == currlayer) { layer[layeri] = i; layeri++; } } // iterate over all nodes on current layer double posy = 0.; - for(i = 0; i < nodeson; i++) { - if(this.debug) System.out.println("Vertical position of " - + this.nodes[layer[i]].getId() + " on layer " + for (i = 0; i < nodeson; i++) { + if (this.debug) { + System.out.println("Vertical position of " + + this.nodes[layer[i]].getId() + " on layer " + currlayer + " set to " + posy); + } this.nodes[layer[i]].setY(posy); // increase position for next node by height of current node // and scaling - if(this.scaling < 0) { - posy = posy + this.nodes[layer[i]].getHeight() - * this.scaling * (-1); - } - else { - posy = posy + this.nodes[layer[i]].getHeight() - + this.scaling; + if (this.scaling < 0) { + posy = posy + this.nodes[layer[i]].getHeight() + * this.scaling * (-1); + } else { + posy = posy + this.nodes[layer[i]].getHeight() + + this.scaling; } } } } - + /** * Calculates horizontal positions of the layers depending on node width. */ @@ -852,56 +906,58 @@ private void calculateHorizontalPositions() { int currlayer; int[] layer; double posx = 0.; - if(this.layering == null) return; - if(this.layercount == 0) return; - for(currlayer = 0; currlayer < this.layercount; currlayer++) { + if (this.layering == null) { return; } + if (this.layercount == 0) { return; } + for (currlayer = 0; currlayer < this.layercount; currlayer++) { // create array of layer int nodeson = 0; // find number of nodes on current layer - for(i = 0; i < this.nodecount; i++) { - if(this.layering[i] == currlayer) nodeson++; + for (i = 0; i < this.nodecount; i++) { + if (this.layering[i] == currlayer) { nodeson++; } } int layeri = 0; layer = new int[nodeson]; // find nodes on current layer - for(i = 0; i < this.nodecount; i++) { - if(this.layering[i] == currlayer) { + for (i = 0; i < this.nodecount; i++) { + if (this.layering[i] == currlayer) { layer[layeri] = i; layeri++; } } // iterate over all nodes on current layer double maxwidth = Double.NEGATIVE_INFINITY; - for(i = 0; i < nodeson; i++) { - if(this.debug) System.out.println("Horizontal position of " - + this.nodes[layer[i]].getId() + " on layer " + for (i = 0; i < nodeson; i++) { + if (this.debug) { + System.out.println("Horizontal position of " + + this.nodes[layer[i]].getId() + " on layer " + currlayer + " set to " + posx); + } this.nodes[layer[i]].setX(posx); // find max width on current layer - if(this.nodes[layer[i]].getWidth() > maxwidth) { + if (this.nodes[layer[i]].getWidth() > maxwidth) { maxwidth = this.nodes[layer[i]].getWidth(); } } // increase position for next layer by max width and scaling - if(this.scaling < 0) { + if (this.scaling < 0) { posx = posx + maxwidth * this.scaling * (-1); - } - else { + } else { posx = posx + maxwidth + this.scaling; } } } - + /** * Returns index of the given node in the nodearray. + * * @param pnode VNode + * * @return Integer - */ + */ private Integer getNodeID(VNode pnode) { int i; - for(i = 0; i < this.nodecount; i++) { - if(this.nodes[i].equals(pnode)) - return i; + for (i = 0; i < this.nodecount; i++) { + if (this.nodes[i].equals(pnode)) { return i; } } return -1; } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGeneratorSmart.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGeneratorSmart.java index 3d0788ad..c4202598 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGeneratorSmart.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/incubating/LayoutGeneratorSmart.java @@ -34,10 +34,10 @@ package eu.mihosoft.vrl.workflow.incubating; import cern.colt.Arrays; -import edu.uci.ics.jung.algorithms.layout.ISOMLayout; +import edu.uci.ics.jung.algorithms.layout.DAGLayout; import edu.uci.ics.jung.algorithms.layout.FRLayout; +import edu.uci.ics.jung.algorithms.layout.ISOMLayout; import edu.uci.ics.jung.algorithms.layout.KKLayout; -import edu.uci.ics.jung.algorithms.layout.DAGLayout; import edu.uci.ics.jung.algorithms.layout.Layout; import edu.uci.ics.jung.graph.DirectedGraph; import edu.uci.ics.jung.graph.DirectedSparseGraph; @@ -46,6 +46,9 @@ import eu.mihosoft.vrl.workflow.Connections; import eu.mihosoft.vrl.workflow.VFlowModel; import eu.mihosoft.vrl.workflow.VNode; +import javafx.collections.ObservableList; +import javafx.collections.ObservableMap; + import java.awt.Dimension; import java.awt.geom.Point2D; import java.util.ArrayList; @@ -53,18 +56,16 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Set; -import javafx.collections.ObservableList; -import javafx.collections.ObservableMap; -/** - * This class provides a sophisticated implementation for the LayoutGenerator +/** + * This class provides a sophisticated implementation for the LayoutGenerator * interface based on layout algorithms implemented in * the Java Universal Network/Graph Drawing Framework. - * + * * @author Tobias Mertz */ public class LayoutGeneratorSmart implements LayoutGenerator { - + // parameters: private VFlowModel workflow; private DirectedGraph jgraph; @@ -89,7 +90,7 @@ public class LayoutGeneratorSmart implements LayoutGenerator { private double direction; private double alignmentThreshold; private boolean debug; - + // internal fields: private VNode[] nodes; private Layout layout; @@ -98,7 +99,7 @@ public class LayoutGeneratorSmart implements LayoutGenerator { private Point2D graphcenter; private Pair[] origin; private boolean cycle; - + /** * Default constructor. * All parameters are initialized with default values. @@ -107,19 +108,20 @@ public LayoutGeneratorSmart() { this.debug = false; initialization(); } - + /** * Constructor with debug-functionality. - * Debug parameter can be set, all other parameters are initialized with + * Debug parameter can be set, all other parameters are initialized with * default values. + * * @param pdebug boolean */ public LayoutGeneratorSmart(boolean pdebug) { this.debug = pdebug; initialization(); - if(this.debug) System.out.println("Creating Layout Generator."); + if (this.debug) { System.out.println("Creating Layout Generator."); } } - + /** * Initializes the fields of the class needed in future methods. */ @@ -146,62 +148,68 @@ private void initialization() { this.direction = 0.; this.alignmentThreshold = (this.scaling - 1) * (-1); } - + // + /** * Returns the workflow to be laid out. + * * @return VFlowModel */ @Override public VFlowModel getWorkflow() { return this.workflow; } - + /** * Returns the model graph to be laid out. * default: a graph is generated automatically from the workflow given. + * * @return DirectedGraph */ public DirectedGraph getModelGraph() { return this.jgraph; } - + /** * Returns a list of the nodes to be laid out. * default: the nodelist is gathered from the given workflow. + * * @return Collection */ public Collection getNodelist() { Collection nodelist = new ArrayList<>(); int i; - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { nodelist.add(this.nodes[i]); } return nodelist; } - + /** - * If set to true, the layout is applied to all subflows of the given + * If set to true, the layout is applied to all subflows of the given * workflow recursively. * default: true + * * @return boolean */ @Override public boolean getRecursive() { return this.recursive; } - + /** - * If set to true, subflow nodes in the given workflow are automatically + * If set to true, subflow nodes in the given workflow are automatically * scaled to fit their contents. * default: true + * * @return boolean */ @Override public boolean getAutoscaleNodes() { return this.autoscaleNodes; } - + /** * Returns the Jung layout that is used in the first step of the algorithm. * 0 - ISOM Layout @@ -209,207 +217,226 @@ public boolean getAutoscaleNodes() { * 2 - KK Layout * 3 - DAG Layout (Does not terminate if the graph contains cycles) * default: 0 + * * @return int */ public int getLayoutSelector() { return this.layoutSelector; } - + /** * Returns the aspect ratio of the initial drawing area of the graph. * Width is determined via the longest path in the graph. * Height is determined by dividing the width by the aspect ratio. * default: 16:9 + * * @return double */ public double getAspectratio() { return this.aspectratio; } - + /** * Returns the set input type. * 0 - VFlowModel (setWorkflow) * 1 - jgraph (setModelGraph) * 2 - nodelist (setNodelist) - * The input must be delivered via the corresponding setter method before + * The input must be delivered via the corresponding setter method before * the call of generateLayout(). * default: 0 + * * @return int */ public int getGraphmode() { return this.graphmode; } - + /** - * If set to true, a depth-first-search is performed and all back edges are - * removed from the model graph. The layout is then applied without these + * If set to true, a depth-first-search is performed and all back edges are + * removed from the model graph. The layout is then applied without these * edges. * Is only run if the graph contains cycles. * default: true + * * @return boolean */ public boolean getLaunchRemoveCycles() { return this.launchRemoveCycles; } - + /** - * If set to true, disjunct parts of the model graph will be laid out - * separately and then arranged over each other to create the cumulative + * If set to true, disjunct parts of the model graph will be laid out + * separately and then arranged over each other to create the cumulative * layout. - * Is never run if launchRemoveCycles is false and the graph contains + * Is never run if launchRemoveCycles is false and the graph contains * cycles, because it does not terminate in this case. * default: true + * * @return boolean */ public boolean getLaunchSeparateDisjunctGraphs() { return this.launchSeparateDisjunctGraphs; } - + /** - * If set to true, edge types will be separated and a layout generated that + * If set to true, edge types will be separated and a layout generated that * follows edge type priorities. * There is no working implementation for this feature yet. * default: false + * * @return boolean */ public boolean getLaunchSeparateEdgeTypes() { return this.launchSeparateEdgeTypes; } - + /** - * If set to true, the specified algorithm from the JUNG-library is applied + * If set to true, the specified algorithm from the JUNG-library is applied * to the graph. * The algorithm is specified using setLayoutSelector(). * default: true + * * @return boolean */ public boolean getLaunchJungLayout() { return this.launchJungLayout; } - + /** - * If set to true, the graph is rotated to reach an average flow direction + * If set to true, the graph is rotated to reach an average flow direction * that is the direction specified. * default: true + * * @return boolean */ public boolean getLaunchRotate() { return this.launchRotate; } - + /** - * If set to true, nodes with an in-degree of 0 will be placed at the + * If set to true, nodes with an in-degree of 0 will be placed at the * leftmost edge of the drawing space. - * Is always run if launchSeparateDisjunctGraphs is true, launchRemoveCycles - * is false and the graph contains cycles, because separateDisjunctGraphs + * Is always run if launchSeparateDisjunctGraphs is true, launchRemoveCycles + * is false and the graph contains cycles, because separateDisjunctGraphs * does not terminate if the graph contains cycles. * default: false + * * @return boolean */ public boolean getLaunchOrigin() { return this.launchOrigin; } - + /** - * If set to true, all nodes will be pushed past their predecessors, so no + * If set to true, all nodes will be pushed past their predecessors, so no * edges have a direction inverse to the specified direction. - * Is never run if launchRemoveCycles is false and the graph contains + * Is never run if launchRemoveCycles is false and the graph contains * cycles, because it does not terminate in this case. * default: true + * * @return boolean */ public boolean getLaunchPushBack() { return this.launchPushBack; } - + /** - * If set to true, nodes that are placed on the same coordinates will be + * If set to true, nodes that are placed on the same coordinates will be * displaced slightly, so the forcePush step can move them accordingly. * default: true + * * @return boolean */ public boolean getLaunchDisplaceIdents() { return this.launchDisplaceIdents; } - + /** - * If set to true, all nodes will repel each other until no overlaps between + * If set to true, all nodes will repel each other until no overlaps between * nodes are left or the maximum amount of iterations has been reached. * default: true + * * @return boolean */ public boolean getLaunchForcePush() { return this.launchForcePush; } - + /** - * If set to true, nodes will be aligned either with each other or on a + * If set to true, nodes will be aligned either with each other or on a * global grid. * default: true + * * @return boolean */ public boolean getLaunchAlignNodes() { return this.launchAlignNodes; } - + /** - * Returns the maximum amount of iterations used by the force push step + * Returns the maximum amount of iterations used by the force push step * of the algorithm. * default: 500 + * * @return boolean */ public int getMaxiterations() { return this.maxiterations; } - + /** - * Returns the scaling parameter of the algorithm. + * Returns the scaling parameter of the algorithm. * Determines the distance between nodes. * default: 1.2 + * * @return double */ public double getScaling() { return this.scaling; } - + /** - * Returns the scaling factor that is used to scale subflow-nodes in the + * Returns the scaling factor that is used to scale subflow-nodes in the * autoscaleNodes procedure. * default: 2.0 + * * @return double */ public double getSubflowscale() { return this.subflowscale; } - + /** * Returns the desired average edge direction of the resulting graph as an * angle to the abscissa in degrees. * default: 0. + * * @return double */ public double getDirection() { return this.direction; } - + /** * Sets the alignment parameter used to align nodes with each other. - * If the value is positive it describes the size of a grid which nodes + * If the value is positive it describes the size of a grid which nodes * will be aligned on. - * If the value is negative its absolute value will be used as multiplier - * to the mean size of each pair of nodes which will then result in a - * threshold under which these two nodes will be positioned at the same + * If the value is negative its absolute value will be used as multiplier + * to the mean size of each pair of nodes which will then result in a + * threshold under which these two nodes will be positioned at the same * coordinate. * default: -(scaling - 1) + * * @return double */ public double getAlignmentThreshold() { return this.alignmentThreshold; } - + /** * If set to true, debugging output will be printed in the command line. * default: false + * * @return boolean */ @Override @@ -417,274 +444,299 @@ public boolean getDebug() { return this.debug; } // - + // + /** * Sets the workflow to be laid out. + * * @param pworkflow VFlowModel */ @Override public void setWorkflow(VFlowModel pworkflow) { this.workflow = pworkflow; } - + /** * Sets the model graph to be laid out. * default: a graph is generated automatically from the workflow given. + * * @param pjgraph DirectedGraph */ public void setModelGraph(DirectedGraph pjgraph) { this.jgraph = pjgraph; } - + /** * Sets the list of nodes to be laid out. * default: the nodelist is gathered from the given workflow. + * * @param pnodelist Collection */ public void setNodelist(Collection pnodelist) { this.nodes = new VNode[pnodelist.size()]; int i = 0; Iterator it = pnodelist.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { this.nodes[i] = it.next(); i++; } } - + /** - * If set to true, the layout is applied to all subflows of the given + * If set to true, the layout is applied to all subflows of the given * workflow recursively. * default: true + * * @param precursive boolean */ @Override public void setRecursive(boolean precursive) { this.recursive = precursive; } - + /** - * If set to true, subflow nodes in the given workflow are automatically + * If set to true, subflow nodes in the given workflow are automatically * scaled to fit their contents. * Can only be run if graphmode is set to 0. * default: true + * * @param pautoscaleNodes boolean */ @Override public void setAutoscaleNodes(boolean pautoscaleNodes) { this.autoscaleNodes = pautoscaleNodes; } - + /** - * Select the Jung layout that is supposed to be used in the first step of + * Select the Jung layout that is supposed to be used in the first step of * the algorithm. * 0 - ISOM Layout * 1 - FR Layout * 2 - KK Layout * 3 - DAG Layout (Does not terminate if the graph contains cycles) * default: 0 + * * @param playoutSelector int */ public void setLayoutSelector(int playoutSelector) { this.layoutSelector = playoutSelector; } - + /** * Sets the aspect ratio of the initial drawing area of the graph. - * Width of the drawing space is determined via the longest path in the + * Width of the drawing space is determined via the longest path in the * graph. * Height is determined by dividing the width by the aspect ratio. * default: 16:9 + * * @param paspectratio double */ public void setAspectratio(double paspectratio) { this.aspectratio = paspectratio; } - + /** * Sets the input type. * 0 - VFlowModel (setWorkflow) * 1 - jgraph (setModelGraph) * 2 - nodelist (setNodelist) - * The input must be delivered via the corresponding setter method before + * The input must be delivered via the corresponding setter method before * the call of generateLayout(). * default: 0 + * * @param pgraphmode int */ public void setGraphmode(int pgraphmode) { this.graphmode = pgraphmode; } - + /** - * If set to true, a depth-first-search is performed and all back edges are - * removed from the model graph. The layout is then applied without these + * If set to true, a depth-first-search is performed and all back edges are + * removed from the model graph. The layout is then applied without these * edges. * Is only run if the graph contains cycles. - * default: true + * default: true + * * @param plaunchRemoveCycles boolean */ public void setLaunchRemoveCycles(boolean plaunchRemoveCycles) { this.launchRemoveCycles = plaunchRemoveCycles; } - + /** - * If set to true, disjunct parts of the model graph will be laid out - * separately and then arranged over each other to create the cumulative + * If set to true, disjunct parts of the model graph will be laid out + * separately and then arranged over each other to create the cumulative * layout. - * Is never run if launchRemoveCycles is false and the graph contains + * Is never run if launchRemoveCycles is false and the graph contains * cycles, because it does not terminate in this case. * default: true + * * @param plaunchSeparateDisjunctGraphs boolean */ public void setLaunchSeparateDisjunctGraphs( - boolean plaunchSeparateDisjunctGraphs) { + boolean plaunchSeparateDisjunctGraphs) { this.launchSeparateDisjunctGraphs = plaunchSeparateDisjunctGraphs; } - + /** - * If set to true, edge types will be separated and a layout generated that + * If set to true, edge types will be separated and a layout generated that * follows edge type priorities. * There is no working implementation for this feature yet. * default: false + * * @param plaunchSeparateEdgeTypes boolean */ public void setLaunchSeparateEdgeTypes(boolean plaunchSeparateEdgeTypes) { this.launchSeparateEdgeTypes = plaunchSeparateEdgeTypes; } - + /** - * If set to true, the specified algorithm from the JUNG-library is applied + * If set to true, the specified algorithm from the JUNG-library is applied * to the graph. * The algorithm is specified using setLayoutSelector(). * default: true + * * @param plaunchJungLayout boolean */ public void setLaunchJungLayout(boolean plaunchJungLayout) { this.launchJungLayout = plaunchJungLayout; } - + /** - * If set to true, the graph is rotated to reach an average flow direction + * If set to true, the graph is rotated to reach an average flow direction * that is the direction specified. * default: true + * * @param plaunchRotate boolean */ public void setLaunchRotate(boolean plaunchRotate) { this.launchRotate = plaunchRotate; } - + /** - * If set to true, nodes with an in-degree of 0 will be placed at the + * If set to true, nodes with an in-degree of 0 will be placed at the * leftmost edge of the drawing space. - * Is always run if launchSeparateDisjunctGraphs is true, launchRemoveCycles - * is false and the graph contains cycles, because separateDisjunctGraphs + * Is always run if launchSeparateDisjunctGraphs is true, launchRemoveCycles + * is false and the graph contains cycles, because separateDisjunctGraphs * does not terminate if the graph contains cycles. * default: false + * * @param plaunchOrigin boolean */ public void setLaunchOrigin(boolean plaunchOrigin) { this.launchOrigin = plaunchOrigin; } - + /** - * If set to true, all nodes will be pushed past their predecessors, so no + * If set to true, all nodes will be pushed past their predecessors, so no * edges have a direction inverse to the specified direction. * (Does not terminate if the graph contains cycles) * default: true + * * @param plaunchPushBack boolean */ public void setLaunchPushBack(boolean plaunchPushBack) { this.launchPushBack = plaunchPushBack; } - + /** - * If set to true, nodes that are placed on the same coordinates will be + * If set to true, nodes that are placed on the same coordinates will be * displaced slightly, so the forcePush step can move them accordingly. * default: true + * * @param plaunchDisplaceIdents boolean */ public void setLaunchDisplaceIdents(boolean plaunchDisplaceIdents) { this.launchDisplaceIdents = plaunchDisplaceIdents; } - + /** - * If set to true, all nodes will repel each other until no overlaps between + * If set to true, all nodes will repel each other until no overlaps between * nodes are left or the maximum amount of iterations has been reached. * default: true + * * @param plaunchForcePush boolean */ public void setLaunchForcePush(boolean plaunchForcePush) { this.launchForcePush = plaunchForcePush; } - + /** - * If set to true, nodes will be aligned either with each other or on a + * If set to true, nodes will be aligned either with each other or on a * global grid. * default: true + * * @param plaunchAlignNodes boolean */ public void setLaunchAlignNodes(boolean plaunchAlignNodes) { this.launchAlignNodes = plaunchAlignNodes; } - + /** - * Sets the maximum amount of iterations for the force push step of the + * Sets the maximum amount of iterations for the force push step of the * algorithm. * default: 500 + * * @param pmaxiterations int */ public void setMaxiterations(int pmaxiterations) { this.maxiterations = pmaxiterations; } - + /** - * Sets the scaling parameter of the algorithm. + * Sets the scaling parameter of the algorithm. * Determines the distance between nodes. * default: 1.2 + * * @param pscaling double */ public void setScaling(double pscaling) { this.scaling = pscaling; } - + /** - * Sets the scaling factor that is used to scale subflow-nodes in the + * Sets the scaling factor that is used to scale subflow-nodes in the * autoscaleNodes procedure. * default: 2.0 + * * @param psubflowscale double */ public void setSubflowscale(double psubflowscale) { this.subflowscale = psubflowscale; } - + /** - * Sets the desired average edge direction as an angle to the abscissa in + * Sets the desired average edge direction as an angle to the abscissa in * degrees. * default: 0. + * * @param pdirection double */ public void setDirection(double pdirection) { this.direction = pdirection; } - + /** * Sets the alignment parameter used to align nodes with each other. - * If the value is positive it describes the size of a grid which nodes + * If the value is positive it describes the size of a grid which nodes * will be aligned on. - * If the value is negative its absolute value will be used as multiplier - * to the mean size of each pair of nodes which will then result in a - * threshold under which these two nodes will be positioned at the same + * If the value is negative its absolute value will be used as multiplier + * to the mean size of each pair of nodes which will then result in a + * threshold under which these two nodes will be positioned at the same * coordinate. * default: -(scaling - 1) + * * @param palignmentThreshold double */ public void setAlignmentThreshold(double palignmentThreshold) { this.alignmentThreshold = palignmentThreshold; } - + /** * If set to true, debugging output will be printed in the command line. * default: false + * * @param pdebug boolean */ @Override @@ -692,30 +744,31 @@ public void setDebug(boolean pdebug) { this.debug = pdebug; } // - + /** * Sets up the model-fields. These include the nodearray, nodecount, origin- * nodes and the model graph. - * Uses either a VFlowModel, a Jung-Graph or a nodelist depending on the + * Uses either a VFlowModel, a Jung-Graph or a nodelist depending on the * graphmode parameter. + * * @return boolean */ private boolean allNodesSetUp() { int i; - switch(this.graphmode) { + switch (this.graphmode) { // VFlowModel: case 0: - if(this.workflow == null) return false; + if (this.workflow == null) { return false; } // gather nodelist from workflow ObservableList nodesTemp = this.workflow.getNodes(); - if(nodesTemp == null) return false; + if (nodesTemp == null) { return false; } this.nodecount = nodesTemp.size(); - if(this.nodecount == 0) return false; + if (this.nodecount == 0) { return false; } this.nodes = new VNode[this.nodecount]; this.jgraph = new DirectedSparseGraph<>(); // copy nodelist into nodearray for better performance in the // future and add nodes to the jgraph - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { this.nodes[i] = nodesTemp.get(i); this.jgraph.addVertex(this.nodes[i]); } @@ -723,19 +776,19 @@ private boolean allNodesSetUp() { break; // jgraph: case 1: - if(this.debug) System.out.println("laying out jgraph."); - if(this.jgraph == null) return false; + if (this.debug) { System.out.println("laying out jgraph."); } + if (this.jgraph == null) { return false; } // gather nodelist from modelgraph Collection temp = this.jgraph.getVertices(); Iterator it = temp.iterator(); this.nodecount = temp.size(); - if(this.nodecount == 0) return false; + if (this.nodecount == 0) { return false; } this.conncount = this.jgraph.getEdgeCount(); this.nodes = new VNode[this.nodecount]; // copy nodelist into nodearray for better performance in the // future i = 0; - while(it.hasNext()) { + while (it.hasNext()) { this.nodes[i] = it.next(); i++; } @@ -743,14 +796,14 @@ private boolean allNodesSetUp() { break; // nodelist: case 2: - if(this.debug) System.out.println("laying out with nodelist"); - if(this.nodes == null) return false; + if (this.debug) { System.out.println("laying out with nodelist"); } + if (this.nodes == null) { return false; } this.nodecount = this.nodes.length; - if(this.nodecount == 0) return false; + if (this.nodecount == 0) { return false; } this.workflow = this.nodes[0].getFlow(); // get all connections this.jgraph = new DirectedSparseGraph<>(); - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { this.jgraph.addVertex(this.nodes[i]); } createGraph(this.workflow.getAllConnections()); @@ -766,9 +819,10 @@ private boolean allNodesSetUp() { this.cycle = checkCycles(); return true; } - + /** * Creates a jung graph from a map of connections. + * * @param allConnections ObservableMap */ private void createGraph(ObservableMap allConnections) { @@ -777,117 +831,123 @@ private void createGraph(ObservableMap allConnections) { // get all types of connections Set keys = allConnections.keySet(); Iterator it = keys.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { // get all connections for current type String currType = it.next(); Connections currConns = allConnections.get(currType); ObservableList connections = currConns.getConnections(); int currConnCount = connections.size(); - for(i = 0; i < currConnCount; i++) { + for (i = 0; i < currConnCount; i++) { Connection currConn = connections.get(i); // add an edge correspondig to the current connection to the // jgraph if both sender and receiver are part of the nodearray Integer sender = getNodeID(currConn.getSender().getNode()); Integer receiver = getNodeID(currConn.getReceiver().getNode()); - if((sender != -1) && (receiver != -1)) { - this.jgraph.addEdge(currConn, this.nodes[sender], - this.nodes[receiver]); + if ((sender != -1) && (receiver != -1)) { + this.jgraph.addEdge(currConn, this.nodes[sender], + this.nodes[receiver]); this.conncount++; } } } } - + /** * Returns all origin nodes of the graph. * Origin nodes are all nodes with an in-degree of 0. - * @return Pair[]: Array of Pairs. Each Pair contains the model-ID + * + * @return Pair[]: Array of Pairs. Each Pair contains the model-ID * of the node and its successor count. */ private Pair[] getOrigin() { int i; // add all nodes with in-degree of 0 to list LinkedList originL = new LinkedList<>(); - for(i = 0; i < this.nodecount; i++) { - if(this.jgraph.inDegree(this.nodes[i]) == 0) originL.add(i); + for (i = 0; i < this.nodecount; i++) { + if (this.jgraph.inDegree(this.nodes[i]) == 0) { originL.add(i); } } // create array for origin values int length = originL.size(); Pair[] origina = new Pair[length]; // add pairs of id and successorcount for all entries of the origin-list // to the origin array - for(i = 0; i < length; i++) { + for (i = 0; i < length; i++) { int curr = originL.removeFirst(); - origina[i] = + origina[i] = new Pair<>(curr, this.jgraph.getSuccessorCount( - this.nodes[curr])); - if(this.debug) System.out.println(this.nodes[curr].getId() - + " | In-Degree: " + this.jgraph.inDegree(this.nodes[curr]) - + " Successors: " + this.nodes[curr])); + if (this.debug) { + System.out.println(this.nodes[curr].getId() + + " | In-Degree: " + this.jgraph.inDegree(this.nodes[curr]) + + " Successors: " + this.jgraph.getSuccessorCount(this.nodes[curr])); + } } return origina; } /** * Calculates the average x and y coordinates of all nodes. + * * @return Point2D */ private Point2D getGraphCenter() { int i; double centerx = 0; double centery = 0; - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { centerx += this.nodes[i].getX(); centery += this.nodes[i].getY(); } centerx /= this.nodecount; centery /= this.nodecount; - if(this.debug) System.out.println("Center of graph is at: (" + if (this.debug) { + System.out.println("Center of graph is at: (" + centerx + "|" + centery + ")"); + } return new Point2D.Double(centerx, centery); } - + /** * Checks if the graph contains cycles. + * * @return boolean */ private boolean checkCycles() { int i; boolean[] checked = new boolean[this.nodecount]; - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { int j; // initialize checked with all entries set to false - for(j = 0; j < this.nodecount; j++) { + for (j = 0; j < this.nodecount; j++) { checked[j] = false; } // select start node VNode start = this.nodes[i]; - if(this.jgraph.getSuccessorCount(start) > 0) { + if (this.jgraph.getSuccessorCount(start) > 0) { Collection succsnomod = this.jgraph.getSuccessors(start); LinkedList succs = new LinkedList<>(); succs.addAll(succsnomod); Iterator it = succs.iterator(); // iterate through all successors of start node - while(it.hasNext()) { + while (it.hasNext()) { VNode currNode = it.next(); - if(getNodeID(currNode) == -1) continue; + if (getNodeID(currNode) == -1) { continue; } // if current node is the start node, the start node can be // reached -> there is a cycle - if(currNode.equals(start)) { - if(this.debug) { + if (currNode.equals(start)) { + if (this.debug) { System.out.println("graph contains cycles."); } return true; - } - else { + } else { // if current node is not the start node and has not yet // been checked, add all successors of current node to // the list, reset the iterator, set checked for current // node true. // -> all nodes that are reacheable from start node will // be checked once. - if(!checked[getNodeID(currNode)]) { + if (!checked[getNodeID(currNode)]) { succs.addAll(this.jgraph.getSuccessors(currNode)); it = succs.iterator(); checked[getNodeID(currNode)] = true; @@ -895,74 +955,77 @@ private boolean checkCycles() { } } } - + } - if(this.debug) System.out.println("graph contains no cycles."); - return false; + if (this.debug) { System.out.println("graph contains no cycles."); } + return false; } - + /** - * Performs a depth-first search and removes all back edges so that the + * Performs a depth-first search and removes all back edges so that the * resulting graph is cycle free. */ private void removeCycles() { int i; boolean[] checked = new boolean[this.nodecount]; // initialize checked with all entries set to false - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { checked[i] = false; } LinkedList path = new LinkedList<>(); // iterate through all origin nodes - for(i = 0; i < this.origin.length; i++) { + for (i = 0; i < this.origin.length; i++) { // select current node as start node and start recursive search VNode start = this.nodes[this.origin[i].getFirst()]; remCycR(start, path, checked); } - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { // start recursive search for all nodes that have not yet been // checked - if(!checked[i]) { + if (!checked[i]) { VNode start = this.nodes[i]; remCycR(start, path, checked); } } this.cycle = false; } - + /** * Recursive helper-function to be used by removeCycles(). - * @param VNode curr: current node - * @param path LinkedList: the path from the root-node to the current - * node - * @param checked boolean[]: array of length nodecount showing which nodes - * were already checked + * + * @param VNode curr: current node + * @param path LinkedList: the path from the root-node to the current + * node + * @param checked boolean[]: array of length nodecount showing which nodes + * were already checked */ private void remCycR(VNode curr, LinkedList path, boolean[] checked) { - if(!checked[getNodeID(curr)]) { + if (!checked[getNodeID(curr)]) { // add current node to path path.addFirst(curr); checked[getNodeID(curr)] = true; // perform search on all successors. Collection succs = this.jgraph.getSuccessors(curr); - if(!succs.isEmpty()) { + if (!succs.isEmpty()) { Iterator it = succs.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { VNode currSucc = it.next(); - if(getNodeID(currSucc) == -1) continue; + if (getNodeID(currSucc) == -1) { continue; } // if edge from curr to currSucc is a back edge - if(path.contains(currSucc)) { + if (path.contains(currSucc)) { // remove all edges from curr to currSucc - Collection conns = - this.jgraph.findEdgeSet(curr, currSucc); + Collection conns = + this.jgraph.findEdgeSet(curr, currSucc); Iterator its = conns.iterator(); - while(its.hasNext()) { + while (its.hasNext()) { Connection currConn = its.next(); this.jgraph.removeEdge(currConn); this.conncount--; } - if(this.debug) System.out.println("removing edge from " + if (this.debug) { + System.out.println("removing edge from " + curr.getId() + " to " + currSucc.getId()); + } it = succs.iterator(); } // if edge from curr to currSucc is not a back edge @@ -975,16 +1038,16 @@ private void remCycR(VNode curr, LinkedList path, boolean[] checked) { path.removeFirst(); } } - + /** * Checks the graph for multiple disjunct parts. * Gives each node an ID depending on which disjunct part it belongs to. * Then applies the layout with the given parameters to each disjunct part. - * Arranges the resulting graphs over each other to create the cumulative + * Arranges the resulting graphs over each other to create the cumulative * layout. */ private void separateDisjunctGraphs() { - if(this.debug) System.out.println("separating disjunct graphs"); + if (this.debug) { System.out.println("separating disjunct graphs"); } int currID; int maxID = -1; LinkedList nextnodes = new LinkedList<>(); @@ -992,62 +1055,65 @@ private void separateDisjunctGraphs() { int i; int j; // initialize graphID for all nodes to -1 - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { graphs[i] = -1; } // iterate through all origin nodes - for(i = 0; i < this.origin.length; i++) { + for (i = 0; i < this.origin.length; i++) { // add all reachable nodes to same graphID currID = maxID + 1; nextnodes.add(this.nodes[this.origin[i].getFirst()]); - while(!nextnodes.isEmpty()) { + while (!nextnodes.isEmpty()) { int currNode = getNodeID(nextnodes.removeFirst()); - if(graphs[currNode] == -1) { + if (graphs[currNode] == -1) { // if node has not yet been added to a graph, // it is added to the current graphID graphs[currNode] = currID; - } - else { + } else { // if node was already reached from other graphID, // all nodes in this iteration are connected with that // ID as well - if(this.debug) System.out.println("currID " + currID - + " graphid " + graphs[currNode] + "graph: " + if (this.debug) { + System.out.println("currID " + currID + + " graphid " + graphs[currNode] + "graph: " + Arrays.toString(graphs)); - for(j = 0; j < this.nodecount; j++) { - if(graphs[j] == currID) graphs[j] = graphs[currNode]; + } + for (j = 0; j < this.nodecount; j++) { + if (graphs[j] == currID) { graphs[j] = graphs[currNode]; } } currID = graphs[currNode]; - if(this.debug) System.out.println("graph now: " + if (this.debug) { + System.out.println("graph now: " + Arrays.toString(graphs)); + } } // add successors of current node to queue, so all reachable // nodes will be iterated over - if(this.jgraph.getSuccessorCount(this.nodes[currNode]) != 0) { - Collection succ = - this.jgraph.getSuccessors(this.nodes[currNode]); + if (this.jgraph.getSuccessorCount(this.nodes[currNode]) != 0) { + Collection succ = + this.jgraph.getSuccessors(this.nodes[currNode]); Iterator it = succ.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { VNode temp = it.next(); - if(getNodeID(temp) == -1) continue; - if(graphs[getNodeID(temp)] != currID) { + if (getNodeID(temp) == -1) { continue; } + if (graphs[getNodeID(temp)] != currID) { nextnodes.add(temp); } } } } // calculate new maxID - for(j = 0; j < this.nodecount; j++) { - if(graphs[j] > maxID) maxID = graphs[j]; + for (j = 0; j < this.nodecount; j++) { + if (graphs[j] > maxID) { maxID = graphs[j]; } } } - if(this.debug) { - for(i = 0; i < this.nodecount; i++) { - System.out.println(this.nodes[i].getId() + " belongs to graph " - + graphs[i]); + if (this.debug) { + for (i = 0; i < this.nodecount; i++) { + System.out.println(this.nodes[i].getId() + " belongs to graph " + + graphs[i]); } } - + // initialize subgenerator for subgraphs LayoutGeneratorSmart subgen = new LayoutGeneratorSmart(); subgen.setAspectratio(this.aspectratio); @@ -1076,26 +1142,30 @@ private void separateDisjunctGraphs() { double x = 0.; double[] xpos = new double[this.nodecount]; double[] ypos = new double[this.nodecount]; - + // iterate over all found graphIDs - for(i = 0; i <= maxID; i++) { - if(this.debug) System.out.println("--- laying out subgraph with ID " + for (i = 0; i <= maxID; i++) { + if (this.debug) { + System.out.println("--- laying out subgraph with ID " + i); + } double minx = Double.POSITIVE_INFINITY; double miny = Double.POSITIVE_INFINITY; double maxy = Double.NEGATIVE_INFINITY; // create subgraph for nodes with current graphID - DirectedGraph subgraph = - new DirectedSparseGraph<>(); - for(j = 0; j < this.nodecount; j++) { - if(graphs[j] == i) { - if(this.debug) System.out.println(this.nodes[j].getId() + DirectedGraph subgraph = + new DirectedSparseGraph<>(); + for (j = 0; j < this.nodecount; j++) { + if (graphs[j] == i) { + if (this.debug) { + System.out.println(this.nodes[j].getId() + " belongs to the subgraph with ID " + i); + } subgraph.addVertex(this.nodes[j]); - Collection conns = - this.jgraph.getIncidentEdges(this.nodes[j]); + Collection conns = + this.jgraph.getIncidentEdges(this.nodes[j]); Iterator it = conns.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { Connection currConn = it.next(); VNode sender = currConn.getSender().getNode(); VNode receiver = currConn.getReceiver().getNode(); @@ -1107,29 +1177,33 @@ private void separateDisjunctGraphs() { subgen.setModelGraph(subgraph); subgen.generateLayout(); // find outermost coordinates of graph - for(j = 0; j < this.nodecount; j++) { - if(graphs[j] == i) { - if(this.nodes[j].getX() < minx) minx = this.nodes[j].getX(); - if(this.nodes[j].getY() < miny) miny = this.nodes[j].getY(); - if((this.nodes[j].getY() - + this.nodes[j].getHeight()) > maxy) { + for (j = 0; j < this.nodecount; j++) { + if (graphs[j] == i) { + if (this.nodes[j].getX() < minx) { minx = this.nodes[j].getX(); } + if (this.nodes[j].getY() < miny) { miny = this.nodes[j].getY(); } + if ((this.nodes[j].getY() + + this.nodes[j].getHeight()) > maxy) { maxy = this.nodes[j].getY() + this.nodes[j].getHeight(); } } } - if(this.debug) System.out.println("graphID: " + i + " minx: " - + minx + " miny: " + miny + " maxy: " + maxy + if (this.debug) { + System.out.println("graphID: " + i + " minx: " + + minx + " miny: " + miny + " maxy: " + maxy + " will be set to: (" + x + "|" + y + ")"); + } // offset calculated node positions with maximum coordinates of // previous subgraphs - for(j = 0; j < this.nodecount; j++) { - if(graphs[j] == i) { + for (j = 0; j < this.nodecount; j++) { + if (graphs[j] == i) { double newx = x + this.nodes[j].getX() - minx; double newy = (y - miny) + this.nodes[j].getY(); - if(this.debug) System.out.println("changing position of " - + this.nodes[j].getId() + " from (" - + this.nodes[j].getX() + "|" + this.nodes[j].getY() + if (this.debug) { + System.out.println("changing position of " + + this.nodes[j].getId() + " from (" + + this.nodes[j].getX() + "|" + this.nodes[j].getY() + ") to (" + newx + "|" + newy + ")"); + } xpos[j] = newx; ypos[j] = newy; } @@ -1137,17 +1211,19 @@ private void separateDisjunctGraphs() { y += (maxy - miny) * this.scaling; } // apply positions to nodes - for(i = 0; i < this.nodecount; i++) { - this.nodes[i].setX(xpos[i]); - this.nodes[i].setY(ypos[i]); - if(this.debug) System.out.println(this.nodes[i].getId() - + " has final position: (" + xpos[i] + "|" + ypos[i] - + ")"); + for (i = 0; i < this.nodecount; i++) { + this.nodes[i].setX(xpos[i]); + this.nodes[i].setY(ypos[i]); + if (this.debug) { + System.out.println(this.nodes[i].getId() + + " has final position: (" + xpos[i] + "|" + ypos[i] + + ")"); + } } } - + /** - * Separates edge types and generates a layout for each edge type + * Separates edge types and generates a layout for each edge type * separately. * This is not a working implementation. */ @@ -1169,14 +1245,14 @@ private void separateEdgeTypes() { subgen.setLaunchRemoveCycles(this.launchRemoveCycles); subgen.setLaunchRotate(this.launchRotate); subgen.setLaunchSeparateDisjunctGraphs( - this.launchSeparateDisjunctGraphs); + this.launchSeparateDisjunctGraphs); subgen.setLaunchSeparateEdgeTypes(false); subgen.setLayoutSelector(this.layoutSelector); subgen.setMaxiterations(this.maxiterations); subgen.setRecursive(false); subgen.setScaling(this.scaling); subgen.setSubflowscale(this.subflowscale); - + // get connectiontypes LinkedList nodelist; VFlowModel flow = this.nodes[0].getFlow(); @@ -1185,25 +1261,25 @@ private void separateEdgeTypes() { Iterator keyit = keys.iterator(); nodelist = new LinkedList<>(); // iterate through connection types - while(keyit.hasNext()) { + while (keyit.hasNext()) { String currkey = keyit.next(); Connections currConns = allConns.get(currkey); ObservableList connList = currConns.getConnections(); Iterator connit = connList.iterator(); // add all nodes of current connection type to nodelist - while(connit.hasNext()) { + while (connit.hasNext()) { Connection currConn = connit.next(); VNode sender = currConn.getSender().getNode(); VNode receiver = currConn.getReceiver().getNode(); - if((getNodeID(sender) != -1) && (!nodelist.contains(sender))) { + if ((getNodeID(sender) != -1) && (!nodelist.contains(sender))) { nodelist.add(sender); } - if((getNodeID(receiver) != -1) - && (!nodelist.contains(receiver))) { + if ((getNodeID(receiver) != -1) + && (!nodelist.contains(receiver))) { nodelist.add(receiver); } } - if(nodelist.isEmpty()) continue; + if (nodelist.isEmpty()) { continue; } // create layout on current nodelist subgen.setNodelist(nodelist); subgen.generateLayout(); @@ -1212,46 +1288,46 @@ private void separateEdgeTypes() { subgen.setLaunchRotate(false); } } - + /** * Applies all steps of the layout, whose launch-parameters are set to true. */ @Override public void generateLayout() { - if(this.debug) System.out.println("Generating layout."); + if (this.debug) { System.out.println("Generating layout."); } // setup and check for errors - if(allNodesSetUp()) { + if (allNodesSetUp()) { // get origin point double minx = Double.POSITIVE_INFINITY; double miny = Double.POSITIVE_INFINITY; int i; - for(i = 0; i < this.nodecount; i++) { - if(this.nodes[i].getX() < minx) minx = this.nodes[i].getX(); - if(this.nodes[i].getY() < miny) miny = this.nodes[i].getY(); + for (i = 0; i < this.nodecount; i++) { + if (this.nodes[i].getX() < minx) { minx = this.nodes[i].getX(); } + if (this.nodes[i].getY() < miny) { miny = this.nodes[i].getY(); } } - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { this.nodes[i].setX(this.nodes[i].getX() - minx); this.nodes[i].setY(this.nodes[i].getY() - miny); } - - if(this.cycle && this.launchRemoveCycles) { + + if (this.cycle && this.launchRemoveCycles) { removeCycles(); this.origin = getOrigin(); } // apply layout to subflows - if(this.recursive) { + if (this.recursive) { runSubflows(); } // scale nodes according to their contents. - if(this.autoscaleNodes) { + if (this.autoscaleNodes) { autoscaleNodes(); } - if(this.launchSeparateDisjunctGraphs) { + if (this.launchSeparateDisjunctGraphs) { // only run if the graph contains no cycles - if(!this.cycle) { + if (!this.cycle) { separateDisjunctGraphs(); // displace by origin point - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { this.nodes[i].setX(this.nodes[i].getX() + minx); this.nodes[i].setY(this.nodes[i].getY() + miny); } @@ -1260,22 +1336,24 @@ public void generateLayout() { // run origin instead else { this.launchOrigin = true; - if(this.debug) System.out.println("Graph contains cycles ->" + if (this.debug) { + System.out.println("Graph contains cycles ->" + " origin used instead of seperate disjunct graphs" + "."); + } } } - if(this.launchSeparateEdgeTypes) { + if (this.launchSeparateEdgeTypes) { separateEdgeTypes(); // displace by origin point - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { this.nodes[i].setX(this.nodes[i].getX() + minx); this.nodes[i].setY(this.nodes[i].getY() + miny); } return; } // create jung-layout - switch(this.layoutSelector) { + switch (this.layoutSelector) { case 0: // ISOM Layout this.layout = new ISOMLayout<>(this.jgraph); break; @@ -1286,56 +1364,56 @@ public void generateLayout() { this.layout = new KKLayout<>(this.jgraph); break; case 3: // DAG Layout - if(!this.cycle) this.layout = new DAGLayout<>(this.jgraph); - else { + if (!this.cycle) { this.layout = new DAGLayout<>(this.jgraph); } else { this.layout = new ISOMLayout<>(this.jgraph); - if(this.debug) System.out.println("Graph contains " - + "cycles -> ISOM Layout used instead of DAG" + if (this.debug) { + System.out.println("Graph contains " + + "cycles -> ISOM Layout used instead of DAG" + " Layout."); + } } break; default: this.layout = new ISOMLayout<>(this.jgraph); break; } - if(this.launchJungLayout) stepLayoutApply(); + if (this.launchJungLayout) { stepLayoutApply(); } this.graphcenter = getGraphCenter(); - if(this.launchRotate) stepRotate(); - if(this.launchOrigin) stepOrigin(); - if(this.launchPushBack) { - if(!this.cycle) stepPushBack(); - else if(this.debug) System.out.println("Graph contains cycles " + if (this.launchRotate) { stepRotate(); } + if (this.launchOrigin) { stepOrigin(); } + if (this.launchPushBack) { + if (!this.cycle) { stepPushBack(); } else if (this.debug) { + System.out.println("Graph contains cycles " + "-> PushBack skipped."); + } } - if(this.launchDisplaceIdents) displaceIdents(); - if(this.launchAlignNodes) { + if (this.launchDisplaceIdents) { displaceIdents(); } + if (this.launchAlignNodes) { this.maxiterations /= 2; - if(this.launchForcePush) forcePush(); + if (this.launchForcePush) { forcePush(); } alignNodes(); - if(this.launchDisplaceIdents) displaceIdents(); - if(this.launchForcePush) forcePush(); - } - else { - if(this.launchForcePush) forcePush(); + if (this.launchDisplaceIdents) { displaceIdents(); } + if (this.launchForcePush) { forcePush(); } + } else { + if (this.launchForcePush) { forcePush(); } } // displace by origin point - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { this.nodes[i].setX(this.nodes[i].getX() + minx); this.nodes[i].setY(this.nodes[i].getY() + miny); } - if(this.debug) { - for(i = 0; i < this.nodecount; i++) { + if (this.debug) { + for (i = 0; i < this.nodecount; i++) { System.out.println(this.nodes[i].getId() + " has final " - + "position: (" + this.nodes[i].getX() + "|" - + this.nodes[i].getY() + ")"); + + "position: (" + this.nodes[i].getX() + "|" + + this.nodes[i].getY() + ")"); } } - } - else { - if(this.debug) System.out.println("Error on setup."); + } else { + if (this.debug) { System.out.println("Error on setup."); } } } - + /** * Applies the layout with the same parameters to each subflow. */ @@ -1353,7 +1431,7 @@ private void runSubflows() { subgen.setGraphmode(0); subgen.setLaunchRemoveCycles(this.launchRemoveCycles); subgen.setLaunchSeparateDisjunctGraphs( - this.launchSeparateDisjunctGraphs); + this.launchSeparateDisjunctGraphs); subgen.setLaunchSeparateEdgeTypes(this.launchSeparateEdgeTypes); subgen.setLaunchJungLayout(this.launchJungLayout); subgen.setLaunchRotate(this.launchRotate); @@ -1365,30 +1443,32 @@ private void runSubflows() { subgen.setMaxiterations(this.maxiterations); // apply layout to each subflow int i; - for(i = 0; i < this.nodecount; i++) { - if(this.nodes[i] instanceof VFlowModel) { + for (i = 0; i < this.nodecount; i++) { + if (this.nodes[i] instanceof VFlowModel) { subgen.setWorkflow((VFlowModel) this.nodes[i]); subgen.generateLayout(); } } } - + /** * Scales subflow-nodes according to their contents. */ private void autoscaleNodes() { int i; - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { VFlowModel subflow; - if(!(this.nodes[i] instanceof VFlowModel)) continue; + if (!(this.nodes[i] instanceof VFlowModel)) { continue; } subflow = (VFlowModel) this.nodes[i]; // get node representation of the current subflow VNode flownode = this.nodes[i]; - if(this.debug) System.out.println("Resizing subflow-node " + if (this.debug) { + System.out.println("Resizing subflow-node " + flownode.getId()); + } // get nodes from the subflow Collection subnodes = subflow.getNodes(); - if(subnodes.isEmpty()) continue; + if (subnodes.isEmpty()) { continue; } Iterator nodeit = subnodes.iterator(); double minx = Double.POSITIVE_INFINITY; double maxx = Double.NEGATIVE_INFINITY; @@ -1396,30 +1476,40 @@ private void autoscaleNodes() { double maxy = Double.NEGATIVE_INFINITY; // iterate over all subflow nodes to get outermost coordinates of // subflow - while(nodeit.hasNext()) { + while (nodeit.hasNext()) { VNode currNode = nodeit.next(); double x = currNode.getX(); double y = currNode.getY(); - if(this.debug) System.out.println(currNode.getId() + " has " + if (this.debug) { + System.out.println(currNode.getId() + " has " + "position (" + x + "|" + y + ")"); - if(minx > x) minx = x; - if(maxx < (x + currNode.getWidth())) maxx = x + } + if (minx > x) { minx = x; } + if (maxx < (x + currNode.getWidth())) { + maxx = x + currNode.getWidth(); - if(miny > y) miny = y; - if(maxy < (y + currNode.getHeight())) maxy = y + } + if (miny > y) { miny = y; } + if (maxy < (y + currNode.getHeight())) { + maxy = y + currNode.getHeight(); + } } - if(this.debug) System.out.println("extreme positions of " - + flownode.getId() + " are min: (" + minx + "|" + miny + if (this.debug) { + System.out.println("extreme positions of " + + flownode.getId() + " are min: (" + minx + "|" + miny + ") max: (" + maxx + "|" + maxy + ")"); + } // calculate size of subflow double width = maxx - minx; double height = maxy - miny; - if(this.debug) System.out.println("Resizing subflow-node " + if (this.debug) { + System.out.println("Resizing subflow-node " + flownode.getId() + " from size (" + flownode.getWidth() + "|" + flownode.getHeight() + ") to size (" - + (width / subnodes.size() * this.subflowscale) + "|" + + (width / subnodes.size() * this.subflowscale) + "|" + (height / subnodes.size() * this.subflowscale) + ")"); + } // set size of node representing current subflow flownode.setWidth(width / subnodes.size() * this.subflowscale); flownode.setHeight(height / subnodes.size() * this.subflowscale); @@ -1430,7 +1520,7 @@ private void autoscaleNodes() { * Applies the chosen layout implemented in the Jung Framework. */ private void stepLayoutApply() { - if(this.debug) System.out.println("--- applying layout."); + if (this.debug) { System.out.println("--- applying layout."); } // find cumulative width of longest path int maxpath = (int) Math.round(findMaxPathWidth() / (this.scaling * 2)); // calculate height from maxpath-width and aspectratio @@ -1438,18 +1528,21 @@ private void stepLayoutApply() { this.layout.setSize(new Dimension(maxpath, y)); // set layout coordinates int i; - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { Point2D coords; coords = this.layout.transform(this.nodes[i]); this.nodes[i].setX(coords.getX() - this.nodes[i].getWidth() / 2); this.nodes[i].setY(coords.getY() - this.nodes[i].getHeight() / 2); - if(this.debug) System.out.println(this.nodes[i].getId() + " | X: " + if (this.debug) { + System.out.println(this.nodes[i].getId() + " | X: " + coords.getX() + " Y: " + coords.getY()); + } } } - + /** * Finds the cumulative width of all nodes on the longest path in the graph. + * * @return double */ private double findMaxPathWidth() { @@ -1463,26 +1556,26 @@ private double findMaxPathWidth() { int i; // set maxPathFollowing for every node without successors to 0 // also add these nodes to the queue - for(i = 0; i < this.nodecount; i++) { - if(this.jgraph.getSuccessorCount(this.nodes[i]) == 0) { + for (i = 0; i < this.nodecount; i++) { + if (this.jgraph.getSuccessorCount(this.nodes[i]) == 0) { maxPathFollowing[i] = 0; fifo.add(i); } } // iterate through the queue - while(!fifo.isEmpty()) { + while (!fifo.isEmpty()) { Integer currNode = fifo.removeFirst(); // iterate over all successors of the current node - if(this.jgraph.getSuccessorCount(this.nodes[currNode]) != 0) { + if (this.jgraph.getSuccessorCount(this.nodes[currNode]) != 0) { nodelist = this.jgraph.getSuccessors(this.nodes[currNode]); it = nodelist.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { Integer currSucc = getNodeID(it.next()); - if(currSucc == -1) continue; + if (currSucc == -1) { continue; } int tempFollowing = 1 + maxPathFollowing[currSucc]; // set maxPathFollowing of the current node to // 1 + the largest maxPathFollowing of all successors - if(tempFollowing > maxPathFollowing[currNode]) { + if (tempFollowing > maxPathFollowing[currNode]) { maxPathFollowing[currNode] = tempFollowing; } } @@ -1490,15 +1583,15 @@ private double findMaxPathWidth() { // add all predecessors of the current node to the queue nodelist = this.jgraph.getPredecessors(this.nodes[currNode]); it = nodelist.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { Integer next = getNodeID(it.next()); - if(next == -1) continue; + if (next == -1) { continue; } fifo.add(next); } } // find max path and its start node - for(i = 0; i < this.nodecount; i++) { - if(maxPathFollowing[i] > maxPath) { + for (i = 0; i < this.nodecount; i++) { + if (maxPathFollowing[i] > maxPath) { maxPath = maxPathFollowing[i]; maxPathIndex = i; } @@ -1508,10 +1601,10 @@ private double findMaxPathWidth() { nodelist = this.jgraph.getSuccessors(this.nodes[maxPathIndex]); maxPath -= 1; it = nodelist.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { VNode currSucc = it.next(); - if(getNodeID(currSucc) == -1) continue; - if(maxPath == maxPathFollowing[getNodeID(currSucc)]) { + if (getNodeID(currSucc) == -1) { continue; } + if (maxPath == maxPathFollowing[getNodeID(currSucc)]) { maxPathWidth += this.nodes[getNodeID(currSucc)].getWidth(); maxPath--; nodelist = this.jgraph.getSuccessors(currSucc); @@ -1520,64 +1613,74 @@ private double findMaxPathWidth() { } return maxPathWidth; } - + /** - * Rotates the entire graph around its center point, so its new average + * Rotates the entire graph around its center point, so its new average * edge-direction is the direction specified. */ private void stepRotate() { - if(this.debug) System.out.println("--- starting rotation."); + if (this.debug) { System.out.println("--- starting rotation."); } int i; - if(this.conncount == 0) return; + if (this.conncount == 0) { return; } double centerx = this.graphcenter.getX(); double centery = this.graphcenter.getY(); - if(this.debug) System.out.println("center of rotation: (" + centerx + if (this.debug) { + System.out.println("center of rotation: (" + centerx + "|" + centery + ")"); - + } + // get average direction of edges double avgdirx = 0; double avgdiry = 0; Collection conns = this.jgraph.getEdges(); Iterator it = conns.iterator(); // iterate over all connections - while(it.hasNext()) { + while (it.hasNext()) { Connection currConn = it.next(); VNode senderNode = currConn.getSender().getNode(); VNode receiverNode = currConn.getReceiver().getNode(); - Point2D sender = new Point2D.Double(senderNode.getX(), - senderNode.getY()); - Point2D receiver = new Point2D.Double(receiverNode.getX(), - receiverNode.getY()); + Point2D sender = new Point2D.Double(senderNode.getX(), + senderNode.getY()); + Point2D receiver = new Point2D.Double(receiverNode.getX(), + receiverNode.getY()); // direction of connection as vector double dirx = receiver.getX() - sender.getX(); double diry = receiver.getY() - sender.getY(); avgdirx += dirx; avgdiry += diry; - if(this.debug) System.out.println("Edge from " - + currConn.getSender().getNode().getId() + " to " - + currConn.getReceiver().getNode().getId() - + " has direction: (" + dirx + "|" +diry + ") = " + if (this.debug) { + System.out.println("Edge from " + + currConn.getSender().getNode().getId() + " to " + + currConn.getReceiver().getNode().getId() + + " has direction: (" + dirx + "|" + diry + ") = " + (diry / dirx)); + } } avgdirx /= this.conncount; avgdiry /= this.conncount; - double avghyp = Math.sqrt(Math.pow(avgdirx, 2.) - + Math.pow(avgdiry, 2.)); - if(this.debug) System.out.println("average horizontal vector: " + double avghyp = Math.sqrt(Math.pow(avgdirx, 2.) + + Math.pow(avgdiry, 2.)); + if (this.debug) { + System.out.println("average horizontal vector: " + avgdirx); - if(this.debug) System.out.println("original average edge direction: " + } + if (this.debug) { + System.out.println("original average edge direction: " + ((avgdiry / avgdirx) / this.conncount)); + } double dirSin = Math.sin(this.direction * 2 * Math.PI / 360); double dirCos = Math.cos(this.direction * 2 * Math.PI / 360); // rotate graph around center so new average direction is 0 // ( -> x-direction) - for(i = 0; i < this.nodecount; i++) { - Point2D currCoords = new Point2D.Double(this.nodes[i].getX(), - this.nodes[i].getY()); - if(this.debug) System.out.println("Rotated Vertex " - + this.nodes[i].getId() + " from (" + currCoords.getX() + for (i = 0; i < this.nodecount; i++) { + Point2D currCoords = new Point2D.Double(this.nodes[i].getX(), + this.nodes[i].getY()); + if (this.debug) { + System.out.println("Rotated Vertex " + + this.nodes[i].getId() + " from (" + currCoords.getX() + "|" + currCoords.getY() + ")"); + } // move coordinates to point of origin double x = currCoords.getX() - centerx; double y = currCoords.getY() - centery; @@ -1596,15 +1699,18 @@ private void stepRotate() { this.nodes[i].setX(newx); this.nodes[i].setY(newy); this.layout.setLocation(this.nodes[i], newCoords); - if(this.debug) System.out.println("to (" + newx + "|" + newy + ")"); + if (this.debug) { System.out.println("to (" + newx + "|" + newy + ")"); } } - if(this.debug) System.out.println("new average edge direction: " + if (this.debug) { + System.out.println("new average edge direction: " + getAvgDir()); + } } - + /** - * Returns the average direction of all edges in the graph relative to the + * Returns the average direction of all edges in the graph relative to the * horizontal axis. + * * @return double */ private double getAvgDir() { @@ -1613,52 +1719,58 @@ private double getAvgDir() { Collection conns = this.jgraph.getEdges(); Iterator it = conns.iterator(); // iterate over all connections - while(it.hasNext()) { + while (it.hasNext()) { Connection currConn = it.next(); VNode senderNode = currConn.getSender().getNode(); VNode receiverNode = currConn.getReceiver().getNode(); - Point2D sender = new Point2D.Double(senderNode.getX(), - senderNode.getY()); - Point2D receiver = new Point2D.Double(receiverNode.getX(), - receiverNode.getY()); + Point2D sender = new Point2D.Double(senderNode.getX(), + senderNode.getY()); + Point2D receiver = new Point2D.Double(receiverNode.getX(), + receiverNode.getY()); // direction of connection as vector double dirx = receiver.getX() - sender.getX(); double diry = receiver.getY() - sender.getY(); avgdirx += dirx; avgdiry += diry; - if(this.debug) System.out.println("Edge from " - + currConn.getSender().getNode().getId() + " to " - + currConn.getReceiver().getNode().getId() - + " has direction: (" + dirx + "|" +diry + ") = " + if (this.debug) { + System.out.println("Edge from " + + currConn.getSender().getNode().getId() + " to " + + currConn.getReceiver().getNode().getId() + + " has direction: (" + dirx + "|" + diry + ") = " + (diry / dirx)); + } } avgdirx /= this.conncount; avgdiry /= this.conncount; return Math.atan(avgdiry / avgdirx); } - + /** * Places all nodes without predecessors at the leftmost edge of the graph. */ private void stepOrigin() { - if(this.debug) System.out.println("--- starting origin"); + if (this.debug) { System.out.println("--- starting origin"); } int i; // get lowest x coordinate, largest height and width in graph double minx = this.nodes[0].getX(); double maxw = 0.; double maxh = 0.; - for(i = 0; i < this.nodecount; i++) { - if(this.nodes[i].getX() < minx) minx = this.nodes[i].getX(); - if(this.nodes[i].getWidth() > maxw) maxw = + for (i = 0; i < this.nodecount; i++) { + if (this.nodes[i].getX() < minx) { minx = this.nodes[i].getX(); } + if (this.nodes[i].getWidth() > maxw) { + maxw = this.nodes[i].getWidth(); - if(this.nodes[i].getHeight() > maxh) maxh = + } + if (this.nodes[i].getHeight() > maxh) { + maxh = this.nodes[i].getHeight(); + } } // place origin nodes on lowest x coordinate double lastpos = - this.graphcenter.getY() + this.graphcenter.getY() - ((this.origin.length / 2) * maxh * this.scaling); - for(i = 0; i < this.origin.length; i++) { + for (i = 0; i < this.origin.length; i++) { Point2D coords = new Point2D.Double(); coords.setLocation((minx - (this.scaling * maxw)), lastpos); lastpos += this.scaling * (maxh); @@ -1668,180 +1780,193 @@ private void stepOrigin() { currNode.setY(coords.getY()); } } - + /** - * Pushes all successor nodes past their predecessors in the direction + * Pushes all successor nodes past their predecessors in the direction * specified, so no edges have a direction inverse to the specified * direction. */ private void stepPushBack() { - if(this.debug) System.out.println("--- starting push back."); + if (this.debug) { System.out.println("--- starting push back."); } LinkedList fifo = new LinkedList<>(); int i; // enter all origin nodes into fifo - for(i = 0; i < this.origin.length; i++) { + for (i = 0; i < this.origin.length; i++) { fifo.add(this.origin[i].getFirst()); } - while(!fifo.isEmpty()) { + while (!fifo.isEmpty()) { i = fifo.removeFirst(); // move node to the right if predecessor has larger // or equal x-coordinate - Collection nodelist = - this.jgraph.getPredecessors(this.nodes[i]); + Collection nodelist = + this.jgraph.getPredecessors(this.nodes[i]); Iterator it = nodelist.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { VNode pred = it.next(); - if(this.debug) System.out.println("handling connection from " + if (this.debug) { + System.out.println("handling connection from " + pred.getId() + " to " + this.nodes[i].getId()); - double preDiag = Math.sqrt(Math.pow((pred.getWidth() / 2), 2) - + Math.pow((pred.getHeight() / 2), 2)); + } + double preDiag = Math.sqrt(Math.pow((pred.getWidth() / 2), 2) + + Math.pow((pred.getHeight() / 2), 2)); double desDist = preDiag * this.scaling; // predecessor: - double xa = pred.getX() + pred.getWidth()/2; - double ya = pred.getY() + pred.getHeight()/2; + double xa = pred.getX() + pred.getWidth() / 2; + double ya = pred.getY() + pred.getHeight() / 2; // current node: - double xb = this.nodes[i].getX() + this.nodes[i].getWidth()/2; - double yb = this.nodes[i].getY() + this.nodes[i].getHeight()/2; + double xb = this.nodes[i].getX() + this.nodes[i].getWidth() / 2; + double yb = this.nodes[i].getY() + this.nodes[i].getHeight() / 2; // direction double xd = Math.cos(this.direction); double yd = Math.sin(this.direction); // projection - double xp = ((xd*(xb - xa)) + (yd*(yb - ya)))*xd - / (Math.pow(xd, 2) + Math.pow(yd, 2)); - double yp = ((xd*(xb - xa)) + (yd*(yb - ya)))*yd - / (Math.pow(xd, 2) + Math.pow(yd, 2)); - double projectionlen = Math.sqrt(Math.pow(xp, 2) - + Math.pow(yp, 2)); - double projtestlen = Math.sqrt(Math.pow((xp + xd), 2) - + Math.pow((yp + yd), 2)); - if((projectionlen < desDist) || (projtestlen < projectionlen)) { + double xp = ((xd * (xb - xa)) + (yd * (yb - ya))) * xd + / (Math.pow(xd, 2) + Math.pow(yd, 2)); + double yp = ((xd * (xb - xa)) + (yd * (yb - ya))) * yd + / (Math.pow(xd, 2) + Math.pow(yd, 2)); + double projectionlen = Math.sqrt(Math.pow(xp, 2) + + Math.pow(yp, 2)); + double projtestlen = Math.sqrt(Math.pow((xp + xd), 2) + + Math.pow((yp + yd), 2)); + if ((projectionlen < desDist) || (projtestlen < projectionlen)) { // parameter: - double phi = (-(xd*xp + yd*yp) + Math.sqrt(2*xd*xp*yd*yp - - Math.pow(xp*yd, 2) - Math.pow(yp*xd, 2) - + Math.pow(desDist*xd, 2) - + Math.pow(desDist*yd, 2))) / (Math.pow(xd, 2) - + Math.pow(yd, 2)); - if(this.debug) System.out.println("phi: " + phi); - xb = xb + phi*xd; - yb = yb + phi*yd; + double phi = (-(xd * xp + yd * yp) + Math.sqrt(2 * xd * xp * yd * yp + - Math.pow(xp * yd, 2) - Math.pow(yp * xd, 2) + + Math.pow(desDist * xd, 2) + + Math.pow(desDist * yd, 2))) / (Math.pow(xd, 2) + + Math.pow(yd, 2)); + if (this.debug) { System.out.println("phi: " + phi); } + xb = xb + phi * xd; + yb = yb + phi * yd; this.nodes[i].setX(xb); this.nodes[i].setY(yb); } } - if(this.debug) System.out.println("position of Node " - + this.nodes[i].getId() + " after push back : (" + if (this.debug) { + System.out.println("position of Node " + + this.nodes[i].getId() + " after push back : (" + this.nodes[i].getX() + "|" + this.nodes[i].getY() + ")"); + } // add successors of current node to the fifo nodelist = this.jgraph.getSuccessors(this.nodes[i]); it = nodelist.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { Integer next = getNodeID(it.next()); - if(next == -1) continue; + if (next == -1) { continue; } fifo.add(next); } } } - + /** * Displaces nodes that are in exactly the same location. */ private void displaceIdents() { // iterate over all pairs of nodes - if(this.debug) System.out.println("- Displacing nodes with identical " + if (this.debug) { + System.out.println("- Displacing nodes with identical " + "positions."); + } double displacement; - if(this.scaling < 0) { + if (this.scaling < 0) { displacement = this.scaling * (-1); - } - else { + } else { displacement = this.scaling; } int i; - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { int j; - for(j = 0; j < this.nodecount; j++) { - if(i == j) continue; + for (j = 0; j < this.nodecount; j++) { + if (i == j) { continue; } // if distance between nodes is 0 - if(getRealNodeDist(this.nodes[i], this.nodes[j]) == 0) { - if(this.debug) System.out.println(this.nodes[i].getId() - + " and " + this.nodes[j].getId() + if (getRealNodeDist(this.nodes[i], this.nodes[j]) == 0) { + if (this.debug) { + System.out.println(this.nodes[i].getId() + + " and " + this.nodes[j].getId() + " have the same position."); - Collection succs = - this.jgraph.getSuccessors(this.nodes[i]); - if(succs.contains(this.nodes[j])) { + } + Collection succs = + this.jgraph.getSuccessors(this.nodes[i]); + if (succs.contains(this.nodes[j])) { // if j is successor to i, move j to the right this.nodes[j].setX(this.nodes[j].getX() + displacement); - if(this.debug) System.out.print(" Moving " - + this.nodes[j].getId() + " by " + if (this.debug) { + System.out.print(" Moving " + + this.nodes[j].getId() + " by " + displacement); - } - else { + } + } else { succs = this.jgraph.getSuccessors(this.nodes[j]); - if(succs.contains(this.nodes[i])) { + if (succs.contains(this.nodes[i])) { // if i is successor to j, move i to the right - this.nodes[i].setX(this.nodes[i].getX() - + displacement); - if(this.debug) System.out.print(" Moving " - + this.nodes[i].getId() + " by " + this.nodes[i].setX(this.nodes[i].getX() + + displacement); + if (this.debug) { + System.out.print(" Moving " + + this.nodes[i].getId() + " by " + displacement); - } - else { + } + } else { // if the nodes are not successors to each other, // displace them vertically - this.nodes[i].setY(this.nodes[i].getY() - + displacement); - if(this.debug) System.out.print(" Moving " - + this.nodes[i].getId() + " by " + this.nodes[i].setY(this.nodes[i].getY() + + displacement); + if (this.debug) { + System.out.print(" Moving " + + this.nodes[i].getId() + " by " + displacement); + } } } } } } } - + /** * Applies force to each node, to push each other away and remove overlaps. */ private void forcePush() { - if(this.debug) System.out.println("--- starting force push"); + if (this.debug) { System.out.println("--- starting force push"); } int iteration; Boolean change = true; // go through all iterations - for(iteration = 0; iteration < this.maxiterations; iteration++) { - if(this.debug) System.out.println("iteration: " + (iteration + 1) + for (iteration = 0; iteration < this.maxiterations; iteration++) { + if (this.debug) { + System.out.println("iteration: " + (iteration + 1) + " of " + this.maxiterations); - if(!change) break; + } + if (!change) { break; } change = false; int i; // iterate over all pairs of nodes - for(i = 0; i < this.nodecount; i++) { + for (i = 0; i < this.nodecount; i++) { int j; - for(j = 0; j < this.nodecount; j++) { - if(j == i) continue; + for (j = 0; j < this.nodecount; j++) { + if (j == i) { continue; } double realDist = getRealNodeDist(this.nodes[i], - this.nodes[j]); + this.nodes[j]); double desDist = getDesiredNodeDist(this.nodes[i], - this.nodes[j]); + this.nodes[j]); // if the desired distance is larger than the existing // distance - if((realDist < desDist) && (realDist != 0)) { + if ((realDist < desDist) && (realDist != 0)) { change = true; // midpoints of both nodes: - double x1 = this.nodes[i].getX() - + (this.nodes[i].getWidth() / 2); - double y1 = this.nodes[i].getY() - + (this.nodes[i].getHeight() / 2); - double x2 = this.nodes[j].getX() - + (this.nodes[j].getWidth() / 2); - double y2 = this.nodes[j].getY() - + (this.nodes[j].getHeight() / 2); + double x1 = this.nodes[i].getX() + + (this.nodes[i].getWidth() / 2); + double y1 = this.nodes[i].getY() + + (this.nodes[i].getHeight() / 2); + double x2 = this.nodes[j].getX() + + (this.nodes[j].getWidth() / 2); + double y2 = this.nodes[j].getY() + + (this.nodes[j].getHeight() / 2); // vector between nodes: double vx = x2 - x1; double vy = y2 - y1; // displacement factor: - double phi = (desDist - realDist) - / Math.sqrt(Math.pow(vx, 2) + Math.pow(vy, 2)); + double phi = (desDist - realDist) + / Math.sqrt(Math.pow(vx, 2) + Math.pow(vy, 2)); // new positions of midpoints: double xf = x2 + (vx * phi) + 1.; double yf = y2 + (vy * phi) + 1.; @@ -1852,18 +1977,18 @@ private void forcePush() { this.nodes[j].setY(newy); Point2D coords = new Point2D.Double(newx, newy); this.layout.setLocation(this.nodes[j], coords); - if(this.debug) { - System.out.println(this.nodes[i].getId() - + " pushed " + this.nodes[j].getId() - + " from (" + x2 + "|" + y2 + ") to (" - + xf + "|" + yf + ")"); - System.out.println("distances before -> real: " - + realDist + "; desired: " + desDist); - System.out.println("distances after -> real: " - + getRealNodeDist(this.nodes[i], - this.nodes[j]) + "; desired: " - + getDesiredNodeDist(this.nodes[i], - this.nodes[j])); + if (this.debug) { + System.out.println(this.nodes[i].getId() + + " pushed " + this.nodes[j].getId() + + " from (" + x2 + "|" + y2 + ") to (" + + xf + "|" + yf + ")"); + System.out.println("distances before -> real: " + + realDist + "; desired: " + desDist); + System.out.println("distances after -> real: " + + getRealNodeDist(this.nodes[i], + this.nodes[j]) + "; desired: " + + getDesiredNodeDist(this.nodes[i], + this.nodes[j])); } } } @@ -1871,25 +1996,29 @@ private void forcePush() { displaceIdents(); } } - + /** * Returns the distance between the center points of two nodes. + * * @param node1 VNode * @param node2 VNode + * * @return double */ private double getRealNodeDist(VNode node1, VNode node2) { - double distx = (node1.getX() + (node1.getWidth() / 2)) - - (node2.getX() + (node2.getWidth() / 2)); - double disty = (node1.getY() + (node1.getHeight() / 2)) - - (node2.getY() + (node2.getHeight() / 2)); + double distx = (node1.getX() + (node1.getWidth() / 2)) + - (node2.getX() + (node2.getWidth() / 2)); + double disty = (node1.getY() + (node1.getHeight() / 2)) + - (node2.getY() + (node2.getHeight() / 2)); return Math.sqrt(Math.pow(distx, 2) + Math.pow(disty, 2)); } /** * Returns the desired distance between the center points of two nodes. + * * @param node1 VNode * @param node2 VNode + * * @return double */ private double getDesiredNodeDist(VNode node1, VNode node2) { @@ -1911,12 +2040,11 @@ private double getDesiredNodeDist(VNode node1, VNode node2) { double ycomp = Math.abs(2 * vy / h1); // determine if vector direction is closer to vertical or horizontal, // relative to the diagonal of the node. - if(xcomp >= ycomp) { + if (xcomp >= ycomp) { // calculate distance between centerpoint and edge of node // horizontal case: f1 = w1 / (Math.cos(Math.atan(vy / vx)) * 2); - } - else { + } else { // calculate distance between centerpoint and edge of node // vertical case: f1 = h1 / (Math.cos(Math.atan(vx / vy)) * 2); @@ -1925,17 +2053,16 @@ private double getDesiredNodeDist(VNode node1, VNode node2) { double f2; xcomp = Math.abs(2 * vx / w2); ycomp = Math.abs(2 * vy / h2); - if(xcomp >= ycomp) { - f2 = w2 / (Math.cos(Math.atan(vy / vx)) * 2); - } - else { + if (xcomp >= ycomp) { + f2 = w2 / (Math.cos(Math.atan(vy / vx)) * 2); + } else { f2 = h2 / (Math.cos(Math.atan(vx / vy)) * 2); } return (f1 + f2) * this.scaling; } - + /** - * Aligns nodes either pairwise to each other or to a global grid, + * Aligns nodes either pairwise to each other or to a global grid, * depending on the alignmentThreshold parameter. */ private void alignNodes() { @@ -1943,17 +2070,19 @@ private void alignNodes() { int j; boolean change; // iterate through all pairs of nodes - if(this.alignmentThreshold <= 0) { - if(this.debug) System.out.println("aligning nodes with similar " - + "coordinates."); - for(i = 0; i < this.nodecount; i++) { + if (this.alignmentThreshold <= 0) { + if (this.debug) { + System.out.println("aligning nodes with similar " + + "coordinates."); + } + for (i = 0; i < this.nodecount; i++) { VNode n1 = this.nodes[i]; double x1 = n1.getX(); double y1 = n1.getY(); double w1 = n1.getWidth(); double h1 = n1.getHeight(); - for(j = 0; j < this.nodecount; j++) { - if(i != j) { + for (j = 0; j < this.nodecount; j++) { + if (i != j) { VNode n2 = this.nodes[j]; double x2 = n2.getX(); double y2 = n2.getY(); @@ -1961,110 +2090,118 @@ private void alignNodes() { double h2 = n2.getHeight(); double threshold; // horizontal alignment - if(x1 != x2) { - threshold = (-1) * this.alignmentThreshold - * (w1 + w2) / 2; + if (x1 != x2) { + threshold = (-1) * this.alignmentThreshold + * (w1 + w2) / 2; change = false; // align by left side - if(Math.abs(x1 - x2) < threshold) { + if (Math.abs(x1 - x2) < threshold) { change = true; n1.setX((x1 + x2) / 2); n2.setX((x1 + x2) / 2); } // align by right side - else if(Math.abs((x1 + w1) - (x2 + w2)) - < threshold) { + else if (Math.abs((x1 + w1) - (x2 + w2)) + < threshold) { change = true; n1.setX(((x1 + w1 + x2 + w2) / 2) - w1); n2.setX(((x1 + w1 + x2 + w2) / 2) - w2); } // align by center - else if(Math.abs((x1 + (w1 / 2)) - (x2 + (w2 / 2))) - < threshold) { + else if (Math.abs((x1 + (w1 / 2)) - (x2 + (w2 / 2))) + < threshold) { change = true; - n1.setX((((2 * x1) + w1 + (2 * x2) + w2) / 4) - - (w1 / 2)); - n2.setX((((2 * x1) + w1 + (2 * x2) + w2) / 4) - - (w2 / 2)); + n1.setX((((2 * x1) + w1 + (2 * x2) + w2) / 4) + - (w1 / 2)); + n2.setX((((2 * x1) + w1 + (2 * x2) + w2) / 4) + - (w2 / 2)); } - if((this.debug) && (change)) { - System.out.println(n1.getId() - + " and " + n2.getId() - + " have been aligned at x coordinate " - + n1.getX()); + if ((this.debug) && (change)) { + System.out.println(n1.getId() + + " and " + n2.getId() + + " have been aligned at x coordinate " + + n1.getX()); } } // vertical alignment - if(y1 != y2) { + if (y1 != y2) { threshold = (h1 + h2) * (this.scaling - 1) / 2; change = false; // align by top side - if(Math.abs(y1 - y2) < threshold) { + if (Math.abs(y1 - y2) < threshold) { change = true; n1.setY((y1 + y2) / 2); n2.setY((y1 + y2) / 2); } // align by bottom side - else if(Math.abs((y1 + h1) - (y2 + h2)) - < threshold) { + else if (Math.abs((y1 + h1) - (y2 + h2)) + < threshold) { change = true; n1.setY(((y1 + h1 + y2 + h2) / 2) - h1); n2.setY(((y1 + h1 + y2 + h2) / 2) - h2); } // align by center - else if(Math.abs((y1 + (h1 / 2)) - (y2 - (h2 / 2))) - < threshold) { + else if (Math.abs((y1 + (h1 / 2)) - (y2 - (h2 / 2))) + < threshold) { change = true; - n1.setY((((2 * y1) + h1 + (2 * y2) + h2) / 4) - - (h1 / 2)); - n2.setY((((2 * y1) + h1 + (2 * y2) + h2) / 4) - - (h2 / 2)); + n1.setY((((2 * y1) + h1 + (2 * y2) + h2) / 4) + - (h1 / 2)); + n2.setY((((2 * y1) + h1 + (2 * y2) + h2) / 4) + - (h2 / 2)); } - if((this.debug) && (change)) { - System.out.println(n1.getId() - + " and " + n2.getId() - + " have been aligned at y coordinate " - + n1.getY()); + if ((this.debug) && (change)) { + System.out.println(n1.getId() + + " and " + n2.getId() + + " have been aligned at y coordinate " + + n1.getY()); } } } } } - } - else { - if(this.debug) System.out.println("aligning nodes on grid of size " + } else { + if (this.debug) { + System.out.println("aligning nodes on grid of size " + this.alignmentThreshold); - for(i = 0; i < this.nodecount; i++) { + } + for (i = 0; i < this.nodecount; i++) { double posX = this.nodes[i].getX(); double posY = this.nodes[i].getY(); // horizontal alignment double pos = Math.rint(posX / this.alignmentThreshold); - if(this.debug) System.out.println((posX + if (this.debug) { + System.out.println((posX / this.alignmentThreshold) + " is rounded: " + pos); + } this.nodes[i].setX(this.alignmentThreshold * pos); // vertical alignment pos = Math.rint(posY / this.alignmentThreshold); - if(this.debug) System.out.println((posY + if (this.debug) { + System.out.println((posY / this.alignmentThreshold) + " is rounded: " + pos); + } this.nodes[i].setY(this.alignmentThreshold * pos); - if(this.debug) System.out.println(this.nodes[i].getId() - + " aligned from (" + posX + "|" + posY + ") to (" - + this.nodes[i].getX() + "|" + this.nodes[i].getY() + if (this.debug) { + System.out.println(this.nodes[i].getId() + + " aligned from (" + posX + "|" + posY + ") to (" + + this.nodes[i].getX() + "|" + this.nodes[i].getY() + ")"); + } } } } - + /** * Returns index of the given node in the nodearray. + * * @param pnode VNode + * * @return Integer */ private Integer getNodeID(VNode pnode) { int i; - for(i = 0; i < this.nodecount; i++) { - if(this.nodes[i].equals(pnode)) - return i; + for (i = 0; i < this.nodecount; i++) { + if (this.nodes[i].equals(pnode)) { return i; } } return -1; } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/ConnectorIOImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/ConnectorIOImpl.java index cdefab12..8ae63aa5 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/ConnectorIOImpl.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/ConnectorIOImpl.java @@ -45,7 +45,6 @@ import javafx.event.EventHandler; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ class ConnectorIOImpl implements Connector { @@ -65,7 +64,7 @@ public ConnectorIOImpl(VNode node, String type, String localId, boolean input, b this.input = input; this.output = output; } - + public ConnectorIOImpl(Connector c) { this(c.getNode(), c.getType(), c.getLocalId(), c.isInput(), c.isOutput()); this.vObj = c.getValueObject(); diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentConnection.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentConnection.java index 79f2aac2..0c6e0555 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentConnection.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentConnection.java @@ -36,16 +36,15 @@ import eu.mihosoft.vrl.workflow.VisualizationRequest; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class PersistentConnection { - + private String id; private String senderId; private String receiverId; private String type; - + private VisualizationRequest vReq; public PersistentConnection() { @@ -58,7 +57,7 @@ public PersistentConnection(String id, String senderId, String receiverId, Strin this.type = type; this.vReq = vReq; } - + /** * @return the id diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentConnector.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentConnector.java index 9061c66d..c6f3f1f0 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentConnector.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentConnector.java @@ -37,12 +37,11 @@ import eu.mihosoft.vrl.workflow.VisualizationRequest; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ -public class PersistentConnector{ +public class PersistentConnector { -// private PersistentNode node; + // private PersistentNode node; private String type; private String localId; private VisualizationRequest vRequest; @@ -55,7 +54,7 @@ public class PersistentConnector{ public PersistentConnector(String type, String localId, boolean input, boolean output, boolean passthru) { this.type = type; this.localId = localId; -// this.node = node; + // this.node = node; this.input = input; this.output = output; this.passthru = passthru; @@ -73,9 +72,9 @@ public void setLocalId(String id) { this.localId = id; } -// public PersistentNode getNode() { -// return this.node; -// } + // public PersistentNode getNode() { + // return this.node; + // } public VisualizationRequest getVisualizationRequest() { @@ -101,12 +100,12 @@ public boolean isOutput() { return output; } -// /** -// * @param node the node to set -// */ -// public void setNode(PersistentNode node) { -// this.node = node; -// } + // /** + // * @param node the node to set + // */ + // public void setNode(PersistentNode node) { + // this.node = node; + // } /** * @return the valueObject @@ -119,7 +118,7 @@ public ValueObject getValueObject() { * @param valueObject the valueObject to set */ public void setValueObject(ValueObject valueObject) { - this.valueObject = valueObject; + this.valueObject = valueObject; } /** diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentFlow.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentFlow.java index 0170d49c..4f6d4e43 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentFlow.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentFlow.java @@ -39,14 +39,13 @@ import java.util.List; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class PersistentFlow extends PersistentNode { private List connections; private List nodes; -// private List connectionTypes; + // private List connectionTypes; private PersistentFlow parent; private boolean visible; @@ -59,13 +58,13 @@ public PersistentFlow(List connections, List connections, List nodes, String title, - double x, double y, double width, double height, - ValueObject valueObject, boolean visible, VisualizationRequest vReq, - List connectors) { + List connections, List nodes, String title, + double x, double y, double width, double height, + ValueObject valueObject, boolean visible, VisualizationRequest vReq, + List connectors) { super(id, title, x, y, width, height, valueObject, vReq, - connectors); + connectors); this.connections = connections; this.nodes = nodes; this.parent = parent; diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentNode.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentNode.java index 07047e86..550a30c2 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentNode.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentNode.java @@ -41,7 +41,6 @@ import java.util.Map; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class PersistentNode { @@ -55,16 +54,16 @@ public class PersistentNode { private VisualizationRequest vReq; private String id; private List connectors; - private Map mainInputs = new HashMap<>(); - private Map mainOutputs = new HashMap<>(); + private Map mainInputs = new HashMap<>(); + private Map mainOutputs = new HashMap<>(); public PersistentNode() { } public PersistentNode(String id, String title, - double x, double y, double width, double height, - ValueObject valueObject, VisualizationRequest vReq, - List connectors) { + double x, double y, double width, double height, + ValueObject valueObject, VisualizationRequest vReq, + List connectors) { this.x = x; this.y = y; @@ -76,8 +75,7 @@ public PersistentNode(String id, String title, this.id = id; this.connectors = WorkflowIO.listToSerializableList(connectors); } - - + /** * @return the x @@ -202,47 +200,47 @@ public List getConnectors() { * @param connectors the inputTypes to set */ public void setConnectors(List connectors) { - + for (PersistentConnector persistentConnector : connectors) { addConnector(persistentConnector); } } - - /** + + /** * @param connector the inputTypes to set */ - public void addConnector(PersistentConnector connector ) { + public void addConnector(PersistentConnector connector) { + + // connector.setNode(this); -// connector.setNode(this); - - connectors.add(connector); + connectors.add(connector); } /** * @return the mainInputs */ - public Map getMainInputs() { + public Map getMainInputs() { return mainInputs; } /** * @param mainInputs the mainInputs to set */ - public void setMainInputs(Map mainInputs) { + public void setMainInputs(Map mainInputs) { this.mainInputs = mainInputs; } /** * @return the mainOutputs */ - public Map getMainOutputs() { + public Map getMainOutputs() { return mainOutputs; } /** * @param mainOutputs the mainOutputs to set */ - public void setMainOutputs(Map mainOutputs) { + public void setMainOutputs(Map mainOutputs) { this.mainOutputs = mainOutputs; } } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentValueObject.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentValueObject.java index ef84c6d1..2dbd55fe 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentValueObject.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/PersistentValueObject.java @@ -45,7 +45,6 @@ /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class PersistentValueObject { diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/WorkflowIO.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/WorkflowIO.java index 93679401..9219783c 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/WorkflowIO.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/io/WorkflowIO.java @@ -37,9 +37,9 @@ import eu.mihosoft.vrl.workflow.Connector; import eu.mihosoft.vrl.workflow.DefaultValueObject; import eu.mihosoft.vrl.workflow.FlowFactory; +import eu.mihosoft.vrl.workflow.IOConnector; import eu.mihosoft.vrl.workflow.IdGenerator; import eu.mihosoft.vrl.workflow.NodeLookupImpl; -import eu.mihosoft.vrl.workflow.IOConnector; import eu.mihosoft.vrl.workflow.ThruConnector; import eu.mihosoft.vrl.workflow.ThruConnectorImpl; import eu.mihosoft.vrl.workflow.VConnections; @@ -60,71 +60,70 @@ import java.util.Map; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class WorkflowIO { - + public static VFlow loadFromXML(Path p) throws IOException { VFlow workflow = FlowFactory.newFlow(); - + VFlowModel flow = WorkflowIO.loadFromXML(p, workflow.getIdGenerator()); workflow.setNodeLookup(flow.getNodeLookup()); workflow.setModel(flow); - + return workflow; } - + public static VFlowModel loadFromXML(String xml, IdGenerator generator) { XStream xstream = new XStream(); - + configureStream(xstream); - + return flowFromPersistentFlow((PersistentFlow) xstream.fromXML(xml), generator); } - + public static VFlow loadFromXML(String xml) { VFlow workflow = FlowFactory.newFlow(); - + VFlowModel flow = WorkflowIO.loadFromXML(xml, workflow.getIdGenerator()); workflow.setNodeLookup(flow.getNodeLookup()); workflow.setModel(flow); - + return workflow; } - + public static VFlow loadFromXML(InputStream xmlStream) { VFlow workflow = FlowFactory.newFlow(); - + VFlowModel flow = WorkflowIO.loadFromXML(xmlStream, workflow.getIdGenerator()); workflow.setNodeLookup(flow.getNodeLookup()); workflow.setModel(flow); - + return workflow; } - + public static VFlowModel loadFromXML(Path p, IdGenerator generator) throws IOException { - + XStream xstream = new XStream(); - + configureStream(xstream); - + InputStream is = Files.newInputStream(p, StandardOpenOption.READ); - + PersistentFlow pFlow = (PersistentFlow) xstream.fromXML(is); - + return flowFromPersistentFlow(pFlow, generator); } - + public static VFlowModel loadFromXML(InputStream xmlStream, IdGenerator generator) { - + XStream xstream = new XStream(); - + configureStream(xstream); - + return flowFromPersistentFlow((PersistentFlow) xstream.fromXML(xmlStream), generator); } - + private static void configureStream(XStream xstream) { xstream.alias("flow", PersistentFlow.class); xstream.alias("node", PersistentNode.class); @@ -132,165 +131,165 @@ private static void configureStream(XStream xstream) { xstream.alias("vobj", PersistentValueObject.class); xstream.alias("connector", PersistentConnector.class); -// xstream.setMode(XStream.ID_REFERENCES); + // xstream.setMode(XStream.ID_REFERENCES); } - + public static void saveToXML(Path p, VFlowModel flow) throws IOException { - + OutputStream os = Files.newOutputStream(p, - StandardOpenOption.CREATE, - StandardOpenOption.WRITE, - StandardOpenOption.TRUNCATE_EXISTING); - + StandardOpenOption.CREATE, + StandardOpenOption.WRITE, + StandardOpenOption.TRUNCATE_EXISTING); + saveToXML(flow, os); } - + public static void saveToXML(VFlowModel flow, OutputStream xmlStream) { XStream xstream = new XStream(); - + configureStream(xstream); - + xstream.toXML(toPersistentNode(flow, null), xmlStream); } - + public static String saveToXML(VFlowModel flow) { XStream xstream = new XStream(); - + configureStream(xstream); - + String xml = xstream.toXML(toPersistentNode(flow, null)); - + return xml; } - + public static PersistentNode toPersistentNode(VNode node, PersistentFlow parent) { - + if (node instanceof VFlowModel) { - + VFlowModel flow = (VFlowModel) node; - + List connectionList = new ArrayList<>(); - + for (eu.mihosoft.vrl.workflow.Connections connections : flow.getAllConnections().values()) { for (eu.mihosoft.vrl.workflow.Connection c : connections.getConnections()) { connectionList.add( - new PersistentConnection(c.getId(), - c.getSender().getId(), - c.getReceiver().getId(), - c.getType(), - c.getVisualizationRequest())); + new PersistentConnection(c.getId(), + c.getSender().getId(), + c.getReceiver().getId(), + c.getType(), + c.getVisualizationRequest())); } } - + List nodeList = new ArrayList<>(); - + List connectionTypes = new ArrayList<>(); - + connectionTypes.addAll(flow.getAllConnections().keySet()); - + PersistentFlow pFlow = new PersistentFlow(parent, - node.getId(), - connectionList, - nodeList, - node.getTitle(), - node.getX(), - node.getY(), - node.getWidth(), - node.getHeight(), - node.getValueObject(), - flow.isVisible(), - node.getVisualizationRequest(), - new ArrayList()); - + node.getId(), + connectionList, + nodeList, + node.getTitle(), + node.getX(), + node.getY(), + node.getWidth(), + node.getHeight(), + node.getValueObject(), + flow.isVisible(), + node.getVisualizationRequest(), + new ArrayList()); + for (Connector c : node.getConnectors()) { pFlow.addConnector(toPersistentConnector(c)); } - + for (String mainType : node.getMainInputTypes()) { pFlow.getMainInputs().put(mainType, node.getMainInput(mainType).getLocalId()); } - + for (String mainType : node.getMainOutputTypes()) { pFlow.getMainOutputs().put(mainType, node.getMainOutput(mainType).getLocalId()); } - + for (VNode n : flow.getNodes()) { nodeList.add(toPersistentNode(n, pFlow)); } - + return pFlow; } else { PersistentNode pNode = new PersistentNode(node.getId(), - node.getTitle(), - node.getX(), - node.getY(), - node.getWidth(), - node.getHeight(), - node.getValueObject(), - node.getVisualizationRequest(), - new ArrayList()); - + node.getTitle(), + node.getX(), + node.getY(), + node.getWidth(), + node.getHeight(), + node.getValueObject(), + node.getVisualizationRequest(), + new ArrayList()); + for (Connector c : node.getConnectors()) { pNode.addConnector(toPersistentConnector(c)); } - + for (String mainType : node.getMainInputTypes()) { pNode.getMainInputs().put(mainType, node.getMainInput(mainType).getLocalId()); } - + for (String mainType : node.getMainOutputTypes()) { pNode.getMainOutputs().put(mainType, node.getMainOutput(mainType).getLocalId()); } - + return pNode; } } - + public static VFlowModel flowFromPersistentFlow( - PersistentFlow flow, IdGenerator generator) { - + PersistentFlow flow, IdGenerator generator) { + VFlowModel flowModel = createFlowFromPersistent(flow, null, generator); - + addConnectionsFromPersistentFlow(flow, flowModel, generator); - + return flowModel; } - + private static void addConnectionsFromPersistentFlow(PersistentFlow flow, VFlowModel flowModel, IdGenerator generator) { - + Map> flowConnections = new HashMap<>(); - + for (PersistentConnection c : flow.getConnections()) { List connectionsOfType = flowConnections.get(c.getType()); - + if (connectionsOfType == null) { connectionsOfType = new ArrayList<>(); flowConnections.put(c.getType(), connectionsOfType); } connectionsOfType.add(c); } - + for (String type : flowConnections.keySet()) { List connections = flowConnections.get(type); if (!connections.isEmpty()) { flowModel.addConnections(fromPersistentConnections(type, connections, flowModel), type); } } - + for (PersistentNode pn : flow.getNodes()) { VNode fn = flowModel.getNodeLookup().getById(pn.getId()); - + if (fn instanceof VFlowModel && pn instanceof PersistentFlow) { addConnectionsFromPersistentFlow((PersistentFlow) pn, (VFlowModel) fn, generator); } } } - + private static VFlowModel createFlowFromPersistent( - PersistentFlow flow, VFlowModel parent, IdGenerator generator) { - + PersistentFlow flow, VFlowModel parent, IdGenerator generator) { + VFlowModel result; - + if (parent == null) { result = FlowFactory.newFlowModel(); result.setIdGenerator(generator); @@ -298,7 +297,7 @@ private static VFlowModel createFlowFromPersistent( } else { result = parent.newFlowNode(); } - + result.setId(flow.getId()); generator.addId(flow.getId()); result.setTitle(flow.getTitle()); @@ -309,47 +308,47 @@ private static VFlowModel createFlowFromPersistent( result.setValueObject(toValueObject(result, flow.getValueObject())); result.setVisible(flow.isVisible()); result.setVisualizationRequest(flow.getVReq()); - + for (PersistentNode n : flow.getNodes()) { addFlowNode(result, n, generator); } - + for (PersistentConnector connector : flow.getConnectors()) { result.addConnector(fromPersistentConnector(connector, result)); } - + for (String type : flow.getMainInputs().keySet()) { result.setMainInput(result.getConnector(flow.getMainInputs().get(type))); } - + for (String type : flow.getMainOutputs().keySet()) { result.setMainOutput(result.getConnector(flow.getMainOutputs().get(type))); } -// -// Map> flowConnections = new HashMap<>(); -// -// for (PersistentConnection c : flow.getConnections()) { -// List connectionsOfType = flowConnections.get(c.getType()); -// -// if (connectionsOfType == null) { -// connectionsOfType = new ArrayList<>(); -// flowConnections.put(c.getType(), connectionsOfType); -// } -// connectionsOfType.add(c); -// } -// -// for (String type : flowConnections.keySet()) { -// List connections = flowConnections.get(type); -// if (!connections.isEmpty()) { -// result.addConnections(fromPersistentConnections(type, connections, result), type); -// } -// } + // + // Map> flowConnections = new HashMap<>(); + // + // for (PersistentConnection c : flow.getConnections()) { + // List connectionsOfType = flowConnections.get(c.getType()); + // + // if (connectionsOfType == null) { + // connectionsOfType = new ArrayList<>(); + // flowConnections.put(c.getType(), connectionsOfType); + // } + // connectionsOfType.add(c); + // } + // + // for (String type : flowConnections.keySet()) { + // List connections = flowConnections.get(type); + // if (!connections.isEmpty()) { + // result.addConnections(fromPersistentConnections(type, connections, result), type); + // } + // } return result; } - + private static void addFlowNode(VFlowModel flow, PersistentNode node, IdGenerator generator) { - + if (node instanceof PersistentFlow) { createFlowFromPersistent((PersistentFlow) node, flow, generator); } else { @@ -363,64 +362,64 @@ private static void addFlowNode(VFlowModel flow, PersistentNode node, IdGenerato result.setHeight(node.getHeight()); result.setValueObject(toValueObject(result, node.getValueObject())); result.setVisualizationRequest(node.getVReq()); - + for (PersistentConnector c : node.getConnectors()) { result.addConnector(fromPersistentConnector(c, result)); } } } -// public static PersistentConnection toPersistentConnection(eu.mihosoft.vrl.workflow.Connection c) { -// return new PersistentConnection(c.getId(), c.getSenderId(), c.getReceiverId(), c.getType(), c.getVisualizationRequest()); -// } + // public static PersistentConnection toPersistentConnection(eu.mihosoft.vrl.workflow.Connection c) { + // return new PersistentConnection(c.getId(), c.getSenderId(), c.getReceiverId(), c.getType(), c.getVisualizationRequest()); + // } public static eu.mihosoft.vrl.workflow.Connections fromPersistentConnections(String connectionType, List connections, VFlowModel flow) { eu.mihosoft.vrl.workflow.Connections result = VConnections.newConnections(connectionType); - + for (PersistentConnection c : connections) { Connector s = flow.getNodeLookup().getConnectorById(c.getSenderId()); Connector r = flow.getNodeLookup().getConnectorById(c.getReceiverId()); result.add(c.getId(), s, r, c.getVReq()); } - + return result; } - + public static List listToSerializableList(List input) { List result = new ArrayList<>(); result.addAll(input); return result; } - + public static Connector fromPersistentConnector(PersistentConnector pC, VNode n) { -// ConnectorIOImpl result -// = new ConnectorImpl(n, c.getType(), c.getLocalId(), c.isInput(), c.isOutput()); -// + // ConnectorIOImpl result + // = new ConnectorImpl(n, c.getType(), c.getLocalId(), c.isInput(), c.isOutput()); + // Connector c; if (pC.isPassthru()) { - + VFlowModel flowModel = (VFlowModel) n; - + if (pC.isInput()) { VNode innerNode = flowModel.newNode(); Connector innerConnector = innerNode.setMainInput( - innerNode.addInput(pC.getType())); + innerNode.addInput(pC.getType())); c = new ThruConnectorImpl(n, pC.getType(), - pC.getLocalId(), true, innerNode, innerConnector); + pC.getLocalId(), true, innerNode, innerConnector); } else { VNode innerNode = flowModel.newNode(); Connector innerConnector = innerNode.setMainOutput( - innerNode.addOutput(pC.getType())); + innerNode.addOutput(pC.getType())); c = new ThruConnectorImpl(n, pC.getType(), - pC.getLocalId(), false, innerNode, innerConnector); + pC.getLocalId(), false, innerNode, innerConnector); } - + } else { c = new IOConnector(n, pC.getType(), pC.getLocalId(), pC.isInput()); } - + c.setMaxNumberOfConnections(pC.getMaxNumConnections()); - + return c; } @@ -432,34 +431,35 @@ public static Connector fromPersistentConnector(PersistentConnector pC, VNode n) * referenced. * * @param c connector to convert + * * @return the equivalent persistent connector to the specified connector */ public static PersistentConnector toPersistentConnector(Connector c) { PersistentConnector pC = new PersistentConnector( - c.getType(), c.getLocalId(), c.isInput(), - c.isOutput(), c instanceof ThruConnector); - + c.getType(), c.getLocalId(), c.isInput(), + c.isOutput(), c instanceof ThruConnector); + pC.setMaxNumConnections(c.getMaxNumberOfConnections()); - + return pC; } - + public static PersistentValueObject toPersistentValueObject(ValueObject vObj) { return new PersistentValueObject(vObj.getParent().getId(), vObj.getValue(), vObj.getVisualizationRequest()); } - + public static ValueObject toValueObject(VNode node, PersistentValueObject vObj) { ValueObject result = new DefaultValueObject(); - + result.setParent(node); result.setValue(vObj.getValue()); - + for (String key : vObj.getStorage().keySet()) { result.getVisualizationRequest().set( - key, vObj.getStorage().get(key)); - } - + key, vObj.getStorage().get(key)); + } + return result; } - + } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/ConnectionSkinFactory.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/ConnectionSkinFactory.java index 0005e7bc..3db31c98 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/ConnectionSkinFactory.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/ConnectionSkinFactory.java @@ -38,18 +38,22 @@ /** * Connection skin factory. - * @author Michael Hoffer <info@michaelhoffer.de> + * * @param connection model type + * + * @author Michael Hoffer <info@michaelhoffer.de> */ public interface ConnectionSkinFactory { /** * Creates a skin for the specified connection. - * @param c connection that shall be skinned + * + * @param c connection that shall be skinned * @param flow parent flow controller * @param type connection type + * * @return connection skin */ ConnectionSkin createSkin(Connection c, VFlow flow, String type); - + } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/Constants.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/Constants.java index 01b94ca3..68a3d69f 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/Constants.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/Constants.java @@ -36,9 +36,14 @@ /** * This class defines constants used library. It is currently used to wrap * the default CSS. + * * @author Michael Hoffer <info@michaelhoffer.de> */ -public class Constants { - public static final String DEFAULT_STYLE = - "/eu/mihosoft/vrl/fxconnections/resources/default.css"; +public final class Constants { + private Constants() { + // prevent instantiation + } + + public static final String DEFAULT_STYLE = + "/eu/mihosoft/vrl/fxconnections/resources/default.css"; } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/FlowNodeSkinLookup.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/FlowNodeSkinLookup.java index f11836a7..15463397 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/FlowNodeSkinLookup.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/FlowNodeSkinLookup.java @@ -49,19 +49,21 @@ public interface FlowNodeSkinLookup extends Lookup> { * Returns the skin of the specified node. * * @param skinFactory skin factory to search - * @param globalId global id of the requested node + * @param globalId global id of the requested node + * * @return the skin of the specified node or null if no such * skin exists */ - public VNodeSkin getById(SkinFactory skinFactory, String globalId); + VNodeSkin getById(SkinFactory skinFactory, String globalId); /** * Returns the skin of the specified connection. * * @param skinFactory skin factory to search - * @param c global id of the requested node + * @param c global id of the requested node + * * @return the skin of the specified connection or null if no * such skin exists */ - public ConnectionSkin getById(SkinFactory skinFactory, Connection c); + ConnectionSkin getById(SkinFactory skinFactory, Connection c); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/Skin.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/Skin.java index 05377776..99e0fb29 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/Skin.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/Skin.java @@ -39,49 +39,61 @@ /** * A skin is a toolkit independent visual representation of a model. - * - * @author Michael Hoffer <info@michaelhoffer.de> + * * @param model type that shall be skinned + * + * @author Michael Hoffer <info@michaelhoffer.de> */ public interface Skin { /** * Adds this skin to its view parent. */ - public void add(); + void add(); + /** * Removes this skin from its view parent. */ - public void remove(); + void remove(); + /** * Defines the model that shall be represented by this skin. + * * @param model model to set */ - public void setModel(T model); + void setModel(T model); + /** * Returns the model represented by this skin. + * * @return model represented by this skin */ - public T getModel(); + T getModel(); + /** * Returns the property the model represented by this skin. + * * @return model represented by this skin */ - public ObjectProperty modelProperty(); + ObjectProperty modelProperty(); + /** * Returns the flow controller that is used to manipulate the model. + * * @return the flow controller that is used to manipulate the model */ - public VFlow getController(); - + VFlow getController(); + /** * Defines the flow controller that shall be used to manipulate the model. + * * @param flow flow controller to set */ - public void setController(VFlow flow); - + void setController(VFlow flow); + /** * Returns the skin factory that created this skin. + * * @return the skin factory that created this skin */ - public SkinFactory getSkinFactory(); + SkinFactory getSkinFactory(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/SkinFactory.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/SkinFactory.java index f6819003..e1b5be54 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/SkinFactory.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/SkinFactory.java @@ -38,9 +38,10 @@ * used by the corresponding flow controller {@link eu.mihosoft.vrl.workflow.VFlow#setSkinFactories(eu.mihosoft.vrl.workflow.skin.SkinFactory...) * }. * - * @author Michael Hoffer <info@michaelhoffer.de> * @param Connection skin type * @param Node skin type + * + * @author Michael Hoffer <info@michaelhoffer.de> */ public interface SkinFactory extends ConnectionSkinFactory, VNodeSkinFactory { @@ -49,6 +50,7 @@ public interface SkinFactory extends ConnectionS * of the model. * * @param parent parent skin + * * @return child skin factory */ SkinFactory createChild(Skin parent); @@ -59,6 +61,5 @@ public interface SkinFactory extends ConnectionS * @return parent skin factory or null if no such skin factory * exists */ - public SkinFactory getParent(); - + SkinFactory getParent(); } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/VNodeSkin.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/VNodeSkin.java index 5d2a556a..c8bbc263 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/VNodeSkin.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/VNodeSkin.java @@ -37,9 +37,10 @@ /** * Node skin. - * - * @author Michael Hoffer <info@michaelhoffer.de> + * * @param node model type + * + * @author Michael Hoffer <info@michaelhoffer.de> */ public interface VNodeSkin extends Skin { diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/VNodeSkinFactory.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/VNodeSkinFactory.java index 89c1666e..8a42d216 100644 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/VNodeSkinFactory.java +++ b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/VNodeSkinFactory.java @@ -38,18 +38,20 @@ /** * Node skin factory. - * @author Michael Hoffer <info@michaelhoffer.de> + * * @param node skin type + * + * @author Michael Hoffer <info@michaelhoffer.de> */ public interface VNodeSkinFactory { /** * Creates a node skin. - * @param n node that shall be skinned + * + * @param n node that shall be skinned * @param controller flow controller + * * @return requested node skin */ VNodeSkin createSkin(VNode n, VFlow controller); - - } diff --git a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectionEventTest.java b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectionEventTest.java index 82256cbc..4a6b1e25 100644 --- a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectionEventTest.java +++ b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectionEventTest.java @@ -41,10 +41,10 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import static org.junit.Assert.*; + +import static org.junit.Assert.assertTrue; /** - * * @author Michael Hoffer */ public class ConnectionEventTest { @@ -87,7 +87,7 @@ public void connectNodes() { class CountingListener implements EventHandler { private int counter = 0; - + private EventType lastEventType; @Override @@ -114,27 +114,27 @@ private void reset() { ConnectionResult resultInput = flow.connect(n1, n2, "control"); assertTrue("Connection must be valid", resultInput.getStatus().isCompatible()); // add event has been fired once - assertTrue("Add-Event must be fired exactly once!", - countingListenerInput.getCounter() == 1 && countingListenerInput.lastEventType == ConnectionEvent.ADD); + assertTrue("Add-Event must be fired exactly once!", + countingListenerInput.getCounter() == 1 && countingListenerInput.lastEventType == ConnectionEvent.ADD); // remove the connection resultInput.getConnection().getConnections().remove(resultInput.getConnection()); // remove event has been fired once assertTrue("Remove-Event must be fired exactly once!", - countingListenerInput.getCounter() == 2 && countingListenerInput.lastEventType == ConnectionEvent.REMOVE); - + countingListenerInput.getCounter() == 2 && countingListenerInput.lastEventType == ConnectionEvent.REMOVE); + // create test for output CountingListener countingListenerOutput = new CountingListener(); sender1.addConnectionEventListener(countingListenerOutput); ConnectionResult resultOutput = flow.connect(n1, n2, "control"); assertTrue("Connection must be valid", resultOutput.getStatus().isCompatible()); // add event has been fired once - assertTrue("Add-Event must be fired exactly once!", - countingListenerOutput.getCounter() == 1 && countingListenerOutput.lastEventType == ConnectionEvent.ADD); + assertTrue("Add-Event must be fired exactly once!", + countingListenerOutput.getCounter() == 1 && countingListenerOutput.lastEventType == ConnectionEvent.ADD); // remove the connection resultOutput.getConnection().getConnections().remove(resultOutput.getConnection()); // remove event has been fired once assertTrue("Remove-Event must be fired exactly once!", - countingListenerOutput.getCounter() == 2 && countingListenerOutput.lastEventType == ConnectionEvent.REMOVE); + countingListenerOutput.getCounter() == 2 && countingListenerOutput.lastEventType == ConnectionEvent.REMOVE); } } diff --git a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectionImplClassTest.java b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectionImplClassTest.java index 23e329fa..a544a822 100644 --- a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectionImplClassTest.java +++ b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectionImplClassTest.java @@ -37,7 +37,6 @@ import org.junit.Test; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class ConnectionImplClassTest { @@ -45,27 +44,30 @@ public class ConnectionImplClassTest { @Test public void testImplClassWithConformingConstructor() { VFlow flow = FlowFactory.newFlow(); - + flow.getConnections("mytype").setConnectionClass(ConnectionBase.class); } public void testImplClassWithNonConformingConstructor() { VFlow flow = FlowFactory.newFlow(); - + boolean exceptionThrown = false; - - try{ + + try { flow.getConnections("mytype").setConnectionClass( ConnectionBaseWithoutConformingConstructor.class); - } catch(IllegalArgumentException ex) { + } catch (IllegalArgumentException ex) { exceptionThrown = true; } - + Assert.assertTrue("IllegalArgumentException must be thrown!", exceptionThrown); } } class ConnectionBaseWithoutConformingConstructor extends ConnectionBase { // - private ConnectionBaseWithoutConformingConstructor() {}; + private ConnectionBaseWithoutConformingConstructor() { + } + + ; } diff --git a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectorTest.java b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectorTest.java index e317e7d8..2d074bcb 100644 --- a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectorTest.java +++ b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/ConnectorTest.java @@ -37,7 +37,6 @@ import org.junit.Test; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class ConnectorTest { @@ -45,40 +44,40 @@ public class ConnectorTest { @Test public void maxNumberOfConnectionsTest() { VFlow flow = FlowFactory.newFlow(); - + VNode sender = flow.newNode(); VNode receiver = flow.newNode(); - + Connector senderOut = sender.addOutput("mytype"); Connector receiverIn = receiver.addInput("mytype"); - + int maxConn = 1; - + senderOut.setMaxNumberOfConnections(maxConn); receiverIn.setMaxNumberOfConnections(maxConn); - + int senderMax = senderOut.getMaxNumberOfConnections(); - + Assert.assertTrue("Sender: expected max number of connections = " - + maxConn + ", got " + senderMax, maxConn == senderMax); - + + maxConn + ", got " + senderMax, maxConn == senderMax); + int receiverMax = receiverIn.getMaxNumberOfConnections(); - + Assert.assertTrue("Receiver: expected max number of connections = " - + maxConn + ", got " + receiverMax, maxConn == receiverMax); - + + maxConn + ", got " + receiverMax, maxConn == receiverMax); + ConnectionResult result = flow.connect(senderOut, receiverIn); - + Assert.assertTrue("Connection must be established. Connection-Msg: " + result.getStatus().getMessage(), - result.getStatus().isCompatible()); - + result.getStatus().isCompatible()); + ConnectionResult result2 = flow.connect(senderOut, receiverIn); - + Assert.assertTrue("Connection must not be established as the max " + "number of connections is already reached.", - !result2.getStatus().isCompatible()); - - + !result2.getStatus().isCompatible()); + + } } diff --git a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/FlowUtil.java b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/FlowUtil.java index f5372629..eb4ba374 100644 --- a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/FlowUtil.java +++ b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/FlowUtil.java @@ -42,7 +42,6 @@ import java.util.List; /** - * * @author Michael Hoffer */ public class FlowUtil { @@ -51,8 +50,8 @@ public class FlowUtil { * Creates a flow with specified width and depth. * * @param workflow parent workflow - * @param depth flow depth (number of nested nodes) - * @param width flow width (number of nodes per layer) + * @param depth flow depth (number of nested nodes) + * @param width flow width (number of nodes per layer) */ public static void createFlow(VFlow workflow, int depth, int width) { @@ -107,7 +106,7 @@ public static void createFlow(VFlow workflow, int depth, int width) { if (i >= connectionTypes.length) { workflow.connect(prevNodes.get(0).getOutputs().get(0), - n.getInputs().get(0)); + n.getInputs().get(0)); prevNodes.remove(0); } diff --git a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/SkinTest.java b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/SkinTest.java index 2da786c2..91e61185 100644 --- a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/SkinTest.java +++ b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/SkinTest.java @@ -37,16 +37,16 @@ import eu.mihosoft.vrl.workflow.skin.Skin; import eu.mihosoft.vrl.workflow.skin.SkinFactory; import eu.mihosoft.vrl.workflow.skin.VNodeSkin; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import org.junit.Assert; import org.junit.Test; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class SkinTest { @@ -61,18 +61,18 @@ public void nodeSkinTest() { VNode n1 = flow.newNode(); Assert.assertTrue("Skin for n1 must be present.", - skinFactory.getNodeSkins().get(n1) != null); + skinFactory.getNodeSkins().get(n1) != null); Assert.assertTrue("Skin must be skin of n1.", - skinFactory.getNodeSkins().get(n1).getModel() == n1); + skinFactory.getNodeSkins().get(n1).getModel() == n1); VFlow sf1 = flow.newSubFlow(); Assert.assertTrue("Skin for sf1 must be present.", - skinFactory.getNodeSkins().get(sf1.getModel()) != null); + skinFactory.getNodeSkins().get(sf1.getModel()) != null); Optional sfSkinFactry - = skinFactory.getChildFactories().values().stream().findFirst(); + = skinFactory.getChildFactories().values().stream().findFirst(); Assert.assertTrue("Child factory must exist.", sfSkinFactry.isPresent()); @@ -80,10 +80,10 @@ public void nodeSkinTest() { sf1.setVisible(true); Assert.assertTrue("Skin for sn1 must be present.", - sfSkinFactry.get().getNodeSkins().get(sn1) != null); + sfSkinFactry.get().getNodeSkins().get(sn1) != null); Assert.assertTrue("Skin must be skin of n1.", - sfSkinFactry.get().getNodeSkins().get(sn1).getModel() == sn1); + sfSkinFactry.get().getNodeSkins().get(sn1).getModel() == sn1); } @@ -97,13 +97,13 @@ public void nodeSkinLookupTest() { VNode n1 = flow.newNode(); VNodeSkin lookupN1 = flow.getNodeSkinLookup(). - getById(skinFactory, n1.getId()); + getById(skinFactory, n1.getId()); Assert.assertTrue("Skin for n1 must be present.", - lookupN1 != null); + lookupN1 != null); Assert.assertTrue("Skin must be skin of n1.", - lookupN1.getModel() == n1); + lookupN1.getModel() == n1); } @Test @@ -117,30 +117,30 @@ public void nodeSkinLookupRemovalTest() { VNode n2 = flow.newNode(); VNodeSkin lookupN1 = flow.getNodeSkinLookup(). - getById(skinFactory, n1.getId()); + getById(skinFactory, n1.getId()); VNodeSkin lookupN2 = flow.getNodeSkinLookup(). - getById(skinFactory, n2.getId()); + getById(skinFactory, n2.getId()); Assert.assertTrue("Skin for n1 must be present.", - lookupN1 != null); + lookupN1 != null); Assert.assertTrue("Skin must be skin of n1.", - lookupN1.getModel() == n1); + lookupN1.getModel() == n1); Assert.assertTrue("Skin for n2 must be present.", - lookupN2 != null); + lookupN2 != null); Assert.assertTrue("Skin must be skin of n2.", - lookupN2.getModel() == n2); + lookupN2.getModel() == n2); flow.remove(n2); VNodeSkin lookupN2AfterRemoval = flow.getNodeSkinLookup(). - getById(skinFactory, n2.getId()); + getById(skinFactory, n2.getId()); Assert.assertTrue("Skin for n2 must be removed after node removal.", - lookupN2AfterRemoval == null); + lookupN2AfterRemoval == null); } @@ -155,37 +155,37 @@ public void nodeSkinRemoveSubFlowTest() { sf.setVisible(true); VNodeSkin lookupN1 = flow.getNodeSkinLookup(). - getById(skinFactory, sf.getModel().getId()); + getById(skinFactory, sf.getModel().getId()); Assert.assertTrue("Skin for sf must be present.", - lookupN1 != null); + lookupN1 != null); Assert.assertTrue("Skin must be skin of n1.", - lookupN1.getModel() == sf.getModel()); + lookupN1.getModel() == sf.getModel()); VNode n1 = sf.newNode(); VFlow sf1 = sf.newSubFlow(); boolean n1IsChildNode = sf.getNodes().stream().filter(n -> n == n1). - findFirst().isPresent(); + findFirst().isPresent(); boolean sf1IsChildNode = sf.getNodes().stream().filter(n -> sf1.getModel() == n). - findFirst().isPresent(); + findFirst().isPresent(); Assert.assertTrue("n1 must be child of sf", - n1IsChildNode); + n1IsChildNode); Assert.assertTrue("sf1 must be child of sf", - sf1IsChildNode); - -// flow.remove(sf.getModel()); -// -// VNodeSkinFactoryStub skinFactoryOfSF = (VNodeSkinFactoryStub) -// sf.getSkinFactories().iterator().next(); -// -// skinFactoryOfSF.getNodeSkins().values().forEach(ns -> { -// System.out.println("ns: " + ns.getModel().getId()); -// }); + sf1IsChildNode); + + // flow.remove(sf.getModel()); + // + // VNodeSkinFactoryStub skinFactoryOfSF = (VNodeSkinFactoryStub) + // sf.getSkinFactories().iterator().next(); + // + // skinFactoryOfSF.getNodeSkins().values().forEach(ns -> { + // System.out.println("ns: " + ns.getModel().getId()); + // }); } @Test @@ -203,13 +203,13 @@ public void connectionSkinLookupTest() { Connection connection = flow.connect(s, r).getConnection(); ConnectionSkin lookupC1 = flow.getNodeSkinLookup(). - getById(skinFactory, connection); + getById(skinFactory, connection); Assert.assertTrue("Skin for connection must be present.", - lookupC1 != null); + lookupC1 != null); Assert.assertTrue("Skin must be skin of connection.", - lookupC1.getModel() == connection); + lookupC1.getModel() == connection); } @Test @@ -229,33 +229,33 @@ public void connectionSkinRemovalLookupTest() { Connection connection2 = flow.connect(s1, r2).getConnection(); ConnectionSkin lookupC1 = flow.getNodeSkinLookup(). - getById(skinFactory, connection1); + getById(skinFactory, connection1); Assert.assertTrue("Skin for connection must be present.", - lookupC1 != null); + lookupC1 != null); Assert.assertTrue("Skin must be skin of connection.", - lookupC1.getModel() == connection1); + lookupC1.getModel() == connection1); ConnectionSkinStub lookupC2 = (ConnectionSkinStub) flow.getNodeSkinLookup(). - getById(skinFactory, connection2); + getById(skinFactory, connection2); Assert.assertTrue("Skin for connection must be present.", - lookupC2 != null); + lookupC2 != null); Assert.assertTrue("Skin must be skin of connection.", - lookupC2.getModel() == connection2); + lookupC2.getModel() == connection2); flow.getConnections("mytype").remove(connection2); Assert.assertTrue("Skin has to be removed after connection removal.", - lookupC2.isRemoved()); + lookupC2.isRemoved()); ConnectionSkinStub lookupC2AfterRemoval = (ConnectionSkinStub) flow.getNodeSkinLookup(). - getById(skinFactory, connection2); + getById(skinFactory, connection2); Assert.assertTrue("Skin has to be removed after connection removal.", - lookupC2AfterRemoval == null); + lookupC2AfterRemoval == null); } } diff --git a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowDiffTest.java b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowDiffTest.java index 0d60c1c7..de79c4e6 100644 --- a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowDiffTest.java +++ b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowDiffTest.java @@ -49,7 +49,6 @@ import java.util.logging.Logger; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class VFlowDiffTest { @@ -57,11 +56,11 @@ public class VFlowDiffTest { @Test public void testSimpleDiff() { VFlow flow = createFlow(10, 5, 3, "control", "data", "event"); - -// VFlow flow = FlowFactory.newFlow(); -// -// FlowUtil.createFlow(flow, 5, 5); - + + // VFlow flow = FlowFactory.newFlow(); + // + // FlowUtil.createFlow(flow, 5, 5); + try { WorkflowIO.saveToXML(Paths.get("flow01.xml"), flow.getModel()); } catch (IOException ex) { @@ -79,8 +78,8 @@ private VFlow createFlow(int maxWidth, int depth, int maxNumConnectors, String.. for (VFlow flow : flows) { VNode prevNode = null; for (int w = 0; - w < Math.random() * (maxWidth / flows.size()) + 1; - w++) { + w < Math.random() * (maxWidth / flows.size()) + 1; + w++) { VNode n; if (Math.random() < 0.5) { @@ -95,8 +94,8 @@ private VFlow createFlow(int maxWidth, int depth, int maxNumConnectors, String.. for (String type : types) { for (int i = 0; - i < Math.random() * maxNumConnectors + 1; - i++) { + i < Math.random() * maxNumConnectors + 1; + i++) { n.addInput(type); n.addOutput(type); } @@ -106,14 +105,14 @@ private VFlow createFlow(int maxWidth, int depth, int maxNumConnectors, String.. if (prevNode != null) { List outputs - = prevNode.getOutputs(). - filtered(conn -> conn.getType(). - equals(type)); + = prevNode.getOutputs(). + filtered(conn -> conn.getType(). + equals(type)); List inputs - = n.getInputs(). - filtered(conn -> conn.getType(). - equals(type)); + = n.getInputs(). + filtered(conn -> conn.getType(). + equals(type)); for (Connector o : outputs) { for (Connector i : inputs) { diff --git a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowIOTest.java b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowIOTest.java index 0cd15fd0..a08d40f8 100644 --- a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowIOTest.java +++ b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowIOTest.java @@ -56,7 +56,6 @@ import static org.junit.Assert.assertTrue; /** - * * @author Michael Hoffer */ public class VFlowIOTest { @@ -167,7 +166,7 @@ public void saveAndLoadFlowString() { // compare both flows (samples) compare(flow1, flow2); } - + @Test public void saveAndLoadFlowStream() { @@ -187,11 +186,11 @@ public void saveAndLoadFlowStream() { assertTrue("saveToXML() must not throw an exception", couldSave); ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); - + boolean couldLoad = true; VFlow flow2 = null; try { - flow2 = WorkflowIO.loadFromXML(is); + flow2 = WorkflowIO.loadFromXML(is); } catch (Exception ex) { Logger.getLogger(VFlowIOTest.class.getName()).log(Level.SEVERE, null, ex); couldLoad = false; @@ -218,29 +217,29 @@ public void saveAndLoadFlowStream() { private void compare(VFlow flow1, VFlow flow2) { assertEquals("Both flows must have equal id", - flow1.getModel().getId(), flow2.getModel().getId()); + flow1.getModel().getId(), flow2.getModel().getId()); assertEquals("Both flows must have an equal number of subflows", - flow1.getSubControllers().size(), flow2.getSubControllers().size()); + flow1.getSubControllers().size(), flow2.getSubControllers().size()); assertEquals("Both flows must have an equal number of nodes", - flow1.getNodes().size(), flow2.getNodes().size()); + flow1.getNodes().size(), flow2.getNodes().size()); // Flows may have empty connection objects // (however, number of connections must be the same, see below) -// assertEquals("Both flows must have an equal number of connection types,", -// flow1.getAllConnections().values().size(), flow2.getAllConnections().values().size()); + // assertEquals("Both flows must have an equal number of connection types,", + // flow1.getAllConnections().values().size(), flow2.getAllConnections().values().size()); for (Connections connections1 : flow1.getAllConnections().values()) { Connections connections2 = flow2.getConnections(connections1.getType()); assertNotNull("Second flows must have a connections object of type " + connections1.getType(), - connections2); + connections2); assertEquals("Both flows must have an equal number of connections,", - connections1.getConnections().size(), - connections2.getConnections().size()); + connections1.getConnections().size(), + connections2.getConnections().size()); for (int i = 0; i < connections1.getConnections().size(); i++) { Connection c1 = connections1.getConnections().get(i); @@ -256,16 +255,16 @@ private void compare(VFlow flow1, VFlow flow2) { VNode n2 = flow2.getNodeLookup().getById(n1.getId()); assertNotNull("Second flow must contain a node with same id as in flow1: " - + n1.getId(), n2); + + n1.getId(), n2); assertEquals("Second node must contain the same number of connectors as node 1", - n1.getConnectors().size(), n2.getConnectors().size()); + n1.getConnectors().size(), n2.getConnectors().size()); for (int i = 0; i < n1.getConnectors().size(); i++) { assertEquals("Connectors must have equal id: ", - n1.getConnectors().get(i).getId(), - n2.getConnectors().get(i).getId()); + n1.getConnectors().get(i).getId(), + n2.getConnectors().get(i).getId()); } // TODO deep compare for valueobjects etc. @@ -283,7 +282,7 @@ private void compare(VFlow flow1, VFlow flow2) { } assertNotNull("Second flow must contain a subflow with same id as in flow1: " - + subFlow1.getModel().getId(), subFlow2); + + subFlow1.getModel().getId(), subFlow2); compare(subFlow1, subFlow2); } diff --git a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowMergeTest.java b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowMergeTest.java index 17d1e19b..2f4ec5e0 100644 --- a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowMergeTest.java +++ b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowMergeTest.java @@ -41,7 +41,6 @@ import org.junit.Ignore; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class VFlowMergeTest { @@ -52,7 +51,7 @@ public void testAdd() { addNodesToFlow(parent.newSubFlow(), 3, "control", "data"); VFlow subflow = FlowFactory.newFlow(); addNodesToFlow(subflow, 3, "control", "data"); -// parent.add(subflow); + // parent.add(subflow); VFlow expectedResult = FlowFactory.newFlow(); addNodesToFlow(expectedResult, 3, "control", "data"); diff --git a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowTest.java b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowTest.java index 437dcbc9..7bc8e9a8 100644 --- a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowTest.java +++ b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/VFlowTest.java @@ -53,7 +53,6 @@ import static org.junit.Assert.assertTrue; /** - * * @author Michael Hoffer */ public class VFlowTest { @@ -104,9 +103,9 @@ public void createNodes() { } assertNotEquals("flow.newNode() must not return equal nodes!", - flow.getNodes().get(i), flow.getNodes().get(j)); + flow.getNodes().get(i), flow.getNodes().get(j)); assertNotEquals("nodes must not have equal ids!", - flow.getNodes().get(i).getId(), flow.getNodes().get(j).getId()); + flow.getNodes().get(i).getId(), flow.getNodes().get(j).getId()); } } } @@ -137,11 +136,11 @@ public void connectNodes() { if (prevNodes.size() >= connectionTypes.length) { -// System.out.print(" >> prevNodes: "); -// for (VNode vNode : prevNodes) { -// System.out.print(" " + vNode.getOutputs().get(0).getType()); -// } -// System.out.println(""); + // System.out.print(" >> prevNodes: "); + // for (VNode vNode : prevNodes) { + // System.out.print(" " + vNode.getOutputs().get(0).getType()); + // } + // System.out.println(""); for (int j = 0; j < prevNodes.size(); j++) { ConnectionResult[] results = new ConnectionResult[connectionTypes.length]; @@ -155,22 +154,22 @@ public void connectNodes() { Connector outputReceiver = receiverNode.getOutputs().get(0); results[j] = flow.connect(outputSender, inputReceiver); - + if (k == 0) { assertTrue("Connection between compatible types failed: " + outputSender.getType() + " -> " + inputReceiver.getType(), - results[j].getStatus().isCompatible()); + results[j].getStatus().isCompatible()); } else { assertFalse("Connection between incompatible types must fail: " + outputSender.getType() + " -> " + inputReceiver.getType(), - results[j].getStatus().isCompatible()); + results[j].getStatus().isCompatible()); } assertFalse("Connection between two outputs must fail", - flow.connect(outputSender, outputReceiver).getStatus().isCompatible()); + flow.connect(outputSender, outputReceiver).getStatus().isCompatible()); assertFalse("Connection between two inputs must fail", - flow.connect(inputSender, inputReceiver).getStatus().isCompatible()); + flow.connect(inputSender, inputReceiver).getStatus().isCompatible()); } // end for k } // end for j @@ -198,7 +197,7 @@ public void createSubflows() { System.out.println(" --> subnode class: " + subNode.getClass()); assertTrue("Node that represent flows must implement VFlowModel interface", - (subNode instanceof VFlowModel)); + (subNode instanceof VFlowModel)); } @Test @@ -218,6 +217,6 @@ public void connectorsParentNode() { System.out.println(" --> subnode class (as referenced by connector): " + connector.getNode().getClass()); assertTrue("Node that represent flows must implement VFlowModel interface", - (connector.getNode() instanceof VFlowModel)); + (connector.getNode() instanceof VFlowModel)); } } diff --git a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/WorkflowUtilTest.java b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/WorkflowUtilTest.java index be2cf974..7a7ecd3a 100644 --- a/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/WorkflowUtilTest.java +++ b/VWorkflows-Core/src/test/java/eu/mihosoft/vrl/workflow/WorkflowUtilTest.java @@ -34,6 +34,9 @@ package eu.mihosoft.vrl.workflow; import eu.mihosoft.vrl.workflow.io.WorkflowIO; +import org.junit.Assert; +import org.junit.Test; + import java.io.IOException; import java.nio.file.Paths; import java.util.ArrayList; @@ -41,11 +44,8 @@ import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; -import org.junit.Assert; -import org.junit.Test; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class WorkflowUtilTest { @@ -64,12 +64,12 @@ public void createAncestorsTestCase(int depth, int width, int destDepth, int des if (destDepth < 0 || destDepth > depth) { throw new IllegalArgumentException("Illegal destDepth specified: " - + destDepth + ". Must be between 1 and " + depth + "."); + + destDepth + ". Must be between 1 and " + depth + "."); } if (destWidth < 0 || destWidth >= width) { throw new IllegalArgumentException("Illegal destDepth specified: " - + destDepth + ". Must be between 0 and " + (width - 1) + "."); + + destDepth + ". Must be between 0 and " + (width - 1) + "."); } VFlow flow = FlowFactory.newFlow(); @@ -90,7 +90,7 @@ public void createAncestorsTestCase(int depth, int width, int destDepth, int des Assert.assertTrue("Number of Ancestors must be equal to dest depth. " + "Expected " + destDepth + ", got " + numAncestors, - numAncestors == destDepth); + numAncestors == destDepth); } @@ -151,51 +151,51 @@ public void createCommonAncestorTestCase(int depth, int width, String n1Id, Stri Assert.assertTrue("Wrong common ancestor. " + "Expected " + commonAncestorId + ", got " + ancestor.getId(), - commonAncestorId.equals(ancestor.getId()) + commonAncestorId.equals(ancestor.getId()) ); } } - + @Test public void pathInLayerTest() { createPathInLayerTest(3, 6); createPathInLayerTest(1, 1); createPathInLayerTest(32, 32); createPathInLayerTest(2, 100); - + } - + private void createPathInLayerTest(int pathLength, int numNodes) { - + if (numNodes == 0 || pathLength == 0) { return; } - + if (numNodes < pathLength) { throw new IllegalArgumentException( - "path length must be less than number of nodes!"); + "path length must be less than number of nodes!"); } - + VFlow flow = FlowFactory.newFlow(); - - for(int i = 0; i < numNodes;i++) { + + for (int i = 0; i < numNodes; i++) { VNode n = flow.newNode(); n.setMainOutput(n.addOutput("mytype")); n.setMainInput(n.addInput("mytype")); } - - for(int i = 0; i < pathLength-1;i++) { + + for (int i = 0; i < pathLength - 1; i++) { VNode sender = flow.getNodes().get(i); - VNode receiver = flow.getNodes().get(i+1); + VNode receiver = flow.getNodes().get(i + 1); flow.connect(sender, receiver, "mytype"); } - - List path= WorkflowUtil.getPathInLayerFromRoot( - flow.getNodes().get(0), "mytype"); - - Assert.assertTrue("Expected number of nodes in path = "+pathLength - +", got " + path.size(), path.size()==pathLength); + + List path = WorkflowUtil.getPathInLayerFromRoot( + flow.getNodes().get(0), "mytype"); + + Assert.assertTrue("Expected number of nodes in path = " + pathLength + + ", got " + path.size(), path.size() == pathLength); } } diff --git a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/CustomContextMenuDemo.java b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/CustomContextMenuDemo.java index 8e4049f3..dff12936 100644 --- a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/CustomContextMenuDemo.java +++ b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/CustomContextMenuDemo.java @@ -67,7 +67,7 @@ public void start(Stage primaryStage) throws Exception { StackPane contentPane = new StackPane(); VCanvas canvas = new VCanvas(); contentPane.getChildren().add(canvas); - createFlow((Pane)canvas.getContent()); + createFlow((Pane) canvas.getContent()); Scene scene = new Scene(contentPane, 1024, 768); diff --git a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/Main.java b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/Main.java index c5864b9e..5a0cecec 100644 --- a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/Main.java +++ b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/Main.java @@ -47,7 +47,6 @@ import java.util.logging.Logger; /** - * * @author Michael Hoffer <info@michaelhoffer.de> */ public class Main extends Application { @@ -63,12 +62,13 @@ public class Main extends Application { public static void main(String[] args) { launch(args); } + private MainWindowFXMLController controller; @Override public void start(Stage primaryStage) { -// connectionTest(); + // connectionTest(); StackPane canvas = new StackPane(); @@ -80,7 +80,7 @@ public void start(Stage primaryStage) { fxmlLoader.load(); } catch (IOException ex) { Logger.getLogger(Main.class.getName()). - log(Level.SEVERE, null, ex); + log(Level.SEVERE, null, ex); } controller = fxmlLoader.getController(); @@ -94,17 +94,17 @@ public void start(Stage primaryStage) { Rectangle rect = new Rectangle(); rect.setStroke(new Color(1, 1, 1, 1)); rect.setFill(new Color(0, 0, 0, 0.5)); - -// MouseControlUtil. -// addSelectionRectangleGesture(controller.getRootPane(), rect); -// Playground.search01(); -// -// VRLShell shell = VShell.showInteractivScenicView(canvas); -// -// controller.registerShell(shell); + // MouseControlUtil. + // addSelectionRectangleGesture(controller.getRootPane(), rect); + + // Playground.search01(); + // + // VRLShell shell = VShell.showInteractivScenicView(canvas); + // + // controller.registerShell(shell); } - + } diff --git a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/MainWindowFXMLController.java b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/MainWindowFXMLController.java index bb2a539d..36d2679a 100644 --- a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/MainWindowFXMLController.java +++ b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/MainWindowFXMLController.java @@ -38,38 +38,46 @@ import eu.mihosoft.vrl.workflow.Connection; import eu.mihosoft.vrl.workflow.Connector; import eu.mihosoft.vrl.workflow.FlowFactory; -import eu.mihosoft.vrl.workflow.incubating.LayoutGenerator; -import eu.mihosoft.vrl.workflow.incubating.LayoutGeneratorNaive; -import eu.mihosoft.vrl.workflow.incubating.LayoutGeneratorSmart; import eu.mihosoft.vrl.workflow.MouseButton; import eu.mihosoft.vrl.workflow.VFlow; import eu.mihosoft.vrl.workflow.VFlowModel; import eu.mihosoft.vrl.workflow.VNode; import eu.mihosoft.vrl.workflow.VisualizationRequest; -import eu.mihosoft.vrl.workflow.fx.FlowNodeWindow; import eu.mihosoft.vrl.workflow.fx.FXFlowNodeSkin; import eu.mihosoft.vrl.workflow.fx.FXSkinFactory; +import eu.mihosoft.vrl.workflow.fx.FlowNodeWindow; import eu.mihosoft.vrl.workflow.fx.InnerCanvas; import eu.mihosoft.vrl.workflow.fx.NodeUtil; import eu.mihosoft.vrl.workflow.fx.OptimizableContentPane; import eu.mihosoft.vrl.workflow.fx.ScalableContentPane; import eu.mihosoft.vrl.workflow.fx.VCanvas; +import eu.mihosoft.vrl.workflow.incubating.LayoutGenerator; +import eu.mihosoft.vrl.workflow.incubating.LayoutGeneratorNaive; +import eu.mihosoft.vrl.workflow.incubating.LayoutGeneratorSmart; import eu.mihosoft.vrl.workflow.io.WorkflowIO; -import java.io.File; import javafx.collections.ObservableList; +import javafx.embed.swing.SwingFXUtils; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.scene.Node; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.SnapshotParameters; import javafx.scene.control.CheckMenuItem; import javafx.scene.control.ContextMenu; import javafx.scene.control.MenuItem; +import javafx.scene.image.WritableImage; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Pane; -import javafx.scene.Parent; -import javafx.scene.Scene; +import javafx.scene.transform.Translate; import javafx.stage.Stage; +import jfxtras.scene.control.window.Window; + +import javax.imageio.ImageIO; +import java.io.File; import java.io.IOException; import java.net.URL; import java.nio.file.Paths; @@ -82,13 +90,6 @@ import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; -import javafx.embed.swing.SwingFXUtils; -import javafx.scene.Node; -import javafx.scene.SnapshotParameters; -import javafx.scene.image.WritableImage; -import javafx.scene.transform.Translate; -import javax.imageio.ImageIO; -import jfxtras.scene.control.window.Window; /** * FXML Controller class @@ -115,7 +116,7 @@ public class MainWindowFXMLController implements Initializable { */ @Override public void initialize(URL url, ResourceBundle rb) { - canvas = new VCanvas(); + canvas = new VCanvas(); Pane root = (Pane) canvas.getContent(); @@ -124,13 +125,13 @@ public void initialize(URL url, ResourceBundle rb) { rootPane = root; onGenerateAction(null); - + // layout interface: smartLayout = new LayoutGeneratorSmart(); naiveLayout = new LayoutGeneratorNaive(); - + fxmlLoaderSmart = new FXMLLoader(getClass() - .getResource("OptionsWindowFXML.fxml")); + .getResource("OptionsWindowFXML.fxml")); optionsstageSmart = new Stage(); optionsstageSmart.setTitle("Smart Layout Options"); try { @@ -142,9 +143,9 @@ public void initialize(URL url, ResourceBundle rb) { optionsSmart = fxmlLoaderSmart.getController(); optionsSmart.setGenerator(smartLayout); optionsSmart.setStage(optionsstageSmart); - + fxmlLoaderNaive = new FXMLLoader(getClass() - .getResource("OptionsWindowNaiveFXML.fxml")); + .getResource("OptionsWindowNaiveFXML.fxml")); optionsstageNaive = new Stage(); optionsstageNaive.setTitle("Naive Layout Options"); try { @@ -157,7 +158,7 @@ public void initialize(URL url, ResourceBundle rb) { optionsNaive.setGenerator(naiveLayout); optionsNaive.setStage(optionsstageNaive); } - + private Pane rootPane; private VCanvas canvas; VFlow workflow; @@ -194,18 +195,18 @@ public void onSaveAction(ActionEvent e) { System.out.println(" [done]"); } - + // @FXML private CheckMenuItem checkDebugLayout; // - + // @FXML public void onNaiveAction(ActionEvent e) { int i; this.naiveLayout.setDebug(this.checkDebugLayout.isSelected()); - switch(this.naiveLayout.getGraphmode()) { + switch (this.naiveLayout.getGraphmode()) { case 0: this.naiveLayout.setWorkflow(this.workflow.getModel()); this.naiveLayout.generateLayout(); @@ -213,26 +214,26 @@ public void onNaiveAction(ActionEvent e) { case 2: ObservableList obsnodes = workflow.getNodes(); LinkedList nodelist = new LinkedList<>(); - for(i = 0; i < obsnodes.size(); i++) { + for (i = 0; i < obsnodes.size(); i++) { VNode curr = obsnodes.get(i); - if(curr.isSelected()) { + if (curr.isSelected()) { nodelist.add(curr); } } - if(!nodelist.isEmpty()) { + if (!nodelist.isEmpty()) { this.smartLayout.setNodelist(nodelist); this.smartLayout.generateLayout(); } break; } - + } - + @FXML public void onSmartRunAction(ActionEvent e) { int i; this.smartLayout.setDebug(this.checkDebugLayout.isSelected()); - switch(this.smartLayout.getGraphmode()) { + switch (this.smartLayout.getGraphmode()) { case 0: this.smartLayout.setWorkflow(this.workflow.getModel()); this.smartLayout.generateLayout(); @@ -241,28 +242,28 @@ public void onSmartRunAction(ActionEvent e) { LayoutGeneratorSmart altlay = new LayoutGeneratorSmart(); altlay.setWorkflow(this.workflow.getModel()); altlay.generateLayout(); - DirectedGraph jgraph = - altlay.getModelGraph(); + DirectedGraph jgraph = + altlay.getModelGraph(); this.smartLayout.setModelGraph(jgraph); this.smartLayout.generateLayout(); break; case 2: ObservableList obsnodes = workflow.getNodes(); LinkedList nodelist = new LinkedList<>(); - for(i = 0; i < obsnodes.size(); i++) { + for (i = 0; i < obsnodes.size(); i++) { VNode curr = obsnodes.get(i); - if(curr.isSelected()) { + if (curr.isSelected()) { nodelist.add(curr); } } - if(!nodelist.isEmpty()) { + if (!nodelist.isEmpty()) { this.smartLayout.setNodelist(nodelist); this.smartLayout.generateLayout(); } break; } } - + @FXML public void onSmartOptionsAction(ActionEvent e) { optionsSmart.setWorkflow(workflow); @@ -270,7 +271,7 @@ public void onSmartOptionsAction(ActionEvent e) { optionsSmart.set(); optionsstageSmart.show(); } - + @FXML public void onNaiveOptionsAction(ActionEvent e) { optionsNaive.setWorkflow(workflow); @@ -278,13 +279,13 @@ public void onNaiveOptionsAction(ActionEvent e) { optionsNaive.set(); optionsstageNaive.show(); } - + @FXML public void onLayoutSnapshotAction(ActionEvent e) { String abspath = new File(".").getAbsolutePath(); - String path = abspath.substring(0, abspath.length()-1); + String path = abspath.substring(0, abspath.length() - 1); File dir = new File(path + "snapshots"); - if(!dir.exists()) { + if (!dir.exists()) { System.out.println("Creating directory: " + dir.getAbsolutePath()); dir.mkdir(); } @@ -305,20 +306,20 @@ public void onLayoutSnapshotAction(ActionEvent e) { } subSnaps((InnerCanvas) canvas.getContent(), path, now); } - + private void subSnaps(InnerCanvas inner, String path, String now) { ObservableList childnodes = inner.getChildrenUnmodifiable(); - for(Node n : childnodes) { - if((n instanceof FlowNodeWindow) && (n.isManaged())) { + for (Node n : childnodes) { + if ((n instanceof FlowNodeWindow) && (n.isManaged())) { FlowNodeWindow w = (FlowNodeWindow) n; List style = NodeUtil.getStylesheetsOfAncestors(w); FXFlowNodeSkin wskin = w.nodeSkinProperty().get(); VFlow cont = wskin.getController(); Collection subconts = cont.getSubControllers(); - for(VFlow currsub : subconts) { - if(currsub.getModel().equals(wskin.getModel())) { + for (VFlow currsub : subconts) { + if (currsub.getModel().equals(wskin.getModel())) { String title = currsub.getModel().getId().replace(':', '-'); - if((currsub.getNodes().size() > 0) && (currsub.isVisible())) { + if ((currsub.getNodes().size() > 0) && (currsub.isVisible())) { VCanvas subcanvas = new VCanvas(); FlowNodeWindow.addResetViewMenu(subcanvas); subcanvas.setMinScaleX(0.1); @@ -326,10 +327,10 @@ private void subSnaps(InnerCanvas inner, String path, String now) { subcanvas.setMaxScaleX(1); subcanvas.setMaxScaleY(1); subcanvas.setTranslateToMinNodePos(true); - + FXSkinFactory fxSkinFactory = w.nodeSkinProperty().get().getSkinFactory().newInstance((Parent) subcanvas.getContent(), null); currsub.addSkinFactories(fxSkinFactory); - + Scene subscene = new Scene(subcanvas, (int) Math.round(rootPane.getWidth()), (int) Math.round(rootPane.getHeight())); subscene.getStylesheets().setAll(style); WritableImage wim = new WritableImage((int) Math.round(subscene.getWidth()), (int) Math.round(subscene.getHeight())); @@ -341,7 +342,7 @@ private void subSnaps(InnerCanvas inner, String path, String now) { } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } - if(w.getWorkflowContentPane() instanceof InnerCanvas) { + if (w.getWorkflowContentPane() instanceof InnerCanvas) { subSnaps((InnerCanvas) w.getWorkflowContentPane(), path, now); } } @@ -351,7 +352,7 @@ private void subSnaps(InnerCanvas inner, String path, String now) { } } // - + // @FXML public void onOriginalAction(ActionEvent e) { @@ -359,222 +360,222 @@ public void onOriginalAction(ActionEvent e) { VFlowModel flow = workflow.getModel(); originalTest(flow); } - + private void originalTest(VFlowModel flow) { ObservableList nodes = flow.getNodes(); - if(nodes.isEmpty()) return; + if (nodes.isEmpty()) { return; } flow.connect(nodes.get(1).getOutputs().get(1), nodes.get(3).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(3).getOutputs().get(1), nodes.get(8).getInputs() - .get(3)); + .get(3)); flow.connect(nodes.get(5).getOutputs().get(1), nodes.get(1).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(5).getOutputs().get(3), nodes.get(7).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(7).getOutputs().get(1), nodes.get(8).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(8).getOutputs().get(2), nodes.get(9).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(3).getOutputs().get(0), nodes.get(6).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(6).getOutputs().get(0), nodes.get(0).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(0).getOutputs().get(0), nodes.get(9).getInputs() - .get(0)); + .get(0)); Iterator it = nodes.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { VNode curr = it.next(); - if(curr instanceof VFlowModel) { + if (curr instanceof VFlowModel) { originalTest((VFlowModel) curr); } } } - + @FXML public void onAdditionalEdgeAction(ActionEvent e) { onGenerateAction(e); VFlowModel flow = workflow.getModel(); additionalEdgeTest(flow); } - + private void additionalEdgeTest(VFlowModel flow) { ObservableList nodes = flow.getNodes(); - if(nodes.isEmpty()) return; + if (nodes.isEmpty()) { return; } flow.connect(nodes.get(1).getOutputs().get(1), nodes.get(3).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(3).getOutputs().get(1), nodes.get(8).getInputs() - .get(3)); + .get(3)); flow.connect(nodes.get(5).getOutputs().get(1), nodes.get(1).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(5).getOutputs().get(3), nodes.get(7).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(7).getOutputs().get(1), nodes.get(8).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(8).getOutputs().get(2), nodes.get(9).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(3).getOutputs().get(0), nodes.get(6).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(6).getOutputs().get(0), nodes.get(0).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(0).getOutputs().get(0), nodes.get(9).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(2).getOutputs().get(2), nodes.get(8).getInputs() - .get(4)); + .get(4)); Iterator it = nodes.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { VNode curr = it.next(); - if(curr instanceof VFlowModel) { + if (curr instanceof VFlowModel) { additionalEdgeTest((VFlowModel) curr); } } } - + @FXML public void onAdditionalGraphAction(ActionEvent e) { onGenerateAction(e); VFlowModel flow = workflow.getModel(); additionalGraphTest(flow); } - + private void additionalGraphTest(VFlowModel flow) { ObservableList nodes = flow.getNodes(); - if(nodes.isEmpty()) return; + if (nodes.isEmpty()) { return; } flow.connect(nodes.get(1).getOutputs().get(1), nodes.get(3).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(3).getOutputs().get(1), nodes.get(8).getInputs() - .get(3)); + .get(3)); flow.connect(nodes.get(5).getOutputs().get(1), nodes.get(1).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(8).getOutputs().get(2), nodes.get(9).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(3).getOutputs().get(0), nodes.get(6).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(6).getOutputs().get(0), nodes.get(0).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(0).getOutputs().get(0), nodes.get(9).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(2).getOutputs().get(1), nodes.get(4).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(4).getOutputs().get(1), nodes.get(7).getInputs() - .get(1)); + .get(1)); Iterator it = nodes.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { VNode curr = it.next(); - if(curr instanceof VFlowModel) { + if (curr instanceof VFlowModel) { additionalGraphTest((VFlowModel) curr); } } } - + @FXML public void onTriLaneAction(ActionEvent e) { onGenerateAction(e); VFlowModel flow = workflow.getModel(); triLaneTest(flow); } - + private void triLaneTest(VFlowModel flow) { ObservableList nodes = flow.getNodes(); - if(nodes.isEmpty()) return; + if (nodes.isEmpty()) { return; } flow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(0).getOutputs().get(1), nodes.get(5).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(0).getOutputs().get(1), nodes.get(6).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(1).getOutputs().get(1), nodes.get(2).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(1).getOutputs().get(1), nodes.get(7).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(5).getOutputs().get(1), nodes.get(3).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(6).getOutputs().get(1), nodes.get(7).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(2).getOutputs().get(1), nodes.get(8).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(7).getOutputs().get(1), nodes.get(8).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(3).getOutputs().get(1), nodes.get(8).getInputs() - .get(1)); + .get(1)); Iterator it = nodes.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { VNode curr = it.next(); - if(curr instanceof VFlowModel) { + if (curr instanceof VFlowModel) { triLaneTest((VFlowModel) curr); } } } - + @FXML public void onDifferentSizesAction(ActionEvent e) { onGenerateAction(e); VFlowModel flow = workflow.getModel(); differentSizesTest(flow); } - + private void differentSizesTest(VFlowModel flow) { ObservableList nodes = flow.getNodes(); - if(nodes.isEmpty()) return; + if (nodes.isEmpty()) { return; } flow.connect(nodes.get(1).getOutputs().get(1), nodes.get(3).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(3).getOutputs().get(1), nodes.get(8).getInputs() - .get(3)); + .get(3)); flow.connect(nodes.get(5).getOutputs().get(1), nodes.get(1).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(5).getOutputs().get(3), nodes.get(7).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(7).getOutputs().get(1), nodes.get(8).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(8).getOutputs().get(2), nodes.get(9).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(3).getOutputs().get(0), nodes.get(6).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(6).getOutputs().get(0), nodes.get(0).getInputs() - .get(0)); + .get(0)); flow.connect(nodes.get(0).getOutputs().get(0), nodes.get(9).getInputs() - .get(0)); + .get(0)); nodes.get(5).setHeight(nodes.get(5).getHeight() * 1.5); nodes.get(5).setWidth(nodes.get(5).getWidth() * 1.5); nodes.get(7).setHeight(nodes.get(7).getHeight() * 2); nodes.get(8).setWidth(nodes.get(8).getWidth() * 2); Iterator it = nodes.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { VNode curr = it.next(); - if(curr instanceof VFlowModel) { + if (curr instanceof VFlowModel) { differentSizesTest((VFlowModel) curr); } } } - + @FXML public void onCycleAction(ActionEvent e) { onGenerateAction(e); VFlowModel flow = workflow.getModel(); cycleTest(flow); } - + private void cycleTest(VFlowModel flow) { ObservableList nodes = flow.getNodes(); - if(nodes.isEmpty()) return; + if (nodes.isEmpty()) { return; } flow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(1).getOutputs().get(1), nodes.get(2).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(2).getOutputs().get(1), nodes.get(3).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(2).getOutputs().get(1), nodes.get(4).getInputs() - .get(1)); + .get(1)); flow.connect(nodes.get(4).getOutputs().get(1), nodes.get(0).getInputs() - .get(1)); + .get(1)); Iterator it = nodes.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { VNode curr = it.next(); - if(curr instanceof VFlowModel) { + if (curr instanceof VFlowModel) { cycleTest((VFlowModel) curr); } } } - + @FXML public void onTestTree1(ActionEvent e) { // generation @@ -585,25 +586,25 @@ public void onTestTree1(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(7) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(4).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); } - + @FXML public void onTestTree2(ActionEvent e) { // generation @@ -614,25 +615,25 @@ public void onTestTree2(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(7) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); } - + @FXML public void onTestTree3(ActionEvent e) { // generation @@ -643,25 +644,25 @@ public void onTestTree3(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(7) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); } - + @FXML public void onTestNontree1(ActionEvent e) { // generation @@ -672,31 +673,31 @@ public void onTestNontree1(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(7) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(6).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); } - + @FXML public void onTestNontree2(ActionEvent e) { // generation @@ -707,31 +708,31 @@ public void onTestNontree2(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(7) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(4).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(6).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(7).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); } - + @FXML public void onTestNontree3(ActionEvent e) { // generation @@ -742,29 +743,29 @@ public void onTestNontree3(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(7) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(6).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(8).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); } - + @FXML public void onTestCyclic1(ActionEvent e) { // generation @@ -775,27 +776,27 @@ public void onTestCyclic1(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(4).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(7) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(6).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(6).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(7).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(7).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); } - + @FXML public void onTestCyclic2(ActionEvent e) { // generation @@ -806,33 +807,33 @@ public void onTestCyclic2(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(4).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(4).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(4).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(6).getOutputs().get(1), nodes.get(7) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(6).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(7).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(8).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); } - + @FXML public void onTestCyclic3(ActionEvent e) { // generation @@ -843,29 +844,29 @@ public void onTestCyclic3(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(4).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(6).getOutputs().get(1), nodes.get(7) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(7).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(8).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(9).getOutputs().get(1), nodes.get(0) - .getInputs().get(1)); + .getInputs().get(1)); } - + @FXML public void onTestSizes1(ActionEvent e) { // generation @@ -876,30 +877,30 @@ public void onTestSizes1(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(4).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); nodes.get(4).setWidth(nodes.get(4).getWidth() * 1.5); nodes.get(4).setHeight(nodes.get(4).getHeight() * 1.5); VFlowModel node5 = (VFlowModel) nodes.get(4); // subflow VNode n; int i; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { n = node5.newNode(); n.setTitle("Node " + n.getId()); n.addInput("event").getVisualizationRequest().set( - VisualizationRequest.KEY_CONNECTOR_AUTO_LAYOUT, true); + VisualizationRequest.KEY_CONNECTOR_AUTO_LAYOUT, true); n.addOutput("event").getVisualizationRequest().set( - VisualizationRequest.KEY_CONNECTOR_AUTO_LAYOUT, true); + VisualizationRequest.KEY_CONNECTOR_AUTO_LAYOUT, true); for (final Connector connector : n.getConnectors()) { connector.addClickEventListener(new EventHandler() { @Override @@ -910,10 +911,10 @@ public void handle(ClickEvent t) { if (t.getEvent() instanceof MouseEvent) { MouseEvent evt = (MouseEvent) t.getEvent(); ContextMenu menu = new ContextMenu(new MenuItem( - "Connector: " + connector.getId() - + ", btn: " + t.getButton())); + "Connector: " + connector.getId() + + ", btn: " + t.getButton())); menu.show(rootPane, evt.getScreenX(), - evt.getScreenY()); + evt.getScreenY()); } } }); @@ -925,17 +926,17 @@ public void handle(ClickEvent t) { } ObservableList subnodes = node5.getNodes(); node5.connect(subnodes.get(0).getOutputs().get(0), subnodes.get(1) - .getInputs().get(0)); + .getInputs().get(0)); node5.connect(subnodes.get(0).getOutputs().get(0), subnodes.get(2) - .getInputs().get(0)); + .getInputs().get(0)); node5.connect(subnodes.get(0).getOutputs().get(0), subnodes.get(3) - .getInputs().get(0)); + .getInputs().get(0)); node5.connect(subnodes.get(1).getOutputs().get(0), subnodes.get(3) - .getInputs().get(0)); + .getInputs().get(0)); node5.connect(subnodes.get(2).getOutputs().get(0), subnodes.get(3) - .getInputs().get(0)); + .getInputs().get(0)); } - + @FXML public void onTestSizes2(ActionEvent e) { // generation @@ -946,27 +947,27 @@ public void onTestSizes2(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(1) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(0).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(4).getOutputs().get(1), nodes.get(7) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(6).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(7).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(8).getOutputs().get(1), nodes.get(9) - .getInputs().get(1)); + .getInputs().get(1)); nodes.get(2).setWidth(nodes.get(2).getWidth() * 2); nodes.get(5).setWidth(nodes.get(5).getWidth() * 2); nodes.get(7).setWidth(nodes.get(7).getWidth() * 2); @@ -974,7 +975,7 @@ public void onTestSizes2(ActionEvent e) { nodes.get(5).setHeight(nodes.get(5).getHeight() * 2); nodes.get(7).setHeight(nodes.get(7).getHeight() * 2); } - + @FXML public void onTestSizes3(ActionEvent e) { // generation @@ -985,33 +986,33 @@ public void onTestSizes3(ActionEvent e) { // edges ObservableList nodes = workflow.getNodes(); workflow.connect(nodes.get(1).getOutputs().get(1), nodes.get(2) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(2).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(1) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(3).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(4).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(3) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(5).getOutputs().get(1), nodes.get(6) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(6).getOutputs().get(1), nodes.get(8) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(7).getOutputs().get(1), nodes.get(0) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(7).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(8).getOutputs().get(1), nodes.get(4) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(8).getOutputs().get(1), nodes.get(0) - .getInputs().get(1)); + .getInputs().get(1)); workflow.connect(nodes.get(9).getOutputs().get(1), nodes.get(5) - .getInputs().get(1)); + .getInputs().get(1)); nodes.get(0).setWidth(nodes.get(0).getWidth() * 3); nodes.get(1).setWidth(nodes.get(1).getWidth() * 0.5); nodes.get(2).setWidth(nodes.get(2).getWidth() * 1.5); @@ -1029,21 +1030,21 @@ public void onTestSizes3(ActionEvent e) { nodes.get(8).setHeight(nodes.get(8).getHeight() * 3); nodes.get(9).setHeight(nodes.get(9).getHeight() * 3); } - + @FXML public void onTestRunAll(ActionEvent e) { System.out.println("starting..."); String abspath = new File(".").getAbsolutePath(); - String path = abspath.substring(0, abspath.length()-1); + String path = abspath.substring(0, abspath.length() - 1); LayoutGenerator layouter; File dir = new File(path + "testimages"); - if(!dir.exists()) { + if (!dir.exists()) { System.out.println("Creating directory: " + dir.getAbsolutePath()); dir.mkdir(); } path += "testimages/"; dir = new File(path + "smart"); - if(!dir.exists()) { + if (!dir.exists()) { System.out.println("Creating directoriy: " + dir.getAbsolutePath()); dir.mkdir(); } @@ -1051,7 +1052,7 @@ public void onTestRunAll(ActionEvent e) { System.out.println("--- testing LayoutGeneratorSmart"); runTests(layouter, (path + "smart/"), e); dir = new File(path + "naive"); - if(!dir.exists()) { + if (!dir.exists()) { System.out.println("Creating directory: " + dir.getAbsolutePath()); dir.mkdir(); } @@ -1060,13 +1061,14 @@ public void onTestRunAll(ActionEvent e) { runTests(layouter, (path + "naive/"), e); System.out.println("...finished"); } - + /** - * Runs all tests for the given layout generator and saves snapshots of the + * Runs all tests for the given layout generator and saves snapshots of the * results in the given path. + * * @param layouter LayoutGenerator - * @param path String - * @param e ActionEvent + * @param path String + * @param e ActionEvent */ private void runTests(LayoutGenerator layouter, String path, ActionEvent e) { WritableImage wim = new WritableImage(1600, 800); @@ -1076,260 +1078,260 @@ private void runTests(LayoutGenerator layouter, String path, ActionEvent e) { int i; // test tree 1 System.out.println("Testing - TestTree1"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestTree1(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestTree1"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestTree1"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestTree1"); dir.mkdir(); } File out = new File(path + "TestTree1/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + ex); } } // test tree 2 System.out.println("Testing - TestTree2"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestTree2(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestTree2"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestTree2"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestTree2"); dir.mkdir(); } File out = new File(path + "TestTree2/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } // test tree 3 System.out.println("Testing - TestTree3"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestTree3(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestTree3"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestTree3"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestTree3"); dir.mkdir(); } File out = new File(path + "TestTree3/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } // test nontree 1 System.out.println("Testing - TestNontree1"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestNontree1(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestNontree1"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestNontree1"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestNontree1"); dir.mkdir(); } File out = new File(path + "TestNontree1/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } // test nontree 2 System.out.println("Testing - TestNontree2"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestNontree2(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestNontree2"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestNontree2"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestNontree2"); dir.mkdir(); } File out = new File(path + "TestNontree2/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } // test nontree 3 System.out.println("Testing - TestNontree3"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestNontree3(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestNontree3"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestNontree3"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestNontree3"); dir.mkdir(); } File out = new File(path + "TestNontree3/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } // test cyclic 1 System.out.println("Testing - TestCyclic1"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestCyclic1(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestCyclic1"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestCyclic1"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestCyclic1"); dir.mkdir(); } File out = new File(path + "TestCyclic1/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } // test cyclic 2 System.out.println("Testing - TestCyclic2"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestCyclic2(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestCyclic2"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestCyclic2"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestCyclic2"); dir.mkdir(); } File out = new File(path + "TestCyclic2/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } // test cyclic 3 System.out.println("Testing - TestCyclic3"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestCyclic3(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestCyclic3"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestCyclic3"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestCyclic3"); dir.mkdir(); } File out = new File(path + "TestCyclic3/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } // test sizes 1 System.out.println("Testing - TestSizes1"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestSizes1(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestSizes1"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestSizes1"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestSizes1"); dir.mkdir(); } File out = new File(path + "TestSizes1/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } // test sizes 2 System.out.println("Testing - TestSizes2"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestSizes2(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestSizes2"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestSizes2"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestSizes2"); dir.mkdir(); } File out = new File(path + "TestSizes2/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } // test sizes 3 System.out.println("Testing - TestSizes3"); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { onTestSizes3(e); layouter.setWorkflow(workflow.getModel()); layouter.generateLayout(); try { rootPane.snapshot(parameter, wim); dir = new File(path + "TestSizes3"); - if(!dir.exists()) { - System.out.println("Creating directory: " + path - + "TestSizes3"); + if (!dir.exists()) { + System.out.println("Creating directory: " + path + + "TestSizes3"); dir.mkdir(); } File out = new File(path + "TestSizes3/" + i + ".png"); ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", out); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, - ex); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, + ex); } } } - + // - + @FXML public void onStableAction(ActionEvent e) { LayoutGeneratorSmart layouter = new LayoutGeneratorSmart(false); @@ -1349,13 +1351,14 @@ public void onGenerateAction(ActionEvent e) { updateUI(); workflowTest(workflow, 5, 10); -// workflowTest(workflow, 2, 2); + // workflowTest(workflow, 2, 2); System.out.println(" [done]"); System.out.println(" --> #nodes: " + counter); } + @FXML public Pane contentPane; @@ -1399,22 +1402,22 @@ public void workflowTest(VFlow workflow, int depth, int width) { } n.setTitle("Node " + n.getId()); - -// n.getVisualizationRequest().set(VisualizationRequest.KEY_MAX_CONNECTOR_SIZE, 10.0); + + // n.getVisualizationRequest().set(VisualizationRequest.KEY_MAX_CONNECTOR_SIZE, 10.0); String type = connectionTypes[i % connectionTypes.length]; n.setMainInput(n.addInput(type)).getVisualizationRequest().set(VisualizationRequest.KEY_CONNECTOR_AUTO_LAYOUT, true); n.setMainInput(n.addInput("event")).getVisualizationRequest().set(VisualizationRequest.KEY_CONNECTOR_AUTO_LAYOUT, true); - -// n.getVisualizationRequest().set(VisualizationRequest.KEY_DISABLE_EDITING, true); + + // n.getVisualizationRequest().set(VisualizationRequest.KEY_DISABLE_EDITING, true); for (int j = 0; j < 3; j++) { n.addInput(type).getVisualizationRequest().set(VisualizationRequest.KEY_CONNECTOR_AUTO_LAYOUT, true); } -// n.addInput(type); -// n.addInput(type); + // n.addInput(type); + // n.addInput(type); n.addOutput(type).getVisualizationRequest().set(VisualizationRequest.KEY_CONNECTOR_AUTO_LAYOUT, true); n.setMainOutput(n.addOutput("event")).getVisualizationRequest().set(VisualizationRequest.KEY_CONNECTOR_AUTO_LAYOUT, true); n.addOutput(type).getVisualizationRequest().set(VisualizationRequest.KEY_CONNECTOR_AUTO_LAYOUT, true); @@ -1457,42 +1460,41 @@ private void updateUI() { rootPane.getChildren().clear(); -// ScalableContentPane minimapPane1 = createMinimap("Minimap 1"); -// ScalableContentPane minimapPane2 = createMinimap("Minimap 2"); -// -// if (workflow == null) { -// return; -// } + // ScalableContentPane minimapPane1 = createMinimap("Minimap 1"); + // ScalableContentPane minimapPane2 = createMinimap("Minimap 2"); + // + // if (workflow == null) { + // return; + // } workflow.getModel().setVisible(true); FXSkinFactory skinFactory = new FXSkinFactory(rootPane); workflow.setSkinFactories(skinFactory); - - - -// skinFactory.setConnectionFillColor("control", new Color(1.0, 1.0, 0.0, 0.75)); -// skinFactory.setConnectionStrokeColor("control", new Color(120 / 255.0, 140 / 255.0, 1, 0.42)); -// -// skinFactory.setConnectionFillColor("data", new Color(0.1, 0.1, 0.1, 0.5)); -// skinFactory.setConnectionStrokeColor("data", new Color(120 / 255.0, 140 / 255.0, 1, 0.42)); -// -// skinFactory.setConnectionFillColor("event", new Color(255.0 / 255.0, 100.0 / 255.0, 1, 0.5)); -// skinFactory.setConnectionStrokeColor("event", new Color(120 / 255.0, 140 / 255.0, 1, 0.42)); -// workflow.addSkinFactories(new FXSkinFactory(minimapPane1.getContentPane()), -// new FXSkinFactory(minimapPane2.getContentPane())); -// ScalableContentPane minimapPane3 = createMinimap("Minimap 3"); -// ScalableContentPane minimapPane4 = createMinimap("Minimap 4"); -// -// if (specialViewFlow1 != null) { -// specialViewFlow1.addSkinFactories(new FXSkinFactory(minimapPane3.getContentPane())); -// } -// -// if (specialViewFlow2 != null) { -// specialViewFlow2.addSkinFactories(new FXSkinFactory(minimapPane4.getContentPane())); -// } -// -// workflow.newSubFlow(); + + + // skinFactory.setConnectionFillColor("control", new Color(1.0, 1.0, 0.0, 0.75)); + // skinFactory.setConnectionStrokeColor("control", new Color(120 / 255.0, 140 / 255.0, 1, 0.42)); + // + // skinFactory.setConnectionFillColor("data", new Color(0.1, 0.1, 0.1, 0.5)); + // skinFactory.setConnectionStrokeColor("data", new Color(120 / 255.0, 140 / 255.0, 1, 0.42)); + // + // skinFactory.setConnectionFillColor("event", new Color(255.0 / 255.0, 100.0 / 255.0, 1, 0.5)); + // skinFactory.setConnectionStrokeColor("event", new Color(120 / 255.0, 140 / 255.0, 1, 0.42)); + // workflow.addSkinFactories(new FXSkinFactory(minimapPane1.getContentPane()), + // new FXSkinFactory(minimapPane2.getContentPane())); + // ScalableContentPane minimapPane3 = createMinimap("Minimap 3"); + // ScalableContentPane minimapPane4 = createMinimap("Minimap 4"); + // + // if (specialViewFlow1 != null) { + // specialViewFlow1.addSkinFactories(new FXSkinFactory(minimapPane3.getContentPane())); + // } + // + // if (specialViewFlow2 != null) { + // specialViewFlow2.addSkinFactories(new FXSkinFactory(minimapPane4.getContentPane())); + // } + // + // workflow.newSubFlow(); } private ScalableContentPane createMinimap(String title) { @@ -1512,7 +1514,7 @@ private ScalableContentPane createMinimap(String title) { rootPane.getChildren().add(minimap); return minimapPane; } -// void registerShell(VRLShell shell) { -// shell.addConstant("flow", workflow); -// } + // void registerShell(VRLShell shell) { + // shell.addConstant("flow", workflow); + // } } diff --git a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/NodeControlFXMLController.java b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/NodeControlFXMLController.java index 3f575daa..523bafbb 100644 --- a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/NodeControlFXMLController.java +++ b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/NodeControlFXMLController.java @@ -51,5 +51,5 @@ public class NodeControlFXMLController implements Initializable { @Override public void initialize(URL url, ResourceBundle rb) { // TODO - } + } } diff --git a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/OptionsWindowFXMLController.java b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/OptionsWindowFXMLController.java index a94cdb36..9d5fb7b0 100644 --- a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/OptionsWindowFXMLController.java +++ b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/OptionsWindowFXMLController.java @@ -35,9 +35,9 @@ import edu.uci.ics.jung.graph.DirectedGraph; import eu.mihosoft.vrl.workflow.Connection; -import eu.mihosoft.vrl.workflow.incubating.LayoutGeneratorSmart; import eu.mihosoft.vrl.workflow.VFlow; import eu.mihosoft.vrl.workflow.VNode; +import eu.mihosoft.vrl.workflow.incubating.LayoutGeneratorSmart; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; @@ -56,15 +56,14 @@ /** * FXML Controller Class - * - * + * * @author Tobias Mertz */ public class OptionsWindowFXMLController implements Initializable { @FXML public Pane contentPane; - + private LayoutGeneratorSmart generator; private Stage optionsstage; private VFlow workflow; @@ -73,8 +72,9 @@ public class OptionsWindowFXMLController implements Initializable { /** * Initializes the controller class. + * * @param url URL - * @param rb ResourceBundle + * @param rb ResourceBundle */ @Override public void initialize(URL url, ResourceBundle rb) { @@ -95,65 +95,65 @@ public void initialize(URL url, ResourceBundle rb) { graphmodelist.add(this.graphmodes[1]); graphmodelist.add(this.graphmodes[2]); } - + // @FXML private CheckBox checkForcePush; - + @FXML private CheckBox checkSeparateDisjunctGraphs; - + @FXML private CheckBox checkSeparateEdgeTypes; - + @FXML private CheckBox checkDisplaceIdents; - + @FXML private TextField tfMaxiterations; - + @FXML private CheckBox checkRecursive; - + @FXML private TextField tfAspectratio; - + @FXML private TextField tfScaling; - + @FXML private ComboBox selLayout; - + @FXML private CheckBox checkAlignNodes; - + @FXML private CheckBox checkRemoveCycles; - + @FXML private CheckBox checkOrigin; - + @FXML private TextField tfSubflowscale; - + @FXML private CheckBox checkRotate; - + @FXML private CheckBox checkPushBack; - + @FXML private CheckBox checkAutoscaleNodes; - + @FXML private CheckBox checkJungLayout; - + @FXML private ComboBox selGraphmode; - + @FXML private TextField tfDirection; - + @FXML private TextField tfAlignmentThreshold; // @@ -162,25 +162,25 @@ public void initialize(URL url, ResourceBundle rb) { public void setGenerator(LayoutGeneratorSmart pgenerator) { this.generator = pgenerator; } - + public void setStage(Stage poptionsstage) { this.optionsstage = poptionsstage; } - + public void setWorkflow(VFlow pworkflow) { this.workflow = pworkflow; } // - + // public LayoutGeneratorSmart getGenerator() { return this.generator; } - + public Stage getStage() { return this.optionsstage; } - + public VFlow getWorkflow() { return this.workflow; } @@ -197,12 +197,12 @@ void onCancelPress(ActionEvent e) { set(); this.optionsstage.close(); } - + @FXML void onShowPress(ActionEvent e) { int i; accept(); - switch(this.generator.getGraphmode()) { + switch (this.generator.getGraphmode()) { case 0: this.generator.setWorkflow(this.workflow.getModel()); this.generator.generateLayout(); @@ -211,69 +211,69 @@ void onShowPress(ActionEvent e) { LayoutGeneratorSmart altlay = new LayoutGeneratorSmart(); altlay.setWorkflow(this.workflow.getModel()); altlay.generateLayout(); - DirectedGraph jgraph = - altlay.getModelGraph(); + DirectedGraph jgraph = + altlay.getModelGraph(); this.generator.setModelGraph(jgraph); this.generator.generateLayout(); break; case 2: ObservableList obsnodes = workflow.getNodes(); LinkedList nodelist = new LinkedList<>(); - for(i = 0; i < obsnodes.size(); i++) { + for (i = 0; i < obsnodes.size(); i++) { VNode curr = obsnodes.get(i); - if(curr.isSelected()) { + if (curr.isSelected()) { nodelist.add(curr); } } - if(!nodelist.isEmpty()) { + if (!nodelist.isEmpty()) { this.generator.setNodelist(nodelist); this.generator.generateLayout(); } break; } } - + /** - * Sets the values of all menu items to the current values of the layout + * Sets the values of all menu items to the current values of the layout * generator. */ public void set() { this.checkForcePush.setSelected(this.generator.getLaunchForcePush()); this.checkSeparateDisjunctGraphs.setSelected(this.generator - .getLaunchSeparateDisjunctGraphs()); + .getLaunchSeparateDisjunctGraphs()); this.checkSeparateEdgeTypes.setSelected(this.generator - .getLaunchSeparateEdgeTypes()); + .getLaunchSeparateEdgeTypes()); this.checkDisplaceIdents.setSelected(this.generator - .getLaunchDisplaceIdents()); + .getLaunchDisplaceIdents()); this.tfMaxiterations.setText(Integer.toString(this.generator - .getMaxiterations())); + .getMaxiterations())); this.checkRecursive.setSelected(this.generator.getRecursive()); this.tfAspectratio.setText(Double.toString(this.generator - .getAspectratio())); + .getAspectratio())); this.tfScaling.setText(Double.toString(this.generator.getScaling())); this.selLayout.setValue(this.layouts[this.generator - .getLayoutSelector()]); + .getLayoutSelector()]); this.checkAlignNodes.setSelected(this.generator.getLaunchAlignNodes()); this.checkRemoveCycles.setSelected(this.generator - .getLaunchRemoveCycles()); + .getLaunchRemoveCycles()); this.checkOrigin.setSelected(this.generator.getLaunchOrigin()); this.tfSubflowscale.setText(Double.toString(this.generator - .getSubflowscale())); + .getSubflowscale())); this.checkRotate.setSelected(this.generator.getLaunchRotate()); this.checkPushBack.setSelected(this.generator.getLaunchPushBack()); this.checkAutoscaleNodes.setSelected(this.generator - .getAutoscaleNodes()); + .getAutoscaleNodes()); this.checkJungLayout.setSelected(this.generator.getLaunchJungLayout()); this.selGraphmode.setValue(this.graphmodes[this.generator - .getGraphmode()]); + .getGraphmode()]); this.tfDirection.setText(Double.toString(this.generator - .getDirection())); + .getDirection())); this.tfAlignmentThreshold.setText(Double.toString(this.generator - .getAlignmentThreshold())); + .getAlignmentThreshold())); } /** - * Sets the values of all parameters of the layout generator to the current + * Sets the values of all parameters of the layout generator to the current * values of the menu items. */ private void accept() { @@ -282,11 +282,11 @@ private void accept() { String temp; this.generator.setLaunchForcePush(this.checkForcePush.isSelected()); this.generator.setLaunchSeparateDisjunctGraphs(this - .checkSeparateDisjunctGraphs.isSelected()); + .checkSeparateDisjunctGraphs.isSelected()); this.generator.setLaunchSeparateEdgeTypes(this.checkSeparateEdgeTypes - .isSelected()); + .isSelected()); this.generator.setLaunchDisplaceIdents(this.checkDisplaceIdents - .isSelected()); + .isSelected()); i = this.generator.getMaxiterations(); temp = this.tfMaxiterations.getText(); try { @@ -313,14 +313,14 @@ private void accept() { } this.generator.setScaling(j); temp = this.selLayout.getValue(); - for(i = 0; i < this.layouts.length; i++) { - if(this.layouts[i].equals(temp)) { + for (i = 0; i < this.layouts.length; i++) { + if (this.layouts[i].equals(temp)) { this.generator.setLayoutSelector(i); } } this.generator.setLaunchAlignNodes(this.checkAlignNodes.isSelected()); this.generator.setLaunchRemoveCycles(this.checkRemoveCycles - .isSelected()); + .isSelected()); this.generator.setLaunchOrigin(this.checkOrigin.isSelected()); j = this.generator.getSubflowscale(); temp = this.tfSubflowscale.getText(); @@ -335,8 +335,8 @@ private void accept() { this.generator.setAutoscaleNodes(this.checkAutoscaleNodes.isSelected()); this.generator.setLaunchJungLayout(this.checkJungLayout.isSelected()); temp = this.selGraphmode.getValue(); - for(i = 0; i < this.graphmodes.length; i++) { - if(this.graphmodes[i].equals(temp)) { + for (i = 0; i < this.graphmodes.length; i++) { + if (this.graphmodes[i].equals(temp)) { this.generator.setGraphmode(i); } } diff --git a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/OptionsWindowNaiveFXMLController.java b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/OptionsWindowNaiveFXMLController.java index e84a932d..5afecd79 100644 --- a/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/OptionsWindowNaiveFXMLController.java +++ b/VWorkflows-Demo/src/main/java/eu/mihosoft/vrl/workflow/demo/OptionsWindowNaiveFXMLController.java @@ -33,9 +33,9 @@ */ package eu.mihosoft.vrl.workflow.demo; -import eu.mihosoft.vrl.workflow.incubating.LayoutGeneratorNaive; import eu.mihosoft.vrl.workflow.VFlow; import eu.mihosoft.vrl.workflow.VNode; +import eu.mihosoft.vrl.workflow.incubating.LayoutGeneratorNaive; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; @@ -54,14 +54,14 @@ /** * FXML Controller Class - * + * * @author Tobias Mertz */ public class OptionsWindowNaiveFXMLController implements Initializable { - + @FXML public Pane contentPane; - + private LayoutGeneratorNaive generator; private Stage optionsstage; private VFlow workflow; @@ -69,8 +69,9 @@ public class OptionsWindowNaiveFXMLController implements Initializable { /** * Initializes the controller class. + * * @param url URL - * @param rb ResourceBundle + * @param rb ResourceBundle */ @Override public void initialize(URL url, ResourceBundle rb) { @@ -82,7 +83,7 @@ public void initialize(URL url, ResourceBundle rb) { graphmodelist.add(this.graphmodes[1]); graphmodelist.add(this.graphmodes[2]); } - + // @FXML private CheckBox checkCalcVertPos; @@ -111,30 +112,30 @@ public void initialize(URL url, ResourceBundle rb) { @FXML private CheckBox checkCalcHorPos; // - + // public void setGenerator(LayoutGeneratorNaive pgenerator) { this.generator = pgenerator; } - + public void setStage(Stage poptionsstage) { this.optionsstage = poptionsstage; } - + public void setWorkflow(VFlow pworkflow) { this.workflow = pworkflow; } // - + // public LayoutGeneratorNaive getGenerator() { return this.generator; } - + public Stage getStage() { return this.optionsstage; } - + public VFlow getWorkflow() { return this.workflow; } @@ -156,7 +157,7 @@ void onCancelPress(ActionEvent event) { void onShowPress(ActionEvent event) { int i; accept(); - switch(this.generator.getGraphmode()) { + switch (this.generator.getGraphmode()) { case 0: this.generator.setWorkflow(this.workflow.getModel()); this.generator.generateLayout(); @@ -164,45 +165,45 @@ void onShowPress(ActionEvent event) { case 2: ObservableList obsnodes = workflow.getNodes(); LinkedList nodelist = new LinkedList<>(); - for(i = 0; i < obsnodes.size(); i++) { + for (i = 0; i < obsnodes.size(); i++) { VNode curr = obsnodes.get(i); - if(curr.isSelected()) { + if (curr.isSelected()) { nodelist.add(curr); } } - if(!nodelist.isEmpty()) { + if (!nodelist.isEmpty()) { this.generator.setNodelist(nodelist); this.generator.generateLayout(); } break; } } - + /** - * Sets the values of all menu items to the current values of the layout + * Sets the values of all menu items to the current values of the layout * generator. */ public void set() { this.checkAutoscaleNodes.setSelected(this.generator - .getAutoscaleNodes()); + .getAutoscaleNodes()); this.checkCalcHorPos.setSelected(this.generator - .getLaunchCalculateHorizontalPositions()); + .getLaunchCalculateHorizontalPositions()); this.checkCalcVertPos.setSelected(this.generator - .getLaunchCalculateVerticalPositions()); + .getLaunchCalculateVerticalPositions()); this.checkCreateLayering.setSelected(this.generator - .getLaunchCreateLayering()); + .getLaunchCreateLayering()); this.checkRecursive.setSelected(this.generator.getRecursive()); this.checkRemoveCycles.setSelected(this.generator - .getLaunchRemoveCycles()); + .getLaunchRemoveCycles()); this.selGraphmode.setValue(this.graphmodes[this.generator - .getGraphmode()]); + .getGraphmode()]); this.tfScaling.setText(Double.toString(this.generator.getScaling())); this.tfSubflowscale.setText(Double.toString(this.generator - .getSubflowscale())); + .getSubflowscale())); } - + /** - * Sets the values of all parameters of the layout generator to the current + * Sets the values of all parameters of the layout generator to the current * values of the menu items. */ private void accept() { @@ -211,18 +212,18 @@ private void accept() { String temp; this.generator.setAutoscaleNodes(this.checkAutoscaleNodes.isSelected()); this.generator.setLaunchCalculateHorizontalPositions( - this.checkCalcHorPos.isSelected()); + this.checkCalcHorPos.isSelected()); this.generator.setLaunchCalculateVerticalPositions( - this.checkCalcVertPos.isSelected()); + this.checkCalcVertPos.isSelected()); this.generator.setLaunchCreateLayering(this.checkCreateLayering - .isSelected()); + .isSelected()); this.generator.setRecursive(this.checkRecursive.isSelected()); this.generator.setLaunchRemoveCycles(this.checkRemoveCycles - .isSelected()); + .isSelected()); temp = this.selGraphmode.getValue(); - for(i = 0; i < this.graphmodes.length; i++) { - if(this.graphmodes[i].equals(temp)) { - if(i != 1) this.generator.setGraphmode(i); + for (i = 0; i < this.graphmodes.length; i++) { + if (this.graphmodes[i].equals(temp)) { + if (i != 1) { this.generator.setGraphmode(i); } } } j = this.generator.getScaling(); diff --git a/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/MainWindowFXML.fxml b/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/MainWindowFXML.fxml index 77c46729..5cc9029f 100644 --- a/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/MainWindowFXML.fxml +++ b/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/MainWindowFXML.fxml @@ -36,82 +36,85 @@ --> + - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - + + + + diff --git a/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/NodeControlFXML.fxml b/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/NodeControlFXML.fxml index d26b254b..c1615a6a 100644 --- a/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/NodeControlFXML.fxml +++ b/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/NodeControlFXML.fxml @@ -36,6 +36,7 @@ --> - - + + diff --git a/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/OptionsWindowFXML.fxml b/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/OptionsWindowFXML.fxml index a1a8d3b3..559f9345 100644 --- a/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/OptionsWindowFXML.fxml +++ b/VWorkflows-Demo/src/main/resources/eu/mihosoft/vrl/workflow/demo/OptionsWindowFXML.fxml @@ -36,41 +36,53 @@ --> - - - - - - - - - - - - - - - - - - - - -