All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gwtopenmaps.openlayers.client.control.DrawFeature Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package org.gwtopenmaps.openlayers.client.control;

import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
import org.gwtopenmaps.openlayers.client.handler.Handler;
import org.gwtopenmaps.openlayers.client.layer.Vector;
import org.gwtopenmaps.openlayers.client.util.JSObject;

/**
 *
 *  Don't be suprised by the following:
 *  Upon activating the DrawFeature tool it creates an extra layer
 *  that is used by the handler (the name of this layer reflects this).
 *
 * (tested in OpenLayers 2.7)
 *
 * @author Erdem Gunay
 * @author Edwin Commandeur - Atlis EJS
 *
 */
public class DrawFeature extends Control {

	public interface FeatureAddedListener {
		void onFeatureAdded(VectorFeature vectorFeature);
	}

	protected DrawFeature(JSObject element) {
		super(element);
	}

	/**
	 *
	 * @param layer
	 * @param handler - a PointHandler, PathHandler or PolygonHandler
	 */
	public DrawFeature(Vector layer, Handler handler) {
		this(DrawFeatureImpl.create(layer.getJSObject(), handler.getJSObject()));
	}

	/**
	 *
	 * @param layer
	 * @param handler - a PointHandler, PathHandler or PolygonHandler
	 * @param options - see {@link DrawFeatureOptions}
	 */
	public DrawFeature(Vector layer, Handler handler, DrawFeatureOptions options){
		this(DrawFeatureImpl.create(layer.getJSObject(), handler.getJSObject(), options.getJSObject()));
	}
	
	/**
	 * This method returns the Handler associated to the control. The CLASS_NAME
	 * of the handler depends on the kind of control.
	 * 
	 * @return Handler
	 */
	public Handler getHandler() {
		return Handler.narrowToHandler(DrawFeatureImpl
				.getHandler(getJSObject()));
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy