define(["require", "exports", "./../objects/node", "../enum/enum", "../enum/enum", "./../objects/connector", "./../objects/node", "../objects/annotation", "../objects/port"], function (require, exports, node_1, enum_1, enum_2, connector_1, node_2, annotation_1, port_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function canSelect(node) {
if (node) {
var state = 0;
if ((node instanceof annotation_1.ShapeAnnotation) || (node instanceof annotation_1.PathAnnotation)) {
state = node.constraints & enum_2.AnnotationConstraints.Select;
}
else if (node instanceof connector_1.Connector) {
state = node.constraints & enum_1.ConnectorConstraints.Select;
}
else {
state = node.constraints & enum_1.NodeConstraints.Select;
}
return state;
}
return 1;
}
exports.canSelect = canSelect;
function canMove(node) {
if (node) {
var state = 0;
if ((node instanceof annotation_1.ShapeAnnotation) || (node instanceof annotation_1.PathAnnotation)) {
state = node.constraints & enum_2.AnnotationConstraints.Drag;
}
else if (node instanceof connector_1.Connector) {
state = node.constraints & enum_1.ConnectorConstraints.Drag;
}
else if (node instanceof node_2.Selector) {
state = 1;
}
else {
state = node.constraints & enum_1.NodeConstraints.Drag;
}
return state;
}
return 1;
}
exports.canMove = canMove;
function canEnablePointerEvents(node, diagram) {
var state = 0;
if (node instanceof connector_1.Connector) {
state = node.constraints & enum_1.ConnectorConstraints.PointerEvents;
}
else {
state = node.constraints & enum_1.NodeConstraints.PointerEvents;
}
return state;
}
exports.canEnablePointerEvents = canEnablePointerEvents;
function canDelete(node) {
var state = 0;
if (node instanceof connector_1.Connector) {
state = node.constraints & enum_1.ConnectorConstraints.Delete;
}
else {
state = node.constraints & enum_1.NodeConstraints.Delete;
}
return state;
}
exports.canDelete = canDelete;
function canBridge(connector, diagram) {
var state = 0;
if (connector.constraints & enum_1.ConnectorConstraints.Bridging) {
state = connector.constraints & enum_1.ConnectorConstraints.Bridging;
}
else if (connector.constraints & enum_1.ConnectorConstraints.InheritBridging) {
state = diagram.constraints & enum_1.DiagramConstraints.Bridging;
}
else {
state = 0;
}
return state;
}
exports.canBridge = canBridge;
function canEnableRouting(connector, diagram) {
var state = 0;
Iif (connector.constraints & enum_1.ConnectorConstraints.LineRouting) {
state = connector.constraints & enum_1.ConnectorConstraints.LineRouting;
}
else Eif (connector.constraints & enum_1.ConnectorConstraints.InheritLineRouting) {
state = diagram.constraints & enum_1.DiagramConstraints.LineRouting;
}
return state;
}
exports.canEnableRouting = canEnableRouting;
function canDragSourceEnd(connector) {
return connector.constraints & enum_1.ConnectorConstraints.DragSourceEnd;
}
exports.canDragSourceEnd = canDragSourceEnd;
function canDragTargetEnd(connector) {
return connector.constraints & enum_1.ConnectorConstraints.DragTargetEnd;
}
exports.canDragTargetEnd = canDragTargetEnd;
function canDragSegmentThumb(connector) {
return connector.constraints & enum_1.ConnectorConstraints.DragSegmentThumb;
}
exports.canDragSegmentThumb = canDragSegmentThumb;
function canRotate(node) {
if ((node instanceof annotation_1.ShapeAnnotation) || (node instanceof annotation_1.PathAnnotation)) {
return node.constraints & enum_2.AnnotationConstraints.Rotate;
}
else {
return node.constraints & enum_1.NodeConstraints.Rotate;
}
}
exports.canRotate = canRotate;
function canShadow(node) {
return node.constraints & enum_1.NodeConstraints.Shadow;
}
exports.canShadow = canShadow;
function canInConnect(node) {
if ((node instanceof node_1.Node) && (node.constraints & enum_1.NodeConstraints.InConnect)) {
return node.constraints & enum_1.NodeConstraints.InConnect;
}
return 0;
}
exports.canInConnect = canInConnect;
function canPortInConnect(port) {
if (port && port.constraints) {
if (!(port.constraints & enum_2.PortConstraints.None) && (port.constraints & enum_2.PortConstraints.InConnect)) {
return port.constraints & enum_2.PortConstraints.InConnect;
}
}
return 0;
}
exports.canPortInConnect = canPortInConnect;
function canOutConnect(node) {
if ((node instanceof node_1.Node) && (node.constraints & enum_1.NodeConstraints.OutConnect)) {
return node.constraints & enum_1.NodeConstraints.OutConnect;
}
return 0;
}
exports.canOutConnect = canOutConnect;
function canPortOutConnect(port) {
if (port && port.constraints) {
if (!(port.constraints & enum_2.PortConstraints.None) && (port.constraints & enum_2.PortConstraints.OutConnect)) {
return port.constraints & enum_2.PortConstraints.OutConnect;
}
}
return 0;
}
exports.canPortOutConnect = canPortOutConnect;
function canResize(node, direction) {
var returnValue = 0;
if (node instanceof annotation_1.ShapeAnnotation || node instanceof annotation_1.PathAnnotation) {
returnValue = node.constraints & enum_2.AnnotationConstraints.Resize;
}
else Eif (node) {
if (direction === 'SouthEast') {
returnValue = node.constraints & enum_1.NodeConstraints.ResizeSouthEast;
}
else if (direction === 'East') {
returnValue = node.constraints & enum_1.NodeConstraints.ResizeEast;
}
else if (direction === 'NorthEast') {
returnValue = node.constraints & enum_1.NodeConstraints.ResizeNorthEast;
}
else if (direction === 'South') {
returnValue = node.constraints & enum_1.NodeConstraints.ResizeSouth;
}
else if (direction === 'North') {
returnValue = node.constraints & enum_1.NodeConstraints.ResizeNorth;
}
else if (direction === 'SouthWest') {
returnValue = node.constraints & enum_1.NodeConstraints.ResizeSouthWest;
}
else if (direction === 'West') {
returnValue = node.constraints & enum_1.NodeConstraints.ResizeWest;
}
else Eif (direction === 'NorthWest') {
returnValue = node.constraints & enum_1.NodeConstraints.ResizeNorthWest;
}
}
return returnValue;
}
exports.canResize = canResize;
function canAllowDrop(node) {
var state = 0;
if (node instanceof connector_1.Connector) {
state = node.constraints & enum_1.ConnectorConstraints.AllowDrop;
}
else {
state = node.constraints & enum_1.NodeConstraints.AllowDrop;
}
return state;
}
exports.canAllowDrop = canAllowDrop;
function canVitualize(diagram) {
return diagram.constraints & enum_1.DiagramConstraints.Virtualization;
}
exports.canVitualize = canVitualize;
function canEnableToolTip(node, diagram) {
var state = 0;
if (node instanceof connector_1.Connector) {
if (node.constraints & enum_1.ConnectorConstraints.Tooltip) {
state = node.constraints & enum_1.ConnectorConstraints.Tooltip;
}
else if (node.constraints & enum_1.ConnectorConstraints.InheritTooltip) {
state = diagram.constraints & enum_1.DiagramConstraints.Tooltip;
}
}
else if (node instanceof port_1.PointPort || node instanceof port_1.PathPort) {
if (node.constraints & enum_2.PortConstraints.ToolTip) {
state = node.constraints & enum_2.PortConstraints.ToolTip;
}
else Iif (node.constraints & enum_2.PortConstraints.InheritTooltip) {
state = diagram.constraints & enum_1.DiagramConstraints.Tooltip;
}
}
else if (node instanceof annotation_1.ShapeAnnotation || node instanceof annotation_1.PathAnnotation) {
Eif (node.constraints & enum_2.AnnotationConstraints.Tooltip) {
state = node.constraints & enum_2.AnnotationConstraints.Tooltip;
}
}
else {
if (node.constraints & enum_1.NodeConstraints.Tooltip) {
state = node.constraints & enum_1.NodeConstraints.Tooltip;
}
else if (node.constraints & enum_1.NodeConstraints.InheritTooltip) {
state = diagram.constraints & enum_1.DiagramConstraints.Tooltip;
}
}
return state;
}
exports.canEnableToolTip = canEnableToolTip;
function canSingleSelect(model) {
return model.tool & enum_1.DiagramTools.SingleSelect;
}
exports.canSingleSelect = canSingleSelect;
function canMultiSelect(model) {
return model.tool & enum_1.DiagramTools.MultipleSelect;
}
exports.canMultiSelect = canMultiSelect;
function canZoomPan(model) {
return model.tool & enum_1.DiagramTools.ZoomPan;
}
exports.canZoomPan = canZoomPan;
function canContinuousDraw(model) {
return model.tool & enum_1.DiagramTools.ContinuousDraw;
}
exports.canContinuousDraw = canContinuousDraw;
function canDrawOnce(model) {
return model.tool & enum_1.DiagramTools.DrawOnce;
}
exports.canDrawOnce = canDrawOnce;
function defaultTool(model) {
return (model.tool & enum_1.DiagramTools.SingleSelect) || (model.tool & enum_1.DiagramTools.MultipleSelect);
}
exports.defaultTool = defaultTool;
function canZoom(model) {
return model.constraints & enum_1.DiagramConstraints.Zoom;
}
exports.canZoom = canZoom;
function canPan(model) {
return model.constraints & enum_1.DiagramConstraints.Pan;
}
exports.canPan = canPan;
function canUserInteract(model) {
return model.constraints & enum_1.DiagramConstraints.UserInteraction;
}
exports.canUserInteract = canUserInteract;
function canApiInteract(model) {
return model.constraints & enum_1.DiagramConstraints.ApiUpdate;
}
exports.canApiInteract = canApiInteract;
function canPanX(model) {
return ((model.constraints & enum_1.DiagramConstraints.PanX));
}
exports.canPanX = canPanX;
function canPanY(model) {
return ((model.constraints & enum_1.DiagramConstraints.PanY));
}
exports.canPanY = canPanY;
function canZoomTextEdit(diagram) {
return ((diagram.constraints & enum_1.DiagramConstraints.ZoomTextEdit));
}
exports.canZoomTextEdit = canZoomTextEdit;
function canPageEditable(model) {
return canApiInteract(model) || (model.diagramActions & enum_1.DiagramAction.ToolAction);
}
exports.canPageEditable = canPageEditable;
function enableReadOnly(annotation, node) {
var enumValue = 0;
enumValue = (node instanceof connector_1.Connector) ? enum_1.ConnectorConstraints.ReadOnly : enum_1.NodeConstraints.ReadOnly;
if (node.shape.type === 'Text') {
return node.constraints & enum_1.NodeConstraints.ReadOnly;
}
else if (node.constraints & enumValue) {
if (annotation.constraints & enum_2.AnnotationConstraints.InheritReadOnly) {
return 1;
}
else {
return 0;
}
}
else if (annotation.constraints & enum_2.AnnotationConstraints.ReadOnly) {
return 1;
}
return 0;
}
exports.enableReadOnly = enableReadOnly;
function canDraw(port, diagram) {
return port.constraints & enum_2.PortConstraints.Draw;
}
exports.canDraw = canDraw;
function canDrag(port, diagram) {
return port.constraints & enum_2.PortConstraints.Drag;
}
exports.canDrag = canDrag;
function canPreventClearSelection(diagramActions) {
Iif (diagramActions & enum_1.DiagramAction.PreventClearSelection) {
return true;
}
else {
return false;
}
}
exports.canPreventClearSelection = canPreventClearSelection;
function canDrawThumbs(rendererActions) {
if (!(rendererActions & enum_1.RendererAction.DrawSelectorBorder)) {
return true;
}
else {
return false;
}
}
exports.canDrawThumbs = canDrawThumbs;
function avoidDrawSelector(rendererActions) {
if ((rendererActions & enum_1.RendererAction.PreventRenderSelector)) {
return true;
}
else {
return false;
}
}
exports.avoidDrawSelector = avoidDrawSelector;
});
|