diff --git a/core/classes/messenger.ts b/core/classes/messenger.ts index bce66ec..d08cfc5 100644 --- a/core/classes/messenger.ts +++ b/core/classes/messenger.ts @@ -16,6 +16,8 @@ module networkcube { export var MESSAGE_SELECTION_FILTER = 'selectionFilter'; export var MESSAGE_SELECTION_PRIORITY = 'selectionPriority' export var MESSAGE_SEARCH_RESULT = 'searchResult'; + export var MESSAGE_STATE = 'stateRecorded'; + var MESSENGER_PROPAGATE: boolean = true; @@ -365,7 +367,24 @@ module networkcube { } - + /// CAPTURE STATE + + + export function recordState(state:Object) + { + distributeMessage(new StateMessage(state)); + } + + export class StateMessage extends Message{ + state:Object; + constructor(state:Object) + { + super(MESSAGE_STATE); + this.state = state; + } + } + + @@ -416,71 +435,6 @@ module networkcube { if (m.type == MESSAGE_HIGHLIGHT) { var m2: HighlightMessage = m; graph.highlight(m2.action, m2.idCompound); - // } else - // if (m.type == MESSAGE_SELECTION) { - // var m3: SelectionMessage = m; - // var compound = cloneCompound(m3.idCompound) - // graph.selection(m3.action, compound, m3.selectionId); - // } else - // if (m.type == MESSAGE_TIME_RANGE) { - // // this type is a view message. no adjustments on the graph necessary. - // } else - // if (m.type == MESSAGE_SELECTION_SET_COLORING_VISIBILITY) { - // var m4: ShowSelectionColorMessage = m; - // graph.getSelection(m4.selectionId).showColor = m4.showColor; - // } else - // if (m.type == MESSAGE_SELECTION_PRIORITY) { - // var m5: SelectionPriorityMessage = m; - // graph.getSelection(m5.selectionId1).priority = m5.priority1; - // graph.getSelection(m5.selectionId2).priority = m5.priority2; - // var linkElements = graph.getLinks().selected().elements; - // for (var i = 0; i < linkElements.length; i++) { - // linkElements[i].getSelections().sort(sortByPriority) - // } - // var nodeElements = graph.getNodes().selected().elements; - // for (var i = 0; i < nodeElements.length; i++) { - // nodeElements[i].getSelections().sort(sortByPriority) - // } - // // elements = graph.getTimes().selected().elements; - // // for(var i=0 ; im; - // // graph.filter(m.idCompound, filter) - // // }else - // if (m.type == MESSAGE_SELECTION_FILTER) { - // var m6: FilterSelectionMessage = m; - // graph.filterSelection(m6.selectionId, m6.filter); - // } else - // // test messages that don't require a message handler - // if (m.type == MESSAGE_SELECTION_CREATE) { - // var m7: CreateSelectionMessage = m; - // graph.addSelection(m7.selection.id, m7.selection.color, m7.selection.acceptedType, m7.selection.priority); - // } else - // if (m.type == MESSAGE_SELECTION_SET_CURRENT) { - // var m8: SetCurrentSelectionIdMessage = m; - // graph.setCurrentSelection(m8.selectionId); - // } else - // if (m.type == MESSAGE_SELECTION_DELETE) { - // var m10: DeleteSelectionMessage = m; - // graph.deleteSelection(m10.selectionId); - // } else - // if (m.type == MESSAGE_SEARCH_RESULT) { - // var m11: SearchResultMessage = m; - // graph.highlight('set', m11.idCompound); - // } else - // if (m.type == MESSAGE_SELECTION_COLORING) { - // var m12: SelectionColorMessage = m; - // graph.getSelection(m12.selectionId).color = m12.color; - // } -// -// }else if(m.type == MESSAGE_SELECTION){ var m3:SelectionMessage = m; @@ -506,19 +460,11 @@ module networkcube { for(var i=0 ; im; - // graph.filter(m.idCompound, filter) - // }else if(m.type == MESSAGE_SELECTION_FILTER){ var m6:FilterSelectionMessage = m; graph.filterSelection(m6.selectionId, m6.filter); diff --git a/core/networkcube.d.ts b/core/networkcube.d.ts index 7eca730..b06b244 100644 --- a/core/networkcube.d.ts +++ b/core/networkcube.d.ts @@ -682,6 +682,7 @@ declare module networkcube { var MESSAGE_SELECTION_FILTER: string; var MESSAGE_SELECTION_PRIORITY: string; var MESSAGE_SEARCH_RESULT: string; + var MESSAGE_STATE: string; function addEventListener(messageType: string, handler: Function): void; function setDefaultEventListener(handler: Function): void; class Message { @@ -752,6 +753,11 @@ declare module networkcube { searchTerm: string; constructor(searchTerm: string, idCompound: IDCompound); } + function recordState(state: Object): void; + class StateMessage extends Message { + state: Object; + constructor(state: Object); + } function distributeMessage(message: Message, ownView?: boolean): void; } declare module networkcube { diff --git a/core/networkcube.js b/core/networkcube.js index 9e9f668..4d8af18 100644 --- a/core/networkcube.js +++ b/core/networkcube.js @@ -12807,6 +12807,7 @@ var networkcube; networkcube.MESSAGE_SELECTION_FILTER = 'selectionFilter'; networkcube.MESSAGE_SELECTION_PRIORITY = 'selectionPriority'; networkcube.MESSAGE_SEARCH_RESULT = 'searchResult'; + networkcube.MESSAGE_STATE = 'stateRecorded'; var MESSENGER_PROPAGATE = true; var MESSAGE_HANDLERS = [ networkcube.MESSAGE_HIGHLIGHT, @@ -13044,6 +13045,19 @@ var networkcube; return SearchResultMessage; })(Message); networkcube.SearchResultMessage = SearchResultMessage; + function recordState(state) { + distributeMessage(new StateMessage(state)); + } + networkcube.recordState = recordState; + var StateMessage = (function (_super) { + __extends(StateMessage, _super); + function StateMessage(state) { + _super.call(this, networkcube.MESSAGE_STATE); + this.state = state; + } + return StateMessage; + })(Message); + networkcube.StateMessage = StateMessage; var MESSAGE_KEY = 'networkcube_message'; localStorage[MESSAGE_KEY] = undefined; function distributeMessage(message, ownView) { diff --git a/styles.css b/styles.css index e9f182e..6535efc 100644 --- a/styles.css +++ b/styles.css @@ -6,7 +6,6 @@ h1{ font-weight: 200; font-family: 'Comfortaa', 'Helvetica Neue', sans-serif; } -} h2{ font-weight: 200; } @@ -30,6 +29,8 @@ div#main{ color: #555; margin-right:20px; margin-top: 20px; + margin-top: 10px; + text-decoration: underline; } .exportPNG-button{ diff --git a/visualizations/nodelink/index.html b/visualizations/nodelink/index.html index d545c83..e59c6bf 100644 --- a/visualizations/nodelink/index.html +++ b/visualizations/nodelink/index.html @@ -17,7 +17,8 @@