public synchronized boolean generate(Projection proj){
  double upLat;
  int columns=getColumns();
  int rows=getRows();
  super.clear();
  setShape(null);
  if (renderType == RENDERTYPE_LATLON) {
    double rightLon;
    rightLon=longitude + columns * horizontalResolution;
    upLat=latitude + rows * verticalResolution;
    point1=(Point)proj.forward(upLat,longitude,new Point());
    point2=(Point)proj.forward(latitude,rightLon,new Point());
    height=point2.y - point1.y;
    width=point2.x - point1.x;
    if (Debug.debugging("grid")) {
      Debug.output("OMGrid.generate:  height = " + height + ", width = "+ width);
    }
  }
 else   if (renderType == RENDERTYPE_XY || renderType == RENDERTYPE_OFFSET) {
    width=(int)Math.round(columns * horizontalResolution);
    height=(int)Math.round(rows * verticalResolution);
    if (renderType == RENDERTYPE_OFFSET) {
      upLat=latitude + columns * verticalResolution;
      point1=(Point)proj.forward(upLat,longitude,new Point());
      point1.x+=point.x;
      point1.y+=point.y;
    }
 else {
      point1=point;
    }
    point2=new Point(point1.x + width,point1.y + height);
  }
 else {
    return false;
  }
  if (Debug.debugging("grid")) {
    Debug.output("OMGrid generated grid, at " + point1 + " and "+ point2+ " with height "+ height+ " and width "+ width);
  }
  setShape();
  if (generator != null && generator.needGenerateToRender()) {
    add(generator.generate(this,proj));
  }
 else   if (gridObjects != null) {
    add(generateGridObjects(proj));
  }
  setLabelLocation(getShape(),proj);
  setNeedToRegenerate(false);
  return true;
}

public synchronized boolean generate ( Projection proj ) { double upLat ; int columns = getColumns ( ) ; int rows = getRows ( ) ; super . clear ( ) ; setShape ( null ) ; if ( renderType == RENDERTYPE_LATLON ) { double rightLon ; rightLon = longitude + columns * horizontalResolution ; upLat = latitude + rows * verticalResolution ; point1 = ( Point ) proj . forward ( upLat , longitude , new Point ( ) ) ; point2 = ( Point ) proj . forward ( latitude , rightLon , new Point ( ) ) ; height = point2 . y - point1 . y ; width = point2 . x - point1 . x ; if ( Debug . debugging ( "grid" ) ) { Debug . output ( "OMGrid.generate:  height = " + height + ", width = " + width ) ; } } else if ( renderType == RENDERTYPE_XY || renderType == RENDERTYPE_OFFSET ) { width = ( int ) Math . round ( columns * horizontalResolution ) ; height = ( int ) Math . round ( rows * verticalResolution ) ; if ( renderType == RENDERTYPE_OFFSET ) { upLat = latitude + columns * verticalResolution ; point1 = ( Point ) proj . forward ( upLat , longitude , new Point ( ) ) ; point1 . x += point . x ; point1 . y += point . y ; } else { point1 = point ; } point2 = new Point ( point1 . x + width , point1 . y + height ) ; } else { return false ; } if ( Debug . debugging ( "grid" ) ) { Debug . output ( "OMGrid generated grid, at " + point1 + " and " + point2 + " with height " + height + " and width " + width ) ; } setShape ( ) ; if ( generator != null && generator . needGenerateToRender ( ) ) { add ( generator . generate ( this , proj ) ) ; } else if ( gridObjects != null ) { add ( generateGridObjects ( proj ) ) ; } setLabelLocation ( getShape ( ) , proj ) ; setNeedToRegenerate ( false ) ; return true ; }
generate omgraphics based on the data array . if there is an omgridgenerator , it will be used to generate omgraphics from the data array . if not , the omgridobjects will be used to create omgraphics for the map .
