Hi Keywan,
Keywan Najafi Tonekaboni <[EMAIL PROTECTED]> wrote on 06/22/2007
01:34:35 PM:
> since I added a JSVGCanvas in my JFrame, the frame itself keeps "empty"
> until I resize the window, after the canvas was build completly
> (SVGDocument&SVGGraphics2D generated and added). At the moment I use a
> small hack, to resize the frame, after all was generated.
If you look at the JSVGViewerFrame (Batik Squiggle's Frame for
the canvas) You will see that it uses a small subclass of the
normal Canvas the overrides the method:
/**
* This method is called when the component knows the
desired
* size of the window (based on width/height of outermost
SVG
* element). We override it to immediately pack this
frame.
*/
public void setMySize(Dimension d)
Before this method is called the Canvas has no real size (I think it
defaults to something small).
> I have another question about zooming the document. Is there anywhere a
> property, which saves the current canvas zoom?
You can save the current RenderingTransform. This includes the scale
(rotation if any) and translate.
> Is it possible to change the zoom absolute and not relativ? For example
> I would set it back to the original size.
If you set the RenderingTransform to the Identity transform the view
will go back to the default (ctrl-T does that already).
> Or would implement a combobox,
> like in Evince (Gnome PDF Viewer) with "50%", "100%", "200%" etc.
You can simply replace the RenderingTransform with a manually created
AffineTransform:
canvas.setRenderingTransform(AffineTransform.getScaleInstance(2,2)); //
200% zoom.
One thing to consider is that often you will want to also translate
(zoom on the center of the document etc).
> If I wand zoom features like "Fit in Page", " Fit in width", must I
> implement them by my own, or is there already a class.
You can try using the ViewBox methods that Randy Mentioned.
> I have another question related to SVGGraphics2D. I want to draw a rect,
> filled with a transparent color and a non-transparent black stroke,
> At the moment I draw it this way:
>
> svgG2D.setPaint(Color.BLACK);
> BasicStroke stroke = new BasicStroke((float)1.5);
> svgG2D.setStroke(stroke);
> svgG2D.draw(shape);
> svgG2D.setPaint(new Color(255, 0, 0, 64));
> svgG2D.fill(shape);
>
> I guess this is not the most intelligent solution...
Nop, that's the best you can do with the SVGGraphics2D.
Of course you can always build your own DOM fairly easily if
you want more contorl.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]