* points.
*/
public void setGrabPoints() {
int renderType = raster.getRenderType();
LatLonPoint llp1;
Debug.message("eomg", "EditableOMScalingRaster.setGrabPoints()");
// Do center point for lat/lon or offset rects
if (renderType == OMGraphic.RENDERTYPE_LATLON) {
if (projection != null) {
if (raster instanceof OMScalingIcon) {
setGrabPointsForOMSI();
return;
}
// Need to figure out which point was moved, and then
// set the upper left and lower right points
// accordingly.
if (movingPoint == gpne) {
llp1 = projection.inverse(gpne.getX(), gpne.getY());
raster.setULLat(llp1.getLatitude());
raster.setLRLon(llp1.getLongitude());
} else if (movingPoint == gpnw) {
llp1 = projection.inverse(gpnw.getX(), gpnw.getY());
raster.setULLat(llp1.getLatitude());
raster.setULLon(llp1.getLongitude());
} else if (movingPoint == gpsw) {
llp1 = projection.inverse(gpsw.getX(), gpsw.getY());
raster.setLRLat(llp1.getLatitude());
raster.setULLon(llp1.getLongitude());
} else if (movingPoint == gpse) {
llp1 = projection.inverse(gpse.getX(), gpse.getY());
LatLonPoint llp2 = projection.inverse(gpnw.getX(),
gpnw.getY());
raster.setULLat(llp2.getLatitude());
raster.setULLon(llp2.getLongitude());
raster.setLRLat(llp1.getLatitude());
raster.setLRLon(llp1.getLongitude());
} else {
//movingPoint == gpc
llp1 = projection.inverse(gpc.getX(), gpc.getY());
raster.setULLat(llp1.getLatitude() + diffy);
raster.setULLon(llp1.getLongitude() - diffx);
raster.setLRLat(llp1.getLatitude() - diffy);
raster.setLRLon(llp1.getLongitude() + diffx);
}
raster.setNeedToRegenerate(true);
}
}
boolean settingOffset = getStateMachine().getState() instanceof GraphicSetOffsetState
&& movingPoint == gpo;
// If the center point is moving, the offset distance changes
if (renderType == OMGraphic.RENDERTYPE_OFFSET) {
llp1 = projection.inverse(gpo.getX(), gpo.getY());
raster.setULLat(llp1.getLatitude());
raster.setULLon(llp1.getLongitude());
if (settingOffset || movingPoint == gpc) {
int halfheight = (gpse.getY() - gpnw.getY()) / 2;
int halfwidth = (gpse.getX() - gpnw.getX()) / 2;
// Don't call rect.setLocation because we only want to
// setNeedToRegenerate if !settingOffset.
llp1 = projection.inverse(gpc.getX() - halfwidth - gpo.getX(),
gpc.getY() - halfheight - gpo.getY());
LatLonPoint llp2 = projection.inverse(gpc.getX() + halfwidth
- gpo.getX(), gpc.getY() + halfheight - gpo.getY());
raster.setULLat(llp1.getLatitude());
raster.setULLon(llp1.getLongitude());
raster.setLRLat(llp2.getLatitude());
raster.setLRLon(llp2.getLongitude());
}
if (!settingOffset) {
Debug.message("eomg",
"EditableOMScalingRaster: updating offset rect");
if (movingPoint == gpnw || movingPoint == gpse) {
llp1 = projection.inverse(gpnw.getX() - gpo.getX(),
gpnw.getY() - gpo.getY());
LatLonPoint llp2 = projection.inverse(gpse.getX()
- gpo.getX(), gpse.getY() - gpo.getY());
raster.setULLat(llp1.getLatitude());
raster.setULLon(llp1.getLongitude());
raster.setLRLat(llp2.getLatitude());
raster.setLRLon(llp2.getLongitude());
} else if (movingPoint == gpne || movingPoint == gpsw) {
llp1 = projection.inverse(gpsw.getX() - gpo.getX(),
gpne.getY() - gpo.getY());
LatLonPoint llp2 = projection.inverse(gpne.getX()
- gpo.getX(), gpsw.getY() - gpo.getY());
raster.setULLat(llp1.getLatitude());
raster.setULLon(llp1.getLongitude());
raster.setLRLat(llp2.getLatitude());
raster.setLRLon(llp2.getLongitude());
}
raster.setNeedToRegenerate(true);
}
// Set Location has reset the rendertype, but provides
// the convenience of setting the max and min values
// for us.
raster.setRenderType(OMGraphic.RENDERTYPE_OFFSET);
}
// Do the rect height and width for XY and OFFSET render
// types.
if (renderType == OMGraphic.RENDERTYPE_XY) {
Debug.message("eomg", "EditableOMScalingRaster: updating x/y rect");
if (movingPoint == gpc) {
int halfheight = (gpse.getY() - gpnw.getY()) / 2;
int halfwidth = (gpse.getX() - gpnw.getX()) / 2;
llp1 = projection.inverse(gpc.getX() - halfwidth, gpc.getY()
- halfheight);
LatLonPoint llp2 = projection.inverse(gpc.getX() + halfwidth,
gpc.getY() + halfheight);
raster.setULLat(llp1.getLatitude());
raster.setULLon(llp1.getLongitude());
raster.setLRLat(llp2.getLatitude());
raster.setLRLon(llp2.getLongitude());
} else if (movingPoint == gpnw || movingPoint == gpse) {
llp1 = projection.inverse(gpnw.getX(), gpnw.getY());
LatLonPoint llp2 = projection.inverse(gpse.getX(), gpse.getY());
raster.setULLat(llp1.getLatitude());
raster.setULLon(llp1.getLongitude());
raster.setLRLat(llp2.getLatitude());
raster.setLRLon(llp2.getLongitude());
} else if (movingPoint == gpne || movingPoint == gpsw) {
llp1 = projection.inverse(gpsw.getX(), gpne.getY());
LatLonPoint llp2 = projection.inverse(gpne.getX(), gpsw.getY());
raster.setULLat(llp1.getLatitude());
raster.setULLon(llp1.getLongitude());
raster.setLRLat(llp2.getLatitude());
raster.setLRLon(llp2.getLongitude());
}
}
if (projection != null) {
regenerate(projection);