use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.
the class DiamondOnEdge method makeOnCurve.
private void makeOnCurve(boolean forShadow, DefaultCamera2D camera) {
Tuple<Point2, Double> tuple = CubicCurve.approxIntersectionPointOnCurve(theEdge, theConnector, camera);
Point2 p1 = tuple.x;
double t = tuple.y;
Style style = theEdge.getStyle();
Point2 p2 = CubicCurve.eval(theConnector.fromPos(), theConnector.byPos1(), theConnector.byPos2(), theConnector.toPos(), t - 0.1f);
Vector2 dir = new Vector2(p1.x - p2.x, p1.y - p2.y);
dir.normalize();
dir.scalarMult(theSize.x);
Vector2 per = new Vector2(dir.y(), -dir.x());
per.normalize();
per.scalarMult(theSize.y);
// Create a polygon.
theShape = new Path2D(5, true);
theShape.moveTo(p1.x, p1.y);
theShape.lineTo(p1.x - dir.x() / 2 + per.x(), p1.y - dir.y() / 2 + per.y());
theShape.lineTo(p1.x - dir.x(), p1.y - dir.y());
theShape.lineTo(p1.x - dir.x() / 2 - per.x(), p1.y - dir.y() / 2 - per.y());
theShape.closePath();
}
use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.
the class DiamondOnEdge method makeOnLine.
private void makeOnLine(boolean forShadow, DefaultCamera2D camera) {
double off = ShapeUtil.evalTargetRadius2D(theEdge, camera);
Vector2 theDirection = new Vector2(theConnector.toPos().x - theConnector.fromPos().x, theConnector.toPos().y - theConnector.fromPos().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 / 2);
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() * 2, y - theDirection.y() * 2);
theShape.lineTo(x - theDirection.x() - perp.x(), y - theDirection.y() - perp.y());
theShape.closePath();
}
use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.
the class AngleShape method makeMulti.
private void makeMulti(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
double fromx = skel.apply(0).x + sox;
double fromy = skel.apply(0).y + soy;
double tox = skel.apply(3).x + sox;
double toy = skel.apply(3).y + soy;
double c1x = skel.apply(1).x + sox;
double c1y = skel.apply(1).y + soy;
double c2x = skel.apply(2).x + sox;
double c2y = skel.apply(2).y + soy;
Vector2 maindir = new Vector2(c2x - c1x, c2y - c1y);
Vector2 perp = new Vector2(maindir.y(), -maindir.x());
// 1/2 perp vector to the from point.
perp.normalize();
// 1/2 perp vector to the first control point.
Vector2 perp1 = new Vector2(perp.x(), perp.y());
// 1/2 perp vector to the second control point.
Vector2 perp2 = new Vector2(perp.x(), perp.y());
perp.scalarMult((theSize + swx) * 0.5f);
if (isDirected) {
perp1.scalarMult((theSize + swx) * 0.4f);
perp2.scalarMult((theSize + swx) * 0.2f);
} else {
perp1.scalarMult((theSize + swx) * 0.5f);
perp2.scalarMult((theSize + swx) * 0.5f);
}
// ctrl1 ctrl2
// x---t-------t---x
// / \
// / \
// X X
// from to
theShape = new Path2D(10, true);
theShape.moveTo(fromx + perp.x(), fromy + perp.y());
if (isDirected) {
theShape.curveTo(c1x + perp1.x(), c1y + perp1.y(), c2x + perp2.x(), c2y + perp2.y(), tox, toy);
theShape.curveTo(c2x - perp2.x(), c2y - perp2.y(), c1x - perp1.x(), c1y - perp1.y(), fromx - perp.x(), fromy - perp.y());
} else {
theShape.curveTo(c1x + perp.x(), c1y + perp.y(), c2x + perp.x(), c2y + perp.y(), tox + perp.x(), toy + perp.y());
theShape.lineTo(tox - perp.x(), toy - perp.y());
theShape.curveTo(c2x - perp.x(), c2y - perp.y(), c1x - perp.x(), c1y - perp.y(), fromx - perp.x(), fromy - perp.y());
}
theShape.closePath();
}
use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.
the class CubicCurveShape method makeFromPoints.
private void makeFromPoints(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
double fromx = skel.from().x + sox;
double fromy = skel.from().y + soy;
double tox = skel.to().x + sox;
double toy = skel.to().y + soy;
double c1x = skel.apply(1).x + sox;
double c1y = skel.apply(1).y + soy;
double c2x = skel.apply(2).x + sox;
double c2y = skel.apply(2).y + soy;
theShape = new Path2D(5, false);
theShape.moveTo(fromx, fromy);
theShape.curveTo(c1x, c1y, c2x, c2y, tox, toy);
if (sox == 0 && soy == 0) {
// Inform the system this is a curve, not a polyline.
skel.setCurve(fromx, fromy, 0, c1x, c1y, 0, c2x, c2y, 0, tox, toy, 0);
}
}
use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.
the class HorizontalSquareEdgeShape method makeLoop.
private void makeLoop(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
double fromx = skel.apply(0).x + sox;
double fromy = skel.apply(0).y + soy;
double tox = skel.apply(3).x + sox;
double toy = skel.apply(3).y + soy;
double c1x = skel.apply(1).x + sox;
double c1y = skel.apply(1).y + soy;
double c2x = skel.apply(2).x + sox;
double c2y = skel.apply(2).y + soy;
theShape = new Path2D(5, true);
theShape.moveTo(fromx, fromy);
theShape.curveTo(c1x, c1y, c2x, c2y, tox, toy);
}
Aggregations