package org.tizen.webuibuilder.animator.action;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
+import org.tizen.webuibuilder.animator.gef.command.AnimationCreateAndChangeFrameCommand;
import org.tizen.webuibuilder.animator.gef.command.AnimatorChangeLayoutCommand;
import org.tizen.webuibuilder.animator.gef.editparts.AnimatorEditPart;
+import org.tizen.webuibuilder.animator.model.AnimatorModelEvent;
+import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
+import org.tizen.webuibuilder.animator.model.AnimatorSelector;
import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
+import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
import org.tizen.webuibuilder.model.Part;
if (editPart instanceof AnimatorEditPart) {
AnimatorPart part = (AnimatorPart) ((AnimatorEditPart) editPart).getModel();
Rectangle originalRect = part.getOriginalPosition();
- Rectangle movedRect =
- new Rectangle(part.getAniPosition().x + delta.x,
- part.getAniPosition().y + delta.y,
- part.getAniPosition().width,
- part.getAniPosition().height);
+// Rectangle movedRect =
+// new Rectangle(part.getAniPosition().x + delta.x,
+// part.getAniPosition().y + delta.y,
+// part.getAniPosition().width,
+// part.getAniPosition().height);
+//
+// command.add(new AnimatorChangeLayoutCommand(part, movedRect, originalRect));
+
+ int left = 0;
+ int top = 0;
+ if (part.getPositionMode() == Part.PositionMode.ABSOLUTE_POSITION) {
+ left = part.getAniPosition().x + delta.x;
+ top = part.getAniPosition().y + delta.y;
+ } else if (part.getPositionMode() == Part.PositionMode.RELATIVE_POSITION) {
+ left = part.getAniPosition().x + delta.x - originalRect.x;
+ top = part.getAniPosition().y + delta.y - originalRect.y;
+ }
+
+ AnimatorModelManager animatorModelManager =
+ AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
+ String animationGroupId =
+ AnimatorUtils.getActiveAnimatorBrowserViewer().getCurrentAnimationGroupId();
- command.add(new AnimatorChangeLayoutCommand(part, movedRect, originalRect));
+ AnimatorSelector selector =
+ animatorModelManager.findAnimatorSelector(animationGroupId, part,
+ part.getUiSelector());
+
+ double currentTime = AnimatorUtils.getActiveAnimatorBrowserViewer().getPointTime();
+
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put("translateX", left + "px");
+ properties.put("translateY", top + "px");
+
+ command.add(new AnimationCreateAndChangeFrameCommand(selector, currentTime, properties,
+ AnimatorModelEvent.Origin.EDITOR));
}
}
package org.tizen.webuibuilder.animator.gef.command;
+import java.util.HashMap;
import java.util.Map;
import org.eclipse.gef.commands.Command;
private double currentTime = 0.0;
private Map<String, String> properties = null;
private AnimatorModelEvent.Origin origin = null;
- private Map<String, String> oldProperties = null;
+ private Map<String, String> oldProperties = new HashMap<String, String>();
+ private boolean isCreate;
/**
* Constructor
public void execute() {
AnimatorModelManager animatorModelManager =
AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
- oldProperties =
- animatorModelManager.createOrEditAnimatorFrame(animatorModelManager.getModelFactory(), selector, currentTime, properties,
+ isCreate =
+ animatorModelManager.createOrEditAnimatorFrame(selector, currentTime, oldProperties, properties,
origin);
}
AnimatorModelManager animatorModelManager =
AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
animatorModelManager.removeOrEditAnimatorFrame(selector, currentTime, oldProperties,
- properties, origin);
+ properties, isCreate, origin);
}
}
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.swt.graphics.Color;
import org.tizen.webuibuilder.animator.gef.command.AnimationCreateAndChangeFrameCommand;
-import org.tizen.webuibuilder.animator.gef.command.AnimatorChangeLayoutCommand;
import org.tizen.webuibuilder.animator.gef.editparts.AnimatorEditPart;
import org.tizen.webuibuilder.animator.gef.editparts.AnimatorRootEditPart;
import org.tizen.webuibuilder.animator.gef.tools.AnimatorDragEditPartsTracker;
@Override
public Command getCommand(Request request) {
if (REQ_MOVE.equals(request.getType())) {
- Point moveDelta = ((ChangeBoundsRequest) request).getMoveDelta();
+ /*Point moveDelta = ((ChangeBoundsRequest) request).getMoveDelta();
moveDelta.x /= ((AnimatorRootEditPart) getHost().getRoot()).getZoomManager().getZoom();
moveDelta.y /= ((AnimatorRootEditPart) getHost().getRoot()).getZoomManager().getZoom();
((ChangeBoundsRequest) request).setMoveDelta(moveDelta);
return new AnimatorChangeLayoutCommand(getHost().getModel(),
((ChangeBoundsRequest) request)
.getTransformedRectangle(rect),
- originalRect);
+ originalRect);*/
+
+ Point moveDelta = ((ChangeBoundsRequest) request).getMoveDelta();
+ moveDelta.x /= ((AnimatorRootEditPart) getHost().getRoot()).getZoomManager().getZoom();
+ moveDelta.y /= ((AnimatorRootEditPart) getHost().getRoot()).getZoomManager().getZoom();
+ ((ChangeBoundsRequest) request).setMoveDelta(moveDelta);
+ AnimatorPart part = (AnimatorPart) (getHost().getModel());
+ Rectangle rect = new Rectangle(part.getAniPosition());
+
+ Rectangle layout = ((ChangeBoundsRequest) request)
+ .getTransformedRectangle(rect);
+ Rectangle originalRect = part.getOriginalPosition();
+ int left = 0;
+ int top = 0;
+
+ if (part.getPositionMode() == Part.PositionMode.ABSOLUTE_POSITION) {
+ left = layout.x;
+ top = layout.y;
+ } else if (part.getPositionMode() == Part.PositionMode.RELATIVE_POSITION) {
+ left = layout.x - originalRect.x;
+ top = layout.y - originalRect.y;
+ }
+
+ AnimatorModelManager animatorModelManager =
+ AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
+ String animationGroupId =
+ AnimatorUtils.getActiveAnimatorBrowserViewer().getCurrentAnimationGroupId();
+
+ AnimatorSelector selector =
+ animatorModelManager.findAnimatorSelector(animationGroupId, part,
+ part.getUiSelector());
+
+ double currentTime = AnimatorUtils.getActiveAnimatorBrowserViewer().getPointTime();
+
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put("translateX", left + "px");
+ properties.put("translateY", top + "px");
+
+ return new AnimationCreateAndChangeFrameCommand(selector, currentTime, properties,
+ AnimatorModelEvent.Origin.EDITOR);
+
} else if (REQ_RESIZE.equals(request.getType())) {
Dimension sizeDelta = ((ChangeBoundsRequest) request).getSizeDelta();
sizeDelta.width /=
*/
private void updateAnimationFW(AnimatorSelector selector, String animationGroupId,
double pointTime) {
- selector.getMergedFrames();
+ selector.updateSelectorTime();
int delay = (int) (selector.getDelay() * 1000);
int duration = (int) (selector.getDuration() * 1000);
String keyFrameId = selector.getId();
*/
private void updateAnimationFWAndDetect(AnimatorSelector selector, String animationGroupId,
double pointTime) {
- selector.getMergedFrames();
+ selector.updateSelectorTime();
int delay = (int) (selector.getDelay() * 1000);
int duration = (int) (selector.getDuration() * 1000);
String keyFrameId = selector.getId();
int top = translateInDesigner.height;
int i = 0;
- List<AnimatorFrame> mergedFrames = selector.getMergedFrames();
+ List<AnimatorFrame> mergedFrames = selector.getMergedPropertyWithWidgetProperty();
Set<String> propertiesUsed = selector.getAllPropertiesUsed(mergedFrames);
for (AnimatorFrame frame : mergedFrames) {
int originX = 50;
int originY = 50;
- List<AnimatorFrame> frameList = selector.getMergedFrames();
+ List<AnimatorFrame> frameList = selector.getMergedPropertyWithWidgetProperty();
for (AnimatorModel frameElement : frameList) {
AnimatorFrame frame = ((AnimatorFrame) frameElement).getFrameLink();
- left = getPixelProperty(frame, Constants.translateX, translateInDesigner.width);
- top = getPixelProperty(frame, Constants.translateY, translateInDesigner.height);
- width = getPixelProperty(frame, "width", width);
- height = getPixelProperty(frame, "height", height);
+ left = getPixelProperty(((AnimatorFrame) frameElement), Constants.translateX, translateInDesigner.width);
+ top = getPixelProperty(((AnimatorFrame) frameElement), Constants.translateY, translateInDesigner.height);
+ width = getPixelProperty(((AnimatorFrame) frameElement), "width", width);
+ height = getPixelProperty(((AnimatorFrame) frameElement), "height", height);
Point point = calculatePathPoint(left, top, width, height, originX, originY);
// if (prevPoint == null || !prevPoint.equals(point)) {
int curveIndex = 0;
CssValueForLocation css =
new CssValueForLocation(0, 0, width, height, originX, originY);
- for (AnimatorCurveFrame curve : frame.getCurveFrames()) {
+ if(!frameElement.equals(frameList.get(frameList.size() -1))) {
+ for (AnimatorCurveFrame curve : frame.getCurveFrames()) {
- AnimationPathCurve curveForView = new AnimationPathCurve();
- convertCurveFromModel(css, curveForView, curve);
+ AnimationPathCurve curveForView = new AnimationPathCurve();
+ convertCurveFromModel(css, curveForView, curve);
- frameForView.insertCurve(curveIndex++, curveForView);
- }
+ frameForView.insertCurve(curveIndex++, curveForView);
+ }
+ }
points.add(frameForView);
// }
}
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.eclipse.draw2d.geometry.Point;
import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
+import org.tizen.webuibuilder.animator.utils.Constants;
/**
public void subtractFrameTime(double time) {
this.frameTime -= time;
}
+
+ /**
+ * Whether contains key or not
+ *
+ * @param key
+ * @return true false
+ */
+ public boolean containsKey(String key) {
+ return this.properties.containsKey(key);
+ }
+
+ /**
+ * Get Curve Frames
+ *
+ * @return List of curve frames
+ */
+ public List<AnimatorCurveFrame> getCurveFrames() {
+ return curveFrames;
+ }
+
+ /**
+ * Get Curve Frame by index
+ *
+ * @param index
+ * @return curve frame
+ */
+ public AnimatorCurveFrame getCurveFrame(int index) {
+ return curveFrames.get(index);
+ }
+
+ /**
+ * Set Curve Frames
+ *
+ * @param curveFrames
+ */
+ public void setCurveFrames(List<AnimatorCurveFrame> curveFrames) {
+ this.curveFrames = curveFrames;
+ }
+
+ /**
+ * Get Curve Frame size
+ *
+ * @return size of curve frame
+ */
+ public int getCurveFrameSize() {
+ return this.curveFrames.size();
+ }
+
+ /**
+ * Add Curve Frame
+ *
+ * @param curveFrame
+ */
+ public void addCurveFrame(AnimatorCurveFrame curveFrame) {
+ this.curveFrames.add(curveFrame);
+ }
+
+ /**
+ * Add Curve frame by index
+ *
+ * @param index
+ * @param curveFrame
+ */
+ public void addCurveFrame(int index, AnimatorCurveFrame curveFrame) {
+ this.curveFrames.add(index, curveFrame);
+ }
+
+ /**
+ * Remove Curve frame by index
+ *
+ * @param index
+ */
+ public void removeCurveFrame(int index) {
+ this.curveFrames.remove(index);
+ }
+
+ /**
+ * Get easing Property
+ *
+ * @return easing Property
+ */
+ public String getEasingProperty() {
+ String easeData = getProperty("-webkit-animation-timing-function");
+ if (easeData == null) {
+ easeData = "ease";
+ }
+ return easeData;
+ }
+
+ /**
+ * Get Frame Link
+ *
+ * @return frame
+ */
+ public AnimatorFrame getFrameLink() {
+ return this.frameLink;
+ }
+
+ /**
+ * Get Frame Link
+ *
+ * @param AnimatorFrame
+ *
+ */
+ public void setFrameLink(AnimatorFrame frame) {
+ this.frameLink = frame;
+ }
/**
* Get Properties
Iterator<String> keyIterator = keySet.iterator();
while (keyIterator.hasNext()) {
String key = keyIterator.next();
- results.put(key, getProperty(key));
+ if(getProperty(key) != null) {
+ results.put(key, getProperty(key));
+ }
}
return results;
return this.getComputedProperties().equals(animatorFrame.getComputedProperties());
}
- /**
- * Whether contains key or not
- *
- * @param key
- * @return true false
- */
- public boolean containsKey(String key) {
- return this.properties.containsKey(key);
- }
-
- /**
- * Get Curve Frames
- *
- * @return List of curve frames
- */
- public List<AnimatorCurveFrame> getCurveFrames() {
- return curveFrames;
- }
-
- /**
- * Get Curve Frame by index
- *
- * @param index
- * @return curve frame
- */
- public AnimatorCurveFrame getCurveFrame(int index) {
- return curveFrames.get(index);
- }
-
- /**
- * Set Curve Frames
- *
- * @param curveFrames
- */
- public void setCurveFrames(List<AnimatorCurveFrame> curveFrames) {
- this.curveFrames = curveFrames;
- }
-
- /**
- * Get Curve Frame size
- *
- * @return size of curve frame
- */
- public int getCurveFrameSize() {
- return this.curveFrames.size();
- }
-
- /**
- * Add Curve Frame
- *
- * @param curveFrame
- */
- public void addCurveFrame(AnimatorCurveFrame curveFrame) {
- this.curveFrames.add(curveFrame);
- }
-
- /**
- * Add Curve frame by index
- *
- * @param index
- * @param curveFrame
- */
- public void addCurveFrame(int index, AnimatorCurveFrame curveFrame) {
- this.curveFrames.add(index, curveFrame);
- }
-
- /**
- * Remove Curve frame by index
- *
- * @param index
- */
- public void removeCurveFrame(int index) {
- this.curveFrames.remove(index);
- }
-
- /**
- * Get easing Property
- *
- * @return easing Property
- */
- public String getEasingProperty() {
- String easeData = getProperty("-webkit-animation-timing-function");
- if (easeData == null) {
- easeData = "ease";
- }
- return easeData;
- }
-
- /**
- * Get Frame Link
- *
- * @return frame
- */
- public AnimatorFrame getFrameLink() {
- return this.frameLink;
- }
-
- /**
- * Get Frame Link
- *
- * @param AnimatorFrame
- *
- */
- public void setFrameLink(AnimatorFrame frame) {
- this.frameLink = frame;
- }
/**
* Get css string
* @return css string from animation for this frame
*
*/
- public String getCssString(Set<String> propertiesUsed, AnimatorSelector selector) {
- // if(properties.size() == 0){//TODO this should be omitted if ...
- // return "";
- // }
+ /*public String getCssString(Set<String> propertiesUsed, AnimatorSelector selector) {
+
Map<String, String> widgetProperties = selector.getWidgetProperties(propertiesUsed);
double duration = selector.getDuration();
builder.append("}");
builder.append("\n");
return builder.toString();
+ }*/
+
+ public String getCssString(Set<String> propertiesUsed, AnimatorSelector selector) {
+
+ Map<String, String> widgetProperties = selector.getWidgetProperties(propertiesUsed);
+ double duration = selector.getDuration();
+
+ StringBuilder builder = new StringBuilder();
+ String percent =
+ AnimatorUtils.convertPercentToString(frameTime == 0.0 ? 0.0 : frameTime / duration
+ * 100);
+ builder.append("\n");
+ builder.append(percent);
+ builder.append("{");
+ Map<String, String> transformRelatedProperties = new HashMap<String, String>();
+ for (String key : propertiesUsed) {
+
+ if (isTransformRelatedProperties(key)) {
+ transformRelatedProperties.put(key, properties.get(key));
+ } else {
+ builder.append("\n\t");
+ builder.append(key);
+ builder.append(":");
+ builder.append(properties.get(key));
+ builder.append(";");
+ builder.append("\n");
+ }
+ }
+ if (transformRelatedProperties.size() > 0) {
+ builder.append(createTransformProperty(transformRelatedProperties,
+ (frameLink != null) ? widgetProperties : null));
+ }
+ builder.append("}");
+ builder.append("\n");
+ return builder.toString();
}
/**
if (getUsedPropertiesInThisFrame().contains(key)) {
computedProperties.put(key, properties.get(key));
} else {
- computedProperties.put(key, widgetProperties.get(key));
+ String computedProperty = getComputedPropertiesFromPreviousFrame(key);
+ if(computedProperty != null) {
+ computedProperties.put(key, computedProperty);
+ } else {
+// computedProperty = getComputedPropertiesFromNextFrame(key);
+// if(computedProperty != null) {
+// computedProperties.put(key, computedProperty);
+// } else {
+ computedProperties.put(key, widgetProperties.get(key));
+// }
+ }
}
}
}
return this.computedProperties;
}
+
+ public String getComputedPropertiesFromPreviousFrame(String key) {
+ AnimatorFrame previousFrame = getPreviousAnimatorFrame(this);
+ while(previousFrame != null) {
+ String value = previousFrame.getProperty(key);
+ if(value != null) {
+ return value;
+ }
+ previousFrame = getPreviousAnimatorFrame(previousFrame);
+ }
+
+ return null;
+ }
+
+ private static AnimatorFrame getPreviousAnimatorFrame(AnimatorFrame frame) {
+
+ AnimatorFrame previousFrame = null;
+ AnimatorKeyframe currentKeyframe = (AnimatorKeyframe)frame.getParent();
+ previousFrame = (AnimatorFrame)currentKeyframe.getPrevChild(frame);
+ if(previousFrame == null) {
+ AnimatorKeyframe previousKeyframe = (AnimatorKeyframe)currentKeyframe.getParent().getPrevChild(currentKeyframe);
+ if(previousKeyframe != null) {
+ previousFrame = previousKeyframe.getLastFrame();
+ }
+ }
+
+ return previousFrame;
+ }
+
+ private static AnimatorFrame getNextAnimatorFrame(AnimatorFrame frame) {
+
+ AnimatorFrame nextFrame = null;
+ AnimatorKeyframe currentKeyframe = (AnimatorKeyframe)frame.getParent();
+ nextFrame = (AnimatorFrame)currentKeyframe.getPrevChild(frame);
+ if(nextFrame == null) {
+ AnimatorKeyframe nextKeyframe = (AnimatorKeyframe)currentKeyframe.getParent().getNextChild(currentKeyframe);
+ if(nextKeyframe != null) {
+ nextFrame = nextKeyframe.getFirstFrame();
+ }
+ }
+
+ return nextFrame;
+ }
+
+ public String getComputedPropertiesFromNextFrame(String key) {
+ AnimatorFrame nextFrame = getNextAnimatorFrame(this);
+ while(nextFrame != null) {
+ String value = nextFrame.getProperty(key);
+ if(value != null) {
+ return value;
+ }
+ nextFrame = getNextAnimatorFrame(nextFrame);
+ }
+
+ return null;
+ }
/**
* Get Computed Properties
Set<String> propertiesUsed = selector.getAllPropertiesUsed(selector.getMergedFrames());
return getComputedProperties(propertiesUsed);
}
+
+ public void addComputedPropertiesIfNotExist(Set<String> properties) {
+ Map<String, String> computedProperties = getComputedProperties(properties);
+ Iterator<Entry<String, String>> computedPropertiesIterator =
+ computedProperties.entrySet().iterator();
+ while (computedPropertiesIterator.hasNext()) {
+ Entry<String, String> propertyNext = computedPropertiesIterator.next();
+ String key = propertyNext.getKey();
+ if(!getProperties().containsKey(key)) {
+ addProperty(key, propertyNext.getValue());
+ }
+ }
+ }
private String createTransformProperty(Map<String, String> transformRelatedProperties,
Map<String, String> widgetProperties) {
new TransformationProperty(transformRelatedProperties, widgetProperties);
return property.toPropertyString();
}
+
+
+ /**
+ * find animated properties
+ *
+ * @param frame
+ * @param keyframe
+ */
+ public void findAnimatedPropertyAndSetInFrame(AnimatorFrame previousFrame, AnimatorFrame nextFrame) {
+ if(previousFrame == null || nextFrame == null) {
+ return;
+ }
+
+ Set<String> animatedProperties = getAnimatedProperties(previousFrame, nextFrame);
+ // set the interpolated value
+ double middle =
+ (getFrameTime() - previousFrame.getFrameTime())
+ / (nextFrame.getFrameTime() - previousFrame.getFrameTime()) * 100.0;
+ String easingProperty = previousFrame.getEasingProperty();
+ Map<String, String> previousFrameProperties = previousFrame.getComputedProperties();
+ Map<String, String> nextFrameProperties = nextFrame.getComputedProperties();
+ for (String key : animatedProperties) {
+ if (key.indexOf("color") >= 0) // TODO remove this after fixing color property
+ continue;
+ if(key.indexOf("timing-function") >=0) {
+// frame.addProperty(key, easingProperty);
+ continue;
+ }
+ String start = previousFrameProperties.get(key);
+ String end = nextFrameProperties.get(key);
+ String interpolatedValue =
+ getInterpolatedValue(key, start, end, middle, easingProperty);
+ addProperty(key, interpolatedValue);
+ }
+ if (previousFrame.getCurveFrames().size() > 0) {
+ Point p;
+ p =
+ AnimationPathModel
+ .findTranslateValueAtTime(getModelFactory(), getFrameTime(), previousFrame,
+ nextFrame,
+ AnimatorUtils.getEasingMethod(easingProperty));
+
+ addProperty(Constants.translateX, AnimatorUtils.convertPixToString(p.x));
+ addProperty(Constants.translateY, AnimatorUtils.convertPixToString(p.y));
+ }
+ }
+
+ private String getInterpolatedValue(String key, String start, String end, double middle,
+ String easingProperty) {
+ CSSProperty startValue = new CSSProperty(key, start);
+ return startValue.getInterpolcatedValue(new CSSProperty(key, end), middle,
+ AnimatorUtils.getEasingMethod(easingProperty));
+ }
+
+ /**
+ *
+ * @param previousFrame
+ * @param nextFrame
+ * @return a set of animated properties
+ */
+ private Set<String> getAnimatedProperties(AnimatorFrame previousFrame, AnimatorFrame nextFrame) {
+ Set<String> properties1 = previousFrame.getProperties().keySet();
+ Set<String> properties2 = nextFrame.getProperties().keySet();
+ Set<String> union = new HashSet<String>(properties1);
+ union.addAll(properties2);
+ return union;
+ }
}
private List<String> names = new ArrayList<String>();
private double duration = 0.0;
private double delay = 0.0;
-
+
public AnimatorKeyframe() {
// TODO Auto-generated constructor stub
}
+
/**
* Set initial property member value
* @param duration
* @param delay
*/
- public void setNames(String name) {
+ public void setName(String name) {
if (name != null) {
String[] array = name.split(",");
}
}
}
-
- /**
+
+
+ /**
* Get merged animation names
*
* @return String
*/
public String getName() {
String result = "";
+ String previousElement = null;
for (int i = 0; i < names.size(); i++) {
String element = names.get(i);
if (i == 0)
result += element;
- else
- result += "," + element;
+ else {
+ if(previousElement != null) {
+ if(previousElement.equals("custom") && element.equals("custom")) {
+
+ } else {
+ result += "," + element;
+ }
+ }
+
+ }
+ previousElement = names.get(i);
}
return result;
}
+
/**
* Add animation name If last name is custom just skip operation
* @param name
*/
public void addName(String name) {
- if (!name.equals("custom")) {
+ /*if (!name.equals("custom")) {
this.names.add(name);
} else {
if (!names.get(names.size() - 1).equals("custom"))
this.names.add(name);
- }
+ }*/
+
+
+ this.names.add(name);
}
/**
return this.names.get(this.names.size() - 1);
return null;
}
-
+
+
+
+
/**
* Remove last animation name
*/
public void removeLastName() {
- this.names.remove(this.names.size() - 1);
+ if(this.names.size() != 0) {
+ this.names.remove(this.names.size() - 1);
+ }
}
+
/**
* Get keyframe duration
*
}
if (nextParent != null) {
AnimatorFrame nextFrame = nextParent.getFirstFrame();
- assert !nextFrame.hasSamePropertyValue(frame) : "This should be always true, if not previous logic is corrupt";
+// assert !nextFrame.hasSamePropertyValue(frame) : "This should be always true, if not previous logic is corrupt";
// if (!nextFrame.hasSamePropertyValue(this)) {// doesn't need to, because
// always true; confirmation required
- if (merged) {
- previousParent.mergeFrame(nextFrame, true);
- } else {
- mergeFrame(nextFrame, true);
+ if (!nextFrame.hasSamePropertyValue(frame)) {
+ if (merged) {
+ previousParent.mergeFrame(nextFrame, true);
+ } else {
+ mergeFrame(nextFrame, true);
+ }
}
- // }
}
}
} else if (keyframeChildrenSize > 1) {// case 2
- if (getChildIndex(this) == 0) { // case 2.1 (left most case)
+ if (getChildIndex(frame) == 0) { // case 2.1 (left most case)
// merge left and check right
if (previousParent != null) {
AnimatorFrame previousFrame = previousParent.getLastFrame();
}
}
// TODO check right
- } else if (getChildIndex(this) == (keyframeChildrenSize - 1)) { // case 2.2 (right most
+ } else if (getChildIndex(frame) == (keyframeChildrenSize - 1)) { // case 2.2 (right most
// case)
// merge next frame
if (nextParent != null) {
if (nextFrame.hasSamePropertyValue(frame)) {
AnimatorKeyframe nextKeyframe =
selector.createKeyframe(getLastName(), frame.getFrameTime());
- splitFrame(nextKeyframe, nextFrame, true);
removeLastName();
+ splitFrame(nextKeyframe, nextFrame, true);
selector.addChild(nextKeyframe);
}
}
if (previousFrame.hasSamePropertyValue(frame)) {
AnimatorKeyframe currentKeyframe =
selector.createKeyframe(getLastName(), frame.getFrameTime());
- splitFrame(currentKeyframe, frame, true);
removeLastName();
+ splitFrame(currentKeyframe, frame, true);
selector.addChild(currentKeyframe);
}
}
package org.tizen.webuibuilder.animator.model;
import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Set;
-import org.eclipse.draw2d.geometry.Point;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
-import org.tizen.webuibuilder.animator.utils.Constants;
import org.tizen.webuibuilder.model.Part;
import org.tizen.webuibuilder.model.app.AppManager;
import org.tizen.webuibuilder.model.app.AppManagerForHTML;
for (AnimatorFrame frame : frames) {
keyframe.addChild(frame, false);
}
- }
- }
-
- if (keyframe != null) {
- animatorSelector.addChild(keyframe);
- if (animatorSelector.mergeKeyframe(keyframe)) {
- animatorSelector.removeChild(keyframe);
- eventSource.fireEvent(AnimatorModelEvent.EventType.KEYFRAME_REMOVE, origin,
- keyframe);
- } else {
- eventSource.fireEvent(true, animatorSelector,
- AnimatorModelEvent.EventType.KEYFRAME_ADD, origin, keyframe);
+
+ animatorSelector.addChild(keyframe);
+ if (animatorSelector.mergeKeyframe(keyframe)) {
+ animatorSelector.removeChild(keyframe);
+ eventSource.fireEvent(AnimatorModelEvent.EventType.KEYFRAME_REMOVE, origin,
+ keyframe);
+ } else {
+ eventSource.fireEvent(true, animatorSelector,
+ AnimatorModelEvent.EventType.KEYFRAME_ADD, origin, keyframe);
+ }
}
}
}
selector.addChild(keyframe);
// copyPropertiesInLeftOrRightFrame(frame, keyframe);
} else {// case 2
- findAnimatedPropertyAndSetInFrame(frame, keyframe);
+ frame.findAnimatedPropertyAndSetInFrame((AnimatorFrame) keyframe.getPrevChild(frame),
+ (AnimatorFrame) keyframe.getNextChild(frame));
+// findAnimatedPropertyAndSetInFrame(frame, keyframe);
}
eventSource.fireEvent(AnimatorModelEvent.EventType.FRAME_ADD, origin, frame);
* @param frame
* @param keyframe
*/
- private void findAnimatedPropertyAndSetInFrame(AnimatorFrame frame, AnimatorKeyframe keyframe) {
+/* private void findAnimatedPropertyAndSetInFrame(AnimatorFrame frame, AnimatorKeyframe keyframe) {
AnimatorFrame previousFrame = (AnimatorFrame) keyframe.getPrevChild(frame);
AnimatorFrame nextFrame = (AnimatorFrame) keyframe.getNextChild(frame);
if(previousFrame == null || nextFrame == null) {
CSSProperty startValue = new CSSProperty(key, start);
return startValue.getInterpolcatedValue(new CSSProperty(key, end), middle,
AnimatorUtils.getEasingMethod(easingProperty));
- }
+ }*/
/**
*
* @param nextFrame
* @return a set of animated properties
*/
- private Set<String> getAnimatedProperties(AnimatorFrame previousFrame, AnimatorFrame nextFrame) {
+ /*private Set<String> getAnimatedProperties(AnimatorFrame previousFrame, AnimatorFrame nextFrame) {
Set<String> properties1 = previousFrame.getProperties().keySet();
Set<String> properties2 = nextFrame.getProperties().keySet();
Set<String> union = new HashSet<String>(properties1);
union.addAll(properties2);
return union;
- }
+ }*/
/**
* Edit Animator frame
* @param properties
* @param origin
*/
- public Map<String, String> createOrEditAnimatorFrame(AnimatorModelFactory modelFactory,
- AnimatorSelector selector,
+ public boolean createOrEditAnimatorFrame(AnimatorSelector selector,
double currentTime,
+ Map<String, String> oldProperties,
Map<String, String> properties,
Origin origin) {
- Map<String, String> oldProperties = new HashMap<String, String>();
- AnimatorFrame frame = selector.getOrCreateAnimatorFrame(currentTime);
+ boolean isCreate = true;
+ AnimatorFrame frame = selector.getAnimatorFrameByCurrentTime(currentTime);
+ if(frame != null) {
+ isCreate = false;
+ } else {
+ frame = selector.getOrCreateAnimatorFrame(currentTime);
+ }
+
if (frame != null) {
+ AnimatorKeyframe currentKeyframe = (AnimatorKeyframe)frame.getParent();
+ AnimatorKeyframe previousParent = (AnimatorKeyframe) selector.getPrevChild(currentKeyframe);
+ int keyframeChildrenSize = currentKeyframe.getChildrenSize();
+ if (keyframeChildrenSize == 1) {
+ if (currentKeyframe.getChildIndex(frame) == 0) {
+ if (previousParent != null) {
+ if(previousParent.getChildrenSize() == 1) {
+ AnimatorFrame previousFrame = previousParent.getLastFrame();
+ previousFrame.addComputedPropertiesIfNotExist(properties.keySet());
+ }
+ }
+ }
+ }
oldProperties = frame.getProperties(properties.keySet());
frame.addOrEditProperties(properties);
}
eventSource.fireEvent(AnimatorModelEvent.EventType.FRAME_EDIT, origin, frame);
- return oldProperties;
+ return isCreate;
}
/**
*/
public void removeOrEditAnimatorFrame(AnimatorSelector selector, double currentTime,
Map<String, String> oldProperties,
- Map<String, String> properties, Origin origin) {
+ Map<String, String> properties, boolean isCreate, Origin origin) {
AnimatorKeyframe keyframe = selector.getCurrentKeyframe(currentTime);
if (keyframe != null) {
AnimatorFrame frame = keyframe.getFrameByCurrentTime(currentTime);
if (frame != null) {
frame.removeOrReplaceProperties(oldProperties, properties);
+ if (frame.getPropertySize() == 0 && isCreate) {
+ AnimatorKeyframe currentKeyframe = (AnimatorKeyframe)frame.getParent();
+ currentKeyframe.removeChild(frame, true);
+ currentKeyframe.removeLastName();
+ }
if (frame.getPropertySize() == 0) {
- keyframe.removeChild(frame, true);
eventSource.fireEvent(AnimatorModelEvent.EventType.FRAME_REMOVE, origin, frame);
} else
eventSource.fireEvent(AnimatorModelEvent.EventType.FRAME_EDIT, origin, frame);
public void removeAnimatorFrame(AnimatorModel model, String name, Origin origin) {
AnimatorFrame frame = (AnimatorFrame) model;
AnimatorKeyframe keyframe = (AnimatorKeyframe) frame.getParent();
- keyframe.removeName(name);
+// keyframe.removeName(name);
+// keyframe.removeLastName();
keyframe.removeChild(frame, true);
eventSource.fireEvent(AnimatorModelEvent.EventType.FRAME_REMOVE, origin, frame);
public double calculateMergeFrameTime(double currentTime) {
return currentTime - getDelay();
}
+
/*
* (non-Javadoc)
}
}
- private void updateSelectorTime() {
+ public void updateSelectorTime() {
// TODO find max delay value
double maxDelay = AnimatorConstants.ANIMATOR_MAX_START_TIME;
}
return frames;
}
+
+ public List<AnimatorFrame> getMergedPropertyWithWidgetProperty() {
+
+ List<AnimatorFrame> mergedFrames = getMergedFrames();
+ Set<String> propertiesUsed = getAllPropertiesUsed(mergedFrames);
+ Map<String, String> widgetProperties = getWidgetProperties(propertiesUsed);
+
+ for(AnimatorFrame mergedFrame : mergedFrames) {
+ for(String key : propertiesUsed) {
+ if(!mergedFrame.getUsedPropertiesInThisFrame().contains(key)) {
+ int index = mergedFrames.indexOf(mergedFrame);
+ if(index != 0) { // not first frame
+ if(index == mergedFrames.size() -1){ //last frame
+ AnimatorFrame previousFrame = mergedFrames.get((mergedFrames.indexOf(mergedFrame) - 1));
+ mergedFrame.addProperty(key, previousFrame.getProperty(key));
+ } else { //middle frame
+ AnimatorFrame previousFrame = mergedFrames.get(index - 1);
+ mergedFrame.addProperty(key, previousFrame.getProperty(key));
+ }
+ } else { //first frame
+ if(mergedFrame.getParent().getChildrenSize() == 1) { // if it is only frame in keyframe
+ AnimatorFrame nextFrame = mergedFrames.get(index + 1);
+ if(nextFrame != null) {
+ mergedFrame.addProperty(key, nextFrame.getProperty(key));
+ } else {
+ mergedFrame.addProperty(key, widgetProperties.get(key));
+ }
+ } else {
+ mergedFrame.addProperty(key, widgetProperties.get(key));
+ }
+ }
+ }
+ }
+ }
+
+ return mergedFrames;
+ }
/**
* Create keyframe
*/
public AnimatorKeyframe createKeyframe(String name, double frameTime) {
AnimatorKeyframe keyframe = (AnimatorKeyframe)getModelFactory().createAnimatorModel(AnimatorModelType.KEYFRAME);
- keyframe.setNames(name);
+ keyframe.setName(name);
keyframe.setDuration(0.0);
keyframe.setDelay(frameTime);
keyframe.setParent(this);
if (previousKeyframe != null) {
AnimatorFrame previousFrame = previousKeyframe.getLastFrame();
- copyLeftPropertiesToAllFramesInKeyframe(previousFrame, keyframe);
+// copyLeftPropertiesToAllFramesInKeyframe(previousFrame, keyframe);
if (previousFrame != null) {
if (!previousFrame.hasSamePropertyValue(keyframe.getFirstFrame())) {
previousKeyframe.mergeFrame(keyframe.getFirstFrame(), true);
keyframe = previousKeyframe;
result = true;
-
}
}
}
* @param previousFrame
* @param keyframe
*/
- private void copyLeftPropertiesToAllFramesInKeyframe(AnimatorFrame previousFrame,
+/* private void copyLeftPropertiesToAllFramesInKeyframe(AnimatorFrame previousFrame,
AnimatorKeyframe keyframe) {
List<AnimatorModel> frames = keyframe.getChildren();
for (AnimatorModel frameModel : frames) {
}
}
}
- }
+ }*/
/**
* Get css string
* @return css string from animation for this selector
*/
public String getCssString(AnimatorModelFactory modelFactory) {
- // String separator = System.getProperty( "line.separator" );
StringBuilder builder = new StringBuilder("\n");
if (getChildrenSize() > 0) {
String id = this.getId();
}
/**
- * 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 =
- new AnimatorFrame(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 (AnimatorModel model : frames) {
- AnimatorFrame frame = (AnimatorFrame) model;
- if (frame.getFrameTime() < addFrame.getFrameTime())
- index++;
- else
- break;
- }
-
- frames.add(index, addFrame);
- }*/
-
- /**
* if there exists a Frame, return exist frame. if not, create and return it.
*
* @param model
*/
public AnimatorFrame getOrCreateAnimatorFrame(double currentTime) {
AnimatorKeyframe keyframe = getCurrentKeyframe(currentTime);
- if (keyframe == null)
+ if (keyframe == null) {
keyframe = createKeyframe("custom", currentTime);
+ addChild(keyframe);
+ }
AnimatorFrame frame = keyframe.getFrameByCurrentTime(currentTime);
if (frame == null) {
- keyframe.createAnimatorFrame(currentTime);
+ frame = keyframe.createAnimatorFrame(currentTime);
+ keyframe.addChild(frame, true);
}
return frame;
if (property.equals("translateX") || property.equals("translateY")
|| property.equals("scaleX") || property.equals("scaleY")
|| property.equals("skewX") || property.equals("skewY")
- || property.equals("rotateZ")) {
+ || property.equals("rotateZ") || property.equals("perspective")) {
fillTransformProperties(properties, cssSelector);
} else {
CssStyle style = cssSelector.getCssStyle(property);
JsonObject jobject = (JsonObject) json;
AnimatorKeyframe keyframe = (AnimatorKeyframe)getModelFactory().createAnimatorModel(AnimatorModelType.KEYFRAME);
- keyframe.setNames(jobject.get("name").getAsString());
+ keyframe.setName(jobject.get("name").getAsString());
keyframe.setDuration(AnimatorUtils.convertTimeToDouble(jobject.get("duration").getAsString()));
keyframe.setDelay( AnimatorUtils.convertTimeToDouble(jobject.get("start").getAsString()));
}
Pattern p =
- Pattern.compile(".*translate\\((\\-?\\d*\\.?\\d+)px,\\s*(\\-?\\d*\\.?\\d+)px\\).*rotate\\((\\-?\\d*\\.?\\d+)deg\\).*scale\\((\\-?\\d*\\.?\\d+),\\s*(\\-?\\d*\\.?\\d+)\\).*skew\\((\\-?\\d*\\.?\\d+)deg,\\s*(\\-?\\d*)deg\\).*");
+ Pattern.compile(".*translate\\((\\-?\\d*\\.?\\d+)px,\\s*(\\-?\\d*\\.?\\d+)px\\).*rotate\\((\\-?\\d*\\.?\\d+)deg\\).*scale\\((\\-?\\d*\\.?\\d+),\\s*(\\-?\\d*\\.?\\d+)\\).*skew\\((\\-?\\d*\\.?\\d+)deg,\\s*(\\-?\\d*)deg\\).*perspective\\((\\-?\\d*\\.?\\d+)px\\)");
Matcher m = p.matcher(fullTransform);
if (m.find()) {
String matchValue = m.group(1);
matchValue = m.group(7);
properties.put(Constants.skewY, matchValue + "deg");
+
+ matchValue = m.group(8);
+ properties.put(Constants.perspective, matchValue + "px");
}
}
public static String skewY = "skewY";
public static String scaleX = "scaleX";
public static String scaleY = "scaleY";
+ public static String perspective = "perspective";
// css Property default value
public static String none = "none";
}
Part clone = part.cloneWidget();
+ if(clone == null) {
+ return null;
+ }
+
List<Part> children = part.getChildren();
int size = children.size();
for (int i = 0; i < size; i++) {
int size = children.size();
for (int i = 0; i < size; i++) {
Part original = children.get(i);
+ if (original == null) {
+ continue;
+ }
Part clone = original.cloneWidget();
+ if (clone == null) {
+ continue;
+ }
clones.add(clone);
int edgeSize = 7;
WidgetPosition widgetPos = ((Part) part.getModel()).getWidgetPosition();
+ if(widgetPos == null) {
+ return;
+ }
PointList polygonPoints = widgetPos.getPolygonPoints();
Point origin = null;
if (part.getPartId() != null && !part.getPartId().isEmpty()) {
WidgetPosition pos = widgetPositions.get(part.getPartId());
if (pos != null) {
- if (isFireEvent) {
+// if (isFireEvent) {
part.setVisualPosition(pos);
- } else {
- part.setVisualPosition(pos);
- }
+// } else {
+// part.setVisualPosition(pos);
+// }
}
}
currentPageEditPart = pageEditPart;
HideAllPages();
- ((HoverViewerEditPart) currentPageEditPart).getFigure().setVisible(true);
+ if(currentPageEditPart != null) {
+ ((HoverViewerEditPart) currentPageEditPart).getFigure().setVisible(true);
+ }
// DeactivateAllPages();
// currentPageEditPart.activate();
for (int i = 0; i < elementList.getLength(); i++) {
Element elem2 = (Element) elementList.item(i);
Part part = parseElement(fileData, elem2, partFactory, selectors);
- if (part.isDocumentPart()) {
+ if (part != null && part.isDocumentPart()) {
fileData.addRootPart("", part);
}
}
Node node = nodes.item(i);
if(node instanceof Element){
Part childPart = parseElement(pageFileData, part, (Element) node, manager, factory);
- part.addChildWhenPageRead(childPart);
- if (childPart.getDescriptorId().equals("tizen.page")) {
- pageFileData.addRootPart(childPart.getIdPropertyValue(), childPart);
+ if(childPart != null) {
+ part.addChildWhenPageRead(childPart);
+ if (childPart.getDescriptorId() != null && childPart.getDescriptorId().equals("tizen.page")) {
+ pageFileData.addRootPart(childPart.getIdPropertyValue(), childPart);
+ }
}
}
}
boolean includePid, Document xslt, boolean partialGen)
throws IOException {
Document doc = PageWriter.writePart(part, includePid);
-
+ if(doc == null) {
+ return;
+ }
+
Element elem0 = null;
if (partialGen) {
elem0 = doc.createElement("tizen.dummy");
if(childNode instanceof Element){
Part part = parseElement(pageFileData, (Element) childNode,
partFactory);
- if (part.isDocumentPart()) {
+ if (part != null && part.isDocumentPart()) {
pageFileData.addRootPart(BuilderConstants.EMPTY, part);
}
}
for (int i = 0; i < elemList.getLength(); i++) {
Element elem2 = (Element) elemList.item(i);
Part part = parseElement(pageFileData, elem2, partFactory, selectors);
- if (part.isDocumentPart()) {
+ if (part != null && part.isDocumentPart()) {
pageFileData.addRootPart("", part);
}
}
String imageName = null;
- if( type.equals("Boolean") ){
- imageName = null;
- }else if( type.equals( "Number" ) ){
- imageName = null;
- }else if( type.equals( "String" ) ){
- imageName = null;
- }else if( type.equals( "Array" ) ){
- imageName = "temp.png";
- }else if( type.equals( "Index" ) ){
- imageName = null;
- }else{
- imageName = null;
+// if( type.equals("Boolean") ){
+// imageName = null;
+// }else if( type.equals( "Number" ) ){
+// imageName = null;
+// }else if( type.equals( "String" ) ){
+// imageName = null;
+// }else if( type.equals( "Array" ) ){
+// imageName = "temp.png";
+// }else if( type.equals( "Index" ) ){
+// imageName = null;
+// }else{
+// imageName = null;
+// }
+
+ if( type.equals( "Array" ) ){
+ imageName = "temp.png";
}
-
+
if (imageName != null) {
treeItem.setImage ( ResourceManager.getImage( BuilderConstants.ICON_DIR, imageName ) );
}
TreeItem[] items = parentItem.getItems();
- JsonObject parentJson = null;
- JsonArray parentArray = null;
-
- if( parentJsonElement instanceof JsonObject ){
- parentJson = (JsonObject) parentJsonElement;
- } else if( parentJsonElement instanceof JsonArray ){
- parentArray = (JsonArray) parentJsonElement;
- }
-
JsonObject jsonOb = null;
if( type.equals("Array") ){
JsonArray array = new JsonArray();
- parentJson.add(key, array);
+ ((JsonObject)parentJsonElement).add(key, array);
jsonOb = null;
for (TreeItem item : items) {
if( item.getText(2).equals("Index") ){
}
}else if( type.equals("Object") ){
jsonOb = new JsonObject();
- parentJson.add(key, jsonOb);
+ ((JsonObject)parentJsonElement).add(key, jsonOb);
for (TreeItem item : items) {
makeJsonFromTree( item, jsonOb );
}
if(item.getText().length() > 0){
makeJsonFromTree( item, jsonOb );
}else{
- parentArray.add( new JsonPrimitive(item.getText(1)) );
+ ((JsonArray)parentJsonElement).add( new JsonPrimitive(item.getText(1)) );
}
}
if( !jsonOb.entrySet().isEmpty() )
- parentArray.add(jsonOb);
+ ((JsonArray)parentJsonElement).add(jsonOb);
}else if( type.equals("String") ){
- parentJson.addProperty( key, value );
+ ((JsonObject)parentJsonElement).addProperty( key, value );
}else if( type.equals("Boolean") ){
- parentJson.addProperty( key, Boolean.valueOf( value ) );
+ ((JsonObject)parentJsonElement).addProperty( key, Boolean.valueOf( value ) );
}else if( type.equals("Number") ){
- parentJson.addProperty( key, Long.parseLong( value ) );
+ ((JsonObject)parentJsonElement).addProperty( key, Long.parseLong( value ) );
}else{
- parentJson.add( key, null );
+ ((JsonObject)parentJsonElement).add( key, null );
}
}
// }
// return false;
// }
-}
+}
\ No newline at end of file
long lTime2 = d2.getTime();
double tempTime = (double) (lTime - lTime2) / 1000;
- if (dTime != 0.0 && dTime == tempTime) {
+ if (Double.compare(dTime, 0.0) != 0 && Double.compare(dTime, tempTime) == 0) {
return false;
}
public void mouseUp(MouseEvent e) {
btnNewButton.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR,
"animator_action_add_normal.png"));
- if ((text_2.getText() == null) || (text_2.getText() == "")) {
+ if ((text_2.getText() == null) || (text_2.getText().equals(BuilderConstants.EMPTY))) {
return;
}
addSelectionBar(text_2.getText());
* @param bar
*/
public void removeSelectionBar(ActionSelectBarComposite bar) {
- actionSelectionBars.remove(actionSelectionBars);
+ if (actionSelectionBars != null && !actionSelectionBars.isEmpty()) {
+ actionSelectionBars.remove(bar);
+ }
+
}
/**
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
import org.tizen.webuibuilder.gef.commands.SetPartMovePageEventCommand;
import org.tizen.webuibuilder.model.GotoPageProperty;
*/
private void valueChanged() {
String pageValue = pageCombo.getText();
- if ((pageValue == null) || (pageValue == "")) {
+ if ((pageValue == null) || (pageValue.equals(BuilderConstants.EMPTY))) {
return;
}
String transitionValue = transitionCombo.getText();
- if ((transitionValue == null) || (transitionValue == "")) {
+ if ((transitionValue == null) || (transitionValue.equals(BuilderConstants.EMPTY))) {
return;
}
static final String CLIP_WIDTH = "width";
static final String CLIP_HEIGHT = "height";
- private final int VIEW_POINT_X = 80;
- // private final int VIEW_POINT_Y = 20;
- private final int EDITOR_WIDTH = 60;
- private final int EDITOR_HEIGHT = 20;
private final int MARGIN = 10;
private final String DEFAULT_VALUE = "0";
private Label originWidth;
/**
- * This class is a inner class of the {@link ClipMethod}. This class creates a text editor and
- * then adds it to the parent {@link Composite}.
- */
- public class TextEditor {
- private final int LIMITED_LENGTH = 6;
-
- private Composite parent;
- private Label label;
- private Text editor;
-
- private final Color bgColor = new Color(null, 219, 218, 218);
-
- /**
- * Construct
- *
- * @param parent
- * the parent {@link Composite}
- * @param input
- * initial value
- */
- public TextEditor(final Composite parent, String input) {
- this.parent = parent;
- label = new Label(this.parent, SWT.CENTER | SWT.READ_ONLY | SWT.BORDER);
- editor = new Text(this.parent, SWT.CENTER | SWT.BORDER);
-
- label.setText(input);
- /** set default background color */
- label.setBackground(bgColor);
- editor.setTextLimit(LIMITED_LENGTH);
- }
-
- /**
- * This method shows the {@link Label} and hides the {@link Text}.
- */
- public void showLabel() {
- label.setVisible(true);
- editor.setVisible(false);
- }
-
- /**
- * This method shows the {@link Text} and hides the {@link Label}.
- */
- public void showEditor() {
- label.setVisible(false);
- editor.setVisible(true);
-
- editor.setText(label.getText());
- editor.selectAll();
- editor.setFocus();
- }
-
- /**
- * This method returns the parent {@link Composite} of the {@link TextEditor}.
- *
- * @return a {@link Composite}
- */
- public Composite getParent() {
- return parent;
- }
-
- /**
- * This method returns the {@link Label} of the {@link TextEditor}.
- *
- * @return a {@link Label}
- */
- public Label getLabel() {
- return label;
- }
-
- /**
- * This method returns the {@link Text} of the {@link TextEditor}.
- *
- * @return a {@link Text}
- */
- public Text getEditor() {
- return editor;
- }
-
- /**
- * This method set value of the {@link Label}.
- *
- * @param value
- * new value of the {@link Label}
- */
- public void setLabel(String value) {
- if (label == null || label.isDisposed()) {
- return;
- }
- label.setText(value);
- }
-
- /**
- * This method set {@link MouseListener} for the mouse event at the {@link Label}.
- *
- * @param listener
- * a {@link MouseListener}
- */
- public void setLabelListener(MouseListener listener) {
- label.addMouseListener(listener);
- }
-
- /**
- * This method set {@link Listener} for the keyboard and mouse event at the {@link Text}.
- *
- * @param listener
- * a {@link Listener}
- */
- public void setEditorListener(Listener listener) {
- editor.addListener(SWT.FocusOut, listener);
- editor.addListener(SWT.Traverse, listener);
- editor.addListener(SWT.Deactivate, listener);
- }
-
- /**
- * This method set top position of the {@link TextEditor} included in the 'Clip component'.
- *
- * @param left
- * a {@link Label}, which is located on the left side
- */
- public void setTopPosition(final Label left) {
- FormData topEditorData = new FormData();
- topEditorData.left = new FormAttachment(left, 0);
- // topEditorData.top = new FormAttachment(0, VIEW_POINT_Y);
- topEditorData.top = new FormAttachment(0, 0);
- topEditorData.right = new FormAttachment(left, EDITOR_WIDTH * 2);
- // topEditorData.bottom = new FormAttachment(0, VIEW_POINT_Y + EDITOR_HEIGHT);
- topEditorData.bottom = new FormAttachment(0, EDITOR_HEIGHT);
- label.setLayoutData(topEditorData);
- editor.setLayoutData(topEditorData);
- }
-
- /**
- * This method set right position of the {@link TextEditor} included in the 'Clip
- * component'.
- *
- * @param left
- * a {@link Label}, which is located on the left side
- */
- public void setRightPosition(final Label left) {
- FormData rightEditorData = new FormData();
- rightEditorData.left = new FormAttachment(left, 0);
- rightEditorData.top = new FormAttachment(0, EDITOR_HEIGHT);
- rightEditorData.right = new FormAttachment(left, EDITOR_WIDTH * 2);
- rightEditorData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 2);
- label.setLayoutData(rightEditorData);
- editor.setLayoutData(rightEditorData);
- }
-
- /**
- * This method set left position of the {@link TextEditor} included in the 'Clip component'.
- */
- public void setLeftPosition() {
- FormData rightEditorData = new FormData();
- rightEditorData.left = new FormAttachment(0, VIEW_POINT_X);
- rightEditorData.top = new FormAttachment(0, EDITOR_HEIGHT);
- rightEditorData.right = new FormAttachment(0, VIEW_POINT_X + EDITOR_WIDTH);
- rightEditorData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 2);
- label.setLayoutData(rightEditorData);
- editor.setLayoutData(rightEditorData);
- }
-
- /**
- * This method set bottom position of the {@link TextEditor} included in the 'Clip
- * component'.
- *
- * @param left
- * a {@link Label}, which is located on the left side
- */
- public void setBottomPosition(final Label left) {
- FormData bottomEditorData = new FormData();
- bottomEditorData.left = new FormAttachment(left, 0);
- bottomEditorData.top = new FormAttachment(0, EDITOR_HEIGHT * 2);
- bottomEditorData.right = new FormAttachment(left, EDITOR_WIDTH * 2);
- bottomEditorData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 3);
- label.setLayoutData(bottomEditorData);
- editor.setLayoutData(bottomEditorData);
- }
- }
-
- /**
* Construct
*
* @param parent
Label blankTopLeft = createBlankLabel(composite);
// blankTL.addPaintListener(fillLabelBGListener());
FormData blankTopLeftData = new FormData();
- blankTopLeftData.left = new FormAttachment(0, VIEW_POINT_X);
+ blankTopLeftData.left = new FormAttachment(0, TextEditor.VIEW_POINT_X);
// blankTopLeftData.top = new FormAttachment(0, VIEW_POINT_Y);
blankTopLeftData.top = new FormAttachment(0, 0);
- blankTopLeftData.right = new FormAttachment(0, VIEW_POINT_X + EDITOR_WIDTH);
- // blankTopLeftData.bottom = new FormAttachment(0, VIEW_POINT_Y + EDITOR_HEIGHT);
- blankTopLeftData.bottom = new FormAttachment(0, EDITOR_HEIGHT);
+ blankTopLeftData.right = new FormAttachment(0, TextEditor.VIEW_POINT_X + TextEditor.EDITOR_WIDTH);
+ // blankTopLeftData.bottom = new FormAttachment(0, VIEW_POINT_Y + TextEditor.EDITOR_HEIGHT);
+ blankTopLeftData.bottom = new FormAttachment(0, TextEditor.EDITOR_HEIGHT);
blankTopLeft.setLayoutData(blankTopLeftData);
topTextEditor = new TextEditor(composite, DEFAULT_VALUE);
FormData blankTopRightData = new FormData();
blankTopRightData.left = new FormAttachment(topTextEditor.getLabel(), 0);
blankTopRightData.top = new FormAttachment(0, 0);
- blankTopRightData.right = new FormAttachment(topTextEditor.getLabel(), EDITOR_WIDTH * 2);
- blankTopRightData.bottom = new FormAttachment(0, EDITOR_HEIGHT);
+ blankTopRightData.right = new FormAttachment(topTextEditor.getLabel(), TextEditor.EDITOR_WIDTH * 2);
+ blankTopRightData.bottom = new FormAttachment(0, TextEditor.EDITOR_HEIGHT);
blankTopRight.setLayoutData(blankTopRightData);
/**
// blankCenter.addPaintListener(fillLabelBGListener());
FormData blankCenterData = new FormData();
blankCenterData.left = new FormAttachment(leftTextEditor.getLabel(), 0);
- blankCenterData.top = new FormAttachment(0, EDITOR_HEIGHT);
- blankCenterData.right = new FormAttachment(leftTextEditor.getLabel(), EDITOR_WIDTH * 2);
- blankCenterData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 2);
+ blankCenterData.top = new FormAttachment(0, TextEditor.EDITOR_HEIGHT);
+ blankCenterData.right = new FormAttachment(leftTextEditor.getLabel(), TextEditor.EDITOR_WIDTH * 2);
+ blankCenterData.bottom = new FormAttachment(0, TextEditor.EDITOR_HEIGHT * 2);
blankCenter.setLayoutData(blankCenterData);
rightTextEditor = new TextEditor(composite, DEFAULT_VALUE);
Label blankBottomLeft = createBlankLabel(composite);
// blankBottomLeft.addPaintListener(fillLabelBGListener());
FormData blankBottomLeftData = new FormData();
- blankBottomLeftData.left = new FormAttachment(0, VIEW_POINT_X);
- blankBottomLeftData.top = new FormAttachment(0, EDITOR_HEIGHT * 2);
- blankBottomLeftData.right = new FormAttachment(0, VIEW_POINT_X + EDITOR_WIDTH);
- blankBottomLeftData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 3);
+ blankBottomLeftData.left = new FormAttachment(0, TextEditor.VIEW_POINT_X);
+ blankBottomLeftData.top = new FormAttachment(0, TextEditor.EDITOR_HEIGHT * 2);
+ blankBottomLeftData.right = new FormAttachment(0, TextEditor.VIEW_POINT_X + TextEditor.EDITOR_WIDTH);
+ blankBottomLeftData.bottom = new FormAttachment(0, TextEditor.EDITOR_HEIGHT * 3);
blankBottomLeft.setLayoutData(blankBottomLeftData);
bottomTextEditor = new TextEditor(composite, DEFAULT_VALUE);
// blankBottomRight.addPaintListener(fillLabelBGListener());
FormData blankBottomRightData = new FormData();
blankBottomRightData.left = new FormAttachment(bottomTextEditor.getLabel(), 0);
- blankBottomRightData.top = new FormAttachment(0, EDITOR_HEIGHT * 2);
+ blankBottomRightData.top = new FormAttachment(0, TextEditor.EDITOR_HEIGHT * 2);
blankBottomRightData.right =
- new FormAttachment(bottomTextEditor.getLabel(), EDITOR_WIDTH * 2);
- blankBottomRightData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 3);
+ new FormAttachment(bottomTextEditor.getLabel(), TextEditor.EDITOR_WIDTH * 2);
+ blankBottomRightData.bottom = new FormAttachment(0, TextEditor.EDITOR_HEIGHT * 3);
blankBottomRight.setLayoutData(blankBottomRightData);
/**
leftArrow
.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR, LEFT_ARROW_IMG_PATH));
FormData leftArrowData = new FormData();
- leftArrowData.left = new FormAttachment(0, VIEW_POINT_X);
+ leftArrowData.left = new FormAttachment(0, TextEditor.VIEW_POINT_X);
leftArrowData.top = new FormAttachment(bottomTextEditor.getLabel(), MARGIN);
- leftArrowData.right = new FormAttachment(0, VIEW_POINT_X + EDITOR_WIDTH);
+ leftArrowData.right = new FormAttachment(0, TextEditor.VIEW_POINT_X + TextEditor.EDITOR_WIDTH);
leftArrowData.bottom = new FormAttachment(100, -MARGIN);
leftArrow.setLayoutData(leftArrowData);
FormData originWidthData = new FormData();
originWidthData.left = new FormAttachment(leftArrow, 0);
originWidthData.top = new FormAttachment(bottomTextEditor.getLabel(), MARGIN);
- originWidthData.right = new FormAttachment(leftArrow, EDITOR_WIDTH * 2);
+ originWidthData.right = new FormAttachment(leftArrow, TextEditor.EDITOR_WIDTH * 2);
originWidthData.bottom = new FormAttachment(100, -MARGIN);
originWidth.setLayoutData(originWidthData);
FormData rightArrowData = new FormData();
rightArrowData.left = new FormAttachment(originWidth, 0);
rightArrowData.top = new FormAttachment(bottomTextEditor.getLabel(), MARGIN);
- rightArrowData.right = new FormAttachment(originWidth, EDITOR_WIDTH * 2);
+ rightArrowData.right = new FormAttachment(originWidth, TextEditor.EDITOR_WIDTH * 2);
rightArrowData.bottom = new FormAttachment(100, -MARGIN);
rightArrow.setLayoutData(rightArrowData);
FormData upArrowData = new FormData();
upArrowData.left = new FormAttachment(rightTextEditor.getLabel(), 0);
upArrowData.top = new FormAttachment(0, 0);
- // upArrowData.right = new FormAttachment(100, -EDITOR_WIDTH);
- upArrowData.right = new FormAttachment(rightTextEditor.getLabel(), EDITOR_WIDTH * 2);
- upArrowData.bottom = new FormAttachment(0, EDITOR_HEIGHT);
+ // upArrowData.right = new FormAttachment(100, -TextEditor.EDITOR_WIDTH);
+ upArrowData.right = new FormAttachment(rightTextEditor.getLabel(), TextEditor.EDITOR_WIDTH * 2);
+ upArrowData.bottom = new FormAttachment(0, TextEditor.EDITOR_HEIGHT);
upArrow.setLayoutData(upArrowData);
originHeight = new Label(composite, SWT.CENTER | SWT.READ_ONLY);
originHeight.setText(DEFAULT_VALUE);
FormData originHeightData = new FormData();
originHeightData.left = new FormAttachment(rightTextEditor.getLabel(), 0);
- originHeightData.top = new FormAttachment(0, EDITOR_HEIGHT);
- // originHeightData.right = new FormAttachment(100, -EDITOR_WIDTH);
- originHeightData.right = new FormAttachment(rightTextEditor.getLabel(), EDITOR_WIDTH * 2);
- originHeightData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 2);
+ originHeightData.top = new FormAttachment(0, TextEditor.EDITOR_HEIGHT);
+ // originHeightData.right = new FormAttachment(100, -TextEditor.EDITOR_WIDTH);
+ originHeightData.right = new FormAttachment(rightTextEditor.getLabel(), TextEditor.EDITOR_WIDTH * 2);
+ originHeightData.bottom = new FormAttachment(0, TextEditor.EDITOR_HEIGHT * 2);
originHeight.setLayoutData(originHeightData);
Label downArrow = new Label(composite, SWT.CENTER | SWT.READ_ONLY);
downArrow.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR, DOWN_ARROW_PATH));
FormData downArrowData = new FormData();
downArrowData.left = new FormAttachment(rightTextEditor.getLabel(), 0);
- downArrowData.top = new FormAttachment(0, EDITOR_HEIGHT * 2);
- // downArrowData.right = new FormAttachment(100, -EDITOR_WIDTH);
- downArrowData.right = new FormAttachment(rightTextEditor.getLabel(), EDITOR_WIDTH * 2);
- downArrowData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 3);
+ downArrowData.top = new FormAttachment(0, TextEditor.EDITOR_HEIGHT * 2);
+ // downArrowData.right = new FormAttachment(100, -TextEditor.EDITOR_WIDTH);
+ downArrowData.right = new FormAttachment(rightTextEditor.getLabel(), TextEditor.EDITOR_WIDTH * 2);
+ downArrowData.bottom = new FormAttachment(0, TextEditor.EDITOR_HEIGHT * 3);
downArrow.setLayoutData(downArrowData);
Label unit = new Label(composite, SWT.CENTER | SWT.READ_ONLY);
FormData unitData = new FormData();
unitData.left = new FormAttachment(rightTextEditor.getLabel(), 0);
unitData.top = new FormAttachment(bottomTextEditor.getLabel(), MARGIN);
- unitData.right = new FormAttachment(rightTextEditor.getLabel(), EDITOR_WIDTH * 2);
+ unitData.right = new FormAttachment(rightTextEditor.getLabel(), TextEditor.EDITOR_WIDTH * 2);
unitData.bottom = new FormAttachment(100, -MARGIN);
unit.setLayoutData(unitData);
--- /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.ui.views.properties.method;
+
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * This class creates a color data model that contains Alpha value and {@link RGB} value.
+ */
+public class ColorData {
+
+ private int alphaValue;
+ private RGB rgbValue;
+
+ /**
+ * Construct
+ *
+ * @param alpha
+ * alpha value of the {@link ColorData}
+ * @param rgb
+ * a {@link RGB}
+ */
+ public ColorData(int alpha, RGB rgb) {
+ alphaValue = alpha;
+ rgbValue = rgb;
+ }
+
+ /**
+ * This method returns the alpha value of the {@link ColorData}.
+ *
+ * @return alpha value of the {@link ColorData}
+ */
+ public int getAlphaValue() {
+ return alphaValue;
+ }
+
+ /**
+ * This method returns the {@link RGB} of the {@link ColorData}.
+ *
+ * @return a {@link RGB}
+ */
+ public RGB getRGBValue() {
+ return rgbValue;
+ }
+
+ /**
+ * This method set alpha value of the {@link ColorData}.
+ *
+ * @param value
+ * new alpha value of the {@link ColorData}
+ */
+ public void setAlphaValue(int value) {
+ alphaValue = value;
+ }
+
+ /**
+ * This method set {@link RGB} value of the {@link ColorData}.
+ *
+ * @param value
+ * new {@link RGB}
+ */
+ public void setRGBValue(RGB value) {
+ rgbValue = value;
+ }
+}
private final int MARGIN = 20;
/**
- * This class is a inner class of the {@link ColorFillMethod}. This class creates a color data
- * model that contains Alpha value and {@link RGB} value.
- */
- public class ColorData {
- private int alphaValue;
- private RGB rgbValue;
-
- /**
- * Construct
- *
- * @param alpha
- * alpha value of the {@link ColorData}
- * @param rgb
- * a {@link RGB}
- */
- public ColorData(int alpha, RGB rgb) {
- alphaValue = alpha;
- rgbValue = rgb;
- }
-
- /**
- * This method returns the alpha value of the {@link ColorData}.
- *
- * @return alpha value of the {@link ColorData}
- */
- public int getAlphaValue() {
- return alphaValue;
- }
-
- /**
- * This method returns the {@link RGB} of the {@link ColorData}.
- *
- * @return a {@link RGB}
- */
- public RGB getRGBValue() {
- return rgbValue;
- }
-
- /**
- * This method set alpha value of the {@link ColorData}.
- *
- * @param value
- * new alpha value of the {@link ColorData}
- */
- public void setAlphaValue(int value) {
- alphaValue = value;
- }
-
- /**
- * This method set {@link RGB} value of the {@link ColorData}.
- *
- * @param value
- * new {@link RGB}
- */
- public void setRGBValue(RGB value) {
- rgbValue = value;
- }
- }
-
- /**
- * This class is a inner class of the {@link ColorFillMethod}. This class is used to represent
- * the custom color.
- */
- public class UserColorData {
- private ColorData color;
- private int labelWidth;
- private int labelHeight;
-
- /**
- * Construct
- *
- * @param color
- * custom {@link ColorData}
- * @param width
- * width of the area to represent the custom color
- * @param height
- * height of the area to represent the custom color
- */
- public UserColorData(ColorData color, int width, int height) {
- this.color = color;
- labelWidth = width;
- labelHeight = height;
- }
-
- /**
- * This method returns color data.
- *
- * @return a {@link ColorData}
- */
- public ColorData getColorData() {
- return color;
- }
-
- /**
- * This method returns width of the area to represent the custom color.
- *
- * @return width of the area to represent the custom color
- */
- public int getLabelWidth() {
- return labelWidth;
- }
-
- /**
- * Thid method returns height of the area to represent the custom color.
- *
- * @return height of the area to represent the custom color
- */
- public int getLabelHeight() {
- return labelHeight;
- }
-
- /**
- * This method set color data.
- *
- * @param color
- * new {@link ColorData}
- */
- public void setColorData(ColorData color) {
- this.color = color;
- }
-
- /**
- * This method set width of the area to represent the custom color.
- *
- * @param width
- * width of the area to represent the custom color
- */
- public void setLabelWidth(int width) {
- labelWidth = width;
- }
-
- /**
- * This method set height of the area to represent the custom color.
- *
- * @param height
- * height of the area to represent the custom color
- */
- public void setLabelHeight(int height) {
- labelHeight = height;
- }
- }
-
- /**
* Enumerations for the color format
*/
public enum ColorType {
NONE, HEX, RGB, RGBA
};
- private List<ColorData> usedColorDataList;
- private List<ColorData> usingColorDataList;
+ //TODO : implements used, using.
+// private List<ColorData> usedColorDataList;
+// private List<ColorData> usingColorDataList;
private List<UserColorData> userColorDataList;
private List<Label> userColorViewList;
userBrightness = 0f;
/** TODO : add data loading & set loaded data - usedColor, usingColor, userColor */
- usedColorDataList = new ArrayList<ColorData>(MAX_LIST_COUNT);
- usingColorDataList = new ArrayList<ColorData>(MAX_LIST_COUNT);
+// usedColorDataList = new ArrayList<ColorData>(MAX_LIST_COUNT);
+// usingColorDataList = new ArrayList<ColorData>(MAX_LIST_COUNT);
userColorViewList = new ArrayList<Label>(MAX_LIST_COUNT - 1);
/** saturation : x / brightness : y */
private final int MARGIN = 20;
/**
- * This class is a inner class of the {@link NewColorMethod}. This class creates a color data
- * model that contains Alpha value and {@link RGB} value.
- */
- public class ColorData {
- private int alphaValue;
- private RGB rgbValue;
-
- /**
- * Construct
- *
- * @param alpha
- * alpha value of the {@link ColorData}
- * @param rgb
- * a {@link RGB}
- */
- public ColorData(int alpha, RGB rgb) {
- alphaValue = alpha;
- rgbValue = rgb;
- }
-
- /**
- * This method returns the alpha value of the {@link ColorData}.
- *
- * @return alpha value of the {@link ColorData}
- */
- public int getAlphaValue() {
- return alphaValue;
- }
-
- /**
- * This method returns the {@link RGB} of the {@link ColorData}.
- *
- * @return {@link RGB} of the {@link ColorData}
- */
- public RGB getRGBValue() {
- return rgbValue;
- }
-
- /**
- * This method set alpha value of the {@link ColorData}.
- *
- * @param value
- * new alpha value of the {@link ColorData}
- */
- public void setAlphaValue(int value) {
- alphaValue = value;
- }
-
- /**
- * This method set {@link RGB} value of the {@link ColorData}.
- *
- * @param value
- * new {@link RGB} of the {@link ColorData}
- */
- public void setRGBValue(RGB value) {
- rgbValue = value;
- }
- }
-
- /**
- * This class is a inner class of the {@link NewColorMethod}. This class is used to represent
- * the custom color.
- */
- public class UserColorData {
- private ColorData color;
- private int labelWidth;
- private int labelHeight;
-
- /**
- * Construct
- *
- * @param color
- * custom {@link ColorData}
- * @param width
- * width of the area to represent the custom color
- * @param height
- * height of the area to represent the custom color
- */
- public UserColorData(ColorData color, int width, int height) {
- this.color = color;
- labelWidth = width;
- labelHeight = height;
- }
-
- /**
- * This method returns {@link ColorData}.
- *
- * @return a {@link ColorData}
- */
- public ColorData getColorData() {
- return color;
- }
-
- /**
- * This method returns width of the area to represent the custom color.
- *
- * @return width of the area to represent the custom color
- */
- public int getLabelWidth() {
- return labelWidth;
- }
-
- /**
- * Thid method returns height of the area to represent the custom color.
- *
- * @return height of the area to represent the custom color
- */
- public int getLabelHeight() {
- return labelHeight;
- }
-
- /**
- * This method set {@link ColorData}.
- *
- * @param color
- * new {@link ColorData}
- */
- public void setColorData(ColorData color) {
- this.color = color;
- }
-
- /**
- * This method set width of the area to represent the custom color.
- *
- * @param width
- * width of the area to represent the custom color
- */
- public void setLabelWidth(int width) {
- labelWidth = width;
- }
-
- /**
- * This method set height of the area to represent the custom color.
- *
- * @param height
- * height of the area to represent the custom color
- */
- public void setLabelHeight(int height) {
- labelHeight = height;
- }
- }
-
- /**
* Enumerations for the color format
*/
public enum ColorType {
NONE, HEX, RGB, RGBA
};
- private List<ColorData> usedColorDataList;
- private List<ColorData> usingColorDataList;
+ // TODO : implements used, using.
+// private List<ColorData> usedColorDataList;
+// private List<ColorData> usingColorDataList;
private List<UserColorData> userColorDataList;
private List<Label> userColorViewList;
// }
/** TODO : add data loading & set loaded data - usedColor, usingColor, userColor */
- usedColorDataList = new ArrayList<ColorData>(MAX_LIST_COUNT);
- usingColorDataList = new ArrayList<ColorData>(MAX_LIST_COUNT);
+// usedColorDataList = new ArrayList<ColorData>(MAX_LIST_COUNT);
+// usingColorDataList = new ArrayList<ColorData>(MAX_LIST_COUNT);
userColorViewList = new ArrayList<Label>(MAX_LIST_COUNT - 1);
/** saturation : x / brightness : y */
--- /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.ui.views.properties.method;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * This class creates a text editor and then adds it to the parent {@link Composite}.
+ */
+public class TextEditor {
+
+ public static final int VIEW_POINT_X = 80;
+ public static final int EDITOR_WIDTH = 60;
+ public static final int EDITOR_HEIGHT = 20;
+ private final int LIMITED_LENGTH = 6;
+
+ private Composite parent;
+ private Label label;
+ private Text editor;
+
+ private final Color bgColor = new Color(null, 219, 218, 218);
+
+ /**
+ * Construct
+ *
+ * @param parent
+ * the parent {@link Composite}
+ * @param input
+ * initial value
+ */
+ public TextEditor(final Composite parent, String input) {
+ this.parent = parent;
+ label = new Label(this.parent, SWT.CENTER | SWT.READ_ONLY | SWT.BORDER);
+ editor = new Text(this.parent, SWT.CENTER | SWT.BORDER);
+
+ label.setText(input);
+ /** set default background color */
+ label.setBackground(bgColor);
+ editor.setTextLimit(LIMITED_LENGTH);
+ }
+
+ /**
+ * This method shows the {@link Label} and hides the {@link Text}.
+ */
+ public void showLabel() {
+ label.setVisible(true);
+ editor.setVisible(false);
+ }
+
+ /**
+ * This method shows the {@link Text} and hides the {@link Label}.
+ */
+ public void showEditor() {
+ label.setVisible(false);
+ editor.setVisible(true);
+
+ editor.setText(label.getText());
+ editor.selectAll();
+ editor.setFocus();
+ }
+
+ /**
+ * This method returns the parent {@link Composite} of the {@link TextEditor}.
+ *
+ * @return a {@link Composite}
+ */
+ public Composite getParent() {
+ return parent;
+ }
+
+ /**
+ * This method returns the {@link Label} of the {@link TextEditor}.
+ *
+ * @return a {@link Label}
+ */
+ public Label getLabel() {
+ return label;
+ }
+
+ /**
+ * This method returns the {@link Text} of the {@link TextEditor}.
+ *
+ * @return a {@link Text}
+ */
+ public Text getEditor() {
+ return editor;
+ }
+
+ /**
+ * This method set value of the {@link Label}.
+ *
+ * @param value
+ * new value of the {@link Label}
+ */
+ public void setLabel(String value) {
+ if (label == null || label.isDisposed()) {
+ return;
+ }
+ label.setText(value);
+ }
+
+ /**
+ * This method set {@link MouseListener} for the mouse event at the {@link Label}.
+ *
+ * @param listener
+ * a {@link MouseListener}
+ */
+ public void setLabelListener(MouseListener listener) {
+ label.addMouseListener(listener);
+ }
+
+ /**
+ * This method set {@link Listener} for the keyboard and mouse event at the {@link Text}.
+ *
+ * @param listener
+ * a {@link Listener}
+ */
+ public void setEditorListener(Listener listener) {
+ editor.addListener(SWT.FocusOut, listener);
+ editor.addListener(SWT.Traverse, listener);
+ editor.addListener(SWT.Deactivate, listener);
+ }
+
+ /**
+ * This method set top position of the {@link TextEditor} included in the 'Clip component'.
+ *
+ * @param left
+ * a {@link Label}, which is located on the left side
+ */
+ public void setTopPosition(final Label left) {
+ FormData topEditorData = new FormData();
+ topEditorData.left = new FormAttachment(left, 0);
+ // topEditorData.top = new FormAttachment(0, VIEW_POINT_Y);
+ topEditorData.top = new FormAttachment(0, 0);
+ topEditorData.right = new FormAttachment(left, EDITOR_WIDTH * 2);
+ // topEditorData.bottom = new FormAttachment(0, VIEW_POINT_Y + EDITOR_HEIGHT);
+ topEditorData.bottom = new FormAttachment(0, EDITOR_HEIGHT);
+ label.setLayoutData(topEditorData);
+ editor.setLayoutData(topEditorData);
+ }
+
+ /**
+ * This method set right position of the {@link TextEditor} included in the 'Clip
+ * component'.
+ *
+ * @param left
+ * a {@link Label}, which is located on the left side
+ */
+ public void setRightPosition(final Label left) {
+ FormData rightEditorData = new FormData();
+ rightEditorData.left = new FormAttachment(left, 0);
+ rightEditorData.top = new FormAttachment(0, EDITOR_HEIGHT);
+ rightEditorData.right = new FormAttachment(left, EDITOR_WIDTH * 2);
+ rightEditorData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 2);
+ label.setLayoutData(rightEditorData);
+ editor.setLayoutData(rightEditorData);
+ }
+
+ /**
+ * This method set left position of the {@link TextEditor} included in the 'Clip component'.
+ */
+ public void setLeftPosition() {
+ FormData rightEditorData = new FormData();
+ rightEditorData.left = new FormAttachment(0, VIEW_POINT_X);
+ rightEditorData.top = new FormAttachment(0, EDITOR_HEIGHT);
+ rightEditorData.right = new FormAttachment(0, VIEW_POINT_X + EDITOR_WIDTH);
+ rightEditorData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 2);
+ label.setLayoutData(rightEditorData);
+ editor.setLayoutData(rightEditorData);
+ }
+
+ /**
+ * This method set bottom position of the {@link TextEditor} included in the 'Clip
+ * component'.
+ *
+ * @param left
+ * a {@link Label}, which is located on the left side
+ */
+ public void setBottomPosition(final Label left) {
+ FormData bottomEditorData = new FormData();
+ bottomEditorData.left = new FormAttachment(left, 0);
+ bottomEditorData.top = new FormAttachment(0, EDITOR_HEIGHT * 2);
+ bottomEditorData.right = new FormAttachment(left, EDITOR_WIDTH * 2);
+ bottomEditorData.bottom = new FormAttachment(0, EDITOR_HEIGHT * 3);
+ label.setLayoutData(bottomEditorData);
+ editor.setLayoutData(bottomEditorData);
+ }
+}
--- /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.ui.views.properties.method;
+
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * This class creates a color data model that contains Alpha value and {@link RGB} value.
+ */
+public class UserColorData {
+
+ private ColorData color;
+ private int labelWidth;
+ private int labelHeight;
+
+ /**
+ * Construct
+ *
+ * @param color
+ * custom {@link ColorData}
+ * @param width
+ * width of the area to represent the custom color
+ * @param height
+ * height of the area to represent the custom color
+ */
+ public UserColorData(ColorData color, int width, int height) {
+ this.color = color;
+ labelWidth = width;
+ labelHeight = height;
+ }
+
+ /**
+ * This method returns color data.
+ *
+ * @return a {@link ColorData}
+ */
+ public ColorData getColorData() {
+ return color;
+ }
+
+ /**
+ * This method returns width of the area to represent the custom color.
+ *
+ * @return width of the area to represent the custom color
+ */
+ public int getLabelWidth() {
+ return labelWidth;
+ }
+
+ /**
+ * Thid method returns height of the area to represent the custom color.
+ *
+ * @return height of the area to represent the custom color
+ */
+ public int getLabelHeight() {
+ return labelHeight;
+ }
+
+ /**
+ * This method set color data.
+ *
+ * @param color
+ * new {@link ColorData}
+ */
+ public void setColorData(ColorData color) {
+ this.color = color;
+ }
+
+ /**
+ * This method set width of the area to represent the custom color.
+ *
+ * @param width
+ * width of the area to represent the custom color
+ */
+ public void setLabelWidth(int width) {
+ labelWidth = width;
+ }
+
+ /**
+ * This method set height of the area to represent the custom color.
+ *
+ * @param height
+ * height of the area to represent the custom color
+ */
+ public void setLabelHeight(int height) {
+ labelHeight = height;
+ }
+}
private void putMapProperty(Map<String, String> propertiesMap, String key, String defaultValue) {
String value = getIntervalValue(key);
- if (value == null || value == BuilderConstants.EMPTY) {
+ if (value == null || value.equals(BuilderConstants.EMPTY)) {
value = defaultValue;
}
if (frameTime > currentTime) {
nextIndex = iter;
break;
- } else if (frameTime == currentTime) {
+ } else if (Double.compare(frameTime, currentTime) == 0) {
currentFrame = frame;
if (iter + 1 < frameListSize) {
nextIndex = iter + 1;
private String getTransformValueBetweenTwoFrames(String propertyName,
AnimatorFrame previewFrame,
AnimatorFrame postFrame, double currentTime) {
- if (propertyName != null && propertyName == BuilderConstants.EMPTY) {
+ if (propertyName != null && propertyName.equals(BuilderConstants.EMPTY)) {
return null;
}
if (previewFrame == null && postFrame == null) {