Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup code #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,16 @@
* @author Michael Hoffer <[email protected]>
*/
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,9 @@ class ConnectionBase implements Connection {
private Connector sender;
private Connector receiver;

// private ObjectProperty<Skin> 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;
Expand All @@ -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();
Expand All @@ -95,10 +83,6 @@ private void updateConnection() {
}
}

// @Override
// public String getReceiverId() {
// return receiverId;
// }
@Override
public void setReceiver(Connector r) {
this.receiverId = r.getId();
Expand Down Expand Up @@ -153,20 +137,6 @@ private ObjectProperty<VisualizationRequest> _visualizationRequestProperty() {
public ReadOnlyProperty<VisualizationRequest> 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
Expand Down Expand Up @@ -233,7 +203,7 @@ public Connector getSender() {
public Connector getReceiver() {
return receiver;
}

@Override
public boolean isVisualizationRequestInitialized() {
return vReqProperty != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ public interface ConnectionResult {
* @return the connection
*/
Connection getConnection();

// List<Connection> getPath();

/**
* Get the status of the connection.
* Get the status of the connection.
* @return the status of the connection
*/
CompatibilityResult getStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,10 @@ class ConnectionsImpl implements Connections {
private String type;
private Map<String, Connection> connections = new HashMap<>();
private Class<? extends Connection> connectionClass = ConnectionBase.class;
// Map<String, Integer> senders = new HashMap<>();
// Map<String, Integer> receivers = new HashMap<>();
private ObservableList<Connection> observableConnections
= FXCollections.observableArrayList();
private ObjectProperty<VisualizationRequest> vReqProperty;

// private ObjectProperty<Skin> skinProperty = new SimpleObjectProperty<>();
public ConnectionsImpl(String type) {
this.type = type;
}
Expand Down Expand Up @@ -119,9 +116,6 @@ public void remove(Connection c) {
connections.remove(connectionId(c));

observableConnections.remove(c);

// decSenderCounter(c.getSenderId());
// decReceiverCounter(c.getReceiverId());
}

@Override
Expand All @@ -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<? extends Connection> 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)");
Expand All @@ -159,11 +150,11 @@ public Class<? extends Connection> 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.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -183,22 +180,17 @@ 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<Connection> connectionsToRemove
= cns.getAllWithNode(n);

for (Connection c : connectionsToRemove) {
cns.remove(c);
// removeConnectionSkin(c);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ public FlowNodeSkinLookupImpl(VFlow root) {

@Override
public List<VNodeSkin> getById(String globalId) {

List<VNodeSkin> result = getNodeByGlobalId(root, globalId);

return result;
return getNodeByGlobalId(root, globalId);
}

private List<VNodeSkin> getNodeByGlobalId(VFlow parent, String id) {
Expand All @@ -77,7 +74,6 @@ private List<VNodeSkin> 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;

Expand All @@ -90,18 +86,13 @@ 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)) {
List<VNodeSkin> s2 = flow.getNodeSkinsById(id);
return getBySkinFactory(sF, s2);
}
}
//
// System.out.println(" --> nothing found :(");

return null;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -197,15 +181,7 @@ public ConnectionSkin<?> getById(SkinFactory skinFactory, Connection c) {

VFlowImpl flowImpl = (VFlowImpl) flow;

ConnectionSkin<Connection> skin = flowImpl.getConnectionSkinMap(skinFactory).get(
return (ConnectionSkin<Connection>) flowImpl.getConnectionSkinMap(skinFactory).get(
VFlowImpl.connectionId(c));

// for (String key : flowImpl.getConnectionSkinMap(skinFactory).keySet()) {
// ConnectionSkin<Connection> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@
class IdGeneratorImpl implements IdGenerator {

private Set<String> ids = new HashSet<>();
// private int lastId = 0;

public IdGeneratorImpl() {
//
}

@Override
Expand All @@ -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 + "-";
}
Expand All @@ -81,8 +79,6 @@ public String newId(String prefix) {

ids.add(id);

// lastId = counter;

return id;
}

Expand All @@ -93,8 +89,7 @@ public String newId() {

@Override
public Set<String> getIds() {
Set<String> result = new HashSet<>(ids);
return result;
return new HashSet<>(ids);
}

@Override
Expand Down
Loading