Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] ExternalGraphic style issue

Hi,

There is some bug in case style contains ExternalGraphics.

in net.refractions.udig.ui.Drawing we call drawImage around line 360, this
causes some exception with illegal value or something, when layer view
ui component
is visible and it try to draw external graphic image next to layer name.

The reason is net.refractions.udig.ui.graphics.Glyph at line 156:
     d.drawDirect( image, display, d.feature(d.point(7,7)), rule );

That d.feature(d.point(7,7))  transform image with 7,7 pixel.

Now what will happen in net.refractions.udig.ui.Drawing.paint around line 360:

g.drawImage(image,
(int)(point[0]-((double)image.getWidth())/(double)2),
(int)(point[1]-((double)image.getHeight())/(double)2));

which is call to NonAdvancedSWTGrapghics.drawImage:

   public void drawImage(RenderedImage rimage, int x, int y) {
        drawImage(rimage, 0, 0, rimage.getWidth(), rimage.getHeight(), x, y, x
                + rimage.getWidth(), y + rimage.getHeight());   //
------- HERE IS THE PROBLEM ------------
    }

.. now what will happend is that source image area is always outside
of the image, for example if we
have image which size is 40,40, the source area is going to be 7,7/47,47.

My quickfix suggesion is just change the line in
net.refractions.udig.ui.Drawing.paint around line 360:

g.drawImage(image,
(int)(point[0]-((double)image.getWidth())/(double)2),
(int)(point[1]-((double)image.getHeight())/(double)2));
to
g.drawImage(image, 0, 0);

We could however directly to call
NonAdvancedSWTGrapghics.drawImage(RenderedImage rimage, int, int, int,
int, int ....) with
correct values but maby that should also describe in ViewportGraphics interface?


- Artsi


Back to the top