ANIMATOR : Implements AnimatorPredefinedAnimationFactory and AnimatorModelFactory 75/17875/1
authorseongwon.shim <seongwon.shim@samsung.com>
Wed, 12 Mar 2014 02:17:20 +0000 (11:17 +0900)
committerseongwon.shim <seongwon.shim@samsung.com>
Wed, 12 Mar 2014 02:17:20 +0000 (11:17 +0900)
AnimatorPredefinedAnimationFactory is class that create predefined animation keyframes and AnimatorModelFactory is factory class for animator related class

Change-Id: Iaf2da55aaf483ea52a22ce68d474fab83e1b0a13
Signed-off-by: seongwon.shim <seongwon.shim@samsung.com>
38 files changed:
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/ActionAnimationGroupRemoveCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/ActoinAnimationGroupChangeCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/ActoinAnimationGroupCreateCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/ActoinCreateCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/AnimationCreateAndChangeFrameCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/AnimationCreateCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/AnimationPathCurveCreateCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimationPathModel.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorAction.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorActionAnimation.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorAnimation.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorCurveFrame.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorFrame.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorKeyframe.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModel.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModelFactory.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModelManager.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModelType.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorPredefinedAnimationFactory.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorSelector.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorTrigger.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorWidget.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/AnimatorActionAnimationDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/AnimatorAnimationDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/AnimatorCurveFrameDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/AnimatorFrameDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/AnimatorKeyframeDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/AnimatorModelDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/AnimatorSelectorDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/AnimatorTriggerDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/AnimatorWidgetDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/PagePartDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/WidgetPartDeserializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/io/AnimatorFileReader.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/io/AnimatorFileWriter.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/part/AnimatorPagePart.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/command/TimelineFrameCreateCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/editor/PageDesignerToolbar.java

index eb3f018..c5cad14 100644 (file)
@@ -29,7 +29,6 @@ import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
-import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.app.AppManager;
 
 
index e3bdde9..25d609e 100644 (file)
@@ -29,7 +29,6 @@ import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
-import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.app.AppManager;
 import org.tizen.webuibuilder.ui.views.properties.action.ActionAnimationGroupComposite.ActionAnimationGroupTypes;
 
index 5b7f6d4..790c35a 100644 (file)
@@ -29,7 +29,6 @@ import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
-import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.app.AppManager;
 import org.tizen.webuibuilder.ui.views.properties.action.ActionAnimationGroupComposite.ActionAnimationGroupTypes;
 
