Re: Example of using an overlay

2005-02-22 Thread Andres Toussaint
Hi:
Please define what do you mean by overlay.
Is it a Swing paint() layer on top of your SVG JSVGCanvas? Or is it 
another element of SVG on top of the first element?

For the dimensions of your SVG, the representation you see on screen is 
a conversion of the units you indicate in your SVG Doc (pts, inches, 
cm) and the viewBox attribute (if set).

The getDocumentSize method is available after the document is loaded, 
you you must make sure you are calling it in or after the 
documentLoadingCompleted event is triggered.

Andres.
On Feb 22, 2005, at 12:55 PM, Lasse Riis wrote:
Hello
I've been reading a lot, but I can't seem to gather a complete 
picture. So could someone present some example code, of say drawing a 
rectangle on an overlay?

I don't understand how the dimensions of the overlay relates to the 
dimensions of the SVG, and I don't even know what the dimensions of 
the SVG is (is it the pixels currently on screen?). I've been trying 
to use the getDocumentSize method on jsvgcanvas, inherited from 
jsvgcomponent, or is it? It gives a null-pointer exceptionso 
somethings wrong I guess.

So could someone present some code of drawing a small rectangle in 
the center of an overlay on a JSVGCanvas?

Lasse Riis
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Example of using an overlay

2005-02-22 Thread Lasse Riis
Andres Toussaint wrote:
Hi:
Please define what do you mean by overlay.
Is it a Swing paint() layer on top of your SVG JSVGCanvas? Or is it 
another element of SVG on top of the first element?

I mean a Swing paint() layer
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Example of using an overlay

2005-02-22 Thread Andres Toussaint
To paint in swing on top of a JSVGCanvas:

The only thing you need to do is to call PaintChildren in the paint method of the parent component to the JSVGCanvas, and then paint your overlay. The parent can be a JPanel, a JSVGScrollPane, a Viewport, etc. In the example provided the most relevant method is the paint(g), all other stuff is generic Batik canvas.

To do a swing paint() overlay, as adapted from the JSVGCanvas tutorial from the Baitk web site:

x-tad-biggerpublic class OverlayPanel extends JPanel {
JSVGCanvas svgCanvas = new JSVGCanvas();
boolean isVisible = false;

public void paint(java.awt.Graphics g) {
paintChildren(g); // give JSVGCanvas a chance to render 
// before we draw the overlay

//Some overlay sample.
if (isVisible) {  // in case the overlay should be drawn
// only if we have a SVG document.
// if you track the gvtRenderingCompleted, you 
// can have a boolean to activate once the
// document is displayed.
g.setColor(java.awt.Color.RED);
g.fillrect(10,10,100,100);
}
//End of overlay sample.
}

//Some routine to load the SVG document
public setSVGDocument(String uri) {
try {
svgCanvas.setURI(f.toURL().toString());
isVisible = false;
} catch (IOException ex) {
ex.printStackTrace();
}
}

// Constructor that creates the listeners, and adds the 
//	JSVGCanvas to the panel.
public OverlayPanel() {
this.add(Center, svgCanvas);

// Set the JSVGCanvas listeners.
svgCanvas.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
label.setText(Document Loading...);
}
public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {
label.setText(Document Loaded.);
}
});

svgCanvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
public void gvtBuildStarted(GVTTreeBuilderEvent e) {
label.setText(Build Started...);
}
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
label.setText(Build Done.);
frame.pack();
}
});

svgCanvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
label.setText(Rendering Started...);
}
public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
label.setText();
isVisible = true;  // Our document is visible.
// Please note that you may need to
// force a redraw of the swing component
// to make it paint after this stage.
}
});
}

/x-tad-bigger
On Feb 22, 2005, at 2:11 PM, Lasse Riis wrote:

Andres Toussaint wrote:

Hi:

Please define what do you mean by overlay.

Is it a Swing paint() layer on top of your SVG JSVGCanvas? Or is it another element of SVG on top of the first element?

I mean a Swing paint() layer

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]