[Mmil-commits] r35 - trunk/src/fr/loria/led/mmil

alexandredenis at users.gforge.inria.fr alexandredenis at users.gforge.inria.fr
Mar 6 Mai 17:42:37 CEST 2008


Author: alexandredenis
Date: 2008-05-06 17:42:35 +0200 (Tue, 06 May 2008)
New Revision: 35

Modified:
   trunk/src/fr/loria/led/mmil/MMILComponent.java
Log:
Added a default copy constructor.


Modified: trunk/src/fr/loria/led/mmil/MMILComponent.java
===================================================================
--- trunk/src/fr/loria/led/mmil/MMILComponent.java	2008-05-06 15:38:28 UTC (rev 34)
+++ trunk/src/fr/loria/led/mmil/MMILComponent.java	2008-05-06 15:42:35 UTC (rev 35)
@@ -134,6 +134,50 @@
 
 
     /**
+        Copy constructor excluding external entities.
+        @param mmil - the component to copy
+    */
+	public MMILComponent(MMILComponent mmil)
+	{
+		entities  = new ArrayList<MMILEntity>();
+        relations = new ArrayList<MMILRelation>();
+
+        List<String> added = new ArrayList<String>();
+
+        // add all entities
+        for(MMILEntity entity : mmil.getEntities())
+        {
+            if (entity.getMMILType().equals("participant"))
+                entities.add(new MMILParticipant((MMILParticipant) entity));
+            else entities.add(new MMILEvent((MMILEvent) entity));
+            added.add(entity.getId());
+        }
+
+        // add all relations, don't add null source or null target relations
+        for(MMILRelation rel : mmil.getRelations())
+        {
+            MMILEntity source,target;
+            MMILEntity sourceOrigin = rel.getSource();
+            MMILEntity targetOrigin = rel.getTarget();
+
+            if (sourceOrigin==null || targetOrigin==null)
+                continue;
+            
+            if (added.contains(sourceOrigin.getId()) && added.contains(targetOrigin.getId()))
+            {
+                source = getEntity(sourceOrigin.getId());
+                target = getEntity(targetOrigin.getId());
+                relations.add(new MMILRelation(rel.getType(), source, target, rel.isModifierDirected()));
+            }
+        }
+
+        left    = mmil.getLeft();
+        right   = mmil.getRight(); 
+        shift   = mmil.getShift();
+        segment = mmil.getSegment();
+    }
+
+    /**
         Copy constructor.
         If includeExtern is true, include a copy of all the relations whose source or
         target is external to the given component plus a copy of all entities that are






Plus d'informations sur la liste de diffusion Mmil-commits