double absSize = size * canvas.getScale();
List<mxPoint> points = state.getAbsolutePoints();
mxLine markerVector = getMarkerVector(points, source, absSize);
mxPoint p0 = new mxPoint(markerVector.getX(), markerVector.getY());
mxPoint pe = markerVector.getEndPoint();
mxPoint offset = null;
// Computes the norm and the inverse norm
double dx = pe.getX() - p0.getX();
double dy = pe.getY() - p0.getY();
double dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
double unitX = dx / dist;
double unitY = dy / dist;
double nx = unitX * absSize;
double ny = unitY * absSize;
// Allow for stroke width in the end point used and the
// orthogonal vectors describing the direction of the
// marker
double strokeX = unitX * strokeWidth;
double strokeY = unitY * strokeWidth;
pe = (mxPoint) pe.clone();
pe.setX(pe.getX() - strokeX / 2.0);
pe.setY(pe.getY() - strokeY / 2.0);
mxIMarker marker = mxMarkerRegistry.getMarker(type);
if (marker != null)
{
offset = marker.paintMarker(canvas, state, type, pe, nx, ny, absSize, source);
if (offset != null)
{
offset.setX(offset.getX() - strokeX / 2.0);
offset.setY(offset.getY() - strokeY / 2.0);
}
}
else
{
// Offset for the strokewidth
nx = dx * strokeWidth / dist;
ny = dy * strokeWidth / dist;
offset = new mxPoint(-strokeX / 2.0, -strokeY / 2.0);
}
return offset;
}