123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921 |
- /**
- * Copyright (c) 2006-2015, JGraph Ltd
- * Copyright (c) 2006-2015, Gaudenz Alder
- */
- var mxPerimeter =
- {
- /**
- * Class: 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:
- *
- * (code)
- * <add as="perimeter">mxPerimeter.RectanglePerimeter</add>
- * (end)
- *
- * Or programmatically:
- *
- * (code)
- * style[mxConstants.STYLE_PERIMETER] = mxPerimeter.RectanglePerimeter;
- * (end)
- *
- * When adding new perimeter functions, it is recommended to use the
- * mxPerimeter-namespace as follows:
- *
- * (code)
- * mxPerimeter.CustomPerimeter = function (bounds, vertex, next, orthogonal)
- * {
- * var x = 0; // Calculate x-coordinate
- * var y = 0; // Calculate y-coordainte
- *
- * return new mxPoint(x, y);
- * }
- * (end)
- *
- * The new perimeter should then be registered in the <mxStyleRegistry> as follows:
- * (code)
- * mxStyleRegistry.putValue('customPerimeter', mxPerimeter.CustomPerimeter);
- * (end)
- *
- * The custom perimeter above can now be used in a specific vertex as follows:
- *
- * (code)
- * model.setStyle(vertex, 'perimeter=customPerimeter');
- * (end)
- *
- * 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:
- *
- * (code)
- * var style = graph.getStylesheet().getDefaultVertexStyle();
- * style[mxConstants.STYLE_PERIMETER] = mxPerimeter.CustomPerimeter;
- * (end)
- *
- * 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>.
- *
- * Function: RectanglePerimeter
- *
- * Describes a rectangular perimeter for the given bounds.
- *
- * Parameters:
- *
- * bounds - <mxRectangle> that represents the absolute bounds of the
- * vertex.
- * vertex - <mxCellState> that represents the vertex.
- * next - <mxPoint> that represents the nearest neighbour point on the
- * given edge.
- * orthogonal - Boolean 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.
- */
- RectanglePerimeter: function (bounds, vertex, next, orthogonal)
- {
- var cx = bounds.getCenterX();
- var cy = bounds.getCenterY();
- var dx = next.x - cx;
- var dy = next.y - cy;
- var alpha = Math.atan2(dy, dx);
- var p = new mxPoint(0, 0);
- var pi = Math.PI;
- var pi2 = Math.PI/2;
- var beta = pi2 - alpha;
- var t = Math.atan2(bounds.height, bounds.width);
-
- if (alpha < -pi + t || alpha > pi - t)
- {
- // Left edge
- p.x = bounds.x;
- p.y = cy - bounds.width * Math.tan(alpha) / 2;
- }
- else if (alpha < -t)
- {
- // Top Edge
- p.y = bounds.y;
- p.x = cx - bounds.height * Math.tan(beta) / 2;
- }
- else if (alpha < t)
- {
- // Right Edge
- p.x = bounds.x + bounds.width;
- p.y = cy + bounds.width * Math.tan(alpha) / 2;
- }
- else
- {
- // Bottom Edge
- p.y = bounds.y + bounds.height;
- p.x = cx + bounds.height * Math.tan(beta) / 2;
- }
-
- if (orthogonal)
- {
- if (next.x >= bounds.x &&
- next.x <= bounds.x + bounds.width)
- {
- p.x = next.x;
- }
- else if (next.y >= bounds.y &&
- next.y <= bounds.y + bounds.height)
- {
- p.y = next.y;
- }
- if (next.x < bounds.x)
- {
- p.x = bounds.x;
- }
- else if (next.x > bounds.x + bounds.width)
- {
- p.x = bounds.x + bounds.width;
- }
- if (next.y < bounds.y)
- {
- p.y = bounds.y;
- }
- else if (next.y > bounds.y + bounds.height)
- {
- p.y = bounds.y + bounds.height;
- }
- }
-
- return p;
- },
- /**
- * Function: EllipsePerimeter
- *
- * Describes an elliptic perimeter. See <RectanglePerimeter>
- * for a description of the parameters.
- */
- EllipsePerimeter: function (bounds, vertex, next, orthogonal)
- {
- var x = bounds.x;
- var y = bounds.y;
- var a = bounds.width / 2;
- var b = bounds.height / 2;
- var cx = x + a;
- var cy = y + b;
- var px = next.x;
- var py = next.y;
-
- // Calculates straight line equation through
- // point and ellipse center y = d * x + h
- var dx = parseInt(px - cx);
- var dy = parseInt(py - cy);
-
- if (dx == 0 && dy != 0)
- {
- return new mxPoint(cx, cy + b * dy / Math.abs(dy));
- }
- else if (dx == 0 && dy == 0)
- {
- return new mxPoint(px, py);
- }
- if (orthogonal)
- {
- if (py >= y && py <= y + bounds.height)
- {
- var ty = py - cy;
- var tx = Math.sqrt(a*a*(1-(ty*ty)/(b*b))) || 0;
-
- if (px <= x)
- {
- tx = -tx;
- }
-
- return new mxPoint(cx+tx, py);
- }
-
- if (px >= x && px <= x + bounds.width)
- {
- var tx = px - cx;
- var ty = Math.sqrt(b*b*(1-(tx*tx)/(a*a))) || 0;
-
- if (py <= y)
- {
- ty = -ty;
- }
-
- return new mxPoint(px, cy+ty);
- }
- }
-
- // Calculates intersection
- var d = dy / dx;
- var h = cy - d * cx;
- var e = a * a * d * d + b * b;
- var f = -2 * cx * e;
- var g = a * a * d * d * cx * cx +
- b * b * cx * cx -
- a * a * b * b;
- var det = Math.sqrt(f * f - 4 * e * g);
-
- // Two solutions (perimeter points)
- var xout1 = (-f + det) / (2 * e);
- var xout2 = (-f - det) / (2 * e);
- var yout1 = d * xout1 + h;
- var yout2 = d * xout2 + h;
- var dist1 = Math.sqrt(Math.pow((xout1 - px), 2)
- + Math.pow((yout1 - py), 2));
- var dist2 = Math.sqrt(Math.pow((xout2 - px), 2)
- + Math.pow((yout2 - py), 2));
-
- // Correct solution
- var xout = 0;
- var yout = 0;
-
- if (dist1 < dist2)
- {
- xout = xout1;
- yout = yout1;
- }
- else
- {
- xout = xout2;
- yout = yout2;
- }
-
- return new mxPoint(xout, yout);
- },
- /**
- * Function: RhombusPerimeter
- *
- * Describes a rhombus (aka diamond) perimeter. See <RectanglePerimeter>
- * for a description of the parameters.
- */
- RhombusPerimeter: function (bounds, vertex, next, orthogonal)
- {
- var x = bounds.x;
- var y = bounds.y;
- var w = bounds.width;
- var h = bounds.height;
-
- var cx = x + w / 2;
- var cy = y + h / 2;
- var px = next.x;
- var py = next.y;
- // Special case for intersecting the diamond's corners
- if (cx == px)
- {
- if (cy > py)
- {
- return new mxPoint(cx, y); // top
- }
- else
- {
- return new mxPoint(cx, y + h); // bottom
- }
- }
- else if (cy == py)
- {
- if (cx > px)
- {
- return new mxPoint(x, cy); // left
- }
- else
- {
- return new mxPoint(x + w, cy); // right
- }
- }
-
- var tx = cx;
- var ty = cy;
-
- if (orthogonal)
- {
- if (px >= x && px <= x + w)
- {
- tx = px;
- }
- else if (py >= y && py <= y + h)
- {
- ty = py;
- }
- }
-
- // In which quadrant will the intersection be?
- // set the slope and offset of the border line accordingly
- if (px < cx)
- {
- if (py < cy)
- {
- return mxUtils.intersection(px, py, tx, ty, cx, y, x, cy);
- }
- else
- {
- return mxUtils.intersection(px, py, tx, ty, cx, y + h, x, cy);
- }
- }
- else if (py < cy)
- {
- return mxUtils.intersection(px, py, tx, ty, cx, y, x + w, cy);
- }
- else
- {
- return mxUtils.intersection(px, py, tx, ty, cx, y + h, x + w, cy);
- }
- },
-
- /**
- * Function: TrianglePerimeter
- *
- * Describes a triangle perimeter. See <RectanglePerimeter>
- * for a description of the parameters.
- */
- TrianglePerimeter: function (bounds, vertex, next, orthogonal)
- {
- var direction = (vertex != null) ?
- vertex.style[mxConstants.STYLE_DIRECTION] : null;
- var vertical = direction == mxConstants.DIRECTION_NORTH ||
- direction == mxConstants.DIRECTION_SOUTH;
- var x = bounds.x;
- var y = bounds.y;
- var w = bounds.width;
- var h = bounds.height;
-
- var cx = x + w / 2;
- var cy = y + h / 2;
-
- var start = new mxPoint(x, y);
- var corner = new mxPoint(x + w, cy);
- var end = new mxPoint(x, y + h);
-
- if (direction == mxConstants.DIRECTION_NORTH)
- {
- start = end;
- corner = new mxPoint(cx, y);
- end = new mxPoint(x + w, y + h);
- }
- else if (direction == mxConstants.DIRECTION_SOUTH)
- {
- corner = new mxPoint(cx, y + h);
- end = new mxPoint(x + w, y);
- }
- else if (direction == mxConstants.DIRECTION_WEST)
- {
- start = new mxPoint(x + w, y);
- corner = new mxPoint(x, cy);
- end = new mxPoint(x + w, y + h);
- }
- var dx = next.x - cx;
- var dy = next.y - cy;
- var alpha = (vertical) ? Math.atan2(dx, dy) : Math.atan2(dy, dx);
- var t = (vertical) ? Math.atan2(w, h) : Math.atan2(h, w);
-
- var base = false;
-
- if (direction == mxConstants.DIRECTION_NORTH ||
- direction == mxConstants.DIRECTION_WEST)
- {
- base = alpha > -t && alpha < t;
- }
- else
- {
- base = alpha < -Math.PI + t || alpha > Math.PI - t;
- }
- var result = null;
- if (base)
- {
- if (orthogonal && ((vertical && next.x >= start.x && next.x <= end.x) ||
- (!vertical && next.y >= start.y && next.y <= end.y)))
- {
- if (vertical)
- {
- result = new mxPoint(next.x, start.y);
- }
- else
- {
- result = new mxPoint(start.x, next.y);
- }
- }
- else
- {
- if (direction == mxConstants.DIRECTION_NORTH)
- {
- result = new mxPoint(x + w / 2 + h * Math.tan(alpha) / 2,
- y + h);
- }
- else if (direction == mxConstants.DIRECTION_SOUTH)
- {
- result = new mxPoint(x + w / 2 - h * Math.tan(alpha) / 2,
- y);
- }
- else if (direction == mxConstants.DIRECTION_WEST)
- {
- result = new mxPoint(x + w, y + h / 2 +
- w * Math.tan(alpha) / 2);
- }
- else
- {
- result = new mxPoint(x, y + h / 2 -
- w * Math.tan(alpha) / 2);
- }
- }
- }
- else
- {
- if (orthogonal)
- {
- var pt = new mxPoint(cx, cy);
-
- if (next.y >= y && next.y <= y + h)
- {
- pt.x = (vertical) ? cx : (
- (direction == mxConstants.DIRECTION_WEST) ?
- x + w : x);
- pt.y = next.y;
- }
- else if (next.x >= x && next.x <= x + w)
- {
- pt.x = next.x;
- pt.y = (!vertical) ? cy : (
- (direction == mxConstants.DIRECTION_NORTH) ?
- y + h : y);
- }
-
- // Compute angle
- dx = next.x - pt.x;
- dy = next.y - pt.y;
-
- cx = pt.x;
- cy = pt.y;
- }
- if ((vertical && next.x <= x + w / 2) ||
- (!vertical && next.y <= y + h / 2))
- {
- result = mxUtils.intersection(next.x, next.y, cx, cy,
- start.x, start.y, corner.x, corner.y);
- }
- else
- {
- result = mxUtils.intersection(next.x, next.y, cx, cy,
- corner.x, corner.y, end.x, end.y);
- }
- }
-
- if (result == null)
- {
- result = new mxPoint(cx, cy);
- }
-
- return result;
- },
-
- /**
- * Function: HexagonPerimeter
- *
- * Describes a hexagon perimeter. See <RectanglePerimeter>
- * for a description of the parameters.
- */
- HexagonPerimeter: function (bounds, vertex, next, orthogonal)
- {
- var x = bounds.x;
- var y = bounds.y;
- var w = bounds.width;
- var h = bounds.height;
- var cx = bounds.getCenterX();
- var cy = bounds.getCenterY();
- var px = next.x;
- var py = next.y;
- var dx = px - cx;
- var dy = py - cy;
- var alpha = -Math.atan2(dy, dx);
- var pi = Math.PI;
- var pi2 = Math.PI / 2;
- var result = new mxPoint(cx, cy);
- var direction = (vertex != null) ? mxUtils.getValue(
- vertex.style, mxConstants.STYLE_DIRECTION,
- mxConstants.DIRECTION_EAST) : mxConstants.DIRECTION_EAST;
- var vertical = direction == mxConstants.DIRECTION_NORTH
- || direction == mxConstants.DIRECTION_SOUTH;
- var a = new mxPoint();
- var b = new mxPoint();
- //Only consider corrects quadrants for the orthogonal case.
- if ((px < x) && (py < y) || (px < x) && (py > y + h)
- || (px > x + w) && (py < y) || (px > x + w) && (py > y + h))
- {
- orthogonal = false;
- }
- if (orthogonal)
- {
- if (vertical)
- {
- //Special cases where intersects with hexagon corners
- if (px == cx)
- {
- if (py <= y)
- {
- return new mxPoint(cx, y);
- }
- else if (py >= y + h)
- {
- return new mxPoint(cx, y + h);
- }
- }
- else if (px < x)
- {
- if (py == y + h / 4)
- {
- return new mxPoint(x, y + h / 4);
- }
- else if (py == y + 3 * h / 4)
- {
- return new mxPoint(x, y + 3 * h / 4);
- }
- }
- else if (px > x + w)
- {
- if (py == y + h / 4)
- {
- return new mxPoint(x + w, y + h / 4);
- }
- else if (py == y + 3 * h / 4)
- {
- return new mxPoint(x + w, y + 3 * h / 4);
- }
- }
- else if (px == x)
- {
- if (py < cy)
- {
- return new mxPoint(x, y + h / 4);
- }
- else if (py > cy)
- {
- return new mxPoint(x, y + 3 * h / 4);
- }
- }
- else if (px == x + w)
- {
- if (py < cy)
- {
- return new mxPoint(x + w, y + h / 4);
- }
- else if (py > cy)
- {
- return new mxPoint(x + w, y + 3 * h / 4);
- }
- }
- if (py == y)
- {
- return new mxPoint(cx, y);
- }
- else if (py == y + h)
- {
- return new mxPoint(cx, y + h);
- }
- if (px < cx)
- {
- if ((py > y + h / 4) && (py < y + 3 * h / 4))
- {
- a = new mxPoint(x, y);
- b = new mxPoint(x, y + h);
- }
- else if (py < y + h / 4)
- {
- a = new mxPoint(x - Math.floor(0.5 * w), y
- + Math.floor(0.5 * h));
- b = new mxPoint(x + w, y - Math.floor(0.25 * h));
- }
- else if (py > y + 3 * h / 4)
- {
- a = new mxPoint(x - Math.floor(0.5 * w), y
- + Math.floor(0.5 * h));
- b = new mxPoint(x + w, y + Math.floor(1.25 * h));
- }
- }
- else if (px > cx)
- {
- if ((py > y + h / 4) && (py < y + 3 * h / 4))
- {
- a = new mxPoint(x + w, y);
- b = new mxPoint(x + w, y + h);
- }
- else if (py < y + h / 4)
- {
- a = new mxPoint(x, y - Math.floor(0.25 * h));
- b = new mxPoint(x + Math.floor(1.5 * w), y
- + Math.floor(0.5 * h));
- }
- else if (py > y + 3 * h / 4)
- {
- a = new mxPoint(x + Math.floor(1.5 * w), y
- + Math.floor(0.5 * h));
- b = new mxPoint(x, y + Math.floor(1.25 * h));
- }
- }
- }
- else
- {
- //Special cases where intersects with hexagon corners
- if (py == cy)
- {
- if (px <= x)
- {
- return new mxPoint(x, y + h / 2);
- }
- else if (px >= x + w)
- {
- return new mxPoint(x + w, y + h / 2);
- }
- }
- else if (py < y)
- {
- if (px == x + w / 4)
- {
- return new mxPoint(x + w / 4, y);
- }
- else if (px == x + 3 * w / 4)
- {
- return new mxPoint(x + 3 * w / 4, y);
- }
- }
- else if (py > y + h)
- {
- if (px == x + w / 4)
- {
- return new mxPoint(x + w / 4, y + h);
- }
- else if (px == x + 3 * w / 4)
- {
- return new mxPoint(x + 3 * w / 4, y + h);
- }
- }
- else if (py == y)
- {
- if (px < cx)
- {
- return new mxPoint(x + w / 4, y);
- }
- else if (px > cx)
- {
- return new mxPoint(x + 3 * w / 4, y);
- }
- }
- else if (py == y + h)
- {
- if (px < cx)
- {
- return new mxPoint(x + w / 4, y + h);
- }
- else if (py > cy)
- {
- return new mxPoint(x + 3 * w / 4, y + h);
- }
- }
- if (px == x)
- {
- return new mxPoint(x, cy);
- }
- else if (px == x + w)
- {
- return new mxPoint(x + w, cy);
- }
- if (py < cy)
- {
- if ((px > x + w / 4) && (px < x + 3 * w / 4))
- {
- a = new mxPoint(x, y);
- b = new mxPoint(x + w, y);
- }
- else if (px < x + w / 4)
- {
- a = new mxPoint(x - Math.floor(0.25 * w), y + h);
- b = new mxPoint(x + Math.floor(0.5 * w), y
- - Math.floor(0.5 * h));
- }
- else if (px > x + 3 * w / 4)
- {
- a = new mxPoint(x + Math.floor(0.5 * w), y
- - Math.floor(0.5 * h));
- b = new mxPoint(x + Math.floor(1.25 * w), y + h);
- }
- }
- else if (py > cy)
- {
- if ((px > x + w / 4) && (px < x + 3 * w / 4))
- {
- a = new mxPoint(x, y + h);
- b = new mxPoint(x + w, y + h);
- }
- else if (px < x + w / 4)
- {
- a = new mxPoint(x - Math.floor(0.25 * w), y);
- b = new mxPoint(x + Math.floor(0.5 * w), y
- + Math.floor(1.5 * h));
- }
- else if (px > x + 3 * w / 4)
- {
- a = new mxPoint(x + Math.floor(0.5 * w), y
- + Math.floor(1.5 * h));
- b = new mxPoint(x + Math.floor(1.25 * w), y);
- }
- }
- }
- var tx = cx;
- var ty = cy;
- if (px >= x && px <= x + w)
- {
- tx = px;
-
- if (py < cy)
- {
- ty = y + h;
- }
- else
- {
- ty = y;
- }
- }
- else if (py >= y && py <= y + h)
- {
- ty = py;
-
- if (px < cx)
- {
- tx = x + w;
- }
- else
- {
- tx = x;
- }
- }
- result = mxUtils.intersection(tx, ty, next.x, next.y, a.x, a.y, b.x, b.y);
- }
- else
- {
- if (vertical)
- {
- var beta = Math.atan2(h / 4, w / 2);
- //Special cases where intersects with hexagon corners
- if (alpha == beta)
- {
- return new mxPoint(x + w, y + Math.floor(0.25 * h));
- }
- else if (alpha == pi2)
- {
- return new mxPoint(x + Math.floor(0.5 * w), y);
- }
- else if (alpha == (pi - beta))
- {
- return new mxPoint(x, y + Math.floor(0.25 * h));
- }
- else if (alpha == -beta)
- {
- return new mxPoint(x + w, y + Math.floor(0.75 * h));
- }
- else if (alpha == (-pi2))
- {
- return new mxPoint(x + Math.floor(0.5 * w), y + h);
- }
- else if (alpha == (-pi + beta))
- {
- return new mxPoint(x, y + Math.floor(0.75 * h));
- }
- if ((alpha < beta) && (alpha > -beta))
- {
- a = new mxPoint(x + w, y);
- b = new mxPoint(x + w, y + h);
- }
- else if ((alpha > beta) && (alpha < pi2))
- {
- a = new mxPoint(x, y - Math.floor(0.25 * h));
- b = new mxPoint(x + Math.floor(1.5 * w), y
- + Math.floor(0.5 * h));
- }
- else if ((alpha > pi2) && (alpha < (pi - beta)))
- {
- a = new mxPoint(x - Math.floor(0.5 * w), y
- + Math.floor(0.5 * h));
- b = new mxPoint(x + w, y - Math.floor(0.25 * h));
- }
- else if (((alpha > (pi - beta)) && (alpha <= pi))
- || ((alpha < (-pi + beta)) && (alpha >= -pi)))
- {
- a = new mxPoint(x, y);
- b = new mxPoint(x, y + h);
- }
- else if ((alpha < -beta) && (alpha > -pi2))
- {
- a = new mxPoint(x + Math.floor(1.5 * w), y
- + Math.floor(0.5 * h));
- b = new mxPoint(x, y + Math.floor(1.25 * h));
- }
- else if ((alpha < -pi2) && (alpha > (-pi + beta)))
- {
- a = new mxPoint(x - Math.floor(0.5 * w), y
- + Math.floor(0.5 * h));
- b = new mxPoint(x + w, y + Math.floor(1.25 * h));
- }
- }
- else
- {
- var beta = Math.atan2(h / 2, w / 4);
- //Special cases where intersects with hexagon corners
- if (alpha == beta)
- {
- return new mxPoint(x + Math.floor(0.75 * w), y);
- }
- else if (alpha == (pi - beta))
- {
- return new mxPoint(x + Math.floor(0.25 * w), y);
- }
- else if ((alpha == pi) || (alpha == -pi))
- {
- return new mxPoint(x, y + Math.floor(0.5 * h));
- }
- else if (alpha == 0)
- {
- return new mxPoint(x + w, y + Math.floor(0.5 * h));
- }
- else if (alpha == -beta)
- {
- return new mxPoint(x + Math.floor(0.75 * w), y + h);
- }
- else if (alpha == (-pi + beta))
- {
- return new mxPoint(x + Math.floor(0.25 * w), y + h);
- }
- if ((alpha > 0) && (alpha < beta))
- {
- a = new mxPoint(x + Math.floor(0.5 * w), y
- - Math.floor(0.5 * h));
- b = new mxPoint(x + Math.floor(1.25 * w), y + h);
- }
- else if ((alpha > beta) && (alpha < (pi - beta)))
- {
- a = new mxPoint(x, y);
- b = new mxPoint(x + w, y);
- }
- else if ((alpha > (pi - beta)) && (alpha < pi))
- {
- a = new mxPoint(x - Math.floor(0.25 * w), y + h);
- b = new mxPoint(x + Math.floor(0.5 * w), y
- - Math.floor(0.5 * h));
- }
- else if ((alpha < 0) && (alpha > -beta))
- {
- a = new mxPoint(x + Math.floor(0.5 * w), y
- + Math.floor(1.5 * h));
- b = new mxPoint(x + Math.floor(1.25 * w), y);
- }
- else if ((alpha < -beta) && (alpha > (-pi + beta)))
- {
- a = new mxPoint(x, y + h);
- b = new mxPoint(x + w, y + h);
- }
- else if ((alpha < (-pi + beta)) && (alpha > -pi))
- {
- a = new mxPoint(x - Math.floor(0.25 * w), y);
- b = new mxPoint(x + Math.floor(0.5 * w), y
- + Math.floor(1.5 * h));
- }
- }
- result = mxUtils.intersection(cx, cy, next.x, next.y, a.x, a.y, b.x, b.y);
- }
-
- if (result == null)
- {
- return new mxPoint(cx, cy);
- }
-
- return result;
- }
- };
|