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

alexandredenis at users.gforge.inria.fr alexandredenis at users.gforge.inria.fr
Mar 3 Oct 12:20:31 CEST 2006


Author: alexandredenis
Date: 2006-10-03 10:20:30 +0000 (Tue, 03 Oct 2006)
New Revision: 17

Modified:
   trunk/src/fr/loria/led/mmil/MMILComponent.java
   trunk/src/fr/loria/led/mmil/MMILEntity.java
Log:
Added an aggregate serial method


Modified: trunk/src/fr/loria/led/mmil/MMILComponent.java
===================================================================
--- trunk/src/fr/loria/led/mmil/MMILComponent.java	2006-10-03 08:51:21 UTC (rev 16)
+++ trunk/src/fr/loria/led/mmil/MMILComponent.java	2006-10-03 10:20:30 UTC (rev 17)
@@ -492,13 +492,61 @@
     }
 
 
+    /**
+        Move the relations of the first entity to the second entity.
+        @param e1 the first entity
+        @param e2 the second entity
+    */
+    public void moveRelations(MMILEntity e1, MMILEntity e2)
+    {
+        for(MMILRelation rel : getRelationsByEntitySource(e1))
+            rel.setSource(e2);
+        
+        for(MMILRelation rel : getRelationsByEntityTarget(e1))
+            rel.setTarget(e2);
+    }
  
 
+    /**
+        Aggregate the entities of this component serially.
+        It tries to unify the entities sorted along their left index, ie. the unification of each entity
+        is tested with its successor.
+    */
+    public void aggregateSerial()
+    {
+        List<MMILEntity> newEntities = new ArrayList<MMILEntity>();
+        sortEntities();
+        for(int i=0; i<entities.size()+1; i++)
+        {
+            MMILEntity ent1 = entities.get(i);
+            MMILEntity ent2 = entities.get(i+1);
+            MMILEntity unif = ent1.unify(ent2);
+            if (unif!=null)
+            {
+                moveRelations(ent1, unif);
+                moveRelations(ent2, unif);
+                newEntities.add(unif);
+            }
+        }
+        setEntities(newEntities);
+    }       
+
+
 /////////////////////
 // ENTITIES METHODS
 /////////////////////
 
     /**
+		Set the entities of this component.
+        @param entities the new entities of this component
+	*/
+	public void setEntities(List<MMILEntity> entities)
+	{
+        this.entities = entities;
+	}
+
+
+    /**
         Test if this component contains the given entity.
         @return true if the component contains the given entity.
     */
@@ -736,7 +784,6 @@
     {
         // Creates standard ent. ids of the form : eid[0-9]+
         int nId = entities.size();
-        ;
     
         while(getEntity(String.valueOf(nId))!=null)
             nId ++;  
@@ -760,6 +807,16 @@
 
 
     /**
+		Set the relations of this component.
+        @param relations the new relations of this component
+	*/
+	public void setRelations(List<MMILRelation> relations)
+	{
+        this.relations = relations;
+	}
+
+
+    /**
 		Retrieve all the relations.
         @return all the relations of this component.
 	*/

Modified: trunk/src/fr/loria/led/mmil/MMILEntity.java
===================================================================
--- trunk/src/fr/loria/led/mmil/MMILEntity.java	2006-10-03 08:51:21 UTC (rev 16)
+++ trunk/src/fr/loria/led/mmil/MMILEntity.java	2006-10-03 10:20:30 UTC (rev 17)
@@ -234,7 +234,7 @@
 	{
 		MMILEntity e = (MMILEntity) entity;
 
-		return getIndex()-e.getIndex();
+		return getLeftIndex()-e.getLeftIndex();
 	}
 
 






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