// handle CADRG
if (projection instanceof CADRG) {
// get corners
LatLonPoint ul = projection.getUpperLeft();
LatLonPoint lr = projection.getLowerRight();
// set start/end indicies
Point ulp = projection.forward(ul);
Point lrp = projection.forward(lr);
sx = (int) ulp.getX();
ex = (int) lrp.getX();
sy = (int) ulp.getY();
ey = (int) lrp.getY();
}
// get the center lat/lon (used by the HACK, see above in
// method description)
LatLonPoint center = projection.getCenter();
LatLonPoint llp = new LatLonPoint();
// build array
for (int y = sy; y < ey; y++) {
// process each column
for (int x = sx; x < ex; x++) {
// inverse project x,y to lon,lat
projection.inverse(x, y, llp);
// get point values
float lat = llp.getLatitude();
float lon = llp.getLongitude();
// check... dfd
if (minuteSpacing == 2) {
lon += 180.;
} else {
if (lon < 0.)
lon += 360.;
}
// find indicies
int lat_idx = (int) ((90. - lat) * scy);
int lon_idx = (int) (lon * scx);
// offset
int ofs = lon_idx + lat_idx * bufferWidth;
// make a color
int idx = 0;
int gray = 0;
try {
// get elevation
short el = dataBuffer[ofs];
// slope
byte sl = slopeMap[ofs];
// our index
idx = y * width + x;
// create a color
Color pix = null;
if (viewType == SLOPESHADING) {
// HACK (see method description above)
if ((llp.getLatitude() == center.getLatitude())
&& (llp.getLongitude() == center.getLongitude()))
gray = 0;
else
gray = 127 + sl;
pix = new Color(gray, gray, gray, opaqueness);
} else if (viewType == COLOREDSHADING) {
// HACK (see method description above)
if ((llp.getLatitude() == center.getLatitude())
&& (llp.getLongitude() == center.getLongitude()))
pix = new Color(0, 0, 0, opaqueness);
else
pix = getColor(el, sl);
}