use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.
the class BlobShape 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;
double srcsz = Math.min(theSourceSize.x, theSourceSize.y);
double trgsz = Math.min(theTargetSize.x, theTargetSize.y);
Vector2 maindir = new Vector2(c2x - c1x, c2y - c1y);
Vector2 perp1 = new Vector2(maindir.y(), -maindir.x());
// 1/2 perp vector to the from point.
perp1.normalize();
// 1/2 perp vector to the to point.
Vector2 perp2 = new Vector2(perp1.x(), perp1.y());
// 1/2 perp vector to the middle point on the edge.
Vector2 perpm = new Vector2(perp1.x(), perp1.y());
double t = 5f;
perp1.scalarMult((srcsz + swx) / 2f);
perpm.scalarMult((theSize + swx) / 2f);
if (isDirected)
perp2.scalarMult((theSize + swx) / 2f);
else
perp2.scalarMult((trgsz + swx) / 2f);
theShape = new Path2D(10, true);
theShape.moveTo(fromx + perp1.x(), fromy + perp1.y());
theShape.quadTo(c1x + perpm.x(), c1y + perpm.y(), c1x + maindir.x() / t + perpm.x(), c1y + maindir.y() / t + perpm.y());
theShape.lineTo(c2x - maindir.x() / t + perpm.x(), c2y - maindir.y() / t + perpm.y());
theShape.quadTo(c2x + perpm.x(), c2y + perpm.y(), tox + perp2.x(), toy + perp2.y());
theShape.lineTo(tox - perp2.x(), toy - perp2.y());
theShape.quadTo(c2x - perpm.x(), c2y - perpm.y(), c2x - maindir.x() / t - perpm.x(), c2y - maindir.y() / t - perpm.y());
theShape.lineTo(c1x + maindir.x() / t - perpm.x(), c1y + maindir.y() / t - perpm.y());
theShape.quadTo(c1x - perpm.x(), c1y - perpm.y(), fromx - perp1.x(), fromy - perp1.y());
theShape.closePath();
}
use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.
the class BlobShape method makeOnLine.
private void makeOnLine(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;
Vector2 dir = new Vector2(tox - fromx, toy - fromy);
Vector2 perp1 = new Vector2(dir.y(), -dir.x());
// 1/2 perp vector to the from point.
perp1.normalize();
// 1/2 perp vector to the to point.
Vector2 perp2 = new Vector2(perp1.x(), perp1.y());
// 1/2 perp vector to the middle point on the edge.
Vector2 perpm = new Vector2(perp1.x(), perp1.y());
double srcsz = Math.min(theSourceSize.x, theSourceSize.y);
double trgsz = Math.min(theTargetSize.x, theTargetSize.y);
perp1.scalarMult((srcsz + swx) / 2f);
perpm.scalarMult((theSize + swx) / 2f);
if (isDirected)
perp2.scalarMult((theSize + swx) / 2f);
else
perp2.scalarMult((trgsz + swx) / 2f);
double t1 = 5f;
double t2 = 2.3f;
double m = 1f;
theShape = new Path2D(10, true);
theShape.moveTo(fromx + perp1.x(), fromy + perp1.y());
theShape.quadTo(fromx + dir.x() / t1 + perpm.x() * m, fromy + dir.y() / t1 + perpm.y() * m, fromx + dir.x() / t2 + perpm.x(), fromy + dir.y() / t2 + perpm.y());
theShape.lineTo(tox - dir.x() / t2 + perpm.x(), toy - dir.y() / t2 + perpm.y());
theShape.quadTo(tox - dir.x() / t1 + perpm.x() * m, toy - dir.y() / t1 + perpm.y() * m, tox + perp2.x(), toy + perp2.y());
theShape.lineTo(tox - perp2.x(), toy - perp2.y());
theShape.quadTo(tox - dir.x() / t1 - perpm.x() * m, toy - dir.y() / t1 - perpm.y() * m, tox - dir.x() / t2 - perpm.x(), toy - dir.y() / t2 - perpm.y());
theShape.lineTo(fromx + dir.x() / t2 - perpm.x(), fromy + dir.y() / t2 - perpm.y());
theShape.quadTo(fromx + dir.x() / t1 - perpm.x() * m, fromy + dir.y() / t1 - perpm.y() * m, fromx - perp1.x(), fromy - perp1.y());
theShape.closePath();
}
use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.
the class FreePlaneEdgeShape method makeSingle.
private void makeSingle(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
try {
double fromx = skel.from().x + sox;
double fromy = skel.from().y + soy - theSourceSize.y / 2;
double tox = skel.to().x + sox;
double toy = skel.to().y + soy - theTargetSize.y / 2;
double length = Math.abs(skel.to().x - skel.from().x);
double c1x = 0.0;
double c1y = 0.0;
double c2x = 0.0;
double c2y = 0.0;
if (skel.from().x < skel.to().x) {
// At right.
fromx += theSourceSize.x / 2;
tox -= theTargetSize.x / 2;
c1x = fromx + length / 3;
c2x = tox - length / 3;
c1y = fromy;
c2y = toy;
} else {
// At left.
fromx -= theSourceSize.x / 2;
tox += theTargetSize.x / 2;
c1x = fromx - length / 3;
c2x = tox + length / 3;
c1y = fromy;
c2y = toy;
}
theShape = new Path2D(5, false);
theShape.moveTo(fromx, fromy);
theShape.curveTo(c1x, c1y, c2x, c2y, tox, toy);
// Set the connector as a curve.
if (sox == 0 && soy == 0) {
skel.setCurve(fromx, fromy, 0, c1x, c1y, 0, c2x, c2y, 0, tox, toy, 0);
}
} catch (Exception e) {
Logger.getLogger(this.getClass().getSimpleName()).log(Level.WARNING, "FOUND!", e);
}
}
use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.
the class FreePlaneEdgeShape 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;
theShape = new Path2D(5, false);
theShape.moveTo(fromx, fromy);
theShape.curveTo(c1x, c1y, c2x, c2y, tox, toy);
}
use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.
the class LSquareEdgeShape method makeSingle.
private void makeSingle(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
Point3 from = new Point3(skel.from().x + sox, skel.from().y + soy, 0);
Point3 to = new Point3(skel.to().x + sox, skel.to().y + soy, 0);
Vector2 mainDir = new Vector2(from, to);
double length = mainDir.length();
double angle = mainDir.y() / length;
Point3 inter = null;
if (angle > 0.707107f || angle < -0.707107f) {
// North or south.
inter = new Point3(from.x, to.y, 0);
} else {
// East or west.
inter = new Point3(to.x, from.y, 0);
}
if (sox == 0 && soy == 0) {
Point3[] pts = { from, inter, to };
skel.setPoly(pts);
}
theShape = new Path2D(5, false);
theShape.moveTo(from.x, from.y);
theShape.lineTo(inter.x, inter.y);
theShape.lineTo(to.x, to.y);
}
Aggregations