use of org.graphstream.ui.javafx.renderer.ConnectorSkeleton in project gs-ui-javafx by graphstream.
the class ArrowOnEdge method makeOnLine.
private void makeOnLine(boolean forShadow, DefaultCamera2D camera) {
ConnectorSkeleton skel = theConnector.skel;
double off = 0;
Vector2 theDirection;
if (skel.isPoly()) {
off = ShapeUtil.evalTargetRadius2D(skel.apply(skel.size() - 2), skel.to(), theEdge.to, camera);
theDirection = new Vector2(skel.to().x - skel.apply(skel.size() - 2).x, skel.to().y - skel.apply(skel.size() - 2).y);
} else {
off = ShapeUtil.evalTargetRadius2D(skel.from(), skel.to(), theEdge.to, camera);
theDirection = new Vector2(skel.to().x - skel.from().x, skel.to().y - skel.from().y);
}
theDirection.normalize();
double x = theCenter.x - (theDirection.x() * off);
double y = theCenter.y - (theDirection.y() * off);
Vector2 perp = new Vector2(theDirection.y(), -theDirection.x());
perp.normalize();
theDirection.scalarMult(theSize.x);
perp.scalarMult(theSize.y);
if (forShadow) {
x += shadowable.theShadowOff.x;
y += shadowable.theShadowOff.y;
}
// Create a polygon.
theShape = new Path2D(5, true);
theShape.moveTo(x, y);
theShape.lineTo(x - theDirection.x() + perp.x(), y - theDirection.y() + perp.y());
theShape.lineTo(x - theDirection.x() - perp.x(), y - theDirection.y() - perp.y());
theShape.closePath();
}
Aggregations