Lasse Riis wrote:
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?
The swing.gvt.AbstractZoomInteractor does exactly that based on
mouse events, I would copy the code and start from there.
I don't understand how the dimensions of the overlay relates to the
dimensions of the SVG,
They don't directly. The overlay is drawn in screen coordinates.
If you want to know how the SVG maps to the screen you can call
'getViewBoxTransform()' to get the mapping from the SVG viewBox to
screen pixels.
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 exception....so somethings wrong I guess.
Most of this stuff only makes sense to try and work with after
the first GVT rendering completes. So structure your code to register
a GVTTreeRendererListener and only start poking the canvas after the
image is rendered the first time.
So could someone present some code of drawing a "small" rectangle in the
center of an overlay on a JSVGCanvas?
class myOverlay implements Overlay {
protected BasicStroke wide = new BasicStroke(3);
protected BasicStroke narrow = new BasicStroke(1);
/**
* Paints this overlay.
*/
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(Color.black);
g2d.setStroke(wide);
g2d.drawRect(50, 50, 100, 100); // draw rectangle.
g2d.setColor(Color.white);
g2d.setStroke(narrow);
g2d.drawRect(50, 50, 100, 100); // draw rectangle.
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]