use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class ConnectorSkeleton method setLine.
public void setLine(double x0, double y0, double z0, double x1, double y1, double z1) {
kind = EdgeShapeKind.LINE;
if (points.size() != 2)
points = new EdgePoints(2);
points.update(0, new Point3(x0, y0, z0));
points.update(1, new Point3(x1, y1, z1));
}
use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class ShowCubics method showCtrlPoints.
/**
* Show the control polygons.
*/
public void showCtrlPoints(GraphicsContext g, Camera camera, ConnectorSkeleton skel) {
if (showControlPolygon && skel.isCurve()) {
Point3 from = skel.from();
Point3 ctrl1 = skel.apply(1);
Point3 ctrl2 = skel.apply(2);
Point3 to = skel.to();
Paint colorStroke = g.getStroke();
Paint colorFill = g.getFill();
double stroke = g.getLineWidth();
double px6 = camera.getMetrics().px1 * 6;
double px3 = camera.getMetrics().px1 * 3;
g.setStroke(Color.RED);
g.setFill(Color.RED);
g.fillOval(from.x - px3, from.y - px3, px6, px6);
if (ctrl1 != null) {
g.fillOval(ctrl1.x - px3, ctrl1.y - px3, px6, px6);
g.fillOval(ctrl2.x - px3, ctrl2.y - px3, px6, px6);
g.setLineWidth(camera.getMetrics().px1);
g.strokeLine(ctrl1.x, ctrl1.y, ctrl2.x, ctrl2.y);
g.strokeLine(from.x, from.y, ctrl1.x, ctrl1.y);
g.strokeLine(ctrl2.x, ctrl2.y, to.x, to.y);
}
g.fillOval(to.x - px3, to.y - px3, px6, px6);
g.setStroke(colorStroke);
g.setFill(colorFill);
g.setLineWidth(stroke);
}
}
use of org.graphstream.ui.geom.Point3 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);
}
use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class LineShape method make.
@Override
public void make(Backend backend, DefaultCamera2D camera) {
Point3 from = skel.from();
Point3 to = skel.to();
if (skel.isCurve()) {
Point3 ctrl1 = skel.apply(1);
Point3 ctrl2 = skel.apply(2);
theShapeC = new CubicCurve2D(from.x, from.y, ctrl1.x, ctrl1.y, ctrl2.x, ctrl2.y, to.x, to.y);
theShape = theShapeC;
} else {
theShapeL = new Line2D(from.x, from.y, to.x, to.y);
theShape = theShapeL;
}
}
use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class ImageOnEdge 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();
Point3 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();
double iw = camera.getMetrics().lengthToGu(image.getWidth(), Units.PX) / 2;
double x = p1.x - (dir.x() * iw);
double y = p1.y - (dir.y() * iw);
if (forShadow) {
x += shadowable.theShadowOff.x;
y += shadowable.theShadowOff.y;
}
p = camera.transformGuToPx(x, y, 0);
angle = Math.acos(dir.dotProduct(1, 0));
if (dir.y() > 0)
angle = (Math.PI - angle);
}
Aggregations