Skip to content

Commit b93fa94

Browse files
committed
add webapp
1 parent abbb3a1 commit b93fa94

File tree

207 files changed

+278693
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+278693
-0
lines changed

.babelrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
"es2015"
4+
],
5+
"plugins": [
6+
"transform-es3-property-literals",
7+
"transform-es3-member-expression-literals",
8+
"transform-runtime"
9+
]
10+
}

.vscode/launch.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// 使用 IntelliSense 了解相关属性。
3+
// 悬停以查看现有属性的描述。
4+
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "run test <selected file>",
11+
"program": "${file}"
12+
},
13+
{
14+
"type": "node",
15+
"request": "launch",
16+
"name": "run test all",
17+
"program": "${workspaceFolder}/src/test/javascript/testAll.js"
18+
}
19+
]
20+
}

exports.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use strict";
2+
3+
exports.MainFrame = require("./src/main/javascript/mainframe").MainFrame;
4+
exports.BaseApp = require("./src/main/javascript/app/app").BaseApp;
5+
exports.GraphExplorer = require("./src/main/javascript/app/explorer").GraphExplorer;
6+
exports.RelationFinder = require("./src/main/javascript/app/relfinder").RelationFinder;
7+
exports.GraphNavigator = require("./src/main/javascript/app/nav").GraphNavigator;
8+
exports.LocalGraph = require("./src/main/javascript/service/local").LocalGraph;
9+
exports.RemoteGraph = require("./src/main/javascript/service/remote").RemoteGraph;
10+
exports.i18n = require("./src/main/javascript/messages").i18n;
11+
exports.Themes = require("./src/main/javascript/theme").Themes;
12+
13+
exports.ExpansionCtrl = require("./src/main/javascript/control/ExpansionCtrl").ExpansionCtrl;
14+
exports.HighlightNodeCtrl = require("./src/main/javascript/control/HighlightNodeCtrl").HighlightNodeCtrl;
15+
exports.InfoBoxCtrl = require("./src/main/javascript/control/InfoBoxCtrl").InfoBoxCtrl;
16+
exports.MessageBoxCtrl = require("./src/main/javascript/control/MessageBoxCtrl").MessageBoxCtrl;
17+
exports.RelFinderCtrl = require("./src/main/javascript/control/RelFinderCtrl").RelFinderCtrl;
18+
exports.SearchBarCtrl = require("./src/main/javascript/control/SearchBarCtrl").SearchBarCtrl;
19+
exports.ToolbarCtrl = require("./src/main/javascript/control/ToolbarCtrl").ToolbarCtrl;
20+
21+
var utils = require("./src/main/javascript/utils");
22+
exports.Utils = utils.Utils;
23+
exports.Point = utils.Point;
24+
exports.Rect = utils.Rect;

