public class Selection
extends java.lang.Object
 该类用于处理地图上被选中的对象。与该类紧密相连的类是 Recordset
 记录集类。通常可以通过选择集类返回地图的选择信息或设置地图上的选中情况。通过与 Recordset 的交互,就可以处理与选中对象相对应的数据。
 
          假设打开了一个工作空间 workspace 对象,工作空间中存在名为 World 的数据源。
          
 public void selectionTest() {
        // 返回数据集,该数据集包含表示人口数量的 Pop_1994 字段
        DatasetVector datasetvector = (DatasetVector) workspace.getDatasources()
                        .get(0).getDatasets().get("World");
        Layer layer = m_mapControl.getMap().getLayers.add(datasetVector, true);
 
        // 根据 ID 进行查询,返回查询结果记录集
        Recordset recordset = datasetvector.query(new int[] { 0, 1, 2, 3, 4, 5, 6,
                        7, 8, 9, 10, 11, 18, 19 }, CursorType.STATIC);
 
        // 设置选择集的风格
        Selection selection = layer.getSelection();
        GeoStyle style = new GeoStyle();
        style.setLineColor(java.awt.Color.cyan);
        style.setLineSymbolID(5);
        style.setLineWidth(3.0);
        selection.setStyle(style);
        
        // 从记录集获取选择集
        selection.fromRecordset(recordset);
 
        // 移除从序号1到10的几何对象
        selection.removeRange(1, 10);
 
        m_mapControl.getMap().refresh();
 
        // 将选择集转化为记录集
        Recordset recordset1 = selection.toRecordset();
 
        // 统计人口最大值
        double maxValue = recordset1.statistic("Pop_1994", StatisticMode.MAX);
        System.out.println("人口最大值" + maxValue);
 
        // 清空选择集
        selection.clear();
 
        // 释放资源
        recordset1.dispose();
        recordset.dispose();
        selection.dispose();
 }
 | 构造器和说明 | 
|---|
Selection()
默认构造函数,构造一个新的  
Selection 对象。 | 
Selection(DatasetVector dataset)
根据指定的参数构造  
Selection 类的新实例。 | 
Selection(Selection selection)
拷贝构造函数,根据给定的  
Selection 对象构造一个与其完全相同的新对象。 | 
| 限定符和类型 | 方法和说明 | 
|---|---|
int | 
add(int geometryID)
用于向选择集中加入几何对象。 
 | 
void | 
clear()
将选择集清空,这样被选中的对象将全部恢复到未选中状态。 
 | 
void | 
dispose()
释放该对象所占用的资源。 
 | 
boolean | 
fromRecordset(Recordset recordset)
用于把一个记录集转化为选择集(即记录集所对应的对象全部呈选中状态)。 
 | 
int | 
get(int index)
根据属性数据中SmID 字段的值返回选择集中指定几何对象的系统 ID。 
 | 
int | 
getCount()
返回选择集中几何对象的个数。 
 | 
DatasetVector | 
getDataset()
返回选择集中几何对象所在的数据集。 
 | 
GeoStyle | 
getStyle()
返回选择集几何对象的显示风格。 
 | 
boolean | 
remove(int geometryID)
用于从选择集中删除一个几何对象,该几何对象由原来的呈选中状态变为非选中状态。 
 | 
int | 
removeRange(int index,
           int count)
用于从选择集中删除指定的若干几何对象,这些几何对象由原来的选中状态变为非选中状态。 
 | 
void | 
setDataset(DatasetVector dataset)
设置选择集中几何对象所在的数据集。 
 | 
void | 
setStyle(GeoStyle style)
设置选择集几何对象的显示风格。 
 | 
Recordset | 
toRecordset()
用于把选择对象转化为记录集。 
 | 
public Selection(DatasetVector dataset)
Selection 类的新实例。dataset - 指定的数据集。public Selection(Selection selection)
Selection 对象构造一个与其完全相同的新对象。selection - 指定的 Selection 对象。public Selection()
Selection 对象。public int getCount()
public int get(int index)
index - 属性数据中SmID 字段的值public DatasetVector getDataset()
public boolean fromRecordset(Recordset recordset)
recordset - 要转化为选择集的记录集。public Recordset toRecordset()
public void setDataset(DatasetVector dataset)
dataset - 选择集中几何对象所在的数据集。public GeoStyle getStyle()
public void setStyle(GeoStyle style)
style - 选择集几何对象的显示风格。public int add(int geometryID)
geometryID - 新添加的几何对象的 ID 值(即其属性数据中 SmID 字段的值)。public boolean remove(int geometryID)
geometryID - 要删除几何对象的 ID 号(即其属性数据中 SmID 字段的值)public int removeRange(int index,
                       int count)
index - 要删除的第一个几何对象的序列号。count - 要删除的几何对象的个数。public void clear()
public void dispose()