yFiles AJAX Web Application Interface

This document describes the resources available from the yFiles AJAX web application. In other words it documents the web application interface of the server side of yFiles AJAX.

This document was created from a WADL description using the wadl_documentation.xsl XSL stylesheet by Mark Nottingham ( http://www.mnot.net/ ) used under the terms of the Creative Commons Attribution-ShareAlike 2.5 License.

Requests

/ getImage?zoom&col&row&size&path&paintDetailThreshold

The resource returned for this request is a graph tile. A graph tile is an image of a part of the graph. The image is a quadratic PNG. Its magnification with respect to the world coordinates of the graph is controlled by the zoom factor. For a fixed graph and a fixed zoom factor, all tiles form a grid covering the plane containing the graph. One of those tiles is specified by its column and row.

GET

parameter value description

zoom

double(required)

the zoom factor, strictly greater than 0, 1.0 is the "original" size of the graph

col

integer(required)

the colum of the image, the left edge of the image corresponds to col*size/zoom in world coordinates

row

integer(required)

the row of the image, the upper edge of the image corresponds to row*size/zoom in world coordinates

size

integer(required)

the size of the image (width and height) in pixels

path

string(required)

the name of the graph, which is shown on the image

paintDetailThreshold

double

The threshold for the zoom level at which the rendering should change from detailed to sloppy painting (if the zoom factor is lower than the threshold) or from sloppy to detailed painting (if the zoom factor is higher than the threshold).

/ getSVGImage?zoom&prefix&border&paintDetailThreshold&path

The resource returned for this request is the graph as an SVG image.

GET

parameter value description

zoom

double(required)

the zoom factor, strictly greater than 0, 1.0 is the "original" size of the graph

prefix

string

the prefix that should be put before all generated ID values so that multiple graphs can be displayed on a single page.

border

integer

A border that should be added to all sides of the generated SVG image. Useful when used with NodeRealizers that have drop shadows but don't include them in their size calculations.

paintDetailThreshold

double

The threshold for the zoom level at which the rendering should change from detailed to sloppy painting (if the zoom factor is lower than the threshold) or from sloppy to detailed painting (if the zoom factor is higher than the threshold).

path

string(required)

the name of the graph, which is shown on the image

/ getWorldBounds?path

the world and content bounds as an enclosing rectangle for a given graph in prefixed JSON format

{}&&{"x":100,"y":50,"width":200,"height":100,"contentBounds":{"x":100,"y":50,"width":200,"height":100}}

GET

parameter value description

path

string(required)

the name of the graph

/ getElementBounds?path&x&y&width&height&types

hit test information for a given graph and a given axis-parallel query rectangle in prefixed JSON format

{}&&[ {"t":"e","i":"e-27","p":[{"x":407.0,"y":-297.0},{"x":417.0,"y":-297.0},{"x":437.0,"y":-317.0},{"x":452.0,"y":-317.0}]},
{"t":"nl","i":"nl-6-41","p":0,"x":443.0,"y":-384.0,"w":76.0,"h":19.0},
{"t":"n","i":"n-6","x":452.0,"y":-361.0,"w":57.0,"h":58.0,"u":"http://imdb.com/title/tt0473358/","d":"In the future... one man WILL make a difference"},
{"t":"nl","i":"nl-5-42","p":0,"x":352.0,"y":-350.0,"w":52.0,"h":19.0},
{"t":"n","i":"n-5","x":350.0,"y":-326.0,"w":57.0,"h":58.0,"u":"http://imdb.com/title/tt0379786/","d":"The crew of the Serenity is getting desperate. They have lain lower and lower to protect their doctor."}]
t: type of element, i: id, p: points for an edge or position in owning list for a label, u: URL, d: description

GET

parameter value description

path

string(required)

the name of the graph

x

double(required)

left edge of the query rectangle in world coordinates

y

double(required)

upper edge of the query rectangle in world coordinates

width

double(required)

width of the query rectangle in world coordinates

height

double(required)

height of the query rectangle in world coordinates

types

integer(required)

types of elements to be included into the response as a bitmask (e.g. 3 means nodes and edges)

  • 1: include nodes
  • 2: include edges
  • 4: include node labels
  • 8: include edge labels

/ getViewInfo?path&x&y&width&height&types

hit test information for a given graph and a given axis-parallel query rectangle in prefixed JSON format. This is a synonym for getElementBounds.

GET

parameter value description

path

string(required)

the name of the graph

x

double(required)

left edge of the query rectangle in world coordinates

y

double(required)

upper edge of the query rectangle in world coordinates

width

double(required)

width of the query rectangle in world coordinates

height

double(required)

height of the query rectangle in world coordinates

types

integer(required)

types of elements to be included into the response as a bitmask (e.g. 3 means nodes and edges)

  • 1: include nodes
  • 2: include edges
  • 4: include node labels
  • 8: include edge labels

/ getHierarchyInfo?path

hierarchy information for a given graph in prefixed JSON format

{}&&[ {"i":"n-0","t":1,"s":{"x":531.0,"y":-30.0,"w":20.0,"h":24.0}},
{"i":"n-1","t":1,"p":"n-0","s":{"x":640.0,"y":7.0,"w":20.0,"h":24.0}},
{"i":"n-2","t":2,"p":"n-1","s":{"x":732.0,"y":44.0,"w":20.0,"h":24.0}},
{"i":"n-3","t":0,"p":"n-2"},{"i":"n-4","t":0,"p":"n-2"},{"i":"n-5","t":0,"p":"n-2"},
{"i":"n-6","t":0,"p":"n-2"},{"i":"n-7","t":0,"p":"n-1"},{"i":"n-8","t":0,"p":"n-0"},
{"i":"n-9","t":0,"p":"n-0"},{"i":"n-10","t":0},{"i":"n-11","t":0},{"i":"n-12","t":0}]
i: id, t: type (0: normal node, 1: open group, 2: closed group), s: bounds of state label for group or folder nodes, p: parent node

GET

parameter value description

path

string(required)

the name of the graph

/ loadableGraphs

a list of names of graphs in prefixed JSON format, which are suitable for loadGraph

{}&&[
   "bigtree.graphml",
   "groups.graphml",
   "hierarchy.graphml"
]

GET

/ loadGraph?path&reload

If the value of the parameter "path" is "foo.graphml", and there is not yet a graph cached for the name "foo.graphml" in the session of the request, then the graph is loaded from the file "foo.graphml" from the directory "resources/graphs" in the web application, to which this servlet belongs, and cached using the name "foo.graphml". Reloading a graph which is already cached can be forced by setting the optional parameter "reload" to "true".

POST

parameter value description

path

string(required)

the name of the graph

reload

string

One of:

  • true
  • false

forces reloading, if the graph was loaded before

/ downloadableFormats

a array of file format descriptions available for downloadGraph in prefixed JSON format, each entry is an array containing a description and a file name extension, e.g., ["GraphML Format","graphml"]

POST

/ downloadGraph?path&format&x&y&z&w&h

The "downloadGraph" request has a mandatory parameter "path" and an optional parameter "format". The parameter "path" contains the name of the graph to be downloaded.

The parameter "format" specifies the format for the download. It defaults to "ygf". Possible values can be queried with a "downloadableFormats" request. The values are filename extensions of yFiles for Java graph formats; "ygf", "gml", "graphml", "graphmlz" and "tgf". Moreover some image formats are supported: "gif", "jpg", "png" and "bmp" Depending on the server configuration "png" and "bmp" may not be available and "pdf" and "swf" may additionally be available, if the server can access yExport. The response for this request is a binary stream containing the graph in the requested format. For the graph formats "ygf", "gml", "graphml", "graphmlz" and "tgf" the whole graph is exported. For the image formats "gif", "jpg", "png" and "bmp" there are additional parameters for specifying the size and contents of the target image.

The parameters x, y, z, w and h are required for image formats. They specify the part of the graph to be exported and the magnification of the target image. Note that there is a limit of 2000 on the target width and height in order to protect the server from allocating too much memory for a single request. If a width or height greater than this limit is requested, then width, height and zoom are scaled down to meet the limits before the request is processed.

POST

parameter value description

path

string(required)

the name of the graph

format

string

One of:

  • ygf
  • gml
  • graphml
  • graphmlz
  • tgf
  • gif
  • jpg
  • png

the format for the response (default: ygf), depending on the server additional formats are possible (see "downloadableFormats")

x

double

left edge of the exported image in world coordinates for image formats, this parameter is required for image formats

y

double

upper edge of the exported image in world coordinates for image formats, this parameter is required for image formats

z

double

zoom of the exported image for image formats, this parameter is required for image formats

w

integer

width of the exported image in pixels for image formats, this parameter is required for image formats

h

integer

height of the exported image in pixels for image formats, this parameter is required for image formats

/ newGraph?name

caches a new empty graph for the given name

POST

parameter value description

name

string(required)

the name of the graph

/ getRealizers

returns a prefixed JSON object containing the names of the available node types (node realizers)

{}&&{"nodeRealizers":["blue diamond","blue square","red circle","yellow square"]}

GET

/ getRealizerImage?type

returns a PNG image showing a sample node realized with the given node realizer

GET

parameter value description

type

string(required)

the name of the node realizer (node type), suitable values are returned by getRealizers

/ createNode?name&x&y&type

creates a new node in a cached graph and returns a prefixed JSON object containing the id of the new node and the new world bounds

{}&&{"id":"n-25","bounds":{"minX":304,"minY":-52,"maxX":871,"maxY":383}}

POST

parameter value description

name

string(required)

the name of the graph

x

double(required)

x coordinate of the new node in world coordinates

y

double(required)

y coordinate of the new node in world coordinates

type

string

the type of node, suitable values are returned by getRealizers

/ createGroup?name&x&y&closed&type&subNodeIds&parentNodeId

creates a new group or folder node in a cached graph and returns a prefixed JSON object containing the id of the new node, the changed hit info and the new world bounds

{}&&{"id":"n-27","hinfo":[ {"i":"n-27","t":1,"s":{"x":459.0,"y":297.0,"w":20.0,"h":24.0}},
{"i":"n-12","t":0,"p":"n-27"},{"i":"n-11","t":0,"p":"n-27"},
{"i":"n-0","t":1,"s":{"x":531.0,"y":-30.0,"w":20.0,"h":24.0}},
{"i":"n-1","t":1,"p":"n-0","s":{"x":640.0,"y":7.0,"w":20.0,"h":24.0}},
{"i":"n-2","t":2,"p":"n-1","s":{"x":732.0,"y":44.0,"w":20.0,"h":24.0}},
{"i":"n-3","t":0,"p":"n-2"},{"i":"n-4","t":0,"p":"n-2"},
{"i":"n-5","t":0,"p":"n-2"},{"i":"n-6","t":0,"p":"n-2"},
{"i":"n-7","t":0,"p":"n-1"},{"i":"n-8","t":0,"p":"n-0"},
{"i":"n-9","t":0,"p":"n-0"},{"i":"n-10","t":0},{"i":"n-25","t":0}],
"bounds":{"minX":304,"minY":-52,"maxX":886,"maxY":398}}

POST

parameter value description

name

string(required)

the name of the graph

x

double

x coordinate of the new node in world coordinates (default 0)

y

double

y coordinate of the new node in world coordinates (default 0)

closed

string

One of:

  • true
  • false

a folder node is created, if this parameter is true, a group node otherwise (default)

type

string

the type of node, suitable values are returned by getRealizers

subNodeIds

string

comma separated ids of the nodes to become members of the inner graph of the newly created node

parentNodeId

string

id of the parent group or folder node for the new group node, if not specified and no subnode ids are given use the currently visible subgraph, if not specified and subnode ids are given, their nearest common ancestor becomes the parent of the new group

/ closeGroup?name&id

converts the group node with the given id into a folder node. The same kind of information as for createGroup is returned.

POST

parameter value description

name

string(required)

the name of the graph

id

string(required)

the id of a group node

/ openGroup?name&id

converts the folder node with the given id into a group node. The same kind of information as for createGroup is returned.

POST

parameter value description

name

string(required)

the name of the graph

id

string(required)

the id of a folder node

/ createEdge?name&source&target&route

creates a new edge in a cached graph and returns a prefixed JSON object containing the id of the new edge and the new world bounds

{}&&{"id":"e-30","bounds":{"minX":304,"minY":-52,"maxX":871,"maxY":428}}

POST

parameter value description

name

string(required)

the name of the graph

source

string(required)

the id of the source node

target

string(required)

the id of the target node

route

integer

route the created edge, if this parameter exists and is not equal to 0

/ moveNodes?name&ids&x&y&route

moves the positions of a set of nodes according to a shift vector. The new graph bounds are returned.

{}&&{"bounds":{"minX":203,"minY":-41,"maxX":871,"maxY":428}}

POST

parameter value description

name

string(required)

the name of the graph

ids

string(required)

comma-separated ids of the nodes to be moved

x

double(required)

x coordinate of the shift vector in world coordinates

y

double(required)

y coordinate of the shift vector in world coordinates

route

integer

route the affected edges, if this parameter exists and is not equal to 0

/ resizeNodes?name&ids&m&dw&dh&route

resizes a set of nodes according to a mode and deltas for width and height. The new graph bounds are returned.

{}&&{"bounds":{"minX":203,"minY":-41,"maxX":871,"maxY":428}}

POST

parameter value description

name

string(required)

the name of the graph

ids

string(required)

comma-separated ids of the nodes to be resized

m

string(required)

One of:

  • NW
  • N
  • NE
  • W
  • E
  • SW
  • S
  • SE

the mode, i.e. the corner or side which changes

dw

double(required)

the delta for the node widths in world coordinates

dh

double(required)

the delta for the node heights in world coordinates

route

integer

route the affected edges, if this parameter exists and is not equal to 0

/ removeAt?name&x&y

removes the first node or edge at the given coordinates and returns a prefixed JSON object containing the id of the removed node or edge if any and the new world bounds

POST

parameter value description

name

string(required)

the name of the graph

x

double(required)

x coordinate in world coordinates

y

double(required)

y coordinate in world coordinates

/ remove?name&ids

removes the graph elements with the given ids and returns a prefixed JSON object containing the id of the removed node or edge if any and the new world bounds. Note that dependent objects are also removed. For example removing a node leads to removing all its adjacent edges and all labels of the removed node and the adjacent edges.

POST

parameter value description

name

string(required)

the name of the graph

ids

string(required)

comma-separated ids of graph elements to be removed

/ getLabel?name&id

returns the text of the given node label or the text of the first label of the given node as a plain text in UTF-8 encoding.

POST

parameter value description

name

string(required)

the name of the graph

id

string(required)

the id of a node or node label

/ setLabel?name&id&label

sets the text of the given node label or the text of the first label of the given node and returns the id of the label.

POST

parameter value description

name

string(required)

the name of the graph

id

string(required)

the id of a node or node label

label

string(required)

the label text

/ layout?name&type

performs a layout algorithm on the given graph and returns a prefixed JSON object containing the new world bounds.

POST

parameter value description

name

string(required)

the name of the graph

type

string(required)

One of:

  • hierarchic
  • organic
  • orthogonal

the type of layout to be performed

/ switchToSubgraph?name&id

switches the currently displayed graph to the inner graph of a group or folder node. The same kind of information as for createGroup is returned.

POST

parameter value description

name

string(required)

the name of the graph

id

string(required)

the id of a group or folder node

/ switchToParent?name

switches the currently displayed graph to its parent graph. The same kind of information as for createGroup is returned.

POST

parameter value description

name

string(required)

the name of the graph

/ moveToSubgraph?name&subNodeIds&parentNodeId&x&y&route

moves a set of nodes to another nested graph. Optionally the nodes can also be moved to another location as in the moveNodes request. If this is desired the x and y parameters have to be given. The same kind of information as for createGroup is returned.

POST

parameter value description

name

string(required)

the name of the graph

subNodeIds

string(required)

comma separated ids of the nodes to be moved

parentNodeId

string

the id of a group or folder node, which is the parent of the target graph (default root graph)

x

double

x coordinate of the shift vector in world coordinates

y

double

y coordinate of the shift vector in world coordinates

route

integer

route the affected edges, if this parameter exists and is not equal to 0

/ moveToParent?name&subNodeIds

moves each node in a set of nodes one level up.

POST

parameter value description

name

string(required)

the name of the graph

subNodeIds

string(required)

comma separated ids of the nodes to be moved

/ isUndoRedoEnabled?name

queries whether support for undo and redo operations for a particular graph is enabled. The state is returned as text.

GET

parameter value description

name

string(required)

the name of the graph

/ setUndoRedoEnabled?name&f

enables or disables support for undo and redo operations for a particular graph. The new state is returned as text.

POST

parameter value description

name

string(required)

the name of the graph

f

string(required)

One of:

  • true
  • false

whether to enable or disable undo and redo

/ canUndoRedo?name

queries whether an undo and a redo operation for a particular graph is currently possible. The information is returned as a prefixed JSON object like the following.

{}&&{ "canUndo" : true, "canRedo" : false }

GET

parameter value description

name

string(required)

the name of the graph

/ undo?name

performs an undo operation for a particular graph. Whether a further undo or redo operation is possible is returned as a prefixed JSON object like the following.

{}&&{ "canUndo" : true, "canRedo" : false }

POST

parameter value description

name

string(required)

the name of the graph

/ redo?name

performs a redo operation for a particular graph. Whether a further undo or redo operation is possible is returned as a prefixed JSON object like the following.

{}&&{ "canUndo" : true, "canRedo" : false }

POST

parameter value description

name

string(required)

the name of the graph

/ yFilesAction?id&graphName&hasHitTest&hitTypes&hasHierarchy&hasSelection&selection&hasCanvas&width&height&zoom&viewpoint&mouse&customParameter

invokes a server side action. All parameters are optional except for the id which identifies the action to be performed. Some parameters are only useful, if another parameter is present, e.g. the "hitTypes" parameter is only needed if hasHitTest is present and has the value "true".



The response is an object represented in prefixed JSON format. All members of the response object are optional.

customResponse: a string

zoom: a double

viewPoint: a JSON string as created by JSONSupport.pointString()

refreshCanvas: a boolean

worldBounds: a JSON string as created by JSONSupport.rectangleString()

hitTestData: a JSON string in the format as described in the getElementBounds request

hierarchyData: a JSON string in the format as described in the getHierarchyInfo request

selection: a string containing comma-separated node and edge ids

POST

parameter value description

id

string(required)

the id of the action

graphName

string

the symbolic name of the graph for the action

hasHitTest

string

whether a hit test is available at the client side

hitTypes

integer

the event mask for the client side hit test, if it is available

hasHierarchy

string

whether a hierarchy manager is available at the client side

hasSelection

string

whether a selection is available at the client side

selection

string

ids of selected nodes and edges at the client side

hasCanvas

string

whether a canvas is available at the client side

width

integer

the width of the client side canvas in view units

height

integer

the height of the client side canvas in view units

zoom

double

the zoom factor of the client side canvas

viewpoint

string

the world coordinates of the upper left corner of the visible region in the client side canvas

mouse

string

the view coordinates of the mouse position

customParameter

string

a custom parameter for the server side action


Copyright (c) 2006-2012 yWorks. All Rights Reserved.