Giter Club home page Giter Club logo

web-topology's Introduction

web-topology

基于jtopo实现的拓扑编辑器,把项目放tomcat才能访问。具体可参考:https://juejin.im/post/5b2b5d686fb9a00e8b252b59

update

增加直线拐点功能,实现思路很简单,在中间增加一个控制点即可,如需要更多的拐点可以分段增加。

js/editor.js
 //鼠标悬浮
    var midList = [];
    this.scene.mouseover(function (e) {
        if(e.target && e.target.midNode){
            e.target.midNode.visible = true;
            return;
        }
        if(e.target && e.target instanceof JTopo.Link && !e.target.hasPaintMid && e.target.lineType == 'line'){
            var nodeA = e.target.nodeA, nodeZ = e.target.nodeZ;
            //移除当前连线
            this.remove(e.target);
            //重建连线
            //中间小节点
            var midNode = new JTopo.CircleNode('');
            midNode.type = 'tag';
            midNode.radius = 3;
            midNode.fillColor = '255,0,0';
            midNode.alpha = 0.7;
            midNode.setLocation((nodeA.cx +nodeZ.cx)/2,(nodeA.cy +nodeZ.cy)/2);
            this.add(midNode)
            var m = new JTopo.Link(nodeA, midNode);
            var n = new JTopo.Link(midNode, nodeZ);
            m.lineType = "line";
            m.strokeColor = self.config.strokeColor;
            m.lineWidth = self.config.lineWidth;
            n.lineType = "line";
            n.strokeColor = self.config.strokeColor;
            n.lineWidth = self.config.lineWidth;
            this.add(m);
            this.add(n);
            m.hasPaintMid = true;
            m.midNode = midNode;
            n.hasPaintMid = true;
            n.midNode = midNode;
            midList.push(midNode);
        }
    });
    this.scene.mouseout(function (e) {
        if(e.target == null || (e.target != null && !e.target instanceof JTopo.Link))
        for (var i = 0; i < midList.length; i++) {
            midList[i].visible = false;
        }
    });

License

License: GNU GPL v3.0

web-topology's People

Contributors

gongxufan avatar

Watchers

duansm avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.