0 Replies Latest reply: Jun 18, 2013 11:43 AM by d860698f-5e04-4406-aa95-efe1baf05db0 RSS

    JavaFX strokeText+translate+clip bug

    d860698f-5e04-4406-aa95-efe1baf05db0

      I think I'm running into a bug in JavaFX (2.2.21-b11). If I try to draw text while also using translate and clip, it doesn't work. Basically what I'm trying to do is draw a grid onto a GraphicsContext, but I want all the contents of the cells of the grid to be clipped to their cell bounds. To do that I'm setting/resetting the clip path with gc.save/restore and using translate to move to the various cell locations. For instance:

       

      gc.save

      gc.beginPath

      gc.rect(0.0, 100.0, 199.0, 99.0)

      gc.clip

       

      gc.translate(0.0, 100.0)

      gc.strokeText("Column 0, Row 1", 45.43701171875, 54.4130859375)

      gc.restore

       

      Should show text, but doesn't. If you comment out the clipping stuff though it works fine:

       

      gc.save

      gc.translate(0.0, 100.0)

      gc.strokeText("Column 0, Row 1", 45.43701171875, 54.4130859375)

      gc.restore

       

      Also if you don't translate (and shift the clip rect back accordingly) it works.

       

      gc.save

      gc.beginPath

      gc.rect(0.0, 0.0, 199.0, 99.0)

      gc.clip

       

      gc.translate(0.0, 0.0)

      gc.strokeText("Column 0, Row 0", 45.43701171875, 54.4130859375)

      gc.restore

       

      But if you put everything together, it doesn't.  :-(  Am I doing something wrong? Or is this really a bug?

       

      Thanks,

      Edwin