您的位置:首页 > 编程语言 > Java开发

ArcGIS Server Java ADF 案例教程 28

2009-08-18 16:59 435 查看
在上一小节最后说马上要讲Graphic,为了和ADF本身的称呼统一,现在这里我们将其称为GraphicElement。由于Blogger被河蟹了,以前的文章我就先不修改了,下面我们来谈一下GraphicElement。

GraphicElement
要说GraphicElement就得先说WebGraphics,欲用GraphicElement,必先添加WebGraphics,在你的配置文件中你应该可以找到如下的定义:

<managed-bean>

<managed-bean-name>graphics</managed-bean-name>

<managed-bean-class>com.esri.adf.web.data.WebGraphics</managed-bean-class>

<managed-bean-scope>none</managed-bean-scope>

</managed-bean>

这个WebGraphics对象的作用就是在服务器端存放所有你需要动态表示的GraphicElement。当然,现在我们已经很熟悉应该怎么去调用WebGraphics对象了:首先肯定要得到WebContext对象,然后在它的attribute中找到WebGraphics对象。

在WebGraphics对象中添加GraphicElement以后,这些GraphicElement就可以自动在Map中渲染出来,它们和后台服务没有关系,WebGraphics中的对象会在后台服务的上层被绘制出来的。下面就让我们改写一下上一小节中的代码,在显示查询结果的时候不使用QueryResult的highlight方法,而是手动把每个GraphicElement添加到WebGraphics中去。

webGraphics.clearGraphics();

for
(int
i = 0; i < listQueryResult.size(); i++)

{

QueryResult queryResult = listQueryResult.get(i);

//queryResult.highlight();

GraphicElement element = new
GraphicElement();

element.setGeometry(queryResult.getHighlightGeometry());

element.setSymbol(symbol);

webGraphics.addGraphics(element);

}

这里我们还通过setSymbol方法给这些GraphicElement设置了一个符号,这个符号的定义在上面的代码中被省略了,在下面一小节我们就重点看一下都有什么符号可以被GraphicElement使用吧。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: