2017-11-17 11 views
0

문서에서 필요한 것을 찾는 데 어려움을 겪고 있습니다. 나는 상수가 있다는 것을 알고 있지만, 내가 원하는 것을 할 수있는 것을 찾을 수없는 것처럼 보입니다.mxgraph 연결 및 레이블 핸들을 제거 하시겠습니까?

mxGraph를 사용하여 꼭지점에 대한 가장자리 연결 핸들을 연결 해제 할 수 없습니다. 나는 그들에게 보여주고 싶지 않다. 또한 라벨 핸들을 제거하고 싶습니다.

어떻게하면됩니까?

function main(container) { 

    // Enables rotation handle 
    mxVertexHandler.prototype.rotationEnabled = false; 
    mxVertexHandler.prototype.guidesEnabled = false; 

    // Alt disables guides 
    mxGuide.prototype.isEnabledForEvent = function(evt) { 
     return !mxEvent.isAltDown(evt); 
    }; 


    // Enables snapping waypoints to terminals 
    mxEdgeHandler.prototype.snapToTerminals = true; 


    // Checks if the browser is supported 
    if (!mxClient.isBrowserSupported()) { 
     console.log('flip to the browser compatiability message'); 
    } 

    // Disables built-in context menu 
    mxEvent.disableContextMenu(document.body); 

    // Changes some default colors 
    mxConstants.HANDLE_FILLCOLOR = '#99ccff'; 
    mxConstants.HANDLE_STROKECOLOR = '#0088cf'; 
    mxConstants.VERTEX_SELECTION_COLOR = '#00a8ff'; 

    // Creates the graph inside the given container 
    var graph = new mxGraph(container); 
    var parent = graph.getDefaultParent(); 



    var baseStyle = graph.getStylesheet().getDefaultVertexStyle(); 
    var edgeStyle = graph.getStylesheet().getDefaultEdgeStyle(); 

    // setup style 
    style = mxUtils.clone(baseStyle); 
    style[mxConstants.STYLE_EDITABLE] = 0; 
    style[mxConstants.STYLE_FILLCOLOR] = "#ffffff"; 
    style[mxConstants.STYLE_STROKECOLOR] = "#d4d4d4"; 
    style[mxConstants.STYLE_STROKEWIDTH] = 1; 
    style[mxConstants.STYLE_ROUNDED] = 1; 
    style[mxConstants.STYLE_ARCSIZE] = 10; 
    style[mxConstants.STYLE_RESIZABLE] = 0; 
    style[mxConstants.STYLE_MARGIN] = 50; 
    graph.getStylesheet().putCellStyle("style", style) 

    edgeStyle[mxConstants.STYLE_EDITABLE] = 0; 
    edgeStyle[mxConstants.STYLE_RESIZABLE] = 0; 
    edgeStyle[mxConstants.STYLE_STROKECOLOR] = "#d4d4d4"; 
    edgeStyle[mxConstants.STYLE_ORTHOGONAL] = 0; 
    edgeStyle[mxConstants.STYLE_STROKEWIDTH] = 1; 
    edgeStyle[mxConstants.STYLE_BENDABLE] = 1; 
    edgeStyle[mxConstants.STYLE_ROUNDED] = true; 
    edgeStyle[mxConstants.STYLE_EDGE] = mxConstants.EDGESTYLE_ENTITY_RELATION; 
    edgeStyle[mxConstants.LABEL_HANDLE_SIZE] = 50; 
    edgeStyle[mxConstants.HANDLE_FILLCOLOR] = '#000000' 
    graph.getStylesheet().putCellStyle("edge_style", edgeStyle); 

    try { 
     var v1 = graph.insertVertex(parent, null, 'One', 20, 20, 80, 30, 'style'); 
     var v2 = graph.insertVertex(parent, null, 'Two', 200, 150, 80, 30, 'style'); 
     var v3 = graph.insertVertex(parent, null, 'Three', 460, 20, 80, 30, 'style'); 

     var e1 = graph.insertEdge(parent, null, 'connected', v1, v2, "edge_style"); 
     var e2 = graph.insertEdge(parent, null, 'connected', v1, v3, "edge_style"); 
     var e4 = graph.insertEdge(parent, null, 'connected', v3, v2, "edge_style"); 

     // TODO: make it so only the root cell can't be moved 
     graph.isCellLocked = function(cell) { 
      return false; 
     } 

     // can't resize cells 
    } finally { 
     graph.getModel().endUpdate(); 
    } 
} 

답변

0

이 기능은 가장자리가 자유롭게 움직이지 않도록 Vertices에 고정되도록 제한합니다.

graph.setAllowDanglingEdges(false); 

이 하나를 시도하십시오.