Package chunmap.view.layer

Source Code of chunmap.view.layer.LayerCollection

/**
* Copyright (c) 2009-2011, chunquedong(YangJiandong)
*
* This file is part of ChunMap project
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
*
* History:
*     2010-05-05  Jed Young  Creation
*/
package chunmap.view.layer;

import java.util.ArrayList;
import java.util.List;

import chunmap.model.elem.Envelope;
import chunmap.model.elem.EnvelopeBuf;
import chunmap.view.Renderer;
/**
* 图层集合
* @author chunquedong
*
*/
public class LayerCollection {
  private Layer decorateLayer;// 装饰层
  private Layer selectedLayer;// 选择层
  private List<Layer> layers = new ArrayList<Layer>();
  private Envelope envelop;

  public void add(Layer layer) {
    layers.add(layer);
    reComputeEnvelop();
  }

  public void render(Renderer r) {
    for (Layer lyr : layers) {
      lyr.render(r);
    }
    if (selectedLayer != null)
      selectedLayer.render(r);
    if (decorateLayer != null)
      decorateLayer.render(r);
  }

  public Envelope getEnvelop() {
    return envelop;
  }

  public void reComputeEnvelop() {
    EnvelopeBuf env = new EnvelopeBuf();
    for (Layer lyr : layers) {
      env.mergeEnvelop(lyr.getEnvelop());
    }
    envelop = env.toEnvelop();
  }

  public Layer getDecorateLayer() {
    return decorateLayer;
  }

  public void setDecorateLayer(Layer decorateLayer) {
    this.decorateLayer = decorateLayer;
  }

  public Layer getSelectedLayer() {
    return selectedLayer;
  }

  public void setSelectedLayer(Layer selectedLayer) {
    this.selectedLayer = selectedLayer;
  }

  public List<Layer> getLayers() {
    return layers;
  }

  public void setLayers(List<Layer> layers) {
    this.layers = layers;
    reComputeEnvelop();
  }
}
TOP

Related Classes of chunmap.view.layer.LayerCollection

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.