I'm a newcomer to this library and I'm struggling to figure out how to properly size and position the canvas. If anyone could provide guidance on the best way to do this, I would greatly appreciate it.
$(window).load(function () {
// setting up the canvas for user interaction
//
var canvas = new draw2d.Canvas("gfx_holder");
// loading the JSON document into the canvas
//
var reader = new draw2d.io.json.Reader();
reader.unmarshal(canvas, jsonDocument);
// displaying the JSON document in the preview DIV
//
displayJSON(canvas);
// adding an event listener to the Canvas for change notifications.
// Update the preview DIV with the current canvas document
//
canvas.getCommandStack().addEventListener(function (e) {
if (e.isPostChangeEvent()) {
displayJSON(canvas);
}
});
});
function displayJSON(canvas) {
var writer = new draw2d.io.json.Writer();
writer.marshal(canvas, function (json) {
$("#json").text(JSON.stringify(json, null, 2));
});
}