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>
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.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;
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;
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;
/**
*/
public class ActoinCreateCommand extends Command {
- private AnimatorPart selelectModel;
+ private AnimatorPart seleectModel;
private AnimatorAnimation animation;
private String method;
private String triggerName;
*/
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;
*/
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;
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 */
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;
// }
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);
// preparedTrigger.addAction(actionAnimation);
preparedTrigger.addChild(actionAnimation);
- selelectModel.addTrigger(preparedTrigger);
+ seleectModel.addTrigger(preparedTrigger);
}
}
AnimatorModelManager animatorModelManager =
AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
oldProperties =
- animatorModelManager.createOrEditAnimatorFrame(selector, currentTime, properties,
+ animatorModelManager.createOrEditAnimatorFrame(animatorModelManager.getModelFactory(), selector, currentTime, properties,
origin);
}
if (frames == null) {
frames =
- animatorModelManager.createPredefinedFrames(animationGroupId, target,
- selector,
- preDefinedAnimationDescriptor,
- delay);
+ animatorModelManager.getPredefinedAnimationFactory().createPredefinedFrames(preDefinedAnimationDescriptor, delay);
}
animatorModelManager
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();
}
*
* @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();
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);
* @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);
* 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;
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;
}
}
- private static List<AnimatorFrame> getCurveFrames(PointList points, Point startPoint,
+ private static List<AnimatorFrame> getCurveFrames(AnimatorModelFactory modelFactory,
+ PointList points, Point startPoint,
AnimatorFrame startFrame,
AnimatorFrame endFrame) {
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);
}
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);
}
}
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));
public AnimatorAction() {
}
-
- /**
- * Constructor
- *
- * @param id
- */
- public AnimatorAction(String id) {
- super.setId(id);
- }
-
}
\ No newline at end of file
}
/**
- * 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
*/
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
// FIXME - by returned value
AnimatorSelector animatorSelector =
- animatorWidget.createAnimatorSelector(part.getUiSelector(), part);
+ animatorWidget.createAnimatorSelector(part.getUiSelector());
animatorWidget.addChild(animatorSelector);
}
* 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.
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
public AnimatorFrame getFrameLink() {
return this.frameLink;
}
+
+ /**
+ * Get Frame Link
+ *
+ * @param AnimatorFrame
+ *
+ */
+ public void setFrameLink(AnimatorFrame frame) {
+ this.frameLink = frame;
+ }
/**
* Get css string
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(",");
names.add(element);
}
}
-
- this.duration = duration;
- this.delay = delay;
}
/**
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()) {
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>();
}
/**
- * 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
return null;
}
- /**
+ public AnimatorModelFactory getModelFactory() {
+ return modelFactory;
+ }
+
+ public void setModelFactory(AnimatorModelFactory modelFactory) {
+ this.modelFactory = modelFactory;
+ }
+
+ /**
* Get child index
*
* @param model
--- /dev/null
+/*
+ * 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;
+ }
+}
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;
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 {
/*
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);
}
/**
- * 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
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
}
}
+ 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
******************************************************************************************************************/
/**
******************************************************************************************************************/
/**
- * 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
* @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) {
Point p;
p =
AnimationPathModel
- .findTranslateValueAtTime(frame.getFrameTime(), previousFrame,
+ .findTranslateValueAtTime(modelFactory, frame.getFrameTime(), previousFrame,
nextFrame,
AnimatorUtils.getEasingMethod(easingProperty));
* @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);
// Create AnimatorAnimation
AnimatorAnimation animationGroup =
- pagePart.createAnimatorAnimation(idGenerator(AnimatorModelType.ANIMATION));
+ pagePart.createAnimatorAnimation(getModelFactory(), idGenerator(AnimatorModelType.ANIMATION));
List<AnimatorModel> makeAnimatorWidget =
animationGroup.composeAnimatorWidget(pagePart.getChildren());
* 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);
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)
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 =
--- /dev/null
+/*
+ * 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
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;
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
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())));
* @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
*
*
* @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) {
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) {
* @param delay
* @return
*/
- public List<AnimatorFrame> createPredefinedFrames(CssAnimationDescriptor preDefinedAnimationDescriptor,
+ /*public List<AnimatorFrame> createPredefinedFrames(CssAnimationDescriptor preDefinedAnimationDescriptor,
double delay) {
List<AnimatorFrame> frames = new ArrayList<AnimatorFrame>();
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;
}
frames.add(index, addFrame);
- }
+ }*/
/**
* if there exists a Frame, return exist frame. if not, create and return it.
* @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;
}
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;
}
package org.tizen.webuibuilder.animator.model;
-import org.tizen.webuibuilder.model.Part;
/**
}
/**
- * 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
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
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
* @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;
}
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;
/**
* A class that implements deserializer for AnimatorActionAnimation
*/
-public class AnimatorActionAnimationDeserializer implements
- JsonDeserializer<AnimatorModel> {
+public class AnimatorActionAnimationDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
private Part rootPart = null;
*
* @param part
*/
- public AnimatorActionAnimationDeserializer(Part part) {
- rootPart = part;
+ public AnimatorActionAnimationDeserializer(AnimatorModelFactory modelFactory, Part part) {
+ super(modelFactory);
+ this.rootPart = part;
}
/*
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());
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;
* A class that implements deserializer for AnimatorAnimation
*/
public class AnimatorAnimationDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
+
+ public AnimatorAnimationDeserializer(AnimatorModelFactory modelFactory) {
+ super(modelFactory);
+ }
- /*
+ /*
* (non-Javadoc)
*
* @see
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");
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);
}
.getAsJsonObject(), AnimatorSelector.class);
selector.setSelector(membersObject.get("selector").getAsString());
selector.setParent(widget);
- // jinwoo
if (widgetPart != null) {
selector.setPartLink(widgetPart);
}
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;
/**
* 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)
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]);
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;
/**
* 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)
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"))
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;
/**
* 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)
*
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;
import java.lang.reflect.Type;
+import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
import org.tizen.webuibuilder.model.Part;
import com.google.gson.JsonDeserializationContext;
*/
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,
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;
/**
* 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)
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()) {
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;
/**
* 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)
*
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;
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;
*/
public class AnimatorWidgetDeserializer extends AnimatorModelDeserializer<AnimatorModel> {
- /*
+ public AnimatorWidgetDeserializer(AnimatorModelFactory modelFactory) {
+ super(modelFactory);
+ }
+
+ /*
* (non-Javadoc)
*
* @see
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());
.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());
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;
* 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
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) {
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;
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;
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>>();
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();
*/
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()) {
for (AnimatorModel widget : animation.getChildren()) {
for (AnimatorModel model : widget.getChildren()) {
AnimatorSelector selector = (AnimatorSelector) model;
- animationCssString.append(selector.getCssString());
+ animationCssString.append(selector.getCssString(manager.getModelFactory()));
}
}
}
for (AnimatorModel widget : animation.getChildren()) {
for (AnimatorModel model : widget.getChildren()) {
AnimatorSelector selector = (AnimatorSelector) model;
- animationCssString.append(selector.getCssString());
+ animationCssString.append(selector.getCssString(manager.getModelFactory()));
}
}
}
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;
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");
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);
}
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;