From 6cefd46f7e4dc5e5aebe02c7b558958f35ce25ca Mon Sep 17 00:00:00 2001 From: Olivier Cavadenti Date: Sun, 17 Jul 2022 16:39:03 +0200 Subject: [PATCH] Cleanup code - Clean commented code. - Refactor to inline variables - Remove used variables --- .../eu/mihosoft/vrl/workflow/Connection.java | 10 +- .../mihosoft/vrl/workflow/ConnectionBase.java | 32 +-- .../vrl/workflow/ConnectionResult.java | 4 +- .../vrl/workflow/ConnectionsImpl.java | 15 +- .../vrl/workflow/DefaultValueObject.java | 11 +- .../eu/mihosoft/vrl/workflow/FlowFactory.java | 12 +- .../mihosoft/vrl/workflow/FlowModelImpl.java | 8 - .../vrl/workflow/FlowNodeSkinLookupImpl.java | 30 +-- .../vrl/workflow/IdGeneratorImpl.java | 13 +- .../vrl/workflow/ThruConnectorImpl.java | 10 +- .../eu/mihosoft/vrl/workflow/VFlowImpl.java | 60 +---- .../mihosoft/vrl/workflow/VFlowModelImpl.java | 32 --- .../java/eu/mihosoft/vrl/workflow/VNode.java | 26 +-- .../eu/mihosoft/vrl/workflow/VNodeImpl.java | 103 +-------- .../vrl/workflow/io/PersistentConnector.java | 14 +- .../vrl/workflow/io/PersistentNode.java | 13 +- .../mihosoft/vrl/workflow/io/WorkflowIO.java | 213 ++++++++---------- .../vrl/workflow/skin/ConnectionsSkin.java | 40 ---- .../fx/DefaultConnectionListener.java | 1 - .../workflow/fx/DefaultFXConnectionSkin.java | 19 -- .../vrl/workflow/fx/FXConnectionsSkin.java | 88 -------- .../vrl/workflow/fx/FXConnectorUtil.java | 6 - .../vrl/workflow/fx/FXFlowNodeSkin.java | 17 +- .../vrl/workflow/fx/FXNewConnectionSkin.java | 79 +++---- .../vrl/workflow/fx/FlowNodeWindow.java | 51 +---- .../eu/mihosoft/vrl/workflow/fx/NodeUtil.java | 70 ------ .../workflow/fx/OptimizableContentPane.java | 13 +- .../skin/window/DefaultWindowSkin.java | 49 +--- .../skin/window/DefaultWindowSkinLegacy.java | 119 +--------- .../window/DefaultWindowSkinSimplified.java | 40 +--- .../labs/util/event/MouseControlUtil.java | 9 - .../jfxtras/scene/control/window/Window.java | 29 +-- .../scene/control/window/WindowUtil.java | 23 +- 33 files changed, 197 insertions(+), 1062 deletions(-) delete mode 100644 VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/ConnectionsSkin.java delete mode 100644 VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXConnectionsSkin.java 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 3603cb54..04d0f56c 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 @@ -38,20 +38,16 @@ * @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(); @Override 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 0fc83ea4..94e406e8 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,9 @@ class ConnectionBase implements Connection { private Connector sender; private Connector receiver; -// 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, Connector sender, Connector receiver, String type) { this.connections = connections; this.id = id; @@ -74,10 +66,6 @@ public ConnectionBase(Connections connections, String id, Connector sender, Conn this.type = type; } -// @Override -// public String getSenderId() { -// return senderId; -// } @Override public void setSender(Connector s) { this.senderId = s.getId(); @@ -95,10 +83,6 @@ private void updateConnection() { } } -// @Override -// public String getReceiverId() { -// return receiverId; -// } @Override public void setReceiver(Connector r) { this.receiverId = r.getId(); @@ -153,20 +137,6 @@ 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; -// } /** * @return the connections @@ -233,7 +203,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/ConnectionResult.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionResult.java index b3b5ce11..64fbfc73 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 @@ -44,11 +44,9 @@ public interface ConnectionResult { * @return the connection */ Connection getConnection(); - -// 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/ConnectionsImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/ConnectionsImpl.java index 9754a3db..a8e0bb6a 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,13 +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<>(); private ObservableList observableConnections = FXCollections.observableArrayList(); private ObjectProperty vReqProperty; - // private ObjectProperty skinProperty = new SimpleObjectProperty<>(); public ConnectionsImpl(String type) { this.type = type; } @@ -119,9 +116,6 @@ public void remove(Connection c) { connections.remove(connectionId(c)); observableConnections.remove(c); - -// decSenderCounter(c.getSenderId()); -// decReceiverCounter(c.getReceiverId()); } @Override @@ -135,16 +129,13 @@ public void remove(String id, Connector s, Connector r) { observableConnections.remove(get(id, s, r)); connections.remove(connectionId(id, s.getId(), r.getId())); - -// 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 +150,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."); } 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 da166f95..f4619540 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 @@ -78,11 +78,8 @@ public CompatibilityResult compatible(final ValueObject sender, final String flo return new CompatibilityResult() { @Override public boolean isCompatible() { - boolean differentObjects = sender != DefaultValueObject.this; -// boolean compatibleType = getParent().isInputOfType(flowType) -// && sender.getParent().isOutputOfType(flowType); - return differentObjects /*&& compatibleType*/; + return sender != DefaultValueObject.this; } @Override @@ -99,14 +96,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 1ace261b..b0a825d8 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 @@ -50,10 +50,8 @@ public class FlowFactory { public static VFlow newFlow() { VFlowModel model = FlowFactory.newFlowModel(); - - VFlow flow = new VFlowImpl(null,model); - return flow; + return new VFlowImpl(null,model); } /** @@ -66,21 +64,19 @@ public static VFlow newFlow( VFlowModel model = FlowFactory.newFlowModel(); - VFlow flow = new VFlowImpl(null,model, skinFactory); - - return flow; + return new VFlowImpl(null,model, skinFactory); } /** * 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 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 592c99f0..fc140585 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 @@ -136,10 +136,7 @@ public ConnectionResult connect(VNode s, VNode r, String type) { receiver = r.getMainInput(type); } -// System.out.println("ADD: " + sender + ", " + receiver); Connection connection = getConnections(type).add(sender, receiver); - - return new ConnectionResultImpl(result.getStatus(), connection); } @@ -183,14 +180,10 @@ public void clear() { @Override public VNode remove(VNode n) { -// if (n instanceof FlowModel) { -// ((FlowModel)n).clear(); -// } VNode result = nodes.remove(n.getId()); nodeLookup.invalidateCache(); observableNodes.remove(n); -// removeNodeSkin(n); for (Connections cns : getAllConnections().values()) { Collection connectionsToRemove @@ -198,7 +191,6 @@ public VNode remove(VNode n) { for (Connection c : connectionsToRemove) { cns.remove(c); -// removeConnectionSkin(c); } } 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 9480e8b4..9278197a 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 @@ -58,10 +58,7 @@ public FlowNodeSkinLookupImpl(VFlow root) { @Override public List getById(String globalId) { - - List result = getNodeByGlobalId(root, globalId); - - return result; + return getNodeByGlobalId(root, globalId); } private List getNodeByGlobalId(VFlow parent, String id) { @@ -77,7 +74,6 @@ private List getNodeByGlobalId(VFlow parent, String id) { private VNodeSkin getNodeByGlobalId(SkinFactory skinFactory, VFlow parent, String id) { -// System.out.println("id: " + id); // find flow that contains the requested node VFlow flow; @@ -90,8 +86,6 @@ private VNodeSkin getNodeByGlobalId(SkinFactory skinFactory, VFlow parent, Strin if (flow == null) { return null; } -// -// System.out.println("found flow: " + flow.getModel().getId()); for (SkinFactory sF : flow.getSkinFactories()) { if (getRootSkinFactoryOf(skinFactory) == getRootSkinFactoryOf(sF)) { @@ -99,9 +93,6 @@ private VNodeSkin getNodeByGlobalId(SkinFactory skinFactory, VFlow parent, Strin return getBySkinFactory(sF, s2); } } -// -// System.out.println(" --> nothing found :("); - return null; } @@ -161,14 +152,7 @@ public VNodeSkin getById(SkinFactory skinFactory, String globalId) { // id is given globalId = globalId.split(":c:")[0]; - VNodeSkin result = getNodeByGlobalId(skinFactory, root, globalId); - -// if (result != null) { -// System.out.println("getById(): " + result); -// } else { -// System.out.println("NOT FOUND: getById(): " + null); -// } - return result; + return getNodeByGlobalId(skinFactory, root, globalId); } @Override @@ -197,15 +181,7 @@ public ConnectionSkin getById(SkinFactory skinFactory, Connection c) { VFlowImpl flowImpl = (VFlowImpl) flow; - ConnectionSkin skin = flowImpl.getConnectionSkinMap(skinFactory).get( + return (ConnectionSkin) 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); - return skin; } } 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 6abd3cbd..a6404942 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,10 +44,8 @@ class IdGeneratorImpl implements IdGenerator { private Set ids = new HashSet<>(); -// private int lastId = 0; public IdGeneratorImpl() { - // } @Override @@ -65,9 +63,9 @@ public String newId(String prefix) { // TODO improve id generation // Question: do we really want strings as id? - int counter = 0;//lastId + 1; - - + int counter = 0; + + if (prefix != null && !prefix.isEmpty() && !prefix.endsWith(":")) { prefix = prefix + "-"; } @@ -81,8 +79,6 @@ public String newId(String prefix) { ids.add(id); -// lastId = counter; - return id; } @@ -93,8 +89,7 @@ public String newId() { @Override public Set getIds() { - Set result = new HashSet<>(ids); - return result; + return new HashSet<>(ids); } @Override 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 92898b88..8b8c96d7 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 @@ -40,20 +40,16 @@ * @author Michael Hoffer <info@michaelhoffer.de> */ 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); -// } @Override public VNode getInnerNode() { @@ -65,5 +61,5 @@ public Connector getInnerConnector() { return this.innerConnector; } - + } 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 b14245c7..b5691eca 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,14 +158,12 @@ public void onChanged(ListChangeListener.Change change) { } else if (change.wasRemoved()) { // removed for (VNode n : change.getRemoved()) { -// if (nodeSkins.containsKey(n.getId())) { if (!getNodeSkinsById(n.getId()).isEmpty()) { removeNodeSkinFromAllSkinFactories(n); for (Connector connector : n.getConnectors()) { -// System.out.println("conn: " + connector); Collection connections = getConnections(connector.getType()). getAllWith(connector); @@ -175,8 +173,6 @@ public void onChanged(ListChangeListener.Change change) { remove(connection); } } - -// System.out.println("remove node: " + n.getId()); } if (n instanceof FlowModel) { @@ -187,13 +183,10 @@ public void onChanged(ListChangeListener.Change change) { } else if (change.wasAdded()) { // added for (VNode n : change.getAddedSubList()) { -// if (!nodeSkins.containsKey(n.getId())) { if (getNodeSkinsById(n.getId()).isEmpty()) { createNodeSkins(n, skinFactories); -// 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()); } } } @@ -263,10 +256,9 @@ public void onChanged(ListChangeListener.Change change) { } // fire events - // remove skins for each connection + // remove skins for each connection // that have been removed removeConnectionSkinFromAllSkinFactories(c); -// System.out.println("remove skin: " + c); } } else if (change.wasAdded()) { // added @@ -312,7 +304,6 @@ public void onChanged(ListChangeListener.Change change) { // fire events // create skins for added connections createConnectionSkins(c, c.getType(), getSkinFactories()); -// System.out.println("add skin: " + c); } } } @@ -323,8 +314,6 @@ public void onChanged(ListChangeListener.Change change) { visibilityListener = new ChangeListener() { @Override public void changed(ObservableValue ov, Boolean t, Boolean t1) { - -// System.out.println("visible: " + t1 + " : " + getModel().isVisible() + " : " + getModel().getId()); if (t1) { setSkinFactories(getSkinFactories()); } else { @@ -336,8 +325,6 @@ public void changed(ObservableValue ov, Boolean t, Boolean t1 modelProperty.addListener(new ChangeListener() { @Override public void changed(ObservableValue ov, FlowModel t, FlowModel t1) { - -// removeUIFromAllSkinFactories(); Collection> tmpFactories = new ArrayList<>(); tmpFactories.addAll(getSkinFactories()); removeSkinFactories(getSkinFactories()); @@ -527,10 +514,8 @@ private List> createNodeSkins(VNode n, SkinFactory> creating skins for node: " + n.getId()); List> skins = new ArrayList<>(); -// System.out.println(" --> #skinFactories: " + skinFactories.length); for (SkinFactory skinFactory : skinFactories) { if (skinFactory == null) { @@ -538,10 +523,8 @@ private List> createNodeSkins(VNode n, SkinFactory adding to skinfsctory: " + skinFactory); VNodeSkin skin = skinFactory.createSkin(n, this); -// nodeSkins.put(n.getId(), skin); putNodeSkin(skinFactory, skin); skin.add(); @@ -556,7 +539,6 @@ private List> createNodeSkins(VNode n, SkinFactory skin) { Map nodeSkinMap = getNodeSkinMap(skinFactory); -// System.out.println("put skin " + skin + "for: " + skin.getModel().getId() + ", factory: " + skinFactory); nodeSkinMap.put(skin.getModel().getId(), skin); } @@ -565,7 +547,6 @@ private VNodeSkin getNodeSkin(SkinFactory skinFactory, String id) { VNodeSkin nodeSkin = nodeSkinMap.get(id); -// System.out.println("skin for " + id + " = " + nodeSkin + ", factory: " + skinFactory + ", controller: " + getModel().getId()); return nodeSkin; } @@ -667,7 +648,6 @@ private List createConnectionSkins(Connection c, String type, Sk ConnectionSkin skin = skinFactory.createSkin(c, this, type); -// connectionSkins.put(connectionId(c), skin); putConnectionSkin(skinFactory, skin); skin.add(); @@ -800,10 +780,6 @@ 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()); -// } - for (SkinFactory skinFactory : skinFactories) { removeUI(skinFactory); @@ -821,8 +797,6 @@ public void removeSkinFactories(SkinFactory #skinFactories: " + getSkinFactories().size()); } @Override @@ -877,7 +851,6 @@ private VFlow newSubFlow(VFlowModel flowNode) { VNodeSkin skin = getNodeSkin(skinFactory, flowNode.getId());//nodeSkins.get(flowNode.getId()); -// System.out.println("skin: " + skin + ", node: " + flowNode.getId()); SkinFactory childFactory = null; if (skinFactory != null) { @@ -980,37 +953,6 @@ 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(); -// } 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/VFlowModelImpl.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/VFlowModelImpl.java index 6d6377aa..89087fd8 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 @@ -323,15 +323,6 @@ public VFlowModel getFlow() { return node.getFlow(); } -// @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 +377,6 @@ public VNode newNode() { return result; } -// @Override -// public String getGlobalId() { -// return node.getGlobalId(); -// } @Override public final void setIdGenerator(IdGenerator generator) { flow.setIdGenerator(generator); @@ -410,25 +397,6 @@ 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 Connector getMainInput(String type) { return this.node.getMainInput(type); 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 e469c204..fa937e28 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 @@ -99,9 +99,6 @@ public interface VNode extends Model, Selectable { public double getHeight(); -// public ObservableList getChildren(); -// public ObservableList> getInputs(); -// public ObservableList> getOutputs(); public void setValueObject(ValueObject obj); public ValueObject getValueObject(); @@ -110,25 +107,14 @@ public interface VNode extends Model, Selectable { public VFlowModel getFlow(); -// 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); public Connector addOutput(String type); public Connector addConnector(Connector c); - + public boolean removeConnector(Connector c); -// ObservableList getInputTypes(); -// -// ObservableList getOutputTypes(); public Collection getMainInputTypes(); public Collection getMainOutputTypes(); @@ -148,20 +134,20 @@ public interface VNode extends Model, Selectable { public ObservableList getInputs(); public ObservableList getOutputs(); - + public BooleanProperty selectableProperty(); public boolean isSelectable(); - - + + /** * Returns the distance to the root element. */ public int getDepth(); - + /** * Returns the root element of this flow. * @return root element */ public 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 1ebddc23..63214591 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 @@ -121,7 +121,7 @@ public void onChanged(Change change) { // else if (change.wasUpdated()) { // //TODO: update item // -// } +// } else if (change.wasRemoved()) { for (Connector connector : change.getRemoved()) { if (connector.isInput()) { @@ -142,12 +142,10 @@ else if (change.wasRemoved()) { for (Connector connector : change.getAddedSubList()) { if (connector.isInput()) { inputs.add(connector); -// System.out.println("added input:" + unmodifiableInputs.size()); } if (connector.isOutput()) { outputs.add(connector); -// System.out.println("added output:" + unmodifiableOutputs.size()); } if (connector instanceof ThruConnector) { @@ -160,25 +158,8 @@ 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; -// } @Override public StringProperty titleProperty() { return titleProperty; @@ -269,10 +250,6 @@ public double getHeight() { return heightProperty.get(); } -// @Override -// public ObservableList getChildren() { -// return children; -// } @Override public ValueObject getValueObject() { return valueObjectProperty.get(); @@ -322,20 +299,6 @@ 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; -// } /** * @return the flow */ @@ -344,23 +307,6 @@ 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 Connector addInput(String type) { return addInput(this, type); @@ -420,51 +366,6 @@ 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 Connector getMainInput(String type) { return mainInputs.get(type); 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 09c146d7..142ffbe4 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 @@ -73,11 +73,6 @@ public void setLocalId(String id) { this.localId = id; } -// public PersistentNode getNode() { -// return this.node; -// } - - public VisualizationRequest getVisualizationRequest() { return this.vRequest; } @@ -101,13 +96,6 @@ public boolean isOutput() { return output; } -// /** -// * @param node the node to set -// */ -// public void setNode(PersistentNode node) { -// this.node = node; -// } - /** * @return the valueObject */ @@ -149,4 +137,4 @@ public int getMaxNumConnections() { public void setMaxNumConnections(int maxNumConnections) { this.maxNumConnections = maxNumConnections; } -} \ No newline at end of file +} 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 0e80f131..221fd512 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 @@ -76,8 +76,8 @@ public PersistentNode(String id, String title, this.id = id; this.connectors = WorkflowIO.listToSerializableList(connectors); } - - + + /** * @return the x @@ -202,20 +202,17 @@ 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 ) { - -// connector.setNode(this); - - connectors.add(connector); + connectors.add(connector); } /** 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 6187a384..ce71c4fc 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 @@ -64,67 +64,67 @@ * @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); @@ -134,43 +134,41 @@ private static void configureStream(XStream xstream) { // 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); - + 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; + + return xstream.toXML(toPersistentNode(flow, null)); } - + 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( @@ -181,13 +179,9 @@ public static PersistentNode toPersistentNode(VNode node, PersistentFlow parent) c.getVisualizationRequest())); } } - + List nodeList = new ArrayList<>(); - - List connectionTypes = new ArrayList<>(); - - connectionTypes.addAll(flow.getAllConnections().keySet()); - + PersistentFlow pFlow = new PersistentFlow(parent, node.getId(), connectionList, @@ -201,23 +195,23 @@ public static PersistentNode toPersistentNode(VNode node, PersistentFlow parent) 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(), @@ -229,68 +223,68 @@ public static PersistentNode toPersistentNode(VNode node, PersistentFlow parent) 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) { - + 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) { - + VFlowModel result; - + if (parent == null) { result = FlowFactory.newFlowModel(); result.setIdGenerator(generator); @@ -298,7 +292,7 @@ private static VFlowModel createFlowFromPersistent( } else { result = parent.newFlowNode(); } - + result.setId(flow.getId()); generator.addId(flow.getId()); result.setTitle(flow.getTitle()); @@ -309,47 +303,28 @@ 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); -// } -// } return result; } - + private static void addFlowNode(VFlowModel flow, PersistentNode node, IdGenerator generator) { - + if (node instanceof PersistentFlow) { createFlowFromPersistent((PersistentFlow) node, flow, generator); } else { @@ -363,44 +338,36 @@ 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 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; + return new ArrayList<>(input); } - + public static Connector fromPersistentConnector(PersistentConnector pC, VNode n) { -// 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( @@ -414,13 +381,13 @@ public static Connector fromPersistentConnector(PersistentConnector pC, VNode n) c = new ThruConnectorImpl(n, pC.getType(), pC.getLocalId(), false, innerNode, innerConnector); } - + } else { c = new IOConnector(n, pC.getType(), pC.getLocalId(), pC.isInput()); } - + c.setMaxNumberOfConnections(pC.getMaxNumConnections()); - + return c; } @@ -438,28 +405,28 @@ public static PersistentConnector toPersistentConnector(Connector c) { PersistentConnector pC = new PersistentConnector( 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)); - } - + } + return result; } - + } diff --git a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/ConnectionsSkin.java b/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/ConnectionsSkin.java deleted file mode 100644 index 82bb087b..00000000 --- a/VWorkflows-Core/src/main/java/eu/mihosoft/vrl/workflow/skin/ConnectionsSkin.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2012-2022 Michael Hoffer . All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * Please cite the following publication(s): - * - * M. Hoffer, C.Poliwoda, G.Wittum. Visual Reflection Library - - * A Framework for Declarative GUI Programming on the Java Platform. - * Computing and Visualization in Science, 2011, in press. - * - * THIS SOFTWARE IS PROVIDED BY Michael Hoffer "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Hoffer OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of Michael Hoffer . - */ -package eu.mihosoft.vrl.workflow.skin; -// * Skin that represents all connections -// * @author Michael Hoffer <info@michaelhoffer.de> -// */ -//public interface ConnectionsSkin extends Skin { -// -//} diff --git a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/DefaultConnectionListener.java b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/DefaultConnectionListener.java index 39f9223c..596a3008 100644 --- a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/DefaultConnectionListener.java +++ b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/DefaultConnectionListener.java @@ -131,7 +131,6 @@ private void newConnectionAnim(ConnectionResult connResult) { } private void newConnectionReverseAnim(ConnectionResult connResult) { - // System.out.println("new-connection anim (reverse)"); if (connResult.getConnection() != null) { FXConnectionSkin connectionSkin = (FXConnectionSkin) flowController.getNodeSkinLookup().getById( diff --git a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/DefaultFXConnectionSkin.java b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/DefaultFXConnectionSkin.java index 84795ad8..6a026d42 100644 --- a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/DefaultFXConnectionSkin.java +++ b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/DefaultFXConnectionSkin.java @@ -201,7 +201,6 @@ protected double computeValue() { receiverDraggingStarted = true; if (lastNode != null) { -// lastNode.setEffect(null); lastNode = null; } @@ -214,10 +213,6 @@ protected double computeValue() { if (selConnector != null && selConnector.getNode() != null && selConnector.getConnector() == null) { -// DropShadow shadow = new DropShadow(20, Color.RED); -// Glow effect = new Glow(0.8); -// effect.setInput(shadow); -// selConnector.getNode().setEffect(effect); connectionListener.onNoConnection(selConnector.getNode()); lastNode = selConnector.getNode(); } @@ -238,11 +233,6 @@ protected double computeValue() { boolean isSameConnection = receiverConnector.equals(getReceiver()); if (connResult.getStatus().isCompatible() || isSameConnection) { - -// DropShadow shadow = new DropShadow(20, Color.WHITE); -// Glow effect = new Glow(0.5); -// shadow.setInput(effect); -// n.setEffect(shadow); getReceiverUI().toFront(); if (lastNode != n) { @@ -251,11 +241,6 @@ protected double computeValue() { } } else { - -// DropShadow shadow = new DropShadow(20, Color.RED); -// Glow effect = new Glow(0.8); -// effect.setInput(shadow); -// n.setEffect(effect); connectionListener.onConnectionIncompatible(); } @@ -287,7 +272,6 @@ protected double computeValue() { } if (lastNode != null) { -// lastNode.setEffect(null); lastNode = null; } @@ -364,10 +348,8 @@ public final void setModel(Connection model) { @Override public void add() { NodeUtil.addToParent(getParent(), connectionPath); -// VFXNodeUtils.addToParent(getParent(), startConnector); NodeUtil.addToParent(getParent(), getReceiverUI()); -// startConnector.toBack(); getReceiverUI().toFront(); connectionPath.toBack(); } @@ -381,7 +363,6 @@ public void remove() { } try { super.remove(); -// connection.getConnections().remove(connection); } catch (Exception ex) { ex.printStackTrace(System.err); } diff --git a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXConnectionsSkin.java b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXConnectionsSkin.java deleted file mode 100644 index c47cb1f5..00000000 --- a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXConnectionsSkin.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2012-2022 Michael Hoffer . All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * Please cite the following publication(s): - * - * M. Hoffer, C.Poliwoda, G.Wittum. Visual Reflection Library - - * A Framework for Declarative GUI Programming on the Java Platform. - * Computing and Visualization in Science, 2011, in press. - * - * THIS SOFTWARE IS PROVIDED BY Michael Hoffer "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Hoffer OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of Michael Hoffer . - */ -///* -// * To change this template, choose Tools | Templates -// * and open the template in the editor. -// */ -//package eu.mihosoft.vrl.workflow.fx; -// -//import eu.mihosoft.vrl.workflow.Connections; -//import eu.mihosoft.vrl.workflow.ConnectionsSkin; -//import javafx.beans.property.ObjectProperty; -//import javafx.beans.property.SimpleObjectProperty; -//import javafx.scene.Node; -// -///** -// * -// * @author Michael Hoffer <info@michaelhoffer.de> -// */ -//public class FXConnectionsSkin implements ConnectionsSkin, FXSkin { -// -// private Connections connections; -// private ObjectProperty modelProperty = new SimpleObjectProperty<>(); -// -// public FXConnectionsSkin(Connections connections) { -// this.connections = connections; -// } -// -// @Override -// public Node getNode() { -// return null; -// } -// -// @Override -// public void remove() { -//// VFXNodeUtils.removeFromParent(node); -// } -// -// @Override -// public void setModel(Connections model) { -// modelProperty.set(model); -// } -// -// @Override -// public Connections getModel() { -// return modelProperty.get(); -// } -// -// @Override -// public ObjectProperty modelProperty() { -// return modelProperty; -// } -// -// @Override -// public void add() { -// throw new UnsupportedOperationException("Not supported yet."); -// } -//} diff --git a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXConnectorUtil.java b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXConnectorUtil.java index 6cd4e0e2..54dcf279 100644 --- a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXConnectorUtil.java +++ b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXConnectorUtil.java @@ -143,9 +143,6 @@ public static void connnectionEstablishedAnim(Node receiverUI) { } Timeline timeline = new Timeline(); -// timeline.setAutoReverse(true); -// timeline.setCycleCount(Timeline.INDEFINITE); - final Circle connectedShape = new Circle(); connectedShape.setStrokeWidth(15); connectedShape.setFill(Color.TRANSPARENT); @@ -185,9 +182,6 @@ public static void connnectionEstablishedAnim(Node receiverUI) { public static void connnectionIncompatibleAnim(Node receiverUI) { Timeline timeline = new Timeline(); -// timeline.setAutoReverse(true); -// timeline.setCycleCount(Timeline.INDEFINITE); - final Circle connectedShape = new Circle(); connectedShape.setStrokeWidth(15); connectedShape.setFill(Color.TRANSPARENT); diff --git a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXFlowNodeSkin.java b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXFlowNodeSkin.java index 314bdafa..5b8eab6c 100644 --- a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXFlowNodeSkin.java +++ b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXFlowNodeSkin.java @@ -136,7 +136,6 @@ protected FlowNodeWindow createNodeWindow() { }); flowNodeWindow.resizingProperty().addListener((ov) -> { -// System.out.println("resizing: " + flowNodeWindow.isResizing()); connectors.values().forEach(cShape -> { cShape.getNode().setCache(!flowNodeWindow.isResizing()); @@ -150,10 +149,6 @@ protected FlowNodeWindow createNodeWindow() { flowNodeWindow.setCache(true); } }); - -// flowNodeWindow.cacheProperty().addListener((ov)->{ -// System.out.println("w-cached: " + flowNodeWindow.isCache()); -// }); return flowNodeWindow; } @@ -185,11 +180,11 @@ private void init() { // for (int i = change.getFrom(); i < change.getTo(); ++i) { // // TODO permutate // } -// } +// } // else if (change.wasUpdated()) { // // TODO update item -// } -// else +// } +// else if (change.wasRemoved()) { numConnectorsHasChanged = true; @@ -210,8 +205,6 @@ private void init() { if (numConnectorsHasChanged) { computeConnectorSizes(); -// computeInputConnectorSize(); -// computeOutputConnectorSize(); adjustConnectorSize(); numConnectorsProperty.set(getModel().getConnectors().size()); @@ -338,7 +331,7 @@ private void layoutConnector(Connector c, boolean updateOthers) { Collection conns = getModel().getFlow(). getConnections(c.getType()).getAllWith(c); - //----------------------------B + //----------------------------B Optional preferTD = c.getVisualizationRequest(). get(VisualizationRequest.KEY_CONNECTOR_PREFER_TOP_DOWN); @@ -568,11 +561,9 @@ protected void addConnector(final Connector connector) { int outputDefault = preferTopDown ? BOTTOM : RIGHT; //--------------------E if (connector.isInput()) { -// inputList.add(connectorNode); shapeLists.get(inputDefault).add(connectorShape); connectorToIndexMap.put(connector, inputDefault); } else if (connector.isOutput()) { -// outputList.add(connectorNode); shapeLists.get(outputDefault).add(connectorShape); connectorToIndexMap.put(connector, outputDefault); } diff --git a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXNewConnectionSkin.java b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXNewConnectionSkin.java index 71560d2b..6e9b4e41 100644 --- a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXNewConnectionSkin.java +++ b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FXNewConnectionSkin.java @@ -80,7 +80,7 @@ protected void initSenderAndReceiver() { final VNode sender = getSender().getNode(); final FXFlowNodeSkin senderSkin = (FXFlowNodeSkin) getController(). getNodeSkinLookup().getById(skinFactory, sender.getId()); - + senderShape = senderSkin.getConnectorShape(getSender()); final Node senderNode = senderShape.getNode(); @@ -97,14 +97,13 @@ protected void makeDraggable() { receiverConnectorUI.toFront(); MouseControlUtil.makeDraggable(receiverConnectorUI, (MouseEvent t) -> { - + if (lastNode != null) { -// lastNode.setEffect(null); lastNode = null; } - + SelectedConnector selConnector = null; - + if (getSender().isOutput()) { selConnector = FXConnectorUtil.getSelectedInputConnector( getSender().getNode(), getParent(), type, t); @@ -112,64 +111,48 @@ protected void makeDraggable() { selConnector = FXConnectorUtil.getSelectedOutputConnector( getSender().getNode(), getParent(), type, t); } - + // reject connection if no main input defined for current node if (selConnector != null && selConnector.getNode() != null && selConnector.getConnector() == null) { -// DropShadow shadow = new DropShadow(20, Color.RED); -// Glow effect = new Glow(0.8); -// effect.setInput(shadow); -// selConnector.getNode().setEffect(effect); - - //onConnectionIncompatible(); connectionListener.onNoConnection(selConnector.getNode()); - + lastNode = selConnector.getNode(); } - + if (selConnector != null && selConnector.getNode() != null && selConnector.getConnector() != null) { - + Connector receiverConnectorModel = selConnector.getConnector(); Node n = selConnector.getNode(); n.toFront(); - - VNode model = selConnector.getConnector().getNode(); - -// // we cannot create a connection from us to us -// if (model == getSender()) { -// return; -// } + ConnectionResult connResult = null; - + if (getSender().isInput() && receiverConnectorModel.isOutput()) { - + connResult = flow.tryConnect( receiverConnectorModel, getSender()); } else { connResult = flow.tryConnect( getSender(), receiverConnectorModel); } - + if (connResult.getStatus().isCompatible()) { - + if (lastNode != n) { - + connectionListener.onConnectionCompatible(n); } - - } else { -// DropShadow shadow = new DropShadow(20, Color.RED); -// Glow effect = new Glow(0.8); -// effect.setInput(shadow); -// n.setEffect(effect); + + } else { connectionListener.onConnectionIncompatible(); } - + receiverConnectorUI.toFront(); - + lastNode = n; } else { if (lastNode == null) { @@ -185,13 +168,13 @@ protected void makeDraggable() { (EventHandler) (MouseEvent t) -> { receiverConnectorUI.toBack(); connectionPath.toBack(); - + if (lastNode != null) { lastNode = null; } SelectedConnector selConnector = null; - + if (getSender().isOutput()) { selConnector = FXConnectorUtil.getSelectedInputConnector( getSender().getNode(), getParent(), type, t); @@ -199,45 +182,45 @@ protected void makeDraggable() { selConnector = FXConnectorUtil.getSelectedOutputConnector( getSender().getNode(), getParent(), type, t); } - + if (selConnector != null && selConnector.getNode() != null && selConnector.getConnector() != null) { - + Node n = selConnector.getNode(); - + n.toFront(); - + Connector receiverConnector = selConnector.getConnector(); - + ConnectionResult connResult = null; - + if (getSender().isInput() && receiverConnector.isOutput()) { connResult = flow.connect(receiverConnector, getSender()); connectionListener. onCreateNewConnectionReverseReleased(connResult); - + } else { connResult = flow.connect(getSender(), receiverConnector); connectionListener.onCreateNewConnectionReleased(connResult); } - + if (!connResult.getStatus().isCompatible()) { connectionListener.onConnectionIncompatibleReleased(n); } } - + remove(); }); } @Override public final void setSender(Connector n) { - + if (n==null) { throw new IllegalArgumentException("Sender 'null' not supported."); } - + senderProperty.set(n); } diff --git a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FlowNodeWindow.java b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FlowNodeWindow.java index 25b5e9c0..cb07d379 100644 --- a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FlowNodeWindow.java +++ b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/FlowNodeWindow.java @@ -174,7 +174,7 @@ private void initUI(final FXFlowNodeSkin skin) { }; } - // + // addCollapseIcon(skin); configureCanvas(skin); } @@ -224,7 +224,7 @@ private void initListenersAndBindings(final FXFlowNodeSkin skin) { // model.visibleProperty().addListener(new ChangeListener() { // @Override // public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { -// +// // for (Node n : content.getContentPane().getChildren()) { // if (n instanceof Window) { // Window w = (Window) n; @@ -232,7 +232,7 @@ private void initListenersAndBindings(final FXFlowNodeSkin skin) { // w.getContentPane().requestLayout(); // } // } -// +// //// System.out.println("TEST"); ////// parentContent.requestOptimization(); //// requestLayout(); @@ -423,14 +423,6 @@ private void connectorsToFront() { } private void configureCanvas(FXFlowNodeSkin skin) { - -// if (skin == null) { -// return; -// } -// -// if ((skin.getModel() instanceof VFlowModel)) { -// return; -// } if (content != null) { content.getStyleClass().setAll("vnode-content"); skin.configureCanvas(content); @@ -511,7 +503,7 @@ public void setHideMinimizeIconCallback(Callback c } private void initCaching() { - + localToSceneTransformProperty().addListener((ov)->{ Bounds bounds = this.localToScene(getBoundsInLocal()); if(bounds.getWidth()<10 || bounds.getHeight()<10) { @@ -520,41 +512,6 @@ private void initCaching() { setCache(true); } }); - -// -// boolean[] wasMoving = {false}; -// -// InvalidationListener cacheListener = (ov) -> { -// -// if (isMoving()) { -// setCache(true); -// Parent parent = getParent(); -// if (parent != null) { -// parent.getChildrenUnmodifiable().stream(). -// filter(n -> n instanceof FlowNodeWindow -// || n instanceof ConnectorCircle). -// forEach(n -> n.setCache(true)); -// } -// } else { -// setCache(false); -// System.out.println("was: " + wasMoving[0]); -// if (wasMoving[0]) { -// Parent parent = getParent(); -// if (parent != null) { -// parent.getChildrenUnmodifiable().stream(). -// filter(n -> n instanceof FlowNodeWindow -// || n instanceof ConnectorCircle). -// forEach(n -> n.setCache(false)); -// } -// } -// } -// -// wasMoving[0] = isMoving(); -// }; -// -// movingProperty().addListener(cacheListener); -// -// cacheProperty().addListener(state -> setTitle("cache: " + isCache())); } static class FlowStage extends Stage { diff --git a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/NodeUtil.java b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/NodeUtil.java index 61a5242b..b237844c 100644 --- a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/NodeUtil.java +++ b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/NodeUtil.java @@ -138,26 +138,15 @@ public static List getAncestors(Node n) { */ public static List getStylesheetsOfAncestors(Node n) { -// System.out.println(">> searching stylesheets of ancestors of: " + n); List result = new ArrayList<>(); if (n instanceof Parent) { - -// for (String css : ((Parent) n).getStylesheets()) { -// System.out.println(" --> n-css: " + css); -// } result.addAll(((Parent) n).getStylesheets()); } Scene scene = null; for (Parent p : getAncestors(n)) { - -// System.out.println(" --> parent: " + p); -// -// for (String css : p.getStylesheets()) { -// System.out.println(" --> p-css: " + p + ": " + css); -// } result.addAll(p.getStylesheets()); if (scene == null) { @@ -166,15 +155,7 @@ public static List getStylesheetsOfAncestors(Node n) { } if (scene != null) { - -// System.out.println(" --> scene: " + scene); result.addAll(scene.getStylesheets()); - -// for (String css : scene.getStylesheets()) { -// System.out.println(" --> scene-css: " + css); -// } -// -// System.out.println(" --> done"); } return result; @@ -297,57 +278,6 @@ public static Node getNode(Parent p, double sceneX, double sceneY, Class node return null; } - /** - * Returns the deepest node at the given location that is an instance of the - * specified class object. The search is performed recursively until either - * a node has been found or a leaf node is reached. - * - * @param p parent node - * @param sceneX x coordinate - * @param sceneY y coordinate - * @param nodeClasses node classes to search for - * @return a node that contains the specified screen coordinates and is an - * instance of the specified class or null if no such node - * exist - */ - /* - public static Node getDeepestNode(Parent p, double sceneX, double sceneY, Class... nodeClasses) { - - // dammit! javafx uses "wrong" children order. - List rightOrder = new ArrayList<>(); - rightOrder.addAll(p.getChildrenUnmodifiable()); - Collections.reverse(rightOrder); - - for (Node n : rightOrder) { - boolean contains = n.contains(n.sceneToLocal(sceneX, sceneY)); - - if (contains) { - - Node result = null; - - if (n instanceof Parent) { - result = getDeepestNode((Parent) n, sceneX, sceneY, nodeClasses); - } - - if (result == null) { - result = n; - } - - for (Class nodeClass : nodeClasses) { - - if (nodeClass.isAssignableFrom(result.getClass())) { - - return result; - - } - } - } - } - - return null; - } - */ - /** * Returns the first node at the given location that is an instance of the * specified class object. The search is performed recursively until either diff --git a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/OptimizableContentPane.java b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/OptimizableContentPane.java index 171fc92c..0c2b7613 100644 --- a/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/OptimizableContentPane.java +++ b/VWorkflows-FX/src/main/java/eu/mihosoft/vrl/workflow/fx/OptimizableContentPane.java @@ -91,10 +91,8 @@ private synchronized void updateOptimizationRule() { optimizing = true; -// if (transform == null) { transform = OptimizableContentPane.this. localToSceneTransformProperty().get(); -// } boolean visible = optimizationRule.visible(this, transform); @@ -108,15 +106,6 @@ private synchronized void updateOptimizationRule() { if (attachedReq) { getChildren().addAll(detatched); detatched.clear(); - -// for (Node n : getChildren()) { -// if (n instanceof Parent) { -// Parent p = (Parent) n; -// p.layout(); -// } -// } - - } else { detatched.addAll(getChildren()); getChildren().removeAll(detatched); @@ -205,4 +194,4 @@ public void setMinSceneDimension(double s) { public double getMinSceneDimension() { return minSceneDimension.get(); } -} \ No newline at end of file +} diff --git a/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkin.java b/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkin.java index 8c4f7553..3eb86329 100644 --- a/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkin.java +++ b/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkin.java @@ -272,7 +272,7 @@ private void init() { // } // } else if (change.wasUpdated()) { // //update item -// } else +// } else if (change.wasRemoved()) { for (String i : change.getRemoved()) { @@ -349,11 +349,6 @@ private void initMouseEventHandlers() { final double parentScaleY = n.getParent(). localToSceneTransformProperty().getValue().getMyy(); - final double scaleX = n.localToSceneTransformProperty(). - getValue().getMxx(); - final double scaleY = n.localToSceneTransformProperty(). - getValue().getMyy(); - Bounds boundsInScene = control.localToScene(control.getBoundsInLocal()); @@ -385,15 +380,7 @@ private void initMouseEventHandlers() { } } else { - - double width = n.getBoundsInLocal().getMaxX() - - n.getBoundsInLocal().getMinX(); - double height = n.getBoundsInLocal().getMaxY() - - n.getBoundsInLocal().getMinY(); - if (resizeTop) { -// System.out.println("TOP"); - double insetOffset = getSkinnable().getInsets().getTop() / 2; double yDiff @@ -409,8 +396,6 @@ private void initMouseEventHandlers() { } } if (resizeLeft) { -// System.out.println("LEFT"); - double insetOffset = getSkinnable().getInsets().getLeft() / 2; double xDiff = sceneX / parentScaleX @@ -427,8 +412,6 @@ private void initMouseEventHandlers() { } if (resizeBottom) { -// System.out.println("BOTTOM"); - double insetOffset = getSkinnable().getInsets().getBottom() / 2; double yDiff = event.getSceneY() / parentScaleY @@ -494,9 +477,6 @@ private void initMouseEventHandlers() { final Node n = control; - final double parentScaleX = n.getParent().localToSceneTransformProperty().getValue().getMxx(); - final double parentScaleY = n.getParent().localToSceneTransformProperty().getValue().getMyy(); - final double scaleX = n.localToSceneTransformProperty().getValue().getMxx(); final double scaleY = n.localToSceneTransformProperty().getValue().getMyy(); @@ -560,27 +540,6 @@ private void initMouseEventHandlers() { control.autosize(); }); - -// setOnScroll(new EventHandler() { -// @Override -// public void handle(ScrollEvent event) { -// -// if (!isZoomable()) { -// return; -// } -// -// double scaleValue = -// control.getScaleY() + event.getDeltaY() * getScaleIncrement(); -// -// scaleValue = Math.max(scaleValue, getMinScale()); -// scaleValue = Math.min(scaleValue, getMaxScale()); -// -// control.setScaleX(scaleValue); -// control.setScaleY(scaleValue); -// -// event.consume(); -// } -// }); } /** @@ -720,12 +679,10 @@ public void changed(ObservableValue ov, Number t, Number t1) { && control.getPrefHeight() < titleBar.minHeight(0) + control.getContentPane().minHeight(0)) { control.getContentPane().setVisible(false); -// System.out.println("v: false"); } else if (!control.isMinimized() && control.getPrefHeight() >= titleBar.minHeight(0) + control.getContentPane().minHeight(0)) { control.getContentPane().setVisible(true); -// System.out.println("v: true"); } } } @@ -755,15 +712,11 @@ public TitleBar(Window w) { setSpacing(8); -// label.setTextAlignment(TextAlignment.CENTER); -// label.getStyleClass().setAll(DEFAULT_STYLE_CLASS); leftIconPane = new IconPane(); rightIconPane = new IconPane(); getChildren().add(leftIconPane); -// getChildren().add(VFXLayoutUtil.createHBoxFiller()); getChildren().add(label); -// getChildren().add(VFXLayoutUtil.createHBoxFiller()); getChildren().add(rightIconPane); control.boundsInParentProperty().addListener( diff --git a/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkinLegacy.java b/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkinLegacy.java index 26095562..8f5c2f5a 100644 --- a/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkinLegacy.java +++ b/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkinLegacy.java @@ -129,8 +129,8 @@ private void init() { // } // } else if (change.wasUpdated()) { // //update item -// } else - +// } else + if (change.wasRemoved()) { for (WindowIcon i : change.getRemoved()) { titleBar.removeLeftIcon(i); @@ -153,8 +153,8 @@ private void init() { // } // } else if (change.wasUpdated()) { // //update item -// } else - +// } else + if (change.wasRemoved()) { for (WindowIcon i : change.getRemoved()) { titleBar.removeRightIcon(i); @@ -201,20 +201,12 @@ private void init() { (ObservableValue ov2, Status oldStatus, Status newStatus) -> { if (newStatus == Status.STOPPED) { - -// // restore cache hint -// getSkinnable().setCache(true); -// getSkinnable().setCacheHint(CacheHint.SPEED); minimizeTimeLine = null; if (newValue) { control.getContentPane().setVisible(false); } } }); - - // temporarily disable cache hint due to rendering bugs -// getSkinnable().setCache(false); -// getSkinnable().setCacheHint(CacheHint.DEFAULT); minimizeTimeLine.play(); }); @@ -236,23 +228,6 @@ private void init() { control.getContentPane().setManaged(false); -// InvalidationListener contentLayoutListener = (ov) -> { -// -// control.autosize(); -// root.autosize(); -// }; -// -// control.getContentPane().needsLayoutProperty().addListener(contentLayoutListener); -// -// control.contentPaneProperty().addListener( -// (ObservableValue ov, -// Pane oldValue, Pane newValue) -> { -// root.getChildren().remove(oldValue); -// root.getChildren().add(newValue); -// newValue.setManaged(false); -// newValue.needsLayoutProperty(). -// addListener(contentLayoutListener); -// }); titleBar.setStyle(control.getStyle()); control.styleProperty().addListener( @@ -281,7 +256,7 @@ private void init() { // } // } else if (change.wasUpdated()) { // //update item -// } else +// } else if (change.wasRemoved()) { for (String i : change.getRemoved()) { titleBar.getStylesheets().remove(i); @@ -308,8 +283,6 @@ private void init() { if (control.isSelectionEffectEnabled()) { ColorAdjust effect = new ColorAdjust(-0.25, 0.2, 0.8, 0); -// Glow glow = new Glow(0.5); -// glow.setInput(effect); control.setEffect(effect); } } else { @@ -320,37 +293,6 @@ private void init() { getSkinnable().setCacheHint(CacheHint.SPEED); -// control.resizingProperty().addListener((ov) -> { -// control.setCache(control.isResizing()); -// }); - // counter intuitive caching (see http://bit.ly/1MemgLz why) -// control.resizingProperty().addListener((ov) -> { -// control.setCache(!control.isResizing()); -// }); -// -// InvalidationListener cacheListener = (ov) -> { -// if (!control.isResizing()) { -// control.setCache( -// !control.isResizing() -// && !control.getParent().isCache() -// ); -// } else { -// control.setCache(false); -// } -// }; -// Parent p = control.getParent(); -// if (p != null) { -// p.cacheProperty().addListener(cacheListener); -// } -// control.parentProperty().addListener((ov, oldV, newV) -> { -// if (oldV != null) { -// oldV.cacheProperty().removeListener(cacheListener); -// } -// if (newV != null) { -// newV.cacheProperty().addListener(cacheListener); -// } -// }); - Rectangle clipRectangle = new Rectangle(); control.getContentPane().setClip(clipRectangle); control.layoutBoundsProperty().addListener((observable, oldValue, newValue) -> { @@ -434,14 +376,7 @@ private void initMouseEventHandlers() { } else { - double width = n.getBoundsInLocal().getMaxX() - - n.getBoundsInLocal().getMinX(); - double height = n.getBoundsInLocal().getMaxY() - - n.getBoundsInLocal().getMinY(); - if (resizeTop) { -// System.out.println("TOP"); - double insetOffset = getSkinnable().getInsets().getTop() * 0.5; double yDiff @@ -457,8 +392,6 @@ private void initMouseEventHandlers() { } } if (resizeLeft) { -// System.out.println("LEFT"); - double insetOffset = getSkinnable().getInsets().getLeft() * 0.5; double xDiff = sceneX / parentScaleX @@ -509,14 +442,6 @@ private void initMouseEventHandlers() { control.setPrefWidth(newWidth); } } - -// if (RESIZE_BOTTOM || RESIZE_TOP || RESIZE_LEFT || RESIZE_RIGHT) { -// getSkinnable().setCache(false); -// -// } else { -// getSkinnable().setCache(true); -// getSkinnable().setCacheHint(CacheHint.DEFAULT); -// } } mouseX = event.getSceneX(); @@ -543,10 +468,6 @@ private void initMouseEventHandlers() { final Node n = control; - final double parentScaleX = n.getParent(). - localToSceneTransformProperty().getValue().getMxx(); - final double parentScaleY = n.getParent(). - localToSceneTransformProperty().getValue().getMyy(); final double scaleX = n.localToSceneTransformProperty().getValue().getMxx(); final double scaleY = n.localToSceneTransformProperty().getValue().getMyy(); @@ -722,15 +643,13 @@ protected void layoutChildren(double x, double y, double w, double h) { double leftAndRight = getSkinnable().getInsets().getLeft() + getSkinnable().getInsets().getRight(); - double topAndBottom = getSkinnable().getInsets().getTop() - + getSkinnable().getInsets().getBottom(); control.getContentPane().relocate( getSkinnable().getInsets().getLeft(), titleBar.prefHeight(-1)); - double rootW = root.getWidth(); //Math.max(root.getWidth(), root.getMinWidth()); - double rootH = root.getHeight();//Math.max(root.getHeight(), root.getMinHeight()); + double rootW = root.getWidth(); + double rootH = root.getHeight(); double contentWidth = rootW - leftAndRight; double contentHeight = rootH - getSkinnable().getInsets(). @@ -775,10 +694,8 @@ public double computeMinWidth() { protected double computePrefWidth(double width, double topInset, double rightInset, double bottomInset, double leftInset) { - double result = computeMinWidth( + return computeMinWidth( width, topInset, rightInset, bottomInset, leftInset); - - return result; } @Override @@ -869,12 +786,10 @@ public void changed(ObservableValue ov, Number t, Number t1) { && control.getPrefHeight() < titleBar.minHeight(0) + control.getContentPane().minHeight(0)) { control.getContentPane().setVisible(false); -// System.out.println("v: false"); } else if (!control.isMinimized() && control.getPrefHeight() >= titleBar.minHeight(0) + control.getContentPane().minHeight(0)) { control.getContentPane().setVisible(true); -// System.out.println("v: true"); } } } @@ -905,16 +820,11 @@ public TitleBarLegacy(Window w) { getStyleClass().setAll(DEFAULT_STYLE_CLASS); setSpacing(8); - -// label.setTextAlignment(TextAlignment.CENTER); -// label.getStyleClass().setAll(DEFAULT_STYLE_CLASS); leftIconPane = new IconPane(); rightIconPane = new IconPane(); getChildren().add(leftIconPane); -// getChildren().add(VFXLayoutUtil.createHBoxFiller()); getChildren().add(label); -// getChildren().add(VFXLayoutUtil.createHBoxFiller()); getChildren().add(rightIconPane); control.boundsInParentProperty().addListener( @@ -925,20 +835,7 @@ public TitleBarLegacy(Window w) { return; } - double maxIconWidth = Math.max( - leftIconPane.getWidth(), rightIconPane.getWidth()); - -// if (!control.getTitle().equals(getLabel().getText())) { -// if (originalTitleWidth -// + maxIconWidth * 2 + offset < getWidth()) { getLabel().setText(control.getTitle()); -// } -// } else if (!"...".equals(getLabel().getText())) { -// if (originalTitleWidth -// + maxIconWidth * 2 + offset >= getWidth()) { -// getLabel().setText("..."); -// } -// } }); } diff --git a/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkinSimplified.java b/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkinSimplified.java index 699ecb6f..d00433c1 100644 --- a/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkinSimplified.java +++ b/VWorkflows-FX/src/main/java/jfxtras/internal/scene/control/skin/window/DefaultWindowSkinSimplified.java @@ -258,7 +258,7 @@ private void init() { // } // } else if (change.wasUpdated()) { // //update item -// } else +// } else if (change.wasRemoved()) { for (String i : change.getRemoved()) { @@ -372,14 +372,7 @@ private void initMouseEventHandlers() { } else { - double width = n.getBoundsInLocal().getMaxX() - - n.getBoundsInLocal().getMinX(); - double height = n.getBoundsInLocal().getMaxY() - - n.getBoundsInLocal().getMinY(); - if (resizeTop) { -// System.out.println("TOP"); - double insetOffset = getSkinnable().getInsets().getTop() / 2; double yDiff @@ -395,8 +388,6 @@ private void initMouseEventHandlers() { } } if (resizeLeft) { -// System.out.println("LEFT"); - double insetOffset = getSkinnable().getInsets().getLeft() / 2; double xDiff = sceneX / parentScaleX @@ -413,8 +404,6 @@ private void initMouseEventHandlers() { } if (resizeBottom) { -// System.out.println("BOTTOM"); - double insetOffset = getSkinnable().getInsets().getBottom() / 2; double yDiff = event.getSceneY() / parentScaleY @@ -480,9 +469,6 @@ private void initMouseEventHandlers() { final Node n = control; - final double parentScaleX = n.getParent().localToSceneTransformProperty().getValue().getMxx(); - final double parentScaleY = n.getParent().localToSceneTransformProperty().getValue().getMyy(); - final double scaleX = n.localToSceneTransformProperty().getValue().getMxx(); final double scaleY = n.localToSceneTransformProperty().getValue().getMyy(); @@ -547,26 +533,6 @@ private void initMouseEventHandlers() { control.autosize(); }); -// setOnScroll(new EventHandler() { -// @Override -// public void handle(ScrollEvent event) { -// -// if (!isZoomable()) { -// return; -// } -// -// double scaleValue = -// control.getScaleY() + event.getDeltaY() * getScaleIncrement(); -// -// scaleValue = Math.max(scaleValue, getMinScale()); -// scaleValue = Math.min(scaleValue, getMaxScale()); -// -// control.setScaleX(scaleValue); -// control.setScaleY(scaleValue); -// -// event.consume(); -// } -// }); } /** @@ -741,15 +707,11 @@ public TitleBarSimplified(Window w) { setSpacing(8); -// label.setTextAlignment(TextAlignment.CENTER); -// label.getStyleClass().setAll(DEFAULT_STYLE_CLASS); leftIconPane = new IconPane(); rightIconPane = new IconPane(); getChildren().add(leftIconPane); -// getChildren().add(VFXLayoutUtil.createHBoxFiller()); getChildren().add(label); -// getChildren().add(VFXLayoutUtil.createHBoxFiller()); getChildren().add(rightIconPane); control.boundsInParentProperty().addListener( diff --git a/VWorkflows-FX/src/main/java/jfxtras/labs/util/event/MouseControlUtil.java b/VWorkflows-FX/src/main/java/jfxtras/labs/util/event/MouseControlUtil.java index a134fca2..25f0eafc 100644 --- a/VWorkflows-FX/src/main/java/jfxtras/labs/util/event/MouseControlUtil.java +++ b/VWorkflows-FX/src/main/java/jfxtras/labs/util/event/MouseControlUtil.java @@ -215,9 +215,6 @@ public static void makeDraggable(final Node n, _makeDraggable(n, dragHandlerGroup, pressHandlerGroup, centerNode); } -// public static void makeResizable(Node n) { -// -// } private static void _makeDraggable( final Node n, EventHandlerGroup dragHandler, @@ -371,12 +368,6 @@ private void init(final Parent root, final Rectangle rect) { this.root = root; -// root.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() { -// @Override -// public void handle(MouseEvent t) { -// WindowUtil.getDefaultClipboard().unselectAll(); -// } -// }); mouseDraggedEventHandler = new EventHandler() { @Override public void handle(MouseEvent event) { diff --git a/VWorkflows-FX/src/main/java/jfxtras/scene/control/window/Window.java b/VWorkflows-FX/src/main/java/jfxtras/scene/control/window/Window.java index c245d689..9c46d93f 100644 --- a/VWorkflows-FX/src/main/java/jfxtras/scene/control/window/Window.java +++ b/VWorkflows-FX/src/main/java/jfxtras/scene/control/window/Window.java @@ -168,7 +168,7 @@ public class Window extends Control implements SelectableNode { */ private final BooleanProperty selectableProperty = new SimpleBooleanProperty(true); - /* + /* * Closed property (defines whether window is closed). */ private final BooleanProperty closeRequested = new SimpleBooleanProperty(); @@ -340,8 +340,8 @@ public void changed(ObservableValue observableValue, initializeMovingPropertyMonitor(); initializeResizingPropertyMonitor(); - - + + } @@ -349,14 +349,8 @@ private void initializeResizingPropertyMonitor() { // detects whether the window is currently moving boolean[] timerTaskSet = {false}; double[] wh = {0, 0}; -// int[] cancelledTasks = {0}; InvalidationListener resizingListener = (ov) -> { -// // purge cancelled tasks regularily to prevent memory leaks -// if (cancelledTasks[0] > 1000) { -// timer[0].purge(); -// cancelledTasks[0] = 0; -// } if (!timerTaskSet[0]) { timerTaskSet[0] = true; timer.scheduleAtFixedRate(new TimerTask() { @@ -392,15 +386,8 @@ private void initializeMovingPropertyMonitor() { // detects whether the window is currently moving boolean [] timerTaskSet = {false}; double[] xy = {0, 0}; -// boolean[] running = {false}; -// int[] cancelledTasks = {0}; InvalidationListener movingListener = (ov) -> { -// // purge cancelled tasks regularily to prevent memory leaks -// if (cancelledTasks[0] > 1000) { -// timer[0].purge(); -// cancelledTasks[0] = 0; -// } if (!timerTaskSet[0] && (getLayoutX() != 0 || getLayoutY() != 0)) { timerTaskSet[0] = true; timer.scheduleAtFixedRate(new TimerTask() { @@ -458,18 +445,12 @@ private void closeSelectedWindows() { } public double minWidthWithTitle() { - if (getSkin() instanceof DefaultWindowSkin) { - DefaultWindowSkin skin = (DefaultWindowSkin) getSkin(); -// return skin.computeMinWidth(); - } - return minWidth(0); } @Override protected double computeMinWidth(double height) { - double result = super.computeMinWidth(height); - return result; + return super.computeMinWidth(height); } // TODO move from control to behavior class (a lot of other stuff here too) @@ -752,7 +733,7 @@ public double getResizableBorderWidth() { */ public void close() { - // if already closed, we do nothing + // if already closed, we do nothing if (this.getParent() == null) { return; } diff --git a/VWorkflows-FX/src/main/java/jfxtras/scene/control/window/WindowUtil.java b/VWorkflows-FX/src/main/java/jfxtras/scene/control/window/WindowUtil.java index 592c8881..500e9533 100644 --- a/VWorkflows-FX/src/main/java/jfxtras/scene/control/window/WindowUtil.java +++ b/VWorkflows-FX/src/main/java/jfxtras/scene/control/window/WindowUtil.java @@ -48,7 +48,7 @@ * @author Michael Hoffer <info@michaelhoffer.de> */ public class WindowUtil { - + private static Clipboard clipboard; /** @@ -62,11 +62,11 @@ public class WindowUtil { * @see jfxtras.scene.control.window.SelectableNode */ public static Clipboard getDefaultClipboard() { - + if (clipboard == null) { clipboard = new ClipboardImpl(); } - + return clipboard; } } @@ -77,10 +77,10 @@ public static Clipboard getDefaultClipboard() { * @author Michael Hoffer <info@michaelhoffer.de> */ class ClipboardImpl implements Clipboard { - + private final ObservableList items = FXCollections.observableArrayList(); - + @Override public boolean select(SelectableNode n, boolean selected) { if (n.requestSelection(selected)) { @@ -91,24 +91,23 @@ public boolean select(SelectableNode n, boolean selected) { } else { items.remove(n); } - + return true; } else { return false; } } - + @Override public ObservableList getSelectedItems() { return items; } - + @Override public void deselectAll() { - - List unselectList = new ArrayList<>(); - unselectList.addAll(items); - + + List unselectList = new ArrayList<>(items); + for (SelectableNode sN : unselectList) { select(sN, false); }