all files / diagram/core/elements/ text-element.js

100% Statements 65/65
100% Branches 32/32
100% Functions 18/18
100% Lines 62/62
11 statements, 6 functions, 9 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112          12525× 12525× 12525× 12525× 12525× 12525× 12525× 12525×     12525× 12525× 12525×             12525× 12525× 12525×     52181×     12572× 12124× 12124× 12124×             14925×     16987×           31922×     16987×         6091×   73589× 73589× 16987×       56602×   73589× 71659×     1930×   73589× 73589×   45394× 11531×   45394× 45394× 45394× 45394×        
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "../../primitives/size", "./diagram-element", "./../../utility/dom-util"], function (require, exports, size_1, diagram_element_1, dom_util_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var TextElement = (function (_super) {
        __extends(TextElement, _super);
        function TextElement() {
            var _this = _super.call(this) || this;
            _this.textContent = '';
            _this.canMeasure = true;
            _this.rotationReference = 'Parent';
            _this.isLaneOrientation = false;
            _this.canConsiderBounds = true;
            _this.annotationVisibility = 'Visible';
            _this.hyperlink = {
                color: 'blue'
            };
            _this.doWrap = true;
            _this.textNodes = [];
            _this.style = {
                color: 'black', fill: 'transparent', strokeColor: 'black',
                strokeWidth: 1, fontFamily: 'Arial', fontSize: 12, whiteSpace: 'CollapseSpace',
                textWrapping: 'WrapWithOverflow', textAlign: 'Center', italic: false, bold: false,
                textDecoration: 'None', strokeDashArray: '', opacity: 5, gradient: null,
                textOverflow: 'Wrap'
            };
            _this.style.fill = 'transparent';
            _this.style.strokeColor = 'transparent';
            return _this;
        }
        Object.defineProperty(TextElement.prototype, "content", {
            get: function () {
                return this.textContent;
            },
            set: function (value) {
                if (this.textContent !== value) {
                    this.textContent = value;
                    this.isDirt = true;
                    this.doWrap = true;
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TextElement.prototype, "childNodes", {
            get: function () {
                return this.textNodes;
            },
            set: function (value) {
                this.textNodes = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TextElement.prototype, "wrapBounds", {
            get: function () {
                return this.textWrapBounds;
            },
            set: function (value) {
                this.textWrapBounds = value;
            },
            enumerable: true,
            configurable: true
        });
        TextElement.prototype.refreshTextElement = function () {
            this.isDirt = true;
        };
        TextElement.prototype.measure = function (availableSize) {
            var size;
            if (this.isDirt && this.canMeasure) {
                size = dom_util_1.measureText(this, this.style, this.content, this.isLaneOrientation ?
                    availableSize.height : (this.width || availableSize.width));
            }
            else {
                size = this.desiredSize;
            }
            if (this.width === undefined || this.height === undefined) {
                this.desiredSize = new size_1.Size(size.width, size.height);
            }
            else {
                this.desiredSize = new size_1.Size(this.width, this.height);
            }
            this.desiredSize = this.validateDesiredSize(this.desiredSize, availableSize);
            return this.desiredSize;
        };
        TextElement.prototype.arrange = function (desiredSize) {
            if (desiredSize.width !== this.actualSize.width || desiredSize.height !== this.actualSize.height || this.isDirt) {
                this.doWrap = true;
            }
            this.actualSize = desiredSize;
            this.updateBounds();
            this.isDirt = false;
            return this.actualSize;
        };
        return TextElement;
    }(diagram_element_1.DiagramElement));
    exports.TextElement = TextElement;
});