sprotty
Version:
A next-gen framework for graphical views
64 lines • 3.78 kB
JavaScript
;
/********************************************************************************
* Copyright (c) 2018 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.IssueMarkerView = void 0;
/** @jsx svg */
const jsx_1 = require("../../lib/jsx");
const vnode_utils_1 = require("../../base/views/vnode-utils");
const inversify_1 = require("inversify");
let IssueMarkerView = class IssueMarkerView {
render(marker, context) {
const scale = 16 / 1792;
const trafo = `scale(${scale}, ${scale})`;
const maxSeverity = this.getMaxSeverity(marker);
const group = (0, jsx_1.svg)("g", { "class-sprotty-issue": true },
(0, jsx_1.svg)("g", { transform: trafo },
(0, jsx_1.svg)("path", { d: this.getPath(maxSeverity) })));
(0, vnode_utils_1.setClass)(group, 'sprotty-' + maxSeverity, true);
return group;
}
getMaxSeverity(marker) {
let currentSeverity = 'info';
for (const severity of marker.issues.map(s => s.severity)) {
if (severity === 'error' || (severity === 'warning' && currentSeverity === 'info'))
currentSeverity = severity;
}
return currentSeverity;
}
getPath(severity) {
switch (severity) {
case 'error':
case 'warning':
// eslint-disable-next-line max-len
return "M768 128q209 0 385.5 103t279.5 279.5 103 385.5-103 385.5-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103zm128 1247v-190q0-14-9-23.5t-22-9.5h-192q-13 0-23 10t-10 23v190q0 13 10 23t23 10h192q13 0 22-9.5t9-23.5zm-2-344l18-621q0-12-10-18-10-8-24-8h-220q-14 0-24 8-10 6-10 18l17 621q0 10 10 17.5t24 7.5h185q14 0 23.5-7.5t10.5-17.5z";
case 'info':
// eslint-disable-next-line max-len
return "M1024 1376v-160q0-14-9-23t-23-9h-96v-512q0-14-9-23t-23-9h-320q-14 0-23 9t-9 23v160q0 14 9 23t23 9h96v320h-96q-14 0-23 9t-9 23v160q0 14 9 23t23 9h448q14 0 23-9t9-23zm-128-896v-160q0-14-9-23t-23-9h-192q-14 0-23 9t-9 23v160q0 14 9 23t23 9h192q14 0 23-9t9-23zm640 416q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z";
}
}
};
exports.IssueMarkerView = IssueMarkerView;
exports.IssueMarkerView = IssueMarkerView = __decorate([
(0, inversify_1.injectable)()
], IssueMarkerView);
//# sourceMappingURL=views.js.map