Skip to content

Commit 1e28023

Browse files
author
SeungpilPark
committed
#4 Save canvas scale while export,import json data
1 parent ed684c8 commit 1e28023

5 files changed

Lines changed: 35 additions & 43 deletions

File tree

src/main/webapp/examples/develope.html

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -338,37 +338,13 @@
338338
canvas.fastLoadingON();
339339

340340
var date1 = new Date();
341-
for (var i = 0; i < 100; i++) {
341+
for (var i = 0; i < 50; i++) {
342342
var p1 = [i * 10, i * 10];
343343
var p2 = [i * 10 + 50, i * 10 + 50];
344344
var location = canvas.drawShape(p1, new OG.MILoad(), [50, 50]);
345345
var location2 = canvas.drawShape(p2, new OG.MILoad(), [50, 50]);
346-
// var raceway = new OG.CableShape();
347-
// canvas.connect(location, location2, null, null, null, null, null, null, raceway);
348-
}
349-
var date2 = new Date();
350-
console.log(date2 - date1);
351-
352-
var date1 = new Date();
353-
for (var i = 0; i < 40; i++) {
354-
var p1 = [i * 10, i * 10];
355-
var p2 = [i * 10 + 50, i * 10 + 50];
356-
var location = canvas.drawShape(p1, new OG.MILoad(), [50, 50]);
357-
var location2 = canvas.drawShape(p2, new OG.MILoad(), [50, 50]);
358-
// var raceway = new OG.CableShape();
359-
// canvas.connect(location, location2, null, null, null, null, null, null, raceway);
360-
}
361-
var date2 = new Date();
362-
console.log(date2 - date1);
363-
364-
var date1 = new Date();
365-
for (var i = 0; i < 1; i++) {
366-
var p1 = [i * 10, i * 10];
367-
var p2 = [i * 10 + 50, i * 10 + 50];
368-
var location = canvas.drawShape(p1, new OG.MILoad(), [50, 50]);
369-
var location2 = canvas.drawShape(p2, new OG.MILoad(), [50, 50]);
370-
// var raceway = new OG.CableShape();
371-
// canvas.connect(location, location2, null, null, null, null, null, null, raceway);
346+
var raceway = new OG.CableShape();
347+
canvas.connect(location, location2, null, null, null, null, null, null, raceway);
372348
}
373349
var date2 = new Date();
374350
console.log(date2 - date1);

src/main/webapp/opengraph/OpenGraph-0.1.2-SNAPSHOT-All.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/webapp/opengraph/OpenGraph-0.1.2-SNAPSHOT-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/webapp/opengraph/OpenGraph-0.1.2-SNAPSHOT.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33187,7 +33187,7 @@ OG.graph.Canvas.prototype = {
3318733187
}
3318833188
,
3318933189
updateSlider: function (val) {
33190-
if(this._CONFIG.AUTO_SLIDER_UPDATE){
33190+
if (this._CONFIG.AUTO_SLIDER_UPDATE) {
3319133191
var me = this;
3319233192
if (!this._CONFIG.SLIDER) {
3319333193
return;
@@ -34235,15 +34235,18 @@ OG.graph.Canvas.prototype = {
3423534235
var CANVAS = this,
3423634236
rootBBox = this._RENDERER.getRootBBox(),
3423734237
rootGroup = this._RENDERER.getRootGroup(),
34238+
scale = this.getScale(),
34239+
canvasWidth = this.getCanvasSize()[0],
34240+
canvasHeight = this.getCanvasSize()[1],
3423834241
jsonObj = {
3423934242
opengraph: {
34240-
'@width': rootBBox.width,
34241-
'@height': rootBBox.height,
34243+
'@width': canvasWidth,
34244+
'@height': canvasHeight,
34245+
'@scale': scale,
3424234246
cell: []
3424334247
}
3424434248
},
3424534249
childShape, i, cellMap;
34246-
3424734250
cellMap = {};
3424834251

3424934252
childShape = function (node) {
@@ -34414,7 +34417,7 @@ OG.graph.Canvas.prototype = {
3441434417
*/
3441534418
loadJSON: function (json) {
3441634419
this.fastLoadingON();
34417-
var canvasWidth, canvasHeight, rootGroup,
34420+
var canvasWidth, canvasHeight, rootGroup, canvasScale,
3441834421
minX = Number.MAX_VALUE, minY = Number.MAX_VALUE, maxX = Number.MIN_VALUE, maxY = Number.MIN_VALUE,
3441934422
i, cell, shape, id, parent, shapeType, shapeId, x, y, width, height, style, geom, from, to,
3442034423
fromEdge, toEdge, label, fromLabel, toLabel, angle, value, data, dataExt, element, loopType, taskType, swimlane, textList;
@@ -34424,6 +34427,13 @@ OG.graph.Canvas.prototype = {
3442434427
if (json && json.opengraph && json.opengraph.cell && OG.Util.isArray(json.opengraph.cell)) {
3442534428
canvasWidth = json.opengraph['@width'];
3442634429
canvasHeight = json.opengraph['@height'];
34430+
canvasScale = json.opengraph['@scale'];
34431+
if (canvasScale) {
34432+
this.setScale(canvasScale);
34433+
} else {
34434+
this.setScale(1);
34435+
}
34436+
this.setCanvasSize([canvasWidth, canvasHeight]);
3442734437

3442834438
data = json.opengraph['@data'];
3442934439
dataExt = json.opengraph['@dataExt'];
@@ -34587,8 +34597,6 @@ OG.graph.Canvas.prototype = {
3458734597
}
3458834598
}
3458934599

34590-
this.setCanvasSize([canvasWidth, canvasHeight]);
34591-
3459234600
this.fastLoadingOFF();
3459334601

3459434602
return {

src/main/webapp/src/graph/Canvas.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ OG.graph.Canvas.prototype = {
11481148
}
11491149
,
11501150
updateSlider: function (val) {
1151-
if(this._CONFIG.AUTO_SLIDER_UPDATE){
1151+
if (this._CONFIG.AUTO_SLIDER_UPDATE) {
11521152
var me = this;
11531153
if (!this._CONFIG.SLIDER) {
11541154
return;
@@ -2196,15 +2196,18 @@ OG.graph.Canvas.prototype = {
21962196
var CANVAS = this,
21972197
rootBBox = this._RENDERER.getRootBBox(),
21982198
rootGroup = this._RENDERER.getRootGroup(),
2199+
scale = this.getScale(),
2200+
canvasWidth = this.getCanvasSize()[0],
2201+
canvasHeight = this.getCanvasSize()[1],
21992202
jsonObj = {
22002203
opengraph: {
2201-
'@width': rootBBox.width,
2202-
'@height': rootBBox.height,
2204+
'@width': canvasWidth,
2205+
'@height': canvasHeight,
2206+
'@scale': scale,
22032207
cell: []
22042208
}
22052209
},
22062210
childShape, i, cellMap;
2207-
22082211
cellMap = {};
22092212

22102213
childShape = function (node) {
@@ -2375,7 +2378,7 @@ OG.graph.Canvas.prototype = {
23752378
*/
23762379
loadJSON: function (json) {
23772380
this.fastLoadingON();
2378-
var canvasWidth, canvasHeight, rootGroup,
2381+
var canvasWidth, canvasHeight, rootGroup, canvasScale,
23792382
minX = Number.MAX_VALUE, minY = Number.MAX_VALUE, maxX = Number.MIN_VALUE, maxY = Number.MIN_VALUE,
23802383
i, cell, shape, id, parent, shapeType, shapeId, x, y, width, height, style, geom, from, to,
23812384
fromEdge, toEdge, label, fromLabel, toLabel, angle, value, data, dataExt, element, loopType, taskType, swimlane, textList;
@@ -2385,6 +2388,13 @@ OG.graph.Canvas.prototype = {
23852388
if (json && json.opengraph && json.opengraph.cell && OG.Util.isArray(json.opengraph.cell)) {
23862389
canvasWidth = json.opengraph['@width'];
23872390
canvasHeight = json.opengraph['@height'];
2391+
canvasScale = json.opengraph['@scale'];
2392+
if (canvasScale) {
2393+
this.setScale(canvasScale);
2394+
} else {
2395+
this.setScale(1);
2396+
}
2397+
this.setCanvasSize([canvasWidth, canvasHeight]);
23882398

23892399
data = json.opengraph['@data'];
23902400
dataExt = json.opengraph['@dataExt'];
@@ -2548,8 +2558,6 @@ OG.graph.Canvas.prototype = {
25482558
}
25492559
}
25502560

2551-
this.setCanvasSize([canvasWidth, canvasHeight]);
2552-
25532561
this.fastLoadingOFF();
25542562

25552563
return {

0 commit comments

Comments
 (0)