Hi Max,

> I implemented
> the java.awt.Shape interface and i created a personal
> PathIterator. My question is about the AffineTransform.
> Who's responsable about the transfomation on a Shape?
> The interface Shape has methods whitch return PathIterator
> and has a AffineTransform as parameter. But, if managing 
> the AffineTransform of the Shape is a PathIterator task,
> what about the implementation of contains() and intersects()
> methods? 

contains() and intersects() operate on the untransformed geometry.

The transformation of coordinates by the AffineTransform parameter in the
getPathIterator() methods is the responsibility of the Shape object and
its PathIterator.

The primary reason that getPathIterator() takes a transform is that
the flatness parameter in the flattening variant needs to be measured
in the destination (or device) coordinate space in order to be accurate
and useful.

Another reason that getPathIterator() takes a transform is that path
iteration is typically performed with the intention of rendering the shape
in device space which means that 99% of the time, the geometry will need
to be transformed to be useful.  The operations can be done separately,
but frequently the shape can do something more optimal than the "iterate
then transform" operation that would otherwise be performed.  For instance
the GeneralPath combines the data copying and the transformation into a
single operation (using the methods on AffineTransform that take input and
output arrays).  Some of the simpler shapes are described by fewer points
than what appears in their iterations so that they can perform fewer
calculations if they transform the points that describe them rather than
the points in their iterated segments.  The worst case is that a Shape
does not know how to do anything special to optimize transformation and so
simply executes:

        at.transform(coords, 0, coords, 0, npoints);

just before returning from the currentSegment() methods.

So, for symmetry, both methods take a transform.  One for correctness,
and both for potential optimization...

                                ...jim

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 2D Home Page: http://java.sun.com/products/java-media/2D/

Reply via email to