if (strokeColor != null && strokeWidth > 0)
{
// Draws the start marker
Object marker = style.get(mxConstants.STYLE_STARTARROW);
mxPoint pt = pts.get(1);
mxPoint p0 = pts.get(0);
mxPoint offset = null;
if (marker != null)
{
float size = (mxUtils.getFloat(style,
mxConstants.STYLE_STARTSIZE,
mxConstants.DEFAULT_MARKERSIZE));
offset = drawMarker(group, marker, pt, p0, size, tmpStroke,
strokeColor);
}
else
{
double dx = pt.getX() - p0.getX();
double dy = pt.getY() - p0.getY();
double dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
double nx = dx * strokeWidth / dist;
double ny = dy * strokeWidth / dist;
offset = new mxPoint(nx / 2, ny / 2);
}
// Applies offset to the point
if (offset != null)
{
p0 = (mxPoint) p0.clone();
p0.setX(p0.getX() + offset.getX());
p0.setY(p0.getY() + offset.getY());
offset = null;
}
// Draws the end marker
marker = style.get(mxConstants.STYLE_ENDARROW);
pt = pts.get(pts.size() - 2);
mxPoint pe = pts.get(pts.size() - 1);
if (marker != null)
{
float size = (mxUtils.getFloat(style,
mxConstants.STYLE_ENDSIZE,
mxConstants.DEFAULT_MARKERSIZE));
offset = drawMarker(group, marker, pt, pe, size, tmpStroke,
strokeColor);
}
else
{
double dx = pt.getX() - p0.getX();
double dy = pt.getY() - p0.getY();
double dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
double nx = dx * strokeWidth / dist;
double ny = dy * strokeWidth / dist;
offset = new mxPoint(nx / 2, ny / 2);
}
// Applies offset to the point
if (offset != null)
{
pe = (mxPoint) pe.clone();
pe.setX(pe.getX() + offset.getX());
pe.setY(pe.getY() + offset.getY());
offset = null;
}
// Draws the line segments
double arcSize = mxConstants.LINE_ARCSIZE * scale;
pt = p0;
String d = "M " + pt.getX() + " " + pt.getY();
for (int i = 1; i < pts.size() - 1; i++)
{
mxPoint tmp = pts.get(i);
double dx = pt.getX() - tmp.getX();
double dy = pt.getY() - tmp.getY();
if ((rounded && i < pts.size() - 1) && (dx != 0 || dy != 0))
{
// Draws a line from the last point to the current
// point with a spacing of size off the current point
// into direction of the last point
double dist = Math.sqrt(dx * dx + dy * dy);
double nx1 = dx * Math.min(arcSize, dist / 2) / dist;
double ny1 = dy * Math.min(arcSize, dist / 2) / dist;
double x1 = tmp.getX() + nx1;
double y1 = tmp.getY() + ny1;
d += " L " + x1 + " " + y1;
// Draws a curve from the last point to the current
// point with a spacing of size off the current point
// into direction of the next point
mxPoint next = pts.get(i + 1);
dx = next.getX() - tmp.getX();
dy = next.getY() - tmp.getY();
dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
double nx2 = dx * Math.min(arcSize, dist / 2) / dist;
double ny2 = dy * Math.min(arcSize, dist / 2) / dist;
double x2 = tmp.getX() + nx2;
double y2 = tmp.getY() + ny2;
d += " Q " + tmp.getX() + " " + tmp.getY() + " " + x2 + " "
+ y2;
tmp = new mxPoint(x2, y2);
}
else
{
d += " L " + tmp.getX() + " " + tmp.getY();
}