changtimwu / changtimwu.github.com

Tim's testing/practice notes
7 stars 2 forks source link

the-graph study #2

Open changtimwu opened 9 years ago

changtimwu commented 9 years ago

continue the notes here https://gist.github.com/changtimwu/0b8f9d5547ac0a2ccaeb

changtimwu commented 9 years ago

theme is controllered by the classes the-graph-light, the-graph-dark in most outer element -- #svgcontainer.

changtimwu commented 9 years ago

this.$ is defined by polymer https://www.polymer-project.org/docs/polymer/polymer.html#automatic-node-finding.

For a polymer component, with this.$, you can access DOM elements/attributes/contents this a way like this.$.svgcontainer.className.

changtimwu commented 9 years ago

several layers

<!-- polymer starts below, the-graph.coffeekup -->
<div id="svgcontainer" class="the-graph-dark">  
   <!-- reactjs starts below.  app.coffee -->
   <div class="the-graph-app normal" name="app" style="" data-reactid=".0"> 
      <canvas class="app-canvas" width="1190" height="858" data-reactid=".0.0"></canvas>
      <svg class="app-svg" width="1190" height="858" data-reactid=".0.1">
         <g class="view" transform="matrix()" data-reactid=".0.1.0">
            <!-- graph.coffee -->
            <g class="graph" data-reactid=".0.1.0.0"></g>
         </g>
      </svg>
   </div>
</div>

How Polymer works with React ?

The the-graph is a polymer element. One of its properties is graph and the changes of the graph property is implemented in graphChanged. In Polymer, property change can be observed in this way.
In graphChanged, It does the following

@appView = React.renderComponent TheGraph.App(), @$.svgcontainer
changtimwu commented 9 years ago

study /the-graph-editor/demo-simple.html. It uses the-graph-editor.

一個 polymer element 的參數, 通常

    <the-graph-editor id="editor"
      width="800" height="600"
      grid="72"
      snap="36"
      theme="dark">
    </the-graph-editor>
var editor = document.getElementById('editor');
editor.triggerAutolayout();
changtimwu commented 9 years ago

get all components

var lib = editor.getLibrary();
changtimwu commented 9 years ago

the live reload function of gulp-connect doesn't work

the scope of the variable lr in node_modules/gulp-connect/index.js has some problem. reported here https://github.com/AveVlad/gulp-connect/issues/88

issue solved.!

changtimwu commented 9 years ago

在 index.html 加 jquery , $.ajax 會動

changtimwu commented 9 years ago

index.html 裡面有看到其他 map, 可以 load

 // script.src = 'https://api.github.com/gists/7135158?callback=loadGraph';
 // script.src = 'clock.json.js';
 script.src = 'photobooth.json.js';
 // Gesture object building (lots of ports!)
 // script.src = 'https://api.github.com/gists/7022120?callback=loadGraph';
 // Gesture data gathering (big graph)
 //script.src = 'https://api.github.com/gists/7022262?callback=loadGraph';
 // Edge algo test
 //script.src = 'https://api.github.com/gists/6890344?callback=loadGraph';
changtimwu commented 9 years ago

map的 load & save格式不一致, 畫面上秀的圖 the-graph, 有提供 export 出來卻沒提供 load

changtimwu commented 9 years ago

想要把 polymer 換成 angularjs

what does a polymer element do? How can angularjs offer alternative?

angular 最接近的機制是 directive

changtimwu commented 9 years ago

ngReact or handwrite directive?

changtimwu commented 9 years ago
noflo = require("noflo") 
noflo.graph.loadJSON @graph, (nofloGraph)=>
    @buildInitialLibrary nofloGraph
    @nofloGraph = nofloGraph
changtimwu commented 9 years ago

noflo defines

data

functions

events

changtimwu commented 9 years ago

react.animate

    script src: "../bower_components/react.animate-djdeath/react.animate.js"
changtimwu commented 9 years ago

bidirectional flow is still under discussion https://groups.google.com/forum/#!searchin/flow-based-programming/bidirection/flow-based-programming/hfYw1gP7FVI/1tWthSjUMtkJ

http://www.jpaulmorrison.com/fbp/noflo.html

changtimwu commented 9 years ago

The author did a complete rewrite from reactjs to polymer https://github.com/noflo/noflo-ui/tree/master/elements

react based the-graph is here https://github.com/noflo/noflo-ui/blob/master/bower.json#L21

study how the the-graph-editor be used as a component with rich polymer UI. https://github.com/noflo/noflo-ui/blob/master/elements/noflo-ui.html

changtimwu commented 9 years ago

noflo usage

changtimwu commented 9 years ago

some difficulty of implementing bidirectional edge , 故意 IN port 連 IN port, OUT port 連 OUT port

In Graph.coffee

      halfEdge = @state.edgePreview
      if event.detail.isIn
        halfEdge.to = port
      else
        halfEdge.from = port
@props.graph.on 'addEdge', @resetPortRoute`, 
@state.graph.addEdge edge.from.process, edge.from.port, edge.to.process, edge.to.port, edge.metadata
changtimwu commented 9 years ago

resetPortRoute 是如何一路到 renderEdges ?