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使用吧。
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使用吧。
相关文章推荐
- ArcGIS Server Java ADF 案例教程 28
- ArcGIS Server Java ADF 案例教程 v9.3.1 PDF 版本
- ArcGIS Server Java ADF 案例教程 26
- ArcGIS Server Java ADF 案例教程 20
- ArcGIS Server Java ADF 案例教程 23
- ArcGIS Server Java ADF 案例教程 8
- ArcGIS Server Java ADF 案例教程 32
- ArcGIS Server Java ADF 案例教程 24
- ArcGIS Server Java ADF 案例教程 27
- ArcGIS Server Java ADF 案例教程 5
- ArcGIS Server Java ADF 案例教程 36
- ArcGIS Server Java ADF 案例教程 37
- ArcGIS Server Java ADF 案例教程 2
- ArcGIS Server Java ADF 案例教程 6
- ArcGIS Server Java ADF 案例教程 41
- ArcGIS Server Java ADF 案例教程 14
- ArcGIS Server Java ADF 案例教程 29
- ArcGIS Server Java ADF 案例教程 30
- ArcGIS Server Java ADF案例教程
- ArcGIS Server Java ADF 案例教程 18