Hello, I'm writing my ph.d and I'm using processingjs.
I have such task:
get xml, parse it and convert to valid processingjs script.
Please, see this xml:
url: w3.org/TR/SVG/images/animate/anim01.svg
Yes, it's "plain old SVG". But take into consideration this string:
Code: <animate attributeName="x" attributeType="XML"
begin="0s" dur="9s" fill="freeze" from="300" to="0" />
As you can see the change of attribute "x" during the time is declared.
Is there any possibility to use some king of Java reflection and write common mehtod for changing attribute value?
For example:
Code:
class AnimatableObject{
String id, name;
float x, y;
color fillColor = color(255,255,255);
int stokeWidth = 0;
color strokeColor = color(255,255,255);
ArrayList transformations;
AnimatableObject(String idStr, String idName, float xPos, float yPos){
id = idStr;
name = idName;
x = xPos;
y = yPos;
}
}
class Rectangle extends AnimatableObject{
float height, width;
Rectangle(String idStr, String idName, float xPos, float yPos, float w, float h){
super(idStr, idName, xPos, yPos);
width = w;
height = h;
}
Rectangle(String idStr, String idName, float xPos, float yPos, color fColor, int sWidth, color sColor, float w, float h){
super(idStr, idName, xPos, yPos, fColor, sWidth, sColor);
width = w;
height = h;
}
}
class AbstractTransformation{
String fromValue;
String toValue;
int startFrame;
int endFrame;
void transform(){
//abstract, does nothing, use implementators
}
}
class AttributeTransformation extends AbstractTransformation{
String attrName;
String attrType;
void transform(){
//transform logic goes here
}
}
In draw method I would like to take each transformation from each AnimatableObject and perform it.
I don't want to write transformation for x and y, I would like to have common method which just takes filed from AnimatableObject and changes its value.
Is it possible?