index 4c980b9..5887995 100644 (file)
@@ -33,7 +33,6 @@ import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
-import org.tizen.webuibuilder.model.Part;
 
 
 /**
@@ -41,7 +40,7 @@ import org.tizen.webuibuilder.model.Part;
  */
 public class ActoinCreateCommand extends Command {
 
-    private AnimatorPart selelectModel;
+    private AnimatorPart seleectModel;
     private AnimatorAnimation animation;
     private String method;
     private String triggerName;
@@ -57,7 +56,7 @@ public class ActoinCreateCommand extends Command {
      */
     public ActoinCreateCommand(AnimatorPart model, String triggerName, AnimatorAnimation animation,
             String method, String selectedWidget) {
-        this.selelectModel = model;
+        this.seleectModel = model;
         this.animation = animation;
         this.method = method;
         this.triggerName = triggerName;
@@ -73,7 +72,7 @@ public class ActoinCreateCommand extends Command {
      */
     public ActoinCreateCommand(AnimatorPart model, String triggerName, AnimatorAnimation animation,
             String method) {
-        this.selelectModel = model;
+        this.seleectModel = model;
         this.animation = animation;
         this.method = method;
         this.triggerName = triggerName;
@@ -90,7 +89,7 @@ public class ActoinCreateCommand extends Command {
         AnimatorTrigger preparedTrigger = null;
 
         /* check the trigger has already been */
-        List<AnimatorTrigger> triggers = selelectModel.getTriggers();
+        List<AnimatorTrigger> triggers = seleectModel.getTriggers();
         for (AnimatorTrigger predefinedTrigger : triggers) {
             if (triggerName.equals(predefinedTrigger.getId())) {
                 /* do not make trigger */
@@ -103,10 +102,9 @@ public class ActoinCreateCommand extends Command {
                 AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
 
         if (preparedTrigger == null) {
-            preparedTrigger =
-                    new AnimatorTrigger(
-                                        animatorModelManager.idGenerator(AnimatorModelType.TRIGGER),
-                                        triggerName, selelectModel);
+            preparedTrigger = (AnimatorTrigger)animatorModelManager.getModelFactory().createAnimatorModel(AnimatorModelType.TRIGGER);
+            preparedTrigger.setEventName(triggerName);
+            preparedTrigger.setPartLink(seleectModel);
         }
 
         AnimatorActionAnimation preparedActionAnimation = null;
@@ -118,7 +116,9 @@ public class ActoinCreateCommand extends Command {
         // }
 
         if (preparedActionAnimation == null) {
-            AnimatorActionAnimation actionAnimation = new AnimatorActionAnimation();
+            AnimatorActionAnimation actionAnimation = (AnimatorActionAnimation)
+                       animatorModelManager.getModelFactory().createAnimatorModel(AnimatorModelType.ACTION_ANIMATION);
+            
             actionAnimation.setParent(preparedTrigger);
             actionAnimation.setAnimation(animation);
             actionAnimation.setActionType(method);
@@ -129,7 +129,7 @@ public class ActoinCreateCommand extends Command {
             // preparedTrigger.addAction(actionAnimation);
             preparedTrigger.addChild(actionAnimation);
 
-            selelectModel.addTrigger(preparedTrigger);
+            seleectModel.addTrigger(preparedTrigger);
         }
     }
 
index ca37de3..396da69 100644 (file)
@@ -71,7 +71,7 @@ public class AnimationCreateAndChangeFrameCommand extends Command {
         AnimatorModelManager animatorModelManager =
                 AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
         oldProperties =
-                animatorModelManager.createOrEditAnimatorFrame(selector, currentTime, properties,
+                animatorModelManager.createOrEditAnimatorFrame(animatorModelManager.getModelFactory(), selector, currentTime, properties,
                                                                origin);
     }
 
index 4768b7c..6963f20 100644 (file)
@@ -89,10 +89,7 @@ public class AnimationCreateCommand extends Command {
 
             if (frames == null) {
                 frames =
-                        animatorModelManager.createPredefinedFrames(animationGroupId, target,
-                                                                    selector,
-                                                                    preDefinedAnimationDescriptor,
-                                                                    delay);
+                               animatorModelManager.getPredefinedAnimationFactory().createPredefinedFrames(preDefinedAnimationDescriptor, delay);
             }
 
             animatorModelManager
index c1fac3a..39b0587 100644 (file)
 
 package org.tizen.webuibuilder.animator.gef.command;
 
+import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
+import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
+
 /**
  * A AnimationPathCurveCreateCommand class
  */
 public class AnimationPathCurveCreateCommand extends AnimationPathCommand {
 
     public void execute() {
-        getModel().insertCurveToModel(getIndex(), getCurveIndex(),
+        AnimatorModelManager animatorModelManager =
+                 AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
+        
+        getModel().insertCurveToModel(animatorModelManager.getModelFactory(), getIndex(), getCurveIndex(),
                                       getModel().getCurve(getIndex(), getCurveIndex()));
         super.execute();
     }
index b286e00..60a9b44 100644 (file)
@@ -67,7 +67,7 @@ public class AnimationPathModel implements IPropertySource {
      * 
      * @return the css keyframes
      */
-    public List<AnimatorFrame> getCssKeyframes() {
+    public List<AnimatorFrame> getCssKeyframes(AnimatorModelFactory modelFactory) {
         List<AnimatorFrame> frames = new ArrayList<AnimatorFrame>();
 
         Dimension translateInDesigner = selector.getPartLink().getWidgetPosition().getTranslate();
@@ -95,7 +95,7 @@ public class AnimationPathModel implements IPropertySource {
                         getCurveFramePoints(frame, nextFrame, translateInDesigner.width,
                                             translateInDesigner.height);
 
-                List<AnimatorFrame> curves = getCurveFrames(pointList, location, frame, nextFrame);
+                List<AnimatorFrame> curves = getCurveFrames(modelFactory, pointList, location, frame, nextFrame);
 
                 curves.remove(curves.size() - 1);
 
@@ -411,10 +411,10 @@ public class AnimationPathModel implements IPropertySource {
      * @param curve
      *            the curve
      */
-    public void insertCurveToModel(int frameIndex, int curveIndex, AnimationPathCurve curve) {
+    public void insertCurveToModel(AnimatorModelFactory modelFactory, int frameIndex, int curveIndex, AnimationPathCurve curve) {
         AnimatorFrame frame = keyframes.get(frameIndex).getFrameForModel();
-
-        AnimatorCurveFrame modelCurve = new AnimatorCurveFrame();
+        
+        AnimatorCurveFrame modelCurve = (AnimatorCurveFrame)modelFactory.createAnimatorModel(AnimatorModelType.CURVEFRAME);
         convertCurveToModel(getLastCss(frameIndex), curve, modelCurve);
         frame.addCurveFrame(curveIndex, modelCurve);
         fireModelChangeEvent(frame, true);
@@ -635,7 +635,7 @@ public class AnimationPathModel implements IPropertySource {
      *            the transition
      * @return the point
      */
-    public static Point findTranslateValueAtTime(double time, AnimatorFrame frame,
+    public static Point findTranslateValueAtTime(AnimatorModelFactory modelFactory, double time, AnimatorFrame frame,
                                                  AnimatorFrame nextFrame, EasingMethod transition) {
 
         int left, top;
@@ -645,7 +645,7 @@ public class AnimationPathModel implements IPropertySource {
         Point location = new Point(left, top);
 
         PointList pointList = getCurveFramePoints(frame, nextFrame, left, top);
-        List<AnimatorFrame> curves = getCurveFrames(pointList, location, frame, nextFrame);
+        List<AnimatorFrame> curves = getCurveFrames(modelFactory, pointList, location, frame, nextFrame);
 
         int matchedIndex = 0;
 
@@ -682,7 +682,8 @@ public class AnimationPathModel implements IPropertySource {
         }
     }
 
-    private static List<AnimatorFrame> getCurveFrames(PointList points, Point startPoint,
+    private static List<AnimatorFrame> getCurveFrames(AnimatorModelFactory modelFactory,
+                                                                                                 PointList points, Point startPoint,
                                                       AnimatorFrame startFrame,
                                                       AnimatorFrame endFrame) {
 
@@ -712,7 +713,7 @@ public class AnimationPathModel implements IPropertySource {
             double percent = lengthes[i] / totalLength;
             double solveY = transition.getXAtY(percent);
 
-            AnimatorFrame frame = createCurveFrame(startTime + (duration * solveY), p.x, p.y);
+            AnimatorFrame frame = createCurveFrame(modelFactory, startTime + (duration * solveY), p.x, p.y);
 
             frames.add(frame);
         }
@@ -748,7 +749,7 @@ public class AnimationPathModel implements IPropertySource {
                     frameFor = endFrames;
                 }
                 if (frameFor != null) {
-                    AnimatorFrame frame = createCurveFrame(frameTime, p.x, p.y);
+                    AnimatorFrame frame = createCurveFrame(modelFactory, frameTime, p.x, p.y);
                     frameFor.add(frame);
                 }
             }
@@ -760,8 +761,9 @@ public class AnimationPathModel implements IPropertySource {
         return frames;
     }
 
-    private static AnimatorFrame createCurveFrame(double frameTime, int x, int y) {
-        AnimatorFrame frame = new AnimatorFrame(frameTime);
+    private static AnimatorFrame createCurveFrame(AnimatorModelFactory modelFactory, double frameTime, int x, int y) {
+       AnimatorFrame frame = (AnimatorFrame)modelFactory.createAnimatorModel(AnimatorModelType.FRAME);
+       frame.setFrameTime(frameTime);       
 
         frame.addProperty(Constants.translateX, AnimatorUtils.convertPixToString(x));
         frame.addProperty(Constants.translateY, AnimatorUtils.convertPixToString(y));
index d3e2cad..e765360 100644 (file)
@@ -34,14 +34,4 @@ public class AnimatorAction extends AnimatorModel {
     public AnimatorAction() {
 
     }
-
-    /**
-     * Constructor
-     * 
-     * @param id
-     */
-    public AnimatorAction(String id) {
-        super.setId(id);
-    }
-
 }
\ No newline at end of file
index 11f2501..f6670cd 100644 (file)
@@ -44,19 +44,6 @@ public class AnimatorActionAnimation extends AnimatorAction {
     }
 
     /**
-     * Constructor
-     * 
-     * @param id
-     * @param animation
-     * @param action
-     */
-    public AnimatorActionAnimation(String id, AnimatorAnimation animation, ActionType action) {
-        super(id);
-        this.animation = animation;
-        this.actionType = action;
-    }
-
-    /**
      * Get animation
      * 
      * @return
index dc835b6..05cc7a9 100644 (file)
@@ -252,7 +252,10 @@ public class AnimatorAnimation extends AnimatorModel {
      */
     public AnimatorWidget createAnimatorWidget(Part part) {
 
-        AnimatorWidget animatorWidget = new AnimatorWidget(part);
+        AnimatorWidget animatorWidget = (AnimatorWidget)getModelFactory()
+                       .createAnimatorModel(AnimatorModelType.WIDGET);
+        animatorWidget.setPartLink(part);
+        animatorWidget.setId(part.getPropertyValue("id"));
         animatorWidget.setParent(this);
 
         // FIXME
@@ -263,7 +266,7 @@ public class AnimatorAnimation extends AnimatorModel {
             // FIXME - by returned value
 
             AnimatorSelector animatorSelector =
-                    animatorWidget.createAnimatorSelector(part.getUiSelector(), part);
+                    animatorWidget.createAnimatorSelector(part.getUiSelector());
             animatorWidget.addChild(animatorSelector);
         }
 
index 21088e0..a072b30 100644 (file)
@@ -39,39 +39,18 @@ public class AnimatorCurveFrame extends AnimatorModel {
      * Instantiates a new animator curve frame.
      */
     public AnimatorCurveFrame() {
-        super();
-    }
-
-    /**
-     * Instantiates a new animator curve frame.
-     * 
-     * @param curveFrame
-     *            the curve frame
-     */
-    public AnimatorCurveFrame(AnimatorCurveFrame curveFrame) {
-        super(curveFrame);
-
-        this.location = curveFrame.location.getCopy();
-        this.cp0 = curveFrame.cp0.getCopy();
-        this.cp1 = curveFrame.cp1.getCopy();
-    }
-
-    /**
-     * Instantiates a new animator curve frame.
-     * 
-     * @param location
-     *            the location
-     * @param cp0
-     *            the cp0
-     * @param cp1
-     *            the cp1
-     */
-    public AnimatorCurveFrame(Point location, Point cp0, Point cp1) {
-        super();
-        this.location = location.getCopy();
-        this.cp0 = cp0.getCopy();
-        this.cp1 = cp1.getCopy();
     }
+    
+       public AnimatorCurveFrame cloneAnimatorCurveFrame() {
+               AnimatorCurveFrame curveFrame = (AnimatorCurveFrame)getModelFactory().createAnimatorModel(AnimatorModelType.CURVEFRAME);
+               
+               curveFrame.setLocation(this.location.getCopy());
+               curveFrame.setCp0(this.cp0.getCopy());
+               curveFrame.setCp1(this.cp1.getCopy());
+               curveFrame.setParent(getParent());
+               
+               return curveFrame;
+       }
 
     /**
      * Gets the location.
index ffea8b9..169287b 100644 (file)
@@ -49,47 +49,31 @@ public class AnimatorFrame extends AnimatorModel {
 
     public AnimatorFrame() {
 
-    }
-
+    }    
+    
     /**
-     * copy constructor
+     * Clone AnimatorFrame
      * 
-     * @param frame
+     * @return frame
      */
-    public AnimatorFrame(AnimatorFrame frame) {
-        super(frame);
-        this.frameTime = frame.frameTime;
-        this.frameLink = frame;
-
-        Iterator<Entry<String, String>> iterator = frame.properties.entrySet().iterator();
+       public AnimatorFrame cloneAnimatorFrame() {
+               
+               AnimatorFrame frame = (AnimatorFrame)getModelFactory().createAnimatorModel(AnimatorModelType.FRAME);
+               frame.setFrameTime(frameTime);
+               frame.setFrameLink(this);
+               frame.setParent(getParent());
+               
+        Iterator<Entry<String, String>> iterator = getPropertyIterator();
         while (iterator.hasNext()) {
             Entry<String, String> next = iterator.next();
-            this.properties.put(next.getKey(), next.getValue());
+            frame.addProperty(next.getKey(), next.getValue());
         }
 
-        for (AnimatorCurveFrame curveFrame : frame.getCurveFrames())
-            this.addCurveFrame(new AnimatorCurveFrame(curveFrame));
-    }
-
-    /**
-     * constructor
-     * 
-     * @param time
-     */
-    public AnimatorFrame(double time) {
-        this.frameTime = time;
-    }
-
-    /**
-     * constructor
-     * 
-     * @param keyframe
-     * @param time
-     */
-    public AnimatorFrame(AnimatorKeyframe keyframe, double time) {
-        super(keyframe, null, null);
-        this.frameTime = time;
-    }
+        for (AnimatorCurveFrame curveFrame : getCurveFrames())
+            frame.addCurveFrame(curveFrame.cloneAnimatorCurveFrame());
+        
+               return frame;
+       }
 
     /**
      * Get frame Time
@@ -447,6 +431,16 @@ public class AnimatorFrame extends AnimatorModel {
     public AnimatorFrame getFrameLink() {
         return this.frameLink;
     }
+    
+    /**
+     * Get Frame Link
+     *
+     * @param AnimatorFrame
+     *
+     */
+    public void setFrameLink(AnimatorFrame frame) {
+       this.frameLink = frame;
+    }
 
     /**
      * Get css string
index 0e90fa0..d9f83b6 100644 (file)
@@ -38,24 +38,18 @@ public class AnimatorKeyframe extends AnimatorModel {
     private double duration = 0.0;
     private double delay = 0.0;
 
-    public AnimatorKeyframe(String name, double duration, double delay) {
-        setMembers(name, duration, delay);
-    }
-
-    public AnimatorKeyframe(AnimatorModel parent, String id, String name, double duration,
-            double delay) {
-        super(parent, null, id);
-        setMembers(name, duration, delay);
-    }
+    public AnimatorKeyframe() {
+               // TODO Auto-generated constructor stub
+       }
 
-    /**
+       /**
      * Set initial property member value
      * 
      * @param name
      * @param duration
      * @param delay
      */
-    public void setMembers(String name, double duration, double delay) {
+    public void setNames(String name) {
         if (name != null) {
             String[] array = name.split(",");
 
@@ -63,9 +57,6 @@ public class AnimatorKeyframe extends AnimatorModel {
                 names.add(element);
             }
         }
-
-        this.duration = duration;
-        this.delay = delay;
     }
 
     /**
@@ -605,16 +596,14 @@ public class AnimatorKeyframe extends AnimatorModel {
         if (nextFrame != null)
             splitFrame(keyframe, nextFrame);
     }
-
-    /**
-     * Create Frame
-     * 
-     * @param currentTime
-     * @return
-     */
-    public AnimatorFrame createFrame(double currentTime) {
-        return new AnimatorFrame(this, currentTime);
-    }
+    
+    public AnimatorFrame createAnimatorFrame(double currentTime) {
+       AnimatorFrame frame = (AnimatorFrame)getModelFactory().createAnimatorModel(AnimatorModelType.FRAME);
+       frame.setFrameTime(currentTime);
+       frame.setParent(this);
+               
+       return frame;
+       }
 
     private void updateFramesForHeadFrameDelete(AnimatorFrame targetFrame, double calcTime) {
         for (AnimatorModel model : getChildren()) {
index 199ca67..6e8cebc 100644 (file)
@@ -38,6 +38,7 @@ public abstract class AnimatorModel {
     private AnimatorModel parent = null;
     private List<AnimatorModel> children = new ArrayList<AnimatorModel>();
     private Part partLink = null;
+    private AnimatorModelFactory modelFactory = null;
 
     private List<IAnimatorModelListener> animatorListeners =
             new ArrayList<IAnimatorModelListener>();
@@ -47,39 +48,6 @@ public abstract class AnimatorModel {
     }
 
     /**
-     * Constructor
-     * 
-     * @param model
-     */
-    public AnimatorModel(AnimatorModel model) {
-        this.id = model.id;
-        this.parent = model.parent;
-        // TODO need to deep copy for children
-    }
-
-    /**
-     * Constructor
-     * 
-     * @param id
-     */
-    public AnimatorModel(String id) {
-        this.id = id;
-    }
-
-    /**
-     * Constructor
-     * 
-     * @param parent
-     * @param part
-     * @param id
-     */
-    public AnimatorModel(AnimatorModel parent, Part part, String id) {
-        this.parent = parent;
-        this.partLink = part;
-        this.id = id;
-    }
-
-    /**
      * Get Id
      * 
      * @return
@@ -160,7 +128,15 @@ public abstract class AnimatorModel {
         return null;
     }
 
-    /**
+    public AnimatorModelFactory getModelFactory() {
+               return modelFactory;
+       }
+
+       public void setModelFactory(AnimatorModelFactory modelFactory) {
+               this.modelFactory = modelFactory;
+       }
+
+       /**
      * Get child index
      * 
      * @param model
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModelFactory.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModelFactory.java
new file mode 100644 (file)
index 0000000..5fe7db8
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * UI Builder
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+
+
+package org.tizen.webuibuilder.animator.model;
+
+
+
+/**
+ * A class that implements event that can fire from Animator Model
+ */
+public class AnimatorModelFactory {
+
+       private IDGenerator idGenerator = null;
+
+       public AnimatorModelFactory(IDGenerator idGenerator) {
+               this.idGenerator = idGenerator; 
+       }
+
+       public AnimatorModel createAnimatorModel(AnimatorModelType modelType) {
+               
+               AnimatorModel model = null;
+               switch(modelType) {
+               case ANIMATION:
+                       model = new AnimatorAnimation();
+                       model.setId(idGenerator.generateAnimationId());
+                       break;
+               case WIDGET:
+                       model = new AnimatorWidget();
+                       break;
+               case SELECTOR:
+                       model = new AnimatorSelector();
+                       model.setId(idGenerator.generateSelectorId());
+                       break;  
+               case KEYFRAME:
+                       model = new AnimatorKeyframe();
+                       model.setId(idGenerator.generateKeyframeId());
+                       break;
+               case FRAME:
+                       model = new AnimatorFrame();
+                       break;
+               case CURVEFRAME:
+                       model = new AnimatorCurveFrame();
+                       break;
+               case TRIGGER:
+                       model = new AnimatorTrigger();
+                       break;
+               case ACTION:
+                       model = new AnimatorAction();
+                       model.setId(idGenerator.generateActionId());
+                       break;
+               case ACTION_ANIMATION:
+                       model = new AnimatorActionAnimation();
+                       model.setId(idGenerator.generateActionId());
+                       break;
+               case ACTION_TIMER:
+               case ACTION_AUDIO:
+               case ACTION_VIDEO:
+               }
+               
+               model.setModelFactory(this);
+               
+               return model;
+       }
+}
index 787f807..d07394e 100644 (file)
@@ -47,7 +47,6 @@ import org.tizen.webuibuilder.animator.gef.viewer.AnimatorBrowserViewer;
 import org.tizen.webuibuilder.animator.model.AnimatorModelEvent.EventType;
 import org.tizen.webuibuilder.animator.model.AnimatorModelEvent.Origin;
 import org.tizen.webuibuilder.animator.model.descriptor.AnimatorDescriptorManager;
-import org.tizen.webuibuilder.animator.model.descriptor.CssAnimationDescriptor;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
@@ -78,7 +77,10 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
     private static final int TIMER_INTERVAL = 1000;
 
     private EventFireDelegate eventSource;
-    private IDGenerator idGenerator = new IDGenerator();
+    private IDGenerator idGenerator = null;
+    
+    private AnimatorPredefinedAnimationFactory predefinedAnimationFactory = null;
+    private AnimatorModelFactory modelFactory = null;
 
     private class AnimatorModelEditorChecker implements Runnable {
         /*
@@ -113,6 +115,9 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
     private AnimatorModelManager(AppManager appManager) {
         this.appManager = appManager;
         this.descriptorManager = AnimatorDescriptorManager.createNewManager(appManager);
+        this.idGenerator = new IDGenerator();
+        this.modelFactory = new AnimatorModelFactory(idGenerator);
+        this.predefinedAnimationFactory = new AnimatorPredefinedAnimationFactory(modelFactory); 
 
         appManager.getPageDataSet().addPageListener(this);
 
@@ -143,23 +148,6 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
     }
 
     /**
-     * This is for test TODO change this....
-     */
-    private AnimatorModelManager() {
-    }
-
-    /**
-     * Get AnimatorModelManager instance
-     * 
-     * @return
-     */
-    public static AnimatorModelManager getInstance() {
-        AnimatorModelManager manager = new AnimatorModelManager();
-        // manager.setIdGenerator();
-        return manager;
-    }
-
-    /**
      * Initialize AnimatorModelManager
      * 
      * @param rootPart
@@ -188,83 +176,7 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
 
         initMaxIds(rootPart);
     }
-
-    /******************************************************************************************************************
-     * Animator Model ID Control - Start
-     ******************************************************************************************************************/
-    private void initMaxIds(Part rootPart) {
-        List<AnimatorAnimation> animations = new ArrayList<AnimatorAnimation>();
-        List<AnimatorTrigger> triggers = new ArrayList<AnimatorTrigger>();
-
-        for (Part part : rootPart.getChildren()) {
-            AnimatorPagePart pagePart = (AnimatorPagePart) part;
-            animations.addAll(pagePart.getAnimations());
-
-            for (AnimatorTrigger trigger : pagePart.getTriggers()) {
-                triggers.add(trigger);
-            }
-            for (Part child : pagePart.getChildren()) {
-               if(child instanceof AnimatorPart){
-                       AnimatorPart widget = (AnimatorPart)child;
-                       for (AnimatorTrigger trigger : widget.getTriggers()) {
-                           triggers.add(trigger);
-                       }
-               }
-            }
-        }
-
-        this.idGenerator.initializeIdGeneratorWithAnimation(animations, triggers);
-    }
-
-    /******************************************************************************************************************
-     * public method for id generation
-     ******************************************************************************************************************/
-    /**
-     * Generator id
-     * 
-     * @param modelType
-     * @return
-     */
-    public String idGenerator(AnimatorModelType modelType) {
-        String generatedId = null;
-
-        if (modelType == AnimatorModelType.ANIMATION) {
-            generatedId = this.idGenerator.generateAnimationId();
-        } else if (modelType == AnimatorModelType.SELECTOR) {
-            generatedId = this.idGenerator.generateSelectorId();
-        } else if (modelType == AnimatorModelType.KEYFRAME) {
-            generatedId = this.idGenerator.generateKeyframeId();
-        } else if (modelType == AnimatorModelType.ACTION
-                || modelType == AnimatorModelType.ACTION_ANIMATION
-                || modelType == AnimatorModelType.ACTION_TIMER
-                || modelType == AnimatorModelType.ACTION_AUDIO
-                || modelType == AnimatorModelType.ACTION_VIDEO) {
-            generatedId = this.idGenerator.generateActionId();
-        }
-
-        return generatedId;
-    }
-
-    /**
-     * Decrease id
-     * 
-     * @param modelType
-     */
-    public void decreaseId(AnimatorModelType modelType) {
-        if (modelType == AnimatorModelType.ANIMATION) {
-            idGenerator.decreaseAnimationId();
-        } else if (modelType == AnimatorModelType.SELECTOR) {
-            idGenerator.decreaseSelectorId();
-        } else if (modelType == AnimatorModelType.KEYFRAME) {
-            idGenerator.decreaseKeyframeId();
-        } else if (modelType == AnimatorModelType.ACTION
-                || modelType == AnimatorModelType.ACTION_ANIMATION
-                || modelType == AnimatorModelType.ACTION_TIMER
-                || modelType == AnimatorModelType.ACTION_AUDIO
-                || modelType == AnimatorModelType.ACTION_VIDEO) {
-            idGenerator.decreaseActionId();
-        }
-    }
+    
 
     /******************************************************************************************************************
      * GETTER - SETTER, ADD, REMOVE, FIND
@@ -343,7 +255,92 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
         }
     }
 
+    public AnimatorPredefinedAnimationFactory getPredefinedAnimationFactory() {
+               return predefinedAnimationFactory;
+       }
+
+       public AnimatorModelFactory getModelFactory() {
+               return modelFactory;
+       }
+
     /******************************************************************************************************************
+     * Animator Model ID Control - Start
+     ******************************************************************************************************************/
+    private void initMaxIds(Part rootPart) {
+        List<AnimatorAnimation> animations = new ArrayList<AnimatorAnimation>();
+        List<AnimatorTrigger> triggers = new ArrayList<AnimatorTrigger>();
+
+        for (Part part : rootPart.getChildren()) {
+            AnimatorPagePart pagePart = (AnimatorPagePart) part;
+            animations.addAll(pagePart.getAnimations());
+
+            for (AnimatorTrigger trigger : pagePart.getTriggers()) {
+                triggers.add(trigger);
+            }
+            for (Part child : pagePart.getChildren()) {
+               if(child instanceof AnimatorPart){
+                       AnimatorPart widget = (AnimatorPart)child;
+                       for (AnimatorTrigger trigger : widget.getTriggers()) {
+                           triggers.add(trigger);
+                       }
+               }
+            }
+        }
+
+        this.idGenerator.initializeIdGeneratorWithAnimation(animations, triggers);
+    }
+
+    /******************************************************************************************************************
+     * public method for id generation
+     ******************************************************************************************************************/
+    /**
+     * Generator id
+     * 
+     * @param modelType
+     * @return
+     */
+    public String idGenerator(AnimatorModelType modelType) {
+        String generatedId = null;
+
+        if (modelType == AnimatorModelType.ANIMATION) {
+            generatedId = this.idGenerator.generateAnimationId();
+        } else if (modelType == AnimatorModelType.SELECTOR) {
+            generatedId = this.idGenerator.generateSelectorId();
+        } else if (modelType == AnimatorModelType.KEYFRAME) {
+            generatedId = this.idGenerator.generateKeyframeId();
+        } else if (modelType == AnimatorModelType.ACTION
+                || modelType == AnimatorModelType.ACTION_ANIMATION
+                || modelType == AnimatorModelType.ACTION_TIMER
+                || modelType == AnimatorModelType.ACTION_AUDIO
+                || modelType == AnimatorModelType.ACTION_VIDEO) {
+            generatedId = this.idGenerator.generateActionId();
+        }
+
+        return generatedId;
+    }
+
+    /**
+     * Decrease id
+     * 
+     * @param modelType
+     */
+    public void decreaseId(AnimatorModelType modelType) {
+        if (modelType == AnimatorModelType.ANIMATION) {
+            idGenerator.decreaseAnimationId();
+        } else if (modelType == AnimatorModelType.SELECTOR) {
+            idGenerator.decreaseSelectorId();
+        } else if (modelType == AnimatorModelType.KEYFRAME) {
+            idGenerator.decreaseKeyframeId();
+        } else if (modelType == AnimatorModelType.ACTION
+                || modelType == AnimatorModelType.ACTION_ANIMATION
+                || modelType == AnimatorModelType.ACTION_TIMER
+                || modelType == AnimatorModelType.ACTION_AUDIO
+                || modelType == AnimatorModelType.ACTION_VIDEO) {
+            idGenerator.decreaseActionId();
+        }
+    }
+
+       /******************************************************************************************************************
      * Model Event Propagation
      ******************************************************************************************************************/
     /**
@@ -649,35 +646,6 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
      ******************************************************************************************************************/
 
     /**
-     * Create Predefined frames Create AnimatorSelector if adjust selector does not exist
-     * 
-     * @param animationGroupId
-     * @param target
-     * @param selector
-     * @param preDefinedAnimationDescriptor
-     * @param delay
-     * @return
-     */
-    public List<AnimatorFrame> createPredefinedFrames(String animationGroupId,
-                                                      Part target,
-                                                      String selector,
-                                                      CssAnimationDescriptor preDefinedAnimationDescriptor,
-                                                      double delay) {
-
-        String widgetId = target.getPropertyValue("id");
-
-        AnimatorSelector animatorSelector =
-                findAnimatorSelector(animationGroupId, widgetId, selector);
-        if (animatorSelector == null) {
-            AnimatorWidget animatorWidget = findAnimatorWidget(animationGroupId, widgetId);
-            animatorSelector = animatorWidget.createAnimatorSelector(selector, target);
-            animatorWidget.addChild(animatorSelector);
-        }
-
-        return animatorSelector.createPredefinedFrames(preDefinedAnimationDescriptor, delay);
-    }
-
-    /**
      * Add Keyframe for predefined animation and check left and right 1. check if left frame has
      * different properties than the first frame of the predefined animation merge this to left 2.
      * check if right frame has different properties than the last frame of the predefined animation
@@ -733,7 +701,8 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
      * @param currentTime
      * @return
      */
-    public List<AnimatorFrame> createOrGetAnimatorFrames(List<AnimatorModel> selectors,
+    public List<AnimatorFrame> createOrGetAnimatorFrames(AnimatorModelFactory modelFactory,
+                                                                                                        List<AnimatorModel> selectors,
                                                          double currentTime) {
         List<AnimatorFrame> frames = new ArrayList<AnimatorFrame>();
         for (AnimatorModel model : selectors) {
@@ -840,7 +809,7 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
             Point p;
             p =
                     AnimationPathModel
-                            .findTranslateValueAtTime(frame.getFrameTime(), previousFrame,
+                            .findTranslateValueAtTime(modelFactory, frame.getFrameTime(), previousFrame,
                                                       nextFrame,
                                                       AnimatorUtils.getEasingMethod(easingProperty));
 
@@ -902,12 +871,13 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
      * @param properties
      * @param origin
      */
-    public Map<String, String> createOrEditAnimatorFrame(AnimatorSelector selector,
+    public Map<String, String> createOrEditAnimatorFrame(AnimatorModelFactory modelFactory,
+                                                                                                        AnimatorSelector selector,
                                                          double currentTime,
                                                          Map<String, String> properties,
                                                          Origin origin) {
         Map<String, String> oldProperties = new HashMap<String, String>();
-        AnimatorFrame frame = selector.getAnimatorFrame(currentTime);
+        AnimatorFrame frame = selector.getOrCreateAnimatorFrame(currentTime);
         if (frame != null) {
             oldProperties = frame.getProperties(properties.keySet());
             frame.addOrEditProperties(properties);
@@ -1061,7 +1031,7 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
 
         // Create AnimatorAnimation
         AnimatorAnimation animationGroup =
-                pagePart.createAnimatorAnimation(idGenerator(AnimatorModelType.ANIMATION));
+                pagePart.createAnimatorAnimation(getModelFactory(), idGenerator(AnimatorModelType.ANIMATION));
 
         List<AnimatorModel> makeAnimatorWidget =
                 animationGroup.composeAnimatorWidget(pagePart.getChildren());
@@ -1141,7 +1111,7 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
      * Model Control - AnimatorTrigger
      ******************************************************************************************************************/
     private AnimatorTrigger createAnimatorTrigger(String eventName, AnimatorPart part) {
-        AnimatorTrigger trigger = new AnimatorTrigger();
+        AnimatorTrigger trigger = (AnimatorTrigger)getModelFactory().createAnimatorModel(AnimatorModelType.TRIGGER);
 
         trigger.setEventName(eventName);
         trigger.setPartLink(part);
@@ -1184,36 +1154,11 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
         AnimatorAnimation animation = findAnimation(animationGroup);
 
         if (animation != null)
-            actionAnimation = createAnimatorActionAnimation(animation, actionType, time, trigger);
+            actionAnimation = trigger.createAnimatorActionAnimation(animation, actionType, time);
 
         return actionAnimation;
     }
 
-    private AnimatorActionAnimation createAnimatorActionAnimation(AnimatorAnimation animation,
-                                                                  String actionType, double time,
-                                                                  AnimatorTrigger trigger) {
-
-        AnimatorActionAnimation actionAnimation =
-                createAnimatorActionAnimation(animation, idGenerator(AnimatorModelType.ACTION),
-                                              actionType, trigger);
-        actionAnimation.setTime(time);
-
-        return actionAnimation;
-    }
-
-    private AnimatorActionAnimation createAnimatorActionAnimation(AnimatorAnimation animationGroup,
-                                                                  String actionId,
-                                                                  String actionType,
-                                                                  AnimatorTrigger trigger) {
-        AnimatorActionAnimation actionAnimation = new AnimatorActionAnimation();
-
-        actionAnimation.setId(actionId);
-        actionAnimation.setAnimation(animationGroup);
-        actionAnimation.setActionType(actionType);
-        actionAnimation.setParent(trigger);
-
-        return actionAnimation;
-    }
 
     /******************************************************************************************************************
      * Listener(Customer)
index 9b404b9..de96162 100644 (file)
@@ -37,9 +37,10 @@ public enum AnimatorModelType {
 
     DOCUMENT(0, "Part"), PAGE(1, "PagePart"), WIDGET(2, "WidgetPart"), SELECTOR(3,
             "AnimatorWidgetSelector"), ANIMATION(4, "AnimatorAnimation"), KEYFRAME(5,
-            "AnimatorKeyframe"), FRAME(6, "AnimatorFrame"), TRIGGER(7, "AnimatorTrigger"), ACTION(
-            8, "AnimatorAction"), ACTION_ANIMATION(9, "AnimatorActionAnimation"), ACTION_TIMER(10,
-            "AnimatorActionTimer"), ACTION_AUDIO(11, "AnimatorActionAudio"), ACTION_VIDEO(12,
+            "AnimatorKeyframe"), FRAME(6, "AnimatorFrame"), CURVEFRAME(7, "AnimatorCurveFrame"), 
+            TRIGGER(8, "AnimatorTrigger"), ACTION(9, "AnimatorAction"),
+            ACTION_ANIMATION(10, "AnimatorActionAnimation"), ACTION_TIMER(11,
+            "AnimatorActionTimer"), ACTION_AUDIO(12, "AnimatorActionAudio"), ACTION_VIDEO(13,
             "AnimatorActionVideo"), MODEL(99, "AnimatorModel");
 
     private static final Map<Integer, AnimatorModelType> lookup =
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorPredefinedAnimationFactory.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorPredefinedAnimationFactory.java
new file mode 100644 (file)
index 0000000..d81f5eb
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * UI Builder
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.webuibuilder.animator.model;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.webuibuilder.animator.AnimatorConstants;
+import org.tizen.webuibuilder.animator.model.descriptor.CssAnimationDescriptor;
+import org.tizen.webuibuilder.animator.model.descriptor.CssAnimationPropertyDescriptor;
+import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
+
+
+public class AnimatorPredefinedAnimationFactory {
+
+       private AnimatorModelFactory modelFactory = null;
+       
+       public AnimatorPredefinedAnimationFactory(AnimatorModelFactory modelFactory) {
+               this.modelFactory = modelFactory;
+       }
+       
+    /**
+     * Create Predefined frames for predefined animation
+     * 
+     * @param preDefinedAnimationDescriptor
+     * @param delay
+     * @return
+     */
+       public List<AnimatorFrame> createPredefinedFrames(CssAnimationDescriptor preDefinedAnimationDescriptor, double delay) {
+               
+               List<AnimatorFrame> frames = new ArrayList<AnimatorFrame>();
+        List<CssAnimationPropertyDescriptor> defaultKeyFrames =
+                preDefinedAnimationDescriptor.getDefaultKeyFrames();
+
+        double duration =
+                AnimatorUtils.convertTimeToDouble(preDefinedAnimationDescriptor
+                        .getPropertyValueByName(AnimatorConstants.PROPERTY_NAME_DURATION));
+
+        for (CssAnimationPropertyDescriptor property : defaultKeyFrames) {
+               AnimatorFrame frame = (AnimatorFrame)modelFactory.createAnimatorModel(AnimatorModelType.FRAME);
+               frame.setFrameTime(AnimatorUtils.doubleRoundCeiling(AnimatorUtils
+                    .convertPercentToDouble(property.getName()) / 100 * duration));
+            List<CssAnimationPropertyDescriptor> childProperties = property.getChildProperties();
+            for (CssAnimationPropertyDescriptor childProperty : childProperties) {
+                String name = childProperty.getName();
+                String value = childProperty.getDefaultValue();
+                frame.addProperty(name, value);
+            }
+
+            frame.setFrameTime(frame.getFrameTime() + delay);
+            addListByFrameTime(frames, frame);
+        }
+        return frames;
+       }
+       
+
+    private void addListByFrameTime(List<AnimatorFrame> frames, AnimatorFrame addFrame) {
+        int index = 0;
+        for (AnimatorFrame model : frames) {
+            AnimatorFrame frame = (AnimatorFrame) model;
+            if (frame.getFrameTime() < addFrame.getFrameTime())
+                index++;
+            else
+                break;
+        }
+
+        frames.add(index, addFrame);
+    }
+
+}
\ No newline at end of file
index 92e478a..a339488 100644 (file)
@@ -32,8 +32,6 @@ import java.util.Map.Entry;
 import java.util.Set;
 
 import org.tizen.webuibuilder.animator.AnimatorConstants;
-import org.tizen.webuibuilder.animator.model.descriptor.CssAnimationDescriptor;
-import org.tizen.webuibuilder.animator.model.descriptor.CssAnimationPropertyDescriptor;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
 import org.tizen.webuibuilder.model.Part;
 
@@ -49,49 +47,12 @@ public class AnimatorSelector extends AnimatorModel {
     private int iteration = 0;
     private boolean justPlay = true;
     private boolean holdEnd = false;
-    private AnimatorModelManager manager;
+    public AnimatorSelector() {
+               // TODO Auto-generated constructor stub
+       }
 
-    /**
-     * Constructor
-     * 
-     * @param animatorWidget
-     * @param widget
-     * @param id
-     * @param selector
-     * @param delay
-     * @param duration
-     * @param iteration
-     * @param justPlay
-     * @param holdEnd
-     */
-    public AnimatorSelector(AnimatorWidget animatorWidget, Part widget, String id, String selector,
-            double delay, double duration, int iteration, boolean justPlay, boolean holdEnd) {
-        super(animatorWidget, widget, id);
-        this.selector = selector;
-        this.delay = delay;
-        this.duration = duration;
-        this.iteration = iteration;
-        this.justPlay = justPlay;
-        this.holdEnd = holdEnd;
-    }
-
-    /**
-     * Constructor
-     * 
-     * @param id
-     * @param selector
-     * @param delay
-     * @param duration
-     * @param iteration
-     * @param justPlay
-     * @param holdEnd
-     */
-    public AnimatorSelector(String id, String selector, double delay, double duration,
-            int iteration, boolean justPlay, boolean holdEnd) {
-        this(null, null, id, selector, delay, duration, iteration, justPlay, holdEnd);
-    }
-
-    /**
+       /**
      * Get selector string
      * 
      * @return selector
@@ -380,7 +341,7 @@ public class AnimatorSelector extends AnimatorModel {
             for (AnimatorModel frameModel : keyframe.getChildren()) {
                 AnimatorFrame frame = (AnimatorFrame) frameModel;
 
-                AnimatorFrame newFrame = new AnimatorFrame(frame);// why? copy? why? ok..
+                AnimatorFrame newFrame = frame.cloneAnimatorFrame();
                 newFrame.setFrameTime(calculateMergeFrameTime(keyframe.getCurrentTime(frame
                         .getFrameTime())));
 
@@ -422,23 +383,16 @@ public class AnimatorSelector extends AnimatorModel {
      * @param frameTime
      * @return
      */
-    public AnimatorKeyframe createKeyframe(String name, double frameTime) {
-        AnimatorModelManager animatorModelManager = getModelManager();
-        AnimatorKeyframe keyframe =
-                new AnimatorKeyframe(this,
-                                     animatorModelManager.idGenerator(AnimatorModelType.KEYFRAME),
-                                     name, 0, frameTime);
+    public AnimatorKeyframe createKeyframe(String name, double frameTime) {        
+        AnimatorKeyframe keyframe = (AnimatorKeyframe)getModelFactory().createAnimatorModel(AnimatorModelType.KEYFRAME);
+        keyframe.setNames(name);
+        keyframe.setDuration(0.0);
+        keyframe.setDelay(frameTime);
+        keyframe.setParent(this);
 
         return keyframe;
     }
 
-    private AnimatorModelManager getModelManager() {
-        if (manager == null) {
-            return AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
-        }
-        return manager;
-    }
-
     /**
      * Get current keyframe by current time
      * 
@@ -590,7 +544,7 @@ public class AnimatorSelector extends AnimatorModel {
      * 
      * @return css string from animation for this selector
      */
-    public String getCssString() {
+    public String getCssString(AnimatorModelFactory modelFactory) {
         // String separator = System.getProperty( "line.separator" );
         StringBuilder builder = new StringBuilder("\n");
         if (getChildrenSize() > 0) {
@@ -598,7 +552,7 @@ public class AnimatorSelector extends AnimatorModel {
             builder.append("@-webkit-keyframes " + id + " {");
             builder.append("\n");
             builder.append("\t");
-            List<AnimatorFrame> frames = new AnimationPathModel(this).getCssKeyframes();
+            List<AnimatorFrame> frames = new AnimationPathModel(this).getCssKeyframes(modelFactory);
             Set<String> propertiesUsed = getAllPropertiesUsed(frames);
 
             for (AnimatorModel frame : frames) {
@@ -642,7 +596,7 @@ public class AnimatorSelector extends AnimatorModel {
      * @param delay
      * @return
      */
-    public List<AnimatorFrame> createPredefinedFrames(CssAnimationDescriptor preDefinedAnimationDescriptor,
+    /*public List<AnimatorFrame> createPredefinedFrames(CssAnimationDescriptor preDefinedAnimationDescriptor,
                                                       double delay) {
 
         List<AnimatorFrame> frames = new ArrayList<AnimatorFrame>();
@@ -668,9 +622,9 @@ public class AnimatorSelector extends AnimatorModel {
             addListByFrameTime(frames, frame);
         }
         return frames;
-    }
+    }*/
 
-    private void addListByFrameTime(List<AnimatorFrame> frames, AnimatorFrame addFrame) {
+    /*private void addListByFrameTime(List<AnimatorFrame> frames, AnimatorFrame addFrame) {
         int index = 0;
         for (AnimatorModel model : frames) {
             AnimatorFrame frame = (AnimatorFrame) model;
@@ -681,7 +635,7 @@ public class AnimatorSelector extends AnimatorModel {
         }
 
         frames.add(index, addFrame);
-    }
+    }*/
 
     /**
      * if there exists a Frame, return exist frame. if not, create and return it.
@@ -690,14 +644,15 @@ public class AnimatorSelector extends AnimatorModel {
      * @param currentTime
      * @return
      */
-    public AnimatorFrame getAnimatorFrame(double currentTime) {
+    public AnimatorFrame getOrCreateAnimatorFrame(double currentTime) {
         AnimatorKeyframe keyframe = getCurrentKeyframe(currentTime);
         if (keyframe == null)
             keyframe = createKeyframe("custom", currentTime);
 
         AnimatorFrame frame = keyframe.getFrameByCurrentTime(currentTime);
-        if (frame == null)
-            frame = keyframe.createFrame(currentTime);
+        if (frame == null) {
+               keyframe.createAnimatorFrame(currentTime);
+        }
 
         return frame;
     }
@@ -716,8 +671,9 @@ public class AnimatorSelector extends AnimatorModel {
             keyframe = createKeyframe("custom", currentTime);
 
         AnimatorFrame currentframe = keyframe.getFrameByCurrentTime(currentTime);
-        if (currentframe == null)
-            frame = keyframe.createFrame(currentTime);
+        if (currentframe == null) {
+               frame = keyframe.createAnimatorFrame(currentTime);
+        }
 
         return frame;
     }
index 22bdb59..bfc9931 100644 (file)
@@ -23,7 +23,6 @@
 
 package org.tizen.webuibuilder.animator.model;
 
-import org.tizen.webuibuilder.model.Part;
 
 
 /**
@@ -41,19 +40,6 @@ public class AnimatorTrigger extends AnimatorModel {
     }
 
     /**
-     * Constructor
-     * 
-     * @param id
-     * @param eventName
-     * @param target
-     */
-    public AnimatorTrigger(String id, String eventName, Part target) {
-        super.setId(id);
-        super.setPartLink(target);
-        this.eventName = eventName;
-    }
-
-    /**
      * Get event name
      * 
      * @return
@@ -86,4 +72,17 @@ public class AnimatorTrigger extends AnimatorModel {
             getParent().removeChild(this);
     }
 
+       public AnimatorActionAnimation createAnimatorActionAnimation(
+                       AnimatorAnimation animation, String actionType, double time) {
+               
+               AnimatorActionAnimation actionAnimation = 
+                               (AnimatorActionAnimation)getModelFactory().createAnimatorModel(AnimatorModelType.ACTION_ANIMATION);
+
+           actionAnimation.setAnimation(animation);
+           actionAnimation.setActionType(actionType);
+           actionAnimation.setTime(time);
+           actionAnimation.setParent(this);
+
+           return actionAnimation;
+       }
 }
\ No newline at end of file
index 965b514..71560ea 100644 (file)
@@ -43,23 +43,12 @@ import org.tizen.webuibuilder.ui.editor.PageDesigner;
 public class AnimatorWidget extends AnimatorModel {
     private boolean visibility = true;
     private boolean lock = false;
+    
+    public AnimatorWidget() {
+               // TODO Auto-generated constructor stub
+       }
 
-    /**
-     * Constructor
-     * 
-     * @param part
-     */
-    public AnimatorWidget(Part part) {
-        if (part != null) {
-            this.setId(part.getPropertyValue("id"));
-            this.setPartLink(part);
-        } else {
-            this.setId("");
-            this.setPartLink(null);
-        }
-    }
-
-    /**
+       /**
      * Check visibility
      * 
      * @return
@@ -115,13 +104,18 @@ public class AnimatorWidget extends AnimatorModel {
      * @param widget
      * @return
      */
-    public AnimatorSelector createAnimatorSelector(String selector, Part widget) {
-        AnimatorModelManager manager =
-                AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
-        AnimatorSelector animatorSelector =
-                new AnimatorSelector(this, widget, manager.idGenerator(AnimatorModelType.SELECTOR),
-                                     selector, 0.0, 0.0, 1, true, true);
-
+    public AnimatorSelector createAnimatorSelector(String selector) {
+       AnimatorSelector animatorSelector =
+                       (AnimatorSelector)getModelFactory().createAnimatorModel(AnimatorModelType.SELECTOR);
+       animatorSelector.setSelector(selector);
+       animatorSelector.setDelay(0.0);
+       animatorSelector.setDuration(0.0);
+       animatorSelector.setIteration(1);
+       animatorSelector.setJustPlay(true);
+       animatorSelector.setHoldEnd(true);
+       animatorSelector.setPartLink(getPartLink());
+       animatorSelector.setParent(this);
+       
         return animatorSelector;
     }
 
index ad3701e..b57d009 100644 (file)
@@ -28,12 +28,13 @@ import java.lang.reflect.Type;
 import org.tizen.webuibuilder.animator.model.AnimatorActionAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
+import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
 import org.tizen.webuibuilder.model.Part;
 
 import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
@@ -42,8 +43,7 @@ import com.google.gson.JsonParseException;
 /**
  * A class that implements deserializer for AnimatorActionAnimation
  */
-public class AnimatorActionAnimationDeserializer implements
-        JsonDeserializer<AnimatorModel> {
+public class AnimatorActionAnimationDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
 
     private Part rootPart = null;
 
@@ -52,8 +52,9 @@ public class AnimatorActionAnimationDeserializer implements
      * 
      * @param part
      */
-    public AnimatorActionAnimationDeserializer(Part part) {
-        rootPart = part;
+    public AnimatorActionAnimationDeserializer(AnimatorModelFactory modelFactory, Part part) {
+       super(modelFactory);
+        this.rootPart = part;
     }
 
     /*
@@ -74,7 +75,7 @@ public class AnimatorActionAnimationDeserializer implements
             for (Part page : rootPart.getChildren()) {
                 for (AnimatorAnimation animation : ((AnimatorPagePart) page).getAnimations()) {
                     if (animation.getId().equals(jobject.get("target").getAsString())) {
-                        actionAnimation = new AnimatorActionAnimation();
+                        actionAnimation = (AnimatorActionAnimation)getModelFactory().createAnimatorModel(AnimatorModelType.ACTION_ANIMATION);
                         actionAnimation.setAnimation(animation);
                         actionAnimation.setId(jobject.get("id").getAsString());
                         actionAnimation.setActionType(jobject.get("act").getAsString());
index 7c0a4e4..bdf7755 100644 (file)
@@ -27,6 +27,8 @@ import java.lang.reflect.Type;
 
 import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
+import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 import org.tizen.webuibuilder.animator.model.AnimatorSelector;
 import org.tizen.webuibuilder.animator.model.AnimatorWidget;
 import org.tizen.webuibuilder.model.Part;
@@ -41,8 +43,12 @@ import com.google.gson.JsonParseException;
  * A class that implements deserializer for AnimatorAnimation
  */
 public class AnimatorAnimationDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
+               
+    public AnimatorAnimationDeserializer(AnimatorModelFactory modelFactory) {
+               super(modelFactory);
+       }
 
-    /*
+       /*
      * (non-Javadoc)
      * 
      * @see
@@ -56,10 +62,10 @@ public class AnimatorAnimationDeserializer extends AnimatorModelDeserializer<Ani
             throws JsonParseException {
 
         AnimatorAnimation animation = null;
-        if (getPart() != null) {
+        if (getPagePart() != null) {
             JsonObject jobject = (JsonObject) json;
 
-            animation = new AnimatorAnimation();
+            animation = (AnimatorAnimation)getModelFactory().createAnimatorModel(AnimatorModelType.ANIMATION);
             animation.setId(jobject.get("id").getAsString());
 
             JsonElement jsonElement = jobject.get("name");
@@ -84,13 +90,12 @@ public class AnimatorAnimationDeserializer extends AnimatorModelDeserializer<Ani
                     String id = membersObject.get("id").getAsString();
 
                     AnimatorWidget widget = (AnimatorWidget) animation.getChild(id);
-                    // jinwoo
                     Part widgetPart = null;
                     if (widget == null) {
-                        // WidgetPart widgetPart =
-                        // (WidgetPart)rootPart.getChildOfIdPropertyValue(id, true);
-                        widgetPart = (Part) getPart().getChildOfIdPropertyValue(id, true);
-                        widget = new AnimatorWidget(widgetPart);
+                        widgetPart = (Part) getPagePart().getChildOfIdPropertyValue(id, true);
+                        widget = (AnimatorWidget)getModelFactory().createAnimatorModel(AnimatorModelType.WIDGET);
+                        widget.setPartLink(widgetPart);
+                        widget.setId(widgetPart.getPropertyValue("id"));
                         widget.setParent(animation);
                         animation.addChild(widget);
                     }
@@ -104,7 +109,6 @@ public class AnimatorAnimationDeserializer extends AnimatorModelDeserializer<Ani
                                         .getAsJsonObject(), AnimatorSelector.class);
                         selector.setSelector(membersObject.get("selector").getAsString());
                         selector.setParent(widget);
-                        // jinwoo
                         if (widgetPart != null) {
                             selector.setPartLink(widgetPart);
                         }
index 1b3c54a..80aa5b6 100644 (file)
@@ -27,9 +27,10 @@ import java.lang.reflect.Type;
 
 import org.tizen.webuibuilder.animator.model.AnimatorCurveFrame;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
+import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 
 import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
@@ -38,7 +39,11 @@ import com.google.gson.JsonParseException;
 /**
  * A class that implements deserializer for AnimatorCurveFrame
  */
-public class AnimatorCurveFrameDeserializer implements JsonDeserializer<AnimatorModel> {
+public class AnimatorCurveFrameDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
+       
+       public AnimatorCurveFrameDeserializer(AnimatorModelFactory modelFactory) {
+               super(modelFactory);
+       }       
 
     /*
      * (non-Javadoc)
@@ -55,7 +60,9 @@ public class AnimatorCurveFrameDeserializer implements JsonDeserializer<Animator
         String result = jobject.get("curveFrame").getAsString();
         String array[] = result.split(",");
 
-        AnimatorCurveFrame curveFrame = new AnimatorCurveFrame();
+        AnimatorCurveFrame curveFrame = (AnimatorCurveFrame)getModelFactory().
+                       createAnimatorModel(AnimatorModelType.CURVEFRAME);
+        
         curveFrame.setLocation(array[0], array[1]);
         curveFrame.setCp0(array[2], array[3]);
         curveFrame.setCp1(array[4], array[5]);
index a38b5da..09b28f8 100644 (file)
@@ -29,9 +29,10 @@ import java.util.Map;
 import org.tizen.webuibuilder.animator.model.AnimatorCurveFrame;
 import org.tizen.webuibuilder.animator.model.AnimatorFrame;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
+import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 
 import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
@@ -40,7 +41,11 @@ import com.google.gson.JsonParseException;
 /**
  * A class that implements deserializer for AnimatorFrame
  */
-public class AnimatorFrameDeserializer implements JsonDeserializer<AnimatorModel> {
+public class AnimatorFrameDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
+       
+       public AnimatorFrameDeserializer(AnimatorModelFactory modelFactory) {
+               super(modelFactory);
+       }
 
     /*
      * (non-Javadoc)
@@ -54,7 +59,7 @@ public class AnimatorFrameDeserializer implements JsonDeserializer<AnimatorModel
 
         JsonObject jobject = (JsonObject) json;
 
-        AnimatorFrame frame = new AnimatorFrame();
+        AnimatorFrame frame = (AnimatorFrame)getModelFactory().createAnimatorModel(AnimatorModelType.FRAME);
         for (Map.Entry<String, JsonElement> entry : jobject.entrySet()) {
             String key = entry.getKey();
             if (key.equals("time"))
index edf0c36..dcb5bff 100644 (file)
@@ -28,12 +28,11 @@ import java.lang.reflect.Type;
 import org.tizen.webuibuilder.animator.model.AnimatorFrame;
 import org.tizen.webuibuilder.animator.model.AnimatorKeyframe;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
-import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
 import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
 
 import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
@@ -42,8 +41,11 @@ import com.google.gson.JsonParseException;
 /**
  * A class that implements deserializer for AnimatorKeyframe
  */
-public class AnimatorKeyframeDeserializer implements JsonDeserializer<AnimatorModel> {
+public class AnimatorKeyframeDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
 
+       public AnimatorKeyframeDeserializer(AnimatorModelFactory modelFactory) {
+               super(modelFactory);
+       }
     /*
      * (non-Javadoc)
      * 
@@ -57,16 +59,10 @@ public class AnimatorKeyframeDeserializer implements JsonDeserializer<AnimatorMo
 
         JsonObject jobject = (JsonObject) json;
 
-        AnimatorModelManager modelManager =
-                AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
-
-        AnimatorKeyframe keyframe =
-                new AnimatorKeyframe(null, modelManager.idGenerator(AnimatorModelType.KEYFRAME),
-                                     jobject.get("name").getAsString(),
-                                     AnimatorUtils.convertTimeToDouble(jobject.get("duration")
-                                             .getAsString()),
-                                     AnimatorUtils.convertTimeToDouble(jobject.get("start")
-                                             .getAsString()));
+        AnimatorKeyframe keyframe = (AnimatorKeyframe)getModelFactory().createAnimatorModel(AnimatorModelType.KEYFRAME);
+        keyframe.setNames(jobject.get("name").getAsString());
+        keyframe.setDuration(AnimatorUtils.convertTimeToDouble(jobject.get("duration").getAsString()));
+        keyframe.setDelay( AnimatorUtils.convertTimeToDouble(jobject.get("start").getAsString()));        
 
         if (jobject.has("frame")) {
             AnimatorFrame frame = null;
index ec9ab56..12e904f 100644 (file)
@@ -25,6 +25,7 @@ package org.tizen.webuibuilder.animator.model.deserializer;
 
 import java.lang.reflect.Type;
 
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
 import org.tizen.webuibuilder.model.Part;
 
 import com.google.gson.JsonDeserializationContext;
@@ -38,17 +39,35 @@ import com.google.gson.JsonParseException;
  */
 public class AnimatorModelDeserializer<AnimatorModel> implements JsonDeserializer<AnimatorModel> {
 
-    private Part part = null;
+    private Part pagePart = null;
+       private AnimatorModelFactory modelFactory = null;
+       
+       public AnimatorModelDeserializer() {
+               super();
+       }
+       
+    public AnimatorModelDeserializer(AnimatorModelFactory modelFactory) {
+               super();
+               this.modelFactory = modelFactory;
+       }
 
-    public void setPart(Part part) {
-        this.part = part;
+       public void setPagePart(Part part) {
+        this.pagePart = part;
     }
 
-    public Part getPart() {
-        return part;
+    public Part getPagePart() {
+        return pagePart;
     }
+    
+    public AnimatorModelFactory getModelFactory() {
+               return modelFactory;
+       }
 
-    /*
+       public void setModelFactory(AnimatorModelFactory modelFactory) {
+               this.modelFactory = modelFactory;
+       }
+
+       /*
      * (non-Javadoc)
      * 
      * @see com.google.gson.JsonDeserializer#deserialize(com.google.gson.JsonElement,
index 38f0dba..2194bcd 100644 (file)
@@ -27,11 +27,12 @@ import java.lang.reflect.Type;
 
 import org.tizen.webuibuilder.animator.model.AnimatorKeyframe;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
+import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 import org.tizen.webuibuilder.animator.model.AnimatorSelector;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
 
 import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
@@ -40,7 +41,12 @@ import com.google.gson.JsonParseException;
 /**
  * A class that implements deserializer for AnimatorSelector
  */
-public class AnimatorSelectorDeserializer implements JsonDeserializer<AnimatorModel> {
+public class AnimatorSelectorDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
+       
+       
+       public AnimatorSelectorDeserializer(AnimatorModelFactory modelFactory) {
+               super(modelFactory);
+       }
 
     /*
      * (non-Javadoc)
@@ -54,16 +60,15 @@ public class AnimatorSelectorDeserializer implements JsonDeserializer<AnimatorMo
             throws JsonParseException {
 
         JsonObject jobject = (JsonObject) json;
-
-        AnimatorSelector selector =
-                new AnimatorSelector(jobject.get("id").getAsString(), null,
-                                     AnimatorUtils.convertTimeToDouble(jobject.get("delay")
-                                             .getAsString()),
-                                     AnimatorUtils.convertTimeToDouble(jobject.get("duration")
-                                             .getAsString()), jobject.get("iteration").getAsInt(),
-                                     jobject.get("justplay").getAsBoolean(), jobject.get("holdEnd")
-                                             .getAsBoolean());
-
+        
+        AnimatorSelector selector = (AnimatorSelector)getModelFactory().createAnimatorModel(AnimatorModelType.SELECTOR);
+        selector.setId(jobject.get("id").getAsString());
+        selector.setDelay(AnimatorUtils.convertTimeToDouble(jobject.get("delay").getAsString()));
+        selector.setDuration(AnimatorUtils.convertTimeToDouble(jobject.get("duration").getAsString()));
+        selector.setIteration(jobject.get("iteration").getAsInt());
+        selector.setJustPlay(jobject.get("justplay").getAsBoolean());
+        selector.setHoldEnd(jobject.get("holdEnd").getAsBoolean());
+        
         if (jobject.has("keyframe")) {
             AnimatorKeyframe keyframe = null;
             for (JsonElement keyframeElement : jobject.get("keyframe").getAsJsonArray()) {
index e0b0d49..be610c9 100644 (file)
@@ -29,11 +29,12 @@ import java.util.Map;
 import org.tizen.webuibuilder.animator.model.AnimatorAction;
 import org.tizen.webuibuilder.animator.model.AnimatorActionAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
+import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 
 import com.google.gson.JsonArray;
 import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
@@ -42,8 +43,11 @@ import com.google.gson.JsonParseException;
 /**
  * A class that implements deserializer for AnimatorTrigger
  */
-public class AnimatorTriggerDeserializer implements JsonDeserializer<AnimatorModel> {
+public class AnimatorTriggerDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
 
+       public AnimatorTriggerDeserializer(AnimatorModelFactory modelFactory) {
+               super(modelFactory);
+       }
     /*
      * (non-Javadoc)
      * 
@@ -56,7 +60,7 @@ public class AnimatorTriggerDeserializer implements JsonDeserializer<AnimatorMod
             throws JsonParseException {
 
         JsonArray actionArray = (JsonArray) json;
-        AnimatorTrigger trigger = new AnimatorTrigger();
+        AnimatorTrigger trigger = (AnimatorTrigger)getModelFactory().createAnimatorModel(AnimatorModelType.TRIGGER);
 
         for (JsonElement actionElement : actionArray) {
             JsonObject actionObject = (JsonObject) actionElement;
index 5c6800c..20d45d2 100644 (file)
@@ -26,6 +26,8 @@ package org.tizen.webuibuilder.animator.model.deserializer;
 import java.lang.reflect.Type;
 
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
+import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 import org.tizen.webuibuilder.animator.model.AnimatorSelector;
 import org.tizen.webuibuilder.animator.model.AnimatorWidget;
 import org.tizen.webuibuilder.model.Part;
@@ -41,7 +43,11 @@ import com.google.gson.JsonParseException;
  */
 public class AnimatorWidgetDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
 
-    /*
+    public AnimatorWidgetDeserializer(AnimatorModelFactory modelFactory) {
+               super(modelFactory);
+       }
+
+       /*
      * (non-Javadoc)
      * 
      * @see
@@ -53,14 +59,16 @@ public class AnimatorWidgetDeserializer extends AnimatorModelDeserializer<Animat
     public AnimatorModel deserialize(JsonElement json, Type arg1,
                                       JsonDeserializationContext context) throws JsonParseException {
         AnimatorWidget widget = null;
-        if (getPart() != null) {
+        if (getPagePart() != null) {
             JsonObject jobject = (JsonObject) json;
 
             Part widgetPart =
-                    (Part) getPart().getChildOfIdPropertyValue(jobject.get("id")
+                    (Part) getPagePart().getChildOfIdPropertyValue(jobject.get("id")
                                                                              .getAsString(), true);
 
-            widget = new AnimatorWidget(widgetPart);
+            widget = (AnimatorWidget)getModelFactory().createAnimatorModel(AnimatorModelType.WIDGET);
+            widget.setPartLink(widgetPart);
+            widget.setId(widgetPart.getPropertyValue("id"));
             widget.setLock(jobject.get("lock").getAsBoolean());
             widget.setVisibility(jobject.get("visibility").getAsBoolean());
 
index c7e0355..5cb1225 100644 (file)
@@ -77,7 +77,7 @@ public class PagePartDeserializer implements JsonDeserializer<AnimatorPagePart>
                         .getChildOfIdPropertyValue(jobject.get("id").getAsString(), true);
         if (pagePart != null) {
             for (AnimatorModelDeserializer<AnimatorModel> deserializer : deserializerList) {
-                deserializer.setPart(pagePart);
+                deserializer.setPagePart(pagePart);
             }
 
             pagePart.setTransition(jobject.get("transit").getAsString());
index 7daf2be..7bdd223 100644 (file)
@@ -27,6 +27,7 @@ import java.lang.reflect.Type;
 import java.util.Map;
 
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 import org.tizen.webuibuilder.animator.model.part.AnimatorWidgetPart;
 
@@ -40,8 +41,17 @@ import com.google.gson.JsonParseException;
  * A class that implements deserializer for WidgetPart
  */
 public class WidgetPartDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
+       
+       
+       public WidgetPartDeserializer() {
+               super();
+       }
 
-    /*
+    public WidgetPartDeserializer(AnimatorModelFactory modelFactory) {
+               super(modelFactory);
+       }
+
+       /*
      * (non-Javadoc)
      * 
      * @see
@@ -53,11 +63,11 @@ public class WidgetPartDeserializer extends AnimatorModelDeserializer<AnimatorMo
     public AnimatorModel deserialize(JsonElement json, Type arg1, JsonDeserializationContext context)
             throws JsonParseException {
 
-        if (getPart() != null) {
+        if (getPagePart() != null) {
             JsonObject jobject = (JsonObject) json;
 
             AnimatorWidgetPart widgetPart =
-                    (AnimatorWidgetPart) getPart().getChildOfIdPropertyValue(jobject.get("id")
+                    (AnimatorWidgetPart) getPagePart().getChildOfIdPropertyValue(jobject.get("id")
                                                                              .getAsString(), true);
             if (widgetPart != null) {
 
index fa82e3b..527d8f3 100644 (file)
@@ -38,6 +38,7 @@ import org.tizen.webuibuilder.animator.model.AnimatorCurveFrame;
 import org.tizen.webuibuilder.animator.model.AnimatorFrame;
 import org.tizen.webuibuilder.animator.model.AnimatorKeyframe;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.AnimatorSelector;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 import org.tizen.webuibuilder.animator.model.AnimatorWidget;
@@ -56,6 +57,7 @@ import org.tizen.webuibuilder.animator.model.deserializer.WidgetPartDeserializer
 import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
 import org.tizen.webuibuilder.animator.model.part.AnimatorWidgetPart;
+import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
 import org.tizen.webuibuilder.model.Part;
 
 import com.google.gson.Gson;
@@ -96,10 +98,13 @@ public class AnimatorFileReader {
     public static void makeModelbyFile(Part rootPart, String jsPath, String cssPath) {
         GsonBuilder gsonBuilder = new GsonBuilder();
 
+        AnimatorModelManager manager =
+                AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
+        
         WidgetPartDeserializer widgetPartDeserializer = new WidgetPartDeserializer();
         AnimatorAnimationDeserializer animatorAnimationDeserializer =
-                new AnimatorAnimationDeserializer();
-        AnimatorWidgetDeserializer animatorWidgetDeserializer = new AnimatorWidgetDeserializer();
+                new AnimatorAnimationDeserializer(manager.getModelFactory());
+        AnimatorWidgetDeserializer animatorWidgetDeserializer = new AnimatorWidgetDeserializer(manager.getModelFactory());
 
         List<AnimatorModelDeserializer<AnimatorModel>> deserializerList =
                 new ArrayList<AnimatorModelDeserializer<AnimatorModel>>();
@@ -107,21 +112,20 @@ public class AnimatorFileReader {
         deserializerList.add(animatorAnimationDeserializer);
         deserializerList.add(animatorWidgetDeserializer);
 
-        //gsonBuilder.registerTypeAdapter(DocumentPart.class, new DocumentPartDeserializer());
         gsonBuilder.registerTypeAdapter(AnimatorPart.class, new DocumentPartDeserializer());
         gsonBuilder.registerTypeAdapter(AnimatorPagePart.class, new PagePartDeserializer(rootPart,
                                                                                  deserializerList));
         gsonBuilder.registerTypeAdapter(AnimatorWidgetPart.class, widgetPartDeserializer);
         gsonBuilder.registerTypeAdapter(AnimatorAnimation.class, animatorAnimationDeserializer);
         gsonBuilder.registerTypeAdapter(AnimatorWidget.class, animatorWidgetDeserializer);
-        gsonBuilder.registerTypeAdapter(AnimatorSelector.class, new AnimatorSelectorDeserializer());
-        gsonBuilder.registerTypeAdapter(AnimatorKeyframe.class, new AnimatorKeyframeDeserializer());
-        gsonBuilder.registerTypeAdapter(AnimatorFrame.class, new AnimatorFrameDeserializer());
+        gsonBuilder.registerTypeAdapter(AnimatorSelector.class, new AnimatorSelectorDeserializer(manager.getModelFactory()));
+        gsonBuilder.registerTypeAdapter(AnimatorKeyframe.class, new AnimatorKeyframeDeserializer(manager.getModelFactory()));
+        gsonBuilder.registerTypeAdapter(AnimatorFrame.class, new AnimatorFrameDeserializer(manager.getModelFactory()));
         gsonBuilder.registerTypeAdapter(AnimatorCurveFrame.class,
-                                        new AnimatorCurveFrameDeserializer());
-        gsonBuilder.registerTypeAdapter(AnimatorTrigger.class, new AnimatorTriggerDeserializer());
+                                        new AnimatorCurveFrameDeserializer(manager.getModelFactory()));
+        gsonBuilder.registerTypeAdapter(AnimatorTrigger.class, new AnimatorTriggerDeserializer(manager.getModelFactory()));
         gsonBuilder.registerTypeAdapter(AnimatorActionAnimation.class,
-                                        new AnimatorActionAnimationDeserializer(rootPart));
+                                        new AnimatorActionAnimationDeserializer(manager.getModelFactory(), rootPart));
 
         Gson gson = gsonBuilder.create();
 
index 0ed7c0c..b09be06 100644 (file)
@@ -268,6 +268,8 @@ public class AnimatorFileWriter {
      */
     public static String getAnimatorKeyFrameString(Part rootPart) {
         try {
+               AnimatorModelManager manager =
+                    AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
             StringBuffer animationCssString = new StringBuffer(new String("".getBytes(), "utf-8"));// ask
                                                                                                    // why?
             for (Part part : rootPart.getChildren()) {
@@ -276,7 +278,7 @@ public class AnimatorFileWriter {
                     for (AnimatorModel widget : animation.getChildren()) {
                         for (AnimatorModel model : widget.getChildren()) {
                             AnimatorSelector selector = (AnimatorSelector) model;
-                            animationCssString.append(selector.getCssString());
+                            animationCssString.append(selector.getCssString(manager.getModelFactory()));
                         }
                     }
                 }
@@ -308,7 +310,7 @@ public class AnimatorFileWriter {
                         for (AnimatorModel widget : animation.getChildren()) {
                             for (AnimatorModel model : widget.getChildren()) {
                                 AnimatorSelector selector = (AnimatorSelector) model;
-                                animationCssString.append(selector.getCssString());
+                                animationCssString.append(selector.getCssString(manager.getModelFactory()));
                             }
                         }
                     }
index db85c63..bcd8367 100644 (file)
@@ -5,6 +5,8 @@ import java.util.List;
 
 import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
+import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.descriptors.PartDescriptor;
 
@@ -68,8 +70,8 @@ public class AnimatorPagePart extends AnimatorPart {
                return animation;
        }
 
-       public AnimatorAnimation createAnimatorAnimation(String animationId) {
-               AnimatorAnimation animationGroup = new AnimatorAnimation();
+       public AnimatorAnimation createAnimatorAnimation(AnimatorModelFactory modelFactory, String animationId) {
+               AnimatorAnimation animationGroup = (AnimatorAnimation)modelFactory.createAnimatorModel(AnimatorModelType.ANIMATION);
                animationGroup.setId(animationId);
                animationGroup.setName(animationId);
                animationGroup.setDuration("0s");
index 81ca67d..69c361f 100644 (file)
@@ -66,7 +66,7 @@ public class TimelineFrameCreateCommand extends Command {
                 AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
 
         if (frames.size() == 0)
-            frames = manager.createOrGetAnimatorFrames(selectors, currentTime);
+            frames = manager.createOrGetAnimatorFrames(manager.getModelFactory(), selectors, currentTime);
 
         manager.addAnimatorFrames(frames, currentTime, Origin.TIMELINE);
     }
index d4bd4cb..d671a32 100644 (file)
@@ -356,7 +356,7 @@ public class PageDesignerToolbar implements ISelectionListener {
     private void insertPreDefinedAnimations(Menu menu) {
         // IProject project = ((FileEditorInput)
         // mainEditor.getEditorInput()).getFile().getProject();
-        AnimatorDescriptorManager manager = AnimatorDescriptorManager.getInstance(appManager);
+        AnimatorDescriptorManager manager = AnimatorDescriptorManager.getInstance(appManager);        
 
         List<CssAnimationDescriptor> cssAnimations = manager.getCssAnimations();
         MenuItem preSubMenuItem = null;