> > When I display a bounding box for a rotated circle (which should have
> > the same bounds no matter how it is rotated) the box changes as if the
> > original square bounding box was part of the shape, e.g. the bounds get
> > larger as you approach 45 degrees. That would mean that the bbox is in
> > fact a maximum bbox. The exact bounds can't be larger (so it's safe to
> > clip), but they could be smaller.
>
> Wow, I'd say this is pretty weird. Please provide some background
> information, such as Batik version (or revision if using the source
> code [1]), Java version, operating system etc.. Also, are you able to
> create a reduced test case [2]?
Here's some sample code. Batik version is 1.7.
public class BoundsTest {
public static void main(String[] args) throws Exception {
ShapeNode innerNode = new ShapeNode();
// circle with diameter 10
innerNode.setShape( new Ellipse2D.Double(-5,-5,10,10) );
CompositeGraphicsNode outerNode = new CompositeGraphicsNode();
outerNode.add( innerNode );
System.out.println( outerNode.getBounds() );
// yields w=10.0,h=10.0
innerNode.setTransform(AffineTransform.getRotateInstance(Math.PI*0.25));
System.out.println( outerNode.getBounds() );
// yields w=14.142135623730951,h=14.142135623730951
// 10x10 square
innerNode.setShape( new Rectangle2D.Double(-5,-5,10,10) );
System.out.println( outerNode.getBounds() );
// yields w=14.142135623730951,h=14.142135623730951
System.out.println( Math.sqrt(200.0) );
// is 14.142135623730951, i.e. the diagonal of a 10x10 square
}
}
> Note that I haven't (yet) tried to reproduce the issue. Naturally,
> this may even be expected -- also I haven't (yet) double check the
> specification regarding this, though intuitively it would seem
> awkward. Currently, I'm just inviting you to share a bit more so one
> to be able to take a better look at this.
The javadoc entry reads
getBounds
Rectangle2D getBounds()
Returns the bounds of this node in user space. This includes primitive
paint, filtering, clipping and masking.
It doesn't actually say "includes transformations", so I guess it is all
well and intended. At least it's assured that the actual bounds are
always smaller than the clipping area returned by getBounds(). I just
wanted to know if there is already another, more accurate function which
would yield the actual bounds (which would definitely require more
computing and would hence be less efficient for clipping purposes).
Regards,
Gerrit
--
http://www.fastmail.fm - The professional email service
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]