use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class Area method configureAreaForElement.
/**
* Select the general size and position of the shape.
* This is done according to:
* - The style,
* - Eventually the element specific size attribute,
* - Eventually the element contents (decor).
*/
public void configureAreaForElement(Backend backend, DefaultCamera2D camera, AreaSkeleton skel, GraphicElement element, ShapeDecor decor) {
Point3 pos = camera.getNodeOrSpritePositionGU(element, null);
if (fit) {
Tuple<Double, Double> decorSize = decor.size(backend, camera, skel.iconAndText);
if (decorSize.val1 == 0 || decorSize.val2 == 0)
sizeForElement(element.getStyle(), camera, element);
positionAndFit(camera, skel, element, pos.x, pos.y, decorSize.val1, decorSize.val2);
} else {
sizeForElement(element.getStyle(), camera, element);
positionAndFit(camera, skel, element, pos.x, pos.y, 0, 0);
}
}
use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class Tuple method renderGu2Px.
/* We choose here to replace the transform (GU->PX) into a the identity to draw
* The text and icon. Is this the best way ? Maybe should we merely scale the
* font size to render the text at the correct size ? How to handle the icon in
* this case ?
*/
protected void renderGu2Px(Backend backend, DefaultCamera2D camera, IconAndText iconAndText, double x, double y, double angle, FunctionIn<Backend, Point3, IconAndText, Double, Point3> positionPx) {
GraphicsContext g = backend.graphics2D();
Point3 p = camera.transformGuToPx(x, y, 0);
Affine Tx = g.getTransform();
g.setTransform(new Affine());
p = positionPx.apply(backend, p, iconAndText, angle);
iconAndText.render(backend, camera, p.x, p.y);
g.setTransform(Tx);
}
use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class FxGraphRenderer method moveElementAtPx.
public void moveElementAtPx(GraphicElement element, double x, double y) {
Point3 p = camera.transformPxToGu(x, y);
element.move(p.x, p.y, element.getZ());
}
use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class ConnectorSkeleton method segmentsLengths.
/**
* Compute the length of each segment between the points making up this edge. This is mostly
* only useful for polylines. The results of this method is cached. It is only recomputed when
* a points changes in the shape. There are size-1 segments if the are size points. The segment
* 0 is between points 0 and 1.
*/
public double[] segmentsLengths() {
if (lengths == null) {
if (isPoly()) {
int n = points.size();
lengthsSum = 0;
if (n > 0) {
lengths = new double[points.size() - 1];
Point3 prev = points.get(0);
Point3 next = null;
for (int i = 1; i < n; i++) {
next = points.get(i);
lengths[i - 1] = next.distance(prev);
lengthsSum += lengths[i - 1];
prev = next;
}
} else {
lengths = new double[0];
}
} else if (isCurve()) {
throw new RuntimeException("segmentsLengths for curve ....");
} else {
lengths = new double[1];
lengths[0] = points.get(0).distance(points.get(3));
lengthsSum = lengths[0];
}
}
return lengths;
}
use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class ConnectorSkeleton method setPoly.
public void setPoly(Object aSetOfPoints) {
if (!kind.equals(EdgeShapeKind.POLYLINE)) {
kind = EdgeShapeKind.POLYLINE;
Point3[] thePoints = getPoints(aSetOfPoints);
points = new EdgePoints(thePoints.length);
points.copy(thePoints);
lengths = null;
}
}
Aggregations