/*
 * Licensed Materials - Property of Rogue Wave Software, Inc. 
 * © Copyright Rogue Wave Software, Inc. 2014, 2015 
 * © Copyright IBM Corp. 2009, 2014
 * © Copyright ILOG 1996, 2009
 * All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:
 * The Software and Documentation were developed at private expense and
 * are "Commercial Items" as that term is defined at 48 CFR 2.101,
 * consisting of "Commercial Computer Software" and
 * "Commercial Computer Software Documentation", as such terms are
 * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4,
 * as applicable.
 */

import ilog.views.IlvPoint;
import ilog.views.IlvRect;
import ilog.views.graphic.IlvLabel;
import ilog.views.graphic.IlvRectangle;
import ilog.views.io.IlvOutputStream;
import ilog.views.tiling.IlvTile;
import ilog.views.tiling.IlvTileLoader;


public class LodLoader implements IlvTileLoader
{
  /**
   * This variable stores the layer name
   */
  private String layerName;
  /**
   * Constructs a new loader with specified name
   */
  public LodLoader(String name) {
    layerName = name;
  }

  /**
   * Loads the graphic objects for specified tile.
   * For this example, this simulate loading of data by generating
   * graphic objects
   */
  public void load(IlvTile tile) throws Exception
  {
    IlvRect bbox = new IlvRect();
    tile.boundingBox(bbox);

    // Generate graphic for this tile boundaries
    tile.addObject(new IlvRectangle(bbox),null);

    // Add a little text
    String text = this.layerName + 
      " (" + tile.getColumn() + "," + tile.getRow() + ")";
    IlvPoint textCenter = new IlvPoint(bbox.x + bbox.width / 2,
                                       bbox.y + bbox.height / 2);
    tile.addObject(new IlvLabel(textCenter,text),null);

    tile.loadComplete();
  }
  /**
   * Release the objects on this tile
   */
  public void release(IlvTile tile) 
  {
    tile.deleteAll();
  }

  // This loader is not persistent, so these methodes need not to
  // be active
  public boolean isPersistent() {
    return false;
  }
  public void write(IlvOutputStream stream) 
  {
  }
  
}