src/main/javascript/app/app.js

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
const mainframe_1 = require("../mainframe");
4+
const local_1 = require("../service/local");
5+
const types_1 = require("../types");
6+
const MessageBoxCtrl_1 = require("../control/MessageBoxCtrl");
7+
const remote_1 = require("../service/remote");
8+
class BaseApp {
9+
constructor(htmlFrame, initialOptions, extra) {
10+
this._toggleEdgeLabelHandlers = {
11+
onselect: this._toggleEdgeLabelOnSelect.bind(this),
12+
ondeselect: this._toggleEdgeLabelOnDeselect.bind(this)
13+
};
14+
this._htmlFrame = htmlFrame;
15+
var frame = new mainframe_1.MainFrame(htmlFrame, initialOptions);
16+
frame.on(types_1.FrameEventName.FRAME_CREATED, this.onCreateFrame.bind(this));
17+
this._frame = frame;
18+
frame.fire(types_1.FrameEventName.FRAME_CREATED, extra || {});
19+
this._messageBox = this._frame.addControl("messagebox", new MessageBoxCtrl_1.MessageBoxCtrl());
20+
}
21+
loadGson(url, callback) {
22+
this._frame.connect(local_1.LocalGraph.fromGsonFile(url), callback);
23+
}
24+
connect(url, callback) {
25+
//remote
26+
console.log("app-remote-connect2");
27+
var graph = new remote_1.RemoteGraph(url);
28+
graph.init();
29+
}
30+
showGraph(options, callback) {
31+
var app = this;
32+
this._messageBox.showMessage("LOADING_GRAPH");
33+
this._frame.load(options, function () {
34+
app._messageBox.hideMessage();
35+
if (callback !== undefined)
36+
callback();
37+
});
38+
}
39+
pickup(keywords, callback) {
40+
var frame = this._frame;
41+
var app = this;
42+
frame.search(keywords, (nodes) => {
43+
var nodeIds = frame.insertNodes(nodes);
44+
frame.placeNodes(nodeIds);
45+
frame.updateNodes(nodeIds.map(function (nodeId) {
46+
return { id: nodeId, physics: false };
47+
}));
48+
if (callback !== undefined)
49+
callback(nodes);
50+
});
51+
}
52+
clearScreen() {
53+
this._frame.clearScreen();
54+
}
55+
updateGraph(showGraphOptions, callback) {
56+
this._frame.updateGraph(showGraphOptions);
57+
}
58+
toggleWeights(checked) {
59+
this.updateGraph(function (options) {
60+
options.showDegrees = checked;
61+
});
62+
}
63+
toggleEdges(checked) {
64+
this.updateGraph(function (options) {
65+
options.showEdges = checked;
66+
});
67+
}
68+
toggleFaces(checked) {
69+
this.updateGraph(function (options) {
70+
options.showFaces = checked;
71+
});
72+
}
73+
toggleShadow(checked) {
74+
this._frame.updateNetworkOptions((options) => {
75+
options.nodes.shadow = checked;
76+
});
77+
}
78+
toggleNavigationButtons(checked) {
79+
this._frame.updateNetworkOptions((options) => {
80+
options.interaction.navigationButtons = checked;
81+
});
82+
}
83+
toggleNodeBorder(checked) {
84+
this._frame.updateNetworkOptions((options) => {
85+
options.nodes.borderWidth = checked ? 1 : 0;
86+
});
87+
}
88+
toggleShowEdgeLabelAlways(checked) {
89+
if (checked) {
90+
this._frame.updateNetworkOptions((options) => {
91+
options.edges.font['size'] = 11;
92+
});
93+
this._frame.off(types_1.FrameEventName.NETWORK_SELECT_EDGES, this._toggleEdgeLabelHandlers.onselect);
94+
this._frame.off(types_1.FrameEventName.NETWORK_DESELECT_EDGES, this._toggleEdgeLabelHandlers.ondeselect);
95+
}
96+
else {
97+
this._frame.updateNetworkOptions((options) => {
98+
options.edges.font['size'] = 0;
99+
});
100+
this._frame.on(types_1.FrameEventName.NETWORK_SELECT_EDGES, this._toggleEdgeLabelHandlers.onselect);
101+
//hide deselected edges
102+
this._frame.on(types_1.FrameEventName.NETWORK_DESELECT_EDGES, this._toggleEdgeLabelHandlers.ondeselect);
103+
}
104+
}
105+
toggleEdgeColor(checked) {
106+
this._frame.updateNetworkOptions((options) => {
107+
if (checked) {
108+
options.edges.color = {
109+
'inherit': 'to'
110+
};
111+
}
112+
else {
113+
options.edges.color = {
114+
opacity: 0.4,
115+
highlight: '#ff0000',
116+
hover: '#ff0000'
117+
};
118+
}
119+
});
120+
}
121+
_toggleEdgeLabelOnSelect(args) {
122+
var frame = this._frame;
123+
var app = this;
124+
//set font size normal
125+
if (args.edges.length > 0) {
126+
var updates = [];
127+
var edgeIds = args.edges;
128+
edgeIds.forEach(edgeId => {
129+
updates.push({
130+
id: edgeId, font: {
131+
size: 11,
132+
}
133+
});
134+
});
135+
frame.updateEdges(updates);
136+
}
137+
}
138+
updateTheme(theme) {
139+
this._frame.updateTheme(theme);
140+
}
141+
_toggleEdgeLabelOnDeselect(args) {
142+
var frame = this._frame;
143+
var app = this;
144+
//set font size 0
145+
if (args.previousSelection.edges.length > 0) {
146+
var updates = [];
147+
var edgeIds = args.previousSelection.edges;
148+
edgeIds.forEach(edgeId => {
149+
updates.push({
150+
id: edgeId, font: {
151+
size: 0,
152+
}
153+
});
154+
});
155+
frame.updateEdges(updates);
156+
}
157+
}
158+
}
159+
exports.BaseApp = BaseApp;

src/main/javascript/app/explorer.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
const app_1 = require("./app");
4+
const SearchBarCtrl_1 = require("../control/SearchBarCtrl");
5+
const ExpansionCtrl_1 = require("../control/ExpansionCtrl");
6+
const InfoBoxCtrl_1 = require("../control/InfoBoxCtrl");
7+
const types_1 = require("../types");
8+
const ToolbarCtrl_1 = require("../control/ToolbarCtrl");
9+
const ConnectCtrl_1 = require("../control/ConnectCtrl");
10+
class GraphExplorer extends app_1.BaseApp {
11+
constructor(htmlFrame) {
12+
super(htmlFrame, {
13+
showLabels: true,
14+
showFaces: true,
15+
showDegrees: true,
16+
showEdges: true,
17+
showGroups: true
18+
});
19+
}
20+
onCreateFrame(args) {
21+
var frame = args.mainFrame;
22+
frame.addControl("search", new SearchBarCtrl_1.SearchBarCtrl());
23+
frame.addControl("info", new InfoBoxCtrl_1.InfoBoxCtrl());
24+
var expansion = frame.addControl("expansion", new ExpansionCtrl_1.ExpansionCtrl());
25+
var toolbar = frame.addControl("toolbar", new ToolbarCtrl_1.ToolbarCtrl());
26+
var connect = frame.addControl("connect", new ConnectCtrl_1.ConnectCtrl());
27+
toolbar.addButton({
28+
icon: "fa fa-file-code-o",
29+
tooltip: "load GSON string",
30+
click: (checked) => { connect.loadGsonString(); }
31+
});
32+
toolbar.addButton({
33+
icon: "fa fa-folder-open-o",
34+
tooltip: "load GSON url",
35+
click: (checked) => { connect.loadGsonUrl(); }
36+
});
37+
this._frame.on(types_1.FrameEventName.GRAPH_CONNECTED, (args) => {
38+
this._frame.clearScreen();
39+
expansion.clear();
40+
});
41+
}
42+
}
43+
exports.GraphExplorer = GraphExplorer;

0 commit comments

Comments
 (0)