Skip to content

Commit

Permalink
> ILink::index (uint) -> ILink::id (String)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmshv committed Mar 14, 2013
1 parent e1e5dba commit c2c5e59
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
16 changes: 8 additions & 8 deletions src/ru/gotoandstop/nodes/VacuumLayout.as
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public class VacuumLayout extends EventDispatcher implements IDisposable {
return this.layers[name];
}

public function connect(first:IPort, second:IPort, index:uint = 0):uint {
public function connect(first:IPort, second:IPort, id:String=null):String {
var connection:ILink;
if (index) {
if (id) {
for each(var c:ILink in _links) {
if (c.index == index) {
if (c.id == id) {
connection = c;
break;
}
Expand All @@ -83,11 +83,11 @@ public class VacuumLayout extends EventDispatcher implements IDisposable {
connection = _linkProvider.provideLink(first, second);
_links.push(connection);
}
return connection.index;
return connection.id;
}

public function connectWithMouse(port:PortPoint, index:uint = 0):uint {
return this.connect(port, this.cursor, index);
public function connectWithMouse(port:PortPoint, id:String=null):String {
return this.connect(port, this.cursor, id);
}

public function addDataType(type:String, obj:*):void {
Expand All @@ -98,9 +98,9 @@ public class VacuumLayout extends EventDispatcher implements IDisposable {
return null;
}

public function breakConnection(connectionIndex:uint):void {
public function breakConnection(connectionIndex:String):void {
for each(var c:ILink in this._links) {
if (c.index == connectionIndex) {
if (c.id == connectionIndex) {
var index:int = this._links.indexOf(c);
this._links.splice(index, 1);

Expand Down
10 changes: 5 additions & 5 deletions src/ru/gotoandstop/nodes/core/NodeSystem.as
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class NodeSystem extends Sprite implements INodeSystem {
private var _mouseDownCoord:Point = new Point();

private var connections:Vector.<Object>;
private var fakeConnection:uint;
private var fakeConnection:String;
private var firstPortFake:PortPoint;

private var nodeLibrary:Object;
Expand Down Expand Up @@ -214,11 +214,11 @@ public class NodeSystem extends Sprite implements INodeSystem {
}
}

var connection_index:uint = _vacuum.connect(from, to, fakeConnection);
var connection_id:String = _vacuum.connect(from, to, fakeConnection);
connections.push({
from:from,
to:to,
vacuumIndex:connection_index
vacuumIndex:connection_id
});

transferData(from.node.id, from.property, to.node.id, to.property, TransportOrigin.LINK_ESTABLISHING);
Expand Down Expand Up @@ -495,7 +495,7 @@ public class NodeSystem extends Sprite implements INodeSystem {
private function handleInVertexMouseUp(event:MouseEvent):void {
const vertex:PortPoint = event.currentTarget as PortPoint;
makeLink(firstPortFake, vertex);
fakeConnection = 0;
fakeConnection = null;
firstPortFake = null;
}

Expand All @@ -518,7 +518,7 @@ public class NodeSystem extends Sprite implements INodeSystem {
}

_vacuum.breakConnection(fakeConnection);
fakeConnection = 0;
fakeConnection = null;
firstPortFake = null;
}

Expand Down
1 change: 0 additions & 1 deletion src/ru/gotoandstop/nodes/links/BezierQuadConnection.as
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class BezierQuadConnection extends NodeLink{
public function BezierQuadConnection(canvas:DisplayObjectContainer) {
super("bezierquad");
_canvas = canvas;
_index = DirectLink.getIndex();
spline = new Spline(canvas);

view = new SplineView(spline);
Expand Down
7 changes: 0 additions & 7 deletions src/ru/gotoandstop/nodes/links/DirectLink.as
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ import ru.gotoandstop.vacuum.core.ITargetVertex;
import ru.gotoandstop.vacuum.core.TargetVertex;

public class DirectLink extends NodeLink{
private static var count:uint = 1;

internal static function getIndex():uint {
return count++;
}

protected var _canvas:DisplayObjectContainer;
public function get canvas():DisplayObjectContainer {
return _canvas;
Expand All @@ -36,7 +30,6 @@ public class DirectLink extends NodeLink{
public function DirectLink(canvas:DisplayObjectContainer) {
super("simplelink");
_canvas = canvas;
_index = DirectLink.getIndex();

_first = new TargetVertex();
_second = new TargetVertex();
Expand Down
2 changes: 1 addition & 1 deletion src/ru/gotoandstop/nodes/links/ILink.as
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ru.gotoandstop.ILockable;
import ru.gotoandstop.ISerializable;

public interface ILink extends ISerializable, ILockable, IDisposable{
function get index():uint;
function get id():String;
function get type():String;
function get inputPort():IPort;
function set inputPort(value:IPort):void;
Expand Down
14 changes: 10 additions & 4 deletions src/ru/gotoandstop/nodes/links/NodeLink.as
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
*/
package ru.gotoandstop.nodes.links {
import flash.errors.IllegalOperationError;
import flash.utils.getTimer;

import ru.gotoandstop.nodes.NodeSystemElementType;

public class NodeLink implements ILink{
protected var _index:uint;
public function get index():uint {
return _index;
private static function generateID():String {
return "link"+getTimer().toString(16);
}

protected var _id:String;
public function get id():String {
return _id;
}

private var _type:String;
Expand Down Expand Up @@ -47,14 +52,15 @@ public class NodeLink implements ILink{

public function NodeLink(linkType:String) {
_type = linkType;
_id = generateID();
init();
}

public function encode():Object {
return {
"elementType":NodeSystemElementType.LINK,
"type":type,
"index":index
"index":id
};
}

Expand Down

0 comments on commit c2c5e59

Please sign in to comment.