com.supermap.mapping

Class Selection

  • java.lang.Object
    • com.supermap.mapping.Selection


  • public class Selection
    extends java.lang.Object
    The Selection class.

    This class is used to process the selected objects in the map. This class is closely links to Recordset The recordset class. It usually obtains the Selection information of maps or sets the selection information through the Selection. The data corresponding to the selected data can be handled through the interaction with the Recordset class.

    Example:
    The following example demonstrates how to get the selection from recordset and get the maximum statistic value of population of the selection(the Pop_1994 field represents the population).

    Suppose we open a workspace workspace object that contains the World datasource.

     public void selectionTest() {
            //Returns the dataset, which contains the Pop_1994 field which represents the population
            DatasetVector datasetvector = (DatasetVector) workspace.getDatasources()
                            .get(0).getDatasets().get("World");
            Layer layer = m_mapControl.getMap().getLayers.add(datasetVector, true);
     
            //ID query, returns the result recordset
            Recordset recordset = datasetvector.query(new int[] { 0, 1, 2, 3, 4, 5, 6,
                            7, 8, 9, 10, 11, 18, 19 }, CursorType.STATIC);
     
            //Sets the style of the selection
            Selection selection = layer.getSelection();
            GeoStyle style = new GeoStyle();
            style.setLineColor(java.awt.Color.cyan);
            style.setLineSymbolID(5);
            style.setLineWidth(3.0);
            selection.setStyle(style);
            
            //Gets the selection from the recordset
            selection.fromRecordset(recordset);
     
            //Removes the geometries from index 1 to 10
            selection.removeRange(1, 10);
     
            m_mapControl.getMap().refresh();
     
            //Convert the selection to recordset
            Recordset recordset1 = selection.toRecordset();
     
            //The maximum value of the statistics population
            double maxValue = recordset1.statistic("Pop_1994", StatisticMode.MAX);
            System.out.println("The maximum value of the statistics population" + maxValue);
     
            //Clear the selection
            selection.clear();
     
            //Release resource.
            recordset1.dispose();
            recordset.dispose();
            selection.dispose();
     }
     
    • Constructor Summary

      Constructors 
      Constructor and Description
      Selection()
      The default constructor for constructing a new Selection object.
      Selection(DatasetVector dataset)
      Initializes a new instance of the Selection class with the specified parameters.
      Selection(Selection selection)
      Copy constructor, initializes a new instance of the class which is identical with the specified ImportSettingGML object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int add(int geometryID)
      Adds a new geometric object to the selection.
      void clear()
      Clears all the objects in the Selection.
      void dispose()
      Release the resource occupy by this object.
      boolean fromRecordset(Recordset recordset)
      Converts a Recordset to a Selection which will make all corresponded objects be selected.
      int get(int index)
      Returns the system ID of the specified geometric objects in the Selection according to the SmID field of attribute data.
      int getCount()
      Returns the number of geometric objects in the Selection.
      DatasetVector getDataset()
      Returns the dataset of the geometric objects belongs to in the Selection.
      GeoStyle getStyle()
      Returns the style of the geometric objects in the Selection.
      boolean remove(int geometryID)
      Removes a specified geometric object from the Selection and makes it unselected.
      int removeRange(int index, int count)
      Removes the specified geometric objects from the Selection and makes them unselected.
      void setDataset(DatasetVector dataset)
      Sets the dataset of the geometric objects belongs to in the Selection.
      void setStyle(GeoStyle style)
      Sets the style of the geometric objects in the Selection.
      Recordset toRecordset()
      Converts the Selection to the Recordset, Where, the data in the Selection can be operated after converting.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Selection

        public Selection(DatasetVector dataset)
        Initializes a new instance of the Selection class with the specified parameters.
        Parameters:
        dataset - The specified dataset.
      • Selection

        public Selection(Selection selection)
        Copy constructor, initializes a new instance of the class which is identical with the specified ImportSettingGML object.
        Parameters:
        selection - the specified Selection object.
      • Selection

        public Selection()
        The default constructor for constructing a new Selection object.
    • Method Detail

      • getCount

        public int getCount()
        Returns the number of geometric objects in the Selection.
        Returns:
        The number of geometric objects in the Selection.
        Default:
        The default value is 0. There are no geometric objects in the Selection.
      • get

        public int get(int index)
        Returns the system ID of the specified geometric objects in the Selection according to the SmID field of attribute data.
        Parameters:
        index - The SmID field in attribute data
        Returns:
        int The system ID of the specified geometric object in the Selection.
      • getDataset

        public DatasetVector getDataset()
        Returns the dataset of the geometric objects belongs to in the Selection.
        Returns:
        The dataset of the geometric objects belongs to in the Selection.
        Default:
        The default value is Null.
      • fromRecordset

        public boolean fromRecordset(Recordset recordset)
        Converts a Recordset to a Selection which will make all corresponded objects be selected.
        Parameters:
        recordset - The Recordset to be converted to a Selection.
        Returns:
        A boolean, returns true if the conversion is successfully; false otherwise.
      • toRecordset

        public Recordset toRecordset()
        Converts the Selection to the Recordset, Where, the data in the Selection can be operated after converting.
        Returns:
        The recordset which contains all the fields.
      • setDataset

        public void setDataset(DatasetVector dataset)
        Sets the dataset of the geometric objects belongs to in the Selection.
        Parameters:
        dataset - The dataset of the geometric objects belongs to in the Selection.
      • getStyle

        public GeoStyle getStyle()
        Returns the style of the geometric objects in the Selection.
        Returns:
        The style of the geometric objects in the Selection.
        Default:
        The default value is {FillBackColor=Color [A=255, R=255, G=255, B=255],FillForeColor=Color [A=255, R=189, G=235, B=255],FillGradientAngle =0,FillGradientMode=None,FillGradientOffsetRatioX =0,FillGradientOffsetRatioY =0,FillOpaqueRate=100,FillSymbolID=1,LineColor=Color [A=255, R=0, G=0, B=255],LineSymbolID=0,LineWidth=0.1,MarkerAngle=0,MarkerSize ={Width=2.4,Height=2.4},MarkerSymbolID=0}
      • setStyle

        public void setStyle(GeoStyle style)
        Sets the style of the geometric objects in the Selection.
        Parameters:
        style - The style of the geometric objects in the Selection.
      • add

        public int add(int geometryID)
        Adds a new geometric object to the selection.
        Parameters:
        geometryID - The ID value (i.e., the value of the SmID field in the attribute table) of the newly added geometric objects.
        Returns:
        The index of the newly added geometric object in the selection.
      • remove

        public boolean remove(int geometryID)
        Removes a specified geometric object from the Selection and makes it unselected.
        Parameters:
        geometryID - The ID (i.e., the value of the SmID field in the attribute table) of the geometric object to be deleted.
        Returns:
        returns true if successful; otherwise false.
      • removeRange

        public int removeRange(int index,
                               int count)
        Removes the specified geometric objects from the Selection and makes them unselected.
        Parameters:
        index - The index of the first geometric object to be deleted.
        count - The count of the geometry objects to be removed.
        Returns:
        The count of geometric objects deleted successfully.
      • clear

        public void clear()
        Clears all the objects in the Selection. Then the status of the objects in the Selection is unselected.
      • dispose

        public void dispose()
        Release the resource occupy by this object.