-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7781382
commit d1ac435
Showing
523 changed files
with
1,034,983 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* Copyright (c) 2006-2015, JGraph Ltd | ||
* Copyright (c) 2006-2015, Gaudenz Alder | ||
*/ | ||
/** | ||
* Class: mxActor | ||
* | ||
* Extends <mxShape> to implement an actor shape. If a custom shape with one | ||
* filled area is needed, then this shape's <redrawPath> should be overridden. | ||
* | ||
* Example: | ||
* | ||
* (code) | ||
* function SampleShape() { } | ||
* | ||
* SampleShape.prototype = new mxActor(); | ||
* SampleShape.prototype.constructor = vsAseShape; | ||
* | ||
* mxCellRenderer.registerShape('sample', SampleShape); | ||
* SampleShape.prototype.redrawPath = function(path, x, y, w, h) | ||
* { | ||
* path.moveTo(0, 0); | ||
* path.lineTo(w, h); | ||
* // ... | ||
* path.close(); | ||
* } | ||
* (end) | ||
* | ||
* This shape is registered under <mxConstants.SHAPE_ACTOR> in | ||
* <mxCellRenderer>. | ||
* | ||
* Constructor: mxActor | ||
* | ||
* Constructs a new actor shape. | ||
* | ||
* Parameters: | ||
* | ||
* bounds - <mxRectangle> that defines the bounds. This is stored in | ||
* <mxShape.bounds>. | ||
* fill - String that defines the fill color. This is stored in <fill>. | ||
* stroke - String that defines the stroke color. This is stored in <stroke>. | ||
* strokewidth - Optional integer that defines the stroke width. Default is | ||
* 1. This is stored in <strokewidth>. | ||
*/ | ||
function mxActor(bounds, fill, stroke, strokewidth) | ||
{ | ||
mxShape.call(this); | ||
this.bounds = bounds; | ||
this.fill = fill; | ||
this.stroke = stroke; | ||
this.strokewidth = (strokewidth != null) ? strokewidth : 1; | ||
}; | ||
|
||
/** | ||
* Extends mxShape. | ||
*/ | ||
mxUtils.extend(mxActor, mxShape); | ||
|
||
/** | ||
* Function: paintVertexShape | ||
* | ||
* Redirects to redrawPath for subclasses to work. | ||
*/ | ||
mxActor.prototype.paintVertexShape = function(c, x, y, w, h) | ||
{ | ||
c.translate(x, y); | ||
c.begin(); | ||
this.redrawPath(c, x, y, w, h); | ||
c.fillAndStroke(); | ||
}; | ||
|
||
/** | ||
* Function: redrawPath | ||
* | ||
* Draws the path for this shape. | ||
*/ | ||
mxActor.prototype.redrawPath = function(c, x, y, w, h) | ||
{ | ||
var width = w/3; | ||
c.moveTo(0, h); | ||
c.curveTo(0, 3 * h / 5, 0, 2 * h / 5, w / 2, 2 * h / 5); | ||
c.curveTo(w / 2 - width, 2 * h / 5, w / 2 - width, 0, w / 2, 0); | ||
c.curveTo(w / 2 + width, 0, w / 2 + width, 2 * h / 5, w / 2, 2 * h / 5); | ||
c.curveTo(w, 2 * h / 5, w, 3 * h / 5, w, h); | ||
c.close(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/** | ||
* Copyright (c) 2006-2015, JGraph Ltd | ||
* Copyright (c) 2006-2015, Gaudenz Alder | ||
*/ | ||
/** | ||
* Class: mxArrow | ||
* | ||
* Extends <mxShape> to implement an arrow shape. (The shape | ||
* is used to represent edges, not vertices.) | ||
* This shape is registered under <mxConstants.SHAPE_ARROW> | ||
* in <mxCellRenderer>. | ||
* | ||
* Constructor: mxArrow | ||
* | ||
* Constructs a new arrow shape. | ||
* | ||
* Parameters: | ||
* | ||
* points - Array of <mxPoints> that define the points. This is stored in | ||
* <mxShape.points>. | ||
* fill - String that defines the fill color. This is stored in <fill>. | ||
* stroke - String that defines the stroke color. This is stored in <stroke>. | ||
* strokewidth - Optional integer that defines the stroke width. Default is | ||
* 1. This is stored in <strokewidth>. | ||
* arrowWidth - Optional integer that defines the arrow width. Default is | ||
* <mxConstants.ARROW_WIDTH>. This is stored in <arrowWidth>. | ||
* spacing - Optional integer that defines the spacing between the arrow shape | ||
* and its endpoints. Default is <mxConstants.ARROW_SPACING>. This is stored in | ||
* <spacing>. | ||
* endSize - Optional integer that defines the size of the arrowhead. Default | ||
* is <mxConstants.ARROW_SIZE>. This is stored in <endSize>. | ||
*/ | ||
function mxArrow(points, fill, stroke, strokewidth, arrowWidth, spacing, endSize) | ||
{ | ||
mxShape.call(this); | ||
this.points = points; | ||
this.fill = fill; | ||
this.stroke = stroke; | ||
this.strokewidth = (strokewidth != null) ? strokewidth : 1; | ||
this.arrowWidth = (arrowWidth != null) ? arrowWidth : mxConstants.ARROW_WIDTH; | ||
this.spacing = (spacing != null) ? spacing : mxConstants.ARROW_SPACING; | ||
this.endSize = (endSize != null) ? endSize : mxConstants.ARROW_SIZE; | ||
}; | ||
|
||
/** | ||
* Extends mxShape. | ||
*/ | ||
mxUtils.extend(mxArrow, mxShape); | ||
|
||
/** | ||
* Function: augmentBoundingBox | ||
* | ||
* Augments the bounding box with the edge width and markers. | ||
*/ | ||
mxArrow.prototype.augmentBoundingBox = function(bbox) | ||
{ | ||
mxShape.prototype.augmentBoundingBox.apply(this, arguments); | ||
|
||
var w = Math.max(this.arrowWidth, this.endSize); | ||
bbox.grow((w / 2 + this.strokewidth) * this.scale); | ||
}; | ||
|
||
/** | ||
* Function: paintEdgeShape | ||
* | ||
* Paints the line shape. | ||
*/ | ||
mxArrow.prototype.paintEdgeShape = function(c, pts) | ||
{ | ||
// Geometry of arrow | ||
var spacing = mxConstants.ARROW_SPACING; | ||
var width = mxConstants.ARROW_WIDTH; | ||
var arrow = mxConstants.ARROW_SIZE; | ||
|
||
// Base vector (between end points) | ||
var p0 = pts[0]; | ||
var pe = pts[pts.length - 1]; | ||
var dx = pe.x - p0.x; | ||
var dy = pe.y - p0.y; | ||
var dist = Math.sqrt(dx * dx + dy * dy); | ||
var length = dist - 2 * spacing - arrow; | ||
|
||
// Computes the norm and the inverse norm | ||
var nx = dx / dist; | ||
var ny = dy / dist; | ||
var basex = length * nx; | ||
var basey = length * ny; | ||
var floorx = width * ny/3; | ||
var floory = -width * nx/3; | ||
|
||
// Computes points | ||
var p0x = p0.x - floorx / 2 + spacing * nx; | ||
var p0y = p0.y - floory / 2 + spacing * ny; | ||
var p1x = p0x + floorx; | ||
var p1y = p0y + floory; | ||
var p2x = p1x + basex; | ||
var p2y = p1y + basey; | ||
var p3x = p2x + floorx; | ||
var p3y = p2y + floory; | ||
// p4 not necessary | ||
var p5x = p3x - 3 * floorx; | ||
var p5y = p3y - 3 * floory; | ||
|
||
c.begin(); | ||
c.moveTo(p0x, p0y); | ||
c.lineTo(p1x, p1y); | ||
c.lineTo(p2x, p2y); | ||
c.lineTo(p3x, p3y); | ||
c.lineTo(pe.x - spacing * nx, pe.y - spacing * ny); | ||
c.lineTo(p5x, p5y); | ||
c.lineTo(p5x + floorx, p5y + floory); | ||
c.close(); | ||
|
||
c.fillAndStroke(); | ||
}; |
Oops, something went wrong.