Merge pull request #409 from ilexwg/master

fix: correct the typo
development
David Benson 2020-01-29 11:37:50 +00:00 committed by GitHub
commit df73309a0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 68 deletions

View File

@ -1,6 +1,6 @@
<!-- <!--
Copyright (c) 2006-2013, JGraph Ltd Copyright (c) 2006-2013, JGraph Ltd
Anchors example for mxGraph. This example demonstrates defining Anchors example for mxGraph. This example demonstrates defining
fixed connection points for all shapes. fixed connection points for all shapes.
--> -->
@ -18,7 +18,7 @@
<!-- Example code --> <!-- Example code -->
<script type="text/javascript"> <script type="text/javascript">
// Overridden to define per-shape connection points // Overridden to define per-shape connection points
mxGraph.prototype.getAllConnectionConstraints = function(terminal, source) mxGraph.prototype.getAllConnectionConstraints = function(terminal, source)
{ {
@ -26,20 +26,17 @@
{ {
if (terminal.shape.stencil != null) if (terminal.shape.stencil != null)
{ {
if (terminal.shape.stencil != null) return terminal.shape.stencil.constraints;
{
return terminal.shape.stencil.constraints;
}
} }
else if (terminal.shape.constraints != null) else if (terminal.shape.constraints != null)
{ {
return terminal.shape.constraints; return terminal.shape.constraints;
} }
} }
return null; return null;
}; };
// Defines the default constraints for all shapes // Defines the default constraints for all shapes
mxShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true), mxShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
new mxConnectionConstraint(new mxPoint(0.5, 0), true), new mxConnectionConstraint(new mxPoint(0.5, 0), true),
@ -53,7 +50,7 @@
new mxConnectionConstraint(new mxPoint(0.25, 1), true), new mxConnectionConstraint(new mxPoint(0.25, 1), true),
new mxConnectionConstraint(new mxPoint(0.5, 1), true), new mxConnectionConstraint(new mxPoint(0.5, 1), true),
new mxConnectionConstraint(new mxPoint(0.75, 1), true)]; new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
// Edges have no connection points // Edges have no connection points
mxPolyline.prototype.constraints = null; mxPolyline.prototype.constraints = null;
@ -76,25 +73,25 @@
// Creates the graph inside the given container // Creates the graph inside the given container
var graph = new mxGraph(container); var graph = new mxGraph(container);
graph.setConnectable(true); graph.setConnectable(true);
// Enables connect preview for the default edge style // Enables connect preview for the default edge style
graph.connectionHandler.createEdgeState = function(me) graph.connectionHandler.createEdgeState = function(me)
{ {
var edge = graph.createEdge(null, null, null, null, null); var edge = graph.createEdge(null, null, null, null, null);
return new mxCellState(this.graph.view, edge, this.graph.getCellStyle(edge)); return new mxCellState(this.graph.view, edge, this.graph.getCellStyle(edge));
}; };
// Specifies the default edge style // Specifies the default edge style
graph.getStylesheet().getDefaultEdgeStyle()['edgeStyle'] = 'orthogonalEdgeStyle'; graph.getStylesheet().getDefaultEdgeStyle()['edgeStyle'] = 'orthogonalEdgeStyle';
// Enables rubberband selection // Enables rubberband selection
new mxRubberband(graph); new mxRubberband(graph);
// Gets the default parent for inserting new cells. This // Gets the default parent for inserting new cells. This
// is normally the first child of the root (ie. layer 0). // is normally the first child of the root (ie. layer 0).
var parent = graph.getDefaultParent(); var parent = graph.getDefaultParent();
// Adds cells to the model in a single step // Adds cells to the model in a single step
graph.getModel().beginUpdate(); graph.getModel().beginUpdate();
try try

View File

