Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

add visualiazations/tsconfig #202

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 20 additions & 74 deletions core/classes/messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
}





Expand Down Expand Up @@ -416,71 +435,6 @@ module networkcube {
if (m.type == MESSAGE_HIGHLIGHT) {
var m2: HighlightMessage = <HighlightMessage>m;
graph.highlight(m2.action, m2.idCompound);
// } else
// if (m.type == MESSAGE_SELECTION) {
// var m3: SelectionMessage = <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 = <ShowSelectionColorMessage>m;
// graph.getSelection(m4.selectionId).showColor = m4.showColor;
// } else
// if (m.type == MESSAGE_SELECTION_PRIORITY) {
// var m5: SelectionPriorityMessage = <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 ; i<elements.length ; i++){
// // elements[i].getSelections().sort(sortByPriority)
// // }
// var nodePairElements = graph.getNodePairs().selected().elements;
// for (var i = 0; i < nodePairElements.length; i++) {
// nodePairElements[i].getSelections().sort(sortByPriority)
// }
// } else
// // if(m.type == MESSAGE_FILTER){
// // var m6:FilterM = <SelectionPriorityMessage>m;
// // graph.filter(m.idCompound, filter)
// // }else
// if (m.type == MESSAGE_SELECTION_FILTER) {
// var m6: FilterSelectionMessage = <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 = <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 = <SetCurrentSelectionIdMessage>m;
// graph.setCurrentSelection(m8.selectionId);
// } else
// if (m.type == MESSAGE_SELECTION_DELETE) {
// var m10: DeleteSelectionMessage = <DeleteSelectionMessage>m;
// graph.deleteSelection(m10.selectionId);
// } else
// if (m.type == MESSAGE_SEARCH_RESULT) {
// var m11: SearchResultMessage = <SearchResultMessage>m;
// graph.highlight('set', m11.idCompound);
// } else
// if (m.type == MESSAGE_SELECTION_COLORING) {
// var m12: SelectionColorMessage = <SelectionColorMessage>m;
// graph.getSelection(m12.selectionId).color = m12.color;
// }
//
//
}else
if(m.type == MESSAGE_SELECTION){
var m3:SelectionMessage = <SelectionMessage>m;
Expand All @@ -506,19 +460,11 @@ module networkcube {
for(var i=0 ; i<nodeElements.length ; i++){
nodeElements[i].getSelections().sort(sortByPriority)
}
// elements = graph.getTimes().selected().elements;
// for(var i=0 ; i<elements.length ; i++){
// elements[i].getSelections().sort(sortByPriority)
// }
var nodePairElements = graph.nodePairs().selected().toArray();
for(var i=0 ; i<nodePairElements.length ; i++){
nodePairElements[i].getSelections().sort(sortByPriority)
}
}else
// if(m.type == MESSAGE_FILTER){
// var m6:FilterM = <SelectionPriorityMessage>m;
// graph.filter(m.idCompound, filter)
// }else
if(m.type == MESSAGE_SELECTION_FILTER){
var m6:FilterSelectionMessage = <FilterSelectionMessage>m;
graph.filterSelection(m6.selectionId, m6.filter);
Expand Down
6 changes: 6 additions & 0 deletions core/networkcube.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions core/networkcube.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ h1{
font-weight: 200;
font-family: 'Comfortaa', 'Helvetica Neue', sans-serif;
}
}
h2{
font-weight: 200;
}
Expand All @@ -30,6 +29,8 @@ div#main{
color: #555;
margin-right:20px;
margin-top: 20px;
margin-top: 10px;
text-decoration: underline;
}

.exportPNG-button{
Expand Down
3 changes: 2 additions & 1 deletion visualizations/nodelink/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<div id="menuDiv">
<!-- VS: Clicks on Manual -->
<a class="manual-button" target="_blank" href="https://github.com/networkcube/networkcube/wiki/Visualization-Manual#node-link-visualization-nodelink" onclick="trace.event('help', 'ts_nodelinkVisManual', 'CCC', 'DDD')"> Manual</a>

<input type="button" id="captureButton" class="manual-button" value="Capture"/>

<!-- Original code -->
<!-- <a class="manual-button" target="_blank" href="https://github.com/networkcube/networkcube/wiki/Visualization-Manual#node-link-visualization-nodelink" onclick="trace.event('help', 'ts_NLVisManual', 'CCC', 'DDD')"> Manual</a> -->

Expand Down
24 changes: 24 additions & 0 deletions visualizations/nodelink/nodelink.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,3 +473,27 @@ function unshowMessage() {
if ($('#messageBox'))
$('#messageBox').remove();
}
d3.select('#captureButton')
.on('click', function () {
captureState();
});
function captureState() {
var json = {};
var nodePosX = [];
var nodePosY = [];
for (var i = 0; i < nodes.length; i++) {
nodePosX.push(nodes[i].x);
nodePosY.push(nodes[i].y);
}
json['nodePosX'] = nodePosX;
json['nodePosY'] = nodePosY;
json['timeStart'] = time_start;
json['timeEnd'] = time_end;
json['visualization'] = 'nodelink';
json['dataset'] = networkcube.getUrlVars()['datasetName'];
networkcube.recordState(json);
console.log('json', json);
return null;
}
function restoreState(json) {
}
50 changes: 50 additions & 0 deletions visualizations/nodelink/nodelink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,3 +651,53 @@



//////////////
/// STATES ///
//////////////


d3.select('#captureButton')
.on('click', ()=>
{
captureState();
})


// Returns an object that captures the current visualization state
function captureState()
{
/// capture states
var json = {};
// node positions, nodes[i].x
var nodePosX = []
var nodePosY = []
for(var i=0 ; i<nodes.length ; i++){
nodePosX.push(nodes[i].x)
nodePosY.push(nodes[i].y)
}
json['nodePosX'] = nodePosX
json['nodePosY'] = nodePosY

// link visibility


// current time: time_start, time_end
json['timeStart'] = time_start
json['timeEnd'] = time_end

json['visualization'] = 'nodelink';
json['dataset'] = networkcube.getUrlVars()['datasetName']

networkcube.recordState(json);

console.log('json', json)
return null;
}


// Restores the state passed by the string.
function restoreState(json:String){
/// restore state
}


20 changes: 20 additions & 0 deletions visualizations/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.5.0-alpha",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"watch": true,
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true
},
"files": [
"nodelink/nodelink.ts",
"map/map.ts",
"matrix/matrix.ts",
"dynamicego/dynamicego.ts"
]
}
1 change: 0 additions & 1 deletion web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"suppressImplicitAnyIndexErrors": true
},
"files": [
"../networkcube/core/networkcube.d.ts",
"./classes/storage.ts",
"./classes/utils.ts",
"./classes/vistorian.ts",
Expand Down