xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steiner, Dominik" <Dominik.Stei...@gigatronik.com>
Subject AW: getBBox
Date Mon, 22 Aug 2005 13:13:19 GMT
Hi Tracey,

 

I had similar problems with getBBox() and found out that 

there are 3  things to notice when you want to get a BBox:

 

1)       your JSVGCanvas should be ALWAYS_DYNAMIC, because only then the
SVGContext gets added to the elements when they are rendered.

2)       The BBox gets available after the gvt tree is rendered, so you
can check this with adding a GVTTreeBuilderListener() to your svgcanvas

3)       Elements in the <defs> section (or with display:none) have no
geometry associated with them and hence have no bounding box.

 

I hope this helps,

 

Dominik

 

  _____  

Von: Tracey Zellmann [mailto:tracey.zellmann@comcast.net] 
Gesendet: Montag, 22. August 2005 15:02
An: batik-users@xmlgraphics.apache.org
Betreff: getBBox

 

I am having some trouble getting the bounding box for an element.

 

I have an application where I show users the image of an automobile -
based on a Visio 2003 drawing saved as an svg document. The display is
working fine. They mark various points on the car as they answer
questions. I do not need to modify the svg document in real time. I
currently am capturing the positions they mark on a glass pane and
drawing them there. When the user finishes the session, I capture all
those points and write them out to an xml file. Later I will process all
the information from various users and produce an overall report. At
that time, I will put various graphical chart elements on the car image.

 

To do this, I need to make sure the points I am capturing are translated
into the coordinate system of the car image. There are various other
Swing components displayed as well as the JSVGCanvas. I have tried to
use canvas.getLocation() as a base point, but that doesn't seem to agree
with the image of the car. I have read the recent posts about image size
and I have tried to get the bounding box of the car image element. 

 

The car image as exported by Visio is pasted below.

 

I try the following code, but it returns a null bounding box

 

  SVGOMGElement elt = 
      (SVGOMGElement)
this.canvas.getSVGDocument().getElementById("shape31-66");
        SVGRect rect = elt.getBBox();
        

I would try to get the properties of rect with getX(), getY(),
getHeight() and getWidth(), and use them to translate the screen points
to the car coordinates. However, when I try, rect is null. I have tried
quite a few alternatives, but I am stumped. Any help would be
appreciated.

 

 

<g id="shape31-66" v:mID="31" v:groupContext="shape"
transform="translate(250.749,0) scale(-1,1)">

<title>Vehicle Body.22</title>

<v:textBlock v:margins="rect(4,4,4,4)"/>

<path d="M41.7 3.84 L37.47 3.99 L33.24 4.45 L29.21 5.36 L25.56 6.43
L21.9 7.8 L18.45 9.47 L15.18 11.45 L12.3 13.58

L9.61 16.02 L7.11 18.45 L5 21.19 L3.27 24.08 L1.92 27.13 L0.77 30.32
L0.19 33.67 L0 37.02 L0 334.73

L0.19 338.08 L0.77 341.43 L1.92 344.63 L3.27 347.67 L5 350.56 L7.11
353.3 L9.61 355.89 L12.3 358.17

L15.18 360.3 L18.45 362.28 L21.9 363.95 L25.56 365.32 L29.21 366.39
L33.24 367.3 L37.47 367.76 L41.7

367.91 L208.86 367.91 L213.09 367.76 L217.32 367.3 L221.35 366.39
L225.19 365.32 L228.84 363.95 L232.3

362.28 L235.57 360.3 L238.45 358.17 L241.14 355.89 L243.64 353.3 L245.75
350.56 L247.48 347.67 L248.83

344.63 L249.98 341.43 L250.56 338.08 L250.75 334.73 L250.75 37.02
L250.56 33.67 L249.98 30.32 L248.83

27.13 L247.48 24.08 L245.75 21.19 L243.64 18.45 L241.14 16.02 L238.45
13.58 L235.57 11.45 L232.3 9.47

L228.84 7.8 L225.19 6.43 L221.35 5.36 L217.32 4.45 L213.09 3.99 L208.86
3.84 L41.7 3.84 Z" class="st7"/>

</g>

 


Mime
View raw message