You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2018/09/03 09:16:29 UTC
[royale-asjs] 07/13: Enable CompoundGraphic for transformations
(and blending some browsers).
This is an automated email from the ASF dual-hosted git repository.
harbs pushed a commit to branch feature/new_merge
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit b2752cf9a64d9889e06722c1193d6c3f257ee366
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Tue Jul 17 11:02:09 2018 +0300
Enable CompoundGraphic for transformations (and blending some browsers).
---
.../projects/Basic/src/main/royale/BasicClasses.as | 1 +
.../org/apache/royale/svg/CompoundGraphic.as | 19 +++--
.../royale/svg/TransformableCompoundGraphic.as | 93 ++++++++++++++++++++++
3 files changed, 108 insertions(+), 5 deletions(-)
diff --git a/frameworks/projects/Basic/src/main/royale/BasicClasses.as b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
index e5560ab..4faef78 100644
--- a/frameworks/projects/Basic/src/main/royale/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
@@ -283,6 +283,7 @@ internal class BasicClasses
import org.apache.royale.svg.Path; Path;
import org.apache.royale.svg.Text; Text;
import org.apache.royale.svg.CompoundGraphic; CompoundGraphic;
+ import org.apache.royale.svg.TransformableCompoundGraphic; TransformableCompoundGraphic;
import org.apache.royale.html.beads.models.DataProviderModel; DataProviderModel;
import org.apache.royale.html.beads.DataContainerView; DataContainerView;
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/CompoundGraphic.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/CompoundGraphic.as
index b980695..7f80d4d 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/CompoundGraphic.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/CompoundGraphic.as
@@ -200,7 +200,7 @@ package org.apache.royale.svg
rect.setAttribute('rx', radiusX);
rect.setAttribute('ry', radiusY);
}
- element.appendChild(rect);
+ addElementToSurface(rect);
}
}
@@ -239,7 +239,7 @@ package org.apache.royale.svg
ellipse.setAttribute('cy', y + height / 2);
ellipse.setAttribute('rx', width / 2);
ellipse.setAttribute('ry', height / 2);
- element.appendChild(ellipse);
+ addElementToSurface(ellipse);
}
}
@@ -276,7 +276,7 @@ package org.apache.royale.svg
circle.setAttribute('cy', y);
circle.setAttribute('rx', radius);
circle.setAttribute('ry', radius);
- element.appendChild(circle);
+ addElementToSurface(circle);
}
}
@@ -332,7 +332,7 @@ package org.apache.royale.svg
path.style.top = "0px";
path.setAttribute('style', style);
path.setAttribute('d', data);
- element.appendChild(path);
+ addElementToSurface(path);
}
}
@@ -550,7 +550,7 @@ package org.apache.royale.svg
text.setAttribute('y', y + 15);
var textNode:Text = document.createTextNode(value) as Text;
text.appendChild(textNode as Node);
- element.appendChild(text);
+ addElementToSurface(text);
return text;
}
}
@@ -585,5 +585,14 @@ package org.apache.royale.svg
}
+ /*
+ * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+ */
+ COMPILE::JS
+ protected function addElementToSurface(e:WrappedHTMLElement):void
+ {
+ element.appendChild(e);
+ }
+
}
}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/TransformableCompoundGraphic.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/TransformableCompoundGraphic.as
new file mode 100644
index 0000000..e23827f
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/TransformableCompoundGraphic.as
@@ -0,0 +1,93 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+package org.apache.royale.svg
+{
+
+ /**
+ * TransformableCompoundGraphic adds a <g> element in which drawn elements are nested.
+ * This is useful for applying transforms and other low level operations not available on SVG elements.
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.3
+ */
+ COMPILE::JS
+ {
+ import org.apache.royale.core.WrappedHTMLElement;
+ }
+ public class TransformableCompoundGraphic extends CompoundGraphic
+ {
+ COMPILE::JS
+ private var _groupElement:WrappedHTMLElement;
+
+ /*
+ * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+ */
+ COMPILE::JS
+ override protected function addElementToSurface(e:WrappedHTMLElement):void
+ {
+ _groupElement.appendChild(e);
+ }
+
+ /**
+ * Clears all of the drawn path data.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.3
+ */
+ override public function clear():void
+ {
+ COMPILE::SWF
+ {
+ super.clear();
+ }
+ COMPILE::JS
+ {
+ while (transformElement.lastChild) {
+ transformElement.removeChild(transformElement.lastChild);
+ }
+ }
+ }
+
+ /**
+ * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+ */
+ COMPILE::JS
+ override protected function createElement():WrappedHTMLElement
+ {
+ super.createElement();
+ _groupElement = document.createElementNS('http://www.w3.org/2000/svg', 'g') as WrappedHTMLElement;
+ element.appendChild(_groupElement);
+ return element;
+ }
+
+ /**
+ * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+ */
+ COMPILE::JS
+ override public function get transformElement():WrappedHTMLElement
+ {
+ return _groupElement;
+ }
+
+
+ }
+}