clearwebgraphicsadapter.java

来自「esri的ArcGIS Server超级学习模板程序(for java)」· Java 代码 · 共 70 行

JAVA
70
字号
package com.esri.solutions.jitk.web.tasks.mapcomp;

import com.esri.adf.web.data.WebContext;
import com.esri.adf.web.data.WebGraphics;
import com.esri.solutions.jitk.web.tasks.IWebContextAware;

/**
 * Clears the graphics on the Map managed in the {@link WebGraphics} object.  The
 * graphics in WebGraphics will be cleared when a Map Composition is created or
 * opened.  Only the {@link #created(MapCompositionEvent)} and {@link #opened(MapCompositionEvent)}
 * methods are implemented by this class.
 */
public class ClearWebGraphicsAdapter implements IMapCompositionEventObserver {

	/*
	 * (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.tasks.mapcomp.IMapCompositionEventObserver#created(com.esri.solutions.jitk.web.tasks.mapcomp.MapCompositionEvent)
	 */
	public void created(MapCompositionEvent event) {
		if (event.getSource() instanceof IWebContextAware) {
			IWebContextAware ctxAware = (IWebContextAware) event.getSource();
			WebContext ctx = ctxAware.getContext();
			WebGraphics graphics = ctx.getWebGraphics();
			clearGraphics(graphics);
		}

	}
	
	/*
	 * (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.tasks.mapcomp.IMapCompositionEventObserver#deleted(com.esri.solutions.jitk.web.tasks.mapcomp.MapCompositionEvent)
	 */
	public void deleted(MapCompositionEvent event) {
	}

	/*
	 * (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.tasks.mapcomp.IMapCompositionEventObserver#opened(com.esri.solutions.jitk.web.tasks.mapcomp.MapCompositionEvent)
	 */
	public void opened(MapCompositionEvent event) {
		if (event.getSource() instanceof IWebContextAware) {
			IWebContextAware ctxAware = (IWebContextAware) event.getSource();
			WebContext ctx = ctxAware.getContext();
			WebGraphics graphics = ctx.getWebGraphics();
			clearGraphics(graphics);
		}
	}

	/*
	 * (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.tasks.mapcomp.IMapCompositionEventObserver#saved(com.esri.solutions.jitk.web.tasks.mapcomp.MapCompositionEvent)
	 */
	public void saved(MapCompositionEvent event) {
		

	}

	/**
	 * Clears the graphics within the {@link WebGraphics} object in the
	 * {@link WebContext}.
	 * 
	 * @param graphics	Reference to {@link WebGraphics}.
	 */
	private void clearGraphics(WebGraphics graphics) {
		if (graphics != null) {
			graphics.clearGraphics();
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?