public OMGraphic generate(OMGrid grid,Projection proj){
  Debug.message("grid","SimpleColorGenerator: generating OMRaster from grid");
  if (grid.height <= 0 || grid.width <= 0) {
    Debug.message("grid","SimpleColorGenerator: grid height/width ZERO!");
    return SinkGraphic.getSharedInstance();
  }
  OMRaster raster=new OMRaster(grid.point1.x,grid.point1.y,grid.width,grid.height,new int[grid.width * grid.height]);
  int rows=grid.getRows();
  int columns=grid.getColumns();
  RasterHelper rasterHelper=getRasterHelper(grid.getData());
  boolean major=grid.getMajor();
  double y_interval=(double)rows / (double)grid.height;
  double x_interval=(double)columns / (double)grid.width;
  Debug.message("grid","SimpleColorGenerator: y_point_interval = " + y_interval + ", x_point_interval = "+ x_interval);
  int post_x, post_y, value;
  for (int x=0; x < grid.width; x++) {
    for (int y=0; y < grid.height; y++) {
      post_x=(int)Math.round(x_interval * (double)x);
      if (grid.getRenderType() == OMGraphic.RENDERTYPE_LATLON) {
        post_y=(int)Math.round(y_interval * (grid.height - 1 - (double)y));
      }
 else {
        post_y=(int)Math.round(y_interval * (double)y);
      }
      if (major == OMGrid.COLUMN_MAJOR) {
        if (post_x >= columns)         post_x=columns - 1;
        if (post_y >= rows)         post_y=rows - 1;
        value=calibratePointValue(rasterHelper.get(post_x,post_y));
      }
 else {
        if (post_y >= columns)         post_y=columns - 1;
        if (post_x >= rows)         post_x=rows - 1;
        value=calibratePointValue(rasterHelper.get(post_y,post_x));
      }
      raster.setPixel(x,y,value);
    }
  }
  raster.generate(proj);
  return raster;
}

public OMGraphic generate ( OMGrid grid , Projection proj ) { Debug . message ( "grid" , "SimpleColorGenerator: generating OMRaster from grid" ) ; if ( grid . height <= 0 || grid . width <= 0 ) { Debug . message ( "grid" , "SimpleColorGenerator: grid height/width ZERO!" ) ; return SinkGraphic . getSharedInstance ( ) ; } OMRaster raster = new OMRaster ( grid . point1 . x , grid . point1 . y , grid . width , grid . height , new int [ grid . width * grid . height ] ) ; int rows = grid . getRows ( ) ; int columns = grid . getColumns ( ) ; RasterHelper rasterHelper = getRasterHelper ( grid . getData ( ) ) ; boolean major = grid . getMajor ( ) ; double y_interval = ( double ) rows / ( double ) grid . height ; double x_interval = ( double ) columns / ( double ) grid . width ; Debug . message ( "grid" , "SimpleColorGenerator: y_point_interval = " + y_interval + ", x_point_interval = " + x_interval ) ; int post_x , post_y , value ; for ( int x = 0 ; x < grid . width ; x ++ ) { for ( int y = 0 ; y < grid . height ; y ++ ) { post_x = ( int ) Math . round ( x_interval * ( double ) x ) ; if ( grid . getRenderType ( ) == OMGraphic . RENDERTYPE_LATLON ) { post_y = ( int ) Math . round ( y_interval * ( grid . height - 1 - ( double ) y ) ) ; } else { post_y = ( int ) Math . round ( y_interval * ( double ) y ) ; } if ( major == OMGrid . COLUMN_MAJOR ) { if ( post_x >= columns ) post_x = columns - 1 ; if ( post_y >= rows ) post_y = rows - 1 ; value = calibratePointValue ( rasterHelper . get ( post_x , post_y ) ) ; } else { if ( post_y >= columns ) post_y = columns - 1 ; if ( post_x >= rows ) post_x = rows - 1 ; value = calibratePointValue ( rasterHelper . get ( post_y , post_x ) ) ; } raster . setPixel ( x , y , value ) ; } } raster . generate ( proj ) ; return raster ; }
going to return an omraster , sized to the current projection , and colored according to the colortable . the grid values are indexes into the colortable . the grid should already be generated when it gets here - meaning that the bounds and parameters of the grid , as they apply to the projection , are figured out .
