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=3d51c0d674afdad4413a16ac104ee111c7031dfc;hp=9f96205b5298c78c7a1d693e9d5a17b358d84706;hpb=87b3241ec277ba3d8e414b26186a032c9cdcaeed;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 9f96205b..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 @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2012, 2013 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ package org.simantics.g3d.scenegraph.structural; import java.util.ArrayList; @@ -8,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))