Todd O'Bryan
Todd O'Bryan

Reputation: 2260

Is there an equivalent of AffineTransform.createTransformedShape(Shape) in JavaFX?

In JavaFX 2.2, it seems like you can't do much with Transform objects except add them to Nodes. In particular, there's no algebraic operations so that you can compose one transformation with another.

I suppose the reason is that most of the calculations should be done by the GPU directly, so not letting people try to do it programmatically prevents some slowdown.

But sometimes you really do want to know what the final result of applying a transformation is. In particular, java.awt.geom.AffineTransform has this nice method createTransformedShape that would turn a java.awt.Shape into the equivalent shape under the given transformation. I can't find anything equivalent in JavaFX, and I can't think of a workaround.

Am I missing something or does anyone have a clever idea that doesn't involve re-implementing the Shape class?

Upvotes: 1

Views: 869

Answers (1)

jewelsea
jewelsea

Reputation: 159496

I do not believe that an exact equivalent of AffineTransform.createTransformedShape was added to Java 8. You can however apply a transform to a shape by adding a transform to the shape's transform list. So in a way, a transformed shape is just a shape with some custom transforms in it's transform list.

The Transform functions in JavaFX were greatly enhance for Java 8 allowing composition of transformations. In addition various vector like algebraic operations were added the Point2D and Point3D classes.

Upvotes: 2

Related Questions