X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fscenegraph%2Fstructural%2FConnection.java;h=bd8ade64c0222fe70b207a6f9ce6380444949f11;hb=HEAD;hp=c43ca12ff2412bda1f9b07ecbadde2bedc014088;hpb=289aaab900078ef56efc8779e4b15830e472149e;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/Connection.java b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/Connection.java index c43ca12f..bd8ade64 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/Connection.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/Connection.java @@ -19,42 +19,42 @@ import org.simantics.db.Resource; import org.simantics.objmap.structural.IStructuralObject; @SuppressWarnings("rawtypes") -public abstract class Connection implements IStructuralObject{ +public abstract class Connection, T2 extends IComponentNode> implements IStructuralObject{ + private List connects = new ArrayList(); - private List connects = new ArrayList(); - - - public void addConnect(T node) { + public void addConnect(T2 node) { if (!connects.contains(node)) connects.add(node); fireChanged(node,true); } - protected void fireChanged(T node, boolean add){ - for (IComponentNode n : connects) { - n.connectionChanged(this,node,add); + @SuppressWarnings("unchecked") + protected void fireChanged(T2 node, boolean add){ + for (T2 n : connects) { + n.connectionChanged((T) this,node,add); } } - public Collection getConnected() { + public Collection getConnected() { return connects; } - public void removeConnect(T node) { + public void removeConnect(T2 node) { connects.remove(node); fireChanged(node,false); } + @SuppressWarnings("unchecked") public void remove() { - List toRemove = new ArrayList(connects.size()); + List toRemove = new ArrayList(connects.size()); toRemove.addAll(connects); for (IComponentNode node : toRemove) { - node.removeConnection(this); + node.removeConnection((T) this); } } - public T getOther(T node) { + public T2 getOther(IComponentNode node) { if (connects.size() != 2) return null; if (connects.get(0).equals(node))