use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class SpriteRenderer method renderShadow.
@Override
public void renderShadow(Backend bck, DefaultCamera2D camera, GraphicElement element) {
GraphicSprite sprite = (GraphicSprite) element;
Point3 pos = camera.getSpritePosition(sprite, new Point3(), StyleConstants.Units.GU);
AreaSkeleton skel = getOrSetAreaSkeleton(element);
shape.configureForElement(bck, element, skel, camera);
shape.renderShadow(bck, camera, element, skel);
}
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 ArrowOnEdge 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.05f);
// XXX The choice of the number above (0.05f) is problematic
Vector2 dir = new Vector2(p1.x - p2.x, p1.y - p2.y);
// Clearly it should be chosen according to the length
dir.normalize();
// of the arrow compared to the length of the curve, however
dir.scalarMult(theSize.x);
// computing the curve length (see CubicCurve) is costly. XXX
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() + per.x(), p1.y - dir.y() + per.y());
theShape.lineTo(p1.x - dir.x() - per.x(), p1.y - dir.y() - per.y());
theShape.closePath();
}
use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.
the class Tuple method renderAlong.
@Override
public void renderAlong(Backend backend, DefaultCamera2D camera, IconAndText iconAndText, ConnectorSkeleton skel) {
Point3 p = skel.pointOnShape(0.5);
renderGu2Px(backend, camera, iconAndText, p.x, p.y, 0, positionTextAndIconPx);
}
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);
}
Aggregations