@@ -73,9 +73,9 @@
window.saveFile = function()
{
- var data = graph.serialize();
+ var data = graph.serialize(true);
var text = JSON.stringify(data, null, "\t");
- Escher.FileUtils.write(text);
+ Escher.FileUtils.write("object.json", text);
};
class OperationNode extends Escher.Node
@@ -31,6 +31,7 @@ function BezierCurve()
BezierCurve.prototype = Object.create(Line.prototype);
BezierCurve.prototype.constructor = BezierCurve;
BezierCurve.prototype.type = "BezierCurve";
+Object2D.register(BezierCurve, "BezierCurve");
/**
* Create a bezier curve helper, to edit the bezier curve anchor points.
@@ -42,6 +42,7 @@ function Box()
Box.prototype = Object.create(Object2D.prototype);
Box.prototype.constructor = Box;
Box.prototype.type = "Box";
+Object2D.register(Box, "Box");
Box.prototype.onPointerEnter = function(pointer, viewport)
@@ -40,6 +40,7 @@ function Circle()
Circle.prototype = Object.create(Object2D.prototype);
Circle.prototype.constructor = Circle;
Circle.prototype.type = "Circle";
+Object2D.register(Circle, "Circle");
Circle.prototype.isInside = function(point)
@@ -50,6 +50,7 @@ function DOM(type)
DOM.prototype = Object.create(Object2D.prototype);
DOM.prototype.constructor = DOM;
DOM.prototype.type = "DOM";
+Object2D.register(DOM, "DOM");
* DOM object implements onAdd() method to automatically attach the DOM object to the DOM tree.
@@ -55,6 +55,7 @@ function Graph()
Graph.prototype = Object.create(Object2D.prototype);
Graph.prototype.constructor = Graph;
Graph.prototype.type = "Graph";
+Object2D.register(Graph, "Graph");
Graph.prototype.isInside = function(point)
@@ -31,6 +31,7 @@ function Image(src)
Image.prototype = Object.create(Object2D.prototype);
Image.prototype.constructor = Image;
Image.prototype.type = "Image";
+Object2D.register(Image, "Image");
* Set the image of the object.
@@ -62,6 +62,7 @@ function Line()
Line.prototype = Object.create(Object2D.prototype);
Line.prototype.constructor = Line;
Line.prototype.type = "Line";
+Object2D.register(Line, "Line");
Line.prototype.style = function(context, viewport, canvas)
@@ -34,6 +34,7 @@ function MultiLineText()
MultiLineText.prototype = Object.create(Text.prototype);
MultiLineText.prototype.constructor = MultiLineText;
MultiLineText.prototype.type = "MultiLineText";
+Object2D.register(MultiLineText, "MultiLineText");
MultiLineText.prototype.draw = function(context, viewport, canvas)
@@ -51,6 +51,7 @@ function Pattern(src)
Pattern.prototype = Object.create(Object2D.prototype);
Pattern.prototype.constructor = Pattern;
Pattern.prototype.type = "Pattern";
+Object2D.register(Pattern, "Pattern");
* Set the image source of the object. Can be anything accepted by the src field of an img element.
@@ -26,6 +26,7 @@ function QuadraticCurve()
QuadraticCurve.prototype = Object.create(Line.prototype);
QuadraticCurve.prototype.constructor = QuadraticCurve;
QuadraticCurve.prototype.type = "QuadraticCurve";
+Object2D.register(QuadraticCurve, "QuadraticCurve");
* Create a quadratic curve helper, to edit the curve control point.
@@ -21,6 +21,7 @@ function RoundedBox()
RoundedBox.prototype = Object.create(Box.prototype);
RoundedBox.prototype.constructor = RoundedBox;
RoundedBox.prototype.type = "RoundedBox";
+Object2D.register(RoundedBox, "RoundedBox");
* Draw a rounded rectangle into the canvas context using path to draw the rounded rectangle.
@@ -69,6 +69,7 @@ function Text()
Text.prototype = Object.create(Object2D.prototype);
Text.prototype.constructor = Text;
Text.prototype.type = "Text";
+Object2D.register(Text, "Text");
Text.prototype.draw = function(context, viewport, canvas)
@@ -32,6 +32,7 @@ function BoxMask()
BoxMask.prototype = Object.create(Mask.prototype);
BoxMask.prototype.constructor = BoxMask;
BoxMask.prototype.type = "BoxMask";
+Object2D.register(BoxMask, "BoxMask");
BoxMask.prototype.isInside = function(point)
@@ -20,6 +20,7 @@ function Mask()
Mask.prototype = Object.create(Object2D.prototype);
Mask.prototype.constructor = Mask;
Mask.prototype.type = "Mask";
+Object2D.register(Mask, "Mask");
Mask.prototype.isMask = true;
@@ -36,6 +36,7 @@ function Node()
Node.prototype = Object.create(RoundedBox.prototype);
Node.prototype.constructor = Node;
Node.prototype.type = "Node";
+Object2D.register(Node, "Node");
* This method should be used for the node to register their socket inputs/outputs.
@@ -19,6 +19,7 @@ function NodeGraph()
NodeGraph.prototype = Object.create(Object2D.prototype);
NodeGraph.prototype.constructor = NodeGraph;
NodeGraph.prototype.type = "NodeGraph";
+Object2D.register(NodeGraph, "NodeGraph");
* Create and add a new node of specific node type to the graph.
@@ -108,6 +108,7 @@ function NodeSocket(node, direction, category, name)
NodeSocket.prototype = Object.create(Circle.prototype);
NodeSocket.prototype.constructor = NodeSocket;
NodeSocket.prototype.type = "NodeSocket";
+Object2D.register(NodeSocket, "NodeSocket");
* Input hook can only be connected to an output.