OK - I think Thomas DeWeese has given me something to try here, so I will explore getScreenCTM().
----- Original Message -----
Sent: Monday, August 22, 2005 10:22 AM
Subject: Re: getBBox

Maybe one last question - how can I find the bounds of the rectangle returned by getBBox() in actual screen coordinates? location of the top-left corner as well as width and height.
----- Original Message -----
Sent: Monday, August 22, 2005 10:01 AM
Subject: AW: getBBox

No, the bounding box is tied to the user coordinates, i.e. to the coordinates of the element in the svg file

 

For your path element the 0 is the minimum x coordinate and the 3.85 the minimum y coordinate. Then the width and height are the extension of your path element, so from the minimum x to maximum x would be width and from minimum y to maximum y is height. You can check that out in the svg file and the path element.

<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"/>

 

 


Von: Tracey Zellmann [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 22. August 2005 15:52
An: [email protected]
Betreff: Re: getBBox

 

Thanks. That works and I can get the bounding box. I will have to puzzle over this some more, since it still isn't doing what I expect. The bounding box has an appropriate width and height, but the x and y coordinates are not what I expect. x is 0.0 and y is 3.85, and the comnponent is well over on the right side of the screen. In screen coordinates, it should be about x = 750.0

 

Is the bounding box not tied to the screen coordinates?

----- Original Message -----

Sent: Monday, August 22, 2005 9:38 AM

Subject: AW: getBBox

 

Try:

 

this.canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);

 

dominik


Von: Tracey Zellmann [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 22. August 2005 15:34
An: [email protected]
Betreff: Re: getBBox

 

Thanks for getting back to me. It makes sense that the canvas should be ALWAYS_DYNAMIC. I don't have any defs and the canvas has been rendered before I get to this place in the application. I am trying to resolve how to actually give the canvas that property. I get the canvas by loading a file:

 

String path = Context.getInstance().getSetUp("ImagePath");
        File f = new File(path);
        try {
            this.canvas.setURI(f.toURL().toString());
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

 

I am continuig to scour the API, but haven't found the way to tell the canvas to be dynamic. Any help with that?

 

----- Original Message -----

Sent: Monday, August 22, 2005 9:13 AM

Subject: AW: getBBox

 

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:[EMAIL PROTECTED]
Gesendet: Montag, 22. August 2005 15:02
An: [email protected]
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>

 

Reply via email to