@ -19,10 +19,7 @@ window.onload = function () {
{ {
if (terminal.shape.stencil != null) if (terminal.shape.stencil != null)
{ {
if (terminal.shape.stencil != null) return terminal.shape.stencil.constraints;
{
return terminal.shape.stencil.constraints;
}
} }
else if (terminal.shape.constraints != null) else if (terminal.shape.constraints != null)
{ {

View File

@ -4,36 +4,36 @@
*/ */
/** /**
* Class: mxGeometry * Class: mxGeometry
* *
* Extends <mxRectangle> to represent the geometry of a cell. * Extends <mxRectangle> to represent the geometry of a cell.
* *
* For vertices, the geometry consists of the x- and y-location, and the width * 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 * and height. For edges, the geometry consists of the optional terminal- and
* control points. The terminal points are only required if an edge is * control points. The terminal points are only required if an edge is
* unconnected, and are stored in the sourcePoint> and <targetPoint> * unconnected, and are stored in the <sourcePoint> and <targetPoint>
* variables, respectively. * variables, respectively.
* *
* Example: * Example:
* *
* If an edge is unconnected, that is, it has no source or target terminal, * 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 * then a geometry with terminal points for a new edge can be defined as
* follows. * follows.
* *
* (code) * (code)
* geometry.setTerminalPoint(new mxPoint(x1, y1), true); * geometry.setTerminalPoint(new mxPoint(x1, y1), true);
* geometry.points = [new mxPoint(x2, y2)]; * geometry.points = [new mxPoint(x2, y2)];
* geometry.setTerminalPoint(new mxPoint(x3, y3), false); * geometry.setTerminalPoint(new mxPoint(x3, y3), false);
* (end) * (end)
* *
* Control points are used regardless of the connected state of an edge and may * 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>. * 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 * To disable automatic reset of control points after a cell has been moved or
* resized, the the <mxGraph.resizeEdgesOnMove> and * resized, the the <mxGraph.resizeEdgesOnMove> and
* <mxGraph.resetEdgesOnResize> may be used. * <mxGraph.resetEdgesOnResize> may be used.
* *
* Edge Labels: * Edge Labels:
* *
* Using the x- and y-coordinates of a cell's geometry, it is possible to * 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 * 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 * as it appears on the screen. The x-coordinate of an edge's geometry is used
@ -42,29 +42,29 @@
* edge's geometry is used to describe the absolute, orthogonal distance in * 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 * pixels from that point. In addition, the <mxGeometry.offset> is used as an
* absolute offset vector from the resulting point. * absolute offset vector from the resulting point.
* *
* This coordinate system is applied if <relative> is true, otherwise the * This coordinate system is applied if <relative> is true, otherwise the
* offset defines the absolute vector from the edge's center point to the * offset defines the absolute vector from the edge's center point to the
* label and the values for <x> and <y> are ignored. * label and the values for <x> and <y> are ignored.
* *
* The width and height parameter for edge geometries can be used to set the * The width and height parameter for edge geometries can be used to set the
* label width and height (eg. for word wrapping). * label width and height (eg. for word wrapping).
* *
* Ports: * Ports:
* *
* The term "port" refers to a relatively positioned, connectable child cell, * The term "port" refers to a relatively positioned, connectable child cell,
* which is used to specify the connection between the parent and another 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 * in the graph. Ports are typically modeled as vertices with relative
* geometries. * geometries.
* *
* Offsets: * Offsets:
* *
* The <offset> field is interpreted in 3 different ways, depending on the cell * 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 * and the geometry. For edges, the offset defines the absolute offset for the
* edge label. For relative geometries, the offset defines the absolute offset * edge label. For relative geometries, the offset defines the absolute offset
* for the origin (top, left corner) of the vertex, otherwise the 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. * defines the absolute offset for the label inside the vertex or group.
* *
* Constructor: mxGeometry * Constructor: mxGeometry
* *
* Constructs a new object to describe the size and location of a vertex or * Constructs a new object to describe the size and location of a vertex or
@ -83,7 +83,7 @@ mxGeometry.prototype.constructor = mxGeometry;
/** /**
* Variable: TRANSLATE_CONTROL_POINTS * Variable: TRANSLATE_CONTROL_POINTS
* *
* Global switch to translate the points in translate. Default is true. * Global switch to translate the points in translate. Default is true.
*/ */
mxGeometry.prototype.TRANSLATE_CONTROL_POINTS = true; mxGeometry.prototype.TRANSLATE_CONTROL_POINTS = true;
@ -143,18 +143,18 @@ mxGeometry.prototype.offset = null;
* the edge label relative to the edge as rendered on the display. For * the edge label relative to the edge as rendered on the display. For
* vertices, this specifies the relative location inside the bounds of the * vertices, this specifies the relative location inside the bounds of the
* parent cell. * parent cell.
* *
* If this is false, then the coordinates are relative to the origin of the * 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 * parent cell or, for edges, the edge label position is relative to the
* center of the edge as rendered on screen. * center of the edge as rendered on screen.
* *
* Default is false. * Default is false.
*/ */
mxGeometry.prototype.relative = false; mxGeometry.prototype.relative = false;
/** /**
* Function: swap * Function: swap
* *
* Swaps the x, y, width and height with the values stored in * Swaps the x, y, width and height with the values stored in
* <alternateBounds> and puts the previous values into <alternateBounds> as * <alternateBounds> and puts the previous values into <alternateBounds> as
* a rectangle. This operation is carried-out in-place, that is, using the * a rectangle. This operation is carried-out in-place, that is, using the
@ -181,12 +181,12 @@ mxGeometry.prototype.swap = function()
/** /**
* Function: getTerminalPoint * Function: getTerminalPoint
* *
* Returns the <mxPoint> representing the source or target point of this * 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. * edge. This is only used if the edge has no source or target vertex.
* *
* Parameters: * Parameters:
* *
* isSource - Boolean that specifies if the source or target point * isSource - Boolean that specifies if the source or target point
* should be returned. * should be returned.
*/ */
@ -197,12 +197,12 @@ mxGeometry.prototype.getTerminalPoint = function(isSource)
/** /**
* Function: setTerminalPoint * Function: setTerminalPoint
* *
* Sets the <sourcePoint> or <targetPoint> to the given <mxPoint> and * Sets the <sourcePoint> or <targetPoint> to the given <mxPoint> and
* returns the new point. * returns the new point.
* *
* Parameters: * Parameters:
* *
* point - Point to be used as the new source or target point. * point - Point to be used as the new source or target point.
* isSource - Boolean that specifies if the source or target point * isSource - Boolean that specifies if the source or target point
* should be set. * should be set.
@ -217,20 +217,20 @@ mxGeometry.prototype.setTerminalPoint = function(point, isSource)
{ {
this.targetPoint = point; this.targetPoint = point;
} }
return point; return point;
}; };
/** /**
* Function: rotate * Function: rotate
* *
* Rotates the geometry by the given angle around the given center. That is, * Rotates the geometry by the given angle around the given center. That is,
* <x> and <y> of the geometry, the <sourcePoint>, <targetPoint> and all * <x> and <y> of the geometry, the <sourcePoint>, <targetPoint> and all
* <points> are translated by the given amount. <x> and <y> are only * <points> are translated by the given amount. <x> and <y> are only
* translated if <relative> is false. * translated if <relative> is false.
* *
* Parameters: * Parameters:
* *
* angle - Number that specifies the rotation angle in degrees. * angle - Number that specifies the rotation angle in degrees.
* cx - <mxPoint> that specifies the center of the rotation. * cx - <mxPoint> that specifies the center of the rotation.
*/ */
@ -239,13 +239,13 @@ mxGeometry.prototype.rotate = function(angle, cx)
var rad = mxUtils.toRadians(angle); var rad = mxUtils.toRadians(angle);
var cos = Math.cos(rad); var cos = Math.cos(rad);
var sin = Math.sin(rad); var sin = Math.sin(rad);
// Rotates the geometry // Rotates the geometry
if (!this.relative) if (!this.relative)
{ {
var ct = new mxPoint(this.getCenterX(), this.getCenterY()); var ct = new mxPoint(this.getCenterX(), this.getCenterY());
var pt = mxUtils.getRotatedPoint(ct, cos, sin, cx); var pt = mxUtils.getRotatedPoint(ct, cos, sin, cx);
this.x = Math.round(pt.x - this.width / 2); this.x = Math.round(pt.x - this.width / 2);
this.y = Math.round(pt.y - this.height / 2); this.y = Math.round(pt.y - this.height / 2);
} }
@ -257,15 +257,15 @@ mxGeometry.prototype.rotate = function(angle, cx)
this.sourcePoint.x = Math.round(pt.x); this.sourcePoint.x = Math.round(pt.x);
this.sourcePoint.y = Math.round(pt.y); this.sourcePoint.y = Math.round(pt.y);
} }
// Translates the target point // Translates the target point
if (this.targetPoint != null) if (this.targetPoint != null)
{ {
var pt = mxUtils.getRotatedPoint(this.targetPoint, cos, sin, cx); var pt = mxUtils.getRotatedPoint(this.targetPoint, cos, sin, cx);
this.targetPoint.x = Math.round(pt.x); this.targetPoint.x = Math.round(pt.x);
this.targetPoint.y = Math.round(pt.y); this.targetPoint.y = Math.round(pt.y);
} }
// Translate the control points // Translate the control points
if (this.points != null) if (this.points != null)
{ {
@ -283,15 +283,15 @@ mxGeometry.prototype.rotate = function(angle, cx)
/** /**
* Function: translate * Function: translate
* *
* Translates the geometry by the specified amount. That is, <x> and <y> of the * Translates the geometry by the specified amount. That is, <x> and <y> of the
* geometry, the <sourcePoint>, <targetPoint> and all <points> are translated * geometry, the <sourcePoint>, <targetPoint> and all <points> are translated
* by the given amount. <x> and <y> are only translated if <relative> is false. * 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 * If <TRANSLATE_CONTROL_POINTS> is false, then <points> are not modified by
* this function. * this function.
* *
* Parameters: * Parameters:
* *
* dx - Number that specifies the x-coordinate of the translation. * dx - Number that specifies the x-coordinate of the translation.
* dy - Number that specifies the y-coordinate of the translation. * dy - Number that specifies the y-coordinate of the translation.
*/ */
@ -299,7 +299,7 @@ mxGeometry.prototype.translate = function(dx, dy)
{ {
dx = parseFloat(dx); dx = parseFloat(dx);
dy = parseFloat(dy); dy = parseFloat(dy);
// Translates the geometry // Translates the geometry
if (!this.relative) if (!this.relative)
{ {
@ -313,12 +313,12 @@ mxGeometry.prototype.translate = function(dx, dy)
this.sourcePoint.x = parseFloat(this.sourcePoint.x) + dx; this.sourcePoint.x = parseFloat(this.sourcePoint.x) + dx;
this.sourcePoint.y = parseFloat(this.sourcePoint.y) + dy; this.sourcePoint.y = parseFloat(this.sourcePoint.y) + dy;
} }
// Translates the target point // Translates the target point
if (this.targetPoint != null) if (this.targetPoint != null)
{ {
this.targetPoint.x = parseFloat(this.targetPoint.x) + dx; this.targetPoint.x = parseFloat(this.targetPoint.x) + dx;
this.targetPoint.y = parseFloat(this.targetPoint.y) + dy; this.targetPoint.y = parseFloat(this.targetPoint.y) + dy;
} }
// Translate the control points // Translate the control points
@ -337,15 +337,15 @@ mxGeometry.prototype.translate = function(dx, dy)
/** /**
* Function: scale * Function: scale
* *
* Scales the geometry by the given amount. That is, <x> and <y> of the * Scales the geometry by the given amount. That is, <x> and <y> of the
* geometry, the <sourcePoint>, <targetPoint> and all <points> are scaled * geometry, the <sourcePoint>, <targetPoint> and all <points> are scaled
* by the given amount. <x>, <y>, <width> and <height> are only scaled if * by the given amount. <x>, <y>, <width> and <height> are only scaled if
* <relative> is false. If <fixedAspect> is true, then the smaller value * <relative> is false. If <fixedAspect> is true, then the smaller value
* is used to scale the width and the height. * is used to scale the width and the height.
* *
* Parameters: * Parameters:
* *
* sx - Number that specifies the horizontal scale factor. * sx - Number that specifies the horizontal scale factor.
* sy - Number that specifies the vertical scale factor. * sy - Number that specifies the vertical scale factor.
* fixedAspect - Optional boolean to keep the aspect ratio fixed. * fixedAspect - Optional boolean to keep the aspect ratio fixed.
@ -361,12 +361,12 @@ mxGeometry.prototype.scale = function(sx, sy, fixedAspect)
this.sourcePoint.x = parseFloat(this.sourcePoint.x) * sx; this.sourcePoint.x = parseFloat(this.sourcePoint.x) * sx;
this.sourcePoint.y = parseFloat(this.sourcePoint.y) * sy; this.sourcePoint.y = parseFloat(this.sourcePoint.y) * sy;
} }
// Translates the target point // Translates the target point
if (this.targetPoint != null) if (this.targetPoint != null)
{ {
this.targetPoint.x = parseFloat(this.targetPoint.x) * sx; this.targetPoint.x = parseFloat(this.targetPoint.x) * sx;
this.targetPoint.y = parseFloat(this.targetPoint.y) * sy; this.targetPoint.y = parseFloat(this.targetPoint.y) * sy;
} }
// Translate the control points // Translate the control points
@ -381,7 +381,7 @@ mxGeometry.prototype.scale = function(sx, sy, fixedAspect)
} }
} }
} }
// Translates the geometry // Translates the geometry
if (!this.relative) if (!this.relative)
{ {
@ -392,7 +392,7 @@ mxGeometry.prototype.scale = function(sx, sy, fixedAspect)
{ {
sy = sx = Math.min(sx, sy); sy = sx = Math.min(sx, sy);
} }
this.width = parseFloat(this.width) * sx; this.width = parseFloat(this.width) * sx;
this.height = parseFloat(this.height) * sy; this.height = parseFloat(this.height) * sy;
} }
@ -400,7 +400,7 @@ mxGeometry.prototype.scale = function(sx, sy, fixedAspect)
/** /**
* Function: equals * Function: equals
* *
* Returns true if the given object equals this geometry. * Returns true if the given object equals this geometry.
*/ */
mxGeometry.prototype.equals = function(obj) mxGeometry.prototype.equals = function(obj)