mxPerimeter

Provides various perimeter functions to be used in a style as the value of mxConstants.STYLE_PERIMETER.  Perimeters for rectangle, circle, rhombus and triangle are available.

Example

<add as="perimeter">mxPerimeter.RectanglePerimeter</add>

Or programmatically

style[mxConstants.STYLE_PERIMETER] = mxPerimeter.RectanglePerimeter;

When adding new perimeter functions, it is recommended to use the mxPerimeter-namespace as follows:

mxPerimeter.CustomPerimeter = function (bounds, vertex, next, orthogonal)
{
  var x = 0; // Calculate x-coordinate
  var y = 0; // Calculate y-coordainte

  return new mxPoint(x, y);
}

The new perimeter should then be registered in the mxStyleRegistry as follows

mxStyleRegistry.putValue('customPerimeter', mxPerimeter.CustomPerimeter);

The custom perimeter above can now be used in a specific vertex as follows

model.setStyle(vertex, 'perimeter=customPerimeter');

Note that the key of the mxStyleRegistry entry for the function should be used in string values, unless mxGraphView.allowEval is true, in which case you can also use mxPerimeter.CustomPerimeter for the value in the cell style above.

Or it can be used for all vertices in the graph as follows

var style = graph.getStylesheet().getDefaultVertexStyle();
style[mxConstants.STYLE_PERIMETER] = mxPerimeter.CustomPerimeter;

Note that the object can be used directly when programmatically setting the value, but the key in the mxStyleRegistry should be used when setting the value via a key, value pair in a cell style.

The parameters are explained in RectanglePerimeter.

Summary
mxPerimeterProvides various perimeter functions to be used in a style as the value of mxConstants.STYLE_PERIMETER.
Functions
RectanglePerimeterDescribes a rectangular perimeter for the given bounds.
EllipsePerimeterDescribes an elliptic perimeter.
RhombusPerimeterDescribes a rhombus (aka diamond) perimeter.
TrianglePerimeterDescribes a triangle perimeter.
HexagonPerimeterDescribes a hexagon perimeter.

Functions

RectanglePerimeter

RectanglePerimeter: function (bounds,
vertex,
next,
orthogonal)

Describes a rectangular perimeter for the given bounds.

Parameters

boundsmxRectangle that represents the absolute bounds of the vertex.
vertexmxCellState that represents the vertex.
nextmxPoint that represents the nearest neighbour point on the given edge.
orthogonalBoolean that specifies if the orthogonal projection onto the perimeter should be returned.  If this is false then the intersection of the perimeter and the line between the next and the center point is returned.

EllipsePerimeter

EllipsePerimeter: function (bounds,
vertex,
next,
orthogonal)

Describes an elliptic perimeter.  See RectanglePerimeter for a description of the parameters.

RhombusPerimeter

RhombusPerimeter: function (bounds,
vertex,
next,
orthogonal)

Describes a rhombus (aka diamond) perimeter.  See RectanglePerimeter for a description of the parameters.

TrianglePerimeter

TrianglePerimeter: function (bounds,
vertex,
next,
orthogonal)

Describes a triangle perimeter.  See RectanglePerimeter for a description of the parameters.

HexagonPerimeter

HexagonPerimeter: function (bounds,
vertex,
next,
orthogonal)

Describes a hexagon perimeter.  See RectanglePerimeter for a description of the parameters.

STYLE_PERIMETER: 'perimeter'
Defines the key for the perimeter style.
RectanglePerimeter: function (bounds,
vertex,
next,
orthogonal)
Describes a rectangular perimeter for the given bounds.
EllipsePerimeter: function (bounds,
vertex,
next,
orthogonal)
Describes an elliptic perimeter.
RhombusPerimeter: function (bounds,
vertex,
next,
orthogonal)
Describes a rhombus (aka diamond) perimeter.
TrianglePerimeter: function (bounds,
vertex,
next,
orthogonal)
Describes a triangle perimeter.
HexagonPerimeter: function (bounds,
vertex,
next,
orthogonal)
Describes a hexagon perimeter.
Singleton class that acts as a global converter from string to object values in a style.
mxGraphView.prototype.allowEval
Specifies if string values in cell styles should be evaluated using mxUtils.eval.
Extends mxPoint to implement a 2-dimensional rectangle with double precision coordinates.
Represents the current state of a cell in a given mxGraphView.
Implements a 2-dimensional vector with double precision coordinates.
Close