Don,
I think I found a bug in OMRasterObject when dealing with rotating an
OMScalingRaster object. What I was seeing was when I scaled a raster
and then used setRotationAngle() the image floated around the map when I
zoomed in and zoomed out. I looked in the code and found the affine
transform happening in the OMRasterObject's method render(Graphics g).
basically I changed the way the affine transform was handling the
translation and rotation by including the rotation and translation info
in one matrix operation rather than two. Everything seems likes it
works correctly now. See the code below for the code I commented out of
the OMRasterObject's render() method and the code I added. If someone
needed an easy fix for OMScalingRaster they could override the render
method in the OMScalingRaster class and use the code below. Can you
take a look at this and see if it looks right to you? Thanks in
advance.
public void render(Graphics g) {
if (getNeedToRegenerate() || getNeedToReposition() ||
!isVisible()) {
if (DEBUG) Debug.output("OMRasterObject.render(): need to
regenerate or not visible!");
return;
}
//copy the graphic, so our transform doesn't cascade to
others...
g = g.create();
// Just a little check to find out if someone is rushing
// things. If a Image isn't fully loaded, the getWidth will
// return -1. This is just a courtesy notification in case
// someone isn't seeing their image, and don't know why.
if (colorModel == COLORMODEL_IMAGEICON && (getWidth() == -1)) {
Debug.error("OMRasterObject.render: Attempting to draw a
Image that is not ready! Image probably wasn't available.");
}
if (bitmap != null)
{
if (isMatted())
{
super.render(g);
}
// new affine transform added by Martin Chapman 04/05/04
AffineTransform at = new
AffineTransform(Math.cos(rotationAngle),
Math.sin(rotationAngle),
-Math.sin(rotationAngle),
Math.cos(rotationAngle),
point1.x,
point1.y);
//if (g instanceof Graphics2D && rotationAngle !=
DEFAULT_ROTATIONANGLE)
// {
//rotate about our image center point
// ( (Graphics2D) g).rotate(rotationAngle, point1.x +
width / 2, point1.y + height / 2);
// }
if (DEBUG)
{
Debug.output("OMRasterObject.render() | drawing " +
width + "x" + height + " image at " +
point1.x + ", " + point1.y);
}
if (g instanceof Graphics2D && bitmap instanceof
RenderedImage)
{
// Affine translation for placement...
((Graphics2D)g).drawRenderedImage((BufferedImage)bitmap,
at);
// Undo the affine translation for future graphics??
//((Graphics2D)g).translate(-point1.x, -point1.y);
}
else
{
g.drawImage(bitmap, point1.x, point1.y, this);
}
}
else
{
if (DEBUG) Debug.output("OMRasterObject.render: ignoring
null bitmap");
}
if (Debug.debugging("rasterobjects")) {
super.render(g);
}
}
Martin Chapman
Cell 303-885-1936
Office 303-660-3933 x226
mchapman@sanz.com
http://www.sanz.com <http://www.sanz.com/>
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Mon Apr 5 18:53:15 2004
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:38 EDT