Nick,
As Phil replied earlier - it seems the font maybe getting messed up. Could you
send me a code snippet or check the params of the current font if they are
reasonable. You may also change the point size etc, and see if they make a
difference. Try changing the clip regions if they have an effect. Are you using
JDK 1.2 or JDK 1.2.2 ?
>X-Accept-Language: en
>Content-Transfer-Encoding: 7bit
>Date: Tue, 11 Jan 2000 13:40:18 -0600
>From: Nick Collier <[EMAIL PROTECTED]>
>Subject: [JAVA2D] Problem drawing Strings
>To: [EMAIL PROTECTED]
>
>Hi,
>
>I asked this once before and someone from sun said he or she would look
>into it. I'd like to know if anyone knows how to fix it, or a workaround
>as it is causing some problems. Couldn't find it in the Bug database
>either.
>
>I'm trying to draw Strings (see code snippet below) and every now and
>then I get the following Exception.
>
>java.lang.IllegalArgumentException: Font
> at sun.awt.font.NativeFontWrapper.drawStringIntDiscreteRaster(Native
>Method)
> at
>sun.java2d.loops.ICRDrawStringRasterContext.invoke(TextRendering.java:330)
> at
>sun.awt.image.BufferedImageGraphics2D.drawString(BufferedImageGraphics2D.java:1
119)
> at sun.java2d.pipe.ValidatePipe.drawString(ValidatePipe.java:124)
> at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2206)
> at uchicago.src.sim.gui.SimGraphics.drawString(SimGraphics.java:365)
> at
>uchicago.src.sim.gui.SimGraphics.drawStringInOval(SimGraphics.java:308)
> at uchicago.src.sim.gui.OvalItem.draw(OvalItem.java:19)
> at
>uchicago.src.sim.gui.Network2DDisplay.drawDisplay(Network2DDisplay.java:61)
> at uchicago.src.sim.gui.LocalPainter.paint(LocalPainter.java:107)
> at
>uchicago.src.sim.gui.DisplaySurface.updateDisplay(DisplaySurface.java:276)
> at uchicago.src.sim.test.OvalTest$1.run(OvalTest.java:57)
> at java.lang.Thread.run(Thread.java:479)
>
>If someone could tell me what was going on in the native code
>sun.awt.font.NativeFontWraper... maybe I could work around it by
>fiddling with the font or something. The drawing code:
>
> public void drawString(String string, Color stringColor) {
> Shape shape = g2.getClip();
> g2.setClip(curX, curY, curWidth, curHeight);
> drawInit(stringColor);
> FontRenderContext rContext = g2.getFontRenderContext();
> Rectangle2D bounds = currentFont.getStringBounds(string, rContext);
>
> int xCenter = curX + curWidth / 2;
> int yCenter = curY + curHeight / 2;
>
> int strX = xCenter - (int)bounds.getCenterX();
> int strY = yCenter - (int)bounds.getCenterY();
>
> g2.drawString(string, strX, strY); <= Exception
>thrown here
> g2.setClip(shape);
> }
>
>This could hold up the release of some simulation software we are
>developing here, so any suggestions would be appreciated.
>
>thanks,
>
>Nick
>
>
>--
>Nick Collier
>Social Science Research Computing
>University of Chicago
>
>[EMAIL PROTECTED]
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff JAVA2D-INTEREST". For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
Parry Kejriwal
Fonts & Text JAVA 2D
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".