float lat, lon;
    protected OMGraphic createImage(Projection projection) {        if (currentTime)            overlayTime = System.currentTimeMillis();        if (Debug.debugging("daynight")) {            Debug.output("DayNightLayer: Calculating sun position at time "                    + Long.toString(overlayTime));        }        LatLonPoint brightPoint = SunPosition.sunPosition(overlayTime);        Debug.message("daynight", "DayNightLayer: Calculated sun position");        // Do a fast and relatively inexpensive calculation of the        // terminator. NOTE: for non-cylindrical projections we don't        // create a full-hemisphere circle so that we don't get        // flip-rendering problem...        if (doPolyTerminator) {            Debug.message("daynight",                    "DayNightLayer:  Creating polygon terminator");            LatLonPoint darkPoint = GreatCircle.spherical_between(brightPoint.radlat_,                    brightPoint.radlon_,                    (float) Math.PI,                    (float) Math.PI / 4f);            OMCircle circle = new OMCircle(darkPoint, (projection instanceof Cylindrical) ? 90f                    : 89.0f,//HACK                    Length.DECIMAL_DEGREE, terminatorVerts);            circle.setPolarCorrection(true);            circle.setFillPaint(nighttimeColor);            circle.setLinePaint(nighttimeColor);            circle.generate(projection);            Debug.message("daynight",                    "DayNightLayer: Done creating polygon terminator");            return circle;        }        int width = projection.getWidth();        int height = projection.getHeight();        int[] pixels = new int[width * height];        OMRaster ret = new OMRaster((int) 0, (int) 0, width, height, pixels);        float lat, lon;        Debug.message("daynight", getName()                + "|createImage: Center of bright spot lat= "                + brightPoint.getLatitude() + ", lon= "                + brightPoint.getLongitude());        // Light is clear and/or white        int light = daytimeColor.getRGB();        // Allocate the memory here for the testPoint        LatLonPoint testPoint = new LatLonPoint(0f, 0f);        // great circle distance between the bright point and each        // pixel.        float distance;        //  Set the darkeness value        int dark = nighttimeColor.getRGB();// ARGB        int darkness = dark >>> 24;// darkness alpha        int value;        // Calculate the fae limits around the terminator        float upperFadeLimit = (float) (MoreMath.HALF_PI * (1.0 + termFade));        float lowerFadeLimit = (float) (MoreMath.HALF_PI * (1.0 - termFade));        int fadeColorValue = 0x00FFFFFF & (dark); // RGB        for (int i = 0; i < width; i++) {            for (int j = 0; j < height; j++) {                testPoint = projection.inverse(i, j, testPoint);                distance = GreatCircle.spherical_distance(brightPoint.radlat_,                        brightPoint.radlon_,                        testPoint.radlat_,                        testPoint.radlon_);                if (distance > upperFadeLimit) {                    pixels[j * width + i] = dark;                } else if (distance > lowerFadeLimit) {                    value = (int) (darkness * (1 - ((upperFadeLimit - distance) / (upperFadeLimit - lowerFadeLimit))));                    value <<= 24;                    pixels[j * width + i] = fadeColorValue | value;                } else {                    pixels[j * width + i] = light;                }            }        }        ret.generate(projection);        return ret;    }