@thewtex/vtk.js-esm
Version:
Visualization Toolkit for the Web
92 lines (76 loc) • 2.35 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
var _ShapeBehavior;
var BehaviorCategory = {
POINTS: 'POINTS',
PLACEMENT: 'PLACEMENT',
RATIO: 'RATIO'
};
var ShapeBehavior = (_ShapeBehavior = {}, _defineProperty(_ShapeBehavior, BehaviorCategory.POINTS, {
CORNER_TO_CORNER: 0,
CENTER_TO_CORNER: 1,
RADIUS: 2,
DIAMETER: 3
}), _defineProperty(_ShapeBehavior, BehaviorCategory.PLACEMENT, {
CLICK: 0,
DRAG: 1,
CLICK_AND_DRAG: 2
}), _defineProperty(_ShapeBehavior, BehaviorCategory.RATIO, {
FIXED: 0,
FREE: 1
}), _ShapeBehavior);
var HorizontalTextPosition = {
OUTSIDE_LEFT: 'OUSIDE_LEFT',
INSIDE_LEFT: 'INSIDE_LEFT',
OUTSIDE_RIGHT: 'OUSIDE_RIGHT',
INSIDE_RIGHT: 'INSIDE_RIGHT',
MIDDLE: 'MIDDLE'
};
var VerticalTextPosition = {
OUTSIDE_TOP: 'OUSIDE_TOP',
INSIDE_TOP: 'INSIDE_TOP',
OUTSIDE_BOTTOM: 'OUSIDE_BOTTOM',
INSIDE_BOTTOM: 'INSIDE_BOTTOM',
MIDDLE: 'MIDDLE'
};
function computeTextPosition(bounds, horizontalPosition, verticalPosition, textWidth, textHeight) {
var margin = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
var x = 0;
switch (horizontalPosition) {
case HorizontalTextPosition.OUTSIDE_LEFT:
x = bounds[0] - textWidth - margin;
break;
case HorizontalTextPosition.INSIDE_LEFT:
x = bounds[0] + margin;
break;
case HorizontalTextPosition.MIDDLE:
x = 0.5 * (bounds[0] + bounds[1] - textWidth);
break;
case HorizontalTextPosition.INSIDE_RIGHT:
x = bounds[1] - textWidth - margin;
break;
case HorizontalTextPosition.OUTSIDE_RIGHT:
x = bounds[1] + margin;
break;
}
var y = 0;
switch (verticalPosition) {
case VerticalTextPosition.OUTSIDE_TOP:
y = bounds[3] + textHeight + margin;
break;
case VerticalTextPosition.INSIDE_TOP:
y = bounds[3] - margin;
break;
case VerticalTextPosition.MIDDLE:
y = 0.5 * (bounds[2] + bounds[3] + textWidth);
break;
case VerticalTextPosition.INSIDE_BOTTOM:
y = bounds[2] + textHeight + margin;
break;
case VerticalTextPosition.OUTSIDE_BOTTOM:
y = bounds[2] - margin;
break;
}
return [x, y, 0];
}
export default ShapeBehavior;
export { BehaviorCategory, HorizontalTextPosition, ShapeBehavior, VerticalTextPosition, computeTextPosition };