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:1119)
        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".

Reply via email to