@yanqirenshi/d3.wireframe 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.markdown +102 -44
- package/dist/DataBackground.js +7 -9
- package/dist/DataFont.js +7 -11
- package/dist/DataPosition.js +7 -11
- package/dist/DataRectangle.js +7 -9
- package/dist/DataStroke.js +7 -9
- package/dist/Digestion.js +20 -20
- package/dist/Drawer.js +20 -20
- package/dist/Element.js +0 -6
- package/dist/ElementButton.js +11 -14
- package/dist/ElementDialog.js +4 -4
- package/dist/ElementFounder.js +11 -7
- package/dist/ElementFrame.js +4 -4
- package/dist/ElementIcon.js +8 -8
- package/dist/ElementImage.js +4 -4
- package/dist/ElementLabel.js +3 -1
- package/dist/ElementModal.js +4 -4
- package/dist/Rectum.js +121 -47
- package/package.json +3 -2
- package/src/DataBackground.js +5 -13
- package/src/DataFont.js +5 -15
- package/src/DataPosition.js +5 -11
- package/src/DataRectangle.js +5 -10
- package/src/DataStroke.js +5 -13
- package/src/Digestion.js +273 -273
- package/src/Drawer.js +270 -270
- package/src/Element.js +0 -5
- package/src/ElementButton.js +6 -13
- package/src/ElementDialog.js +67 -67
- package/src/ElementFounder.js +12 -6
- package/src/ElementFrame.js +67 -67
- package/src/ElementIcon.js +72 -72
- package/src/ElementImage.js +67 -67
- package/src/ElementLabel.js +3 -1
- package/src/ElementModal.js +61 -61
- package/src/Rectum.js +115 -44
package/src/ElementDialog.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import ElementFounder from './ElementFounder';
|
|
2
|
-
import ElementLabel from './ElementLabel';
|
|
3
|
-
|
|
4
|
-
export default class ElementDialog extends ElementFounder {
|
|
5
|
-
constructor (params) {
|
|
6
|
-
super('dialog', params);
|
|
7
|
-
|
|
8
|
-
this.label = new ElementLabel({idm:this.idm});
|
|
9
|
-
}
|
|
10
|
-
/* **************************************************************** *
|
|
11
|
-
* Data
|
|
12
|
-
* **************************************************************** */
|
|
13
|
-
templateElement () {
|
|
14
|
-
return this.makeTemplateElement({
|
|
15
|
-
rectangle: null,
|
|
16
|
-
position: null,
|
|
17
|
-
background: null,
|
|
18
|
-
stroke: null,
|
|
19
|
-
labels: [],
|
|
20
|
-
children: [],
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
makeElement (core, parent) {
|
|
24
|
-
let element = this.templateElement();
|
|
25
|
-
|
|
26
|
-
this.initElement(element, core, parent);
|
|
27
|
-
|
|
28
|
-
this.fittingRectangle(element, core);
|
|
29
|
-
this.fittingPosition(element, core);
|
|
30
|
-
this.fittingBackground(element, core);
|
|
31
|
-
this.fittingStroke(element, core);
|
|
32
|
-
|
|
33
|
-
element.labels = this.label.makeElements (core.labels);
|
|
34
|
-
|
|
35
|
-
return element;
|
|
36
|
-
}
|
|
37
|
-
/* **************************************************************** *
|
|
38
|
-
* Draw
|
|
39
|
-
* **************************************************************** */
|
|
40
|
-
drawAdd (place, data, projector) {
|
|
41
|
-
const g = place.selectAll(`g.${this.name}`)
|
|
42
|
-
.data([data], (d) => { return d._id; })
|
|
43
|
-
.enter()
|
|
44
|
-
.append('g')
|
|
45
|
-
.attr('class', this.name)
|
|
46
|
-
.attr("transform", d => this.groupTransform(d, projector));
|
|
47
|
-
|
|
48
|
-
this.drawBase(g, projector);
|
|
49
|
-
|
|
50
|
-
this.label.draw(g, data, projector);
|
|
51
|
-
}
|
|
52
|
-
drawUpdate (place, data) {
|
|
53
|
-
place.selectAll(`g.${this.name}`)
|
|
54
|
-
.data([data], (d) => { return d._id; });
|
|
55
|
-
}
|
|
56
|
-
drawDelete (place, data) {
|
|
57
|
-
place.selectAll(`g.${this.name}`)
|
|
58
|
-
.data([data], (d) => { return d._id; })
|
|
59
|
-
.exit()
|
|
60
|
-
.remove();
|
|
61
|
-
}
|
|
62
|
-
draw (place, data, projector) {
|
|
63
|
-
// this.drawDelete(place, data);
|
|
64
|
-
this.drawUpdate(place, data);
|
|
65
|
-
this.drawAdd(place, data, projector);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
import ElementFounder from './ElementFounder';
|
|
2
|
+
import ElementLabel from './ElementLabel';
|
|
3
|
+
|
|
4
|
+
export default class ElementDialog extends ElementFounder {
|
|
5
|
+
constructor (params) {
|
|
6
|
+
super('dialog', params);
|
|
7
|
+
|
|
8
|
+
this.label = new ElementLabel({idm:this.idm});
|
|
9
|
+
}
|
|
10
|
+
/* **************************************************************** *
|
|
11
|
+
* Data
|
|
12
|
+
* **************************************************************** */
|
|
13
|
+
templateElement () {
|
|
14
|
+
return this.makeTemplateElement({
|
|
15
|
+
rectangle: null,
|
|
16
|
+
position: null,
|
|
17
|
+
background: null,
|
|
18
|
+
stroke: null,
|
|
19
|
+
labels: [],
|
|
20
|
+
children: [],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
makeElement (core, parent) {
|
|
24
|
+
let element = this.templateElement();
|
|
25
|
+
|
|
26
|
+
this.initElement(element, core, parent);
|
|
27
|
+
|
|
28
|
+
this.fittingRectangle(element, core);
|
|
29
|
+
this.fittingPosition(element, core);
|
|
30
|
+
this.fittingBackground(element, core);
|
|
31
|
+
this.fittingStroke(element, core);
|
|
32
|
+
|
|
33
|
+
element.labels = this.label.makeElements (core.labels);
|
|
34
|
+
|
|
35
|
+
return element;
|
|
36
|
+
}
|
|
37
|
+
/* **************************************************************** *
|
|
38
|
+
* Draw
|
|
39
|
+
* **************************************************************** */
|
|
40
|
+
drawAdd (place, data, projector) {
|
|
41
|
+
const g = place.selectAll(`g.${this.name}`)
|
|
42
|
+
.data([data], (d) => { return d._id; })
|
|
43
|
+
.enter()
|
|
44
|
+
.append('g')
|
|
45
|
+
.attr('class', this.name)
|
|
46
|
+
.attr("transform", d => this.groupTransform(d, projector));
|
|
47
|
+
|
|
48
|
+
this.drawBase(g, projector);
|
|
49
|
+
|
|
50
|
+
this.label.draw(g, data, projector);
|
|
51
|
+
}
|
|
52
|
+
drawUpdate (place, data) {
|
|
53
|
+
place.selectAll(`g.${this.name}`)
|
|
54
|
+
.data([data], (d) => { return d._id; });
|
|
55
|
+
}
|
|
56
|
+
drawDelete (place, data) {
|
|
57
|
+
place.selectAll(`g.${this.name}`)
|
|
58
|
+
.data([data], (d) => { return d._id; })
|
|
59
|
+
.exit()
|
|
60
|
+
.remove();
|
|
61
|
+
}
|
|
62
|
+
draw (place, data, projector) {
|
|
63
|
+
// this.drawDelete(place, data);
|
|
64
|
+
this.drawUpdate(place, data);
|
|
65
|
+
this.drawAdd(place, data, projector);
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/ElementFounder.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import POSITION from './DataPosition';
|
|
2
2
|
import RECTANGLE from './DataRectangle';
|
|
3
3
|
import BACKGROUND from './DataBackground';
|
|
4
|
-
import STROKE from './DataStroke';
|
|
5
4
|
import FONT from './DataFont';
|
|
6
5
|
|
|
6
|
+
import { elementStrokeOf, visibleOf } from '@yanqirenshi/model.wireframe';
|
|
7
|
+
|
|
7
8
|
export default class ElementFounder {
|
|
8
9
|
constructor (name, params) {
|
|
9
10
|
this.name = name;
|
|
@@ -24,16 +25,20 @@ export default class ElementFounder {
|
|
|
24
25
|
...attributes
|
|
25
26
|
};
|
|
26
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* 要素から入力を引けるようにする(element._core)。
|
|
30
|
+
* 入力の側には書かない(0.2.1 までは core._element を書いていたが、読む所が無く、
|
|
31
|
+
* 入力を書き換えて JSON にできなくしていたので、0.3.0 でやめた。#195)。
|
|
32
|
+
*/
|
|
27
33
|
makeCrossReference (element, core) {
|
|
28
34
|
element._core = core;
|
|
29
|
-
core._element = element;
|
|
30
35
|
}
|
|
31
36
|
initElementID (element, core) {
|
|
32
37
|
element._id = core.id || this.idm.nextID();
|
|
33
38
|
}
|
|
34
39
|
initElementVisible (element, core) {
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
// false と書いたときだけ描かない(model.wireframe の visibleOf)
|
|
41
|
+
element.visible = visibleOf(core);
|
|
37
42
|
}
|
|
38
43
|
initElementParent (element, parent) {
|
|
39
44
|
if (parent)
|
|
@@ -55,12 +60,13 @@ export default class ElementFounder {
|
|
|
55
60
|
element.background = BACKGROUND.build(core.background);
|
|
56
61
|
}
|
|
57
62
|
fittingStroke (element, core) {
|
|
58
|
-
|
|
63
|
+
// 種類ごとの線(button は書いていなければ既定の線・null で線なし。ほかは書いていなければ線なし)。
|
|
64
|
+
// 判定は model.wireframe の elementStrokeOf(#195)
|
|
65
|
+
element.stroke = elementStrokeOf(core);
|
|
59
66
|
}
|
|
60
67
|
fittingFont (element, core) {
|
|
61
68
|
element.font = FONT.build(core.font);
|
|
62
69
|
}
|
|
63
|
-
merge (core, element) {}
|
|
64
70
|
/* **************************************************************** *
|
|
65
71
|
* Draw
|
|
66
72
|
* **************************************************************** */
|
package/src/ElementFrame.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import ElementFounder from './ElementFounder';
|
|
2
|
-
import ElementLabel from './ElementLabel';
|
|
3
|
-
|
|
4
|
-
export default class ElementFrame extends ElementFounder {
|
|
5
|
-
constructor (params) {
|
|
6
|
-
super('frame', params);
|
|
7
|
-
|
|
8
|
-
this.label = new ElementLabel({idm:this.idm});
|
|
9
|
-
}
|
|
10
|
-
/* **************************************************************** *
|
|
11
|
-
* Data
|
|
12
|
-
* **************************************************************** */
|
|
13
|
-
templateElement () {
|
|
14
|
-
return this.makeTemplateElement({
|
|
15
|
-
rectangle: null,
|
|
16
|
-
position: null,
|
|
17
|
-
background: null,
|
|
18
|
-
stroke: null,
|
|
19
|
-
labels: [],
|
|
20
|
-
children: [],
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
makeElement (core, parent) {
|
|
24
|
-
let element = this.templateElement();
|
|
25
|
-
|
|
26
|
-
this.initElement(element, core, parent);
|
|
27
|
-
|
|
28
|
-
this.fittingRectangle(element, core);
|
|
29
|
-
this.fittingPosition(element, core);
|
|
30
|
-
this.fittingBackground(element, core);
|
|
31
|
-
this.fittingStroke(element, core);
|
|
32
|
-
|
|
33
|
-
element.labels = this.label.makeElements (core.labels);
|
|
34
|
-
|
|
35
|
-
return element;
|
|
36
|
-
}
|
|
37
|
-
/* **************************************************************** *
|
|
38
|
-
* Draw
|
|
39
|
-
* **************************************************************** */
|
|
40
|
-
drawAdd (place, data, projector) {
|
|
41
|
-
const g = place.selectAll(`g.${this.name}`)
|
|
42
|
-
.data([data], (d) => { return d._id; })
|
|
43
|
-
.enter()
|
|
44
|
-
.append('g')
|
|
45
|
-
.attr('class', this.name)
|
|
46
|
-
.attr("transform", d => this.groupTransform(d, projector));
|
|
47
|
-
|
|
48
|
-
this.drawBase(g, projector);
|
|
49
|
-
|
|
50
|
-
this.label.draw(g, data, projector);
|
|
51
|
-
}
|
|
52
|
-
drawUpdate (place, data) {
|
|
53
|
-
place.selectAll(`g.${this.name}`)
|
|
54
|
-
.data([data], (d) => { return d._id; });
|
|
55
|
-
}
|
|
56
|
-
drawDelete (place, data) {
|
|
57
|
-
place.selectAll(`g.${this.name}`)
|
|
58
|
-
.data([data], (d) => { return d._id; })
|
|
59
|
-
.exit()
|
|
60
|
-
.remove();
|
|
61
|
-
}
|
|
62
|
-
draw (place, data, projector) {
|
|
63
|
-
// this.drawDelete(place, data);
|
|
64
|
-
this.drawUpdate(place, data);
|
|
65
|
-
this.drawAdd(place, data, projector);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
import ElementFounder from './ElementFounder';
|
|
2
|
+
import ElementLabel from './ElementLabel';
|
|
3
|
+
|
|
4
|
+
export default class ElementFrame extends ElementFounder {
|
|
5
|
+
constructor (params) {
|
|
6
|
+
super('frame', params);
|
|
7
|
+
|
|
8
|
+
this.label = new ElementLabel({idm:this.idm});
|
|
9
|
+
}
|
|
10
|
+
/* **************************************************************** *
|
|
11
|
+
* Data
|
|
12
|
+
* **************************************************************** */
|
|
13
|
+
templateElement () {
|
|
14
|
+
return this.makeTemplateElement({
|
|
15
|
+
rectangle: null,
|
|
16
|
+
position: null,
|
|
17
|
+
background: null,
|
|
18
|
+
stroke: null,
|
|
19
|
+
labels: [],
|
|
20
|
+
children: [],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
makeElement (core, parent) {
|
|
24
|
+
let element = this.templateElement();
|
|
25
|
+
|
|
26
|
+
this.initElement(element, core, parent);
|
|
27
|
+
|
|
28
|
+
this.fittingRectangle(element, core);
|
|
29
|
+
this.fittingPosition(element, core);
|
|
30
|
+
this.fittingBackground(element, core);
|
|
31
|
+
this.fittingStroke(element, core);
|
|
32
|
+
|
|
33
|
+
element.labels = this.label.makeElements (core.labels);
|
|
34
|
+
|
|
35
|
+
return element;
|
|
36
|
+
}
|
|
37
|
+
/* **************************************************************** *
|
|
38
|
+
* Draw
|
|
39
|
+
* **************************************************************** */
|
|
40
|
+
drawAdd (place, data, projector) {
|
|
41
|
+
const g = place.selectAll(`g.${this.name}`)
|
|
42
|
+
.data([data], (d) => { return d._id; })
|
|
43
|
+
.enter()
|
|
44
|
+
.append('g')
|
|
45
|
+
.attr('class', this.name)
|
|
46
|
+
.attr("transform", d => this.groupTransform(d, projector));
|
|
47
|
+
|
|
48
|
+
this.drawBase(g, projector);
|
|
49
|
+
|
|
50
|
+
this.label.draw(g, data, projector);
|
|
51
|
+
}
|
|
52
|
+
drawUpdate (place, data) {
|
|
53
|
+
place.selectAll(`g.${this.name}`)
|
|
54
|
+
.data([data], (d) => { return d._id; });
|
|
55
|
+
}
|
|
56
|
+
drawDelete (place, data) {
|
|
57
|
+
place.selectAll(`g.${this.name}`)
|
|
58
|
+
.data([data], (d) => { return d._id; })
|
|
59
|
+
.exit()
|
|
60
|
+
.remove();
|
|
61
|
+
}
|
|
62
|
+
draw (place, data, projector) {
|
|
63
|
+
// this.drawDelete(place, data);
|
|
64
|
+
this.drawUpdate(place, data);
|
|
65
|
+
this.drawAdd(place, data, projector);
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/ElementIcon.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import ElementFounder from './ElementFounder';
|
|
2
|
-
|
|
3
|
-
export default class ElementIcon extends ElementFounder {
|
|
4
|
-
constructor (params) {
|
|
5
|
-
super('icon', params);
|
|
6
|
-
|
|
7
|
-
this.idm = params.idm;
|
|
8
|
-
}
|
|
9
|
-
/* **************************************************************** *
|
|
10
|
-
* Data
|
|
11
|
-
* **************************************************************** */
|
|
12
|
-
templateElement () {
|
|
13
|
-
return this.makeTemplateElement({
|
|
14
|
-
position: null,
|
|
15
|
-
rectangle: null,
|
|
16
|
-
url: null,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
makeElement (core, parent) {
|
|
20
|
-
let element = this.templateElement();
|
|
21
|
-
|
|
22
|
-
this.initElement(element, core, parent);
|
|
23
|
-
|
|
24
|
-
this.fittingPosition(element, core);
|
|
25
|
-
|
|
26
|
-
if (core.size)
|
|
27
|
-
this.fittingRectangle(element, core);
|
|
28
|
-
else
|
|
29
|
-
element.size = parent.rectangle;
|
|
30
|
-
|
|
31
|
-
if (core.url)
|
|
32
|
-
element.url = core.url;
|
|
33
|
-
|
|
34
|
-
return element;
|
|
35
|
-
}
|
|
36
|
-
makeElements (icons, parent) {
|
|
37
|
-
if (!icons)
|
|
38
|
-
return [];
|
|
39
|
-
|
|
40
|
-
return icons.map(icon => this.makeElement(icon, parent));
|
|
41
|
-
}
|
|
42
|
-
/* **************************************************************** *
|
|
43
|
-
* Draw
|
|
44
|
-
* **************************************************************** */
|
|
45
|
-
/**
|
|
46
|
-
* アイコン(画像)を描く。SVG の <image> は polygon 化できないため、
|
|
47
|
-
* 回転ビュー(projector あり)では要素の3隅を正確に写す近似 affine
|
|
48
|
-
* 行列で変形する(アイコンは小さいので誤差は実用上見えない)。
|
|
49
|
-
*/
|
|
50
|
-
draw (place, data, projector) {
|
|
51
|
-
place.selectAll('image')
|
|
52
|
-
.data(data.icons || [], d => d._id)
|
|
53
|
-
.enter()
|
|
54
|
-
.append('image')
|
|
55
|
-
.attr('xlink:href', d => d.url)
|
|
56
|
-
.attr('transform', d => {
|
|
57
|
-
if (!projector)
|
|
58
|
-
return null;
|
|
59
|
-
|
|
60
|
-
const x = data.position.x + ((d.position && d.position.x) || 0);
|
|
61
|
-
const y = data.position.y + ((d.position && d.position.y) || 0);
|
|
62
|
-
const w = (d.size && d.size.w) || d.rectangle.w;
|
|
63
|
-
const h = (d.size && d.size.h) || d.rectangle.h;
|
|
64
|
-
|
|
65
|
-
return projector.affine(x, y, w, h, projector.depthZ(data._depth));
|
|
66
|
-
})
|
|
67
|
-
.attr('x', d => projector ? 0 : ((d.position && d.position.x) || 0))
|
|
68
|
-
.attr('y', d => projector ? 0 : ((d.position && d.position.y) || 0))
|
|
69
|
-
.attr('width', d => (d.size && d.size.w) || d.rectangle.w)
|
|
70
|
-
.attr('height', d => (d.size && d.size.h) || d.rectangle.h);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
1
|
+
import ElementFounder from './ElementFounder';
|
|
2
|
+
|
|
3
|
+
export default class ElementIcon extends ElementFounder {
|
|
4
|
+
constructor (params) {
|
|
5
|
+
super('icon', params);
|
|
6
|
+
|
|
7
|
+
this.idm = params.idm;
|
|
8
|
+
}
|
|
9
|
+
/* **************************************************************** *
|
|
10
|
+
* Data
|
|
11
|
+
* **************************************************************** */
|
|
12
|
+
templateElement () {
|
|
13
|
+
return this.makeTemplateElement({
|
|
14
|
+
position: null,
|
|
15
|
+
rectangle: null,
|
|
16
|
+
url: null,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
makeElement (core, parent) {
|
|
20
|
+
let element = this.templateElement();
|
|
21
|
+
|
|
22
|
+
this.initElement(element, core, parent);
|
|
23
|
+
|
|
24
|
+
this.fittingPosition(element, core);
|
|
25
|
+
|
|
26
|
+
if (core.size)
|
|
27
|
+
this.fittingRectangle(element, core);
|
|
28
|
+
else
|
|
29
|
+
element.size = parent.rectangle;
|
|
30
|
+
|
|
31
|
+
if (core.url)
|
|
32
|
+
element.url = core.url;
|
|
33
|
+
|
|
34
|
+
return element;
|
|
35
|
+
}
|
|
36
|
+
makeElements (icons, parent) {
|
|
37
|
+
if (!icons)
|
|
38
|
+
return [];
|
|
39
|
+
|
|
40
|
+
return icons.map(icon => this.makeElement(icon, parent));
|
|
41
|
+
}
|
|
42
|
+
/* **************************************************************** *
|
|
43
|
+
* Draw
|
|
44
|
+
* **************************************************************** */
|
|
45
|
+
/**
|
|
46
|
+
* アイコン(画像)を描く。SVG の <image> は polygon 化できないため、
|
|
47
|
+
* 回転ビュー(projector あり)では要素の3隅を正確に写す近似 affine
|
|
48
|
+
* 行列で変形する(アイコンは小さいので誤差は実用上見えない)。
|
|
49
|
+
*/
|
|
50
|
+
draw (place, data, projector) {
|
|
51
|
+
place.selectAll('image')
|
|
52
|
+
.data(data.icons || [], d => d._id)
|
|
53
|
+
.enter()
|
|
54
|
+
.append('image')
|
|
55
|
+
.attr('xlink:href', d => d.url)
|
|
56
|
+
.attr('transform', d => {
|
|
57
|
+
if (!projector)
|
|
58
|
+
return null;
|
|
59
|
+
|
|
60
|
+
const x = data.position.x + ((d.position && d.position.x) || 0);
|
|
61
|
+
const y = data.position.y + ((d.position && d.position.y) || 0);
|
|
62
|
+
const w = (d.size && d.size.w) || d.rectangle.w;
|
|
63
|
+
const h = (d.size && d.size.h) || d.rectangle.h;
|
|
64
|
+
|
|
65
|
+
return projector.affine(x, y, w, h, projector.depthZ(data._depth));
|
|
66
|
+
})
|
|
67
|
+
.attr('x', d => projector ? 0 : ((d.position && d.position.x) || 0))
|
|
68
|
+
.attr('y', d => projector ? 0 : ((d.position && d.position.y) || 0))
|
|
69
|
+
.attr('width', d => (d.size && d.size.w) || d.rectangle.w)
|
|
70
|
+
.attr('height', d => (d.size && d.size.h) || d.rectangle.h);
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/ElementImage.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import ElementFounder from './ElementFounder';
|
|
2
|
-
import ElementLabel from './ElementLabel';
|
|
3
|
-
|
|
4
|
-
export default class ElementImage extends ElementFounder {
|
|
5
|
-
constructor (params) {
|
|
6
|
-
super('image', params);
|
|
7
|
-
|
|
8
|
-
this.label = new ElementLabel({idm:this.idm});
|
|
9
|
-
}
|
|
10
|
-
/* **************************************************************** *
|
|
11
|
-
* Data
|
|
12
|
-
* **************************************************************** */
|
|
13
|
-
templateElement () {
|
|
14
|
-
return this.makeTemplateElement({
|
|
15
|
-
rectangle: null,
|
|
16
|
-
position: null,
|
|
17
|
-
background: null,
|
|
18
|
-
stroke: null,
|
|
19
|
-
labels: [],
|
|
20
|
-
children: [],
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
makeElement (core, parent) {
|
|
24
|
-
let element = this.templateElement();
|
|
25
|
-
|
|
26
|
-
this.initElement(element, core, parent);
|
|
27
|
-
|
|
28
|
-
this.fittingRectangle(element, core);
|
|
29
|
-
this.fittingPosition(element, core);
|
|
30
|
-
this.fittingBackground(element, core);
|
|
31
|
-
this.fittingStroke(element, core);
|
|
32
|
-
|
|
33
|
-
element.labels = this.label.makeElements (core.labels);
|
|
34
|
-
|
|
35
|
-
return element;
|
|
36
|
-
}
|
|
37
|
-
/* **************************************************************** *
|
|
38
|
-
* Draw
|
|
39
|
-
* **************************************************************** */
|
|
40
|
-
drawAdd (place, data, projector) {
|
|
41
|
-
const g = place.selectAll(`g.${this.name}`)
|
|
42
|
-
.data([data], (d) => { return d._id; })
|
|
43
|
-
.enter()
|
|
44
|
-
.append('g')
|
|
45
|
-
.attr('class', this.name)
|
|
46
|
-
.attr("transform", d => this.groupTransform(d, projector));
|
|
47
|
-
|
|
48
|
-
this.drawBase(g, projector);
|
|
49
|
-
|
|
50
|
-
this.label.draw(g, data, projector);
|
|
51
|
-
}
|
|
52
|
-
drawUpdate (place, data) {
|
|
53
|
-
place.selectAll(`g.${this.name}`)
|
|
54
|
-
.data([data], (d) => { return d._id; });
|
|
55
|
-
}
|
|
56
|
-
drawDelete (place, data) {
|
|
57
|
-
place.selectAll(`g.${this.name}`)
|
|
58
|
-
.data([data], (d) => { return d._id; })
|
|
59
|
-
.exit()
|
|
60
|
-
.remove();
|
|
61
|
-
}
|
|
62
|
-
draw (place, data, projector) {
|
|
63
|
-
// this.drawDelete(place, data);
|
|
64
|
-
this.drawUpdate(place, data);
|
|
65
|
-
this.drawAdd(place, data, projector);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
import ElementFounder from './ElementFounder';
|
|
2
|
+
import ElementLabel from './ElementLabel';
|
|
3
|
+
|
|
4
|
+
export default class ElementImage extends ElementFounder {
|
|
5
|
+
constructor (params) {
|
|
6
|
+
super('image', params);
|
|
7
|
+
|
|
8
|
+
this.label = new ElementLabel({idm:this.idm});
|
|
9
|
+
}
|
|
10
|
+
/* **************************************************************** *
|
|
11
|
+
* Data
|
|
12
|
+
* **************************************************************** */
|
|
13
|
+
templateElement () {
|
|
14
|
+
return this.makeTemplateElement({
|
|
15
|
+
rectangle: null,
|
|
16
|
+
position: null,
|
|
17
|
+
background: null,
|
|
18
|
+
stroke: null,
|
|
19
|
+
labels: [],
|
|
20
|
+
children: [],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
makeElement (core, parent) {
|
|
24
|
+
let element = this.templateElement();
|
|
25
|
+
|
|
26
|
+
this.initElement(element, core, parent);
|
|
27
|
+
|
|
28
|
+
this.fittingRectangle(element, core);
|
|
29
|
+
this.fittingPosition(element, core);
|
|
30
|
+
this.fittingBackground(element, core);
|
|
31
|
+
this.fittingStroke(element, core);
|
|
32
|
+
|
|
33
|
+
element.labels = this.label.makeElements (core.labels);
|
|
34
|
+
|
|
35
|
+
return element;
|
|
36
|
+
}
|
|
37
|
+
/* **************************************************************** *
|
|
38
|
+
* Draw
|
|
39
|
+
* **************************************************************** */
|
|
40
|
+
drawAdd (place, data, projector) {
|
|
41
|
+
const g = place.selectAll(`g.${this.name}`)
|
|
42
|
+
.data([data], (d) => { return d._id; })
|
|
43
|
+
.enter()
|
|
44
|
+
.append('g')
|
|
45
|
+
.attr('class', this.name)
|
|
46
|
+
.attr("transform", d => this.groupTransform(d, projector));
|
|
47
|
+
|
|
48
|
+
this.drawBase(g, projector);
|
|
49
|
+
|
|
50
|
+
this.label.draw(g, data, projector);
|
|
51
|
+
}
|
|
52
|
+
drawUpdate (place, data) {
|
|
53
|
+
place.selectAll(`g.${this.name}`)
|
|
54
|
+
.data([data], (d) => { return d._id; });
|
|
55
|
+
}
|
|
56
|
+
drawDelete (place, data) {
|
|
57
|
+
place.selectAll(`g.${this.name}`)
|
|
58
|
+
.data([data], (d) => { return d._id; })
|
|
59
|
+
.exit()
|
|
60
|
+
.remove();
|
|
61
|
+
}
|
|
62
|
+
draw (place, data, projector) {
|
|
63
|
+
// this.drawDelete(place, data);
|
|
64
|
+
this.drawUpdate(place, data);
|
|
65
|
+
this.drawAdd(place, data, projector);
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/ElementLabel.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import ElementFounder from './ElementFounder';
|
|
2
2
|
|
|
3
|
+
import { LABEL_DEFAULTS } from '@yanqirenshi/model.wireframe';
|
|
4
|
+
|
|
3
5
|
export default class ElementLabel extends ElementFounder {
|
|
4
6
|
constructor (params) {
|
|
5
7
|
super('label', params);
|
|
@@ -9,7 +11,7 @@ export default class ElementLabel extends ElementFounder {
|
|
|
9
11
|
* **************************************************************** */
|
|
10
12
|
templateElement () {
|
|
11
13
|
return this.makeTemplateElement({
|
|
12
|
-
text:
|
|
14
|
+
text: LABEL_DEFAULTS.text, // model.wireframe(#195)
|
|
13
15
|
position: null,
|
|
14
16
|
font: null,
|
|
15
17
|
});
|