Package org.geomajas.widget.advancedviews.client.util

Source Code of org.geomajas.widget.advancedviews.client.util.LayerIconHelper

/*
* This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
*
* Copyright 2008-2011 Geosparc nv, http://www.geosparc.com/, Belgium.
*
* The program is available in open source according to the GNU Affero
* General Public License. All contributions in this program are covered
* by the Geomajas Contributors License Agreement. For full licensing
* details, see LICENSE.txt in the project root.
*/
package org.geomajas.widget.advancedviews.client.util;

import org.geomajas.gwt.client.map.layer.Layer;
import org.geomajas.gwt.client.map.layer.RasterLayer;
import org.geomajas.gwt.client.map.layer.VectorLayer;
import org.geomajas.widget.advancedviews.configuration.client.ExtraLayerInfo;

import com.smartgwt.client.widgets.Img;

/**
* Helper class for working with layerIcons.
*
* @author Kristof Heirwegh
*
*/
public final class LayerIconHelper {

  private static final String LAYER_LABEL_OVERLAY_URL = "[ISOMORPHIC]/geomajas/layerIcons/layer_label_overlay.png";
  private static final String LAYER_TRANSPARENCY_UNDERLAY_URL = "[ISOMORPHIC]/geomajas/layerIcons/layer_transparenc" +
      "y_underlay.png";
  private static final String LAYER_RASTER_ICON_LARGE_URL = "[ISOMORPHIC]/geomajas/layerIcons/raster_icon_large.png";
  private static final String LAYER_VECTOR_POINT_ICON_LARGE_URL = "[ISOMORPHIC]/geomajas/layerIcons/vector_point_ic" +
      "on_large.png";
  private static final String LAYER_VECTOR_LINE_ICON_LARGE_URL = "[ISOMORPHIC]/geomajas/layerIcons/vector_line_icon" +
      "_large.png";
  private static final String LAYER_VECTOR_POLYGON_ICON_LARGE_URL = "[ISOMORPHIC]/geomajas/layerIcons/vector_polygo" +
      "n_icon_large.png";

  private LayerIconHelper() {
  }

  public static Img getSmallLayerIcon(Layer<?> layer) {
    String url = getSmallLayerIconUrl(layer);
    if (url != null) {
      return new Img(url);
    } else {
      return null;
    }
  }

  public static String getSmallLayerIconUrl(Layer<?> layer) {
    ExtraLayerInfo eli = WidgetInfoHelper.getClientWidgetInfo(ExtraLayerInfo.IDENTIFIER, ExtraLayerInfo.class,
        layer);
    if (eli != null) {
      return eli.getSmallLayerIconUrl();
    } else {
      return null;
    }
  }

  public static Img getLargeLayerIcon(Layer<?> layer) {
    ExtraLayerInfo eli = WidgetInfoHelper.getClientWidgetInfo(ExtraLayerInfo.IDENTIFIER, ExtraLayerInfo.class,
        layer);
    if (eli != null) {
      return new Img(eli.getLargeLayerIconUrl());
    } else {
      if (layer instanceof RasterLayer) {
        return new Img(LAYER_RASTER_ICON_LARGE_URL);
      } else {
        switch (((VectorLayer) layer).getLayerInfo().getLayerType()) {
        case POINT:
        case MULTIPOINT:
          return new Img(LAYER_VECTOR_POINT_ICON_LARGE_URL);

        case LINESTRING:
        case MULTILINESTRING:
          return new Img(LAYER_VECTOR_LINE_ICON_LARGE_URL);

        case POLYGON:
        case MULTIPOLYGON:
          return new Img(LAYER_VECTOR_POLYGON_ICON_LARGE_URL);

        default:
          return new Img(""); // should not happen
        }
      }
    }
  }

  public static Img getLegendImage(Layer<?> layer) {
    ExtraLayerInfo eli = WidgetInfoHelper.getClientWidgetInfo(ExtraLayerInfo.IDENTIFIER, ExtraLayerInfo.class,
        layer);
    if (eli != null) {
      return new Img(eli.getLegendImageUrl());
    } else {
      return null;
    }
  }

  public static Img getLabelOverlayImg() {
    return new Img(LAYER_LABEL_OVERLAY_URL);
  }

  public static Img getTransparencyUnderlayImg() {
    return new Img(LAYER_TRANSPARENCY_UNDERLAY_URL);
  }
}
TOP

Related Classes of org.geomajas.widget.advancedviews.client.util.LayerIconHelper

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.