okay I got it :) the second example with the JTextArea works perfect, except for Firefox: If you write font-size:28; instead of font-size:28px; => all Text will be in some sort of default size (but line-height is correct). So that is definitely a Firefox Bug and not a Batik Issue.
thanks & keep up got work, I really like the Batik Toolkit! You can add "OpenMeetings" http://code.google.com/p/openmeetings/ to the Open-Source Projects using Batik if you like. sebastian 2008/10/17 Sebastian Wagner <[EMAIL PROTECTED]> > hi, > > hope you can give me a hint how to handle multi-line text. > I tried different approaches to create multi-line Text Objects. > > Is there an Example of how-to create Multi-Line Text-Object* using DOM or > Graphics2D*? Only Display, NO input-textfield, NO Skripting. I want to > convert the SVG later on into PNG so a Skripted Multi-Line Text like > http://www.carto.net/papers/svg/textFlow/index.svg is not usable for me as > ImageMagick does not render these Skripts. > > > the problem is that I never had good results in trying DOM or Graphics2D: > > With DOM: > > http://openmeetings.googlecode.com/svn/trunk/webapp/src/test/org/openmeetings/batik/TestSimpleSVGDom.java > => the resulting Document does not contain anything! > > With Graphics2D using JTextArea (AWT/SWING): > public void _drawText(Graphics2D g2d, int x, int y, int width, int height, > String text, String default_export_font, int style, int size, > Color fontColor) throws Exception { > > Font font = new Font("Verdana", style, size); > String[] stringsText = text.split("\r"); > log.debug("TEXT: "+stringsText); > log.debug("TEXT: "+stringsText.length); > > String newText = ""; > > for (int i=0;i<stringsText.length;i++) { > newText += stringsText[i]; > if (i+1<stringsText.length) { > newText += "\n"; > } > } > > JTextArea n = new JTextArea( newText ); > n.setFont(font); > n.setWrapStyleWord( true ); > n.setLineWrap( true ); > n.setForeground( fontColor ); > > log.debug("Text at: "+x+" "+y); > n.setBounds( x, y , width, height ); > n.setOpaque( false ); > > //Text > SVGGraphics2D svgGenerator2 = (SVGGraphics2D) g2d.create(x, y, > width, height); > svgGenerator2.setColor(fontColor); > svgGenerator2.setPaint(fontColor); > n.paint( svgGenerator2 ); > } > => It does not contain the correct Font-Size (the resulting SVG will > contain font-size:11 instead of font-size:11px ... so the *px* is missing > which leads to an ignored font-size attribute) > > > thank you very much > > -- > Sebastian Wagner > http://www.webbase-design.de > http://openmeetings.googlecode.com > http://www.laszlo-forum.de > [EMAIL PROTECTED] > -- Sebastian Wagner http://www.webbase-design.de http://openmeetings.googlecode.com http://www.laszlo-forum.de [EMAIL PROTECTED]
