+ ;
+ grid(doc) {
+ for (var j = 0; j < exports.A4_IN_PX.width; j += 5) {
+ if (j % 50 == 0) {
+ doc.save().fill('#000000')
+ .fontSize(8).text(j.toString(), j * 0.75, 50);
+ doc
+ .save()
+ .lineWidth(0.4)
+ .strokeColor("#dddddd")
+ .moveTo(j * 0.75, 0)
+ .lineTo(j * 0.75, 1000)
+ .stroke();
+ }
+ doc
+ .save()
+ .lineWidth(0.2)
+ .strokeColor("#dddddd")
+ .moveTo(j * 0.75, 0)
+ .lineTo(j * 0.75, 1000)
+ .stroke();
+ }
+ for (var i = 0; i < 1050; i += 5) {
+ if (i % 50 == 0) {
+ doc.save()
+ .fontSize(8).text(i.toString(), 50, i * 0.75);
+ doc
+ .save()
+ .lineWidth(0.4)
+ .strokeColor("#bbbbbb")
+ .moveTo(0, i * 0.75)
+ .lineTo(1000, i * 0.75)
+ .stroke();
+ }
+ doc
+ .save()
+ .lineWidth(0.2)
+ .strokeColor("#bbbbbb")
+ .moveTo(0, i * 0.75)
+ .lineTo(1000, i * 0.75)
+ .stroke();
+ }
+ doc
+ .save()
+ .moveTo(0, 200)
+ .lineTo(1000, 200)
+ .fill('#FF3300');
+ }
+ /**
+ * make all the nest boxes's position fixed
+ * @param box the main boxes
+ * @returns the fixed boxes
+ */
+ fixenBoxesPosition(box) {
+ console.log("~~~~~", box);
+ var currX = (box.x !== null ? box.x : 0); // current x
+ var currY = (box.y !== null ? box.y : 0); // current y
+ if (Array.isArray(box.content)) {
+ for (var i = 0; i < box.content.length; i++) {
+ if (box.direction == Direction.LTR) {
+ box.content[i].x = currX;
+ box.content[i].y = currY;
+ let elementWidth = box.content[i].width;
+ if (elementWidth !== null) {
+ currX += elementWidth;
+ }
+ }
+ if (box.direction == Direction.TTB) {
+ box.content[i].x = currX;
+ box.content[i].y = currY;
+ let elementHeight = box.content[i].height;
+ if (elementHeight !== null) {
+ currY += elementHeight;
+ }
+ }
+ box.content[i] = this.fixenBoxesPosition(box.content[i]);
+ }
+ }
+ return box;
+ }
+ /**
+ * input a `segmentedNodes` and a layed `frame`, return a big `Box` that nodes is put in.
+ * @param segmentedNodes the segmentnodes to be input
+ * @param frame the frame to be layed out.
+ * @returns the big `Box`.
+ */