com.supermap.mapping

Class ThemeRange



  • public class ThemeRange
    extends Theme
    The ThemeRange class.

    In Ranges Map, a field or an expression, which is regarded as the thematic variable, can be separated into several ranges according to a certain range method. Each feature or record is separated into a certain range in terms of the thematic variable.

    Note:

    When making the ThemeRange map, if the tail and head range haven't been set style, and without setting the default style, then the tail and head range will be set to the same style as the first range which the user specified.

    Example:
    The following code demonstrates how to create a new ranges map. Suppose there is a MapControl object and an open workspace object with a World datasource.
     public void makeThemeRangeMap() {
            // Creates range thematic map
            ThemeRange themeRangeMap = new ThemeRange();
            themeRangeMap.setRangeExpression("Pop_1994");
            
            // The setting of filling style
            GeoStyle geoStyle = new GeoStyle();
            geoStyle.setLineColor(Color.WHITE);
            geoStyle.setLineWidth(0.3);
    
            // The setting of range thematic map item for the population is less than 1 million
            ThemeRangeItem themeRangeItem1 = new ThemeRangeItem();
            themeRangeItem1.setCaption("<1000000");
            themeRangeItem1.setEnd(1000000);
            themeRangeItem1.setStart(0);
            themeRangeItem1.setVisible(true);
            geoStyle.setFillForeColor(new Color(209, 182, 210));
            themeRangeItem1.setStyle(geoStyle);
    
            // The setting of range thematic map item for the population is more than 1 million
            ThemeRangeItem themeRangeItem2 = new ThemeRangeItem();
            themeRangeItem2.setCaption(">1000000");
            themeRangeItem2.setEnd(10000000);
            themeRangeItem2.setStart(1000000);
            themeRangeItem2.setVisible(true);
            geoStyle.setFillForeColor(new Color(205, 167, 183));
            themeRangeItem2.setStyle(geoStyle);
    
            // The setting of range thematic map item for the population is less than 10 million
            ThemeRangeItem themeRangeItem3 = new ThemeRangeItem();
            themeRangeItem3.setCaption(">10000000");
            themeRangeItem3.setEnd(100000000);
            themeRangeItem3.setStart(10000000);
            themeRangeItem3.setVisible(true);
            geoStyle.setFillForeColor(new Color(183, 128, 151));
            themeRangeItem3.setStyle(geoStyle);
    
            // The setting of range thematic map item for the population is less than 100 million
            ThemeRangeItem themeRangeItem4 = new ThemeRangeItem();
            themeRangeItem4.setCaption(">100000000");
            themeRangeItem4.setEnd(120000000);
            themeRangeItem4.setStart(100000000);
            themeRangeItem4.setVisible(true);
            geoStyle.setFillForeColor(new Color(164, 97, 136));
            themeRangeItem4.setStyle(geoStyle);
            
            // The setting of range thematic map item for the population is less than 1200 million
            ThemeRangeItem themeRangeItem5 = new ThemeRangeItem();
            themeRangeItem5.setCaption(">1200000000");
            themeRangeItem5.setEnd(Double.MAX_VALUE);
            themeRangeItem5.setStart(120000000);
            themeRangeItem5.setVisible(true);
            geoStyle.setFillForeColor(new Color(94, 53, 77));
            themeRangeItem5.setStyle(geoStyle);
    
            //Adds the thematic map item into the thematic map object
            themeRangeMap.addToHead(themeRangeItem1);
            themeRangeMap.addToTail(themeRangeItem2);
            themeRangeMap.addToTail(themeRangeItem3);
            themeRangeMap.addToTail(themeRangeItem4);
            themeRangeMap.addToTail(themeRangeItem5);
    
            //Shows
            MapControl mapControl = new MapControl();
            mapControl.getMap().setWorkspace(workspace);
            Layer layerTheme = mapControl.getMap().getLayers().add(targetDataset,themeRangeMap, true);
            mapControl.getMap().refresh();
    
            //Releases resources
            mapControl.dispose();
            workspace.dispose();
        }
     
    • Constructor Summary

      Constructors 
      Constructor and Description
      ThemeRange()
      The default constructor for constructing a new object.
      ThemeRange(ThemeRange themeRange)
      Copy constructor, initializes a new instance of the class which is identical with the specified ImportSettingGML object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean addToHead(ThemeRangeItem item)
      Adds an ThemeRangeItem object to the head of the range list.
      boolean addToHead(ThemeRangeItem item, boolean normalize)
      Adds an ThemeRangeItem object to the head of the range list.
      boolean addToTail(ThemeRangeItem item)
      Adds a ThemeRangeItem object to the tail of the range list.
      boolean addToTail(ThemeRangeItem item, boolean normalize)
      Adds a ThemeRangeItem object to the tail of the range list.
      void clear()
      Clears all the items of the ranges map.
      void dispose()
      Disposes the resources occupied by the object.
      int getCount()
      Returns the count of the ranges in the ranges map.
      double getCustomInterval()
      Gets the custom range interval.
      ThemeRangeItem getItem(int index)
      Returns the ranges map item with the specified index in range thematic map.
      java.lang.String getOffsetX()
      Returns the X offset.
      java.lang.String getOffsetY()
      Returns the Y offset.
      double getPrecision()
      Returns the range precision for the ranges map.
      java.lang.String getRangeExpression()
      Returns the field expression.
      RangeMode getRangeMode()
      Returns the current range mode.
      int indexOf(double value)
      Returns the index of the ranges map item with the specified field value in the item list.
      boolean isOffsetFixed()
      Returns whether to fix the offsets.
      static ThemeRange makeDefault(DatasetVector dataset, java.lang.String rangeExpression, RangeMode rangeMode, double rangeParameter)
      Makes the default range map with the given dataset, rangeExpression, rangeMode and rangeParameter.
      static ThemeRange makeDefault(DatasetVector dataset, java.lang.String rangeExpression, RangeMode rangeMode, double rangeParameter, ColorGradientType colorGradientType)
      Makes the default range map with the given dataset, rangeExpression, rangeMode, rangeParameter and colorGradientType.
      static ThemeRange makeDefault(DatasetVector dataset, java.lang.String rangeExpression, RangeMode rangeMode, double rangeParameter, ColorGradientType colorGradientType, JoinItems joinItems)
      Makes the default range map with the given dataset, rangeExpression, rangeMode, rangeParameter, colorGradientType and joinItems.
      static ThemeRange makeDefault(DatasetVector dataset, java.lang.String rangeExpression, RangeMode rangeMode, double rangeParameter, ColorGradientType colorGradientType, JoinItems joinItems, double precision)
      Makes the default range map with the given dataset, rangeExpression, rangeMode, rangeParameter, colorGradientType, joinItems, and rangePrecision.
      boolean merge(int index, int count, GeoStyle style, java.lang.String caption)
      Merges the specified counts of ranges map items from the specified index and assign the style and caption to the new item.
      void reverseStyle()
      Displays the ThemeRangeItem object with the reverse style in the ranges map.
      void setOffsetFixed(boolean value)
      Sets whether to fix the offsets.
      void setOffsetX(java.lang.String value)
      Sets the X offset.
      void setOffsetY(java.lang.String value)
      Sets the Y offset.
      void setPrecision(double value)
      Sets the range precision for the ranges map.
      void setRangeExpression(java.lang.String value)
      Sets the range field expression.
      boolean split(int index, double splitValue, GeoStyle style1, java.lang.String caption1, GeoStyle style2, java.lang.String caption2)
      Splits a ranges map item with a specified index into items with separate styles and names.
      java.lang.String toString()
      Outputs the formatted string for the ranges thematic map.
      • Methods inherited from class java.lang.Object

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

      • ThemeRange

        public ThemeRange()
        The default constructor for constructing a new object.
      • ThemeRange

        public ThemeRange(ThemeRange themeRange)
        Copy constructor, initializes a new instance of the class which is identical with the specified ImportSettingGML object.
        Parameters:
        themeRange - The specified ThemeRange object.
    • Method Detail

      • getItem

        public ThemeRangeItem getItem(int index)
        Returns the ranges map item with the specified index in range thematic map. Fore more details about the ranges map item, please refer to .
        Parameters:
        index - The index of the specified ranges map item.
        Returns:
        The ranges map item with the specified index.
        See Also:
        ThemeRangeItem
      • getCount

        public int getCount()
        Returns the count of the ranges in the ranges map.
        Returns:
        The count of the ranges in the ranges map.
        Default:
        The default value is 0.
      • getRangeExpression

        public java.lang.String getRangeExpression()
        Returns the field expression.

        Compares the value of this expression of a feature and the range value to determine the range to which the feature belongs, so that you can set the different style for the features in the different range.

        Returns:
        The rangeExpression class.
        Default:
        The default is a null string.
      • setRangeExpression

        public void setRangeExpression(java.lang.String value)
        Sets the range field expression.

        Compares the value of this expression of a feature and the range value to determine the range to which the feature belongs, so that you can set the different style for the features in the different range.

        Parameters:
        value - The range field expression.
      • addToHead

        public boolean addToHead(ThemeRangeItem item)
        Adds an ThemeRangeItem object to the head of the range list.
        Parameters:
        item - The ranges map item to be added.
        Returns:
        True, if successful; otherwise, false.
      • addToTail

        public boolean addToTail(ThemeRangeItem item)
        Adds a ThemeRangeItem object to the tail of the range list.
        Parameters:
        item - The ranges map item to be added.
        Returns:
        True, if successful; otherwise, false.
      • addToHead

        public boolean addToHead(ThemeRangeItem item,
                                 boolean normalize)
        Adds an ThemeRangeItem object to the head of the range list.
        Parameters:
        item - The ranges map item to be added.
        normalize - Whether to normalize or not. If true, normalize the value of item if it is invalid; otherwise, throw an exception if the value of item is invalid.
        Returns:
        True, if successful; otherwise, false.
      • addToTail

        public boolean addToTail(ThemeRangeItem item,
                                 boolean normalize)
        Adds a ThemeRangeItem object to the tail of the range list.
        Parameters:
        item - The ranges map item to be added.
        normalize - Whether to normalize or not. If true, normalize the value of item if it is invalid; otherwise, throw an exception if the value of item is invalid.
        Returns:
        True, if successful; otherwise, false.
      • split

        public boolean split(int index,
                             double splitValue,
                             GeoStyle style1,
                             java.lang.String caption1,
                             GeoStyle style2,
                             java.lang.String caption2)
        Splits a ranges map item with a specified index into items with separate styles and names. Note: The splitValue must be in the range for split, that is, greater than the start value and less than the end value of the ranges map item to split. If the condition is not satisfied, an exception will be thrown.
        Parameters:
        index - The index of the specified ranges map item.
        splitValue - The specified value for splitting ranges.
        style1 - The style of one of the two split ranges map items.
        caption1 - The name of one of the two split ranges map items.
        style2 - The style of one of the two split ranges map items.
        caption2 - The name of one of the two split ranges map items.
        Returns:
        Returns true if successful; otherwise returns false.
      • merge

        public boolean merge(int index,
                             int count,
                             GeoStyle style,
                             java.lang.String caption)
        Merges the specified counts of ranges map items from the specified index and assign the style and caption to the new item. Those merged items will be disposed after calling this method.
        Parameters:
        index - The index of the specified ranges map item. This index serves as the start index.
        count - The count of ranges map items to be merged, counting from the specified index.
        style - The style of merged ThemeRangeItem.
        caption - The caption of the merged ThemeRangeItem..
        Returns:
        If merging successfully, returns true; otherwise false.
      • makeDefault

        public static ThemeRange makeDefault(DatasetVector dataset,
                                             java.lang.String rangeExpression,
                                             RangeMode rangeMode,
                                             double rangeParameter)
        Makes the default range map with the given dataset, rangeExpression, rangeMode and rangeParameter.
        Parameters:
        dataset - The vector dataset.
        rangeExpression - Range expression
        rangeMode - The range modes include the equidistant, square root, standard deviation, log, equal-counting, and the custom distance method.
        rangeParameter - If the range mode is the equal interval mode, the square root mode, the log mode, or the quantile mode, this parameter is for setting the range number and is required; if the range mode is the standard deviation mode, this parameter does not apply; if the range mode is the custom interval mode, this parameter is used to set the custom intervals.
        Returns:
        Creates a new instance of the ThemeRange class.
      • makeDefault

        public static ThemeRange makeDefault(DatasetVector dataset,
                                             java.lang.String rangeExpression,
                                             RangeMode rangeMode,
                                             double rangeParameter,
                                             ColorGradientType colorGradientType)
        Makes the default range map with the given dataset, rangeExpression, rangeMode, rangeParameter and colorGradientType.
        Parameters:
        dataset - The vector dataset.
        rangeExpression - Range expression
        rangeMode - The range modes include the equidistant, square root, standard deviation, log, equal-counting, and the custom distance method.
        rangeParameter - If the range mode is the equal interval mode, the square root mode, the log mode, or the quantile mode, this parameter is for setting the range number and is required; if the range mode is the standard deviation mode, this parameter does not apply; if the range mode is the custom interval mode, this parameter is used to set the custom intervals.
        colorGradientType - Color gradient type.
        Returns:
        Creates a new instance of the ThemeRange class.
      • makeDefault

        public static ThemeRange makeDefault(DatasetVector dataset,
                                             java.lang.String rangeExpression,
                                             RangeMode rangeMode,
                                             double rangeParameter,
                                             ColorGradientType colorGradientType,
                                             JoinItems joinItems)
        Makes the default range map with the given dataset, rangeExpression, rangeMode, rangeParameter, colorGradientType and joinItems.
        Parameters:
        dataset - The vector dataset.
        rangeExpression - Range expression
        rangeMode - The range modes include the equidistant, square root, standard deviation, log, equal-counting, and the custom distance method.
        rangeParameter - If the range mode is the equal interval mode, the square root mode, the log mode, or the quantile mode, this parameter is for setting the range number and is required; if the range mode is the standard deviation mode, this parameter does not apply; if the range mode is the custom interval mode, this parameter is used to set the custom intervals.
        colorGradientType - Color gradient type.
        joinItems - External join items
        Returns:
        Creates a new instance of the ThemeRange class.
      • makeDefault

        public static ThemeRange makeDefault(DatasetVector dataset,
                                             java.lang.String rangeExpression,
                                             RangeMode rangeMode,
                                             double rangeParameter,
                                             ColorGradientType colorGradientType,
                                             JoinItems joinItems,
                                             double precision)
        Makes the default range map with the given dataset, rangeExpression, rangeMode, rangeParameter, colorGradientType, joinItems, and rangePrecision.
        Parameters:
        dataset - The specified vector dataset.
        rangeExpression - Range expression
        rangeMode - The RangeMode class. The class includes the equal interval, square root, standard deviation, logarithm, quantile and customer Interval. Please refer to the class.
        rangeParameter - If the range mode is the equal interval mode, the square root mode, the log mode, or the quantile mode, this parameter is for setting the range number and is required; if the range mode is the standard deviation mode, this parameter does not apply; if the range mode is the custom interval mode, this parameter is used to set the custom intervals.
        colorGradientType - Color gradient type.
        joinItems - External join items
        precision - The precision of the segmentation value. For example, if the calculated segmentation value is 13.02145 and the segmentation accuracy is 0.001, the adopted segmentation value would be 13.021.
        Returns:
        Creates a new instance of the ThemeRange class.
      • getPrecision

        public double getPrecision()
        Returns the range precision for the ranges map.
        Returns:
        The range precision.
      • setPrecision

        public void setPrecision(double value)
        Sets the range precision for the ranges map.
        Parameters:
        value - round precision.
      • indexOf

        public int indexOf(double value)
        Returns the index of the ranges map item with the specified field value in the item list.
        Parameters:
        value - The given field values for segmentation.
        Returns:
        The index number of the item of the ranges. If the item of the ranges does not exist, returns -1.
      • reverseStyle

        public void reverseStyle()
        Displays the ThemeRangeItem object with the reverse style in the ranges map. For example, there are three ranges in a thematic map; they are item1, item2, item3. After calling this method, the display style of item3 and item1 will reverse and the item2 will not change.
      • clear

        public void clear()
        Clears all the items of the ranges map. All the ThemeRangeItem objects will be disposed after calling this method.
      • toString

        public java.lang.String toString()
        Outputs the formatted string for the ranges thematic map. The formatted string provides the information about the thematic map settings and it cannot be used for import and display of the thematic map like what the XML string can do.
        1. For raster ranges map, the format is {Caption="china", Start=10 End=20, Visible=true?false, Style={linestyle=,markerstyle=,fillstyle=} };
        2. For raster unique map, the format is {Caption="china", Unique =20, Visible=true?false, Style={linestyle=,markerstyle=,fillstyle=} };
        3. For labels map, the format is {Caption="China", Start=10 End=20, Visible=true, Style={name=,width=,height=,color=()} };
        4. For ranges map, the format is {Caption="china", Start=10 End=20, Visible=true?false, Style={linestyle=,markerstyle=,fillstyle=} };
        5. For unqiue values map, the format is {Caption="china", Unique =20, Visible=true?false, Style={linestyle=,markerstyle=,fillstyle=} };
        Specified by:
        toString in class Theme
        Returns:
        The formatted string for the thematic map.
      • dispose

        public void dispose()
        Disposes the resources occupied by the object. After calling this method, this object will not be usable.
      • getRangeMode

        public RangeMode getRangeMode()
        Returns the current range mode.
        Returns:
        The current range mode.
      • getOffsetX

        public java.lang.String getOffsetX()
        Returns the X offset.
        Returns:
        The X offset.
      • setOffsetX

        public void setOffsetX(java.lang.String value)
        Sets the X offset.
        Parameters:
        value - X offset
      • getOffsetY

        public java.lang.String getOffsetY()
        Returns the Y offset.
        Returns:
        The Y offset.
      • setOffsetY

        public void setOffsetY(java.lang.String value)
        Sets the Y offset.
        Parameters:
        value - Y offset
      • isOffsetFixed

        public boolean isOffsetFixed()
        Returns whether to fix the offsets.
        Returns:
        True if the offset of the label is fixed; false otherwise.
      • setOffsetFixed

        public void setOffsetFixed(boolean value)
        Sets whether to fix the offsets.
        Parameters:
        value - True means to fix the offsets; otherwise, false.
      • getCustomInterval

        public double getCustomInterval()
        Gets the custom range interval.
        Returns:
        The custom range interval.