Extends mxRectangle to represent the geometry of a cell.
For vertices, the geometry consists of the x- and y-location, and the width and height. For edges, the geometry consists of the optional terminal- and control points. The terminal points are only required if an edge is unconnected, and are stored in the sourcePoint and targetPoint variables, respectively.
If an edge is unconnected, that is, it has no source or target terminal, then a geometry with terminal points for a new edge can be defined as follows.
geometry.setTerminalPoint(new mxPoint(x1, y1), true); geometry.points = [new mxPoint(x2, y2)]; geometry.setTerminalPoint(new mxPoint(x3, y3), false);
Control points are used regardless of the connected state of an edge and may be ignored or interpreted differently depending on the edge’s mxEdgeStyle.
To disable automatic reset of control points after a cell has been moved or resized, the the <mxGraph.resizeEdgesOnMove> and mxGraph.resetEdgesOnResize may be used.
Using the x- and y-coordinates of a cell’s geometry, it is possible to position the label on edges on a specific location on the actual edge shape as it appears on the screen. The x-coordinate of an edge’s geometry is used to describe the distance from the center of the edge from -1 to 1 with 0 being the center of the edge and the default value. The y-coordinate of an edge’s geometry is used to describe the absolute, orthogonal distance in pixels from that point. In addition, the mxGeometry.offset is used as an absolute offset vector from the resulting point.
This coordinate system is applied if relative is true, otherwise the offset defines the absolute vector from the edge’s center point to the label and the values for <x> and <y> are ignored.
The width and height parameter for edge geometries can be used to set the label width and height (eg. for word wrapping).
The term “port” refers to a relatively positioned, connectable child cell, which is used to specify the connection between the parent and another cell in the graph. Ports are typically modeled as vertices with relative geometries.
The offset field is interpreted in 3 different ways, depending on the cell and the geometry. For edges, the offset defines the absolute offset for the edge label. For relative geometries, the offset defines the absolute offset for the origin (top, left corner) of the vertex, otherwise the offset defines the absolute offset for the label inside the vertex or group.
mxGeometry | Extends mxRectangle to represent the geometry of a cell. |
Functions | |
mxGeometry | Constructs a new object to describe the size and location of a vertex or the control points of an edge. |
Variables | |
TRANSLATE_CONTROL_POINTS | Global switch to translate the points in translate. |
alternateBounds | Stores alternate values for x, y, width and height in a rectangle. |
sourcePoint | Defines the source mxPoint of the edge. |
targetPoint | Defines the target mxPoint of the edge. |
points | Array of mxPoints which specifies the control points along the edge. |
offset | For edges, this holds the offset (in pixels) from the position defined by <x> and <y> on the edge. |
relative | Specifies if the coordinates in the geometry are to be interpreted as relative coordinates. |
Functions | |
swap | Swaps the x, y, width and height with the values stored in alternateBounds and puts the previous values into alternateBounds as a rectangle. |
getTerminalPoint | Returns the mxPoint representing the source or target point of this edge. |
setTerminalPoint | Sets the sourcePoint or targetPoint to the given mxPoint and returns the new point. |
rotate | Rotates the geometry by the given angle around the given center. |
translate | Translates the geometry by the specified amount. |
scale | Scales the geometry by the given amount. |
equals | Returns true if the given object equals this geometry. |
mxGeometry.prototype.alternateBounds
Stores alternate values for x, y, width and height in a rectangle. See swap to exchange the values. Default is null.
mxGeometry.prototype.sourcePoint
Defines the source mxPoint of the edge. This is used if the corresponding edge does not have a source vertex. Otherwise it is ignored. Default is null.
mxGeometry.prototype.targetPoint
Defines the target mxPoint of the edge. This is used if the corresponding edge does not have a target vertex. Otherwise it is ignored. Default is null.
mxGeometry.prototype.points
Array of mxPoints which specifies the control points along the edge. These points are the intermediate points on the edge, for the endpoints use targetPoint and sourcePoint or set the terminals of the edge to a non-null value. Default is null.
mxGeometry.prototype.offset
For edges, this holds the offset (in pixels) from the position defined by <x> and <y> on the edge. For relative geometries (for vertices), this defines the absolute offset from the point defined by the relative coordinates. For absolute geometries (for vertices), this defines the offset for the label. Default is null.
mxGeometry.prototype.relative
Specifies if the coordinates in the geometry are to be interpreted as relative coordinates. For edges, this is used to define the location of the edge label relative to the edge as rendered on the display. For vertices, this specifies the relative location inside the bounds of the parent cell.
If this is false, then the coordinates are relative to the origin of the parent cell or, for edges, the edge label position is relative to the center of the edge as rendered on screen.
Default is false.
mxGeometry.prototype.swap = function()
Swaps the x, y, width and height with the values stored in alternateBounds and puts the previous values into alternateBounds as a rectangle. This operation is carried-out in-place, that is, using the existing geometry instance. If this operation is called during a graph model transactional change, then the geometry should be cloned before calling this method and setting the geometry of the cell using mxGraphModel.setGeometry.
mxGeometry.prototype.getTerminalPoint = function( isSource )
Returns the mxPoint representing the source or target point of this edge. This is only used if the edge has no source or target vertex.
isSource | Boolean that specifies if the source or target point should be returned. |
mxGeometry.prototype.setTerminalPoint = function( point, isSource )
Sets the sourcePoint or targetPoint to the given mxPoint and returns the new point.
point | Point to be used as the new source or target point. |
isSource | Boolean that specifies if the source or target point should be set. |
mxGeometry.prototype.rotate = function( angle, cx )
Rotates the geometry by the given angle around the given center. That is, <x> and <y> of the geometry, the sourcePoint, targetPoint and all points are translated by the given amount. <x> and <y> are only translated if relative is false.
angle | Number that specifies the rotation angle in degrees. |
cx | mxPoint that specifies the center of the rotation. |
mxGeometry.prototype.translate = function( dx, dy )
Translates the geometry by the specified amount. That is, <x> and <y> of the geometry, the sourcePoint, targetPoint and all points are translated by the given amount. <x> and <y> are only translated if relative is false. If TRANSLATE_CONTROL_POINTS is false, then points are not modified by this function.
dx | Number that specifies the x-coordinate of the translation. |
dy | Number that specifies the y-coordinate of the translation. |
mxGeometry.prototype.scale = function( sx, sy, fixedAspect )
Scales the geometry by the given amount. That is, <x> and <y> of the geometry, the sourcePoint, targetPoint and all points are scaled by the given amount. <x>, <y>, <width> and <height> are only scaled if relative is false. If <fixedAspect> is true, then the smaller value is used to scale the width and the height.
sx | Number that specifies the horizontal scale factor. |
sy | Number that specifies the vertical scale factor. |
fixedAspect | Optional boolean to keep the aspect ratio fixed. |
Constructs a new object to describe the size and location of a vertex or the control points of an edge.
function mxGeometry( x, y, width, height )
Global switch to translate the points in translate.
mxGeometry.prototype.TRANSLATE_CONTROL_POINTS
Stores alternate values for x, y, width and height in a rectangle.
mxGeometry.prototype.alternateBounds
Defines the source mxPoint of the edge.
mxGeometry.prototype.sourcePoint
Defines the target mxPoint of the edge.
mxGeometry.prototype.targetPoint
Array of mxPoints which specifies the control points along the edge.
mxGeometry.prototype.points
For edges, this holds the offset (in pixels) from the position defined by x and y on the edge.
mxGeometry.prototype.offset
Specifies if the coordinates in the geometry are to be interpreted as relative coordinates.
mxGeometry.prototype.relative
Swaps the x, y, width and height with the values stored in alternateBounds and puts the previous values into alternateBounds as a rectangle.
mxGeometry.prototype.swap = function()
Returns the mxPoint representing the source or target point of this edge.
mxGeometry.prototype.getTerminalPoint = function( isSource )
Sets the sourcePoint or targetPoint to the given mxPoint and returns the new point.
mxGeometry.prototype.setTerminalPoint = function( point, isSource )
Rotates the geometry by the given angle around the given center.
mxGeometry.prototype.rotate = function( angle, cx )
Translates the geometry by the specified amount.
mxGeometry.prototype.translate = function( dx, dy )
Scales the geometry by the given amount.
mxGeometry.prototype.scale = function( sx, sy, fixedAspect )
Returns true if the given object equals this geometry.
mxGeometry.prototype.equals = function( obj )
Specifies if edge control points should be reset after the resize of a connected cell.
mxGraph.prototype.resetEdgesOnResize
Sets the mxGeometry of the given mxCell.
mxGraphModel.prototype.setGeometry = function( cell, geometry )