Browser usage

To use MWG in your browser, you simply have to add the needed .js files to your DOM, for example:

<script src="js/mwg.js"></script>

In addition, plugins can be loaded later, for example:

<script src="js/mwg.structure.js"></script>
<script src="js/"></script>
<script src="js/"></script>

Usage with manual download

JS files can be downloaded via the maven central repository, e.g.,

The name 'core' and the version number '7' must be replaced by the desired plugin name and version number. In every MWG zip bundle one can find the following files:

  • XYZ.js: standard file usable for debug and development environments
  • XYZ.min.js: compressed file for production usage
  • XYZ.ts: TypeScript source for MWG extension
  • XYZ.d.ts TypeScript header file for simple inclusion in TypeScript development environment.

For lightweight development, we advise you to use .min.js files.

Then, the JS API is practically identical to the Java API and can be used like in the following code snipped:

var mwg = new org.mwg.GraphBuilder()
    .withStorage(new org.mwg.plugin.WSClient("ws://localhost:8081"))

The line .withStorage(new org.mwg.plugin.WSClient("ws://localhost:8081")) is optional but allows to use a remote graph (client/server mode). Please read the distributed graph section to get more details on this topic.

Usage with Bower

Bower is a very handy tool to manage dependencies for font-end development.

For instance, it allows to describe (in bower.json) dependencies for MWG related development, for example:

  "name": "mwg-sample",
  "version": "0.0.1",
  "dependencies": {
    "mwg-core": "",
    "mwg-ws": "",
    "mwg-structure": "",
    "mwg-ml": ""

Then a simple command: bower install will download and extract the necessary dependencies in a directory bower_components.

Then, these dependencies can be used like in the following code snipped:

    <title>MWG Sample</title>
    <script type="text/javascript" src="bower_components/mwg-core/mwg.min.js"></script>
    <script type="text/javascript" src="bower_components/mwg-ws/"></script>
    <script type="text/javascript" src="bower_components/mwg-structure/mwg.structure.min.js"></script>
    <script type="text/javascript" src="bower_components/mwg-ml/"></script>
var mwg = new org.mwg.GraphBuilder()
    //.withStorage(new org.mwg.plugin.WSClient("ws://localhost:8081"))
  console.log("Ready to work...");

A sample project can be downloaded here.

results matching ""

    No results matching ""